From 87ac2b043a663720c84d0b7d923b7d9dca5391c1 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 2 Sep 2023 05:37:58 +0000 Subject: [PATCH 0001/1030] Add EXTRA_SRC build var. If set, it is treated like a list of files, each of which gets appended verbatim to sqlite3.c. The intent is to enable easily extending the amalgamation. Requested in/around [forum:3fcc655f0ac0efe8|forum post 3fcc655f0ac0efe8]. FossilOrigin-Name: 934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c --- Makefile.in | 6 ++++-- main.mk | 5 ++--- manifest | 19 +++++++++++-------- manifest.uuid | 2 +- tool/mksqlite3c.tcl | 12 +++++++++--- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Makefile.in b/Makefile.in index e3bf1c0e7a..16ebf098c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -782,7 +782,8 @@ mptest: mptester$(TEXE) touch .target_source sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl src-verify - $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(AMALGAMATION_LINE_MACROS) + $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(AMALGAMATION_LINE_MACROS) \ + $(EXTRA_SRC) cp tsrc/sqlite3ext.h . cp $(TOP)/ext/session/sqlite3session.h . @@ -793,7 +794,8 @@ sqlite3r.c: sqlite3.c sqlite3r.h cp $(TOP)/ext/recover/sqlite3recover.c tsrc/ cp $(TOP)/ext/recover/sqlite3recover.h tsrc/ cp $(TOP)/ext/recover/dbdata.c tsrc/ - $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl --enable-recover $(AMALGAMATION_LINE_MACROS) + $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl --enable-recover \ + $(AMALGAMATION_LINE_MACROS) $(EXTRA_SRC) sqlite3ext.h: .target_source cp tsrc/sqlite3ext.h . diff --git a/main.mk b/main.mk index d8c372430e..0efdec309c 100644 --- a/main.mk +++ b/main.mk @@ -230,7 +230,6 @@ SRC += \ SRC += \ $(TOP)/ext/misc/stmt.c - # FTS5 things # FTS5_HDR = \ @@ -645,7 +644,7 @@ target_source: $(SRC) $(TOP)/tool/vdbe-compress.tcl fts5.c touch target_source sqlite3.c: target_source $(TOP)/tool/mksqlite3c.tcl src-verify - tclsh $(TOP)/tool/mksqlite3c.tcl + tclsh $(TOP)/tool/mksqlite3c.tcl $(EXTRA_SRC) cp tsrc/sqlite3ext.h . cp $(TOP)/ext/session/sqlite3session.h . echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c @@ -657,7 +656,7 @@ sqlite3ext.h: target_source cp tsrc/sqlite3ext.h . sqlite3.c-debug: target_source $(TOP)/tool/mksqlite3c.tcl src-verify - tclsh $(TOP)/tool/mksqlite3c.tcl --linemacros=1 + tclsh $(TOP)/tool/mksqlite3c.tcl --linemacros=1 $(EXTRA_SRC) echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c cat sqlite3.c >>tclsqlite3.c echo '#endif /* USE_SYSTEM_SQLITE */' >>tclsqlite3.c diff --git a/manifest b/manifest index 09646366ed..902e4aba7d 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Second\shalf\sof\s[1c532e80]. -D 2023-09-01T11:10:09.238 +C Add\sEXTRA_SRC\sbuild\svar.\sIf\sset,\sit\sis\streated\slike\sa\slist\sof\sfiles,\seach\sof\swhich\sgets\sappended\sverbatim\sto\ssqlite3.c.\sThe\sintent\sis\sto\senable\seasily\sextending\sthe\samalgamation.\sRequested\sin/around\s[forum:3fcc655f0ac0efe8|forum\spost\s3fcc655f0ac0efe8]. +D 2023-09-02T05:37:58.754 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 345a8599cf8ff015db534cedad7af70a1a6c36e295b85d720966c18af836ed30 +F Makefile.in c0ee78a772a33c1b377eb8f8b6f456ca10ad4aee86de4c9fcd16490e7432bcdb F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 26c2d196391a285c279adb10fd6001774d9b243af94b700b681e4a49cd476684 F README.md 963d30019abf0cc06b263cd2824bce022893f3f93a531758f6f04ff2194a16a8 @@ -625,7 +625,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 5536159f62058714c972b5bd325c8d5ecd5c9b00b385dd2e1cbc17da70a711b2 +F main.mk 48632ee12ecb9157c8f662794051260933518b52c5b430c30c3852b6743a48bc F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2048,7 +2048,7 @@ F tool/mkshellc.tcl b7adf08b82de60811d2cb6af05ff59fc17e5cd6f3e98743c14eaaa3f8971 F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f -F tool/mksqlite3c.tcl 49e39b1e616abc92fd8c24445f2b0a38881825f764541e0026f72371f0d84b65 +F tool/mksqlite3c.tcl 4f366e3d1ddb28996a6763c847fa62e1452bb11ca702841485df77823ec94ea4 F tool/mksqlite3h.tcl d391cff7cad0a372ee1406faee9ccc7dad9cb80a0c95cae0f73d10dd26e06762 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 @@ -2115,8 +2115,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c532e807bf8466b67d9600ab9630a6736de77259e9a71ac435641715ee0e04b -R ea796b2653d720202144fba261cf7ada +P 8ca1d815a57be1fade59fb8ea5705c27b10294e4959c8a9c624f1623df6a5f63 +R 26961792cf57fe21537a8837bc1686c0 +T *branch * extra-src +T *sym-extra-src * +T -sym-trunk * Cancelled\sby\sbranch. U stephan -Z 3f0f478ea9581db06db30ac4b45877cc +Z 89876b5c6405dcc4d6d608637f43ad0e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2cefe103b6..f5b052c057 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ca1d815a57be1fade59fb8ea5705c27b10294e4959c8a9c624f1623df6a5f63 \ No newline at end of file +934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index 6def8fa447..bdbc01e496 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -17,7 +17,7 @@ # After the "tsrc" directory has been created and populated, run # this script: # -# tclsh mksqlite3c.tcl +# tclsh mksqlite3c.tcl [flags] [extra source files] # # The amalgamated SQLite code will be written into sqlite3.c # @@ -42,6 +42,7 @@ set linemacros 0 set useapicall 0 set enable_recover 0 set srcdir tsrc +set extrasrc [list] for {set i 0} {$i<[llength $argv]} {incr i} { set x [lindex $argv $i] @@ -63,8 +64,10 @@ for {set i 0} {$i<[llength $argv]} {incr i} { } elseif {[regexp {^-?-((help)|\?)$} $x]} { puts $help exit 0 - } else { + } elseif {[regexp {^-?-} $x]} { error "unknown command-line option: $x" + } else { + lappend extrasrc $x } } set in [open $srcdir/sqlite3.h] @@ -470,13 +473,16 @@ set flist { sqlite3session.c fts5.c stmt.c -} +} if {$enable_recover} { lappend flist sqlite3recover.c dbdata.c } foreach file $flist { copy_file $srcdir/$file } +foreach file $extrasrc { + copy_file $file +} puts $out \ "/* Return the source-id for this library */ From 2065a9b7305e43bb84e003242431d7f859511dad Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 2 Sep 2023 21:55:10 +0000 Subject: [PATCH 0002/1030] Also add support for EXTRA_SRC in the Makefile for MSVC. FossilOrigin-Name: bfc18ef4323cd73fc63cb93f18bdd9c3add41bea83c1cbc1c20de5c1e4296a60 --- Makefile.msc | 6 +++++- manifest | 17 +++++++---------- manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 3179e301ce..9b0f8c412f 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -16,6 +16,10 @@ TOP = . !IFNDEF USE_AMALGAMATION USE_AMALGAMATION = 1 !ENDIF + +!IFNDEF EXTRA_SRC +EXTRA_SRC = +!ENDIF # <> # Set this non-0 to enable full warnings (-W4, etc) when compiling. @@ -1904,7 +1908,7 @@ mptest: mptester.exe echo > .target_source sqlite3.c: .target_source sqlite3ext.h sqlite3session.h $(MKSQLITE3C_TOOL) src-verify.exe - $(TCLSH_CMD) $(MKSQLITE3C_TOOL) $(MKSQLITE3C_ARGS) + $(TCLSH_CMD) $(MKSQLITE3C_TOOL) $(MKSQLITE3C_ARGS) $(EXTRA_SRC) sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl diff --git a/manifest b/manifest index 902e4aba7d..f2e0fcdcfc 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Add\sEXTRA_SRC\sbuild\svar.\sIf\sset,\sit\sis\streated\slike\sa\slist\sof\sfiles,\seach\sof\swhich\sgets\sappended\sverbatim\sto\ssqlite3.c.\sThe\sintent\sis\sto\senable\seasily\sextending\sthe\samalgamation.\sRequested\sin/around\s[forum:3fcc655f0ac0efe8|forum\spost\s3fcc655f0ac0efe8]. -D 2023-09-02T05:37:58.754 +C Also\sadd\ssupport\sfor\sEXTRA_SRC\sin\sthe\sMakefile\sfor\sMSVC. +D 2023-09-02T21:55:10.922 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in c0ee78a772a33c1b377eb8f8b6f456ca10ad4aee86de4c9fcd16490e7432bcdb F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 26c2d196391a285c279adb10fd6001774d9b243af94b700b681e4a49cd476684 +F Makefile.msc 4d7da1cd760e595cf751f8b3220c0b20657b20969713803ea538f66950453828 F README.md 963d30019abf0cc06b263cd2824bce022893f3f93a531758f6f04ff2194a16a8 F VERSION 4c09b629c03b8ae32317cb336a32f3aa3252841d6dcd51184cecc4278d08f21e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -2115,11 +2115,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8ca1d815a57be1fade59fb8ea5705c27b10294e4959c8a9c624f1623df6a5f63 -R 26961792cf57fe21537a8837bc1686c0 -T *branch * extra-src -T *sym-extra-src * -T -sym-trunk * Cancelled\sby\sbranch. -U stephan -Z 89876b5c6405dcc4d6d608637f43ad0e +P 934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c +R c273c661c255a780f4edcaa61a31a00b +U mistachkin +Z 47e1eabb65e7f37ad8c0f6188be76f6d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f5b052c057..9687ff42b9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c \ No newline at end of file +bfc18ef4323cd73fc63cb93f18bdd9c3add41bea83c1cbc1c20de5c1e4296a60 \ No newline at end of file From 45cf8ad02a30f76212f7b1c00fa45b00e8626eb6 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 3 Sep 2023 15:01:11 +0000 Subject: [PATCH 0003/1030] In mksqlite3c.tcl, pass EXTRA_SRC files through verbatim instead of applying the post-processing needed for sqlite's own source files. FossilOrigin-Name: 44f3d7d054055fab4cca0ba753e75e237ca159ae868ffd1d13ed45a874a772f2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/mksqlite3c.tcl | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f2e0fcdcfc..2d41793356 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Also\sadd\ssupport\sfor\sEXTRA_SRC\sin\sthe\sMakefile\sfor\sMSVC. -D 2023-09-02T21:55:10.922 +C In\smksqlite3c.tcl,\spass\sEXTRA_SRC\sfiles\sthrough\sverbatim\sinstead\sof\sapplying\sthe\spost-processing\sneeded\sfor\ssqlite's\sown\ssource\sfiles. +D 2023-09-03T15:01:11.477 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2048,7 +2048,7 @@ F tool/mkshellc.tcl b7adf08b82de60811d2cb6af05ff59fc17e5cd6f3e98743c14eaaa3f8971 F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f -F tool/mksqlite3c.tcl 4f366e3d1ddb28996a6763c847fa62e1452bb11ca702841485df77823ec94ea4 +F tool/mksqlite3c.tcl 6d95b3317a7c51e76458c1d4b056b1791b4d9022570e2e23efbaf6a272b47de2 F tool/mksqlite3h.tcl d391cff7cad0a372ee1406faee9ccc7dad9cb80a0c95cae0f73d10dd26e06762 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 @@ -2115,8 +2115,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c -R c273c661c255a780f4edcaa61a31a00b -U mistachkin -Z 47e1eabb65e7f37ad8c0f6188be76f6d +P bfc18ef4323cd73fc63cb93f18bdd9c3add41bea83c1cbc1c20de5c1e4296a60 +R 7d78e3217d362137366a609d99cdc8a6 +U stephan +Z c9456c989544e03851e269725c9f500c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9687ff42b9..ed0de42d69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bfc18ef4323cd73fc63cb93f18bdd9c3add41bea83c1cbc1c20de5c1e4296a60 \ No newline at end of file +44f3d7d054055fab4cca0ba753e75e237ca159ae868ffd1d13ed45a874a772f2 \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index bdbc01e496..0ed96d2032 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -352,6 +352,21 @@ proc copy_file {filename} { section_comment "End of $tail" } +# Read the source file named $filename and write it into the +# sqlite3.c output file. The only transformation is the trimming +# of EOL whitespace. +# +proc copy_file_verbatim {filename} { + global out + set in [open $filename r] + set tail [file tail $filename] + section_comment "Begin EXTRA_SRC file $tail" + while {![eof $in]} { + set line [string trimright [gets $in]] + puts $out $line + } + section_comment "End of EXTRA_SRC $tail" +} # Process the source files. Process files containing commonly # used subroutines first in order to help the compiler find @@ -481,7 +496,7 @@ foreach file $flist { copy_file $srcdir/$file } foreach file $extrasrc { - copy_file $file + copy_file_verbatim $file } puts $out \ From 6b36d0b46189d217721d25ce475fad171ae0a227 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 8 Jan 2024 07:52:47 +0000 Subject: [PATCH 0004/1030] Make explicit which JS APIs are for internal use only by moving the JS-bound internal-use-only functions out of client-visible reach and renaming the WASM-exported ones from sqlite3_wasm... to sqlite3__wasm... (with two underscores). These have always been documented as internal-use-only, so this is not a breaking change except for clients which have ignored the docs. FossilOrigin-Name: 0eddc20f37988df6bce5f407b69e4a315e5cca4af104586e6fe942f0d656cccd --- ext/wasm/GNUmakefile | 5 +- ext/wasm/api/sqlite3-api-glue.js | 68 +++++++------- ext/wasm/api/sqlite3-api-prologue.js | 30 +++---- ext/wasm/api/sqlite3-api-worker1.js | 9 +- ext/wasm/api/sqlite3-wasm.c | 129 +++++++++++++-------------- ext/wasm/fiddle/fiddle-worker.js | 4 +- ext/wasm/speedtest1-worker.js | 4 - ext/wasm/tester1.c-pp.js | 43 ++++----- manifest | 31 ++++--- manifest.uuid | 2 +- 10 files changed, 162 insertions(+), 163 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index f0cff463a8..cbba48cc58 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -43,8 +43,9 @@ # which generates the makefile code, rather than using $(call) and # $(eval), or at least centralize the setup of the numerous vars # related to each build variant $(JS_BUILD_MODES). (Update: an -# external script was attempted but it's even less legible than the -# $(eval) indirection going on in this file. +# external script was attempted but generating properly-escaped +# makefile code from within a shell script is even less legible +# than the $(eval) indirection going on in this file.) # default: all #default: quick diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index 29efb3e07b..e12c5162c6 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -601,16 +601,16 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ /** Functions which are intended solely for API-internal use by the WASM components, not client code. These get installed into - sqlite3.wasm. Some of them get exposed to clients via variants - named sqlite3_js_...(). + sqlite3.util. Some of them get exposed to clients via variants + in wasm.sqlite3_js_...(). */ - wasm.bindingSignatures.wasm = [ - ["sqlite3_wasm_db_reset", "int", "sqlite3*"], - ["sqlite3_wasm_db_vfs", "sqlite3_vfs*", "sqlite3*","string"], - ["sqlite3_wasm_vfs_create_file", "int", + wasm.bindingSignatures.wasmInternal = [ + ["sqlite3__wasm_db_reset", "int", "sqlite3*"], + ["sqlite3__wasm_db_vfs", "sqlite3_vfs*", "sqlite3*","string"], + ["sqlite3__wasm_vfs_create_file", "int", "sqlite3_vfs*","string","*", "int"], - ["sqlite3_wasm_posix_create_file", "int", "string","*", "int"], - ["sqlite3_wasm_vfs_unlink", "int", "sqlite3_vfs*","string"] + ["sqlite3__wasm_posix_create_file", "int", "string","*", "int"], + ["sqlite3__wasm_vfs_unlink", "int", "sqlite3_vfs*","string"] ]; /** @@ -742,8 +742,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ for(const e of wasm.bindingSignatures){ capi[e[0]] = wasm.xWrap.apply(null, e); } - for(const e of wasm.bindingSignatures.wasm){ - wasm[e[0]] = wasm.xWrap.apply(null, e); + for(const e of wasm.bindingSignatures.wasmInternal){ + util[e[0]] = wasm.xWrap.apply(null, e); } /* For C API functions which cannot work properly unless @@ -765,9 +765,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ implicitly making it part of the public interface. */ delete wasm.bindingSignatures; - if(wasm.exports.sqlite3_wasm_db_error){ + if(wasm.exports.sqlite3__wasm_db_error){ const __db_err = wasm.xWrap( - 'sqlite3_wasm_db_error', 'int', 'sqlite3*', 'int', 'string' + 'sqlite3__wasm_db_error', 'int', 'sqlite3*', 'int', 'string' ); /** Sets the given db's error state. Accepts: @@ -785,7 +785,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Returns the resulting code. Pass (pDb,0,0) to clear the error state. */ - util.sqlite3_wasm_db_error = function(pDb, resultCode, message){ + util.sqlite3__wasm_db_error = function(pDb, resultCode, message){ if(resultCode instanceof sqlite3.WasmAllocError){ resultCode = capi.SQLITE_NOMEM; message = 0 /*avoid allocating message string*/; @@ -796,17 +796,17 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return pDb ? __db_err(pDb, resultCode, message) : resultCode; }; }else{ - util.sqlite3_wasm_db_error = function(pDb,errCode,msg){ - console.warn("sqlite3_wasm_db_error() is not exported.",arguments); + util.sqlite3__wasm_db_error = function(pDb,errCode,msg){ + console.warn("sqlite3__wasm_db_error() is not exported.",arguments); return errCode; }; } }/*xWrap() bindings*/ {/* Import C-level constants and structs... */ - const cJson = wasm.xCall('sqlite3_wasm_enum_json'); + const cJson = wasm.xCall('sqlite3__wasm_enum_json'); if(!cJson){ - toss("Maintenance required: increase sqlite3_wasm_enum_json()'s", + toss("Maintenance required: increase sqlite3__wasm_enum_json()'s", "static buffer size!"); } //console.debug('wasm.ctype length =',wasm.cstrlen(cJson)); @@ -877,7 +877,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ delete capi[k]; } capi.sqlite3_vtab_config = wasm.xWrap( - 'sqlite3_wasm_vtab_config','int',[ + 'sqlite3__wasm_vtab_config','int',[ 'sqlite3*', 'int', 'int'] ); }/* end vtab-related setup */ @@ -889,7 +889,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ consistency with non-special-case wrappings. */ const __dbArgcMismatch = (pDb,f,n)=>{ - return util.sqlite3_wasm_db_error(pDb, capi.SQLITE_MISUSE, + return util.sqlite3__wasm_db_error(pDb, capi.SQLITE_MISUSE, f+"() requires "+n+" argument"+ (1===n?"":'s')+"."); }; @@ -898,7 +898,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ argument and require SQLITE_UTF8. Sets the db error code to SQLITE_FORMAT and returns that code. */ const __errEncoding = (pDb)=>{ - return util.sqlite3_wasm_db_error( + return util.sqlite3__wasm_db_error( pDb, capi.SQLITE_FORMAT, "SQLITE_UTF8 is the only supported encoding." ); }; @@ -1128,7 +1128,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } return rc; }catch(e){ - return util.sqlite3_wasm_db_error(pDb, e); + return util.sqlite3__wasm_db_error(pDb, e); } }; @@ -1254,7 +1254,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return rc; }catch(e){ console.error("sqlite3_create_function_v2() setup threw:",e); - return util.sqlite3_wasm_db_error(pDb, e, "Creation of UDF threw: "+e); + return util.sqlite3__wasm_db_error(pDb, e, "Creation of UDF threw: "+e); } }; @@ -1299,7 +1299,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return rc; }catch(e){ console.error("sqlite3_create_window_function() setup threw:",e); - return util.sqlite3_wasm_db_error(pDb, e, "Creation of UDF threw: "+e); + return util.sqlite3__wasm_db_error(pDb, e, "Creation of UDF threw: "+e); } }; /** @@ -1394,7 +1394,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ case 'string': return __prepare.basic(pDb, xSql, xSqlLen, prepFlags, ppStmt, null); case 'number': return __prepare.full(pDb, xSql, xSqlLen, prepFlags, ppStmt, pzTail); default: - return util.sqlite3_wasm_db_error( + return util.sqlite3__wasm_db_error( pDb, capi.SQLITE_MISUSE, "Invalid SQL argument type for sqlite3_prepare_v2/v3()." ); @@ -1438,7 +1438,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }else if('string'===typeof text){ [p, n] = wasm.allocCString(text); }else{ - return util.sqlite3_wasm_db_error( + return util.sqlite3__wasm_db_error( capi.sqlite3_db_handle(pStmt), capi.SQLITE_MISUSE, "Invalid 3rd argument type for sqlite3_bind_text()." ); @@ -1446,7 +1446,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return __bindText(pStmt, iCol, p, n, capi.SQLITE_WASM_DEALLOC); }catch(e){ wasm.dealloc(p); - return util.sqlite3_wasm_db_error( + return util.sqlite3__wasm_db_error( capi.sqlite3_db_handle(pStmt), e ); } @@ -1472,7 +1472,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }else if('string'===typeof pMem){ [p, n] = wasm.allocCString(pMem); }else{ - return util.sqlite3_wasm_db_error( + return util.sqlite3__wasm_db_error( capi.sqlite3_db_handle(pStmt), capi.SQLITE_MISUSE, "Invalid 3rd argument type for sqlite3_bind_blob()." ); @@ -1480,7 +1480,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return __bindBlob(pStmt, iCol, p, n, capi.SQLITE_WASM_DEALLOC); }catch(e){ wasm.dealloc(p); - return util.sqlite3_wasm_db_error( + return util.sqlite3__wasm_db_error( capi.sqlite3_db_handle(pStmt), e ); } @@ -1504,11 +1504,11 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ case capi.SQLITE_CONFIG_SORTERREF_SIZE: // 28 /* int nByte */ case capi.SQLITE_CONFIG_STMTJRNL_SPILL: // 26 /* int nByte */ case capi.SQLITE_CONFIG_URI:// 17 /* int */ - return wasm.exports.sqlite3_wasm_config_i(op, args[0]); + return wasm.exports.sqlite3__wasm_config_i(op, args[0]); case capi.SQLITE_CONFIG_LOOKASIDE: // 13 /* int int */ - return wasm.exports.sqlite3_wasm_config_ii(op, args[0], args[1]); + return wasm.exports.sqlite3__wasm_config_ii(op, args[0], args[1]); case capi.SQLITE_CONFIG_MEMDB_MAXSIZE: // 29 /* sqlite3_int64 */ - return wasm.exports.sqlite3_wasm_config_j(op, args[0]); + return wasm.exports.sqlite3__wasm_config_j(op, args[0]); case capi.SQLITE_CONFIG_GETMALLOC: // 5 /* sqlite3_mem_methods* */ case capi.SQLITE_CONFIG_GETMUTEX: // 11 /* sqlite3_mutex_methods* */ case capi.SQLITE_CONFIG_GETPCACHE2: // 19 /* sqlite3_pcache_methods2* */ @@ -1574,11 +1574,11 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ if( pKvvfs ){/* kvvfs-specific glue */ if(util.isUIThread()){ const kvvfsMethods = new capi.sqlite3_kvvfs_methods( - wasm.exports.sqlite3_wasm_kvvfs_methods() + wasm.exports.sqlite3__wasm_kvvfs_methods() ); delete capi.sqlite3_kvvfs_methods; - const kvvfsMakeKey = wasm.exports.sqlite3_wasm_kvvfsMakeKeyOnPstack, + const kvvfsMakeKey = wasm.exports.sqlite3__wasm_kvvfsMakeKeyOnPstack, pstack = wasm.pstack; const kvvfsStorage = (zClass)=> @@ -1587,7 +1587,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ /** Implementations for members of the object referred to by - sqlite3_wasm_kvvfs_methods(). We swap out the native + sqlite3__wasm_kvvfs_methods(). We swap out the native implementations with these, which use localStorage or sessionStorage for their backing store. */ diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index ef1154f6b6..c784b69909 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -1061,7 +1061,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( are undefined if the passed-in value did not come from this.pointer. */ - restore: wasm.exports.sqlite3_wasm_pstack_restore, + restore: wasm.exports.sqlite3__wasm_pstack_restore, /** Attempts to allocate the given number of bytes from the pstack. On success, it zeroes out a block of memory of the @@ -1083,7 +1083,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( if('string'===typeof n && !(n = wasm.sizeofIR(n))){ WasmAllocError.toss("Invalid value for pstack.alloc(",arguments[0],")"); } - return wasm.exports.sqlite3_wasm_pstack_alloc(n) + return wasm.exports.sqlite3__wasm_pstack_alloc(n) || WasmAllocError.toss("Could not allocate",n, "bytes from the pstack."); }, @@ -1163,10 +1163,10 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( */ pointer: { configurable: false, iterable: true, writeable: false, - get: wasm.exports.sqlite3_wasm_pstack_ptr + get: wasm.exports.sqlite3__wasm_pstack_ptr //Whether or not a setter as an alternative to restore() is //clearer or would just lead to confusion is unclear. - //set: wasm.exports.sqlite3_wasm_pstack_restore + //set: wasm.exports.sqlite3__wasm_pstack_restore }, /** sqlite3.wasm.pstack.quota to the total number of bytes @@ -1175,7 +1175,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( */ quota: { configurable: false, iterable: true, writeable: false, - get: wasm.exports.sqlite3_wasm_pstack_quota + get: wasm.exports.sqlite3__wasm_pstack_quota }, /** sqlite3.wasm.pstack.remaining resolves to the amount of space @@ -1183,7 +1183,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( */ remaining: { configurable: false, iterable: true, writeable: false, - get: wasm.exports.sqlite3_wasm_pstack_remaining + get: wasm.exports.sqlite3__wasm_pstack_remaining } })/*wasm.pstack properties*/; @@ -1256,14 +1256,14 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( } try{ if(pdir && 0===wasm.xCallWrapped( - 'sqlite3_wasm_init_wasmfs', 'i32', ['string'], pdir + 'sqlite3__wasm_init_wasmfs', 'i32', ['string'], pdir )){ return __wasmfsOpfsDir = pdir; }else{ return __wasmfsOpfsDir = ""; } }catch(e){ - // sqlite3_wasm_init_wasmfs() is not available + // sqlite3__wasm_init_wasmfs() is not available return __wasmfsOpfsDir = ""; } }; @@ -1365,7 +1365,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( const zSchema = schema ? (wasm.isPtr(schema) ? schema : wasm.scopedAllocCString(''+schema)) : 0; - let rc = wasm.exports.sqlite3_wasm_db_serialize( + let rc = wasm.exports.sqlite3__wasm_db_serialize( pDb, zSchema, ppOut, pSize, 0 ); if(rc){ @@ -1391,7 +1391,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( or not provided, then "main" is assumed. */ capi.sqlite3_js_db_vfs = - (dbPointer, dbName=0)=>wasm.sqlite3_wasm_db_vfs(dbPointer, dbName); + (dbPointer, dbName=0)=>util.sqlite3__wasm_db_vfs(dbPointer, dbName); /** A thin wrapper around capi.sqlite3_aggregate_context() which @@ -1449,7 +1449,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( if(!util.isInt32(dataLen) || dataLen<0){ SQLite3Error.toss("Invalid 3rd argument for sqlite3_js_posix_create_file()."); } - const rc = wasm.sqlite3_wasm_posix_create_file(filename, pData, dataLen); + const rc = util.sqlite3__wasm_posix_create_file(filename, pData, dataLen); if(rc) SQLite3Error.toss("Creation of file failed with sqlite3 result code", capi.sqlite3_js_rc_str(rc)); }finally{ @@ -1551,7 +1551,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( SQLite3Error.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."); } try{ - const rc = wasm.sqlite3_wasm_vfs_create_file(vfs, filename, pData, dataLen); + const rc = util.sqlite3__wasm_vfs_create_file(vfs, filename, pData, dataLen); if(rc) SQLite3Error.toss("Creation of file failed with sqlite3 result code", capi.sqlite3_js_rc_str(rc)); }finally{ @@ -1672,12 +1672,12 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( */ capi.sqlite3_db_config = function(pDb, op, ...args){ if(!this.s){ - this.s = wasm.xWrap('sqlite3_wasm_db_config_s','int', + this.s = wasm.xWrap('sqlite3__wasm_db_config_s','int', ['sqlite3*', 'int', 'string:static'] /* MAINDBNAME requires a static string */); - this.pii = wasm.xWrap('sqlite3_wasm_db_config_pii', 'int', + this.pii = wasm.xWrap('sqlite3__wasm_db_config_pii', 'int', ['sqlite3*', 'int', '*','int', 'int']); - this.ip = wasm.xWrap('sqlite3_wasm_db_config_ip','int', + this.ip = wasm.xWrap('sqlite3__wasm_db_config_ip','int', ['sqlite3*', 'int', 'int','*']); } switch(op){ diff --git a/ext/wasm/api/sqlite3-api-worker1.js b/ext/wasm/api/sqlite3-api-worker1.js index 3099c19ec4..bd99f3ec8e 100644 --- a/ext/wasm/api/sqlite3-api-worker1.js +++ b/ext/wasm/api/sqlite3-api-worker1.js @@ -359,6 +359,7 @@ */ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ +const util = sqlite3.util; sqlite3.initWorker1API = function(){ 'use strict'; const toss = (...args)=>{throw new Error(args.join(' '))}; @@ -409,12 +410,12 @@ sqlite3.initWorker1API = function(){ if(db){ delete this.dbs[getDbId(db)]; const filename = db.filename; - const pVfs = sqlite3.wasm.sqlite3_wasm_db_vfs(db.pointer, 0); + const pVfs = util.sqlite3__wasm_db_vfs(db.pointer, 0); db.close(); const ddNdx = this.dbList.indexOf(db); if(ddNdx>=0) this.dbList.splice(ddNdx, 1); if(alsoUnlink && filename && pVfs){ - sqlite3.wasm.sqlite3_wasm_vfs_unlink(pVfs, filename); + util.sqlite3__wasm_vfs_unlink(pVfs, filename); } } }, @@ -495,12 +496,12 @@ sqlite3.initWorker1API = function(){ } if(pVfs){ /* 2022-11-02: this feature is as-yet untested except that - sqlite3_wasm_vfs_create_file() has been tested from the + sqlite3__wasm_vfs_create_file() has been tested from the browser dev console. */ let pMem; try{ pMem = sqlite3.wasm.allocFromTypedArray(byteArray); - const rc = sqlite3.wasm.sqlite3_wasm_vfs_create_file( + const rc = util.sqlite3__wasm_vfs_create_file( pVfs, oargs.filename, pMem, byteArray.byteLength ); if(rc) sqlite3.SQLite3Error.toss(rc); diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index 618d0f085a..bd0eb884c9 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -238,28 +238,28 @@ ** Another option is to malloc() a chunk of our own and call that our ** "stack". */ -SQLITE_WASM_EXPORT void * sqlite3_wasm_stack_end(void){ +SQLITE_WASM_EXPORT void * sqlite3__wasm_stack_end(void){ extern void __heap_base /* see https://stackoverflow.com/questions/10038964 */; return &__heap_base; } -SQLITE_WASM_EXPORT void * sqlite3_wasm_stack_begin(void){ +SQLITE_WASM_EXPORT void * sqlite3__wasm_stack_begin(void){ extern void __data_end; return &__data_end; } static void * pWasmStackPtr = 0; -SQLITE_WASM_EXPORT void * sqlite3_wasm_stack_ptr(void){ - if(!pWasmStackPtr) pWasmStackPtr = sqlite3_wasm_stack_end(); +SQLITE_WASM_EXPORT void * sqlite3__wasm_stack_ptr(void){ + if(!pWasmStackPtr) pWasmStackPtr = sqlite3__wasm_stack_end(); return pWasmStackPtr; } -SQLITE_WASM_EXPORT void sqlite3_wasm_stack_restore(void * p){ +SQLITE_WASM_EXPORT void sqlite3__wasm_stack_restore(void * p){ pWasmStackPtr = p; } -SQLITE_WASM_EXPORT void * sqlite3_wasm_stack_alloc(int n){ +SQLITE_WASM_EXPORT void * sqlite3__wasm_stack_alloc(int n){ if(n<=0) return 0; n = (n + 7) & ~7 /* align to 8-byte boundary */; - unsigned char * const p = (unsigned char *)sqlite3_wasm_stack_ptr(); - unsigned const char * const b = (unsigned const char *)sqlite3_wasm_stack_begin(); + unsigned char * const p = (unsigned char *)sqlite3__wasm_stack_ptr(); + unsigned const char * const b = (unsigned const char *)sqlite3__wasm_stack_begin(); if(b + n >= p || b + n < b/*overflow*/) return 0; return pWasmStackPtr = p - n; } @@ -267,7 +267,7 @@ SQLITE_WASM_EXPORT void * sqlite3_wasm_stack_alloc(int n){ /* ** State for the "pseudo-stack" allocator implemented in -** sqlite3_wasm_pstack_xyz(). In order to avoid colliding with +** sqlite3__wasm_pstack_xyz(). In order to avoid colliding with ** Emscripten-controled stack space, it carves out a bit of stack ** memory to use for that purpose. This memory ends up in the ** WASM-managed memory, such that routines which manipulate the wasm @@ -291,14 +291,14 @@ static struct { /* ** Returns the current pstack position. */ -SQLITE_WASM_EXPORT void * sqlite3_wasm_pstack_ptr(void){ +SQLITE_WASM_EXPORT void * sqlite3__wasm_pstack_ptr(void){ return PStack.pPos; } /* ** Sets the pstack position poitner to p. Results are undefined if the -** given value did not come from sqlite3_wasm_pstack_ptr(). +** given value did not come from sqlite3__wasm_pstack_ptr(). */ -SQLITE_WASM_EXPORT void sqlite3_wasm_pstack_restore(unsigned char * p){ +SQLITE_WASM_EXPORT void sqlite3__wasm_pstack_restore(unsigned char * p){ assert(p>=PStack.pBegin && p<=PStack.pEnd && p>=PStack.pPos); assert(0==((unsigned long long)p & 0x7)); if(p>=PStack.pBegin && p<=PStack.pEnd /*&& p>=PStack.pPos*/){ @@ -313,7 +313,7 @@ SQLITE_WASM_EXPORT void sqlite3_wasm_pstack_restore(unsigned char * p){ ** JS code from having to do so, and most uses of the pstack will ** call for doing so). */ -SQLITE_WASM_EXPORT void * sqlite3_wasm_pstack_alloc(int n){ +SQLITE_WASM_EXPORT void * sqlite3__wasm_pstack_alloc(int n){ if( n<=0 ) return 0; //if( n & 0x7 ) n += 8 - (n & 0x7) /* align to 8-byte boundary */; n = (n + 7) & ~7 /* align to 8-byte boundary */; @@ -324,9 +324,9 @@ SQLITE_WASM_EXPORT void * sqlite3_wasm_pstack_alloc(int n){ } /* ** Return the number of bytes left which can be -** sqlite3_wasm_pstack_alloc()'d. +** sqlite3__wasm_pstack_alloc()'d. */ -SQLITE_WASM_EXPORT int sqlite3_wasm_pstack_remaining(void){ +SQLITE_WASM_EXPORT int sqlite3__wasm_pstack_remaining(void){ assert(PStack.pPos >= PStack.pBegin); assert(PStack.pPos <= PStack.pEnd); return (int)(PStack.pPos - PStack.pBegin); @@ -337,7 +337,7 @@ SQLITE_WASM_EXPORT int sqlite3_wasm_pstack_remaining(void){ ** any space which is currently allocated. This value is a ** compile-time constant. */ -SQLITE_WASM_EXPORT int sqlite3_wasm_pstack_quota(void){ +SQLITE_WASM_EXPORT int sqlite3__wasm_pstack_quota(void){ return (int)(PStack.pEnd - PStack.pBegin); } @@ -356,7 +356,7 @@ SQLITE_WASM_EXPORT int sqlite3_wasm_pstack_quota(void){ ** Returns err_code. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_db_error(sqlite3*db, int err_code, const char *zMsg){ +int sqlite3__wasm_db_error(sqlite3*db, int err_code, const char *zMsg){ if( db!=0 ){ if( 0!=zMsg ){ const int nMsg = sqlite3Strlen30(zMsg); @@ -380,7 +380,7 @@ struct WasmTestStruct { }; typedef struct WasmTestStruct WasmTestStruct; SQLITE_WASM_EXPORT -void sqlite3_wasm_test_struct(WasmTestStruct * s){ +void sqlite3__wasm_test_struct(WasmTestStruct * s){ if(s){ s->v4 *= 2; s->v8 = s->v4 * 2; @@ -408,7 +408,7 @@ void sqlite3_wasm_test_struct(WasmTestStruct * s){ ** increased. In debug builds that will trigger an assert(). */ SQLITE_WASM_EXPORT -const char * sqlite3_wasm_enum_json(void){ +const char * sqlite3__wasm_enum_json(void){ static char aBuffer[1024 * 20] = {0} /* where the JSON goes */; int n = 0, nChildren = 0, nStruct = 0 /* output counters for figuring out where commas go */; @@ -425,7 +425,7 @@ const char * sqlite3_wasm_enum_json(void){ /* Core output macros... */ #define lenCheck assert(zPos < zEnd - 128 \ - && "sqlite3_wasm_enum_json() buffer is too small."); \ + && "sqlite3__wasm_enum_json() buffer is too small."); \ if( zPos >= zEnd - 128 ) return 0 #define outf(format,...) \ zPos += snprintf(zPos, ((size_t)(zEnd - zPos)), format, __VA_ARGS__); \ @@ -1220,7 +1220,7 @@ const char * sqlite3_wasm_enum_json(void){ ** call is returned. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_vfs_unlink(sqlite3_vfs *pVfs, const char *zName){ +int sqlite3__wasm_vfs_unlink(sqlite3_vfs *pVfs, const char *zName){ int rc = SQLITE_MISUSE /* ??? */; if( 0==pVfs && 0!=zName ) pVfs = sqlite3_vfs_find(0); if( zName && pVfs && pVfs->xDelete ){ @@ -1238,7 +1238,7 @@ int sqlite3_wasm_vfs_unlink(sqlite3_vfs *pVfs, const char *zName){ ** given name is open. */ SQLITE_WASM_EXPORT -sqlite3_vfs * sqlite3_wasm_db_vfs(sqlite3 *pDb, const char *zDbName){ +sqlite3_vfs * sqlite3__wasm_db_vfs(sqlite3 *pDb, const char *zDbName){ sqlite3_vfs * pVfs = 0; sqlite3_file_control(pDb, zDbName ? zDbName : "main", SQLITE_FCNTL_VFS_POINTER, &pVfs); @@ -1261,7 +1261,7 @@ sqlite3_vfs * sqlite3_wasm_db_vfs(sqlite3 *pDb, const char *zDbName){ ** SQLITE_MISUSE if pDb is NULL. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_db_reset(sqlite3 *pDb){ +int sqlite3__wasm_db_reset(sqlite3 *pDb){ int rc = SQLITE_MISUSE; if( pDb ){ sqlite3_table_column_metadata(pDb, "main", 0, 0, 0, 0, 0, 0, 0); @@ -1288,11 +1288,11 @@ int sqlite3_wasm_db_reset(sqlite3 *pDb){ ** takes no measures to ensure that is the case. ** ** This implementation appears to work fine, but -** sqlite3_wasm_db_serialize() is arguably the better way to achieve +** sqlite3__wasm_db_serialize() is arguably the better way to achieve ** this. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_db_export_chunked( sqlite3* pDb, +int sqlite3__wasm_db_export_chunked( sqlite3* pDb, int (*xCallback)(unsigned const char *zOut, int n) ){ sqlite3_int64 nSize = 0; sqlite3_int64 nPos = 0; @@ -1343,7 +1343,7 @@ int sqlite3_wasm_db_export_chunked( sqlite3* pDb, ** sqlite3_free() to free it. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_db_serialize( sqlite3 *pDb, const char *zSchema, +int sqlite3__wasm_db_serialize( sqlite3 *pDb, const char *zSchema, unsigned char **pOut, sqlite3_int64 *nOut, unsigned int mFlags ){ unsigned char * z; @@ -1366,7 +1366,7 @@ int sqlite3_wasm_db_serialize( sqlite3 *pDb, const char *zSchema, ** this function's out-of-scope use of the sqlite3_vfs/file/io_methods ** APIs leads to triggering of assertions in the core library. Its use ** is now deprecated and VFS-specific APIs for importing files need to -** be found to replace it. sqlite3_wasm_posix_create_file() is +** be found to replace it. sqlite3__wasm_posix_create_file() is ** suitable for the "unix" family of VFSes. ** ** Creates a new file using the I/O API of the given VFS, containing @@ -1407,7 +1407,7 @@ int sqlite3_wasm_db_serialize( sqlite3 *pDb, const char *zSchema, ** support is disabled or unavailable. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_vfs_create_file( sqlite3_vfs *pVfs, +int sqlite3__wasm_vfs_create_file( sqlite3_vfs *pVfs, const char *zFilename, const unsigned char * pData, int nData ){ @@ -1497,7 +1497,7 @@ int sqlite3_wasm_vfs_create_file( sqlite3_vfs *pVfs, ** SQLITE_IOERR on error. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_posix_create_file( const char *zFilename, +int sqlite3__wasm_posix_create_file( const char *zFilename, const unsigned char * pData, int nData ){ int rc; @@ -1520,17 +1520,17 @@ int sqlite3_wasm_posix_create_file( const char *zFilename, ** for use by the sqlite project's own JS/WASM bindings. ** ** Allocates sqlite3KvvfsMethods.nKeySize bytes from -** sqlite3_wasm_pstack_alloc() and returns 0 if that allocation fails, +** sqlite3__wasm_pstack_alloc() and returns 0 if that allocation fails, ** else it passes that string to kvstorageMakeKey() and returns a ** NUL-terminated pointer to that string. It is up to the caller to -** use sqlite3_wasm_pstack_restore() to free the returned pointer. +** use sqlite3__wasm_pstack_restore() to free the returned pointer. */ SQLITE_WASM_EXPORT -char * sqlite3_wasm_kvvfsMakeKeyOnPstack(const char *zClass, +char * sqlite3__wasm_kvvfsMakeKeyOnPstack(const char *zClass, const char *zKeyIn){ assert(sqlite3KvvfsMethods.nKeySize>24); char *zKeyOut = - (char *)sqlite3_wasm_pstack_alloc(sqlite3KvvfsMethods.nKeySize); + (char *)sqlite3__wasm_pstack_alloc(sqlite3KvvfsMethods.nKeySize); if(zKeyOut){ kvstorageMakeKey(zClass, zKeyIn, zKeyOut); } @@ -1545,7 +1545,7 @@ char * sqlite3_wasm_kvvfsMakeKeyOnPstack(const char *zClass, ** I/O methods and associated state. */ SQLITE_WASM_EXPORT -sqlite3_kvvfs_methods * sqlite3_wasm_kvvfs_methods(void){ +sqlite3_kvvfs_methods * sqlite3__wasm_kvvfs_methods(void){ return &sqlite3KvvfsMethods; } @@ -1560,7 +1560,7 @@ sqlite3_kvvfs_methods * sqlite3_wasm_kvvfs_methods(void){ ** valid value. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_vtab_config(sqlite3 *pDb, int op, int arg){ +int sqlite3__wasm_vtab_config(sqlite3 *pDb, int op, int arg){ switch(op){ case SQLITE_VTAB_DIRECTONLY: case SQLITE_VTAB_INNOCUOUS: @@ -1580,7 +1580,7 @@ int sqlite3_wasm_vtab_config(sqlite3 *pDb, int op, int arg){ ** (int,int*) variadic args. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_db_config_ip(sqlite3 *pDb, int op, int arg1, int* pArg2){ +int sqlite3__wasm_db_config_ip(sqlite3 *pDb, int op, int arg1, int* pArg2){ switch(op){ case SQLITE_DBCONFIG_ENABLE_FKEY: case SQLITE_DBCONFIG_ENABLE_TRIGGER: @@ -1613,7 +1613,7 @@ int sqlite3_wasm_db_config_ip(sqlite3 *pDb, int op, int arg1, int* pArg2){ ** (void*,int,int) variadic args. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_db_config_pii(sqlite3 *pDb, int op, void * pArg1, int arg2, int arg3){ +int sqlite3__wasm_db_config_pii(sqlite3 *pDb, int op, void * pArg1, int arg2, int arg3){ switch(op){ case SQLITE_DBCONFIG_LOOKASIDE: return sqlite3_db_config(pDb, op, pArg1, arg2, arg3); @@ -1629,7 +1629,7 @@ int sqlite3_wasm_db_config_pii(sqlite3 *pDb, int op, void * pArg1, int arg2, int ** (const char *) variadic args. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_db_config_s(sqlite3 *pDb, int op, const char *zArg){ +int sqlite3__wasm_db_config_s(sqlite3 *pDb, int op, const char *zArg){ switch(op){ case SQLITE_DBCONFIG_MAINDBNAME: return sqlite3_db_config(pDb, op, zArg); @@ -1646,7 +1646,7 @@ int sqlite3_wasm_db_config_s(sqlite3 *pDb, int op, const char *zArg){ ** a single integer argument. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_config_i(int op, int arg){ +int sqlite3__wasm_config_i(int op, int arg){ return sqlite3_config(op, arg); } @@ -1658,7 +1658,7 @@ int sqlite3_wasm_config_i(int op, int arg){ ** two int arguments. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_config_ii(int op, int arg1, int arg2){ +int sqlite3__wasm_config_ii(int op, int arg1, int arg2){ return sqlite3_config(op, arg1, arg2); } @@ -1670,7 +1670,7 @@ int sqlite3_wasm_config_ii(int op, int arg1, int arg2){ ** a single i64 argument. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_config_j(int op, sqlite3_int64 arg){ +int sqlite3__wasm_config_j(int op, sqlite3_int64 arg){ return sqlite3_config(op, arg); } @@ -1689,17 +1689,17 @@ int sqlite3_wasm_config_j(int op, sqlite3_int64 arg){ ** ** ``` ** sqlite3.wasm.functionEntry( -** sqlite3.wasm.exports.sqlite3_wasm_ptr_to_sqlite3_free() +** sqlite3.wasm.exports.sqlite3__wasm_ptr_to_sqlite3_free() ** ) === sqlite3.wasm.exports.sqlite3_free ** ``` ** ** Using a function to return this pointer, as opposed to exporting it -** via sqlite3_wasm_enum_json(), is an attempt to work around a +** via sqlite3__wasm_enum_json(), is an attempt to work around a ** Safari-specific quirk covered at ** https://sqlite.org/forum/info/e5b20e1feb37a19a. **/ SQLITE_WASM_EXPORT -void * sqlite3_wasm_ptr_to_sqlite3_free(void){ +void * sqlite3__wasm_ptr_to_sqlite3_free(void){ return (void*)sqlite3_free; } #endif @@ -1729,7 +1729,7 @@ void * sqlite3_wasm_ptr_to_sqlite3_free(void){ ** defined, SQLITE_NOTFOUND is returned without side effects. */ SQLITE_WASM_EXPORT -int sqlite3_wasm_init_wasmfs(const char *zMountPoint){ +int sqlite3__wasm_init_wasmfs(const char *zMountPoint){ static backend_t pOpfs = 0; if( !zMountPoint || !*zMountPoint ) zMountPoint = "/opfs"; if( !pOpfs ){ @@ -1749,7 +1749,7 @@ int sqlite3_wasm_init_wasmfs(const char *zMountPoint){ } #else SQLITE_WASM_EXPORT -int sqlite3_wasm_init_wasmfs(const char *zUnused){ +int sqlite3__wasm_init_wasmfs(const char *zUnused){ //emscripten_console_warn("WASMFS OPFS is not compiled in."); if(zUnused){/*unused*/} return SQLITE_NOTFOUND; @@ -1759,51 +1759,51 @@ int sqlite3_wasm_init_wasmfs(const char *zUnused){ #if SQLITE_WASM_TESTS SQLITE_WASM_EXPORT -int sqlite3_wasm_test_intptr(int * p){ +int sqlite3__wasm_test_intptr(int * p){ return *p = *p * 2; } SQLITE_WASM_EXPORT -void * sqlite3_wasm_test_voidptr(void * p){ +void * sqlite3__wasm_test_voidptr(void * p){ return p; } SQLITE_WASM_EXPORT -int64_t sqlite3_wasm_test_int64_max(void){ +int64_t sqlite3__wasm_test_int64_max(void){ return (int64_t)0x7fffffffffffffff; } SQLITE_WASM_EXPORT -int64_t sqlite3_wasm_test_int64_min(void){ - return ~sqlite3_wasm_test_int64_max(); +int64_t sqlite3__wasm_test_int64_min(void){ + return ~sqlite3__wasm_test_int64_max(); } SQLITE_WASM_EXPORT -int64_t sqlite3_wasm_test_int64_times2(int64_t x){ +int64_t sqlite3__wasm_test_int64_times2(int64_t x){ return x * 2; } SQLITE_WASM_EXPORT -void sqlite3_wasm_test_int64_minmax(int64_t * min, int64_t *max){ - *max = sqlite3_wasm_test_int64_max(); - *min = sqlite3_wasm_test_int64_min(); +void sqlite3__wasm_test_int64_minmax(int64_t * min, int64_t *max){ + *max = sqlite3__wasm_test_int64_max(); + *min = sqlite3__wasm_test_int64_min(); /*printf("minmax: min=%lld, max=%lld\n", *min, *max);*/ } SQLITE_WASM_EXPORT -int64_t sqlite3_wasm_test_int64ptr(int64_t * p){ - /*printf("sqlite3_wasm_test_int64ptr( @%lld = 0x%llx )\n", (int64_t)p, *p);*/ +int64_t sqlite3__wasm_test_int64ptr(int64_t * p){ + /*printf("sqlite3__wasm_test_int64ptr( @%lld = 0x%llx )\n", (int64_t)p, *p);*/ return *p = *p * 2; } SQLITE_WASM_EXPORT -void sqlite3_wasm_test_stack_overflow(int recurse){ - if(recurse) sqlite3_wasm_test_stack_overflow(recurse); +void sqlite3__wasm_test_stack_overflow(int recurse){ + if(recurse) sqlite3__wasm_test_stack_overflow(recurse); } /* For testing the 'string:dealloc' whwasmutil.xWrap() conversion. */ SQLITE_WASM_EXPORT -char * sqlite3_wasm_test_str_hello(int fail){ +char * sqlite3__wasm_test_str_hello(int fail){ char * s = fail ? 0 : (char *)sqlite3_malloc(6); if(s){ memcpy(s, "hello", 5); @@ -1838,12 +1838,12 @@ char * sqlite3_wasm_test_str_hello(int fail){ ** optional + or - sign in front, or a hexadecimal ** literal of the form 0x... */ -static int sqlite3_wasm_SQLTester_strnotglob(const char *zGlob, const char *z){ +static int sqlite3__wasm_SQLTester_strnotglob(const char *zGlob, const char *z){ int c, c2; int invert; int seen; typedef int (*recurse_f)(const char *,const char *); - static const recurse_f recurse = sqlite3_wasm_SQLTester_strnotglob; + static const recurse_f recurse = sqlite3__wasm_SQLTester_strnotglob; while( (c = (*(zGlob++)))!=0 ){ if( c=='*' ){ @@ -1918,11 +1918,10 @@ static int sqlite3_wasm_SQLTester_strnotglob(const char *zGlob, const char *z){ } SQLITE_WASM_EXPORT -int sqlite3_wasm_SQLTester_strglob(const char *zGlob, const char *z){ - return !sqlite3_wasm_SQLTester_strnotglob(zGlob, z); +int sqlite3__wasm_SQLTester_strglob(const char *zGlob, const char *z){ + return !sqlite3__wasm_SQLTester_strnotglob(zGlob, z); } - #endif /* SQLITE_WASM_TESTS */ #undef SQLITE_WASM_EXPORT diff --git a/ext/wasm/fiddle/fiddle-worker.js b/ext/wasm/fiddle/fiddle-worker.js index 67f61008fb..cf0aa1ca2c 100644 --- a/ext/wasm/fiddle/fiddle-worker.js +++ b/ext/wasm/fiddle/fiddle-worker.js @@ -374,9 +374,7 @@ "for use in the dev console.", sqlite3); globalThis.sqlite3 = sqlite3; const dbVfs = sqlite3.wasm.xWrap('fiddle_db_vfs', "*", ['string']); - fiddleModule.fsUnlink = (fn)=>{ - return sqlite3.wasm.sqlite3_wasm_vfs_unlink(dbVfs(0), fn); - }; + fiddleModule.fsUnlink = (fn)=>fiddleModule.FS.unlink(fn); wMsg('fiddle-ready'); }).catch(e=>{ console.error("Fiddle worker init failed:",e); diff --git a/ext/wasm/speedtest1-worker.js b/ext/wasm/speedtest1-worker.js index 3abc589b59..5261c83932 100644 --- a/ext/wasm/speedtest1-worker.js +++ b/ext/wasm/speedtest1-worker.js @@ -111,10 +111,6 @@ self.sqlite3InitModule(EmscriptenModule).then(async (sqlite3)=>{ const S = globalThis.S = App.sqlite3 = sqlite3; log("Loaded speedtest1 module. Setting up..."); - App.vfsUnlink = function(pDb, fname){ - const pVfs = S.wasm.sqlite3_wasm_db_vfs(pDb, 0); - if(pVfs) S.wasm.sqlite3_wasm_vfs_unlink(pVfs, fname||0); - }; App.pDir = wasmfsDir(S.wasm); App.wasm = S.wasm; //if(App.pDir) log("Persistent storage:",pDir); diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 36ca4c976f..f8a0225234 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -63,7 +63,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; /* Predicate for tests/groups. */ const testIsTodo = ()=>false; const haveWasmCTests = ()=>{ - return !!wasm.exports.sqlite3_wasm_test_intptr; + return !!wasm.exports.sqlite3__wasm_test_intptr; }; const hasOpfs = ()=>{ return globalThis.FileSystemHandle @@ -722,7 +722,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //log("xCall()..."); { - const pJson = w.xCall('sqlite3_wasm_enum_json'); + const pJson = w.xCall('sqlite3__wasm_enum_json'); T.assert(Number.isFinite(pJson)).assert(w.cstrlen(pJson)>300); } @@ -736,9 +736,9 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.mustThrowMatching(()=>fw(1), /requires 0 arg/); let rc = fw(); T.assert('string'===typeof rc).assert(rc.length>5); - rc = w.xCallWrapped('sqlite3_wasm_enum_json','*'); + rc = w.xCallWrapped('sqlite3__wasm_enum_json','*'); T.assert(rc>0 && Number.isFinite(rc)); - rc = w.xCallWrapped('sqlite3_wasm_enum_json','utf8'); + rc = w.xCallWrapped('sqlite3__wasm_enum_json','utf8'); T.assert('string'===typeof rc).assert(rc.length>300); @@ -821,7 +821,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; if(haveWasmCTests()){ if(!sqlite3.config.useStdAlloc){ - fw = w.xWrap('sqlite3_wasm_test_str_hello', 'utf8:dealloc',['i32']); + fw = w.xWrap('sqlite3__wasm_test_str_hello', 'utf8:dealloc',['i32']); rc = fw(0); T.assert('hello'===rc); rc = fw(1); @@ -831,14 +831,14 @@ globalThis.sqlite3InitModule = sqlite3InitModule; if(w.bigIntEnabled){ w.xWrap.resultAdapter('thrice', (v)=>3n*BigInt(v)); w.xWrap.argAdapter('twice', (v)=>2n*BigInt(v)); - fw = w.xWrap('sqlite3_wasm_test_int64_times2','thrice','twice'); + fw = w.xWrap('sqlite3__wasm_test_int64_times2','thrice','twice'); rc = fw(1); T.assert(12n===rc); w.scopedAllocCall(function(){ const pI1 = w.scopedAlloc(8), pI2 = pI1+4; w.pokePtr([pI1, pI2], 0); - const f = w.xWrap('sqlite3_wasm_test_int64_minmax',undefined,['i64*','i64*']); + const f = w.xWrap('sqlite3__wasm_test_int64_minmax',undefined,['i64*','i64*']); const [r1, r2] = w.peek64([pI1, pI2]); T.assert(!Number.isSafeInteger(r1)).assert(!Number.isSafeInteger(r2)); }); @@ -942,7 +942,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; assert(wts.pointer>0).assert(0===wts.$v4).assert(0n===wts.$v8). assert(0===wts.$ppV).assert(0===wts.$xFunc); const testFunc = - W.xGet('sqlite3_wasm_test_struct'/*name gets mangled in -O3 builds!*/); + W.xGet('sqlite3__wasm_test_struct'/*name gets mangled in -O3 builds!*/); let counter = 0; //log("wts.pointer =",wts.pointer); const wtsFunc = function(arg){ @@ -1128,7 +1128,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.g('sqlite3.oo1') .t('Create db', function(sqlite3){ const dbFile = '/tester1.db'; - wasm.sqlite3_wasm_vfs_unlink(0, dbFile); + sqlite3.util.sqlite3__wasm_vfs_unlink(0, dbFile); const db = this.db = new sqlite3.oo1.DB(dbFile, 0 ? 'ct' : 'c'); db.onclose = { disposeAfter: [], @@ -1459,7 +1459,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; rv = db.exec("SELECT 1 WHERE 0",{rowMode: 0}); T.assert(Array.isArray(rv)).assert(0===rv.length); if(wasm.bigIntEnabled && haveWasmCTests()){ - const mI = wasm.xCall('sqlite3_wasm_test_int64_max'); + const mI = wasm.xCall('sqlite3__wasm_test_int64_max'); const b = BigInt(Number.MAX_SAFE_INTEGER * 2); T.assert(b === db.selectValue("SELECT "+b)). assert(b === db.selectValue("SELECT ?", b)). @@ -1685,7 +1685,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.assert(n>0 && db2.selectValue(sql) === n); }finally{ db2.close(); - wasm.sqlite3_wasm_vfs_unlink(0, filename); + sqlite3.util.sqlite3__wasm_vfs_unlink(0, filename); } } }/*sqlite3_js_posix_create_file()*/) @@ -2075,7 +2075,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; try{ ptrInt = w.scopedAlloc(4); w.poke32(ptrInt,origValue); - const cf = w.xGet('sqlite3_wasm_test_intptr'); + const cf = w.xGet('sqlite3__wasm_test_intptr'); const oldPtrInt = ptrInt; T.assert(origValue === w.peek32(ptrInt)); const rc = cf(ptrInt); @@ -2090,13 +2090,13 @@ globalThis.sqlite3InitModule = sqlite3InitModule; const v64 = ()=>w.peek64(pi64) T.assert(v64() == o64); //T.assert(o64 === w.peek64(pi64)); - const cf64w = w.xGet('sqlite3_wasm_test_int64ptr'); + const cf64w = w.xGet('sqlite3__wasm_test_int64ptr'); cf64w(pi64); T.assert(v64() == BigInt(2 * o64)); cf64w(pi64); T.assert(v64() == BigInt(4 * o64)); - const biTimes2 = w.xGet('sqlite3_wasm_test_int64_times2'); + const biTimes2 = w.xGet('sqlite3__wasm_test_int64_times2'); T.assert(BigInt(2 * o64) === biTimes2(BigInt(o64)/*explicit conv. required to avoid TypeError in the call :/ */)); @@ -2106,13 +2106,13 @@ globalThis.sqlite3InitModule = sqlite3InitModule; const g64 = (p)=>w.peek64(p); w.poke64([pMin, pMax], 0); const minMaxI64 = [ - w.xCall('sqlite3_wasm_test_int64_min'), - w.xCall('sqlite3_wasm_test_int64_max') + w.xCall('sqlite3__wasm_test_int64_min'), + w.xCall('sqlite3__wasm_test_int64_max') ]; T.assert(minMaxI64[0] < BigInt(Number.MIN_SAFE_INTEGER)). assert(minMaxI64[1] > BigInt(Number.MAX_SAFE_INTEGER)); //log("int64_min/max() =",minMaxI64, typeof minMaxI64[0]); - w.xCall('sqlite3_wasm_test_int64_minmax', pMin, pMax); + w.xCall('sqlite3__wasm_test_int64_minmax', pMin, pMax); T.assert(g64(pMin) === minMaxI64[0], "int64 mismatch"). assert(g64(pMax) === minMaxI64[1], "int64 mismatch"); //log("pMin",g64(pMin), "pMax",g64(pMax)); @@ -2560,7 +2560,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////////// .t('Close db', function(){ T.assert(this.db).assert(wasm.isPtr(this.db.pointer)); - //wasm.sqlite3_wasm_db_reset(this.db); // will leak virtual tables! + //wasm.sqlite3__wasm_db_reset(this.db); // will leak virtual tables! this.db.close(); T.assert(!this.db.pointer); }) @@ -2892,7 +2892,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; const pVfs = this.opfsVfs = capi.sqlite3_vfs_find('opfs'); T.assert(pVfs); const unlink = this.opfsUnlink = - (fn=filename)=>{wasm.sqlite3_wasm_vfs_unlink(pVfs,fn)}; + (fn=filename)=>{sqlite3.util.sqlite3__wasm_vfs_unlink(pVfs,fn)}; unlink(); let db = new sqlite3.oo1.OpfsDb(filename); try { @@ -3209,6 +3209,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; print: log, printErr: error }).then(async function(sqlite3){ + TestUtil.assert(!!sqlite3.util); log("Done initializing WASM/JS bits. Running tests..."); sqlite3.config.warn("Installing sqlite3 bits as global S for local dev/test purposes."); globalThis.S = sqlite3; @@ -3227,9 +3228,9 @@ globalThis.sqlite3InitModule = sqlite3InitModule; logClass('warning',"BigInt/int64 support is disabled."); } if(haveWasmCTests()){ - log("sqlite3_wasm_test_...() APIs are available."); + log("sqlite3__wasm_test_...() APIs are available."); }else{ - logClass('warning',"sqlite3_wasm_test_...() APIs unavailable."); + logClass('warning',"sqlite3__wasm_test_...() APIs unavailable."); } log("registered vfs list =",capi.sqlite3_js_vfs_list().join(', ')); TestUtil.runTests(sqlite3); diff --git a/manifest b/manifest index 30972b2b7b..3ae52dc786 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sALWAYS()\sfrom\sRTREE.\s\sDbsqlfuzz\sfound\sa\sway\sto\smake\sit\sfalse. -D 2024-01-07T20:27:54.639 +C Make\sexplicit\swhich\sJS\sAPIs\sare\sfor\sinternal\suse\sonly\sby\smoving\sthe\sJS-bound\sinternal-use-only\sfunctions\sout\sof\sclient-visible\sreach\sand\srenaming\sthe\sWASM-exported\sones\sfrom\ssqlite3_wasm...\sto\ssqlite3__wasm...\s(with\stwo\sunderscores).\sThese\shave\salways\sbeen\sdocumented\sas\sinternal-use-only,\sso\sthis\sis\snot\sa\sbreaking\schange\sexcept\sfor\sclients\swhich\shave\signored\sthe\sdocs. +D 2024-01-08T07:52:47.965 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -575,7 +575,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 99aad6d6a28c43573f80825e986427c1a024a3298aaf0c69c56a0c6b336f12c8 +F ext/wasm/GNUmakefile 0f4ccfd350a9b0ebe60183fb4ad3b41c670eec62c88279f22e2627887b524b3c F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -593,16 +593,16 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.js 119b91c8a7ce6648679eb66fcdd1ed07ef7fd892eb501d658fbfefcc962012d9 +F ext/wasm/api/sqlite3-api-glue.js 8f4478c927466245259478788c293810bc812ac8c49df38c62574966d836131a F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0 -F ext/wasm/api/sqlite3-api-prologue.js 9aeba7b45cf41b3a26d34d7fb2525633cd1adfc544888c1ea8dbb077496f4ce9 -F ext/wasm/api/sqlite3-api-worker1.js fd46628ef147dd5856c88f63a9a279a40f744f1fdfddd55251ad8fbc3d8200ae +F ext/wasm/api/sqlite3-api-prologue.js fffcee629bf020a8ccf5c367fbe6a169f5d5d73dfce1707a75c9fbf4aa21c7da +F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 F ext/wasm/api/sqlite3-v-helper.js 7daa0eab0a513a25b05e9abae7b5beaaa39209b3ed12f86aeae9ef8d2719ed25 F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 595953994aa3ae2287c889c4da39ab3d6f17b6461ecf4bec334b7a3faafddb02 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 46c4afa6c50d7369252c104f274ad977a97e91ccfafc38b400fe36e90bdda88e -F ext/wasm/api/sqlite3-wasm.c dfd1f1a225b267e8fd641dcd6c7d579fbe2b731aeaa123324135efac830a2bcf +F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js f234191fe6bf41a5a1e59c9f43ed816e74a522b3d60d3f556f66c3085c448503 F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -627,7 +627,7 @@ F ext/wasm/dist.make 3a851858aad72e246a5d9c5aaf6b6a144305f1bf898ac1846760ea7bab9 F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle.make fa2ba6e90457ba2a71cb745f200d409caf773076df75ae5b177cc225d7627a11 F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f -F ext/wasm/fiddle/fiddle-worker.js e0153f9af6500805c6f09c0b3cfdb7d857e9d6863dbee9d50d1628fccf5f4b4d +F ext/wasm/fiddle/fiddle-worker.js 9be57887756c6854dbdcb5e7d8b7a26935d565491333a2f91dc4113598c659b5 F ext/wasm/fiddle/fiddle.js 974b995119ac443685d7d94d3b3c58c6a36540e9eb3fed7069d5653284071715 F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2 F ext/wasm/index-dist.html e91d76e4581185238fd3d42ed86ec600f7023ed3e3a944c5c356f25304bf1263 @@ -640,7 +640,7 @@ F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd84223150 F ext/wasm/speedtest1-wasmfs.html 0e9d335a9b5b5fafe6e1bc8dc0f0ca7e22e6eb916682a2d7c36218bb7d67379d F ext/wasm/speedtest1-wasmfs.mjs ac5cadbf4ffe69e9eaac8b45e8523f030521e02bb67d654c6eb5236d9c456cbe F ext/wasm/speedtest1-worker.html 864b65ed78ce24847a348c180e7f267621a02ca027068a1863ec1c90187c1852 -F ext/wasm/speedtest1-worker.js 4d2ea70a3c24e05bdca78025202841f33d298c4fa9541a0070c3228661f89ecd +F ext/wasm/speedtest1-worker.js 95e549e13a4d35863a9a7fc66122b5f546c0130d3be7b06dfcc556eb66d24bde F ext/wasm/speedtest1.html ff048b4a623aa192e83e143e48f1ce2a899846dd42c023fdedc8772b6e3f07da F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0 @@ -649,7 +649,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js a92dc256738dbd1b50f142d1fd0c835294ba09b7bb6526650360e942f88cb63f +F ext/wasm/tester1.c-pp.js 7c51d19f3644904156a154ddedd7024539ffba1a4e2df5e1efe10333e5b91b8f F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2156,8 +2156,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7a5b42ff74882c58493dc8b710fde73d4ff251f5d42271d84be73ceaabc01698 -R e24ddedf31de297bbf4b76d307641631 -U drh -Z ac5f82bfe64ed7224d42f062673e1893 +P 40f0a29e6dd90fcb969d7c0e49728ba0ee8f31d9e8f502b9a21469620a8ad283 +R 31be0596762218f8c1e89235c4c8d052 +T *branch * wasm-post-3.45 +T *sym-wasm-post-3.45 * +T -sym-trunk * Cancelled\sby\sbranch. +U stephan +Z 0af9fee02d812416e8b303fb5ea1a236 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 215afe7261..c473c95c40 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -40f0a29e6dd90fcb969d7c0e49728ba0ee8f31d9e8f502b9a21469620a8ad283 \ No newline at end of file +0eddc20f37988df6bce5f407b69e4a315e5cca4af104586e6fe942f0d656cccd \ No newline at end of file From 20728a599e52fecad15f6e2d8658ec47f38d0225 Mon Sep 17 00:00:00 2001 From: larrybr Date: Wed, 10 Jan 2024 05:52:02 +0000 Subject: [PATCH 0005/1030] For CLI shell and other utilities, optionally avoid C runtime file I/O on Windows in favor of WIN32 calls, while nominally preserving FILE* API interfaces. (a WIP, awaiting build and testing) FossilOrigin-Name: 6be68be17927e72b1f1c4b93e781b7e9235876b3ad9512fe168e5b9d0b7b763a --- ext/consio/console_io.c | 84 ++++++++++++++++++++++++++++++++++++++++- ext/consio/console_io.h | 15 ++++++-- manifest | 21 ++++++----- manifest.uuid | 2 +- src/shell.c.in | 3 ++ 5 files changed, 109 insertions(+), 16 deletions(-) diff --git a/ext/consio/console_io.c b/ext/consio/console_io.c index 3acb0daa27..0630e90e16 100755 --- a/ext/consio/console_io.c +++ b/ext/consio/console_io.c @@ -593,6 +593,86 @@ oPutbUtf8(const char *cBuf, int nAccept){ # endif } +/* +** Flush the given output stream. Return non-zero for success, else 0. +*/ +#if !defined(SQLITE_CIO_NO_FLUSH) && !defined(SQLITE_CIO_NO_SETMODE) +SQLITE_INTERNAL_LINKAGE int +fFlushBuffer(FILE *pfOut){ +# if CIO_WIN_WC_XLATE && !defined(SHELL_OMIT_FIO_DUPE) + return FlushFileBuffers(handleOfFile(pfOut))? 1 : 0; +# else + return fflush(pfOut); +# endif +} +#endif + +# if CIO_WIN_WC_XLATE && !defined(SHELL_OMIT_FIO_DUPE) +static struct FileAltIds { + int fd; + HANDLE fh; +} altIdsOfFile(FILE *pf){ + struct FileAltIds rv = { _fileno(pf) }; + union { intptr_t osfh; HANDLE fh; } fid = { + (rv.fd>=0)? _get_osfhandle(rv.fd) : (intptr_t)INVALID_HANDLE_VALUE + }; + rv.fh = fid.fh; + return rv; +} + +SQLITE_INTERNAL_LINKAGE size_t +cfWrite(const void *buf, size_t osz, size_t ocnt, FILE *pf){ + size_t rv = 0; + struct FileAltIds fai = altIdsOfFile(pf); + int fmode = _setmode(fai.fd, _O_BINARY); + _setmode(fai.fd, fmode); + while( rv < ocnt ){ + size_t nbo = osz; + while( nbo > 0 ){ + DWORD dwno = (nbo>(1L<<24))? 1L<<24 : (DWORD)nbo; + BOOL wrc = TRUE; + BOOL genCR = (fmode & _O_TEXT)!=0; + if( genCR ){ + const char *pnl = (const char*)memchr(buf, '\n', nbo); + if( pnl ) nbo = pnl - (const char*)buf; + else genCR = 0; + } + if( dwno>0 ) wrc = WriteFile(fai.hf, buf, dwno, 0,0); + if( genCR && wrc ){ + wrc = WriteFile(fai.hf, "\r\n", 2, 0,0); + ++dwno; /* Skip over the LF */ + } + if( !wrc ) return rv; + buf = (const char*)buf + dwno; + nbo += dwno; + } + ++rv; + } + return rv; +} + +SQLITE_INTERNAL_LINKAGE char * +cfGets(char *cBuf, int n, FILE *pf){ + int nci = 0; + struct FileAltIds fai = altIdsOfFile(pf); + int fmode = _setmode(fai.fd, _O_BINARY); + BOOL eatCR = (fmode & _O_TEXT)!=0; + _setmode(fai.fd, fmode); + while( nci < n-1 ){ + char cin; + DWORD nr; + if( !ReadFile(fai.hf, cBuf+nci, 1, &nr, 0) || nr==0 ) break; + if( eatCR && cin=='\r' ) continue; + cBuf[nci++] = cin; + } + if( nci < n ) cBuf[nci] = 0; + return (nci>0)? cBuf : 0; +} +# else +# define cfWrite(b,os,no,f) fwrite(b,os,no,f) +# define cfGets(b,n,f) fgets(b,n,f) +# endif + # ifdef CONSIO_EPUTB SQLITE_INTERNAL_LINKAGE int ePutbUtf8(const char *cBuf, int nAccept){ @@ -604,7 +684,7 @@ ePutbUtf8(const char *cBuf, int nAccept){ return conZstrEmit(ppst, cBuf, nAccept); }else { # endif - return (int)fwrite(cBuf, 1, nAccept, pfErr); + return (int)cfWrite(cBuf, 1, nAccept, pfErr); # if CIO_WIN_WC_XLATE } # endif @@ -670,7 +750,7 @@ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){ # endif }else{ # endif - return fgets(cBuf, ncMax, pfIn); + return cfGets(cBuf, ncMax, pfIn); # if CIO_WIN_WC_XLATE } # endif diff --git a/ext/consio/console_io.h b/ext/consio/console_io.h index 26fd7dd946..1affa15bad 100644 --- a/ext/consio/console_io.h +++ b/ext/consio/console_io.h @@ -176,12 +176,19 @@ SQLITE_INTERNAL_LINKAGE int ePutbUtf8(const char *cBuf, int nAccept); #endif +/* +** Flush the given output stream. Return non-zero for success, else 0. +*/ +#if !defined(SQLITE_CIO_NO_FLUSH) && !defined(SQLITE_CIO_NO_SETMODE) +SQLITE_INTERNAL_LINKAGE int +fFlushBuffer(FILE *pfOut); +#endif + /* ** Collect input like fgets(...) with special provisions for input -** from the console on platforms that require same. Defers to the -** C library fgets() when input is not from the console. Newline -** translation may be done as set by set{Binary,Text}Mode(). As a -** convenience, pfIn==NULL is treated as stdin. +** from the console on such platforms as require same. Newline +** translation may be done as set by set{Binary,Text}Mode(). +** As a convenience, pfIn==NULL is treated as stdin. */ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn); /* Like fGetsUtf8 except stream is always the designated input. */ diff --git a/manifest b/manifest index 467ba30c52..1c2810a843 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sresolution\sof\sunqualified\snames\sin\sthe\sREINDEX\scommand.\n[forum:/info/74cd0ceabd|Forum\sthread\s74cd0ceabd]. -D 2024-01-09T12:28:51.969 +C For\sCLI\sshell\sand\sother\sutilities,\soptionally\savoid\sC\sruntime\sfile\sI/O\son\sWindows\sin\sfavor\sof\sWIN32\scalls,\swhile\snominally\spreserving\sFILE*\sAPI\sinterfaces.\s(a\sWIP,\sawaiting\sbuild\sand\stesting) +D 2024-01-10T05:52:02.536 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -51,8 +51,8 @@ F ext/README.md fd5f78013b0a2bc6f0067afb19e6ad040e89a10179b4f6f03eee58fac5f169bd F ext/async/README.txt e12275968f6fde133a80e04387d0e839b0c51f91 F ext/async/sqlite3async.c 6f247666b495c477628dd19364d279c78ea48cd90c72d9f9b98ad1aff3294f94 F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a49808287f04aa5309a -F ext/consio/console_io.c e1be639e79e54264b3ae97ca291728987a9aa82e6a4526458e6400f5e083e524 x -F ext/consio/console_io.h 0548b83d7c4b7270ad544a67f2bb90cebc519637fa39b1838df4744cf0d87646 +F ext/consio/console_io.c 23c4ce0448a93803eb93e47ed46e4ffd5efb9001d7e18230737082612b1573de x +F ext/consio/console_io.h b5ebe34aa15b357621ebbea3d3f2e2b24750d4280b5802516409e23947fd9ee5 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 F ext/expert/expert1.test 0dd5cb096d66bed593e33053a3b364f6ef52ed72064bf5cf298364636dbf3cd6 @@ -738,7 +738,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c e25f51a473a5f30a0d978e4df2aaa98aeec84eac29ecae1ad4708a6c3e669345 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da -F src/shell.c.in 3d19abd924ed1cec9c9908d5a10cb1580b8ca30df24c26bfe80efa0c00f664d8 +F src/shell.c.in aff59dbd24dcee008dc64a3b0aa8b58d5fa43c5fd0fd9893a81ed6fd538ba6ac F src/sqlite.h.in 61a60b4ea04db8ead15e1579b20b64cb56e9f55d52c5f9f9694de630110593a3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2157,8 +2157,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cd016f26bb61549a304f2148035e050f76a8f4a35cdb7131bba2f5fc5d09f49e -R 79992c442c5c0c9ae7a8d7762db4a7c0 -U drh -Z 0f0f16e628a0bab1003ad4c460a1aa8e +P 97709ce2a1f5ae05495e412ca27108048e5b8a63a1e3bca4be13933f7527da7b +R 1d946ec61d5c9d01acdd2c0e650e9027 +T *branch * win-dupe-crt-fio +T *sym-win-dupe-crt-fio * +T -sym-trunk * +U larrybr +Z 0b0925e801b21e9b8c7d51a5b0a1c236 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cb966c2175..cc336ddfe9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -97709ce2a1f5ae05495e412ca27108048e5b8a63a1e3bca4be13933f7527da7b \ No newline at end of file +6be68be17927e72b1f1c4b93e781b7e9235876b3ad9512fe168e5b9d0b7b763a \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 19574dc79c..33f2ea9a76 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -246,6 +246,7 @@ extern LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText); # define SQLITE_CIO_NO_CLASSIFY # define SQLITE_CIO_NO_TRANSLATE # define SQLITE_CIO_NO_SETMODE +# define SQLITE_CIO_NO_FLUSH #endif INCLUDE ../ext/consio/console_io.h INCLUDE ../ext/consio/console_io.c @@ -276,6 +277,7 @@ INCLUDE ../ext/consio/console_io.c # define eputz(z) ePutsUtf8(z) # define eputf ePrintfUtf8 # define oputb(buf,na) oPutbUtf8(buf,na) +# define fflush(s) fFlushBuffer(s); #else /* For Fiddle, all console handling and emit redirection is omitted. */ @@ -286,6 +288,7 @@ INCLUDE ../ext/consio/console_io.c # define eputz(z) fputs(z,stderr) # define eputf(fmt, ...) fprintf(stderr,fmt,__VA_ARGS__) # define oputb(buf,na) fwrite(buf,1,na,stdout) +# undef fflush #endif /* True if the timer is enabled */ From 3a39c44c21a801927f98aa3cdb2240f00e701b8a Mon Sep 17 00:00:00 2001 From: larrybr Date: Wed, 10 Jan 2024 20:13:38 +0000 Subject: [PATCH 0006/1030] Fix a few compiler gripes. FossilOrigin-Name: 2e74a938f771a889dd8c49648b5a125ff748835ba1925388cc6b379a0abde9ac --- ext/consio/console_io.c | 10 ++++------ manifest | 15 ++++++--------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/ext/consio/console_io.c b/ext/consio/console_io.c index 0630e90e16..8ecd97f0b2 100755 --- a/ext/consio/console_io.c +++ b/ext/consio/console_io.c @@ -637,9 +637,9 @@ cfWrite(const void *buf, size_t osz, size_t ocnt, FILE *pf){ if( pnl ) nbo = pnl - (const char*)buf; else genCR = 0; } - if( dwno>0 ) wrc = WriteFile(fai.hf, buf, dwno, 0,0); + if( dwno>0 ) wrc = WriteFile(fai.fh, buf, dwno, 0,0); if( genCR && wrc ){ - wrc = WriteFile(fai.hf, "\r\n", 2, 0,0); + wrc = WriteFile(fai.fh, "\r\n", 2, 0,0); ++dwno; /* Skip over the LF */ } if( !wrc ) return rv; @@ -659,11 +659,9 @@ cfGets(char *cBuf, int n, FILE *pf){ BOOL eatCR = (fmode & _O_TEXT)!=0; _setmode(fai.fd, fmode); while( nci < n-1 ){ - char cin; DWORD nr; - if( !ReadFile(fai.hf, cBuf+nci, 1, &nr, 0) || nr==0 ) break; - if( eatCR && cin=='\r' ) continue; - cBuf[nci++] = cin; + if( !ReadFile(fai.fh, cBuf+nci, 1, &nr, 0) || nr==0 ) break; + if( nr>0 && (!eatCR || cBuf[nci]!='\r') ) nci += nr; } if( nci < n ) cBuf[nci] = 0; return (nci>0)? cBuf : 0; diff --git a/manifest b/manifest index 1c2810a843..05fe008c4e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sCLI\sshell\sand\sother\sutilities,\soptionally\savoid\sC\sruntime\sfile\sI/O\son\sWindows\sin\sfavor\sof\sWIN32\scalls,\swhile\snominally\spreserving\sFILE*\sAPI\sinterfaces.\s(a\sWIP,\sawaiting\sbuild\sand\stesting) -D 2024-01-10T05:52:02.536 +C Fix\sa\sfew\scompiler\sgripes. +D 2024-01-10T20:13:38.259 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -51,7 +51,7 @@ F ext/README.md fd5f78013b0a2bc6f0067afb19e6ad040e89a10179b4f6f03eee58fac5f169bd F ext/async/README.txt e12275968f6fde133a80e04387d0e839b0c51f91 F ext/async/sqlite3async.c 6f247666b495c477628dd19364d279c78ea48cd90c72d9f9b98ad1aff3294f94 F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a49808287f04aa5309a -F ext/consio/console_io.c 23c4ce0448a93803eb93e47ed46e4ffd5efb9001d7e18230737082612b1573de x +F ext/consio/console_io.c 3f635b6dd2ddbc722aeaa738d415768c9a40dedff53894975816dcbd7711145f x F ext/consio/console_io.h b5ebe34aa15b357621ebbea3d3f2e2b24750d4280b5802516409e23947fd9ee5 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 @@ -2157,11 +2157,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 97709ce2a1f5ae05495e412ca27108048e5b8a63a1e3bca4be13933f7527da7b -R 1d946ec61d5c9d01acdd2c0e650e9027 -T *branch * win-dupe-crt-fio -T *sym-win-dupe-crt-fio * -T -sym-trunk * +P 6be68be17927e72b1f1c4b93e781b7e9235876b3ad9512fe168e5b9d0b7b763a +R 2f77944a93e4bc36153f9450a52f3c42 U larrybr -Z 0b0925e801b21e9b8c7d51a5b0a1c236 +Z 5b64f41a30f93cac02d6a6331bee0468 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cc336ddfe9..9db802f7c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6be68be17927e72b1f1c4b93e781b7e9235876b3ad9512fe168e5b9d0b7b763a \ No newline at end of file +2e74a938f771a889dd8c49648b5a125ff748835ba1925388cc6b379a0abde9ac \ No newline at end of file From 598328209f421d48e98115dd6816da5114403616 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jan 2024 12:31:58 +0000 Subject: [PATCH 0007/1030] Split the JS vfs/vtab helper code into discreet units as a step towards a build which optionally elides those pieces. This is an internal restructuring change and does not affect the API. FossilOrigin-Name: ede945fd2360097d9961b8a4b8fb48fea57399cb9163534ed1c3c6b86588b0a5 --- ext/wasm/GNUmakefile | 6 +- ext/wasm/api/README.md | 10 +- ext/wasm/api/sqlite3-api-glue.js | 207 +++++++++++- ext/wasm/api/sqlite3-vfs-helper.c-pp.js | 103 ++++++ ...-helper.js => sqlite3-vtab-helper.c-pp.js} | 311 +----------------- manifest | 22 +- manifest.uuid | 2 +- 7 files changed, 334 insertions(+), 327 deletions(-) create mode 100644 ext/wasm/api/sqlite3-vfs-helper.c-pp.js rename ext/wasm/api/{sqlite3-v-helper.js => sqlite3-vtab-helper.c-pp.js} (57%) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index cbba48cc58..ac4a9cf8dd 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -433,8 +433,10 @@ sqlite3-api.jses += $(sqlite3-api-build-version.js) sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.js # sqlite3-api-worker.js = the Worker1 API: sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.js -# sqlite3-v-helper = helper APIs for VFSes and VTABLEs: -sqlite3-api.jses += $(dir.api)/sqlite3-v-helper.js +# sqlite3-vfs-helper = helper APIs for VFSes: +sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js +# sqlite3-vtab-helper = helper APIs for VTABLEs: +sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js # sqlite3-vfs-opfs.c-pp.js = the first OPFS VFS: sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js # sqlite3-vfs-opfs-sahpool.c-pp.js = the second OPFS VFS: diff --git a/ext/wasm/api/README.md b/ext/wasm/api/README.md index eb0f073cf7..ebd4aaacb1 100644 --- a/ext/wasm/api/README.md +++ b/ext/wasm/api/README.md @@ -78,10 +78,12 @@ browser client: a Promise-based interface into the Worker #1 API. This is a far user-friendlier way to interface with databases running in a Worker thread. -- **`sqlite3-v-helper.js`**\ - Installs `sqlite3.vfs` and `sqlite3.vtab`, namespaces which contain - helpers for use by downstream code which creates `sqlite3_vfs` - and `sqlite3_module` implementations. +- **`sqlite3-vfs-helper.js`**\ + Installs the `sqlite3.vfs` namespace, which contain helpers for use + by downstream code which creates `sqlite3_vfs` implementations. +- **`sqlite3-vtab-helper.js`**\ + Installs the `sqlite3.vtab` namespace, which contain helpers for use + by downstream code which creates `sqlite3_module` implementations. - **`sqlite3-vfs-opfs.c-pp.js`**\ is an sqlite3 VFS implementation which supports the Origin-Private FileSystem (OPFS) as a storage layer to provide persistent storage diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index e12c5162c6..63fb3c739c 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -329,6 +329,14 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } if(wasm.exports.sqlite3_activate_see instanceof Function){ + /** + This code is capable of using an SEE build but note that an SEE + WASM build is generally incompatible with SEE's license + conditions. It is permitted for use internally in organizations + which have licensed SEE, but not for public sites because + exposing an SEE build of sqlite3.wasm effectively provides all + clients with a working copy of the commercial SEE code. + */ wasm.bindingSignatures.push( ["sqlite3_key", "int", "sqlite3*", "string", "int"], ["sqlite3_key_v2","int","sqlite3*","string","*","int"], @@ -341,6 +349,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Functions which require BigInt (int64) support are separated from the others because we need to conditionally bind them or apply dummy impls, depending on the capabilities of the environment. + (That said: we never actually build without BigInt support, + and such builds are untested.) Note that not all of these functions directly require int64 but are only for use with APIs which require int64. For example, @@ -359,7 +369,10 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ /* Careful! Short version: de/serialize() are problematic because they might use a different allocator than the user for managing the deserialized block. de/serialize() are ONLY safe to use with - sqlite3_malloc(), sqlite3_free(), and its 64-bit variants. */, + sqlite3_malloc(), sqlite3_free(), and its 64-bit variants. Because + of this, the canonical builds of sqlite3.wasm/js guarantee that + sqlite3.wasm.alloc() and friends use those allocators. Custom builds + may not guarantee that, however. */, ["sqlite3_drop_modules", "int", ["sqlite3*", "**"]], ["sqlite3_last_insert_rowid", "i64", ["sqlite3*"]], ["sqlite3_malloc64", "*","i64"], @@ -422,8 +435,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ // Add session/changeset APIs... if(wasm.bigIntEnabled && !!wasm.exports.sqlite3changegroup_add){ - /* ACHTUNG: 2022-12-23: the session/changeset API bindings are - COMPLETELY UNTESTED. */ /** FuncPtrAdapter options for session-related callbacks with the native signature "i(ps)". This proxy converts the 2nd argument @@ -602,7 +613,12 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Functions which are intended solely for API-internal use by the WASM components, not client code. These get installed into sqlite3.util. Some of them get exposed to clients via variants - in wasm.sqlite3_js_...(). + in sqlite3_js_...(). + + 2024-01-11: these were renamed, with two underscores in the + prefix, to ensure that clients do not accidentally depend on + them. They have always been documented as internal-use-only, so + no clients "should" be depending on the old names. */ wasm.bindingSignatures.wasmInternal = [ ["sqlite3__wasm_db_reset", "int", "sqlite3*"], @@ -652,7 +668,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Use case: sqlite3_bind_pointer() and sqlite3_result_pointer() call for "a static string and preferably a string - literal". This converter is used to ensure that the string + literal." This converter is used to ensure that the string value seen by those functions is long-lived and behaves as they need it to. */ @@ -674,14 +690,15 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ `sqlite3_vfs*` via capi.sqlite3_vfs.pointer. */ const __xArgPtr = wasm.xWrap.argAdapter('*'); - const nilType = function(){}/*a class no value can ever be an instance of*/; + const nilType = function(){ + /*a class which no value can ever be an instance of*/ + }; wasm.xWrap.argAdapter('sqlite3_filename', __xArgPtr) ('sqlite3_context*', __xArgPtr) ('sqlite3_value*', __xArgPtr) ('void*', __xArgPtr) ('sqlite3_changegroup*', __xArgPtr) ('sqlite3_changeset_iter*', __xArgPtr) - //('sqlite3_rebaser*', __xArgPtr) ('sqlite3_session*', __xArgPtr) ('sqlite3_stmt*', (v)=> __xArgPtr((v instanceof (sqlite3?.oo1?.Stmt || nilType)) @@ -1667,5 +1684,181 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } }/*pKvvfs*/ + /* Warn if client-level code makes use of FuncPtrAdapter. */ wasm.xWrap.FuncPtrAdapter.warnOnUse = true; + + const StructBinder = sqlite3.StructBinder + /* we require a local alias b/c StructBinder is removed from the sqlite3 + object during the final steps of the API cleanup. */; + /** + Installs a StructBinder-bound function pointer member of the + given name and function in the given StructBinder.StructType + target object. + + It creates a WASM proxy for the given function and arranges for + that proxy to be cleaned up when tgt.dispose() is called. Throws + on the slightest hint of error, e.g. tgt is-not-a StructType, + name does not map to a struct-bound member, etc. + + As a special case, if the given function is a pointer, then + `wasm.functionEntry()` is used to validate that it is a known + function. If so, it is used as-is with no extra level of proxying + or cleanup, else an exception is thrown. It is legal to pass a + value of 0, indicating a NULL pointer, with the caveat that 0 + _is_ a legal function pointer in WASM but it will not be accepted + as such _here_. (Justification: the function at address zero must + be one which initially came from the WASM module, not a method we + want to bind to a virtual table or VFS.) + + This function returns a proxy for itself which is bound to tgt + and takes 2 args (name,func). That function returns the same + thing as this one, permitting calls to be chained. + + If called with only 1 arg, it has no side effects but returns a + func with the same signature as described above. + + ACHTUNG: because we cannot generically know how to transform JS + exceptions into result codes, the installed functions do no + automatic catching of exceptions. It is critical, to avoid + undefined behavior in the C layer, that methods mapped via + this function do not throw. The exception, as it were, to that + rule is... + + If applyArgcCheck is true then each JS function (as opposed to + function pointers) gets wrapped in a proxy which asserts that it + is passed the expected number of arguments, throwing if the + argument count does not match expectations. That is only intended + for dev-time usage for sanity checking, and may leave the C + environment in an undefined state. + */ + const installMethod = function callee( + tgt, name, func, applyArgcCheck = callee.installMethodArgcCheck + ){ + if(!(tgt instanceof StructBinder.StructType)){ + toss("Usage error: target object is-not-a StructType."); + }else if(!(func instanceof Function) && !wasm.isPtr(func)){ + toss("Usage errror: expecting a Function or WASM pointer to one."); + } + if(1===arguments.length){ + return (n,f)=>callee(tgt, n, f, applyArgcCheck); + } + if(!callee.argcProxy){ + callee.argcProxy = function(tgt, funcName, func,sig){ + return function(...args){ + if(func.length!==arguments.length){ + toss("Argument mismatch for", + tgt.structInfo.name+"::"+funcName + +": Native signature is:",sig); + } + return func.apply(this, args); + } + }; + /* An ondispose() callback for use with + StructBinder-created types. */ + callee.removeFuncList = function(){ + if(this.ondispose.__removeFuncList){ + this.ondispose.__removeFuncList.forEach( + (v,ndx)=>{ + if('number'===typeof v){ + try{wasm.uninstallFunction(v)} + catch(e){/*ignore*/} + } + /* else it's a descriptive label for the next number in + the list. */ + } + ); + delete this.ondispose.__removeFuncList; + } + }; + }/*static init*/ + const sigN = tgt.memberSignature(name); + if(sigN.length<2){ + toss("Member",name,"does not have a function pointer signature:",sigN); + } + const memKey = tgt.memberKey(name); + const fProxy = (applyArgcCheck && !wasm.isPtr(func)) + /** This middle-man proxy is only for use during development, to + confirm that we always pass the proper number of + arguments. We know that the C-level code will always use the + correct argument count. */ + ? callee.argcProxy(tgt, memKey, func, sigN) + : func; + if(wasm.isPtr(fProxy)){ + if(fProxy && !wasm.functionEntry(fProxy)){ + toss("Pointer",fProxy,"is not a WASM function table entry."); + } + tgt[memKey] = fProxy; + }else{ + const pFunc = wasm.installFunction(fProxy, tgt.memberSignature(name, true)); + tgt[memKey] = pFunc; + if(!tgt.ondispose || !tgt.ondispose.__removeFuncList){ + tgt.addOnDispose('ondispose.__removeFuncList handler', + callee.removeFuncList); + tgt.ondispose.__removeFuncList = []; + } + tgt.ondispose.__removeFuncList.push(memKey, pFunc); + } + return (n,f)=>callee(tgt, n, f, applyArgcCheck); + }/*installMethod*/; + installMethod.installMethodArgcCheck = false; + + /** + Installs methods into the given StructBinder.StructType-type + instance. Each entry in the given methods object must map to a + known member of the given StructType, else an exception will be + triggered. See installMethod() for more details, including the + semantics of the 3rd argument. + + As an exception to the above, if any two or more methods in the + 2nd argument are the exact same function, installMethod() is + _not_ called for the 2nd and subsequent instances, and instead + those instances get assigned the same method pointer which is + created for the first instance. This optimization is primarily to + accommodate special handling of sqlite3_module::xConnect and + xCreate methods. + + On success, returns its first argument. Throws on error. + */ + const installMethods = function( + structInstance, methods, applyArgcCheck = installMethod.installMethodArgcCheck + ){ + const seen = new Map /* map of */; + for(const k of Object.keys(methods)){ + const m = methods[k]; + const prior = seen.get(m); + if(prior){ + const mkey = structInstance.memberKey(k); + structInstance[mkey] = structInstance[structInstance.memberKey(prior)]; + }else{ + installMethod(structInstance, k, m, applyArgcCheck); + seen.set(m, k); + } + } + return structInstance; + }; + + /** + Equivalent to calling installMethod(this,...arguments) with a + first argument of this object. If called with 1 or 2 arguments + and the first is an object, it's instead equivalent to calling + installMethods(this,...arguments). + */ + StructBinder.StructType.prototype.installMethod = function callee( + name, func, applyArgcCheck = installMethod.installMethodArgcCheck + ){ + return (arguments.length < 3 && name && 'object'===typeof name) + ? installMethods(this, ...arguments) + : installMethod(this, ...arguments); + }; + + /** + Equivalent to calling installMethods() with a first argument + of this object. + */ + StructBinder.StructType.prototype.installMethods = function( + methods, applyArgcCheck = installMethod.installMethodArgcCheck + ){ + return installMethods(this, methods, applyArgcCheck); + }; + }); diff --git a/ext/wasm/api/sqlite3-vfs-helper.c-pp.js b/ext/wasm/api/sqlite3-vfs-helper.c-pp.js new file mode 100644 index 0000000000..0065d9547c --- /dev/null +++ b/ext/wasm/api/sqlite3-vfs-helper.c-pp.js @@ -0,0 +1,103 @@ +/* +** 2022-11-30 +** +** 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 installs sqlite3.vfs, an object which exists to assist + in the creation of JavaScript implementations of sqlite3_vfs. +*/ +'use strict'; +globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ + const wasm = sqlite3.wasm, capi = sqlite3.capi, toss = sqlite3.util.toss3; + const vfs = Object.create(null); + sqlite3.vfs = vfs; + + /** + Uses sqlite3_vfs_register() to register this + sqlite3.capi.sqlite3_vfs. This object must have already been + filled out properly. If the first argument is truthy, the VFS is + registered as the default VFS, else it is not. + + On success, returns this object. Throws on error. + */ + capi.sqlite3_vfs.prototype.registerVfs = function(asDefault=false){ + if(!(this instanceof sqlite3.capi.sqlite3_vfs)){ + toss("Expecting a sqlite3_vfs-type argument."); + } + const rc = capi.sqlite3_vfs_register(this, asDefault ? 1 : 0); + if(rc){ + toss("sqlite3_vfs_register(",this,") failed with rc",rc); + } + if(this.pointer !== capi.sqlite3_vfs_find(this.$zName)){ + toss("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS", + this); + } + return this; + }; + + /** + A wrapper for + sqlite3.StructBinder.StructType.prototype.installMethods() or + registerVfs() to reduce installation of a VFS and/or its I/O + methods to a single call. + + Accepts an object which contains the properties "io" and/or + "vfs", each of which is itself an object with following properties: + + - `struct`: an sqlite3.StructBinder.StructType-type struct. This + must be a populated (except for the methods) object of type + sqlite3_io_methods (for the "io" entry) or sqlite3_vfs (for the + "vfs" entry). + + - `methods`: an object mapping sqlite3_io_methods method names + (e.g. 'xClose') to JS implementations of those methods. The JS + implementations must be call-compatible with their native + counterparts. + + For each of those object, this function passes its (`struct`, + `methods`, (optional) `applyArgcCheck`) properties to + installMethods(). + + If the `vfs` entry is set then: + + - Its `struct` property's registerVfs() is called. The + `vfs` entry may optionally have an `asDefault` property, which + gets passed as the argument to registerVfs(). + + - If `struct.$zName` is falsy and the entry has a string-type + `name` property, `struct.$zName` is set to the C-string form of + that `name` value before registerVfs() is called. That string + gets added to the on-dispose state of the struct. + + On success returns this object. Throws on error. + */ + vfs.installVfs = function(opt){ + let count = 0; + const propList = ['io','vfs']; + for(const key of propList){ + const o = opt[key]; + if(o){ + ++count; + o.struct.installMethods(o.methods, !!o.applyArgcCheck); + if('vfs'===key){ + if(!o.struct.$zName && 'string'===typeof o.name){ + o.struct.addOnDispose( + o.struct.$zName = wasm.allocCString(o.name) + ); + } + o.struct.registerVfs(!!o.asDefault); + } + } + } + if(!count) toss("Misuse: installVfs() options object requires at least", + "one of:", propList); + return this; + }; +}/*sqlite3ApiBootstrap.initializers.push()*/); diff --git a/ext/wasm/api/sqlite3-v-helper.js b/ext/wasm/api/sqlite3-vtab-helper.c-pp.js similarity index 57% rename from ext/wasm/api/sqlite3-v-helper.js rename to ext/wasm/api/sqlite3-vtab-helper.c-pp.js index e63da8afc3..c069554a13 100644 --- a/ext/wasm/api/sqlite3-v-helper.js +++ b/ext/wasm/api/sqlite3-vtab-helper.c-pp.js @@ -10,19 +10,17 @@ */ /** - This file installs sqlite3.vfs, and object which exists to assist - in the creation of JavaScript implementations of sqlite3_vfs, along - with its virtual table counterpart, sqlite3.vtab. + This file installs sqlite3.vtab, an object which exists to assist + in the creation of JavaScript implementations virtual tables. + + Maintenance note: 2024-01-11: this file requires that StructBinder + has been extended with the installMethod(s)() methods, which + currently happens in sqlite3-api-glue.js. */ 'use strict'; globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ const wasm = sqlite3.wasm, capi = sqlite3.capi, toss = sqlite3.util.toss3; - const vfs = Object.create(null), vtab = Object.create(null); - - const StructBinder = sqlite3.StructBinder - /* we require a local alias b/c StructBinder is removed from the sqlite3 - object during the final steps of the API cleanup. */; - sqlite3.vfs = vfs; + const vtab = Object.create(null); sqlite3.vtab = vtab; const sii = capi.sqlite3_index_info; @@ -72,257 +70,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return asPtr ? ptr : new sii.sqlite3_index_orderby(ptr); }; - /** - Installs a StructBinder-bound function pointer member of the - given name and function in the given StructType target object. - - It creates a WASM proxy for the given function and arranges for - that proxy to be cleaned up when tgt.dispose() is called. Throws - on the slightest hint of error, e.g. tgt is-not-a StructType, - name does not map to a struct-bound member, etc. - - As a special case, if the given function is a pointer, then - `wasm.functionEntry()` is used to validate that it is a known - function. If so, it is used as-is with no extra level of proxying - or cleanup, else an exception is thrown. It is legal to pass a - value of 0, indicating a NULL pointer, with the caveat that 0 - _is_ a legal function pointer in WASM but it will not be accepted - as such _here_. (Justification: the function at address zero must - be one which initially came from the WASM module, not a method we - want to bind to a virtual table or VFS.) - - This function returns a proxy for itself which is bound to tgt - and takes 2 args (name,func). That function returns the same - thing as this one, permitting calls to be chained. - - If called with only 1 arg, it has no side effects but returns a - func with the same signature as described above. - - ACHTUNG: because we cannot generically know how to transform JS - exceptions into result codes, the installed functions do no - automatic catching of exceptions. It is critical, to avoid - undefined behavior in the C layer, that methods mapped via - this function do not throw. The exception, as it were, to that - rule is... - - If applyArgcCheck is true then each JS function (as opposed to - function pointers) gets wrapped in a proxy which asserts that it - is passed the expected number of arguments, throwing if the - argument count does not match expectations. That is only intended - for dev-time usage for sanity checking, and will leave the C - environment in an undefined state. - */ - const installMethod = function callee( - tgt, name, func, applyArgcCheck = callee.installMethodArgcCheck - ){ - if(!(tgt instanceof StructBinder.StructType)){ - toss("Usage error: target object is-not-a StructType."); - }else if(!(func instanceof Function) && !wasm.isPtr(func)){ - toss("Usage errror: expecting a Function or WASM pointer to one."); - } - if(1===arguments.length){ - return (n,f)=>callee(tgt, n, f, applyArgcCheck); - } - if(!callee.argcProxy){ - callee.argcProxy = function(tgt, funcName, func,sig){ - return function(...args){ - if(func.length!==arguments.length){ - toss("Argument mismatch for", - tgt.structInfo.name+"::"+funcName - +": Native signature is:",sig); - } - return func.apply(this, args); - } - }; - /* An ondispose() callback for use with - StructBinder-created types. */ - callee.removeFuncList = function(){ - if(this.ondispose.__removeFuncList){ - this.ondispose.__removeFuncList.forEach( - (v,ndx)=>{ - if('number'===typeof v){ - try{wasm.uninstallFunction(v)} - catch(e){/*ignore*/} - } - /* else it's a descriptive label for the next number in - the list. */ - } - ); - delete this.ondispose.__removeFuncList; - } - }; - }/*static init*/ - const sigN = tgt.memberSignature(name); - if(sigN.length<2){ - toss("Member",name,"does not have a function pointer signature:",sigN); - } - const memKey = tgt.memberKey(name); - const fProxy = (applyArgcCheck && !wasm.isPtr(func)) - /** This middle-man proxy is only for use during development, to - confirm that we always pass the proper number of - arguments. We know that the C-level code will always use the - correct argument count. */ - ? callee.argcProxy(tgt, memKey, func, sigN) - : func; - if(wasm.isPtr(fProxy)){ - if(fProxy && !wasm.functionEntry(fProxy)){ - toss("Pointer",fProxy,"is not a WASM function table entry."); - } - tgt[memKey] = fProxy; - }else{ - const pFunc = wasm.installFunction(fProxy, tgt.memberSignature(name, true)); - tgt[memKey] = pFunc; - if(!tgt.ondispose || !tgt.ondispose.__removeFuncList){ - tgt.addOnDispose('ondispose.__removeFuncList handler', - callee.removeFuncList); - tgt.ondispose.__removeFuncList = []; - } - tgt.ondispose.__removeFuncList.push(memKey, pFunc); - } - return (n,f)=>callee(tgt, n, f, applyArgcCheck); - }/*installMethod*/; - installMethod.installMethodArgcCheck = false; - - /** - Installs methods into the given StructType-type instance. Each - entry in the given methods object must map to a known member of - the given StructType, else an exception will be triggered. See - installMethod() for more details, including the semantics of the - 3rd argument. - - As an exception to the above, if any two or more methods in the - 2nd argument are the exact same function, installMethod() is - _not_ called for the 2nd and subsequent instances, and instead - those instances get assigned the same method pointer which is - created for the first instance. This optimization is primarily to - accommodate special handling of sqlite3_module::xConnect and - xCreate methods. - - On success, returns its first argument. Throws on error. - */ - const installMethods = function( - structInstance, methods, applyArgcCheck = installMethod.installMethodArgcCheck - ){ - const seen = new Map /* map of */; - for(const k of Object.keys(methods)){ - const m = methods[k]; - const prior = seen.get(m); - if(prior){ - const mkey = structInstance.memberKey(k); - structInstance[mkey] = structInstance[structInstance.memberKey(prior)]; - }else{ - installMethod(structInstance, k, m, applyArgcCheck); - seen.set(m, k); - } - } - return structInstance; - }; - - /** - Equivalent to calling installMethod(this,...arguments) with a - first argument of this object. If called with 1 or 2 arguments - and the first is an object, it's instead equivalent to calling - installMethods(this,...arguments). - */ - StructBinder.StructType.prototype.installMethod = function callee( - name, func, applyArgcCheck = installMethod.installMethodArgcCheck - ){ - return (arguments.length < 3 && name && 'object'===typeof name) - ? installMethods(this, ...arguments) - : installMethod(this, ...arguments); - }; - - /** - Equivalent to calling installMethods() with a first argument - of this object. - */ - StructBinder.StructType.prototype.installMethods = function( - methods, applyArgcCheck = installMethod.installMethodArgcCheck - ){ - return installMethods(this, methods, applyArgcCheck); - }; - - /** - Uses sqlite3_vfs_register() to register this - sqlite3.capi.sqlite3_vfs. This object must have already been - filled out properly. If the first argument is truthy, the VFS is - registered as the default VFS, else it is not. - - On success, returns this object. Throws on error. - */ - capi.sqlite3_vfs.prototype.registerVfs = function(asDefault=false){ - if(!(this instanceof sqlite3.capi.sqlite3_vfs)){ - toss("Expecting a sqlite3_vfs-type argument."); - } - const rc = capi.sqlite3_vfs_register(this, asDefault ? 1 : 0); - if(rc){ - toss("sqlite3_vfs_register(",this,") failed with rc",rc); - } - if(this.pointer !== capi.sqlite3_vfs_find(this.$zName)){ - toss("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS", - this); - } - return this; - }; - - /** - A wrapper for installMethods() or registerVfs() to reduce - installation of a VFS and/or its I/O methods to a single - call. - - Accepts an object which contains the properties "io" and/or - "vfs", each of which is itself an object with following properties: - - - `struct`: an sqlite3.StructType-type struct. This must be a - populated (except for the methods) object of type - sqlite3_io_methods (for the "io" entry) or sqlite3_vfs (for the - "vfs" entry). - - - `methods`: an object mapping sqlite3_io_methods method names - (e.g. 'xClose') to JS implementations of those methods. The JS - implementations must be call-compatible with their native - counterparts. - - For each of those object, this function passes its (`struct`, - `methods`, (optional) `applyArgcCheck`) properties to - installMethods(). - - If the `vfs` entry is set then: - - - Its `struct` property's registerVfs() is called. The - `vfs` entry may optionally have an `asDefault` property, which - gets passed as the argument to registerVfs(). - - - If `struct.$zName` is falsy and the entry has a string-type - `name` property, `struct.$zName` is set to the C-string form of - that `name` value before registerVfs() is called. That string - gets added to the on-dispose state of the struct. - - On success returns this object. Throws on error. - */ - vfs.installVfs = function(opt){ - let count = 0; - const propList = ['io','vfs']; - for(const key of propList){ - const o = opt[key]; - if(o){ - ++count; - installMethods(o.struct, o.methods, !!o.applyArgcCheck); - if('vfs'===key){ - if(!o.struct.$zName && 'string'===typeof o.name){ - o.struct.addOnDispose( - o.struct.$zName = wasm.allocCString(o.name) - ); - } - o.struct.registerVfs(!!o.asDefault); - } - } - } - if(!count) toss("Misuse: installVfs() options object requires at least", - "one of:", propList); - return this; - }; - /** Internal factory function for xVtab and xCursor impls. */ @@ -456,30 +203,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ */ vtab.xIndexInfo = (pIdxInfo)=>new capi.sqlite3_index_info(pIdxInfo); - /** - Given an error object, this function returns - sqlite3.capi.SQLITE_NOMEM if (e instanceof - sqlite3.WasmAllocError), else it returns its - second argument. Its intended usage is in the methods - of a sqlite3_vfs or sqlite3_module: - - ``` - try{ - let rc = ... - return rc; - }catch(e){ - return sqlite3.vtab.exceptionToRc(e, sqlite3.capi.SQLITE_XYZ); - // where SQLITE_XYZ is some call-appropriate result code. - } - ``` - */ - /**vfs.exceptionToRc = vtab.exceptionToRc = - (e, defaultRc=capi.SQLITE_ERROR)=>( - (e instanceof sqlite3.WasmAllocError) - ? capi.SQLITE_NOMEM - : defaultRc - );*/ - /** Given an sqlite3_module method name and error object, this function returns sqlite3.capi.SQLITE_NOMEM if (e instanceof @@ -525,20 +248,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }; vtab.xError.errorReporter = 1 ? console.error.bind(console) : false; - /** - "The problem" with this is that it introduces an outer function with - a different arity than the passed-in method callback. That means we - cannot do argc validation on these. Additionally, some methods (namely - xConnect) may have call-specific error handling. It would be a shame to - hard-coded that per-method support in this function. - */ - /** vtab.methodCatcher = function(methodName, method, defaultErrRc=capi.SQLITE_ERROR){ - return function(...args){ - try { method(...args); } - }catch(e){ return vtab.xError(methodName, e, defaultRc) } - }; - */ - /** A helper for sqlite3_vtab::xRowid() and xUpdate() implementations. It must be passed the final argument to one of @@ -685,12 +394,12 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ remethods[k] = fwrap(k, m); } } - installMethods(mod, remethods, false); + mod.installMethods(remethods, false); }else{ // No automatic exception handling. Trust the client // to not throw. - installMethods( - mod, methods, !!opt.applyArgcCheck/*undocumented option*/ + mod.installMethods( + methods, !!opt.applyArgcCheck/*undocumented option*/ ); } if(0===mod.$iVersion){ diff --git a/manifest b/manifest index 3ae52dc786..e50e307ac3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sexplicit\swhich\sJS\sAPIs\sare\sfor\sinternal\suse\sonly\sby\smoving\sthe\sJS-bound\sinternal-use-only\sfunctions\sout\sof\sclient-visible\sreach\sand\srenaming\sthe\sWASM-exported\sones\sfrom\ssqlite3_wasm...\sto\ssqlite3__wasm...\s(with\stwo\sunderscores).\sThese\shave\salways\sbeen\sdocumented\sas\sinternal-use-only,\sso\sthis\sis\snot\sa\sbreaking\schange\sexcept\sfor\sclients\swhich\shave\signored\sthe\sdocs. -D 2024-01-08T07:52:47.965 +C Split\sthe\sJS\svfs/vtab\shelper\scode\sinto\sdiscreet\sunits\sas\sa\sstep\stowards\sa\sbuild\swhich\soptionally\selides\sthose\spieces.\sThis\sis\san\sinternal\srestructuring\schange\sand\sdoes\snot\saffect\sthe\sAPI. +D 2024-01-11T12:31:58.929 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -575,7 +575,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 0f4ccfd350a9b0ebe60183fb4ad3b41c670eec62c88279f22e2627887b524b3c +F ext/wasm/GNUmakefile 693ff54a2710751a34ef4419a63eb7ea957f7e730f837fc1ef1dc475bdc5a6c8 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -586,22 +586,23 @@ F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f30 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api f442460ed9a109e637dd3ea1caa4489553ad9414e8988118b208bb7a4bbece6b F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 -F ext/wasm/api/README.md 5eb44fa02e9c693a1884a3692428647894b0380b24bca120866b7a24c8786134 +F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 F ext/wasm/api/extern-post-js.c-pp.js c4154a7f90c2d7e51fd6738273908152036c3457fdc0b6523f1be3ef51105aac F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41 F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08902f15c34720ee4a1 F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.js 8f4478c927466245259478788c293810bc812ac8c49df38c62574966d836131a +F ext/wasm/api/sqlite3-api-glue.js 81ec1423e8c6dc8c26a3af470c993460d2f5137319ab1a00581203017e8b6b1f F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0 F ext/wasm/api/sqlite3-api-prologue.js fffcee629bf020a8ccf5c367fbe6a169f5d5d73dfce1707a75c9fbf4aa21c7da F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 -F ext/wasm/api/sqlite3-v-helper.js 7daa0eab0a513a25b05e9abae7b5beaaa39209b3ed12f86aeae9ef8d2719ed25 +F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 6c02e969ad988e083415221e84445711730a321c748d8555bb61aebec6b4a37c w ext/wasm/api/sqlite3-v-helper.js F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 595953994aa3ae2287c889c4da39ab3d6f17b6461ecf4bec334b7a3faafddb02 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 46c4afa6c50d7369252c104f274ad977a97e91ccfafc38b400fe36e90bdda88e +F ext/wasm/api/sqlite3-vtab-helper.c-pp.js ebbabbd33915904d3135680a0ea25f374adb60d6f39d664994bc48ac1673c280 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js f234191fe6bf41a5a1e59c9f43ed816e74a522b3d60d3f556f66c3085c448503 F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 @@ -2156,11 +2157,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 40f0a29e6dd90fcb969d7c0e49728ba0ee8f31d9e8f502b9a21469620a8ad283 -R 31be0596762218f8c1e89235c4c8d052 -T *branch * wasm-post-3.45 -T *sym-wasm-post-3.45 * -T -sym-trunk * Cancelled\sby\sbranch. +P 0eddc20f37988df6bce5f407b69e4a315e5cca4af104586e6fe942f0d656cccd +R 1d7e7db8e9c4453b4e333bcfcd1a037e U stephan -Z 0af9fee02d812416e8b303fb5ea1a236 +Z d03852f251d26d93c85f34544dbc6738 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c473c95c40..e7c51869c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0eddc20f37988df6bce5f407b69e4a315e5cca4af104586e6fe942f0d656cccd \ No newline at end of file +ede945fd2360097d9961b8a4b8fb48fea57399cb9163534ed1c3c6b86588b0a5 \ No newline at end of file From bb9ab35ab14148cf28c3f7c8269d8af960ba7985 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jan 2024 12:56:03 +0000 Subject: [PATCH 0008/1030] Remove some dead JS code. Minor doc cleanups. FossilOrigin-Name: bf23cf204976516651b1c4c39ced21cd858dea4ba88052d96fc4f5f11525f170 --- ext/wasm/api/sqlite3-vfs-helper.c-pp.js | 10 +++++----- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 24 ++---------------------- ext/wasm/api/sqlite3-vtab-helper.c-pp.js | 8 ++------ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 18 insertions(+), 42 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-helper.c-pp.js b/ext/wasm/api/sqlite3-vfs-helper.c-pp.js index 0065d9547c..4d29c7b91a 100644 --- a/ext/wasm/api/sqlite3-vfs-helper.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-helper.c-pp.js @@ -10,8 +10,8 @@ */ /** - This file installs sqlite3.vfs, an object which exists to assist - in the creation of JavaScript implementations of sqlite3_vfs. + This file installs sqlite3.vfs, a namespace of helpers for use in + the creation of JavaScript implementations of sqlite3_vfs. */ 'use strict'; globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ @@ -21,9 +21,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ /** Uses sqlite3_vfs_register() to register this - sqlite3.capi.sqlite3_vfs. This object must have already been - filled out properly. If the first argument is truthy, the VFS is - registered as the default VFS, else it is not. + sqlite3.capi.sqlite3_vfs instance. This object must have already + been filled out properly. If the first argument is truthy, the + VFS is registered as the default VFS, else it is not. On success, returns this object. Throws on error. */ diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index af89f216f7..f7c92100a0 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -245,7 +245,8 @@ const installOpfsVfs = function callee(options){ opfsIoMethods.$iVersion = 1; opfsVfs.$iVersion = 2/*yes, two*/; opfsVfs.$szOsFile = capi.sqlite3_file.structInfo.sizeof; - opfsVfs.$mxPathname = 1024/*sure, why not?*/; + opfsVfs.$mxPathname = 1024/* sure, why not? The OPFS name length limit + is undocumented/unspecified. */; opfsVfs.$zName = wasm.allocCString("opfs"); // All C-side memory of opfsVfs is zeroed out, but just to be explicit: opfsVfs.$xDlOpen = opfsVfs.$xDlError = opfsVfs.$xDlSym = opfsVfs.$xDlClose = null; @@ -993,27 +994,6 @@ const installOpfsVfs = function callee(options){ */ opfsUtil.randomFilename = randomFilename; - /** - Re-registers the OPFS VFS. This is intended only for odd use - cases which have to call sqlite3_shutdown() as part of their - initialization process, which will unregister the VFS - registered by installOpfsVfs(). If passed a truthy value, the - OPFS VFS is registered as the default VFS, else it is not made - the default. Returns the result of the the - sqlite3_vfs_register() call. - - Design note: the problem of having to re-register things after - a shutdown/initialize pair is more general. How to best plug - that in to the library is unclear. In particular, we cannot - hook in to any C-side calls to sqlite3_initialize(), so we - cannot add an after-initialize callback mechanism. - */ - opfsUtil.registerVfs = (asDefault=false)=>{ - return wasm.exports.sqlite3_vfs_register( - opfsVfs.pointer, asDefault ? 1 : 0 - ); - }; - /** Returns a promise which resolves to an object which represents all files and directories in the OPFS tree. The top-most object diff --git a/ext/wasm/api/sqlite3-vtab-helper.c-pp.js b/ext/wasm/api/sqlite3-vtab-helper.c-pp.js index c069554a13..7359ea39aa 100644 --- a/ext/wasm/api/sqlite3-vtab-helper.c-pp.js +++ b/ext/wasm/api/sqlite3-vtab-helper.c-pp.js @@ -10,12 +10,8 @@ */ /** - This file installs sqlite3.vtab, an object which exists to assist - in the creation of JavaScript implementations virtual tables. - - Maintenance note: 2024-01-11: this file requires that StructBinder - has been extended with the installMethod(s)() methods, which - currently happens in sqlite3-api-glue.js. + This file installs sqlite3.vtab, a namespace of helpers for use in + the creation of JavaScript implementations virtual tables. */ 'use strict'; globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ diff --git a/manifest b/manifest index e50e307ac3..087f72cc2a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Split\sthe\sJS\svfs/vtab\shelper\scode\sinto\sdiscreet\sunits\sas\sa\sstep\stowards\sa\sbuild\swhich\soptionally\selides\sthose\spieces.\sThis\sis\san\sinternal\srestructuring\schange\sand\sdoes\snot\saffect\sthe\sAPI. -D 2024-01-11T12:31:58.929 +C Remove\ssome\sdead\sJS\scode.\sMinor\sdoc\scleanups. +D 2024-01-11T12:56:03.352 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -599,10 +599,10 @@ F ext/wasm/api/sqlite3-api-prologue.js fffcee629bf020a8ccf5c367fbe6a169f5d5d73df F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 -F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 6c02e969ad988e083415221e84445711730a321c748d8555bb61aebec6b4a37c w ext/wasm/api/sqlite3-v-helper.js +F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 595953994aa3ae2287c889c4da39ab3d6f17b6461ecf4bec334b7a3faafddb02 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 46c4afa6c50d7369252c104f274ad977a97e91ccfafc38b400fe36e90bdda88e -F ext/wasm/api/sqlite3-vtab-helper.c-pp.js ebbabbd33915904d3135680a0ea25f374adb60d6f39d664994bc48ac1673c280 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js ebf6c7e997cd8948b35b3afc550b0503dd53febd9d2b56354efd11d985e5f0f2 +F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js f234191fe6bf41a5a1e59c9f43ed816e74a522b3d60d3f556f66c3085c448503 F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 @@ -2157,8 +2157,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0eddc20f37988df6bce5f407b69e4a315e5cca4af104586e6fe942f0d656cccd -R 1d7e7db8e9c4453b4e333bcfcd1a037e +P ede945fd2360097d9961b8a4b8fb48fea57399cb9163534ed1c3c6b86588b0a5 +R 3773101454a60b5af14ffec3a5e82fe8 U stephan -Z d03852f251d26d93c85f34544dbc6738 +Z 63b0feac805925513bf1a514b58f7275 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e7c51869c8..9648d6e54f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ede945fd2360097d9961b8a4b8fb48fea57399cb9163534ed1c3c6b86588b0a5 \ No newline at end of file +bf23cf204976516651b1c4c39ced21cd858dea4ba88052d96fc4f5f11525f170 \ No newline at end of file From 7a543f6fbffabdf4f274c16f29604ec026641f09 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jan 2024 14:21:15 +0000 Subject: [PATCH 0009/1030] Internal JS doc cleanups. FossilOrigin-Name: c8284170f66374fc528e9d6e5a03ee7321f27e80acf4360701a8b176497b7130 --- ext/wasm/api/post-js-header.js | 6 ++++-- ext/wasm/api/sqlite3-api-glue.js | 3 ++- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ext/wasm/api/post-js-header.js b/ext/wasm/api/post-js-header.js index 0e27e1fd94..7fd82a7d6c 100644 --- a/ext/wasm/api/post-js-header.js +++ b/ext/wasm/api/post-js-header.js @@ -19,8 +19,10 @@ Module.postRun.push(function(Module/*the Emscripten-style module object*/){ - sqlite3-api-glue.js => glues previous parts together - sqlite3-api-oo.js => SQLite3 OO API #1 - sqlite3-api-worker1.js => Worker-based API - - sqlite3-vfs-helper.js => Internal-use utilities for... - - sqlite3-vfs-opfs.js => OPFS VFS + - sqlite3-vfs-helper.c-pp.js => Utilities for VFS impls + - sqlite3-vtab-helper.c-pp.js => Utilities for virtual table impls + - sqlite3-vfs-opfs.c-pp.js => OPFS VFS + - sqlite3-vfs-opfs-sahpool.c-pp.js => OPFS SAHPool VFS - sqlite3-api-cleanup.js => final API cleanup - post-js-footer.js => closes this postRun() function */ diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index 63fb3c739c..2cb4c800d2 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -14,7 +14,8 @@ previous steps of the sqlite3-api.js bootstrapping process: sqlite3-api-prologue.js, whwasmutil.js, and jaccwabyt.js. It initializes the main API pieces so that the downstream components - (e.g. sqlite3-api-oo1.js) have all that they need. + (e.g. sqlite3-api-oo1.js) have all of the infrastructure that they + need. */ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ 'use strict'; diff --git a/manifest b/manifest index 087f72cc2a..3748fa6b01 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sdead\sJS\scode.\sMinor\sdoc\scleanups. -D 2024-01-11T12:56:03.352 +C Internal\sJS\sdoc\scleanups. +D 2024-01-11T14:21:15.997 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -590,10 +590,10 @@ F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639 F ext/wasm/api/extern-post-js.c-pp.js c4154a7f90c2d7e51fd6738273908152036c3457fdc0b6523f1be3ef51105aac F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41 F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08902f15c34720ee4a1 -F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62 +F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.js 81ec1423e8c6dc8c26a3af470c993460d2f5137319ab1a00581203017e8b6b1f +F ext/wasm/api/sqlite3-api-glue.js 587dc6db2d69329a5f4cb9635c377f516cf4a8e30f443f33380e5044889ec71b F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0 F ext/wasm/api/sqlite3-api-prologue.js fffcee629bf020a8ccf5c367fbe6a169f5d5d73dfce1707a75c9fbf4aa21c7da F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf @@ -2157,8 +2157,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ede945fd2360097d9961b8a4b8fb48fea57399cb9163534ed1c3c6b86588b0a5 -R 3773101454a60b5af14ffec3a5e82fe8 +P bf23cf204976516651b1c4c39ced21cd858dea4ba88052d96fc4f5f11525f170 +R e6ab7f42561dbf7e5d9624bfb9b0bf26 U stephan -Z 63b0feac805925513bf1a514b58f7275 +Z 562f2a1dff86c554fee852503a03b96a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9648d6e54f..27445cc530 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf23cf204976516651b1c4c39ced21cd858dea4ba88052d96fc4f5f11525f170 \ No newline at end of file +c8284170f66374fc528e9d6e5a03ee7321f27e80acf4360701a8b176497b7130 \ No newline at end of file From 2fe917cfa5b44d2ef978216c1b5368f1297a3c4f Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jan 2024 16:10:22 +0000 Subject: [PATCH 0010/1030] wasm build: reformulate an awk invocation to account for awks which do not support the -e flag. Problem reported on the forum via a docker-hosted build. FossilOrigin-Name: 5836657929d7d6d3f0d5865c9f6de4e4c00edd53d15a246802b375fa15d0f255 --- ext/wasm/GNUmakefile | 7 +++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index ac4a9cf8dd..0865492cf5 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -655,6 +655,9 @@ $(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE) ######################################################################## # $(sqlite3-license-version.js) contains the license header and # in-comment build version info. +# +# Maintenance reminder: there are awk binaries out there which do not +# support -e SCRIPT. $(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.js) \ $(MAKEFILE) @echo "Making $@..."; { \ @@ -662,8 +665,8 @@ $(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.js) echo '/*'; \ echo '** This code was built from sqlite3 version...'; \ echo "**"; \ - awk -e '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' \ - -e '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \ + awk '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' $(sqlite3.h); \ + awk '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \ echo "**"; \ echo "** Using the Emscripten SDK version $(emcc.version)."; \ echo '*/'; \ diff --git a/manifest b/manifest index 3748fa6b01..cfc9843ec7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Internal\sJS\sdoc\scleanups. -D 2024-01-11T14:21:15.997 +C wasm\sbuild:\sreformulate\san\sawk\sinvocation\sto\saccount\sfor\sawks\swhich\sdo\snot\ssupport\sthe\s-e\sflag.\sProblem\sreported\son\sthe\sforum\svia\sa\sdocker-hosted\sbuild. +D 2024-01-11T16:10:22.408 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -575,7 +575,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 693ff54a2710751a34ef4419a63eb7ea957f7e730f837fc1ef1dc475bdc5a6c8 +F ext/wasm/GNUmakefile 867c903a27fa0d53a3bf1b01d8c7bb713456f87e0939c3cac9f07faa68f58734 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -2157,8 +2157,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bf23cf204976516651b1c4c39ced21cd858dea4ba88052d96fc4f5f11525f170 -R e6ab7f42561dbf7e5d9624bfb9b0bf26 +P c8284170f66374fc528e9d6e5a03ee7321f27e80acf4360701a8b176497b7130 +R acd9470388512134bc217adbff86bef2 U stephan -Z 562f2a1dff86c554fee852503a03b96a +Z ccc05bb973966212e05811d87616f96f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 27445cc530..68668e9e76 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c8284170f66374fc528e9d6e5a03ee7321f27e80acf4360701a8b176497b7130 \ No newline at end of file +5836657929d7d6d3f0d5865c9f6de4e4c00edd53d15a246802b375fa15d0f255 \ No newline at end of file From 9239fb59ad74b1fee03ea99e86dddf3726dd7bf4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 16 Jan 2024 14:54:54 +0000 Subject: [PATCH 0011/1030] Remove the LLONG_MAX preprocessor macro from the series.c extension as it is apparently only C99 and later. [forum:/forumpost/4af649419b|Forum post 4af649419b]. FossilOrigin-Name: f106bc0d21b7a815f0d23a97b6fd63c54d3f5353e965dfa550fa715e698ec6e3 --- ext/misc/series.c | 18 +++++++++++------- manifest | 17 ++++++++--------- manifest.uuid | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ext/misc/series.c b/ext/misc/series.c index abd6af7ad6..3e859a8f23 100644 --- a/ext/misc/series.c +++ b/ext/misc/series.c @@ -103,16 +103,20 @@ SQLITE_EXTENSION_INIT1 ** index is ix. The 0th member is given by smBase. The sequence members ** progress per ix increment by smStep. */ -static sqlite3_int64 genSeqMember(sqlite3_int64 smBase, - sqlite3_int64 smStep, - sqlite3_uint64 ix){ - if( ix>=(sqlite3_uint64)LLONG_MAX ){ +static sqlite3_int64 genSeqMember( + sqlite3_int64 smBase, + sqlite3_int64 smStep, + sqlite3_uint64 ix +){ + static const sqlite3_uint64 mxI64 = + ((sqlite3_uint64)0x7fffffff)<<32 | 0xffffffff; + if( ix>=mxI64 ){ /* Get ix into signed i64 range. */ - ix -= (sqlite3_uint64)LLONG_MAX; + ix -= mxI64; /* With 2's complement ALU, this next can be 1 step, but is split into * 2 for UBSAN's satisfaction (and hypothetical 1's complement ALUs.) */ - smBase += (LLONG_MAX/2) * smStep; - smBase += (LLONG_MAX - LLONG_MAX/2) * smStep; + smBase += (mxI64/2) * smStep; + smBase += (mxI64 - mxI64/2) * smStep; } /* Under UBSAN (or on 1's complement machines), must do this last term * in steps to avoid the dreaded (and harmless) signed multiply overlow. */ diff --git a/manifest b/manifest index 50904cc140..1dd0a39dcf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Various\sbuild-\sand\scode-reorg\scleanups\sfor\sext/wasm.\sNo\sfunctional\schanges. -D 2024-01-16T14:24:35.067 +C Remove\sthe\sLLONG_MAX\spreprocessor\smacro\sfrom\sthe\sseries.c\sextension\sas\sit\nis\sapparently\sonly\sC99\sand\slater.\n[forum:/forumpost/4af649419b|Forum\spost\s4af649419b]. +D 2024-01-16T14:54:54.485 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -400,7 +400,7 @@ F ext/misc/regexp.c 4bdd0045912f81c84908bd535ec5ad3b1c8540b4287c70ab840709636240 F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 -F ext/misc/series.c 80692f675de989629ee20796f75010ce87ca826cb383131040e84f7e1bea5d7a +F ext/misc/series.c 384f93a8a09cf45e1aa6575660cb580ed61d372c590aad05cdcd4a84fbd8f6ab F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d F ext/misc/shathree.c 543af7ce71d391cd3a9ab6924a6a1124efc63211fd0f2e240dc4b56077ba88ac F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 @@ -599,7 +599,7 @@ F ext/wasm/api/sqlite3-api-prologue.js fffcee629bf020a8ccf5c367fbe6a169f5d5d73df F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 -F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d w ext/wasm/api/sqlite3-v-helper.js +F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 595953994aa3ae2287c889c4da39ab3d6f17b6461ecf4bec334b7a3faafddb02 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js ebf6c7e997cd8948b35b3afc550b0503dd53febd9d2b56354efd11d985e5f0f2 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 @@ -2158,9 +2158,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d 5836657929d7d6d3f0d5865c9f6de4e4c00edd53d15a246802b375fa15d0f255 -R 59b52c4e344f8871547dae1c84cd4afc -T +closed 5836657929d7d6d3f0d5865c9f6de4e4c00edd53d15a246802b375fa15d0f255 Closed\sby\sintegrate-merge. -U stephan -Z 3deb67a608c540b8c97149e595f2800e +P 835bd4a11e56ede378235379604ac01350ee92433f952a23c761f7be492fd475 +R 637840d72f118d7c04eecbf407fe77d2 +U drh +Z 9da67d078ad71f5567c52e74dbe3905e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f6272410e1..ea50ef5daa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -835bd4a11e56ede378235379604ac01350ee92433f952a23c761f7be492fd475 \ No newline at end of file +f106bc0d21b7a815f0d23a97b6fd63c54d3f5353e965dfa550fa715e698ec6e3 \ No newline at end of file From 6ad928d91d06d2738ffa2eecaea07a7477a88781 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 16 Jan 2024 15:04:19 +0000 Subject: [PATCH 0012/1030] Clutter the code with "fall-through" comments in order to suppress nuisance compiler warnings. No logic changes. FossilOrigin-Name: 05d2cf5e90d2a6b8e7fbcdb9e12e7c1281db7cfbe212997bd63c8aa66797edda --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/json.c | 1 + src/vdbe.c | 5 +++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1dd0a39dcf..d9cc4defde 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sLLONG_MAX\spreprocessor\smacro\sfrom\sthe\sseries.c\sextension\sas\sit\nis\sapparently\sonly\sC99\sand\slater.\n[forum:/forumpost/4af649419b|Forum\spost\s4af649419b]. -D 2024-01-16T14:54:54.485 +C Clutter\sthe\scode\swith\s"fall-through"\scomments\sin\sorder\sto\ssuppress\snuisance\ncompiler\swarnings.\s\sNo\slogic\schanges. +D 2024-01-16T15:04:19.943 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 4913fd22c4f0fa30643afb93a4d78d289cd490620e782b31016c3d4b2049b1cc +F src/json.c 624824b0c405dc64bb371107f21baf1d00a6b609cbdb16feaa2338a335bf981b F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -808,7 +808,7 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 96ac876e57f480bd35ec8d74ed992bca6ae9deebe8b527a3a718e7b4714d6c2e +F src/vdbe.c 4a42916b14548112cb1ee9b9dea3c0ba6c21d08fa0c660cd1561c1871e25908f F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -2158,8 +2158,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 835bd4a11e56ede378235379604ac01350ee92433f952a23c761f7be492fd475 -R 637840d72f118d7c04eecbf407fe77d2 +P f106bc0d21b7a815f0d23a97b6fd63c54d3f5353e965dfa550fa715e698ec6e3 +R da8805f28e584450d69243ce8bdddb6a U drh -Z 9da67d078ad71f5567c52e74dbe3905e +Z 0ea920a6e11610b2206c6aeee95b6afa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ea50ef5daa..3da3587b59 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f106bc0d21b7a815f0d23a97b6fd63c54d3f5353e965dfa550fa715e698ec6e3 \ No newline at end of file +05d2cf5e90d2a6b8e7fbcdb9e12e7c1281db7cfbe212997bd63c8aa66797edda \ No newline at end of file diff --git a/src/json.c b/src/json.c index 682f30597f..97cf5fe28c 100644 --- a/src/json.c +++ b/src/json.c @@ -1911,6 +1911,7 @@ static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){ return i+4; } /* fall-through into the default case that checks for NaN */ + /* no break */ deliberate_fall_through } default: { u32 k; diff --git a/src/vdbe.c b/src/vdbe.c index 6d45bbbbbd..2ae757b76e 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3654,11 +3654,16 @@ case OP_MakeRecord: { switch( len ){ default: zPayload[7] = (u8)(v&0xff); v >>= 8; zPayload[6] = (u8)(v&0xff); v >>= 8; + /* no break */ deliberate_fall_through case 6: zPayload[5] = (u8)(v&0xff); v >>= 8; zPayload[4] = (u8)(v&0xff); v >>= 8; + /* no break */ deliberate_fall_through case 4: zPayload[3] = (u8)(v&0xff); v >>= 8; + /* no break */ deliberate_fall_through case 3: zPayload[2] = (u8)(v&0xff); v >>= 8; + /* no break */ deliberate_fall_through case 2: zPayload[1] = (u8)(v&0xff); v >>= 8; + /* no break */ deliberate_fall_through case 1: zPayload[0] = (u8)(v&0xff); } zPayload += len; From 75f9ba32bde3028cc8f6d4e8a86ab89d14e3eaf8 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 16 Jan 2024 16:05:21 +0000 Subject: [PATCH 0013/1030] Ensure that the xIntegrity methods of fts3 and fts5 work on read-only databases. FossilOrigin-Name: b855886c4ccce0745af6957943e77be18949722f09821688725d546d3d79b4fb --- ext/fts3/fts3.c | 34 +++++++++++--------------------- ext/fts3/fts3Int.h | 2 ++ ext/fts3/fts3_write.c | 6 +++--- ext/fts5/fts5_main.c | 16 +++++---------- ext/fts5/test/fts5integrity.test | 26 ++++++++++++++++++++++++ manifest | 24 +++++++++++----------- manifest.uuid | 2 +- test/fts4intck1.test | 17 ++++++++++++++++ 8 files changed, 78 insertions(+), 49 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 65852804a1..c9d0eb25b1 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4006,7 +4006,7 @@ static int fts3ShadowName(const char *zName){ ** Implementation of the xIntegrity() method on the FTS3/FTS4 virtual ** table. */ -static int fts3Integrity( +static int fts3IntegrityMethod( sqlite3_vtab *pVtab, /* The virtual table to be checked */ const char *zSchema, /* Name of schema in which pVtab lives */ const char *zTabname, /* Name of the pVTab table */ @@ -4014,30 +4014,20 @@ static int fts3Integrity( char **pzErr /* Write error message here */ ){ Fts3Table *p = (Fts3Table*)pVtab; - char *zSql; int rc; - char *zErr = 0; - - assert( pzErr!=0 ); - assert( *pzErr==0 ); - UNUSED_PARAMETER(isQuick); - zSql = sqlite3_mprintf( - "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", - zSchema, zTabname, zTabname); - if( zSql==0 ){ - return SQLITE_NOMEM; - } - rc = sqlite3_exec(p->db, zSql, 0, 0, &zErr); - sqlite3_free(zSql); - if( (rc&0xff)==SQLITE_CORRUPT ){ - *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s", - p->bFts4 ? 4 : 3, zSchema, zTabname); - }else if( rc!=SQLITE_OK ){ + int bOk = 0; + + rc = sqlite3Fts3IntegrityCheck(p, &bOk); + assert( rc!=SQLITE_CORRUPT_VTAB || bOk==0 ); + if( rc!=SQLITE_OK && rc!=SQLITE_CORRUPT_VTAB ){ *pzErr = sqlite3_mprintf("unable to validate the inverted index for" " FTS%d table %s.%s: %s", - p->bFts4 ? 4 : 3, zSchema, zTabname, zErr); + p->bFts4 ? 4 : 3, zSchema, zTabname, sqlite3_errstr(rc)); + }else if( bOk==0 ){ + *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s", + p->bFts4 ? 4 : 3, zSchema, zTabname); } - sqlite3_free(zErr); + sqlite3Fts3SegmentsClose(p); return SQLITE_OK; } @@ -4068,7 +4058,7 @@ static const sqlite3_module fts3Module = { /* xRelease */ fts3ReleaseMethod, /* xRollbackTo */ fts3RollbackToMethod, /* xShadowName */ fts3ShadowName, - /* xIntegrity */ fts3Integrity, + /* xIntegrity */ fts3IntegrityMethod, }; /* diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 5a5b123b4c..3b236faf49 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -653,5 +653,7 @@ int sqlite3FtsUnicodeIsdiacritic(int); int sqlite3Fts3ExprIterate(Fts3Expr*, int (*x)(Fts3Expr*,int,void*), void*); +int sqlite3Fts3IntegrityCheck(Fts3Table *p, int *pbOk); + #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */ #endif /* _FTSINT_H */ diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 0f894943dd..2516a39083 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -5294,7 +5294,7 @@ static u64 fts3ChecksumIndex( ** If an error occurs (e.g. an OOM or IO error), return an SQLite error ** code. The final value of *pbOk is undefined in this case. */ -static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){ +int sqlite3Fts3IntegrityCheck(Fts3Table *p, int *pbOk){ int rc = SQLITE_OK; /* Return code */ u64 cksum1 = 0; /* Checksum based on FTS index contents */ u64 cksum2 = 0; /* Checksum based on %_content contents */ @@ -5372,7 +5372,7 @@ static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){ sqlite3_finalize(pStmt); } - *pbOk = (cksum1==cksum2); + *pbOk = (rc==SQLITE_OK && cksum1==cksum2); return rc; } @@ -5412,7 +5412,7 @@ static int fts3DoIntegrityCheck( ){ int rc; int bOk = 0; - rc = fts3IntegrityCheck(p, &bOk); + rc = sqlite3Fts3IntegrityCheck(p, &bOk); if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB; return rc; } diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index eb7ee74087..7c818ce747 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2971,27 +2971,21 @@ static int fts5IntegrityMethod( char **pzErr /* Write error message here */ ){ Fts5FullTable *pTab = (Fts5FullTable*)pVtab; - Fts5Config *pConfig = pTab->p.pConfig; - char *zSql; - char *zErr = 0; int rc; + assert( pzErr!=0 && *pzErr==0 ); UNUSED_PARAM(isQuick); - zSql = sqlite3_mprintf( - "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", - zSchema, zTabname, pConfig->zName); - if( zSql==0 ) return SQLITE_NOMEM; - rc = sqlite3_exec(pConfig->db, zSql, 0, 0, &zErr); - sqlite3_free(zSql); + rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, 0); if( (rc&0xff)==SQLITE_CORRUPT ){ *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", zSchema, zTabname); }else if( rc!=SQLITE_OK ){ *pzErr = sqlite3_mprintf("unable to validate the inverted index for" " FTS5 table %s.%s: %s", - zSchema, zTabname, zErr); + zSchema, zTabname, sqlite3_errstr(rc)); } - sqlite3_free(zErr); + sqlite3Fts5IndexCloseReader(pTab->p.pIndex); + return SQLITE_OK; } diff --git a/ext/fts5/test/fts5integrity.test b/ext/fts5/test/fts5integrity.test index f9851dc15a..1bb367538d 100644 --- a/ext/fts5/test/fts5integrity.test +++ b/ext/fts5/test/fts5integrity.test @@ -355,4 +355,30 @@ do_execsql_test 11.4 { PRAGMA integrity_check(t2); } {ok} +#------------------------------------------------------------------- +reset_db + +do_execsql_test 12.1 { + CREATE VIRTUAL TABLE x1 USING fts5(a, b); + INSERT INTO x1 VALUES('one', 'two'); + INSERT INTO x1 VALUES('three', 'four'); + INSERT INTO x1 VALUES('five', 'six'); +} + +do_execsql_test 12.2 { + PRAGMA integrity_check +} {ok} + +db close +sqlite3 db test.db -readonly 1 + +explain_i { + PRAGMA integrity_check + } +do_execsql_test 12.3 { + PRAGMA integrity_check +} {ok} + + + finish_test diff --git a/manifest b/manifest index d9cc4defde..ee8f95c4c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clutter\sthe\scode\swith\s"fall-through"\scomments\sin\sorder\sto\ssuppress\snuisance\ncompiler\swarnings.\s\sNo\slogic\schanges. -D 2024-01-16T15:04:19.943 +C Ensure\sthat\sthe\sxIntegrity\smethods\sof\sfts3\sand\sfts5\swork\son\sread-only\sdatabases. +D 2024-01-16T16:05:21.776 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -63,9 +63,9 @@ F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers b92bdeb8b46503f0dd301d364efc5ef59ef9fa8e2758b8e742f39fa93a2e422d F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c d01dfb641fc04efeeadcb94d7a8342eb07d71c1a3a3852ec8ab5e64c1fcdfff9 +F ext/fts3/fts3.c 16366d9e422be6022255fcb6bb2838387a0fe0a6afb12d14e21fe8f74386ab6a F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h be688580701d41340de73384e3acc8c55be12a438583207444bd5e20f9ef426c +F ext/fts3/fts3Int.h 968f7d7cae541a6926146e9fd3fb2b2ccbd3845b7890a8ed03de0c06ac776682 F ext/fts3/fts3_aux.c 7eab82a9cf0830f6551ba3abfdbe73ed39e322a4d3940ee82fbf723674ecd9f3 F ext/fts3/fts3_expr.c 903bfb9433109fffb10e910d7066c49cbf8eeae316adc93f0499c4da7dfc932a F ext/fts3/fts3_hash.c 8b6e31bfb0844c27dc6092c2620bdb1fca17ed613072db057d96952c6bdb48b7 @@ -81,7 +81,7 @@ F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c c1de4ae28356ad98ccb8b2e3388a7fdcce7607b5523738c9afb6275dab765154 F ext/fts3/fts3_unicode.c de426ff05c1c2e7bce161cf6b706638419c3a1d9c2667de9cb9dc0458c18e226 F ext/fts3/fts3_unicode2.c 416eb7e1e81142703520d284b768ca2751d40e31fa912cae24ba74860532bf0f -F ext/fts3/fts3_write.c 5bb4721330ca589f906e72bb824dd4080b313c6d4c4231fa541e9db32dc67982 +F ext/fts3/fts3_write.c c2d7a8dfb6e7a00c6c88ce626785cf4c50ed18eba34b5fbd53cacd60af96d0f2 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/tool/fts3cov.sh c331d006359456cf6f8f953e37f2b9c7d568f3863f00bb5f7eb87fea4ac01b73 F ext/fts3/tool/fts3view.c 413c346399159df81f86c4928b7c4a455caab73bfbc8cd68f950f632e5751674 @@ -98,7 +98,7 @@ F ext/fts5/fts5_config.c 8072a207034b51ae9b7694121d1b5715c794e94b275e088f70ae532 F ext/fts5/fts5_expr.c e91156ebdcc08d837f4f324168f69f3c0d7fdef0e521fd561efb48ef3297b696 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c bb1965c3965f6fe5f64160bf1c0694a9684a790a783f293a76da1d38d319b258 -F ext/fts5/fts5_main.c 94a03dd431022d706290bb81b7f2180a0bb7c98f1397b5fbc90e18d3ed8d366c +F ext/fts5/fts5_main.c cd56ed9619e9bc55ae603ecafd5965c3684bb4c1de7dd00893c307ddf98afe88 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c cf0fd0dbe64ec272491b749e0d594f563cda03336aeb60900129e6d18b0aefb8 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -176,7 +176,7 @@ F ext/fts5/test/fts5first.test 3fcf2365c00a15fc9704233674789a3b95131d12de18a9b99 F ext/fts5/test/fts5full.test e1701a112354e0ff9a1fdffb0c940c576530c33732ee20ac5e8361777070d717 F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e F ext/fts5/test/fts5hash.test dc7bc7e0cdeb42cfce31294ad2f8fcf43192bfd0145bb7f3ecc5465d8c72696f -F ext/fts5/test/fts5integrity.test 0d249d351163e17e2227aa9850e68193f88a7813d16cc7d51287e554bf915b3d +F ext/fts5/test/fts5integrity.test f1723fe9fb9381b26c946ab4d7505041434df2c449d1cd53f45c7bf8c098dfa2 F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fdde7ea00e78ea283d227 F ext/fts5/test/fts5lastrowid.test be98fe3e03235296585b72daad7aed5717ba0062bae5e5c18dd6e04e194c6b28 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad @@ -1198,7 +1198,7 @@ F test/fts4docid.test e33c383cfbdff0284685604d256f347a18fdbf01 F test/fts4growth.test 289833c34ad45a5e6e6133b53b6a71647231fb89d36ddcb8d9c87211b6721d7f F test/fts4growth2.test 13ad4e76451af6e6906c95cdc725d01b00044269 F test/fts4incr.test 4e353a0bd886ea984e56fce9e77724fc923b8d0d -F test/fts4intck1.test 43774c641fdf6607c6ee90c3db8af065a37434d55d6eaf13bafe515e8b0c5729 +F test/fts4intck1.test 54e7f28e34b72fb0c614d414bb1f568154d463c5a00b20944e893df858372ed4 F test/fts4langid.test 4be912f42454998e239a2e877600263e0394afbaba03e06cedcc5a08693a345a F test/fts4lastrowid.test 185835895948d5325c7710649824042373b2203149abe8024a9319d25234dfd7 F test/fts4merge.test 57d093660a5093ae6e9fbd2d17592a88b45bbd66db2703c4b640b28828dbe38b @@ -2158,8 +2158,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f106bc0d21b7a815f0d23a97b6fd63c54d3f5353e965dfa550fa715e698ec6e3 -R da8805f28e584450d69243ce8bdddb6a -U drh -Z 0ea920a6e11610b2206c6aeee95b6afa +P 05d2cf5e90d2a6b8e7fbcdb9e12e7c1281db7cfbe212997bd63c8aa66797edda +R 5cbf3bdeb8af5f75cdbf0493086676ae +U dan +Z 2db4aae4a26f0f9cf09b997cf1ada5be # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3da3587b59..c922e4e7bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -05d2cf5e90d2a6b8e7fbcdb9e12e7c1281db7cfbe212997bd63c8aa66797edda \ No newline at end of file +b855886c4ccce0745af6957943e77be18949722f09821688725d546d3d79b4fb \ No newline at end of file diff --git a/test/fts4intck1.test b/test/fts4intck1.test index abdc46bf52..6596b2f997 100644 --- a/test/fts4intck1.test +++ b/test/fts4intck1.test @@ -54,5 +54,22 @@ do_execsql_test 2.3 { PRAGMA integrity_check(t2); } {{malformed inverted index for FTS4 table main.t2}} +#------------------------------------------------------------------------- +# Test that integrity-check works on a read-only database. +# +reset_db +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE x1 USING fts4(a, b); + INSERT INTO x1 VALUES('one', 'two'); + INSERT INTO x1 VALUES('three', 'four'); +} +db close +sqlite3 db test.db -readonly 1 + +do_execsql_test 3.1 { + PRAGMA integrity_check; +} {ok} + + finish_test From 31ebe65b5ebe20a1871f3a27fa07ce24deca6b8e Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 16 Jan 2024 16:14:52 +0000 Subject: [PATCH 0014/1030] Fix harmless "unused parameter" compiler warning in the new fts3IntegrityMethod implementation. FossilOrigin-Name: bb1fe53a97672fc868e3f3897162ea0d714dc1da95187f9c7e35255049f2b0e7 --- ext/fts3/fts3.c | 1 + manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index c9d0eb25b1..379590188d 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4017,6 +4017,7 @@ static int fts3IntegrityMethod( int rc; int bOk = 0; + UNUSED_PARAMETER(isQuick); rc = sqlite3Fts3IntegrityCheck(p, &bOk); assert( rc!=SQLITE_CORRUPT_VTAB || bOk==0 ); if( rc!=SQLITE_OK && rc!=SQLITE_CORRUPT_VTAB ){ diff --git a/manifest b/manifest index ee8f95c4c3..b0ad7329f9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\sxIntegrity\smethods\sof\sfts3\sand\sfts5\swork\son\sread-only\sdatabases. -D 2024-01-16T16:05:21.776 +C Fix\sharmless\s"unused\sparameter"\scompiler\swarning\sin\sthe\snew\sfts3IntegrityMethod\nimplementation. +D 2024-01-16T16:14:52.891 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -63,7 +63,7 @@ F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers b92bdeb8b46503f0dd301d364efc5ef59ef9fa8e2758b8e742f39fa93a2e422d F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 16366d9e422be6022255fcb6bb2838387a0fe0a6afb12d14e21fe8f74386ab6a +F ext/fts3/fts3.c fd64a588471ce00b19da08acb0d6f904277a21ac1d15141d5913c83591afa027 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 968f7d7cae541a6926146e9fd3fb2b2ccbd3845b7890a8ed03de0c06ac776682 F ext/fts3/fts3_aux.c 7eab82a9cf0830f6551ba3abfdbe73ed39e322a4d3940ee82fbf723674ecd9f3 @@ -2158,8 +2158,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 05d2cf5e90d2a6b8e7fbcdb9e12e7c1281db7cfbe212997bd63c8aa66797edda -R 5cbf3bdeb8af5f75cdbf0493086676ae -U dan -Z 2db4aae4a26f0f9cf09b997cf1ada5be +P b855886c4ccce0745af6957943e77be18949722f09821688725d546d3d79b4fb +R e3234ce42cab7cdbc84f346ed1a36dc2 +U drh +Z 29787cb80c2a8f6910db50466343041a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c922e4e7bf..d671591dbf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b855886c4ccce0745af6957943e77be18949722f09821688725d546d3d79b4fb \ No newline at end of file +bb1fe53a97672fc868e3f3897162ea0d714dc1da95187f9c7e35255049f2b0e7 \ No newline at end of file From d0603eda6cc64497cfb811a4538e8f24b4a373c4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 18 Jan 2024 16:50:25 +0000 Subject: [PATCH 0015/1030] Add support in the strftime() SQL function for conversion letters %G, %g, %U, and %V. FossilOrigin-Name: e1155d6aa4b960ecfd14fa3467f28672af3327699c547f5b9e75da3ac1348ff7 --- manifest | 16 +++--- manifest.uuid | 2 +- src/date.c | 146 ++++++++++++++++++++++++++++++++++++++++-------- test/date.test | 4 +- test/date4.test | 2 +- 5 files changed, 134 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index b0ad7329f9..2ef2bf10a8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\s"unused\sparameter"\scompiler\swarning\sin\sthe\snew\sfts3IntegrityMethod\nimplementation. -D 2024-01-16T16:14:52.891 +C Add\ssupport\sin\sthe\sstrftime()\sSQL\sfunction\sfor\sconversion\sletters\s%G,\s%g,\n%U,\sand\s%V. +D 2024-01-18T16:50:25.492 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -684,7 +684,7 @@ F src/build.c e7d9044592eeeea8e78d8ae53ca8d31fd6e92ca0d4f53e2f2e8ccf7352e0b04b F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c 3b8d02977d160e128469de38493b4085f7c5cf4073193459909a6af3cf6d7c91 +F src/date.c 7ed194fee09bc3aa2129cfe74ebf5daca6fc24c0995dd28cf2a2feacf4d8d44f F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -1030,10 +1030,10 @@ F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c47 F test/cursorhint.test 05cf0febe5c5f8a31f199401fd1c9322249e753950d55f26f9d5aca61408a270 F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8 -F test/date.test ff2341a1ef71b9a27979494d299222f9a293aa22cb9ff6e9c38d88a895317ebf +F test/date.test b1a5208e6a9c390cf1d1fa4e38a910386b427b0e27046901c6b0fb995d19800e F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1 F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5 -F test/date4.test 8aeb3de5b5e9fda968baa9357e4c0fae573724b7904943410195a19e96e31b6a +F test/date4.test 77b3781c28d3a5e181c6474315aa58e1f6cf79f5171a4e46e248837b506e7adf F test/dbdata.test 042f49acff3438f940eeba5868d3af080ae64ddf26ae78f80c92bec3ca7d8603 F test/dbfuzz.c 73047c920d6210e5912c87cdffd9a1c281d4252e F test/dbfuzz001.test 6c9a4622029d69dc38926f115864b055cb2f39badd25ec22cbfb130c8ba8e9c3 @@ -2158,8 +2158,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b855886c4ccce0745af6957943e77be18949722f09821688725d546d3d79b4fb -R e3234ce42cab7cdbc84f346ed1a36dc2 +P bb1fe53a97672fc868e3f3897162ea0d714dc1da95187f9c7e35255049f2b0e7 +R 600b04759487eea2e950d6a6bdd54077 U drh -Z 29787cb80c2a8f6910db50466343041a +Z fe80399e6509893ac8c8ba9e1f44bd65 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d671591dbf..e751fb38dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bb1fe53a97672fc868e3f3897162ea0d714dc1da95187f9c7e35255049f2b0e7 \ No newline at end of file +e1155d6aa4b960ecfd14fa3467f28672af3327699c547f5b9e75da3ac1348ff7 \ No newline at end of file diff --git a/src/date.c b/src/date.c index e493542db9..059d4c88a6 100644 --- a/src/date.c +++ b/src/date.c @@ -1236,22 +1236,98 @@ static void dateFunc( } } +/* +** Compute the one-based day of the year for the DateTime pDate. +** Jan01 = 1, Jan02 = 2, ... Dec31 = 356 or 366. +*/ +static int dayOfYear(DateTime *pDate){ + DateTime jan01 = *pDate; + assert( jan01.validYMD ); + assert( jan01.validHMS ); + assert( pDate->validJD ); + jan01.validJD = 0; + jan01.M = 1; + jan01.D = 1; + computeJD(&jan01); + return (int)((pDate->iJD-jan01.iJD+45300000)/86400000) + 1; +} + +/* +** Return the day of the week. 1==Monday, 2=Tues, ..., 7=Sunday. +*/ +static int dayOfWeek(DateTime *pDate){ + int w; + assert( pDate->validJD ); + w = ((pDate->iJD+129600000)/86400000) % 7; + if( w==0 ) w = 7; + return w; +} + +/* +** Compute the day-of-week (0=Sunday, 1=Monday, ..., 6=Saturday) for +** the last day of the calendar year Y. +*/ +static int lastDayOfYear(int Y){ + return (Y + (Y/4) - (Y/100) + (Y/400))%7; +} + +/* +** Return the number of ISO weeks in calendar year Y. The answer is +** either 52 or 53. +*/ +static int weeksInYear(int Y){ + if( lastDayOfYear(Y)==4 || lastDayOfYear(Y-1)==3 ){ + return 53; + }else{ + return 52; + } +} + +/* +** Compute the number days since the start of the ISO-week year for pDate. +** The ISO-week year starts on the first day of the week (always a Monday) +** that contains the first Thursday on or after January 1. +*/ +static int isoWeekNumber(DateTime *pDate){ + int wn = (10 + dayOfYear(pDate) - dayOfWeek(pDate))/7; + if( wn<1 ){ + wn = weeksInYear(pDate->Y-1); + }else if( wn>weeksInYear(pDate->Y) ){ + wn = 1; + } + return wn; +} + /* ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) ** ** Return a string described by FORMAT. Conversions as follows: ** -** %d day of month +** %d day of month 01-31 +** %e day of month 1-31 ** %f ** fractional seconds SS.SSS +** %F ISO date. YYYY-MM-DD +** %G ISO year corresponding to %V 0000-9999. +** %g 2-digit ISO year corresponding to %V 00-99 ** %H hour 00-24 -** %j day of year 000-366 +** %k hour 0-24 (leading zero converted to space) +** %I hour 01-12 +** %j day of year 001-366 ** %J ** julian day number +** %l hour 1-12 (leading zero converted to space) ** %m month 01-12 ** %M minute 00-59 +** %p "am" or "pm" +** %P "AM" or "PM" +** %R time as HH:MM ** %s seconds since 1970-01-01 ** %S seconds 00-59 -** %w day of week 0-6 Sunday==0 -** %W week of year 00-53 +** %T time as HH:MM:SS +** %u day of week 1-7 Monday==1, Sunday==7 +** %w day of week 0-6 Sunday==0, Monday==1 +** %U week of year 00-53 (First Sunday is start of week 01) +** %V week of year 01-53 (First week containing Thursday is week 01) +** %W week of year 00-53 (First Monday is start of week 01) ** %Y year 0000-9999 ** %% % */ @@ -1288,7 +1364,7 @@ static void strftimeFunc( sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D); break; } - case 'f': { + case 'f': { /* Fractional seconds. (Non-standard) */ double s = x.s; if( s>59.999 ) s = 59.999; sqlite3_str_appendf(&sRes, "%06.3f", s); @@ -1298,6 +1374,21 @@ static void strftimeFunc( sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D); break; } + case 'G': /* Fall thru */ + case 'g': { + int Y = x.Y; + if( x.M==12 && isoWeekNumber(&x)==1 ){ + Y++; + }else if( x.M==1 && isoWeekNumber(&x)>=52 ){ + Y--; + } + if( cf=='g' ){ + sqlite3_str_appendf(&sRes, "%02d", Y%100); + }else{ + sqlite3_str_appendf(&sRes, "%04d", Y); + } + break; + } case 'H': case 'k': { sqlite3_str_appendf(&sRes, cf=='H' ? "%02d" : "%2d", x.h); @@ -1311,25 +1402,12 @@ static void strftimeFunc( sqlite3_str_appendf(&sRes, cf=='I' ? "%02d" : "%2d", h); break; } - case 'W': /* Fall thru */ - case 'j': { - int nDay; /* Number of days since 1st day of year */ - DateTime y = x; - y.validJD = 0; - y.M = 1; - y.D = 1; - computeJD(&y); - nDay = (int)((x.iJD-y.iJD+43200000)/86400000); - if( cf=='W' ){ - int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ - wd = (int)(((x.iJD+43200000)/86400000)%7); - sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); - }else{ - sqlite3_str_appendf(&sRes,"%03d",nDay+1); - } + case 'j': { /* Day of year. Jan01==1, Jan02==2, and so forth */ + int nDay = dayOfYear(&x); + sqlite3_str_appendf(&sRes,"%03d",nDay); break; } - case 'J': { + case 'J': { /* Julian day number. (Non-standard) */ sqlite3_str_appendf(&sRes,"%.16g",x.iJD/86400000.0); break; } @@ -1372,13 +1450,33 @@ static void strftimeFunc( sqlite3_str_appendf(&sRes,"%02d:%02d:%02d", x.h, x.m, (int)x.s); break; } - case 'u': /* Fall thru */ - case 'w': { + case 'u': /* Day of week. 1 to 7. Monday==1, Sunday==7 */ + case 'w': { /* Day of week. 0 to 6. Sunday==0, Monday==1 */ char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; if( c=='0' && cf=='u' ) c = '7'; sqlite3_str_appendchar(&sRes, 1, c); break; } + case 'U': { /* Week num. 00-53. First Sun of the year is week 01 */ + int wd; /* 0=Sunday, 1=Monday, 2=Tuesday, ... 7=Saturday */ + int nDay; /* Day of the year. 0..364 or 0..365 for leapyears */ + nDay = dayOfYear(&x); + wd = (int)(((x.iJD+43200000)/86400000 + 1)%7); + sqlite3_str_appendf(&sRes,"%02d",(nDay+6-wd)/7); + break; + } + case 'V': { /* Week num. 01-53. First week with a Thur is week 01 */ + sqlite3_str_appendf(&sRes,"%02d", isoWeekNumber(&x)); + break; + } + case 'W': { /* Week num. 00-53. First Mon of the year is week 01 */ + int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ + int nDay; /* Day of the year. 0..364 or 0..365 for leapyears */ + nDay = dayOfYear(&x); + wd = (int)(((x.iJD+43200000)/86400000)%7); + sqlite3_str_appendf(&sRes,"%02d",(nDay+6-wd)/7); + break; + } case 'Y': { sqlite3_str_appendf(&sRes,"%04d",x.Y); break; diff --git a/test/date.test b/test/date.test index 19cecc2db3..d536c65fce 100644 --- a/test/date.test +++ b/test/date.test @@ -209,8 +209,8 @@ datetest 3.16 "strftime('[repeat 200 %Y]','2003-10-31')" [repeat 200 2003] datetest 3.17 "strftime('[repeat 200 abc%m123]','2003-10-31')" \ [repeat 200 abc10123] -foreach c {a b c g h i n o q r t v x y z - A B C D E G K L N O Q V Z +foreach c {a b c h i n o q r t v x y z + A B C D E K L N O Q Z 0 1 2 3 4 5 6 6 7 9 _} { datetest 3.18.$c "strftime('%$c','2003-10-31')" NULL } diff --git a/test/date4.test b/test/date4.test index 0d820a0a40..0dd06debb7 100644 --- a/test/date4.test +++ b/test/date4.test @@ -24,7 +24,7 @@ ifcapable {!datetime} { } if {$tcl_platform(os)=="Linux"} { - set FMT {%d,%e,%F,%H,%k,%I,%l,%j,%m,%M,%u,%w,%W,%Y,%%,%P,%p} + set FMT {%d,%e,%F,%H,%k,%I,%l,%j,%m,%M,%u,%w,%W,%Y,%%,%P,%p,%U,%V,%G,%g} } else { set FMT {%d,%e,%F,%H,%I,%j,%p,%R,%u,%w,%W,%%} } From 0a626b2b52b58137e00b3d7c25a1a4047fc12d51 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 18 Jan 2024 16:52:11 +0000 Subject: [PATCH 0016/1030] Increase the version number to 3.46.0 to begin the next development cycle. FossilOrigin-Name: 1481baf3d55effcc117f2097e2d49a6f60f5f74b21190c3be943fd785b8a4c5b --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index ff3ff28f6b..850ac8f28c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.45.0 +3.46.0 diff --git a/configure b/configure index 6a47c4dcc8..f6717f96fb 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.45.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.46.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.45.0' -PACKAGE_STRING='sqlite 3.45.0' +PACKAGE_VERSION='3.46.0' +PACKAGE_STRING='sqlite 3.46.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1472,7 +1472,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.45.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.46.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1537,7 +1537,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.45.0:";; + short | recursive ) echo "Configuration of sqlite 3.46.0:";; esac cat <<\_ACEOF @@ -1668,7 +1668,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.45.0 +sqlite configure 3.46.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2087,7 +2087,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.45.0, which was +It was created by sqlite $as_me 3.46.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -12481,7 +12481,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.45.0, which was +This file was extended by sqlite $as_me 3.46.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12547,7 +12547,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.45.0 +sqlite config.status 3.46.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/manifest b/manifest index 2ef2bf10a8..2d1eb4053d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sin\sthe\sstrftime()\sSQL\sfunction\sfor\sconversion\sletters\s%G,\s%g,\n%U,\sand\s%V. -D 2024-01-18T16:50:25.492 +C Increase\sthe\sversion\snumber\sto\s3.46.0\sto\sbegin\sthe\snext\sdevelopment\scycle. +D 2024-01-18T16:52:11.788 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -7,7 +7,7 @@ F Makefile.in 24be65ae641c5727bbc247d60286a15ecc24fb80f14f8fb2d32533bf0ec96e79 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc df56c06ef05add5ebcdcc9d4823fb2ec66ac16b06acb6971a7420859025886fa F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 -F VERSION 73573d4545343f001bf5dc5461173a7c78c203dd046cabcf99153878cf25d3a6 +F VERSION c84541c6a9e8426462176fbb1f9ecb5cfd7d1bb56228053ff7eeba8841673eb6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 @@ -33,7 +33,7 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure bcb1042e92775424a1021d2f4c89c78a699a6225df01fa8c593df7df0be6ad10 x +F configure 40f7af9ed5ca0d44a4b9bc7ad34f1ee4867bb4eeb19e75036be6bed66193a498 x F configure.ac f25bd7843120f2c2b8bc9db5a92b0502bbdd28e68907415c3d42fc8e57c657b9 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd @@ -2158,8 +2158,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bb1fe53a97672fc868e3f3897162ea0d714dc1da95187f9c7e35255049f2b0e7 -R 600b04759487eea2e950d6a6bdd54077 +P e1155d6aa4b960ecfd14fa3467f28672af3327699c547f5b9e75da3ac1348ff7 +R 9689bd329de0e140711926288014ba0a U drh -Z fe80399e6509893ac8c8ba9e1f44bd65 +Z 0a03ba584bfec4968cbf95a431d1a244 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e751fb38dc..04b005239f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1155d6aa4b960ecfd14fa3467f28672af3327699c547f5b9e75da3ac1348ff7 \ No newline at end of file +1481baf3d55effcc117f2097e2d49a6f60f5f74b21190c3be943fd785b8a4c5b \ No newline at end of file From a4802720a1fe1d51c4e35a2e85c8c09ade420a93 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 19 Jan 2024 16:51:34 +0000 Subject: [PATCH 0017/1030] Allow large hexadecimal literals to be used as DEFAULT values. FossilOrigin-Name: 8cccc1f27d7470d3cdd3c9c6d74f6a5ac49ec6eaa7002bcf96f4842fb8c79e1a --- manifest | 15 ++++++++------- manifest.uuid | 2 +- src/vdbemem.c | 33 ++++++++++++++++++++++----------- test/literal.test | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 19 deletions(-) create mode 100644 test/literal.test diff --git a/manifest b/manifest index 2d1eb4053d..149c0f4a50 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increase\sthe\sversion\snumber\sto\s3.46.0\sto\sbegin\sthe\snext\sdevelopment\scycle. -D 2024-01-18T16:52:11.788 +C Allow\slarge\shexadecimal\sliterals\sto\sbe\sused\sas\sDEFAULT\svalues. +D 2024-01-19T16:51:34.042 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -814,7 +814,7 @@ F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b F src/vdbeaux.c c5a471b34e9c4cfc0295a3e10734fd197670ffaebcb742f284c8e17e8026ceea F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 -F src/vdbemem.c 0012d5f01cc866833847c2f3ae4c318ac53a1cb3d28acad9c35e688039464cf0 +F src/vdbemem.c bbe87b3e851bcc5cad2a9329ad0387432e41ddf2f98f2682c524ad676b739987 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 @@ -1355,6 +1355,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e +F test/literal.test 31ef70d425c39b993d0dd61b3f4c65d30b7491e8b3dbbd2d8a23b78b1e8931ca F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -2158,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e1155d6aa4b960ecfd14fa3467f28672af3327699c547f5b9e75da3ac1348ff7 -R 9689bd329de0e140711926288014ba0a -U drh -Z 0a03ba584bfec4968cbf95a431d1a244 +P 1481baf3d55effcc117f2097e2d49a6f60f5f74b21190c3be943fd785b8a4c5b +R 7a04f28ab4102a53adff1c3861de4c59 +U dan +Z de8bd7b1420ad71ea0d7cb25c6eae88b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 04b005239f..e0ae0c40c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1481baf3d55effcc117f2097e2d49a6f60f5f74b21190c3be943fd785b8a4c5b \ No newline at end of file +8cccc1f27d7470d3cdd3c9c6d74f6a5ac49ec6eaa7002bcf96f4842fb8c79e1a \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index d527164685..2d10cda8d5 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1631,14 +1631,20 @@ static int valueFromExpr( } /* Handle negative integers in a single step. This is needed in the - ** case when the value is -9223372036854775808. - */ - if( op==TK_UMINUS - && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){ - pExpr = pExpr->pLeft; - op = pExpr->op; - negInt = -1; - zNeg = "-"; + ** case when the value is -9223372036854775808. Except - do not do this + ** for hexadecimal literals. */ + if( op==TK_UMINUS ){ + Expr *pLeft = pExpr->pLeft; + if( (pLeft->op==TK_INTEGER || pLeft->op==TK_FLOAT) ){ + if( ExprHasProperty(pLeft, EP_IntValue) + || pLeft->u.zToken[0]!='0' || (pLeft->u.zToken[1] & ~0x20)!='X' + ){ + pExpr = pLeft; + op = pExpr->op; + negInt = -1; + zNeg = "-"; + } + } } if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){ @@ -1647,9 +1653,14 @@ static int valueFromExpr( if( ExprHasProperty(pExpr, EP_IntValue) ){ sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt); }else{ - zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken); - if( zVal==0 ) goto no_mem; - sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); + i64 iVal; + if( op==TK_INTEGER && 0==sqlite3DecOrHexToI64(pExpr->u.zToken, &iVal) ){ + sqlite3VdbeMemSetInt64(pVal, iVal*negInt); + }else{ + zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken); + if( zVal==0 ) goto no_mem; + sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); + } } if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){ sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); diff --git a/test/literal.test b/test/literal.test new file mode 100644 index 0000000000..7bbb8f0f7a --- /dev/null +++ b/test/literal.test @@ -0,0 +1,47 @@ +# 2024-01-19 +# +# 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 tests for SQL literals + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix literal + +proc test_literal {tn lit type val} { + do_execsql_test $tn.1 "SELECT typeof( $lit ), $lit" [list $type $val] + + do_execsql_test $tn.2 " + DROP TABLE IF EXISTS x1; + CREATE TABLE x1(a); + INSERT INTO x1 VALUES(123); + ALTER TABLE x1 ADD COLUMN b DEFAULT $lit ; + SELECT typeof(b), b FROM x1; + " [list $type $val] +} + + +test_literal 1.0 45 integer 45 +test_literal 1.1 0xFF integer 255 +test_literal 1.2 0xFFFFFFFF integer [expr 0xFFFFFFFF] +test_literal 1.3 0x123FFFFFFFF integer [expr 0x123FFFFFFFF] +test_literal 1.4 -0x123FFFFFFFF integer [expr -1 * 0x123FFFFFFFF] +test_literal 1.5 0xFFFFFFFFFFFFFFFF integer -1 +test_literal 1.7 0x7FFFFFFFFFFFFFFF integer [expr 0x7FFFFFFFFFFFFFFF] +test_literal 1.8 -0x7FFFFFFFFFFFFFFF integer [expr -0x7FFFFFFFFFFFFFFF] +test_literal 1.9 +0x7FFFFFFFFFFFFFFF integer [expr +0x7FFFFFFFFFFFFFFF] +test_literal 1.10 -45 integer -45 +test_literal 1.11 '0xFF' text 0xFF +test_literal 1.12 '-0xFF' text -0xFF +test_literal 1.13 -'0xFF' integer 0 + + +finish_test From f08287cc1243ff220d2a7f001809b37752b1bcd6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 00:31:44 +0000 Subject: [PATCH 0018/1030] Implement a new algorithm for computing ISO week values in strftime() based on the idea (from [forum/forumpost/3681cb1bcd|Nuno Cruces]) of shifting the date being tested to the Thursday of the same week. FossilOrigin-Name: b06ab46a9ee98719159ed3e05cdfbf26281353d781206f56ed7cb12859210fed --- manifest | 14 ++++++------ manifest.uuid | 2 +- src/date.c | 61 ++++++++++++++------------------------------------- 3 files changed, 24 insertions(+), 53 deletions(-) diff --git a/manifest b/manifest index 149c0f4a50..f3a5bcbb8d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\slarge\shexadecimal\sliterals\sto\sbe\sused\sas\sDEFAULT\svalues. -D 2024-01-19T16:51:34.042 +C Implement\sa\snew\salgorithm\sfor\scomputing\sISO\sweek\svalues\sin\sstrftime()\sbased\non\sthe\sidea\s(from\s[forum/forumpost/3681cb1bcd|Nuno\sCruces])\sof\sshifting\sthe\ndate\sbeing\stested\sto\sthe\sThursday\sof\sthe\ssame\sweek. +D 2024-01-20T00:31:44.563 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -684,7 +684,7 @@ F src/build.c e7d9044592eeeea8e78d8ae53ca8d31fd6e92ca0d4f53e2f2e8ccf7352e0b04b F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c 7ed194fee09bc3aa2129cfe74ebf5daca6fc24c0995dd28cf2a2feacf4d8d44f +F src/date.c 35ea61eb7ab5b918db7a96725346234bf8fb5bc161c7b868c20a7f24f351a2da F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1481baf3d55effcc117f2097e2d49a6f60f5f74b21190c3be943fd785b8a4c5b -R 7a04f28ab4102a53adff1c3861de4c59 -U dan -Z de8bd7b1420ad71ea0d7cb25c6eae88b +P 8cccc1f27d7470d3cdd3c9c6d74f6a5ac49ec6eaa7002bcf96f4842fb8c79e1a +R 6109198c01da554c8b8cc1d558fbd53e +U drh +Z ae5f14e34bf5701b2021ec4920aa096b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e0ae0c40c2..c05237a31f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8cccc1f27d7470d3cdd3c9c6d74f6a5ac49ec6eaa7002bcf96f4842fb8c79e1a \ No newline at end of file +b06ab46a9ee98719159ed3e05cdfbf26281353d781206f56ed7cb12859210fed \ No newline at end of file diff --git a/src/date.c b/src/date.c index 059d4c88a6..76e1894f8d 100644 --- a/src/date.c +++ b/src/date.c @@ -1249,7 +1249,7 @@ static int dayOfYear(DateTime *pDate){ jan01.M = 1; jan01.D = 1; computeJD(&jan01); - return (int)((pDate->iJD-jan01.iJD+45300000)/86400000) + 1; + return (int)((pDate->iJD-jan01.iJD+43200000)/86400000) + 1; } /* @@ -1263,41 +1263,6 @@ static int dayOfWeek(DateTime *pDate){ return w; } -/* -** Compute the day-of-week (0=Sunday, 1=Monday, ..., 6=Saturday) for -** the last day of the calendar year Y. -*/ -static int lastDayOfYear(int Y){ - return (Y + (Y/4) - (Y/100) + (Y/400))%7; -} - -/* -** Return the number of ISO weeks in calendar year Y. The answer is -** either 52 or 53. -*/ -static int weeksInYear(int Y){ - if( lastDayOfYear(Y)==4 || lastDayOfYear(Y-1)==3 ){ - return 53; - }else{ - return 52; - } -} - -/* -** Compute the number days since the start of the ISO-week year for pDate. -** The ISO-week year starts on the first day of the week (always a Monday) -** that contains the first Thursday on or after January 1. -*/ -static int isoWeekNumber(DateTime *pDate){ - int wn = (10 + dayOfYear(pDate) - dayOfWeek(pDate))/7; - if( wn<1 ){ - wn = weeksInYear(pDate->Y-1); - }else if( wn>weeksInYear(pDate->Y) ){ - wn = 1; - } - return wn; -} - /* ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) ** @@ -1376,16 +1341,16 @@ static void strftimeFunc( } case 'G': /* Fall thru */ case 'g': { - int Y = x.Y; - if( x.M==12 && isoWeekNumber(&x)==1 ){ - Y++; - }else if( x.M==1 && isoWeekNumber(&x)>=52 ){ - Y--; - } + DateTime y = x; + assert( y.validJD ); + /* Move y so that it is the Thursday in the same week as x */ + y.iJD += (4 - dayOfWeek(&x))*86400000; + y.validYMD = 0; + computeYMD(&y); if( cf=='g' ){ - sqlite3_str_appendf(&sRes, "%02d", Y%100); + sqlite3_str_appendf(&sRes, "%02d", y.Y%100); }else{ - sqlite3_str_appendf(&sRes, "%04d", Y); + sqlite3_str_appendf(&sRes, "%04d", y.Y); } break; } @@ -1466,7 +1431,13 @@ static void strftimeFunc( break; } case 'V': { /* Week num. 01-53. First week with a Thur is week 01 */ - sqlite3_str_appendf(&sRes,"%02d", isoWeekNumber(&x)); + DateTime y = x; + /* Adjust y so that is the Thursday in the same week as x */ + assert( y.validJD ); + y.iJD += (4 - dayOfWeek(&x))*86400000; + y.validYMD = 0; + computeYMD(&y); + sqlite3_str_appendf(&sRes,"%02d", (dayOfYear(&y)-1)/7+1); break; } case 'W': { /* Week num. 00-53. First Mon of the year is week 01 */ From a74a7f5b9e6e9beaf69ae23ff90296d3948d7dd7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 12:00:20 +0000 Subject: [PATCH 0019/1030] Fix the version number in the TEA configure script. This should have been changed by [1481baf3d55effcc] three check-ins ago. It is unclear how testing missed this. FossilOrigin-Name: eaf2cf73fca3355edd05fef5b0d0262a6555633908794068805d12b1948beedc --- autoconf/tea/configure.ac | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/autoconf/tea/configure.ac b/autoconf/tea/configure.ac index 4df57344be..f188f22039 100644 --- a/autoconf/tea/configure.ac +++ b/autoconf/tea/configure.ac @@ -19,7 +19,7 @@ dnl to configure the system for the local environment. # so that we create the export library with the dll. #----------------------------------------------------------------------- -AC_INIT([sqlite],[3.45.0]) +AC_INIT([sqlite],[3.46.0]) #-------------------------------------------------------------------- # Call TEA_INIT as the first TEA_ macro to set up initial vars. diff --git a/manifest b/manifest index f3a5bcbb8d..94f8ff8ff4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Implement\sa\snew\salgorithm\sfor\scomputing\sISO\sweek\svalues\sin\sstrftime()\sbased\non\sthe\sidea\s(from\s[forum/forumpost/3681cb1bcd|Nuno\sCruces])\sof\sshifting\sthe\ndate\sbeing\stested\sto\sthe\sThursday\sof\sthe\ssame\sweek. -D 2024-01-20T00:31:44.563 +C Fix\sthe\sversion\snumber\sin\sthe\sTEA\sconfigure\sscript.\s\sThis\sshould\shave\nbeen\schanged\sby\s[1481baf3d55effcc]\sthree\scheck-ins\sago.\nIt\sis\sunclear\show\stesting\smissed\sthis. +D 2024-01-20T12:00:20.372 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -22,7 +22,7 @@ F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d F autoconf/tea/Makefile.in 106a96f2f745d41a0f6193f1de98d7355830b65d45032c18cd7c90295ec24196 F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 -F autoconf/tea/configure.ac 4c32b08691a5b296206b38422b53b92b65be3d3f6b3dd6552a50981a61f5acda +F autoconf/tea/configure.ac 9e74135563a901d9b1a019bad1c9d73a6659fa32325f6a565bef72bfb0ec7297 F autoconf/tea/doc/sqlite3.n e1fe45d4f5286ee3d0ccc877aca2a0def488e9bb F autoconf/tea/license.terms 13bd403c9610fd2b76ece0ab50c4c5eda933d523 F autoconf/tea/pkgIndex.tcl.in b9eb6dd37f64e08e637d576b3c83259814b9cddd78bec4af2e5abfc6c5c750ce @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8cccc1f27d7470d3cdd3c9c6d74f6a5ac49ec6eaa7002bcf96f4842fb8c79e1a -R 6109198c01da554c8b8cc1d558fbd53e +P b06ab46a9ee98719159ed3e05cdfbf26281353d781206f56ed7cb12859210fed +R 9501c38a1e8bd841e94256d593af54ad U drh -Z ae5f14e34bf5701b2021ec4920aa096b +Z 968fbfadacc13465ad30d7b8182c0acc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c05237a31f..93934bab25 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b06ab46a9ee98719159ed3e05cdfbf26281353d781206f56ed7cb12859210fed \ No newline at end of file +eaf2cf73fca3355edd05fef5b0d0262a6555633908794068805d12b1948beedc \ No newline at end of file From 777a08893bd08bfed6fc09e498912fb63d974d83 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 12:13:00 +0000 Subject: [PATCH 0020/1030] When backing out a character in a constructed string in JSON, first make sure the string has not been reset by on OOM. dbsqlfuzz 2fffbea91a5376526ea118d4fe4188c8dd35e317. FossilOrigin-Name: 666690eb433fe38fa527ccbbb8e2c00041a33939da4f6b8bfb737d664f28f0d8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 24 +++++++++++++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 94f8ff8ff4..5a4e7fd711 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sversion\snumber\sin\sthe\sTEA\sconfigure\sscript.\s\sThis\sshould\shave\nbeen\schanged\sby\s[1481baf3d55effcc]\sthree\scheck-ins\sago.\nIt\sis\sunclear\show\stesting\smissed\sthis. -D 2024-01-20T12:00:20.372 +C When\sbacking\sout\sa\scharacter\sin\sa\sconstructed\sstring\sin\sJSON,\sfirst\smake\ssure\nthe\sstring\shas\snot\sbeen\sreset\sby\son\sOOM.\ndbsqlfuzz\s2fffbea91a5376526ea118d4fe4188c8dd35e317. +D 2024-01-20T12:13:00.530 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 624824b0c405dc64bb371107f21baf1d00a6b609cbdb16feaa2338a335bf981b +F src/json.c 5405e50cf0d7aeae12ac5b46e0fc9b3757b3b9cb4885f1a73ec7afeac99b9759 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b06ab46a9ee98719159ed3e05cdfbf26281353d781206f56ed7cb12859210fed -R 9501c38a1e8bd841e94256d593af54ad +P eaf2cf73fca3355edd05fef5b0d0262a6555633908794068805d12b1948beedc +R 8f8b8c466d5567f67ab6487c681d59e2 U drh -Z 968fbfadacc13465ad30d7b8182c0acc +Z fda57e08b93251c93aba9abc8bd9967a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 93934bab25..75aed94f83 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eaf2cf73fca3355edd05fef5b0d0262a6555633908794068805d12b1948beedc \ No newline at end of file +666690eb433fe38fa527ccbbb8e2c00041a33939da4f6b8bfb737d664f28f0d8 \ No newline at end of file diff --git a/src/json.c b/src/json.c index 97cf5fe28c..d33692466b 100644 --- a/src/json.c +++ b/src/json.c @@ -589,6 +589,16 @@ static void jsonAppendChar(JsonString *p, char c){ } } +/* Remove a single character from the end of the string +*/ +static void jsonStringTrimOneChar(JsonString *p){ + if( p->eErr==0 ){ + assert( p->nUsed>0 ); + p->nUsed--; + } +} + + /* Make sure there is a zero terminator on p->zBuf[] ** ** Return true on success. Return false if an OOM prevents this @@ -596,7 +606,7 @@ static void jsonAppendChar(JsonString *p, char c){ */ static int jsonStringTerminate(JsonString *p){ jsonAppendChar(p, 0); - p->nUsed--; + jsonStringTrimOneChar(p); return p->eErr==0; } @@ -2261,7 +2271,7 @@ static u32 jsonTranslateBlobToText( j = jsonTranslateBlobToText(pParse, j, pOut); jsonAppendChar(pOut, ','); } - if( sz>0 ) pOut->nUsed--; + if( sz>0 ) jsonStringTrimOneChar(pOut); jsonAppendChar(pOut, ']'); break; } @@ -2275,7 +2285,7 @@ static u32 jsonTranslateBlobToText( jsonAppendChar(pOut, (x++ & 1) ? ',' : ':'); } if( x & 1 ) pOut->eErr |= JSTRING_MALFORMED; - if( sz>0 ) pOut->nUsed--; + if( sz>0 ) jsonStringTrimOneChar(pOut); jsonAppendChar(pOut, '}'); break; } @@ -4403,7 +4413,7 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ if( isFinal ){ if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf); }else{ - pStr->nUsed--; + jsonStringTrimOneChar(pStr); } return; }else if( isFinal ){ @@ -4413,7 +4423,7 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ pStr->bStatic = 1; }else{ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); - pStr->nUsed--; + jsonStringTrimOneChar(pStr); } }else{ sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC); @@ -4523,7 +4533,7 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ if( isFinal ){ if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf); }else{ - pStr->nUsed--; + jsonStringTrimOneChar(pStr); } return; }else if( isFinal ){ @@ -4533,7 +4543,7 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ pStr->bStatic = 1; }else{ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); - pStr->nUsed--; + jsonStringTrimOneChar(pStr); } }else{ sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC); From 8dca1905edbfb064b8bd99d3ffb07deeb370f8f8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 13:18:22 +0000 Subject: [PATCH 0021/1030] Ensure that the replace() SQL function always returns a TEXT value even when its first argument is numeric and its second argument is an empty string. Fix for the issue reported by [forum:/forumpost/3776b48e71|forum post 3776b48e71]. FossilOrigin-Name: 01868ebcd25fadb2034da234c0636e82d07c5abc902ef66493cadfc988e74d7b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 2 +- test/func.test | 3 +++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 5a4e7fd711..87e3d53958 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sbacking\sout\sa\scharacter\sin\sa\sconstructed\sstring\sin\sJSON,\sfirst\smake\ssure\nthe\sstring\shas\snot\sbeen\sreset\sby\son\sOOM.\ndbsqlfuzz\s2fffbea91a5376526ea118d4fe4188c8dd35e317. -D 2024-01-20T12:13:00.530 +C Ensure\sthat\sthe\sreplace()\sSQL\sfunction\salways\sreturns\sa\sTEXT\svalue\seven\nwhen\sits\sfirst\sargument\sis\snumeric\sand\sits\ssecond\sargument\sis\san\sempty\sstring.\nFix\sfor\sthe\sissue\sreported\sby\n[forum:/forumpost/3776b48e71|forum\spost\s3776b48e71]. +D 2024-01-20T13:18:22.409 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -691,7 +691,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c 3381ee4c9aa7ccde22a2a7f35ce343925a7a25d96bdc943649131f9decdebad2 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 -F src/func.c 472f6dcfa39cf54f89a6aec76c79c225fb880a6c14469c15d361331662b9bf43 +F src/func.c c71b81223e165722cd81fa71fb869a235de5998c4c5142a5dfa2725d6331f539 F src/global.c 765a0656d6cbf043cb272ff0ae38f39cc46713539ffe6793258ed3eb4b188b52 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -1216,7 +1216,7 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75 F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9 F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test 3a29323b640c0552f6e9f1577407ced3a68e7d8c0bc04b61dd6040fa593a3a02 +F test/func.test da1332f6ab70338b83f5e2d594e72c7aa438c9b68406915e5a54618d601c09ee F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a F test/func4.test e8ef9b2bd6a192a213cbd5cf31a3b35e25cd6ff2fdaeea0b58d63be31b03d220 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eaf2cf73fca3355edd05fef5b0d0262a6555633908794068805d12b1948beedc -R 8f8b8c466d5567f67ab6487c681d59e2 +P 666690eb433fe38fa527ccbbb8e2c00041a33939da4f6b8bfb737d664f28f0d8 +R 5c8274fb3e9d5dd9f1b4d6e28e9c5cce U drh -Z fda57e08b93251c93aba9abc8bd9967a +Z 5fa26dddb0e1de9dbc03b74686820e2f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 75aed94f83..7cab8868f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -666690eb433fe38fa527ccbbb8e2c00041a33939da4f6b8bfb737d664f28f0d8 \ No newline at end of file +01868ebcd25fadb2034da234c0636e82d07c5abc902ef66493cadfc988e74d7b \ No newline at end of file diff --git a/src/func.c b/src/func.c index 58ef4fef9c..249c17857e 100644 --- a/src/func.c +++ b/src/func.c @@ -1409,7 +1409,7 @@ static void replaceFunc( } if( zPattern[0]==0 ){ assert( sqlite3_value_type(argv[1])!=SQLITE_NULL ); - sqlite3_result_value(context, argv[0]); + sqlite3_result_text(context, (const char*)zStr, nStr, SQLITE_TRANSIENT); return; } nPattern = sqlite3_value_bytes(argv[1]); diff --git a/test/func.test b/test/func.test index 883950a0c4..82f51b857d 100644 --- a/test/func.test +++ b/test/func.test @@ -1042,6 +1042,9 @@ do_test func-21.8 { SELECT replace('aaaaaaa', 'a', '0123456789'); } } {0123456789012345678901234567890123456789012345678901234567890123456789} +do_execsql_test func-21.9 { + SELECT typeof(replace(1,'',0)); +} {text} ifcapable tclvar { do_test func-21.9 { From 4c43f1881e86893c22ead7a72be6b14bbcd051eb Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 15:13:13 +0000 Subject: [PATCH 0022/1030] When doing a text-affinity comparison between two values where one or both have both a text and a numeric type, make sure the numeric type does not confuse the answer. This is a deeper fix to the problem observed by [forum:/forumpost/3776b48e71|forum pose 3776b48e71]. The problem bisects to [25f2246be404f38b] on 2014-08-24, prior to version 3.8.7. FossilOrigin-Name: 709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21 --- ext/misc/noop.c | 22 ++++++++++++++++++++++ manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/test1.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ src/vdbe.c | 8 ++++++-- test/types3.test | 30 +++++++++++++++++++++++++++-- 6 files changed, 115 insertions(+), 14 deletions(-) diff --git a/ext/misc/noop.c b/ext/misc/noop.c index d3a58670c4..18c25e10f7 100644 --- a/ext/misc/noop.c +++ b/ext/misc/noop.c @@ -38,6 +38,24 @@ static void noopfunc( sqlite3_result_value(context, argv[0]); } +/* +** Implementation of the multitype_text() function. +** +** The function returns its argument. The result will always have a +** TEXT value. But if the original input is numeric, it will also +** have that numeric value. +*/ +static void multitypeTextFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + assert( argc==1 ); + (void)argc; + (void)sqlite3_value_text(argv[0]); + sqlite3_result_value(context, argv[0]); +} + #ifdef _WIN32 __declspec(dllexport) #endif @@ -64,5 +82,9 @@ int sqlite3_noop_init( rc = sqlite3_create_function(db, "noop_nd", 1, SQLITE_UTF8, 0, noopfunc, 0, 0); + if( rc ) return rc; + rc = sqlite3_create_function(db, "multitype_text", 1, + SQLITE_UTF8, + 0, multitypeTextFunc, 0, 0); return rc; } diff --git a/manifest b/manifest index 87e3d53958..320c5bbcb4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\sreplace()\sSQL\sfunction\salways\sreturns\sa\sTEXT\svalue\seven\nwhen\sits\sfirst\sargument\sis\snumeric\sand\sits\ssecond\sargument\sis\san\sempty\sstring.\nFix\sfor\sthe\sissue\sreported\sby\n[forum:/forumpost/3776b48e71|forum\spost\s3776b48e71]. -D 2024-01-20T13:18:22.409 +C When\sdoing\sa\stext-affinity\scomparison\sbetween\stwo\svalues\swhere\sone\sor\sboth\nhave\sboth\sa\stext\sand\sa\snumeric\stype,\smake\ssure\sthe\snumeric\stype\sdoes\snot\nconfuse\sthe\sanswer.\s\sThis\sis\sa\sdeeper\sfix\sto\sthe\sproblem\sobserved\sby\n[forum:/forumpost/3776b48e71|forum\spose\s3776b48e71].\s\sThe\sproblem\sbisects\nto\s[25f2246be404f38b]\son\s2014-08-24,\sprior\sto\sversion\s3.8.7. +D 2024-01-20T15:13:13.896 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -389,7 +389,7 @@ F ext/misc/memtrace.c 7c0d115d2ef716ad0ba632c91e05bd119cb16c1aedf3bec9f06196ead2 F ext/misc/memvfs.c 7dffa8cc89c7f2d73da4bd4ccea1bcbd2bd283e3bb4cea398df7c372a197291b F ext/misc/mmapwarm.c a81af4aaec00f24f308e2f4c19bf1d88f3ac3ce848c36daa7a4cd38145c4080d F ext/misc/nextchar.c 7877914c2a80c2f181dd04c3dbef550dfb54c93495dc03da2403b5dd58f34edd -F ext/misc/noop.c 81efe4cad9ec740e64388b14281cb983e6e2c223fed43eb77ab3e34946e0c1ab +F ext/misc/noop.c f1a21cc9b7a4e667e5c8458d80ba680b8bd4315a003f256006046879f679c5a0 F ext/misc/normalize.c bd84355c118e297522aba74de34a4fd286fc775524e0499b14473918d09ea61f F ext/misc/pcachetrace.c f4227ce03fb16aa8d6f321b72dd051097419d7a028a9853af048bee7645cb405 F ext/misc/percentile.c b9086e223d583bdaf8cb73c98a6539d501a2fc4282654adbfea576453d82e691 @@ -748,7 +748,7 @@ F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c ecbc3c99c0d0c3ed122a913f143026c26d38d57f33e06bb71185dd5c1efe37cd -F src/test1.c ac6542cddd1f405e332d869946b977b2ce8b4dc28b9f7cc61df38abe1fe49bc3 +F src/test1.c 310f43eb17a9252a7790726ca652e4ea3197da17c19eec93b8578863a49dc7b4 F src/test2.c 54520d0565ef2b9bf0f8f1dcac43dc4d06baf4ffe13d10905f8d8c3ad3e4b9ab F src/test3.c e5178558c41ff53236ae0271e9acb3d6885a94981d2eb939536ee6474598840e F src/test4.c 4533b76419e7feb41b40582554663ed3cd77aaa54e135cf76b3205098cd6e664 @@ -808,7 +808,7 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 4a42916b14548112cb1ee9b9dea3c0ba6c21d08fa0c660cd1561c1871e25908f +F src/vdbe.c 92910d536e0b77505599cd6ae5d9d449e4a5d31ada61da4c0bb84f6ccb2c3189 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -1866,7 +1866,7 @@ F test/tt3_stress.c f9a769ca8b026ecc76ee93ca8c9700a5619f8e51c581107c4053ba6ac97f F test/tt3_vacuum.c 71b254cde1fc49d6c8c44efd54f4668f3e57d7b3a8f4601ade069f75a999ba39 F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff F test/types2.test 1aeb81976841a91eef292723649b5c4fe3bc3cac -F test/types3.test 99e009491a54f4dc02c06bdbc0c5eea56ae3e25a +F test/types3.test c9db8f9e80309edfa4252585cf16bcab7ed31f39eeb904d21e831199a3613fb0 F test/unhex.test b7f1b806207cb77fa31c3e434fe92fba524464e3e9356809bfcc28f15af1a8b7 F test/unionall.test 5b1c4186a661e4bf762875caf4c61d8fda3dd04a6fa9005187f6ba8900c2913f F test/unionall2.test 71e8fa08d5699d50dc9f9dc0c9799c2e7a6bb7931a330d369307a4df7f157fa1 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 666690eb433fe38fa527ccbbb8e2c00041a33939da4f6b8bfb737d664f28f0d8 -R 5c8274fb3e9d5dd9f1b4d6e28e9c5cce +P 01868ebcd25fadb2034da234c0636e82d07c5abc902ef66493cadfc988e74d7b +R c017e3ff6a3cf5fef0c29004a344e6f7 U drh -Z 5fa26dddb0e1de9dbc03b74686820e2f +Z f4a73b0af78f34dd85f781f1eb7187c3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7cab8868f6..d23f19cb29 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -01868ebcd25fadb2034da234c0636e82d07c5abc902ef66493cadfc988e74d7b \ No newline at end of file +709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 9c28259b41..8faf5a397b 100644 --- a/src/test1.c +++ b/src/test1.c @@ -991,6 +991,39 @@ static void intrealFunction( sqlite3_test_control(SQLITE_TESTCTRL_RESULT_INTREAL, context); } +/* +** These SQL functions attempt to return a value (their first argument) +** that has been modified to have multiple datatypes. For example both +** TEXT and INTEGER. +*/ +static void addTextTypeFunction( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + (void)sqlite3_value_text(argv[0]); + (void)argc; + sqlite3_result_value(context, argv[0]); +} +static void addIntTypeFunction( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + (void)sqlite3_value_int64(argv[0]); + (void)argc; + sqlite3_result_value(context, argv[0]); +} +static void addRealTypeFunction( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + (void)sqlite3_value_double(argv[0]); + (void)argc; + sqlite3_result_value(context, argv[0]); +} + /* ** SQL function: strtod(X) ** @@ -1103,6 +1136,22 @@ static int SQLITE_TCLAPI test_create_function( 0, intrealFunction, 0, 0); } + /* The add_text_type(), add_int_type(), and add_real_type() functions + ** attempt to return a value that has multiple datatypes. + */ + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "add_text_type", 1, SQLITE_UTF8, + 0, addTextTypeFunction, 0, 0); + } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "add_int_type", 1, SQLITE_UTF8, + 0, addIntTypeFunction, 0, 0); + } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "add_real_type", 1, SQLITE_UTF8, + 0, addRealTypeFunction, 0, 0); + } + /* Functions strtod() and dtostr() work as in the shell. These routines ** use the standard C library to convert between floating point and ** text. This is used to compare SQLite's internal conversion routines diff --git a/src/vdbe.c b/src/vdbe.c index 2ae757b76e..84eccf5334 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2301,7 +2301,9 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ } } }else if( affinity==SQLITE_AFF_TEXT && ((flags1 | flags3) & MEM_Str)!=0 ){ - if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ + if( (flags1 & MEM_Str)!=0 ){ + pIn1->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal); + }else if( (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ testcase( pIn1->flags & MEM_Int ); testcase( pIn1->flags & MEM_Real ); testcase( pIn1->flags & MEM_IntReal ); @@ -2310,7 +2312,9 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); if( NEVER(pIn1==pIn3) ) flags3 = flags1 | MEM_Str; } - if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ + if( (flags3 & MEM_Str)!=0 ){ + pIn3->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal); + }else if( (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ testcase( pIn3->flags & MEM_Int ); testcase( pIn3->flags & MEM_Real ); testcase( pIn3->flags & MEM_IntReal ); diff --git a/test/types3.test b/test/types3.test index 807ae84f9d..0ff346ce28 100644 --- a/test/types3.test +++ b/test/types3.test @@ -12,8 +12,6 @@ # of this file is testing the interaction of SQLite manifest types # with Tcl dual-representations. # -# $Id: types3.test,v 1.8 2008/04/28 13:02:58 drh Exp $ -# set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -96,4 +94,32 @@ do_test types3-2.6 { tcl_variable_type V } {} +# See https://sqlite.org/forum/forumpost/3776b48e71 +# +# On a text-affinity comparison of two values where one of +# the values has both MEM_Str and a numeric type like MEM_Int, +# make sure that only the MEM_Str representation is used. +# +sqlite3_create_function db +do_execsql_test types3-3.1 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(x TEXT PRIMARY KEY); + INSERT INTO t1 VALUES('1'); + SELECT * FROM t1 WHERE NOT x=upper(1); +} {} +do_execsql_test types3-3.2 { + SELECT * FROM t1 WHERE NOT x=add_text_type(1); +} {} +do_execsql_test types3-3.3 { + SELECT * FROM t1 WHERE NOT x=add_int_type('1'); +} {} +do_execsql_test types3-3.4 { + DELETE FROM t1; + INSERT INTO t1 VALUES(1.25); + SELECT * FROM t1 WHERE NOT x=add_real_type('1.25'); +} {} +do_execsql_test types3-3.5 { + SELECT * FROM t1 WHERE NOT x=add_text_type(1.25); +} {} + finish_test From 3eae6664a00961baf3d011229794cd98371aa9cf Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 20 Jan 2024 16:18:04 +0000 Subject: [PATCH 0023/1030] Allow "_" characters to appear following any digit in an integer or real SQL literal. FossilOrigin-Name: 401650aaccbc99246bd4e1ff37a28b78f528178aee2f294d87b9f7fecd7432bb --- manifest | 29 +++++++++++++++------------- manifest.uuid | 2 +- src/parse.y | 6 ++++++ src/sqliteInt.h | 3 +++ src/tokenize.c | 27 +++++++++++++++++++------- src/util.c | 21 +++++++++++++++++++++ test/literal.test | 3 +++ test/speedtest1.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ tool/speed-check.sh | 3 +++ 9 files changed, 119 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 320c5bbcb4..f2673bb861 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sdoing\sa\stext-affinity\scomparison\sbetween\stwo\svalues\swhere\sone\sor\sboth\nhave\sboth\sa\stext\sand\sa\snumeric\stype,\smake\ssure\sthe\snumeric\stype\sdoes\snot\nconfuse\sthe\sanswer.\s\sThis\sis\sa\sdeeper\sfix\sto\sthe\sproblem\sobserved\sby\n[forum:/forumpost/3776b48e71|forum\spose\s3776b48e71].\s\sThe\sproblem\sbisects\nto\s[25f2246be404f38b]\son\s2014-08-24,\sprior\sto\sversion\s3.8.7. -D 2024-01-20T15:13:13.896 +C Allow\s"_"\scharacters\sto\sappear\sfollowing\sany\sdigit\sin\san\sinteger\sor\sreal\sSQL\sliteral. +D 2024-01-20T16:18:04.854 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -727,7 +727,7 @@ F src/os_win.c 4a50a154aeebc66a1f8fb79c1ff6dd5fe3d005556533361e0d460d41cb6a45a8 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 020d80386eb216ec9520549106353c517d2bbc89be28752ffdca649a9eaf56ec +F src/parse.y 2354aaf964e7c4154a9dbe56ea55a797a0fa3021c38b50afe491ea4a387bf971 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -743,7 +743,7 @@ F src/shell.c.in d1ed426aae2d547932971e8019939cacb4dfda8258e45b8924b250e488e2d53 F src/sqlite.h.in 61a60b4ea04db8ead15e1579b20b64cb56e9f55d52c5f9f9694de630110593a3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 73800d73e21180e6b3df8d0fe7d11758dc24367fd2b0b0075b48fc116de406bb +F src/sqliteInt.h 6e5e330d84b4ace70e3163721601f01df84566e6db21e1fc45bd00636e3d6640 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -800,13 +800,13 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c 23d9f4539880b40226254ad9072f4ecf12eb1902e62aea47aac29928afafcfd5 +F src/tokenize.c b3ab5ee644f3ac54e6a6a856cfb78bdb285e634fae39b38ce0f6e848305ca32e F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b +F src/util.c 2b274b03f0d4fd1bf253f160d6b399bc5265338b043c078045c5e32298891ec8 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c 92910d536e0b77505599cd6ae5d9d449e4a5d31ada61da4c0bb84f6ccb2c3189 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb @@ -1355,7 +1355,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test 31ef70d425c39b993d0dd61b3f4c65d30b7491e8b3dbbd2d8a23b78b1e8931ca +F test/literal.test 9bf0ce5ca1034e3c6f83d5dff82abdedcfa1596cd843b2e4f93f58828e123046 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -1624,7 +1624,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c -F test/speedtest1.c f9505ad6f9c2c3c488a370a2d193e9603a030e51126ef3ecfeb056d21f0e7ad5 +F test/speedtest1.c 19c9b60908d25502d2831f97efee8b81006c356ab8c08327e25d24a4144f2131 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2112,7 +2112,7 @@ F tool/showstat4.c 0682ebea7abf4d3657f53c4a243f2e7eab48eab344ed36a94bb75dcd19a5c F tool/showwal.c 11eca547980a066b081f512636151233350ac679f29ecf4ebfce7f4530230b3d F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/spaceanal.tcl 70c87c04cfd2e77b3e6f21c33ca768296aa8f67d4ab4874786ac8fbb28433477 -F tool/speed-check.sh 72dc85b2c0484af971ee3e7d10775f72b4e771e27e162c2099b3bf25517c25fb +F tool/speed-check.sh e8d20cc2eb9c85ec1ba562226de144435456dcdff4ee618de49603c6958f6116 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -2159,8 +2159,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 01868ebcd25fadb2034da234c0636e82d07c5abc902ef66493cadfc988e74d7b -R c017e3ff6a3cf5fef0c29004a344e6f7 -U drh -Z f4a73b0af78f34dd85f781f1eb7187c3 +P 709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21 +R 25ab10e7bacd9206b22870bd4ed39a9a +T *branch * digit-separators +T *sym-digit-separators * +T -sym-trunk * +U dan +Z ce3fc1dbdae9b70fcb4dc10489ba2fab # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d23f19cb29..e6ba736181 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21 \ No newline at end of file +401650aaccbc99246bd4e1ff37a28b78f528178aee2f294d87b9f7fecd7432bb \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 19491192e3..b0d03a04ee 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1923,6 +1923,12 @@ filter_clause(A) ::= FILTER LP WHERE expr(X) RP. { A = X; } SPAN /* The span operator */ ERROR /* An expression containing an error */ . + +term(A) ::= QNUMBER(X). { + A=tokenExpr(pParse,@X,X); + sqlite3DequoteNumber(A); +} + /* There must be no more than 255 tokens defined above. If this grammar ** is extended with new rules and tokens, they must either be so few in ** number that TK_SPAN is no more than 255, or else the new tokens must diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 79a36e060e..c4aaf9d203 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -609,6 +609,8 @@ # define SQLITE_OMIT_ALTERTABLE #endif +#define SQLITE_DIGIT_SEPARATOR '_' + /* ** Return true (non-zero) if the input is an integer that is too large ** to fit in 32-bits. This macro is used inside of various testcase() @@ -4792,6 +4794,7 @@ int sqlite3ErrorToParser(sqlite3*,int); void sqlite3Dequote(char*); void sqlite3DequoteExpr(Expr*); void sqlite3DequoteToken(Token*); +void sqlite3DequoteNumber(Expr*); void sqlite3TokenInit(Token*,char*); int sqlite3KeywordCode(const unsigned char*, int); int sqlite3RunParser(Parse*, const char*); diff --git a/src/tokenize.c b/src/tokenize.c index f4d013deea..ae1f6da3f1 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -441,21 +441,34 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ return i; } #endif - for(i=0; sqlite3Isdigit(z[i]); i++){} + for(i=0; 1; i++){ + if( sqlite3Isdigit(z[i])==0 ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; } + else{ break; } + } + } #ifndef SQLITE_OMIT_FLOATING_POINT if( z[i]=='.' ){ - i++; - while( sqlite3Isdigit(z[i]) ){ i++; } - *tokenType = TK_FLOAT; + if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; + for(i++; 1; i++){ + if( sqlite3Isdigit(z[i])==0 ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; } + else{ break; } + } + } } if( (z[i]=='e' || z[i]=='E') && ( sqlite3Isdigit(z[i+1]) || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2])) ) ){ - i += 2; - while( sqlite3Isdigit(z[i]) ){ i++; } - *tokenType = TK_FLOAT; + if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; + for(i+=2; 1; i++){ + if( sqlite3Isdigit(z[i])==0 ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; } + else{ break; } + } + } } #endif while( IdChar(z[i]) ){ diff --git a/src/util.c b/src/util.c index 207b901bad..24eff14e9f 100644 --- a/src/util.c +++ b/src/util.c @@ -311,6 +311,27 @@ void sqlite3DequoteExpr(Expr *p){ sqlite3Dequote(p->u.zToken); } +/* +** Expression p is a QINTEGER or QFLOAT (quoted integer or float). Dequote +** the value in p->u.zToken and set the type to INTEGER or FLOAT. "Quoted" +** integers or floats are those that contain '_' characters that must +** be removed before further processing. +*/ +void sqlite3DequoteNumber(Expr *p){ + if( p ){ + const char *pIn = p->u.zToken; + char *pOut = p->u.zToken; + assert( p->op==TK_QNUMBER ); + p->op = TK_INTEGER; + do { + if( *pIn!=SQLITE_DIGIT_SEPARATOR ){ + *pOut++ = *pIn; + if( *pIn=='e' || *pIn=='E' || *pIn=='.' ) p->op = TK_FLOAT; + } + }while( *pIn++ ); + } +} + /* ** If the input token p is quoted, try to adjust the token to remove ** the quotes. This is not always possible: diff --git a/test/literal.test b/test/literal.test index 7bbb8f0f7a..8537ab5935 100644 --- a/test/literal.test +++ b/test/literal.test @@ -44,4 +44,7 @@ test_literal 1.12 '-0xFF' text -0xFF test_literal 1.13 -'0xFF' integer 0 +test_literal 2.1 1_000 integer 1000 + + finish_test diff --git a/test/speedtest1.c b/test/speedtest1.c index 4f32580987..5709423818 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -2150,6 +2150,50 @@ void testset_debug1(void){ } } +/* +** This testset focuses on the speed of parsing numeric literals (integers +** and real numbers). This was added to test the impact of allowing "_" +** characters to appear in numeric SQL literals to make them easier to read. +** For example, "SELECT 1_000_000;" instead of "SELECT 1000000;". +*/ +void testset_parsenumber(void){ + const char *zSql1 = "SELECT 1, 12, 123, 1234, 12345, 123456"; + const char *zSql2 = "SELECT 8227256643844975616, 7932208612563860480, " + "2010730661871032832, 9138463067404021760, " + "2557616153664746496, 2557616153664746496"; + const char *zSql3 = "SELECT 1.0, 1.2, 1.23, 123.4, 1.2345, 1.23456"; + const char *zSql4 = "SELECT 8.227256643844975616, 7.932208612563860480, " + "2.010730661871032832, 9.138463067404021760, " + "2.557616153664746496, 2.557616153664746496"; + + const int NROW = 100*g.szTest; + int ii; + + speedtest1_begin_test(100, "parsing small integers"); + for(ii=0; ii #include @@ -2557,6 +2601,8 @@ int main(int argc, char **argv){ testset_fp(); }else if( strcmp(zThisTest,"trigger")==0 ){ testset_trigger(); + }else if( strcmp(zThisTest,"parsenumber")==0 ){ + testset_parsenumber(); }else if( strcmp(zThisTest,"rtree")==0 ){ #ifdef SQLITE_ENABLE_RTREE testset_rtree(6, 147); diff --git a/tool/speed-check.sh b/tool/speed-check.sh index 4cc25794a2..5d425c3b37 100644 --- a/tool/speed-check.sh +++ b/tool/speed-check.sh @@ -161,6 +161,9 @@ while test "$1" != ""; do --fp) SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset fp" ;; + --parsenumber) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset parsenumber" + ;; --stmtscanstatus) SPEEDTEST_OPTS="$SPEEDTEST_OPTS --stmtscanstatus" ;; From b23f61b73fcbb9e3e369b222c7c3559280a4f720 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 16:29:19 +0000 Subject: [PATCH 0024/1030] Rig sqlite3_serialize() so that it will initialize a previously uninitialized database prior to serializing it, so that it does not have a zero-byte size and does not return NULL (except for OOM). [forum:/forumpost/498777780e16880a|Forum thread 498777780e16880a]. FossilOrigin-Name: e638d5e408ea2e189b6771d16bbc2e42c606e88e05fbea78079b6e39e41f344c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/memdb.c | 8 ++++++++ test/memdb1.test | 12 ++++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 320c5bbcb4..a4427cb088 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sdoing\sa\stext-affinity\scomparison\sbetween\stwo\svalues\swhere\sone\sor\sboth\nhave\sboth\sa\stext\sand\sa\snumeric\stype,\smake\ssure\sthe\snumeric\stype\sdoes\snot\nconfuse\sthe\sanswer.\s\sThis\sis\sa\sdeeper\sfix\sto\sthe\sproblem\sobserved\sby\n[forum:/forumpost/3776b48e71|forum\spose\s3776b48e71].\s\sThe\sproblem\sbisects\nto\s[25f2246be404f38b]\son\s2014-08-24,\sprior\sto\sversion\s3.8.7. -D 2024-01-20T15:13:13.896 +C Rig\ssqlite3_serialize()\sso\sthat\sit\swill\sinitialize\sa\spreviously\suninitialized\ndatabase\sprior\sto\sserializing\sit,\sso\sthat\sit\sdoes\snot\shave\sa\szero-byte\ssize\nand\sdoes\snot\sreturn\sNULL\s(except\sfor\sOOM).\n[forum:/forumpost/498777780e16880a|Forum\sthread\s498777780e16880a]. +D 2024-01-20T16:29:19.033 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -708,7 +708,7 @@ F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75 F src/mem3.c 30301196cace2a085cbedee1326a49f4b26deff0af68774ca82c1f7c06fda4f6 F src/mem5.c b7da5c10a726aacacc9ad7cdcb0667deec643e117591cc69cf9b4b9e7f3e96ff -F src/memdb.c 559c42e61eb70cd6d4bc692b042497133c6d96c09a3d514d92f3dac72268e223 +F src/memdb.c 16679def118b5fd75292a253166d3feba3ec9c6189205bf209643ecdb2174ecc F src/memjournal.c c283c6c95d940eb9dc70f1863eef3ee40382dbd35e5a1108026e7817c206e8a0 F src/msvc.h 80b35f95d93bf996ccb3e498535255f2ef1118c78764719a7cd15ab4106ccac9 F src/mutex.c 1b4c7e5e3621b510e0c18397210be27cd54c8084141144fbbafd003fde948e88 @@ -1396,7 +1396,7 @@ F test/malloctraceviewer.tcl 3e3ddf11e30d2b20f53aa16aa6615082fb24a100bea61cca721 F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7 -F test/memdb1.test 2c4e9cc10d21c6bf4e217d72b7f6b8ba9b2605971bb2c5e6df76018e189f98f5 +F test/memdb1.test bef8623da0c0c2d8d4e0426dee5a52008a5714860901f8bca7638830b2645dbe F test/memdb2.test 4ba1fc09e2f51df80d148a540e4a3fa66d0462e91167b27497084de4d1f6b5b4 F test/memjournal.test 70f3a00c7f84ee2978ad14e831231caa1e7f23915a2c54b4f775a021d5740c6c F test/memjournal2.test dbc2c5cb5f7b38950f4f6dc3e73fcecf0fcbed3fc32c7ce913bba164d288da1e @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 01868ebcd25fadb2034da234c0636e82d07c5abc902ef66493cadfc988e74d7b -R c017e3ff6a3cf5fef0c29004a344e6f7 +P 709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21 +R 6b35ed1d4541fe33e619d0defc51d4d4 U drh -Z f4a73b0af78f34dd85f781f1eb7187c3 +Z 0850c6fe7ffc6bdccabb75e3570a33ee # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d23f19cb29..2ff1ab4571 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21 \ No newline at end of file +e638d5e408ea2e189b6771d16bbc2e42c606e88e05fbea78079b6e39e41f344c \ No newline at end of file diff --git a/src/memdb.c b/src/memdb.c index 657cb9ca65..d83a51d54d 100644 --- a/src/memdb.c +++ b/src/memdb.c @@ -799,6 +799,14 @@ unsigned char *sqlite3_serialize( pOut = 0; }else{ sz = sqlite3_column_int64(pStmt, 0)*szPage; + if( sz==0 ){ + sqlite3_reset(pStmt); + sqlite3_exec(db, "BEGIN IMMEDIATE; COMMIT;", 0, 0, 0); + rc = sqlite3_step(pStmt); + if( rc==SQLITE_ROW ){ + sz = sqlite3_column_int64(pStmt, 0)*szPage; + } + } if( piSize ) *piSize = sz; if( mFlags & SQLITE_SERIALIZE_NOCOPY ){ pOut = 0; diff --git a/test/memdb1.test b/test/memdb1.test index 5e219a4c01..05d9fa04ed 100644 --- a/test/memdb1.test +++ b/test/memdb1.test @@ -267,4 +267,16 @@ if {[wal_is_capable]} { } {1 {database disk image is malformed}} } +# 2024-01-20 +# https://sqlite.org/forum/forumpost/498777780e16880a +# +# Make sure a database is initialized before serializing it. +# +reset_db +sqlite3 dbempty :memory: +do_test 900 { + set len [string length [dbempty serialize]] + expr {$len>0} +} 1 + finish_test From 2e12890732f8c23719a46e56175323cf7d1daccb Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 16:38:00 +0000 Subject: [PATCH 0025/1030] Make sure that %V and %G are testing for every since day in between 1970-01-01 and 2023-01-19. FossilOrigin-Name: 39c475f5fb86526622a715860385f0a3a4b2c18d8ef209779c423527e0639385 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/date4.test | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index a4427cb088..a8079c2744 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rig\ssqlite3_serialize()\sso\sthat\sit\swill\sinitialize\sa\spreviously\suninitialized\ndatabase\sprior\sto\sserializing\sit,\sso\sthat\sit\sdoes\snot\shave\sa\szero-byte\ssize\nand\sdoes\snot\sreturn\sNULL\s(except\sfor\sOOM).\n[forum:/forumpost/498777780e16880a|Forum\sthread\s498777780e16880a]. -D 2024-01-20T16:29:19.033 +C Make\ssure\sthat\s%V\sand\s%G\sare\stesting\sfor\severy\ssince\sday\sin\sbetween\s1970-01-01\nand\s2023-01-19. +D 2024-01-20T16:38:00.290 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1033,7 +1033,7 @@ F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68 F test/date.test b1a5208e6a9c390cf1d1fa4e38a910386b427b0e27046901c6b0fb995d19800e F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1 F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5 -F test/date4.test 77b3781c28d3a5e181c6474315aa58e1f6cf79f5171a4e46e248837b506e7adf +F test/date4.test 75dc8401e8c0639a228cd26a6eaa4ff5ea8ccda912b9853d1c9462c476670e17 F test/dbdata.test 042f49acff3438f940eeba5868d3af080ae64ddf26ae78f80c92bec3ca7d8603 F test/dbfuzz.c 73047c920d6210e5912c87cdffd9a1c281d4252e F test/dbfuzz001.test 6c9a4622029d69dc38926f115864b055cb2f39badd25ec22cbfb130c8ba8e9c3 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21 -R 6b35ed1d4541fe33e619d0defc51d4d4 +P e638d5e408ea2e189b6771d16bbc2e42c606e88e05fbea78079b6e39e41f344c +R def255443f75553b73e601b4d3401144 U drh -Z 0850c6fe7ffc6bdccabb75e3570a33ee +Z f250ebbbb7ead57b6a863fb7b3b9221e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2ff1ab4571..d3659e6025 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e638d5e408ea2e189b6771d16bbc2e42c606e88e05fbea78079b6e39e41f344c \ No newline at end of file +39c475f5fb86526622a715860385f0a3a4b2c18d8ef209779c423527e0639385 \ No newline at end of file diff --git a/test/date4.test b/test/date4.test index 0dd06debb7..56a9090b1b 100644 --- a/test/date4.test +++ b/test/date4.test @@ -28,8 +28,8 @@ if {$tcl_platform(os)=="Linux"} { } else { set FMT {%d,%e,%F,%H,%I,%j,%p,%R,%u,%w,%W,%%} } -for {set i 0} {$i<=24854} {incr i} { - set TS [expr {$i*86401}] +for {set i 0} {$i<=24858} {incr i} { + set TS [expr {$i*86390}] do_execsql_test date4-$i { SELECT strftime($::FMT,$::TS,'unixepoch'); } [list [strftime $FMT $TS]] From 95295a7e9b59e90029ae7a90ebee1667c51a3139 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 20 Jan 2024 16:46:25 +0000 Subject: [PATCH 0026/1030] Add test cases for the new code on this branch. FossilOrigin-Name: 49f29a7b4f44f691ecf7a57b26477971e6ffaf2a0b1690b4926ffbb43fa3929b --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/tokenize.c | 7 +++++-- test/literal.test | 13 ++++++++++--- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index f2673bb861..85784dcc72 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\s"_"\scharacters\sto\sappear\sfollowing\sany\sdigit\sin\san\sinteger\sor\sreal\sSQL\sliteral. -D 2024-01-20T16:18:04.854 +C Add\stest\scases\sfor\sthe\snew\scode\son\sthis\sbranch. +D 2024-01-20T16:46:25.186 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -800,7 +800,7 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c b3ab5ee644f3ac54e6a6a856cfb78bdb285e634fae39b38ce0f6e848305ca32e +F src/tokenize.c e0cdd971ebf7225cd617661d8198fc90a49559e21210af03bdf440e2fcba6b88 F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 @@ -1355,7 +1355,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test 9bf0ce5ca1034e3c6f83d5dff82abdedcfa1596cd843b2e4f93f58828e123046 +F test/literal.test 62415688179c0d586f3633482e6c8e441edb805cd73c306964cf39912a6bff0e F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -2159,11 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21 -R 25ab10e7bacd9206b22870bd4ed39a9a -T *branch * digit-separators -T *sym-digit-separators * -T -sym-trunk * +P 401650aaccbc99246bd4e1ff37a28b78f528178aee2f294d87b9f7fecd7432bb +R f613ae2f01e87601e8fa7113cad6d125 U dan -Z ce3fc1dbdae9b70fcb4dc10489ba2fab +Z 0deb0f7f0bb54434edd39b41a13f24b4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e6ba736181..a510d65faa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -401650aaccbc99246bd4e1ff37a28b78f528178aee2f294d87b9f7fecd7432bb \ No newline at end of file +49f29a7b4f44f691ecf7a57b26477971e6ffaf2a0b1690b4926ffbb43fa3929b \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index ae1f6da3f1..592d6b8d8d 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -635,10 +635,13 @@ int sqlite3RunParser(Parse *pParse, const char *zSql){ if( tokenType>=TK_WINDOW ){ assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW + || tokenType==TK_QNUMBER ); #else if( tokenType>=TK_SPACE ){ - assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL ); + assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL + || tokenType==TK_QNUMBER + ); #endif /* SQLITE_OMIT_WINDOWFUNC */ if( AtomicLoad(&db->u1.isInterrupted) ){ pParse->rc = SQLITE_INTERRUPT; @@ -671,7 +674,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql){ assert( n==6 ); tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed); #endif /* SQLITE_OMIT_WINDOWFUNC */ - }else{ + }else if( tokenType!=TK_QNUMBER ){ Token x; x.z = zSql; x.n = n; diff --git a/test/literal.test b/test/literal.test index 8537ab5935..01ea7b954c 100644 --- a/test/literal.test +++ b/test/literal.test @@ -43,8 +43,15 @@ test_literal 1.11 '0xFF' text 0xFF test_literal 1.12 '-0xFF' text -0xFF test_literal 1.13 -'0xFF' integer 0 - -test_literal 2.1 1_000 integer 1000 - +test_literal 2.1 1_000 integer 1000 +test_literal 2.2 1.1_1 real 1.11 +test_literal 2.3 1_0.1_1 real 10.11 +test_literal 2.4 1e1_000 real Inf +test_literal 2.5 123______456.7_8__9_ real 123456.789 +test_literal 2.6 9_223_372_036_854_775_807 integer 9223372036854775807 +test_literal 2.7 9_223_372_036_854_775_808 real 9.22337203685478e+18 +test_literal 2.8 -9_223_372_036_854_775_808 integer -9223372036854775808 + +test_literal 3.3 1e12 real 1000000000000.0 finish_test From 6c64e24f9d0675095a2c67a025e3db7bf4636821 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 18:21:50 +0000 Subject: [PATCH 0027/1030] Fix a memory leak in new memdb1.test test cases that were added by [e638d5e408ea2e18]. No changes to SQLite itself. FossilOrigin-Name: bb2b7a658e0186d8b09199170db17744536602d8282b83c71ed969494d2ca465 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/memdb1.test | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index a8079c2744..165799a685 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthat\s%V\sand\s%G\sare\stesting\sfor\severy\ssince\sday\sin\sbetween\s1970-01-01\nand\s2023-01-19. -D 2024-01-20T16:38:00.290 +C Fix\sa\smemory\sleak\sin\snew\smemdb1.test\stest\scases\sthat\swere\sadded\sby\n[e638d5e408ea2e18].\s\sNo\schanges\sto\sSQLite\sitself. +D 2024-01-20T18:21:50.590 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1396,7 +1396,7 @@ F test/malloctraceviewer.tcl 3e3ddf11e30d2b20f53aa16aa6615082fb24a100bea61cca721 F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7 -F test/memdb1.test bef8623da0c0c2d8d4e0426dee5a52008a5714860901f8bca7638830b2645dbe +F test/memdb1.test cd6b6b1632cf2f76c8a6f35be013f4011f3ab2c8d74d3d1424576f29bfa4a9a1 F test/memdb2.test 4ba1fc09e2f51df80d148a540e4a3fa66d0462e91167b27497084de4d1f6b5b4 F test/memjournal.test 70f3a00c7f84ee2978ad14e831231caa1e7f23915a2c54b4f775a021d5740c6c F test/memjournal2.test dbc2c5cb5f7b38950f4f6dc3e73fcecf0fcbed3fc32c7ce913bba164d288da1e @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e638d5e408ea2e189b6771d16bbc2e42c606e88e05fbea78079b6e39e41f344c -R def255443f75553b73e601b4d3401144 +P 39c475f5fb86526622a715860385f0a3a4b2c18d8ef209779c423527e0639385 +R 74384040736e0977d7c5dfb4dce5d968 U drh -Z f250ebbbb7ead57b6a863fb7b3b9221e +Z 312b96149522d237d108c8a3641b64b6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d3659e6025..0ffeb5f5fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39c475f5fb86526622a715860385f0a3a4b2c18d8ef209779c423527e0639385 \ No newline at end of file +bb2b7a658e0186d8b09199170db17744536602d8282b83c71ed969494d2ca465 \ No newline at end of file diff --git a/test/memdb1.test b/test/memdb1.test index 05d9fa04ed..e6820da4a2 100644 --- a/test/memdb1.test +++ b/test/memdb1.test @@ -278,5 +278,6 @@ do_test 900 { set len [string length [dbempty serialize]] expr {$len>0} } 1 +dbempty close finish_test From 514bf99b6aa18f05f78d02b9b3afddc51d006eca Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 20 Jan 2024 18:26:28 +0000 Subject: [PATCH 0028/1030] Simplifications to the strftime() logic. FossilOrigin-Name: aaa5a044d8a4942278eb4269fa8c7252f9f1dc161408e618e7c97c55a12283ff --- manifest | 12 +++++----- manifest.uuid | 2 +- src/date.c | 64 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index 165799a685..821d38be63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sleak\sin\snew\smemdb1.test\stest\scases\sthat\swere\sadded\sby\n[e638d5e408ea2e18].\s\sNo\schanges\sto\sSQLite\sitself. -D 2024-01-20T18:21:50.590 +C Simplifications\sto\sthe\sstrftime()\slogic. +D 2024-01-20T18:26:28.712 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -684,7 +684,7 @@ F src/build.c e7d9044592eeeea8e78d8ae53ca8d31fd6e92ca0d4f53e2f2e8ccf7352e0b04b F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c 35ea61eb7ab5b918db7a96725346234bf8fb5bc161c7b868c20a7f24f351a2da +F src/date.c 48a110a2a267398ad9b04fe3db69dfa194f91719f94fa55cd560e03510f963e6 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 39c475f5fb86526622a715860385f0a3a4b2c18d8ef209779c423527e0639385 -R 74384040736e0977d7c5dfb4dce5d968 +P bb2b7a658e0186d8b09199170db17744536602d8282b83c71ed969494d2ca465 +R 8518c96f5a8faebc2a9945073340f70a U drh -Z 312b96149522d237d108c8a3641b64b6 +Z f670e53a135b10311c59f478b3527211 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0ffeb5f5fe..e3a0693990 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bb2b7a658e0186d8b09199170db17744536602d8282b83c71ed969494d2ca465 \ No newline at end of file +aaa5a044d8a4942278eb4269fa8c7252f9f1dc161408e618e7c97c55a12283ff \ No newline at end of file diff --git a/src/date.c b/src/date.c index 76e1894f8d..e468925d5e 100644 --- a/src/date.c +++ b/src/date.c @@ -1237,10 +1237,14 @@ static void dateFunc( } /* -** Compute the one-based day of the year for the DateTime pDate. -** Jan01 = 1, Jan02 = 2, ... Dec31 = 356 or 366. +** Compute the number of days after the most recent January 1. +** +** In other words, compute the zero-based day number for the +** current year: +** +** Jan01 = 0, Jan02 = 2, ... Dec31 = 364 or 365. */ -static int dayOfYear(DateTime *pDate){ +static int daysAfterJan01(DateTime *pDate){ DateTime jan01 = *pDate; assert( jan01.validYMD ); assert( jan01.validHMS ); @@ -1249,18 +1253,33 @@ static int dayOfYear(DateTime *pDate){ jan01.M = 1; jan01.D = 1; computeJD(&jan01); - return (int)((pDate->iJD-jan01.iJD+43200000)/86400000) + 1; + return (int)((pDate->iJD-jan01.iJD+43200000)/86400000); } /* -** Return the day of the week. 1==Monday, 2=Tues, ..., 7=Sunday. +** Return the number of days after the most recent Monday. +** +** In other words, return the day of the week according +** to this code: +** +** 0=Monday, 1=Tuesday, 2=Wednesday, ..., 6=Sunday. +*/ +static int daysAfterMonday(DateTime *pDate){ + assert( pDate->validJD ); + return (int)((pDate->iJD+43200000)/86400000) % 7; +} + +/* +** Return the number of days after the most recent Sunday. +** +** In other words, return the day of the week according +** to this code: +** +** 0=Sunday, 1=Monday, 2=Tues, ..., 6=Saturday */ -static int dayOfWeek(DateTime *pDate){ - int w; +static int daysAfterSunday(DateTime *pDate){ assert( pDate->validJD ); - w = ((pDate->iJD+129600000)/86400000) % 7; - if( w==0 ) w = 7; - return w; + return (int)((pDate->iJD+129600000)/86400000) % 7; } /* @@ -1344,7 +1363,7 @@ static void strftimeFunc( DateTime y = x; assert( y.validJD ); /* Move y so that it is the Thursday in the same week as x */ - y.iJD += (4 - dayOfWeek(&x))*86400000; + y.iJD += (3 - daysAfterMonday(&x))*86400000; y.validYMD = 0; computeYMD(&y); if( cf=='g' ){ @@ -1368,8 +1387,7 @@ static void strftimeFunc( break; } case 'j': { /* Day of year. Jan01==1, Jan02==2, and so forth */ - int nDay = dayOfYear(&x); - sqlite3_str_appendf(&sRes,"%03d",nDay); + sqlite3_str_appendf(&sRes,"%03d",daysAfterJan01(&x)+1); break; } case 'J': { /* Julian day number. (Non-standard) */ @@ -1417,35 +1435,29 @@ static void strftimeFunc( } case 'u': /* Day of week. 1 to 7. Monday==1, Sunday==7 */ case 'w': { /* Day of week. 0 to 6. Sunday==0, Monday==1 */ - char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; + char c = (char)daysAfterSunday(&x) + '0'; if( c=='0' && cf=='u' ) c = '7'; sqlite3_str_appendchar(&sRes, 1, c); break; } case 'U': { /* Week num. 00-53. First Sun of the year is week 01 */ - int wd; /* 0=Sunday, 1=Monday, 2=Tuesday, ... 7=Saturday */ - int nDay; /* Day of the year. 0..364 or 0..365 for leapyears */ - nDay = dayOfYear(&x); - wd = (int)(((x.iJD+43200000)/86400000 + 1)%7); - sqlite3_str_appendf(&sRes,"%02d",(nDay+6-wd)/7); + sqlite3_str_appendf(&sRes,"%02d", + (daysAfterJan01(&x)-daysAfterSunday(&x)+7)/7); break; } case 'V': { /* Week num. 01-53. First week with a Thur is week 01 */ DateTime y = x; /* Adjust y so that is the Thursday in the same week as x */ assert( y.validJD ); - y.iJD += (4 - dayOfWeek(&x))*86400000; + y.iJD += (3 - daysAfterMonday(&x))*86400000; y.validYMD = 0; computeYMD(&y); - sqlite3_str_appendf(&sRes,"%02d", (dayOfYear(&y)-1)/7+1); + sqlite3_str_appendf(&sRes,"%02d", daysAfterJan01(&y)/7+1); break; } case 'W': { /* Week num. 00-53. First Mon of the year is week 01 */ - int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ - int nDay; /* Day of the year. 0..364 or 0..365 for leapyears */ - nDay = dayOfYear(&x); - wd = (int)(((x.iJD+43200000)/86400000)%7); - sqlite3_str_appendf(&sRes,"%02d",(nDay+6-wd)/7); + sqlite3_str_appendf(&sRes,"%02d", + (daysAfterJan01(&x)-daysAfterMonday(&x)+7)/7); break; } case 'Y': { From f28bff745c778598ef1740e4cbb1a44b176aac83 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 20 Jan 2024 18:41:13 +0000 Subject: [PATCH 0029/1030] Ensure that values generated by DEFAULT clauses that specify real numbers that can be expressed as 64-bit integers (e.g. -1234.0) are not silently converted to integers. FossilOrigin-Name: 298d6977285c71be917896bc875a8a26d985dcf0a74069b7c4d290e8ff0ac618 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/vdbemem.c | 13 +++++++++++-- test/alter2.test | 8 ++++---- test/literal.test | 6 ++++++ test/tkt-8454a207b9.test | 2 +- 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 821d38be63..eec8b0a2e9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\sstrftime()\slogic. -D 2024-01-20T18:26:28.712 +C Ensure\sthat\svalues\sgenerated\sby\sDEFAULT\sclauses\sthat\sspecify\sreal\snumbers\sthat\scan\sbe\sexpressed\sas\s64-bit\sintegers\s(e.g.\s-1234.0)\sare\snot\ssilently\sconverted\sto\sintegers. +D 2024-01-20T18:41:13.528 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -814,7 +814,7 @@ F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b F src/vdbeaux.c c5a471b34e9c4cfc0295a3e10734fd197670ffaebcb742f284c8e17e8026ceea F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 -F src/vdbemem.c bbe87b3e851bcc5cad2a9329ad0387432e41ddf2f98f2682c524ad676b739987 +F src/vdbemem.c 3e37dab421b74e9ce55c1e88fbc7bc6fead590b5ab258bc684f8b70abb1d6e71 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 @@ -838,7 +838,7 @@ F test/aggorderby.test cc3abf5de64d46ff66395ca8c2346b66c2576d5aedb7bffc5b0742508 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 2ecb8bbd52416642e41c9081182a8df05d42c75637afd4488aace78cc4b69e13 F test/alter.test 3c00eff1e2036b9f93e9cd0f3d3e63750ac87ecb5bc71b9d7bd07cbf2ac4c494 -F test/alter2.test a966ccfcddf9ce0a4e0e6ff1aca9e6e7948e0e242cd7e43fc091948521807687 +F test/alter2.test 7e3d26ab409df52df887b366a63902c3429b935c41cb962fd58ffc25784f2f19 F test/alter3.test ffc4ab29ce78a3517a66afd69b2730667e3471622509c283b2bd4c46f680fba3 F test/alter4.test 716caa071dd8a3c6d57225778d15d3c3cbf5e34b2e84ae44199aeb2bbf50a707 F test/alterauth.test 63442ba61ceb0c1eeb63aac1f4f5cebfa509d352276059d27106ae256bafc959 @@ -1355,7 +1355,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test 31ef70d425c39b993d0dd61b3f4c65d30b7491e8b3dbbd2d8a23b78b1e8931ca +F test/literal.test 12e3c865a9e20f984240dbfb362be2a53ad5ca4ee25a6d429cf059115a9ac48f F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -1715,7 +1715,7 @@ F test/tkt-7a31705a7e6.test 9e9c057b6a9497c8f7ba7b16871029414ccf6550e7345d9085d6 F test/tkt-7bbfb7d442.test e87b59e620700b5a52ecd92f05d56686c1cad9e1aa17456eada55e0bb821b698 F test/tkt-80ba201079.test 105a721e6aad0ae3c5946d7615d1e4d03f6145b8 F test/tkt-80e031a00f.test 7c93af53f43527f50020983a4bcc39b077e77c7362d7af8e04a5fd155fe5e829 -F test/tkt-8454a207b9.test aff2e76143cfa443ddce6f7d85968a2e9b57a3deb0b881b730120740555f9e2f +F test/tkt-8454a207b9.test ead80b7a01438ca1436cee029694a96c821346cf1e24f06de12f8172e139ddbb F test/tkt-868145d012.test a5f941107ece6a64410ca4755c6329b7eb57a356 F test/tkt-8c63ff0ec.test 258b7fc8d7e4e1cb5362c7d65c143528b9c4cbed F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bb2b7a658e0186d8b09199170db17744536602d8282b83c71ed969494d2ca465 -R 8518c96f5a8faebc2a9945073340f70a -U drh -Z f670e53a135b10311c59f478b3527211 +P aaa5a044d8a4942278eb4269fa8c7252f9f1dc161408e618e7c97c55a12283ff +R 363a8d4d24bb7774a5f7eceb24c4f650 +U dan +Z ee966b48b47570fa6886cd7583990b8c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e3a0693990..3883df6b7b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aaa5a044d8a4942278eb4269fa8c7252f9f1dc161408e618e7c97c55a12283ff \ No newline at end of file +298d6977285c71be917896bc875a8a26d985dcf0a74069b7c4d290e8ff0ac618 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index 2d10cda8d5..cbc6712bfd 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1662,8 +1662,17 @@ static int valueFromExpr( sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); } } - if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){ - sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); + if( affinity==SQLITE_AFF_BLOB ){ + if( op==TK_FLOAT ){ + assert( pVal && pVal->z && pVal->flags==(MEM_Str|MEM_Term) ); + sqlite3AtoF(pVal->z, &pVal->u.r, pVal->n, SQLITE_UTF8); + pVal->flags = MEM_Real; + }else if( op==TK_INTEGER ){ + /* This case is required by -9223372036854775808 and other strings + ** that look like integers but cannot be handled by the + ** sqlite3DecOrHexToI64() call above. */ + sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); + } }else{ sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8); } diff --git a/test/alter2.test b/test/alter2.test index aae0061ad4..20b75b59ee 100644 --- a/test/alter2.test +++ b/test/alter2.test @@ -371,7 +371,7 @@ do_test alter2-7.5 { execsql { SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1; } -} {1 integer -123 integer 5 text} +} {1 integer -123.0 real 5 text} #----------------------------------------------------------------------- # Test that UPDATE trigger tables work with default values, and that when @@ -397,11 +397,11 @@ do_test alter2-8.2 { UPDATE t1 SET c = 10 WHERE a = 1; SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1; } -} {1 integer -123 integer 10 text} +} {1 integer -123.0 real 10 text} ifcapable trigger { do_test alter2-8.3 { set ::val - } {-123 integer 5 text -123 integer 10 text} + } {-123.0 real 5 text -123.0 real 10 text} } #----------------------------------------------------------------------- @@ -425,7 +425,7 @@ ifcapable trigger { DELETE FROM t1 WHERE a = 2; } set ::val - } {-123 integer 5 text} + } {-123.0 real 5 text} } #----------------------------------------------------------------------- diff --git a/test/literal.test b/test/literal.test index 7bbb8f0f7a..4e957c05db 100644 --- a/test/literal.test +++ b/test/literal.test @@ -43,5 +43,11 @@ test_literal 1.11 '0xFF' text 0xFF test_literal 1.12 '-0xFF' text -0xFF test_literal 1.13 -'0xFF' integer 0 +test_literal 1.14 -9223372036854775808 integer -9223372036854775808 + +test_literal 2.1 1e12 real 1000000000000.0 +test_literal 2.2 1.0 real 1.0 +test_literal 2.3 1e1000 real Inf +test_literal 2.4 -1e1000 real -Inf finish_test diff --git a/test/tkt-8454a207b9.test b/test/tkt-8454a207b9.test index 20e142057d..42b95c8f53 100644 --- a/test/tkt-8454a207b9.test +++ b/test/tkt-8454a207b9.test @@ -49,7 +49,7 @@ do_test tkt-8454a207b9.4 { ALTER TABLE t1 ADD COLUMN e DEFAULT -123.0; SELECT e, typeof(e) FROM t1; } -} {-123 integer} +} {-123.0 real} do_test tkt-8454a207b9.5 { db eval { ALTER TABLE t1 ADD COLUMN f DEFAULT -123.5; From 199b0b2d6ef338a444ad85c39ea79012a8740369 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 21 Jan 2024 21:20:33 +0000 Subject: [PATCH 0030/1030] Fix a harmless typo in a comment. FossilOrigin-Name: 382a8f94bffef3e5f715116e363a30e21e2c53cd42d4959dfbe90c4624143e6d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/date.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index eec8b0a2e9..517067f287 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\svalues\sgenerated\sby\sDEFAULT\sclauses\sthat\sspecify\sreal\snumbers\sthat\scan\sbe\sexpressed\sas\s64-bit\sintegers\s(e.g.\s-1234.0)\sare\snot\ssilently\sconverted\sto\sintegers. -D 2024-01-20T18:41:13.528 +C Fix\sa\sharmless\stypo\sin\sa\scomment. +D 2024-01-21T21:20:33.306 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -684,7 +684,7 @@ F src/build.c e7d9044592eeeea8e78d8ae53ca8d31fd6e92ca0d4f53e2f2e8ccf7352e0b04b F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c 48a110a2a267398ad9b04fe3db69dfa194f91719f94fa55cd560e03510f963e6 +F src/date.c 90df32c2d8b2a38dd2e83d32e47802629305c4882fb2ec75c9ecdcd75b68bcb2 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aaa5a044d8a4942278eb4269fa8c7252f9f1dc161408e618e7c97c55a12283ff -R 363a8d4d24bb7774a5f7eceb24c4f650 -U dan -Z ee966b48b47570fa6886cd7583990b8c +P 298d6977285c71be917896bc875a8a26d985dcf0a74069b7c4d290e8ff0ac618 +R 6efa1c82cfa2e7d17b14637b7f3e1900 +U drh +Z 096bcae3083b69021bc23dacf629858d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3883df6b7b..91dcb94d92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -298d6977285c71be917896bc875a8a26d985dcf0a74069b7c4d290e8ff0ac618 \ No newline at end of file +382a8f94bffef3e5f715116e363a30e21e2c53cd42d4959dfbe90c4624143e6d \ No newline at end of file diff --git a/src/date.c b/src/date.c index e468925d5e..026d83391a 100644 --- a/src/date.c +++ b/src/date.c @@ -1242,7 +1242,8 @@ static void dateFunc( ** In other words, compute the zero-based day number for the ** current year: ** -** Jan01 = 0, Jan02 = 2, ... Dec31 = 364 or 365. +** Jan01 = 0, Jan02 = 1, ..., Jan31 = 30, Feb01 = 31, ... +** Dec31 = 364 or 365. */ static int daysAfterJan01(DateTime *pDate){ DateTime jan01 = *pDate; From 05ab0f72c34e705ee10097ac243abb11d52c3a5e Mon Sep 17 00:00:00 2001 From: larrybr Date: Mon, 22 Jan 2024 01:11:24 +0000 Subject: [PATCH 0031/1030] Make CLI .dump immune to pragma reverse_unordered_selects, as reported in [forum:/forumpost/c42be01880e961eb|Forum thread "Missing ORDER BY in .dump?"] FossilOrigin-Name: 488caed24453fcef6fddcf40353e3b44cf37fb9d21e0ed743d39d60cbff020a7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 517067f287..280e8dc3bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\stypo\sin\sa\scomment. -D 2024-01-21T21:20:33.306 +C Make\sCLI\s.dump\simmune\sto\spragma\sreverse_unordered_selects,\sas\sreported\sin\s[forum:/forumpost/c42be01880e961eb|Forum\sthread\s"Missing\sORDER\sBY\sin\s.dump?"] +D 2024-01-22T01:11:24.847 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -739,7 +739,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c e25f51a473a5f30a0d978e4df2aaa98aeec84eac29ecae1ad4708a6c3e669345 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da -F src/shell.c.in d1ed426aae2d547932971e8019939cacb4dfda8258e45b8924b250e488e2d53d +F src/shell.c.in 5ea8c6b0057bfe3bcdff31949fe72aa231ae429047c421ea1b168af6825a4890 F src/sqlite.h.in 61a60b4ea04db8ead15e1579b20b64cb56e9f55d52c5f9f9694de630110593a3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 298d6977285c71be917896bc875a8a26d985dcf0a74069b7c4d290e8ff0ac618 -R 6efa1c82cfa2e7d17b14637b7f3e1900 -U drh -Z 096bcae3083b69021bc23dacf629858d +P 382a8f94bffef3e5f715116e363a30e21e2c53cd42d4959dfbe90c4624143e6d +R 0c3ae1bf61b2c5523c6e506b1fe8b74c +U larrybr +Z df2931d680c73052f2016399cfecfafe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 91dcb94d92..d376c3e270 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -382a8f94bffef3e5f715116e363a30e21e2c53cd42d4959dfbe90c4624143e6d \ No newline at end of file +488caed24453fcef6fddcf40353e3b44cf37fb9d21e0ed743d39d60cbff020a7 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index da3b9f8706..02850691d9 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8375,7 +8375,8 @@ static int do_meta_command(char *zLine, ShellState *p){ zSql = sqlite3_mprintf( "SELECT sql FROM sqlite_schema AS o " "WHERE (%s) AND sql NOT NULL" - " AND type IN ('index','trigger','view')", + " AND type IN ('index','trigger','view') " + "ORDER BY type COLLATE NOCASE DESC", zLike ); run_table_dump_query(p, zSql); From 17589f781142afbe9ccb00fb6912270a50e2f710 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 22 Jan 2024 11:12:38 +0000 Subject: [PATCH 0032/1030] Fix test script literal.test so that it works with SQLITE_OMIT_ALTER_TABLE builds. FossilOrigin-Name: b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/literal.test | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 6c05005d18..d5565a35b7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\schanges\sinto\sthis\sbranch. -D 2024-01-20T18:45:30.244 +C Fix\stest\sscript\sliteral.test\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_ALTER_TABLE\sbuilds. +D 2024-01-22T11:12:38.218 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1355,7 +1355,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test 17d21dda2f877018a02c28e2a85947b82ed638f2ca5ef3fa47c92359f02520a3 +F test/literal.test db71a7616dc027badf8d8f7ac6e23e8655915eb51b187c40a0a6e667aed495b7 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 49f29a7b4f44f691ecf7a57b26477971e6ffaf2a0b1690b4926ffbb43fa3929b 298d6977285c71be917896bc875a8a26d985dcf0a74069b7c4d290e8ff0ac618 -R d4f77c6633329aa6323323954676adb8 +P 03ade4a810516ff84bc5c1a716b0e454cc8a89374100415ff21a82449112811b +R 4dc96dbb63712d691b87fb65e2e995c9 U dan -Z 02dbf9257e243f2009f448d2d8147299 +Z 060bde75456debf514e23a793c3f90b5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5f5c21e2d7..902662ca4b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -03ade4a810516ff84bc5c1a716b0e454cc8a89374100415ff21a82449112811b \ No newline at end of file +b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 \ No newline at end of file diff --git a/test/literal.test b/test/literal.test index e29789d37d..3140eedf2a 100644 --- a/test/literal.test +++ b/test/literal.test @@ -19,12 +19,21 @@ set ::testprefix literal proc test_literal {tn lit type val} { do_execsql_test $tn.1 "SELECT typeof( $lit ), $lit" [list $type $val] - do_execsql_test $tn.2 " + ifcapable altertable { + do_execsql_test $tn.2 " + DROP TABLE IF EXISTS x1; + CREATE TABLE x1(a); + INSERT INTO x1 VALUES(123); + ALTER TABLE x1 ADD COLUMN b DEFAULT $lit ; + SELECT typeof(b), b FROM x1; + " [list $type $val] + } + + do_execsql_test $tn.3 " DROP TABLE IF EXISTS x1; - CREATE TABLE x1(a); - INSERT INTO x1 VALUES(123); - ALTER TABLE x1 ADD COLUMN b DEFAULT $lit ; - SELECT typeof(b), b FROM x1; + CREATE TABLE x1(a DEFAULT $lit); + INSERT INTO x1 DEFAULT VALUES; + SELECT typeof(a), a FROM x1; " [list $type $val] } From 3b799b0fca14c36b0c2c62a699fea08b05013718 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 22 Jan 2024 12:30:17 +0000 Subject: [PATCH 0033/1030] Add a notice to the user-authentication documentation to say that the extension is deprecated and may disappear in the future. FossilOrigin-Name: fe6fc7b91ad1771a2d2d4e3d9d60831b3056d528a700932bf11a336c7e3414a2 --- ext/userauth/user-auth.txt | 12 ++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ext/userauth/user-auth.txt b/ext/userauth/user-auth.txt index ba4eabc137..66caca3e1e 100644 --- a/ext/userauth/user-auth.txt +++ b/ext/userauth/user-auth.txt @@ -1,3 +1,15 @@ +*********************************** NOTICE ************************************ +* This extension is deprecated. The SQLite developers do not maintain this * +* extension. At some point in the future, it might disappear from the source * +* tree. * +* * +* If you are using this extension and think it should be supported moving * +* forward, visit the SQLite Forum (https://sqlite.org/forum) and make your * +* case. * +* * +* This deprecation notice was added on 2024-01-22. * +******************************************************************************* + Activate the user authentication logic by including the ext/userauth/userauth.c source code file in the build and adding the -DSQLITE_USER_AUTHENTICATION compile-time option. diff --git a/manifest b/manifest index 280e8dc3bd..ff616768bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sCLI\s.dump\simmune\sto\spragma\sreverse_unordered_selects,\sas\sreported\sin\s[forum:/forumpost/c42be01880e961eb|Forum\sthread\s"Missing\sORDER\sBY\sin\s.dump?"] -D 2024-01-22T01:11:24.847 +C Add\sa\snotice\sto\sthe\suser-authentication\sdocumentation\sto\ssay\sthat\sthe\nextension\sis\sdeprecated\sand\smay\sdisappear\sin\sthe\sfuture. +D 2024-01-22T12:30:17.497 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -572,7 +572,7 @@ F ext/session/sqlite3session.c 829d468f0f3d2710aace56b0116a7ca3f414683ce78e3125a F ext/session/sqlite3session.h 4cf19a51975746d7cff2fdd74db8b769c570958e1c3639ac150d824ac1553b3e F ext/session/test_session.c 7b94ad945cd4afe6c73ee935aeb3d44b4446186e1729362af616c7695a5283d9 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 -F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 +F ext/userauth/user-auth.txt 9a3bdae6b5d2746056d7611ae1d81fa888772ef716b05d20497cdb4f7992e997 F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c F ext/wasm/GNUmakefile 867c903a27fa0d53a3bf1b01d8c7bb713456f87e0939c3cac9f07faa68f58734 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 382a8f94bffef3e5f715116e363a30e21e2c53cd42d4959dfbe90c4624143e6d -R 0c3ae1bf61b2c5523c6e506b1fe8b74c -U larrybr -Z df2931d680c73052f2016399cfecfafe +P 488caed24453fcef6fddcf40353e3b44cf37fb9d21e0ed743d39d60cbff020a7 +R ea5433aac763e6ce8bcfabec2e6890c2 +U drh +Z 559db82f0095218d6f000421c012f60a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d376c3e270..54eab787fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -488caed24453fcef6fddcf40353e3b44cf37fb9d21e0ed743d39d60cbff020a7 \ No newline at end of file +fe6fc7b91ad1771a2d2d4e3d9d60831b3056d528a700932bf11a336c7e3414a2 \ No newline at end of file From 776fe42c70fac79657496020b235a9e67fceeec8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 22 Jan 2024 12:56:58 +0000 Subject: [PATCH 0034/1030] Fix userauth so that it works together with SQLITE_OMIT_SHARED_CACHE. ([forum:/forumpost/0bfc5888a384d430|Forum post 0bfc5888a384d430]). However, also change to code to issue a deprecation warning whenever SQLITE_USER_AUTHENTICATION is used. FossilOrigin-Name: 249048b0cbc37058c229a785182e07b46029584aff9c385269b0b93503153476 --- ext/userauth/user-auth.txt | 4 ++-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/build.c | 2 +- src/sqliteInt.h | 4 ++++ 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ext/userauth/user-auth.txt b/ext/userauth/user-auth.txt index 66caca3e1e..9d6ba23336 100644 --- a/ext/userauth/user-auth.txt +++ b/ext/userauth/user-auth.txt @@ -4,8 +4,8 @@ * tree. * * * * If you are using this extension and think it should be supported moving * -* forward, visit the SQLite Forum (https://sqlite.org/forum) and make your * -* case. * +* forward, visit the SQLite Forum (https://sqlite.org/forum) and argue your * +* case there. * * * * This deprecation notice was added on 2024-01-22. * ******************************************************************************* diff --git a/manifest b/manifest index ff616768bd..d84135d1bc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snotice\sto\sthe\suser-authentication\sdocumentation\sto\ssay\sthat\sthe\nextension\sis\sdeprecated\sand\smay\sdisappear\sin\sthe\sfuture. -D 2024-01-22T12:30:17.497 +C Fix\suserauth\sso\sthat\sit\sworks\stogether\swith\sSQLITE_OMIT_SHARED_CACHE.\n([forum:/forumpost/0bfc5888a384d430|Forum\spost\s0bfc5888a384d430]).\nHowever,\salso\schange\sto\scode\sto\sissue\sa\sdeprecation\swarning\swhenever\nSQLITE_USER_AUTHENTICATION\sis\sused. +D 2024-01-22T12:56:58.708 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -572,7 +572,7 @@ F ext/session/sqlite3session.c 829d468f0f3d2710aace56b0116a7ca3f414683ce78e3125a F ext/session/sqlite3session.h 4cf19a51975746d7cff2fdd74db8b769c570958e1c3639ac150d824ac1553b3e F ext/session/test_session.c 7b94ad945cd4afe6c73ee935aeb3d44b4446186e1729362af616c7695a5283d9 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 -F ext/userauth/user-auth.txt 9a3bdae6b5d2746056d7611ae1d81fa888772ef716b05d20497cdb4f7992e997 +F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c F ext/wasm/GNUmakefile 867c903a27fa0d53a3bf1b01d8c7bb713456f87e0939c3cac9f07faa68f58734 @@ -680,7 +680,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c dee25e097b749275333b55d64a5ffc079249576f8e88a2ee476468cf67510f4b F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 -F src/build.c e7d9044592eeeea8e78d8ae53ca8d31fd6e92ca0d4f53e2f2e8ccf7352e0b04b +F src/build.c 05c9eb387638982092988d2ef4c00a91b0c29baa1b85923f082ce0cf2903ea7e F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b @@ -743,7 +743,7 @@ F src/shell.c.in 5ea8c6b0057bfe3bcdff31949fe72aa231ae429047c421ea1b168af6825a489 F src/sqlite.h.in 61a60b4ea04db8ead15e1579b20b64cb56e9f55d52c5f9f9694de630110593a3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 73800d73e21180e6b3df8d0fe7d11758dc24367fd2b0b0075b48fc116de406bb +F src/sqliteInt.h 03e64e4a973f56035772421e94be7bf092ceceeb3dc91a74a2147030a822c392 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 488caed24453fcef6fddcf40353e3b44cf37fb9d21e0ed743d39d60cbff020a7 -R ea5433aac763e6ce8bcfabec2e6890c2 +P fe6fc7b91ad1771a2d2d4e3d9d60831b3056d528a700932bf11a336c7e3414a2 +R c9a2f047c14d9ac32442399617ab89a7 U drh -Z 559db82f0095218d6f000421c012f60a +Z 8584c8666b4931dfcdafd4fc01ba8536 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 54eab787fa..86154680d5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe6fc7b91ad1771a2d2d4e3d9d60831b3056d528a700932bf11a336c7e3414a2 \ No newline at end of file +249048b0cbc37058c229a785182e07b46029584aff9c385269b0b93503153476 \ No newline at end of file diff --git a/src/build.c b/src/build.c index a2553da9fd..cfa2c886c5 100644 --- a/src/build.c +++ b/src/build.c @@ -189,7 +189,7 @@ void sqlite3FinishCoding(Parse *pParse){ } sqlite3VdbeAddOp0(v, OP_Halt); -#if SQLITE_USER_AUTHENTICATION +#if SQLITE_USER_AUTHENTICATION && !defined(SQLITE_OMIT_SHARED_CACHE) if( pParse->nTableLock>0 && db->init.busy==0 ){ sqlite3UserAuthInit(db); if( db->auth.authLevel Date: Mon, 22 Jan 2024 14:01:07 +0000 Subject: [PATCH 0035/1030] Fix test script literal.test so that it works with SQLITE_OMIT_ALTER_TABLE builds. FossilOrigin-Name: 4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e --- manifest | 15 ++++++++------- manifest.uuid | 2 +- test/literal.test | 19 ++++++++++++++----- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index d84135d1bc..105fdc6b4b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\suserauth\sso\sthat\sit\sworks\stogether\swith\sSQLITE_OMIT_SHARED_CACHE.\n([forum:/forumpost/0bfc5888a384d430|Forum\spost\s0bfc5888a384d430]).\nHowever,\salso\schange\sto\scode\sto\sissue\sa\sdeprecation\swarning\swhenever\nSQLITE_USER_AUTHENTICATION\sis\sused. -D 2024-01-22T12:56:58.708 +C Fix\stest\sscript\sliteral.test\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_ALTER_TABLE\sbuilds. +D 2024-01-22T14:01:07.189 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1355,7 +1355,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test 12e3c865a9e20f984240dbfb362be2a53ad5ca4ee25a6d429cf059115a9ac48f +F test/literal.test d0a72ab5afe525da7b5f0d2e11df7a369e8021f98de90da4352b8634dba9ccaf F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -2159,8 +2159,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fe6fc7b91ad1771a2d2d4e3d9d60831b3056d528a700932bf11a336c7e3414a2 -R c9a2f047c14d9ac32442399617ab89a7 -U drh -Z 8584c8666b4931dfcdafd4fc01ba8536 +P 249048b0cbc37058c229a785182e07b46029584aff9c385269b0b93503153476 +Q +b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 +R 30b53374dcbd0df72ff4a36d2f8af72e +U dan +Z 80e756b96db0b6ae94203f53b2e0b98b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 86154680d5..cbd31ca380 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -249048b0cbc37058c229a785182e07b46029584aff9c385269b0b93503153476 \ No newline at end of file +4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e \ No newline at end of file diff --git a/test/literal.test b/test/literal.test index 4e957c05db..c617b0642c 100644 --- a/test/literal.test +++ b/test/literal.test @@ -19,12 +19,21 @@ set ::testprefix literal proc test_literal {tn lit type val} { do_execsql_test $tn.1 "SELECT typeof( $lit ), $lit" [list $type $val] - do_execsql_test $tn.2 " + ifcapable altertable { + do_execsql_test $tn.2 " + DROP TABLE IF EXISTS x1; + CREATE TABLE x1(a); + INSERT INTO x1 VALUES(123); + ALTER TABLE x1 ADD COLUMN b DEFAULT $lit ; + SELECT typeof(b), b FROM x1; + " [list $type $val] + } + + do_execsql_test $tn.3 " DROP TABLE IF EXISTS x1; - CREATE TABLE x1(a); - INSERT INTO x1 VALUES(123); - ALTER TABLE x1 ADD COLUMN b DEFAULT $lit ; - SELECT typeof(b), b FROM x1; + CREATE TABLE x1(a DEFAULT $lit); + INSERT INTO x1 DEFAULT VALUES; + SELECT typeof(a), a FROM x1; " [list $type $val] } From 41fb2eed07d109c5bf452d443562ec154dc3b78a Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 22 Jan 2024 14:16:10 +0000 Subject: [PATCH 0036/1030] The -DSQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE compile-time option causes blob inputs to JSON functions that are not JSONB to be processed as if they where text, immulating historical bugging behavior which some applications have come to rely upon. See [forum:/forumpost/012136abd5292b8d|forum thread 012136abd5292b8d] for discussion. FossilOrigin-Name: 65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a --- manifest | 15 +++++------ manifest.uuid | 2 +- src/json.c | 73 +++++++++++++++++++++++++++++++++++---------------- 3 files changed, 59 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index 105fdc6b4b..ddd60a6df8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stest\sscript\sliteral.test\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_ALTER_TABLE\sbuilds. -D 2024-01-22T14:01:07.189 +C The\s-DSQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE\scompile-time\soption\scauses\sblob\ninputs\sto\sJSON\sfunctions\sthat\sare\snot\sJSONB\sto\sbe\sprocessed\sas\sif\sthey\nwhere\stext,\simmulating\shistorical\sbugging\sbehavior\swhich\ssome\sapplications\nhave\scome\sto\srely\supon.\s\sSee\n[forum:/forumpost/012136abd5292b8d|forum\sthread\s012136abd5292b8d]\sfor\ndiscussion. +D 2024-01-22T14:16:10.354 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 5405e50cf0d7aeae12ac5b46e0fc9b3757b3b9cb4885f1a73ec7afeac99b9759 +F src/json.c 99f2825b44327811bdf47808e57077388b83bcc6a253c1269d13fd1b3237138d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2159,9 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 249048b0cbc37058c229a785182e07b46029584aff9c385269b0b93503153476 -Q +b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 -R 30b53374dcbd0df72ff4a36d2f8af72e -U dan -Z 80e756b96db0b6ae94203f53b2e0b98b +P 4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e +R 59af26cba445671768ccc033868954ad +U drh +Z 9f8b0dd9fdc4264b889c936f6659e28d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cbd31ca380..25bb88a0e7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e \ No newline at end of file +65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a \ No newline at end of file diff --git a/src/json.c b/src/json.c index d33692466b..b9a88822e0 100644 --- a/src/json.c +++ b/src/json.c @@ -3217,6 +3217,38 @@ static void jsonInsertIntoBlob( return; } +/* +** If pArg is a blob that seems like a JSONB blob, then initialize +** p to point to that JSONB and return TRUE. If pArg does not seem like +** a JSONB blob, then return FALSE; +** +** This routine is only called if it is already known that pArg is a +** blob. The only open question is whether or not the blob appears +** to be a JSONB blob. +*/ +static int jsonArgIsJsonb(sqlite3_value *pArg, JsonParse *p){ + u32 n, sz = 0; + p->aBlob = (u8*)sqlite3_value_blob(pArg); + p->nBlob = (u32)sqlite3_value_bytes(pArg); + if( p->nBlob==0 ){ + p->aBlob = 0; + return 0; + } + if( NEVER(p->aBlob==0) ){ + return 0; + } + if( (p->aBlob[0] & 0x0f)<=JSONB_OBJECT + && (n = jsonbPayloadSize(p, 0, &sz))>0 + && sz+n==p->nBlob + && ((p->aBlob[0] & 0x0f)>JSONB_FALSE || sz==0) + ){ + return 1; + } + p->aBlob = 0; + p->nBlob = 0; + return 0; +} + /* ** Generate a JsonParse object, containing valid JSONB in aBlob and nBlob, ** from the SQL function argument pArg. Return a pointer to the new @@ -3273,29 +3305,26 @@ static JsonParse *jsonParseFuncArg( return p; } if( eType==SQLITE_BLOB ){ - u32 n, sz = 0; - p->aBlob = (u8*)sqlite3_value_blob(pArg); - p->nBlob = (u32)sqlite3_value_bytes(pArg); - if( p->nBlob==0 ){ - goto json_pfa_malformed; - } - if( NEVER(p->aBlob==0) ){ - goto json_pfa_oom; - } - if( (p->aBlob[0] & 0x0f)>JSONB_OBJECT ){ - goto json_pfa_malformed; - } - n = jsonbPayloadSize(p, 0, &sz); - if( n==0 - || sz+n!=p->nBlob - || ((p->aBlob[0] & 0x0f)<=JSONB_FALSE && sz>0) - ){ - goto json_pfa_malformed; - } - if( (flgs & JSON_EDITABLE)!=0 && jsonBlobMakeEditable(p, 0)==0 ){ - goto json_pfa_oom; + if( jsonArgIsJsonb(pArg,p) ){ + if( (flgs & JSON_EDITABLE)!=0 && jsonBlobMakeEditable(p, 0)==0 ){ + goto json_pfa_oom; + } + return p; } - return p; +#if defined(SQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE) + /* If the input is a BLOB that is not JSONB, fall through into trying + ** to process that BLOB as if it where text. This goes against all + ** historical documentation about how the SQLite JSON functions are + ** suppose to work. Nevertheless, many SQLite implementations prior to + ** version 3.45.0 contained a bug such that they did behave this way + ** and some applications came to depend upon this buggy behavior. The + ** SQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE compile-time option provides + ** a mechanism for those applications to continue working even after + ** the bug was fixed. See + ** https://sqlite.org/forum/forumpost/012136abd5292b8d */ +#else + goto json_pfa_malformed; +#endif } p->zJson = (char*)sqlite3_value_text(pArg); p->nJson = sqlite3_value_bytes(pArg); From a67d63b4816979b5bd8c123d0d2e332047502e06 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 22 Jan 2024 15:26:33 +0000 Subject: [PATCH 0037/1030] Improved error message when a double-quoted string is used and it seems likely that the user wanted a single-quoted string literal. FossilOrigin-Name: 0a834bd81122b6e9c34c8253f9e45d53dab3274be28df60968366fa42237617b --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/resolve.c | 13 ++++++++----- test/quote.test | 10 +++++----- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index ddd60a6df8..7a89979994 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\s-DSQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE\scompile-time\soption\scauses\sblob\ninputs\sto\sJSON\sfunctions\sthat\sare\snot\sJSONB\sto\sbe\sprocessed\sas\sif\sthey\nwhere\stext,\simmulating\shistorical\sbugging\sbehavior\swhich\ssome\sapplications\nhave\scome\sto\srely\supon.\s\sSee\n[forum:/forumpost/012136abd5292b8d|forum\sthread\s012136abd5292b8d]\sfor\ndiscussion. -D 2024-01-22T14:16:10.354 +C Improved\serror\smessage\swhen\sa\sdouble-quoted\sstring\sis\sused\sand\sit\sseems\slikely\nthat\sthe\suser\swanted\sa\ssingle-quoted\sstring\sliteral. +D 2024-01-22T15:26:33.828 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -736,7 +736,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c e25f51a473a5f30a0d978e4df2aaa98aeec84eac29ecae1ad4708a6c3e669345 +F src/resolve.c 6221ea6fa0f4767b051bae74a2c967c4ca411fc46512a7f6f1ec97555114ea6b F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da F src/shell.c.in 5ea8c6b0057bfe3bcdff31949fe72aa231ae429047c421ea1b168af6825a4890 @@ -1497,7 +1497,7 @@ F test/quickcheck.test a4b7e878cd97e46108291c409b0bf8214f29e18fddd68a42bc5c1375a F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26 F test/quota.test bfb269ce81ea52f593f9648316cd5013d766dd2a F test/quota2.test 7dc12e08b11cbc4c16c9ba2aa2e040ea8d8ab4b8 -F test/quote.test ffb40f0eb7a25c1d8cfe11ee2fe67f8e85fbf3fed348810834114be1fdada142 +F test/quote.test 7b01b2a261bc26d9821aea9f4941ce1e08191d62fc55ba8862440fb3a59197a4 F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 @@ -2159,8 +2159,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e -R 59af26cba445671768ccc033868954ad +P 65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a +R 7e3b76756c0a4c8c51526beb20e2ad21 +T *branch * improved-dqs-error-msg +T *sym-improved-dqs-error-msg * +T -sym-trunk * U drh -Z 9f8b0dd9fdc4264b889c936f6659e28d +Z eea53958dbf5ca2fad33a06e593a1f98 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 25bb88a0e7..5936974ca1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a \ No newline at end of file +0a834bd81122b6e9c34c8253f9e45d53dab3274be28df60968366fa42237617b \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index b4f03fe7e6..fde5506f9c 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -277,7 +277,7 @@ static int lookupName( Parse *pParse, /* The parsing context */ const char *zDb, /* Name of the database containing table, or NULL */ const char *zTab, /* Name of table containing column, or NULL */ - const char *zCol, /* Name of the column. */ + const Expr *pRight, /* Name of the column. */ NameContext *pNC, /* The name context used to resolve the name */ Expr *pExpr /* Make this EXPR node point to the selected column */ ){ @@ -294,6 +294,7 @@ static int lookupName( Table *pTab = 0; /* Table holding the row */ Column *pCol; /* A column of pTab */ ExprList *pFJMatch = 0; /* Matches for FULL JOIN .. USING */ + const char *zCol = pRight->u.zToken; assert( pNC ); /* the name context cannot be NULL. */ assert( zCol ); /* The Z in X.Y.Z cannot be NULL */ @@ -753,6 +754,10 @@ static int lookupName( sqlite3ErrorMsg(pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol); }else if( zTab ){ sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol); + }else if( cnt==0 && ExprHasProperty(pRight,EP_DblQuoted) ){ + sqlite3ErrorMsg(pParse, "no such column: \"%s\" - should this be a" + " string literal in single-quotes?", + zCol); }else{ sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol); } @@ -1000,7 +1005,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ */ case TK_ID: case TK_DOT: { - const char *zColumn; const char *zTable; const char *zDb; Expr *pRight; @@ -1009,7 +1013,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ zDb = 0; zTable = 0; assert( !ExprHasProperty(pExpr, EP_IntValue) ); - zColumn = pExpr->u.zToken; + pRight = pExpr; }else{ Expr *pLeft = pExpr->pLeft; testcase( pNC->ncFlags & NC_IdxExpr ); @@ -1028,14 +1032,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ } assert( ExprUseUToken(pLeft) && ExprUseUToken(pRight) ); zTable = pLeft->u.zToken; - zColumn = pRight->u.zToken; assert( ExprUseYTab(pExpr) ); if( IN_RENAME_OBJECT ){ sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight); sqlite3RenameTokenRemap(pParse, (void*)&pExpr->y.pTab, (void*)pLeft); } } - return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr); + return lookupName(pParse, zDb, zTable, pRight, pNC, pExpr); } /* Resolve function names diff --git a/test/quote.test b/test/quote.test index 6d7b317ea1..4e40a9e57f 100644 --- a/test/quote.test +++ b/test/quote.test @@ -103,7 +103,7 @@ foreach {tn sql errname} { 3 { CREATE INDEX i3 ON t1("w") } w 4 { CREATE INDEX i4 ON t1(x) WHERE z="w" } w } { - do_catchsql_test 2.1.$tn $sql [list 1 "no such column: $errname"] + do_catchsql_test 2.1.$tn $sql [list 1 "no such column: \"$errname\" - should this be a string literal in single-quotes?"] } do_execsql_test 2.2 { @@ -147,19 +147,19 @@ ifcapable altertable { CREATE TABLE t1(a,b); CREATE INDEX x1 on t1("b"); ALTER TABLE t1 DROP COLUMN b; - } {1 {error in index x1 after drop column: no such column: b}} + } {1 {error in index x1 after drop column: no such column: "b" - should this be a string literal in single-quotes?}} do_catchsql_test 3.1 { DROP TABLE t1; CREATE TABLE t1(a,"b"); CREATE INDEX x1 on t1("b"); ALTER TABLE t1 DROP COLUMN b; - } {1 {error in index x1 after drop column: no such column: b}} + } {1 {error in index x1 after drop column: no such column: "b" - should this be a string literal in single-quotes?}} do_catchsql_test 3.2 { DROP TABLE t1; CREATE TABLE t1(a,'b'); CREATE INDEX x1 on t1("b"); ALTER TABLE t1 DROP COLUMN b; - } {1 {error in index x1 after drop column: no such column: b}} + } {1 {error in index x1 after drop column: no such column: "b" - should this be a string literal in single-quotes?}} do_catchsql_test 3.3 { DROP TABLE t1; CREATE TABLE t1(a,"b"); @@ -172,7 +172,7 @@ ifcapable altertable { CREATE INDEX x1 ON t1("a"||"b"); INSERT INTO t1 VALUES(1,2,3),(1,4,5); ALTER TABLE t1 DROP COLUMN b; - } {1 {error in index x1 after drop column: no such column: b}} + } {1 {error in index x1 after drop column: no such column: "b" - should this be a string literal in single-quotes?}} sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1 do_catchsql_test 3.5 { DROP TABLE t1; From 87ad06ed997a505b60d2ca9c9751c0d0e83cfbd4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 22 Jan 2024 17:18:41 +0000 Subject: [PATCH 0038/1030] Do not allow digit separators that are not surrounded on both sides by digits. FossilOrigin-Name: 5bbc378a3022e2013048c8e296d95de21d15a8d7c1b62e8ffb64782f952cfe12 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tokenize.c | 20 ++++++++++++++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index d5565a35b7..b43db80a8c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stest\sscript\sliteral.test\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_ALTER_TABLE\sbuilds. -D 2024-01-22T11:12:38.218 +C Do\snot\sallow\sdigit\sseparators\sthat\sare\snot\ssurrounded\son\sboth\ssides\sby\sdigits. +D 2024-01-22T17:18:41.963 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -800,7 +800,7 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c e0cdd971ebf7225cd617661d8198fc90a49559e21210af03bdf440e2fcba6b88 +F src/tokenize.c 1664cd0d9224bf63e7471d892074f580933c0e85a3b77f98e016dce2d5fed4a5 F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 @@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 03ade4a810516ff84bc5c1a716b0e454cc8a89374100415ff21a82449112811b -R 4dc96dbb63712d691b87fb65e2e995c9 -U dan -Z 060bde75456debf514e23a793c3f90b5 +P b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 +R dc78fe3596a95d4e421310d3dc095c60 +U drh +Z 8ae254187429ecb3341b495c0d5f92df # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 902662ca4b..40427080bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 \ No newline at end of file +5bbc378a3022e2013048c8e296d95de21d15a8d7c1b62e8ffb64782f952cfe12 \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index 592d6b8d8d..37254da70d 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -443,8 +443,14 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ #endif for(i=0; 1; i++){ if( sqlite3Isdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; } - else{ break; } + if( z[i]==SQLITE_DIGIT_SEPARATOR + && sqlite3Isdigit(z[i-1]) + && sqlite3Isdigit(z[i+1]) + ){ + *tokenType = TK_QNUMBER; + }else{ + break; + } } } #ifndef SQLITE_OMIT_FLOATING_POINT @@ -452,8 +458,14 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; for(i++; 1; i++){ if( sqlite3Isdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; } - else{ break; } + if( z[i]==SQLITE_DIGIT_SEPARATOR + && sqlite3Isdigit(z[i-1]) + && sqlite3Isdigit(z[i+1]) + ){ + *tokenType = TK_QNUMBER; + }else{ + break; + } } } } From fbb72fae8ff79bdc1308f70c64a8093c9d605ce8 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 22 Jan 2024 19:00:50 +0000 Subject: [PATCH 0039/1030] Add extra tests for the code on this branch. FossilOrigin-Name: b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c --- manifest | 18 +++++++++-------- manifest.uuid | 2 +- src/tokenize.c | 10 ++++++++-- test/literal.test | 28 ++++++++++++++++++++++++++- test/literal2.tcl | 27 ++++++++++++++++++++++++++ test/literal2.test | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 test/literal2.tcl create mode 100644 test/literal2.test diff --git a/manifest b/manifest index b43db80a8c..c1b974d23a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sallow\sdigit\sseparators\sthat\sare\snot\ssurrounded\son\sboth\ssides\sby\sdigits. -D 2024-01-22T17:18:41.963 +C Add\sextra\stests\sfor\sthe\scode\son\sthis\sbranch. +D 2024-01-22T19:00:50.821 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -800,7 +800,7 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c 1664cd0d9224bf63e7471d892074f580933c0e85a3b77f98e016dce2d5fed4a5 +F src/tokenize.c f283d8017b57d8be74218f6a820fb72f72ee7e05267083b4ac3b1ed456e0a290 F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 @@ -1355,7 +1355,9 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test db71a7616dc027badf8d8f7ac6e23e8655915eb51b187c40a0a6e667aed495b7 +F test/literal.test e3d65d4091126cb008f31f57a324364511a83dd9461df31f60b5df6bd1f1f846 +F test/literal2.tcl 10713fed76885d43ada4161c0edf18fdc06e4405094e7baad888c6a1a29141b9 +F test/literal2.test 2e3ad4bc8cb019169d4f43400658fdc35acdcde7f79322c952b61ca07ac27ba6 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -2159,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 -R dc78fe3596a95d4e421310d3dc095c60 -U drh -Z 8ae254187429ecb3341b495c0d5f92df +P 5bbc378a3022e2013048c8e296d95de21d15a8d7c1b62e8ffb64782f952cfe12 +R 5ae47ec02f1c44e5b63d2c7bab26a43e +U dan +Z 067422c390415b433adad2a7d339896e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 40427080bf..0b49600412 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5bbc378a3022e2013048c8e296d95de21d15a8d7c1b62e8ffb64782f952cfe12 \ No newline at end of file +b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index 37254da70d..7a30512ec6 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -477,8 +477,14 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; for(i+=2; 1; i++){ if( sqlite3Isdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; } - else{ break; } + if( z[i]==SQLITE_DIGIT_SEPARATOR + && sqlite3Isdigit(z[i-1]) + && sqlite3Isdigit(z[i+1]) + ){ + *tokenType = TK_QNUMBER; + }else{ + break; + } } } } diff --git a/test/literal.test b/test/literal.test index 3140eedf2a..fe6b70acf7 100644 --- a/test/literal.test +++ b/test/literal.test @@ -37,6 +37,10 @@ proc test_literal {tn lit type val} { " [list $type $val] } +proc test_literal_error {tn lit unrec} { + do_catchsql_test $tn "SELECT $lit" "1 {unrecognized token: \"$unrec\"}" +} + test_literal 1.0 45 integer 45 test_literal 1.1 0xFF integer 255 @@ -62,9 +66,31 @@ test_literal 3.1 1_000 integer 1000 test_literal 3.2 1.1_1 real 1.11 test_literal 3.3 1_0.1_1 real 10.11 test_literal 3.4 1e1_000 real Inf -test_literal 3.5 123______456.7_8__9_ real 123456.789 +test_literal 3.5 12_3_456.7_8_9 real 123456.789 test_literal 3.6 9_223_372_036_854_775_807 integer 9223372036854775807 test_literal 3.7 9_223_372_036_854_775_808 real 9.22337203685478e+18 test_literal 3.8 -9_223_372_036_854_775_808 integer -9223372036854775808 +foreach {tn lit unrec} { + 0 123a456 123a456 + 1 1_ 1_ + 2 1_.4 1_ + 3 1e_4 1e_4 + 4 1_e4 1_e4 + 5 1.4_e4 1.4_e4 + 6 1.4e+_4 1.4e + 7 1.4e-_4 1.4e + 8 1.4e4_ 1.4e4_ + 9 1.4_e4 1.4_e4 + 10 1.4e_4 1.4e_4 + 11 12__34 12__34 + 12 1234_ 1234_ + 13 12._34 12._34 + 14 12_.34 12_ + 15 12.34_ 12.34_ + 16 1.0e1_______2 1.0e1_______2 +} { + test_literal_error 4.$tn $lit $unrec +} + finish_test diff --git a/test/literal2.tcl b/test/literal2.tcl new file mode 100644 index 0000000000..2c97150b0c --- /dev/null +++ b/test/literal2.tcl @@ -0,0 +1,27 @@ +# 2018 May 19 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +source [file join [file dirname $argv0] pg_common.tcl] + +#========================================================================= + + +start_test literal2 "2024 Jan 23" + +execsql_test 1.0 { SELECT 123_456 } +errorsql_test 1.1 { SELECT 123__456 } + +execsql_float_test 2.1 { SELECT 1.0e1_2 } + +finish_test + + diff --git a/test/literal2.test b/test/literal2.test new file mode 100644 index 0000000000..743df44eb7 --- /dev/null +++ b/test/literal2.test @@ -0,0 +1,48 @@ +# 2024 Jan 23 +# +# 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. +# + +#################################################### +# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED! +#################################################### + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix literal2 + +do_execsql_test 1.0 { + SELECT 123_456 +} {123456} + +# PG says ERROR: trailing junk after numeric literal at or near "123_" +do_test 1.1 { catch { execsql { + SELECT 123__456 +} } } 1 + + +do_test 2.1 { + set myres {} + foreach r [db eval {SELECT 1.0e1_2}] { + lappend myres [format %.4f [set r]] + } + set res2 {1000000000000.0000} + set i 0 + foreach r [set myres] r2 [set res2] { + if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} { + error "list element [set i] does not match: got=[set r] expected=[set r2]" + } + incr i + } + set {} {} +} {} + +finish_test From 8374f7dfaf1106f01205e874b8b7e86a14f9d6cf Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 22 Jan 2024 19:38:55 +0000 Subject: [PATCH 0040/1030] Allow underscores to occur in hex literals. FossilOrigin-Name: 81a56229460cc5b6acfd3c3729fcf89ea3cccb546ca2b4f4035b140c60911e18 --- manifest | 20 ++++++------ manifest.uuid | 2 +- src/tokenize.c | 76 +++++++++++++++++++++++++++------------------- src/util.c | 10 +++--- test/literal2.tcl | 8 +++++ test/literal2.test | 18 +++++++++++ test/misc1.test | 2 +- 7 files changed, 88 insertions(+), 48 deletions(-) diff --git a/manifest b/manifest index c1b974d23a..77f3ca0ff6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\stests\sfor\sthe\scode\son\sthis\sbranch. -D 2024-01-22T19:00:50.821 +C Allow\sunderscores\sto\soccur\sin\shex\sliterals. +D 2024-01-22T19:38:55.172 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -800,13 +800,13 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c f283d8017b57d8be74218f6a820fb72f72ee7e05267083b4ac3b1ed456e0a290 +F src/tokenize.c 3ea60fcd98a0eb1391592a080fb8871b0026eaffbdb5795ef3b19bb7d48e702a F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c 2b274b03f0d4fd1bf253f160d6b399bc5265338b043c078045c5e32298891ec8 +F src/util.c 25e0b776d5bb326d6009fbd8705c5ab332318b0f1c213dab4a717524defb9a7d F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c 92910d536e0b77505599cd6ae5d9d449e4a5d31ada61da4c0bb84f6ccb2c3189 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb @@ -1356,8 +1356,8 @@ F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de9874 F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e F test/literal.test e3d65d4091126cb008f31f57a324364511a83dd9461df31f60b5df6bd1f1f846 -F test/literal2.tcl 10713fed76885d43ada4161c0edf18fdc06e4405094e7baad888c6a1a29141b9 -F test/literal2.test 2e3ad4bc8cb019169d4f43400658fdc35acdcde7f79322c952b61ca07ac27ba6 +F test/literal2.tcl 70cf73b43f09396a4ba3ba7462b107a32866bb77deaa991c3296aa978edcdfdd +F test/literal2.test dd6b763feb086fa34b4229c527b35099020e7f5d588089fff9e4434c71695f60 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -1410,7 +1410,7 @@ F test/minmax.test fe638b55d77d2375531a8f549b338eafcd9adfbd2f72df37ed77d9b26ca0a F test/minmax2.test cf9311babb6f0518d04e42fd6a42c619531c4309a9dd790a2c4e9b3bc595e0de F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 272ca395257f05937dc96441c9dde4bc9fbf116a8d4fa02baeb0d13d50e36c87 -F test/misc1.test 8d138a4926ab90617c1aa29ce26e7785ae2b83a4d3a195d543b7374e05589dd1 +F test/misc1.test e3e36262aff1bd9b8b9bf1eeb3af04adb3fc1e23f0a92dbff708bba9e939ace1 F test/misc2.test 71e746af479119386ac2ed7ab7d81d99970e75b49ffd3e8efffee100b4b5f350 F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5bbc378a3022e2013048c8e296d95de21d15a8d7c1b62e8ffb64782f952cfe12 -R 5ae47ec02f1c44e5b63d2c7bab26a43e +P b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c +R d0d892d569c1b9650e2494b0fb9379db U dan -Z 067422c390415b433adad2a7d339896e +Z 87a049db1576d41d80b78f3d72e95d0a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0b49600412..bec89eba1b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c \ No newline at end of file +81a56229460cc5b6acfd3c3729fcf89ea3cccb546ca2b4f4035b140c60911e18 \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index 7a30512ec6..f01548d4cb 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -437,30 +437,11 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ *tokenType = TK_INTEGER; #ifndef SQLITE_OMIT_HEX_INTEGER if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){ - for(i=3; sqlite3Isxdigit(z[i]); i++){} - return i; - } -#endif - for(i=0; 1; i++){ - if( sqlite3Isdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR - && sqlite3Isdigit(z[i-1]) - && sqlite3Isdigit(z[i+1]) - ){ - *tokenType = TK_QNUMBER; - }else{ - break; - } - } - } -#ifndef SQLITE_OMIT_FLOATING_POINT - if( z[i]=='.' ){ - if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; - for(i++; 1; i++){ - if( sqlite3Isdigit(z[i])==0 ){ + for(i=3; 1; i++){ + if( sqlite3Isxdigit(z[i])==0 ){ if( z[i]==SQLITE_DIGIT_SEPARATOR - && sqlite3Isdigit(z[i-1]) - && sqlite3Isdigit(z[i+1]) + && sqlite3Isxdigit(z[i-1]) + && sqlite3Isxdigit(z[i+1]) ){ *tokenType = TK_QNUMBER; }else{ @@ -468,14 +449,10 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ } } } - } - if( (z[i]=='e' || z[i]=='E') && - ( sqlite3Isdigit(z[i+1]) - || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2])) - ) - ){ - if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; - for(i+=2; 1; i++){ + }else +#endif + { + for(i=0; 1; i++){ if( sqlite3Isdigit(z[i])==0 ){ if( z[i]==SQLITE_DIGIT_SEPARATOR && sqlite3Isdigit(z[i-1]) @@ -487,8 +464,43 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ } } } - } +#ifndef SQLITE_OMIT_FLOATING_POINT + if( z[i]=='.' ){ + if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; + for(i++; 1; i++){ + if( sqlite3Isdigit(z[i])==0 ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR + && sqlite3Isdigit(z[i-1]) + && sqlite3Isdigit(z[i+1]) + ){ + *tokenType = TK_QNUMBER; + }else{ + break; + } + } + } + } + if( (z[i]=='e' || z[i]=='E') && + ( sqlite3Isdigit(z[i+1]) + || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2])) + ) + ){ + if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; + for(i+=2; 1; i++){ + if( sqlite3Isdigit(z[i])==0 ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR + && sqlite3Isdigit(z[i-1]) + && sqlite3Isdigit(z[i+1]) + ){ + *tokenType = TK_QNUMBER; + }else{ + break; + } + } + } + } #endif + } while( IdChar(z[i]) ){ *tokenType = TK_ILLEGAL; i++; diff --git a/src/util.c b/src/util.c index 24eff14e9f..9a2ea9e901 100644 --- a/src/util.c +++ b/src/util.c @@ -312,10 +312,9 @@ void sqlite3DequoteExpr(Expr *p){ } /* -** Expression p is a QINTEGER or QFLOAT (quoted integer or float). Dequote -** the value in p->u.zToken and set the type to INTEGER or FLOAT. "Quoted" -** integers or floats are those that contain '_' characters that must -** be removed before further processing. +** Expression p is a QNUMBER (quoted number). Dequote the value in p->u.zToken +** and set the type to INTEGER or FLOAT. "Quoted" integers or floats are those +** that contain '_' characters that must be removed before further processing. */ void sqlite3DequoteNumber(Expr *p){ if( p ){ @@ -329,6 +328,9 @@ void sqlite3DequoteNumber(Expr *p){ if( *pIn=='e' || *pIn=='E' || *pIn=='.' ) p->op = TK_FLOAT; } }while( *pIn++ ); + if( p->u.zToken[0]=='0' && p->u.zToken[1]=='x' ){ + p->op = TK_INTEGER; + } } } diff --git a/test/literal2.tcl b/test/literal2.tcl index 2c97150b0c..029d33f51a 100644 --- a/test/literal2.tcl +++ b/test/literal2.tcl @@ -22,6 +22,14 @@ errorsql_test 1.1 { SELECT 123__456 } execsql_float_test 2.1 { SELECT 1.0e1_2 } + +execsql_test 3.0 { SELECT 0xFF_FF } +execsql_test 3.1 { SELECT 0xFF_EF } + +errorsql_test 3.2 { SELECT 0xFF__EF } +# errorsql_test 3.3 { SELECT 0x_FFEF } +errorsql_test 3.4 { SELECT 0xFFEF_ } + finish_test diff --git a/test/literal2.test b/test/literal2.test index 743df44eb7..eda526fcef 100644 --- a/test/literal2.test +++ b/test/literal2.test @@ -45,4 +45,22 @@ do_test 2.1 { set {} {} } {} +do_execsql_test 3.0 { + SELECT 0xFF_FF +} {65535} + +do_execsql_test 3.1 { + SELECT 0xFF_EF +} {65519} + +# PG says ERROR: trailing junk after numeric literal at or near "0xFF_" +do_test 3.2 { catch { execsql { + SELECT 0xFF__EF +} } } 1 + +# PG says ERROR: trailing junk after numeric literal at or near "0xFFEF_" +do_test 3.4 { catch { execsql { + SELECT 0xFFEF_ +} } } 1 + finish_test diff --git a/test/misc1.test b/test/misc1.test index 83acc752af..8110d38678 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -654,7 +654,7 @@ do_catchsql_test misc1-21.1 { } {1 {near "#0": syntax error}} do_catchsql_test misc1-21.2 { VALUES(0,0x0MATCH#0; -} {1 {near ";": syntax error}} +} {1 {unrecognized token: "0x0MATCH"}} # 2015-04-15 do_execsql_test misc1-22.1 { From a545de6827e9839da413f52e800f8184eedc6060 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 22 Jan 2024 19:42:56 +0000 Subject: [PATCH 0041/1030] Fix a problem in the previous commit with hex literals that start with "0X" instead of "0x". FossilOrigin-Name: c063c89b11487e6e712b97de604db316fa97bcf91ed810bb2dcbbcb54c68dbf4 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/util.c | 2 +- test/literal2.tcl | 17 +++++++++++------ test/literal2.test | 26 ++++++++++++++++++++++---- 5 files changed, 43 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 77f3ca0ff6..f48cebcf73 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sunderscores\sto\soccur\sin\shex\sliterals. -D 2024-01-22T19:38:55.172 +C Fix\sa\sproblem\sin\sthe\sprevious\scommit\swith\shex\sliterals\sthat\sstart\swith\s"0X"\sinstead\sof\s"0x". +D 2024-01-22T19:42:56.220 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -806,7 +806,7 @@ F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c 25e0b776d5bb326d6009fbd8705c5ab332318b0f1c213dab4a717524defb9a7d +F src/util.c ef37d377684d6f725773c15bfc1ef5b75483b4f3b6b6198d4b8b969831623be0 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c 92910d536e0b77505599cd6ae5d9d449e4a5d31ada61da4c0bb84f6ccb2c3189 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb @@ -1356,8 +1356,8 @@ F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de9874 F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e F test/literal.test e3d65d4091126cb008f31f57a324364511a83dd9461df31f60b5df6bd1f1f846 -F test/literal2.tcl 70cf73b43f09396a4ba3ba7462b107a32866bb77deaa991c3296aa978edcdfdd -F test/literal2.test dd6b763feb086fa34b4229c527b35099020e7f5d588089fff9e4434c71695f60 +F test/literal2.tcl 1499037beaf661aeecdbe48801220a181d805372a64c6128d5f26bb6a4a8f0ce +F test/literal2.test b149e16b5fc9ee6249069a8858ed41052f222014fe0ba7ad43c2fb989c2dada2 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c -R d0d892d569c1b9650e2494b0fb9379db +P 81a56229460cc5b6acfd3c3729fcf89ea3cccb546ca2b4f4035b140c60911e18 +R 8fee7748a406cec8844b4286c6b28b8f U dan -Z 87a049db1576d41d80b78f3d72e95d0a +Z 6bae334234c9987a328b3a9421e4a531 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bec89eba1b..de37a7858c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -81a56229460cc5b6acfd3c3729fcf89ea3cccb546ca2b4f4035b140c60911e18 \ No newline at end of file +c063c89b11487e6e712b97de604db316fa97bcf91ed810bb2dcbbcb54c68dbf4 \ No newline at end of file diff --git a/src/util.c b/src/util.c index 9a2ea9e901..ed7789591b 100644 --- a/src/util.c +++ b/src/util.c @@ -328,7 +328,7 @@ void sqlite3DequoteNumber(Expr *p){ if( *pIn=='e' || *pIn=='E' || *pIn=='.' ) p->op = TK_FLOAT; } }while( *pIn++ ); - if( p->u.zToken[0]=='0' && p->u.zToken[1]=='x' ){ + if( p->u.zToken[0]=='0' && (p->u.zToken[1]=='x' || p->u.zToken[1]=='X') ){ p->op = TK_INTEGER; } } diff --git a/test/literal2.tcl b/test/literal2.tcl index 029d33f51a..e14a03587b 100644 --- a/test/literal2.tcl +++ b/test/literal2.tcl @@ -23,12 +23,17 @@ errorsql_test 1.1 { SELECT 123__456 } execsql_float_test 2.1 { SELECT 1.0e1_2 } -execsql_test 3.0 { SELECT 0xFF_FF } -execsql_test 3.1 { SELECT 0xFF_EF } - -errorsql_test 3.2 { SELECT 0xFF__EF } -# errorsql_test 3.3 { SELECT 0x_FFEF } -errorsql_test 3.4 { SELECT 0xFFEF_ } +execsql_test 3.0.0 { SELECT 0xFF_FF } +execsql_test 3.0.1 { SELECT 0xFF_EF } +errorsql_test 3.0.2 { SELECT 0xFF__EF } +# errorsql_test 3.0.3 { SELECT 0x_FFEF } +errorsql_test 3.0.4 { SELECT 0xFFEF_ } + +execsql_test 3.1.0 { SELECT 0XFF_FF } +execsql_test 3.1.1 { SELECT 0XFF_EF } +errorsql_test 3.1.2 { SELECT 0XFF__EF } +# errorsql_test 3.1.3 { SELECT 0X_FFEF } +errorsql_test 3.1.4 { SELECT 0XFFEF_ } finish_test diff --git a/test/literal2.test b/test/literal2.test index eda526fcef..ed177ca261 100644 --- a/test/literal2.test +++ b/test/literal2.test @@ -45,22 +45,40 @@ do_test 2.1 { set {} {} } {} -do_execsql_test 3.0 { +do_execsql_test 3.0.0 { SELECT 0xFF_FF } {65535} -do_execsql_test 3.1 { +do_execsql_test 3.0.1 { SELECT 0xFF_EF } {65519} # PG says ERROR: trailing junk after numeric literal at or near "0xFF_" -do_test 3.2 { catch { execsql { +do_test 3.0.2 { catch { execsql { SELECT 0xFF__EF } } } 1 # PG says ERROR: trailing junk after numeric literal at or near "0xFFEF_" -do_test 3.4 { catch { execsql { +do_test 3.0.4 { catch { execsql { SELECT 0xFFEF_ } } } 1 +do_execsql_test 3.1.0 { + SELECT 0XFF_FF +} {65535} + +do_execsql_test 3.1.1 { + SELECT 0XFF_EF +} {65519} + +# PG says ERROR: trailing junk after numeric literal at or near "0XFF_" +do_test 3.1.2 { catch { execsql { + SELECT 0XFF__EF +} } } 1 + +# PG says ERROR: trailing junk after numeric literal at or near "0XFFEF_" +do_test 3.1.4 { catch { execsql { + SELECT 0XFFEF_ +} } } 1 + finish_test From 727b35cbfcdaa1009e00f525c9e37bee584e4890 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 22 Jan 2024 20:49:47 +0000 Subject: [PATCH 0042/1030] Simplification of the error reporting logic. FossilOrigin-Name: 59eb9d29e796886db17a578b64e75fd2797aebf969cbeeda70ecf2fda378c98f --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/resolve.c | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 7a89979994..e117fbd0bb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\serror\smessage\swhen\sa\sdouble-quoted\sstring\sis\sused\sand\sit\sseems\slikely\nthat\sthe\suser\swanted\sa\ssingle-quoted\sstring\sliteral. -D 2024-01-22T15:26:33.828 +C Simplification\sof\sthe\serror\sreporting\slogic. +D 2024-01-22T20:49:47.506 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -736,7 +736,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 6221ea6fa0f4767b051bae74a2c967c4ca411fc46512a7f6f1ec97555114ea6b +F src/resolve.c 0ed10ebb70d15dcf3f1882051931ccfaf9c3f4debe67dbd114047d9e2adb9523 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da F src/shell.c.in 5ea8c6b0057bfe3bcdff31949fe72aa231ae429047c421ea1b168af6825a4890 @@ -2159,11 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a -R 7e3b76756c0a4c8c51526beb20e2ad21 -T *branch * improved-dqs-error-msg -T *sym-improved-dqs-error-msg * -T -sym-trunk * +P 0a834bd81122b6e9c34c8253f9e45d53dab3274be28df60968366fa42237617b +R 55b4daf0d623afe21abf6d430f07654f U drh -Z eea53958dbf5ca2fad33a06e593a1f98 +Z 28de270bfc8a17f68f447b4061913785 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5936974ca1..f001d964d3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a834bd81122b6e9c34c8253f9e45d53dab3274be28df60968366fa42237617b \ No newline at end of file +59eb9d29e796886db17a578b64e75fd2797aebf969cbeeda70ecf2fda378c98f \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index fde5506f9c..29975f385a 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -755,9 +755,9 @@ static int lookupName( }else if( zTab ){ sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol); }else if( cnt==0 && ExprHasProperty(pRight,EP_DblQuoted) ){ - sqlite3ErrorMsg(pParse, "no such column: \"%s\" - should this be a" + sqlite3ErrorMsg(pParse, "%s: \"%s\" - should this be a" " string literal in single-quotes?", - zCol); + zErr, zCol); }else{ sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol); } From 406eb5a146e06c29a5f1d8b8e25c10d125945a20 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 23 Jan 2024 11:20:58 +0000 Subject: [PATCH 0043/1030] Add extra checks for the validity of a numeric literal to sqlite3DequoteNumber(). FossilOrigin-Name: d57407ef59baf699b72c8c4859abfaa7977dd41f6f16eb8fe1d53a68806eb966 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/parse.y | 2 +- src/sqliteInt.h | 2 +- src/tokenize.c | 20 ++++---------------- src/util.c | 13 +++++++++---- test/literal.test | 4 ++-- 7 files changed, 28 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index f48cebcf73..0470957ccf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\sprevious\scommit\swith\shex\sliterals\sthat\sstart\swith\s"0X"\sinstead\sof\s"0x". -D 2024-01-22T19:42:56.220 +C Add\sextra\schecks\sfor\sthe\svalidity\sof\sa\snumeric\sliteral\sto\ssqlite3DequoteNumber(). +D 2024-01-23T11:20:58.812 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -727,7 +727,7 @@ F src/os_win.c 4a50a154aeebc66a1f8fb79c1ff6dd5fe3d005556533361e0d460d41cb6a45a8 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 2354aaf964e7c4154a9dbe56ea55a797a0fa3021c38b50afe491ea4a387bf971 +F src/parse.y d2823ae4a503f83b3e8629c31470686624e46851d576c1f2b7bbec2e7328bb05 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -743,7 +743,7 @@ F src/shell.c.in d1ed426aae2d547932971e8019939cacb4dfda8258e45b8924b250e488e2d53 F src/sqlite.h.in 61a60b4ea04db8ead15e1579b20b64cb56e9f55d52c5f9f9694de630110593a3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 6e5e330d84b4ace70e3163721601f01df84566e6db21e1fc45bd00636e3d6640 +F src/sqliteInt.h a1367a4cd90c90e5eb2e5ca7d1be96823507f63b43030deb394f90f4f8d9ac10 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -800,13 +800,13 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c 3ea60fcd98a0eb1391592a080fb8871b0026eaffbdb5795ef3b19bb7d48e702a +F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c ef37d377684d6f725773c15bfc1ef5b75483b4f3b6b6198d4b8b969831623be0 +F src/util.c 88484a62e2465728288ca6e5b10f30489058e66266f52c70e87663310298793b F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c 92910d536e0b77505599cd6ae5d9d449e4a5d31ada61da4c0bb84f6ccb2c3189 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb @@ -1355,7 +1355,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test e3d65d4091126cb008f31f57a324364511a83dd9461df31f60b5df6bd1f1f846 +F test/literal.test c4f6f281964ac5ab48a32bd978e80644affac822664879d7558762b2fad7aff5 F test/literal2.tcl 1499037beaf661aeecdbe48801220a181d805372a64c6128d5f26bb6a4a8f0ce F test/literal2.test b149e16b5fc9ee6249069a8858ed41052f222014fe0ba7ad43c2fb989c2dada2 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 81a56229460cc5b6acfd3c3729fcf89ea3cccb546ca2b4f4035b140c60911e18 -R 8fee7748a406cec8844b4286c6b28b8f +P c063c89b11487e6e712b97de604db316fa97bcf91ed810bb2dcbbcb54c68dbf4 +R 92b3c6e9a0a36e247ccad3d6a5b99b6c U dan -Z 6bae334234c9987a328b3a9421e4a531 +Z 62284248efaccf35cb9923c551aa2ba1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index de37a7858c..66162263f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c063c89b11487e6e712b97de604db316fa97bcf91ed810bb2dcbbcb54c68dbf4 \ No newline at end of file +d57407ef59baf699b72c8c4859abfaa7977dd41f6f16eb8fe1d53a68806eb966 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index b0d03a04ee..c26a9bccc2 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1926,7 +1926,7 @@ filter_clause(A) ::= FILTER LP WHERE expr(X) RP. { A = X; } term(A) ::= QNUMBER(X). { A=tokenExpr(pParse,@X,X); - sqlite3DequoteNumber(A); + sqlite3DequoteNumber(pParse, A); } /* There must be no more than 255 tokens defined above. If this grammar diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c4aaf9d203..2db491fc81 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4794,7 +4794,7 @@ int sqlite3ErrorToParser(sqlite3*,int); void sqlite3Dequote(char*); void sqlite3DequoteExpr(Expr*); void sqlite3DequoteToken(Token*); -void sqlite3DequoteNumber(Expr*); +void sqlite3DequoteNumber(Parse*, Expr*); void sqlite3TokenInit(Token*,char*); int sqlite3KeywordCode(const unsigned char*, int); int sqlite3RunParser(Parse*, const char*); diff --git a/src/tokenize.c b/src/tokenize.c index f01548d4cb..65d1fbf350 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -439,10 +439,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){ for(i=3; 1; i++){ if( sqlite3Isxdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR - && sqlite3Isxdigit(z[i-1]) - && sqlite3Isxdigit(z[i+1]) - ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; }else{ break; @@ -454,10 +451,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ { for(i=0; 1; i++){ if( sqlite3Isdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR - && sqlite3Isdigit(z[i-1]) - && sqlite3Isdigit(z[i+1]) - ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; }else{ break; @@ -469,10 +463,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; for(i++; 1; i++){ if( sqlite3Isdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR - && sqlite3Isdigit(z[i-1]) - && sqlite3Isdigit(z[i+1]) - ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; }else{ break; @@ -488,10 +479,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; for(i+=2; 1; i++){ if( sqlite3Isdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR - && sqlite3Isdigit(z[i-1]) - && sqlite3Isdigit(z[i+1]) - ){ + if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; }else{ break; diff --git a/src/util.c b/src/util.c index ed7789591b..5a88979fe4 100644 --- a/src/util.c +++ b/src/util.c @@ -316,21 +316,26 @@ void sqlite3DequoteExpr(Expr *p){ ** and set the type to INTEGER or FLOAT. "Quoted" integers or floats are those ** that contain '_' characters that must be removed before further processing. */ -void sqlite3DequoteNumber(Expr *p){ +void sqlite3DequoteNumber(Parse *pParse, Expr *p){ if( p ){ const char *pIn = p->u.zToken; char *pOut = p->u.zToken; + int bHex = (pIn[0]=='0' && (pIn[1]=='x' || pIn[1]=='X')); assert( p->op==TK_QNUMBER ); p->op = TK_INTEGER; do { if( *pIn!=SQLITE_DIGIT_SEPARATOR ){ *pOut++ = *pIn; if( *pIn=='e' || *pIn=='E' || *pIn=='.' ) p->op = TK_FLOAT; + }else{ + if( (bHex==0 && (!sqlite3Isdigit(pIn[-1]) || !sqlite3Isdigit(pIn[1]))) + || (bHex==1 && (!sqlite3Isxdigit(pIn[-1]) || !sqlite3Isxdigit(pIn[1]))) + ){ + sqlite3ErrorMsg(pParse, "unrecognized token: \"%s\"", p->u.zToken); + } } }while( *pIn++ ); - if( p->u.zToken[0]=='0' && (p->u.zToken[1]=='x' || p->u.zToken[1]=='X') ){ - p->op = TK_INTEGER; - } + if( bHex ) p->op = TK_INTEGER; } } diff --git a/test/literal.test b/test/literal.test index fe6b70acf7..30205692c9 100644 --- a/test/literal.test +++ b/test/literal.test @@ -74,7 +74,7 @@ test_literal 3.8 -9_223_372_036_854_775_808 integer -9223372036854775808 foreach {tn lit unrec} { 0 123a456 123a456 1 1_ 1_ - 2 1_.4 1_ + 2 1_.4 1_.4 3 1e_4 1e_4 4 1_e4 1_e4 5 1.4_e4 1.4_e4 @@ -86,7 +86,7 @@ foreach {tn lit unrec} { 11 12__34 12__34 12 1234_ 1234_ 13 12._34 12._34 - 14 12_.34 12_ + 14 12_.34 12_.34 15 12.34_ 12.34_ 16 1.0e1_______2 1.0e1_______2 } { From 91cee17d8334c91cad1919230c1ba61812f86317 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 23 Jan 2024 12:51:17 +0000 Subject: [PATCH 0044/1030] Change the shell's --help flag to exit with code 0 instead of 1, per /forum and /chat discussions. FossilOrigin-Name: df563a18578c5cf1aaecf5818c93967aaa70475598d3c099779622ac8911f926 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/shell.c.in | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 105fdc6b4b..0080b0dd01 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stest\sscript\sliteral.test\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_ALTER_TABLE\sbuilds. -D 2024-01-22T14:01:07.189 +C Change\sthe\sshell's\s--help\sflag\sto\sexit\swith\scode\s0\sinstead\sof\s1,\sper\s/forum\sand\s/chat\sdiscussions. +D 2024-01-23T12:51:17.111 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -739,7 +739,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c e25f51a473a5f30a0d978e4df2aaa98aeec84eac29ecae1ad4708a6c3e669345 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da -F src/shell.c.in 5ea8c6b0057bfe3bcdff31949fe72aa231ae429047c421ea1b168af6825a4890 +F src/shell.c.in c6cb773b7703d76677529de19d1c40584520701966422c33da3e9334498a7099 F src/sqlite.h.in 61a60b4ea04db8ead15e1579b20b64cb56e9f55d52c5f9f9694de630110593a3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2159,9 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 249048b0cbc37058c229a785182e07b46029584aff9c385269b0b93503153476 -Q +b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 -R 30b53374dcbd0df72ff4a36d2f8af72e -U dan -Z 80e756b96db0b6ae94203f53b2e0b98b +P 4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e +R 7d04a318d80ba08d1692be25eacaeef6 +U stephan +Z b8daa0711959586873a5caee05ab1e56 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cbd31ca380..eebd6825b5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e \ No newline at end of file +df563a18578c5cf1aaecf5818c93967aaa70475598d3c099779622ac8911f926 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 02850691d9..353db72ede 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -11926,7 +11926,7 @@ static void usage(int showDetail){ }else{ eputz("Use the -help option for additional information\n"); } - exit(1); + exit(0); } /* From e318f10ce25f2c36ce3bcbca71688c1060546dd8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 23 Jan 2024 13:21:40 +0000 Subject: [PATCH 0045/1030] If a BLOB looks like JSON when cast to text, then treat it as if it really were JSON. This replicates a long-standing bug in the JSON processing routines, and thereby avoids breaking legacy. FossilOrigin-Name: d79a37690ce7ebb91df203170d73511da44546328043c2b3fe1786b2f0087093 --- manifest | 13 +++---- manifest.uuid | 2 +- src/json.c | 45 ++++++++++++------------- test/json107.test | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 31 deletions(-) create mode 100644 test/json107.test diff --git a/manifest b/manifest index ddd60a6df8..3a5eb3c4a6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\s-DSQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE\scompile-time\soption\scauses\sblob\ninputs\sto\sJSON\sfunctions\sthat\sare\snot\sJSONB\sto\sbe\sprocessed\sas\sif\sthey\nwhere\stext,\simmulating\shistorical\sbugging\sbehavior\swhich\ssome\sapplications\nhave\scome\sto\srely\supon.\s\sSee\n[forum:/forumpost/012136abd5292b8d|forum\sthread\s012136abd5292b8d]\sfor\ndiscussion. -D 2024-01-22T14:16:10.354 +C If\sa\sBLOB\slooks\slike\sJSON\swhen\scast\sto\stext,\sthen\streat\sit\sas\sif\sit\sreally\nwere\sJSON.\s\sThis\sreplicates\sa\slong-standing\sbug\sin\sthe\sJSON\sprocessing\nroutines,\sand\sthereby\savoids\sbreaking\slegacy. +D 2024-01-23T13:21:40.846 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 99f2825b44327811bdf47808e57077388b83bcc6a253c1269d13fd1b3237138d +F src/json.c 14563eed12fdf0753eb8df2a72480a626335ab4467bc4dfdf15f9652f11ae1b8 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -1342,6 +1342,7 @@ F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a888011 F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba0114348c1 F test/json105.test 043838b56e68f3252a0dcf5be1689016f6f3f05056f8dcfcdc9d074f4d932988 F test/json106.test 1d46a9294e2ced35c7f87cebbcb9626d01abab04f1969d7ded7b6f6a1d9be0f2 +F test/json107.test 59054e815c8f6b67d634d44ace421cf975828fb5651c4460aa66015c8e19d562 F test/json501.test ab168a12eb6eb14d479f8c1cdae3ac062fd5a4679f17f976e96f1af518408330 F test/json502.test 84634d3dbb521d2814e43624025b760c6198456c8197bbec6c977c0236648f5b F test/jsonb01.test cace70765b36a36aec9a85a41ea65667d3bbf647d4400ddc3ac76f8fe7d94f90 @@ -2159,8 +2160,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e -R 59af26cba445671768ccc033868954ad +P 65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a +R d924d06eebab83ae665aafd4e67b28da U drh -Z 9f8b0dd9fdc4264b889c936f6659e28d +Z 70b17e73c0bc74c502f8785eed06d844 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 25bb88a0e7..916c951931 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a \ No newline at end of file +d79a37690ce7ebb91df203170d73511da44546328043c2b3fe1786b2f0087093 \ No newline at end of file diff --git a/src/json.c b/src/json.c index b9a88822e0..69995bbdfb 100644 --- a/src/json.c +++ b/src/json.c @@ -3311,20 +3311,18 @@ static JsonParse *jsonParseFuncArg( } return p; } -#if defined(SQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE) - /* If the input is a BLOB that is not JSONB, fall through into trying - ** to process that BLOB as if it where text. This goes against all - ** historical documentation about how the SQLite JSON functions are - ** suppose to work. Nevertheless, many SQLite implementations prior to - ** version 3.45.0 contained a bug such that they did behave this way - ** and some applications came to depend upon this buggy behavior. The - ** SQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE compile-time option provides - ** a mechanism for those applications to continue working even after - ** the bug was fixed. See - ** https://sqlite.org/forum/forumpost/012136abd5292b8d */ -#else - goto json_pfa_malformed; -#endif + /* If the blob is not valid JSONB, fall through into trying to cast + ** the blob into text which is then interpreted as JSON. (tag-20240123-a) + ** + ** This goes against all historical documentation about how the SQLite + ** JSON functions were suppose to work. From the beginning, blob was + ** reserved for expansion and a blob value should have raised an error. + ** But it did not, due to a bug. And many applications came to depend + ** upon this buggy behavior, espeically when using the CLI and reading + ** JSON text using readfile(), which returns a blob. For this reason + ** we will continue to support the bug moving forward. + ** See for example https://sqlite.org/forum/forumpost/012136abd5292b8d + */ } p->zJson = (char*)sqlite3_value_text(pArg); p->nJson = sqlite3_value_bytes(pArg); @@ -4300,12 +4298,12 @@ static void jsonValidFunc( return; } case SQLITE_BLOB: { - if( (flags & 0x0c)!=0 && jsonFuncArgMightBeBinary(argv[0]) ){ + if( jsonFuncArgMightBeBinary(argv[0]) ){ if( flags & 0x04 ){ /* Superficial checking only - accomplished by the ** jsonFuncArgMightBeBinary() call above. */ res = 1; - }else{ + }else if( flags & 0x08 ){ /* Strict checking. Check by translating BLOB->TEXT->BLOB. If ** no errors occur, call that a "strict check". */ JsonParse px; @@ -4316,8 +4314,11 @@ static void jsonValidFunc( iErr = jsonbValidityCheck(&px, 0, px.nBlob, 1); res = iErr==0; } + break; } - break; + /* Fall through into interpreting the input as text. See note + ** above at tag-20240124-a. */ + /* no break */ deliberate_fall_through } default: { JsonParse px; @@ -5053,13 +5054,9 @@ static int jsonEachFilter( memset(&p->sParse, 0, sizeof(p->sParse)); p->sParse.nJPRef = 1; p->sParse.db = p->db; - if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){ - if( jsonFuncArgMightBeBinary(argv[0]) ){ - p->sParse.nBlob = sqlite3_value_bytes(argv[0]); - p->sParse.aBlob = (u8*)sqlite3_value_blob(argv[0]); - }else{ - goto json_each_malformed_input; - } + if( jsonFuncArgMightBeBinary(argv[0]) ){ + p->sParse.nBlob = sqlite3_value_bytes(argv[0]); + p->sParse.aBlob = (u8*)sqlite3_value_blob(argv[0]); }else{ p->sParse.zJson = (char*)sqlite3_value_text(argv[0]); p->sParse.nJson = sqlite3_value_bytes(argv[0]); diff --git a/test/json107.test b/test/json107.test new file mode 100644 index 0000000000..779b557fba --- /dev/null +++ b/test/json107.test @@ -0,0 +1,86 @@ +# 2024-01-23 +# +# 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. +# +#*********************************************************************** +# +# Legacy JSON bug: If the input is a BLOB that when cast into TEXT looks +# like valid JSON, then treat it as valid JSON. +# +# The original intent of the JSON functions was to raise an error on any +# BLOB input. That intent was clearly documented, but the code failed to +# to implement it. Subsequently, many applications began to depend on the +# incorrect behavior, especially apps that used readfile() to read JSON +# content, since readfile() returns a BLOB. So we need to support the +# bug moving forward. +# +# The tests in this fail verify that the original buggy behavior is +# preserved. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix json107 + +if {[db one {PRAGMA encoding}]!="UTF-8"} { + # These tests only work for a UTF-8 encoding. + finish_test + return +} + +do_execsql_test 1.1 { + SELECT json_valid( CAST('{"a":1}' AS BLOB) ); +} 1 +do_execsql_test 1.1.1 { + SELECT json_valid( CAST('{"a":1}' AS BLOB), 1); +} 1 +do_execsql_test 1.1.2 { + SELECT json_valid( CAST('{"a":1}' AS BLOB), 2); +} 1 +do_execsql_test 1.1.4 { + SELECT json_valid( CAST('{"a":1}' AS BLOB), 4); +} 0 +do_execsql_test 1.1.8 { + SELECT json_valid( CAST('{"a":1}' AS BLOB), 8); +} 0 + +do_execsql_test 1.2.1 { + SELECT CAST('{"a":123}' AS blob) -> 'a'; +} 123 +do_execsql_test 1.2.2 { + SELECT CAST('{"a":123}' AS blob) ->> 'a'; +} 123 +do_execsql_test 1.2.3 { + SELECT json_extract(CAST('{"a":123}' AS blob), '$.a'); +} 123 +do_execsql_test 1.3 { + SELECT json_insert(CAST('{"a":123}' AS blob),'$.b',456); +} {{{"a":123,"b":456}}} +do_execsql_test 1.4 { + SELECT json_remove(CAST('{"a":123,"b":456}' AS blob),'$.a'); +} {{{"b":456}}} +do_execsql_test 1.5 { + SELECT json_set(CAST('{"a":123,"b":456}' AS blob),'$.a',789); +} {{{"a":789,"b":456}}} +do_execsql_test 1.6 { + SELECT json_replace(CAST('{"a":123,"b":456}' AS blob),'$.a',789); +} {{{"a":789,"b":456}}} +do_execsql_test 1.7 { + SELECT json_type(CAST('{"a":123,"b":456}' AS blob)); +} object +do_execsql_test 1.8 { + SELECT json(CAST('{"a":123,"b":456}' AS blob)); +} {{{"a":123,"b":456}}} + +ifcapable vtab { + do_execsql_test 2.1 { + SELECT key, value FROM json_tree( CAST('{"a":123,"b":456}' AS blob) ) + WHERE atom; + } {a 123 b 456} +} +finish_test From 6bb8ce6375f9f2586821c02b646d701e7ca64aaa Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 23 Jan 2024 13:28:21 +0000 Subject: [PATCH 0046/1030] Fix typo in the tag-20240123-a in a comment. FossilOrigin-Name: 1f09541eb4203ccce476f6040ff134353850f22f07fb84f96a1d2c27b304a91b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 3a5eb3c4a6..bd360840cf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\sBLOB\slooks\slike\sJSON\swhen\scast\sto\stext,\sthen\streat\sit\sas\sif\sit\sreally\nwere\sJSON.\s\sThis\sreplicates\sa\slong-standing\sbug\sin\sthe\sJSON\sprocessing\nroutines,\sand\sthereby\savoids\sbreaking\slegacy. -D 2024-01-23T13:21:40.846 +C Fix\stypo\sin\sthe\stag-20240123-a\sin\sa\scomment. +D 2024-01-23T13:28:21.325 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 14563eed12fdf0753eb8df2a72480a626335ab4467bc4dfdf15f9652f11ae1b8 +F src/json.c b2189995bb2f5eeac20a0282983cc82198fc77f9429708468ba360bbacb6fa80 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2160,8 +2160,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a -R d924d06eebab83ae665aafd4e67b28da +P d79a37690ce7ebb91df203170d73511da44546328043c2b3fe1786b2f0087093 +R daf98ef3cd5515173b41dfefd789b29a U drh -Z 70b17e73c0bc74c502f8785eed06d844 +Z 73f4e47cde19088f6970a061f009bfef # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 916c951931..60064befb3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d79a37690ce7ebb91df203170d73511da44546328043c2b3fe1786b2f0087093 \ No newline at end of file +1f09541eb4203ccce476f6040ff134353850f22f07fb84f96a1d2c27b304a91b \ No newline at end of file diff --git a/src/json.c b/src/json.c index 69995bbdfb..c7412d3c78 100644 --- a/src/json.c +++ b/src/json.c @@ -4317,7 +4317,7 @@ static void jsonValidFunc( break; } /* Fall through into interpreting the input as text. See note - ** above at tag-20240124-a. */ + ** above at tag-20240123-a. */ /* no break */ deliberate_fall_through } default: { From bcf3df01928257644f91ead9a28b7b8487104508 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 23 Jan 2024 16:09:22 +0000 Subject: [PATCH 0047/1030] In os_unix.c and os_win.c, do not allow xFetch() to return a pointer to a page buffer that is right at the end of the mapped region - if the database is corrupted in a specific way such a page buffer might be overread by several bytes. FossilOrigin-Name: 2684feac3bc9c5463604900d72710be861527614f4957224c74a16a3b3c702f5 --- manifest | 20 ++++++++--------- manifest.uuid | 2 +- src/os_unix.c | 7 +++++- src/os_win.c | 7 +++++- test/mmap1.test | 12 +++++----- test/mmapcorrupt.test | 51 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 test/mmapcorrupt.test diff --git a/manifest b/manifest index 116ab1ad12..c4f57831bb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\serror\smessage\swhen\sa\sdouble-quoted\sidentifier\sname\scannot\sbe\nresolved\s-\sask\sthe\suser\sif\sthey\sintended\sto\suse\sa\sstring\sliteral. -D 2024-01-23T14:45:22.468 +C In\sos_unix.c\sand\sos_win.c,\sdo\snot\sallow\sxFetch()\sto\sreturn\sa\spointer\sto\sa\spage\sbuffer\sthat\sis\sright\sat\sthe\send\sof\sthe\smapped\sregion\s-\sif\sthe\sdatabase\sis\scorrupted\sin\sa\sspecific\sway\ssuch\sa\spage\sbuffer\smight\sbe\soverread\sby\sseveral\sbytes. +D 2024-01-23T16:09:22.291 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -722,8 +722,8 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c 5dc41030cd5dfd99b907976b1725a4ed695566405d33744e4824c3d6aff245a3 -F src/os_win.c 4a50a154aeebc66a1f8fb79c1ff6dd5fe3d005556533361e0d460d41cb6a45a8 +F src/os_unix.c fa9b81b642e60e77ffaf98bd1a2e5fde16c1c2317614ec178bf3bd5864772356 +F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a @@ -1419,10 +1419,11 @@ F test/misc7.test d912f3d45c2989191b797504a220ca225d6be80b21acad22ba0d35f4a9ee45 F test/misc8.test 4db9f8be59834cea08c87e9658014080efa02678ef54a088f84fa5647e81fee0 F test/misuse.test 9e7f78402005e833af71dcab32d048003869eca5abcaccc985d4f8dc1d86bcc7 F test/mjournal.test 28a08d5cb5fb5b5702a46e19176e45e964e0800d1f894677169e79f34030e152 -F test/mmap1.test 5c1f768828094b0dd94e55ae7f10489a1ded74772682be2c4c78679d0acaf7ef +F test/mmap1.test e154d0442c9b43646f86b8ddc38b656bb8bc79284209a9367076473cec5d0eef F test/mmap2.test 9d6dd9ddb4ad2379f29cc78f38ce1e63ed418022 F test/mmap3.test b3c297e78e6a8520aafcc1a8f140535594c9086e F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93 +F test/mmapcorrupt.test 0d89724591f22a376019f3df60d075b838dd2ba6dae6effb0be465c49cf86d4a F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3 F test/mmapwarm.test 2272005969cd17a910077bd5082f70bc1fefad9a875afec7fc9af483898ecaf3 F test/multiplex.test d74c034e52805f6de8cc5432cef8c9eb774bb64ec29b83a22effc8ca4dac1f08 @@ -2160,9 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e5dc81d5c7ee97866feb688dfa9b6fc225dabff2b020b9b96b49a8fea5640aec 59eb9d29e796886db17a578b64e75fd2797aebf969cbeeda70ecf2fda378c98f -R c6b194554d1ef13c7fd9b0cfa6d21ae1 -T +closed 59eb9d29e796886db17a578b64e75fd2797aebf969cbeeda70ecf2fda378c98f -U drh -Z e1ae068dffaf45ea92f1b3624e579582 +P efc5c3c5e6ae1f9f0be61ea4ce7b3e34f3dc318791c78e0f4bebebeaccf6951e +R d2fac210a7e93b5529ce586e57a37021 +U dan +Z 75c6fc2c30c7c083cae329bbdba750e2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cfd6af6d29..104eee66ea 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -efc5c3c5e6ae1f9f0be61ea4ce7b3e34f3dc318791c78e0f4bebebeaccf6951e \ No newline at end of file +2684feac3bc9c5463604900d72710be861527614f4957224c74a16a3b3c702f5 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 80e6f6ad9a..4b3d63c2c1 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5441,11 +5441,16 @@ static int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){ #if SQLITE_MAX_MMAP_SIZE>0 if( pFd->mmapSizeMax>0 ){ + /* Ensure that there is always at least a 256 byte buffer of addressable + ** memory following the returned page. If the database is corrupt, + ** SQLite may overread the page slightly (in practice only a few bytes, + ** but 256 is safe, round, number). */ + const int nEofBuffer = 256; if( pFd->pMapRegion==0 ){ int rc = unixMapfile(pFd, -1); if( rc!=SQLITE_OK ) return rc; } - if( pFd->mmapSize >= iOff+nAmt ){ + if( pFd->mmapSize >= (iOff+nAmt+nEofBuffer) ){ *pp = &((u8 *)pFd->pMapRegion)[iOff]; pFd->nFetchOut++; } diff --git a/src/os_win.c b/src/os_win.c index dc16c08b51..442c108e9d 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -4521,6 +4521,11 @@ static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){ #if SQLITE_MAX_MMAP_SIZE>0 if( pFd->mmapSizeMax>0 ){ + /* Ensure that there is always at least a 256 byte buffer of addressable + ** memory following the returned page. If the database is corrupt, + ** SQLite may overread the page slightly (in practice only a few bytes, + ** but 256 is safe, round, number). */ + const int nEofBuffer = 256; if( pFd->pMapRegion==0 ){ int rc = winMapfile(pFd, -1); if( rc!=SQLITE_OK ){ @@ -4529,7 +4534,7 @@ static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){ return rc; } } - if( pFd->mmapSize >= iOff+nAmt ){ + if( pFd->mmapSize >= (iOff+nAmt+nEofBuffer) ){ assert( pFd->pMapRegion!=0 ); *pp = &((u8 *)pFd->pMapRegion)[iOff]; pFd->nFetchOut++; diff --git a/test/mmap1.test b/test/mmap1.test index 3362f7187f..01cb4bddb9 100644 --- a/test/mmap1.test +++ b/test/mmap1.test @@ -45,17 +45,17 @@ proc register_rblob_code {dbname seed} { } -# For cases 1.1 and 1.4, the number of pages read using xRead() is 4 on -# unix and 9 on windows. The difference is that windows only ever maps +# For cases 1.1 and 1.4, the number of pages read using xRead() is 8 on +# unix and 12 on windows. The difference is that windows only ever maps # an integer number of OS pages (i.e. creates mappings that are a multiple # of 4KB in size). Whereas on unix any sized mapping may be created. # foreach {t mmap_size nRead c2init} { - 1.1 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 0} - 1.2 { PRAGMA mmap_size = 53248 } 150 {PRAGMA mmap_size = 0} + 1.1 { PRAGMA mmap_size = 67108864 } /8|12/ {PRAGMA mmap_size = 0} + 1.2 { PRAGMA mmap_size = 53248 } 154 {PRAGMA mmap_size = 0} 1.3 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 0} - 1.4 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 67108864 } - 1.5 { PRAGMA mmap_size = 53248 } 150 {PRAGMA mmap_size = 67108864 } + 1.4 { PRAGMA mmap_size = 67108864 } /12|8/ {PRAGMA mmap_size = 67108864 } + 1.5 { PRAGMA mmap_size = 53248 } 154 {PRAGMA mmap_size = 67108864 } 1.6 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 67108864 } } { diff --git a/test/mmapcorrupt.test b/test/mmapcorrupt.test new file mode 100644 index 0000000000..70dbe84647 --- /dev/null +++ b/test/mmapcorrupt.test @@ -0,0 +1,51 @@ +# 2024 January 23 +# +# 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 special cases of corrupt database handling in mmap-mode. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix mmapcorrupt + +database_may_be_corrupt + +db close +sqlite3_shutdown +sqlite3_config_lookaside 0 0 +sqlite3_initialize + +reset_db +do_execsql_test 1.0 { + PRAGMA page_size = 16384; + CREATE TABLE tn1(a PRIMARY KEY) WITHOUT ROWID; + CREATE TABLE t0(a PRIMARY KEY) WITHOUT ROWID; + CREATE TABLE t1(a PRIMARY KEY) WITHOUT ROWID; + INSERT INTO t1 VALUES('B'); +} +db close + +set sz [file size test.db] +hexio_write test.db [expr $sz-3] 800380 + +sqlite3 db test.db +do_execsql_test 2.1 { + PRAGMA mmap_size = 1000000; + SELECT sql FROM sqlite_schema LIMIT 1; + SELECT * FROM t0; +} {1000000 {CREATE TABLE tn1(a PRIMARY KEY) WITHOUT ROWID}} + +do_execsql_test 2.2 { + INSERT INTO t0 SELECT * FROM t1; +} + +finish_test + From fa079680f1c2d6cc254ece7a76fd44ebfa28673c Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 23 Jan 2024 21:10:01 +0000 Subject: [PATCH 0048/1030] Slight adjustment to test results for Windows in mmap1.test due to the previous check-in. FossilOrigin-Name: 5cf9ea9b1fff4625a50a2343d0fd3812da6612d6b24c07e10edb6c1ff03ca2df --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/mmap1.test | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index c4f57831bb..6b179c3f9c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sos_unix.c\sand\sos_win.c,\sdo\snot\sallow\sxFetch()\sto\sreturn\sa\spointer\sto\sa\spage\sbuffer\sthat\sis\sright\sat\sthe\send\sof\sthe\smapped\sregion\s-\sif\sthe\sdatabase\sis\scorrupted\sin\sa\sspecific\sway\ssuch\sa\spage\sbuffer\smight\sbe\soverread\sby\sseveral\sbytes. -D 2024-01-23T16:09:22.291 +C Slight\sadjustment\sto\stest\sresults\sfor\sWindows\sin\smmap1.test\sdue\sto\nthe\sprevious\scheck-in. +D 2024-01-23T21:10:01.121 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1419,7 +1419,7 @@ F test/misc7.test d912f3d45c2989191b797504a220ca225d6be80b21acad22ba0d35f4a9ee45 F test/misc8.test 4db9f8be59834cea08c87e9658014080efa02678ef54a088f84fa5647e81fee0 F test/misuse.test 9e7f78402005e833af71dcab32d048003869eca5abcaccc985d4f8dc1d86bcc7 F test/mjournal.test 28a08d5cb5fb5b5702a46e19176e45e964e0800d1f894677169e79f34030e152 -F test/mmap1.test e154d0442c9b43646f86b8ddc38b656bb8bc79284209a9367076473cec5d0eef +F test/mmap1.test 18de3fd7b70a777af6004ca2feecfcdd3d0be17fa04058e808baf530c94b1a1d F test/mmap2.test 9d6dd9ddb4ad2379f29cc78f38ce1e63ed418022 F test/mmap3.test b3c297e78e6a8520aafcc1a8f140535594c9086e F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P efc5c3c5e6ae1f9f0be61ea4ce7b3e34f3dc318791c78e0f4bebebeaccf6951e -R d2fac210a7e93b5529ce586e57a37021 -U dan -Z 75c6fc2c30c7c083cae329bbdba750e2 +P 2684feac3bc9c5463604900d72710be861527614f4957224c74a16a3b3c702f5 +R 914fcc8566f9cd381eed502f3475f2e9 +U drh +Z 4b9eeb9a5957633229a8e3aa9d4bef67 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 104eee66ea..19d180bb45 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2684feac3bc9c5463604900d72710be861527614f4957224c74a16a3b3c702f5 \ No newline at end of file +5cf9ea9b1fff4625a50a2343d0fd3812da6612d6b24c07e10edb6c1ff03ca2df \ No newline at end of file diff --git a/test/mmap1.test b/test/mmap1.test index 01cb4bddb9..6a9625427a 100644 --- a/test/mmap1.test +++ b/test/mmap1.test @@ -51,12 +51,12 @@ proc register_rblob_code {dbname seed} { # of 4KB in size). Whereas on unix any sized mapping may be created. # foreach {t mmap_size nRead c2init} { - 1.1 { PRAGMA mmap_size = 67108864 } /8|12/ {PRAGMA mmap_size = 0} - 1.2 { PRAGMA mmap_size = 53248 } 154 {PRAGMA mmap_size = 0} - 1.3 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 0} - 1.4 { PRAGMA mmap_size = 67108864 } /12|8/ {PRAGMA mmap_size = 67108864 } - 1.5 { PRAGMA mmap_size = 53248 } 154 {PRAGMA mmap_size = 67108864 } - 1.6 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 67108864 } + 1.1 { PRAGMA mmap_size = 67108864 } /8|12/ {PRAGMA mmap_size = 0} + 1.2 { PRAGMA mmap_size = 53248 } /15[34]/ {PRAGMA mmap_size = 0} + 1.3 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 0} + 1.4 { PRAGMA mmap_size = 67108864 } /12|8/ {PRAGMA mmap_size = 67108864 } + 1.5 { PRAGMA mmap_size = 53248 } /15[34]/ {PRAGMA mmap_size = 67108864 } + 1.6 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 67108864 } } { do_multiclient_test tn { From 4821b15dca234d86d1042f652a045796fc92c16e Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 24 Jan 2024 19:54:49 +0000 Subject: [PATCH 0049/1030] Update ext/wasm/SQLTester for recent internal-API reorgs. FossilOrigin-Name: 996cfdf9b5f70408faeaa68ba2ea9494e419be8f2c59d89ab702419056e3569c --- ext/wasm/SQLTester/SQLTester.mjs | 12 +++++++++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ext/wasm/SQLTester/SQLTester.mjs b/ext/wasm/SQLTester/SQLTester.mjs index a72399aefc..71c5d4c538 100644 --- a/ext/wasm/SQLTester/SQLTester.mjs +++ b/ext/wasm/SQLTester/SQLTester.mjs @@ -174,11 +174,17 @@ const Rx = newObj({ squiggly: /[{}]/ }); + + const Util = newObj({ toss, - unlink: function(fn){ - return 0==sqlite3.wasm.sqlite3_wasm_vfs_unlink(0,fn); + unlink: function f(fn){ + if(!f.unlink){ + f.unlink = sqlite3.wasm.xWrap('sqlite3__wasm_vfs_unlink','int', + ['*','string']); + } + return 0==f.unlink(0,fn); }, argvToString: (list)=>{ @@ -197,7 +203,7 @@ const Util = newObj({ utf8Encode: (str)=>__utf8Encoder.encode(str), - strglob: sqlite3.wasm.xWrap('sqlite3_wasm_SQLTester_strglob','int', + strglob: sqlite3.wasm.xWrap('sqlite3__wasm_SQLTester_strglob','int', ['string','string']) })/*Util*/; diff --git a/manifest b/manifest index 6b179c3f9c..b129f28e22 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Slight\sadjustment\sto\stest\sresults\sfor\sWindows\sin\smmap1.test\sdue\sto\nthe\sprevious\scheck-in. -D 2024-01-23T21:10:01.121 +C Update\sext/wasm/SQLTester\sfor\srecent\sinternal-API\sreorgs. +D 2024-01-24T19:54:49.304 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -579,7 +579,7 @@ F ext/wasm/GNUmakefile 867c903a27fa0d53a3bf1b01d8c7bb713456f87e0939c3cac9f07faa6 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff -F ext/wasm/SQLTester/SQLTester.mjs ec2f6ba63a0f2f0562941a0fb8e46b7dc55589711513f1952349785966edfe50 +F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26d472daacab49031e1fb F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2684feac3bc9c5463604900d72710be861527614f4957224c74a16a3b3c702f5 -R 914fcc8566f9cd381eed502f3475f2e9 -U drh -Z 4b9eeb9a5957633229a8e3aa9d4bef67 +P 5cf9ea9b1fff4625a50a2343d0fd3812da6612d6b24c07e10edb6c1ff03ca2df +R e306e6e13da3ca6b74df7f0d8d78804a +U stephan +Z be34d47cda2dc0f9c45c17c4b0edc6bd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 19d180bb45..7541c5d7e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5cf9ea9b1fff4625a50a2343d0fd3812da6612d6b24c07e10edb6c1ff03ca2df \ No newline at end of file +996cfdf9b5f70408faeaa68ba2ea9494e419be8f2c59d89ab702419056e3569c \ No newline at end of file From 539085ddf5d575e3be4ace469551d4d7ff92b975 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 24 Jan 2024 21:08:57 +0000 Subject: [PATCH 0050/1030] Add NEVER() to a branch that is no longer reachable. FossilOrigin-Name: 9411337a7b3237366768fc708396da53d67a7a17b6cdc5c6f8932c5ab32217a9 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbesort.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b129f28e22..d546c7f2d5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sext/wasm/SQLTester\sfor\srecent\sinternal-API\sreorgs. -D 2024-01-24T19:54:49.304 +C Add\sNEVER()\sto\sa\sbranch\sthat\sis\sno\slonger\sreachable. +D 2024-01-24T21:08:57.555 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -815,7 +815,7 @@ F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b F src/vdbeaux.c c5a471b34e9c4cfc0295a3e10734fd197670ffaebcb742f284c8e17e8026ceea F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 3e37dab421b74e9ce55c1e88fbc7bc6fead590b5ab258bc684f8b70abb1d6e71 -F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 +F src/vdbesort.c 00c1fb15171205063556c2f1cf454e24c0b41c1effb0c876b850dce91f21bc64 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 F src/vtab.c 11948e105f56e84099ca17f1f434b1944539ea84de26d0d767eadfbc670ce1ea @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5cf9ea9b1fff4625a50a2343d0fd3812da6612d6b24c07e10edb6c1ff03ca2df -R e306e6e13da3ca6b74df7f0d8d78804a -U stephan -Z be34d47cda2dc0f9c45c17c4b0edc6bd +P 996cfdf9b5f70408faeaa68ba2ea9494e419be8f2c59d89ab702419056e3569c +R cc29f59aa57a1c6bea20c14e055ec6a4 +U drh +Z 22d3dca63255cbf92f3e39d6096754f7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7541c5d7e1..48c5e7a6da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -996cfdf9b5f70408faeaa68ba2ea9494e419be8f2c59d89ab702419056e3569c \ No newline at end of file +9411337a7b3237366768fc708396da53d67a7a17b6cdc5c6f8932c5ab32217a9 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 0083690308..324c7c43e3 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -1290,7 +1290,7 @@ static void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){ sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_CHUNK_SIZE, &chunksize); sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_SIZE_HINT, &nByte); sqlite3OsFetch(pFd, 0, (int)nByte, &p); - if( p ) sqlite3OsUnfetch(pFd, 0, p); + if( NEVER(p) ) sqlite3OsUnfetch(pFd, 0, p); } } #else From 82bf13796adf380c70badde482e1e05c5d151128 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 26 Jan 2024 20:34:48 +0000 Subject: [PATCH 0051/1030] Experimental changes that prevent parser stack overflows by growing the parser stack with heap memory when it reaches its limit. FossilOrigin-Name: 3fd062905fc20507b7cfc97fa976ac5b57c5b68926bf9136bd5ea4265d2d6528 --- doc/lemon.html | 18 ++++++++ manifest | 21 ++++++---- manifest.uuid | 2 +- src/parse.y | 4 ++ tool/lemon.c | 23 +++++++++++ tool/lempar.c | 109 ++++++++++++++++++++++++------------------------- 6 files changed, 112 insertions(+), 65 deletions(-) diff --git a/doc/lemon.html b/doc/lemon.html index 66665f46f3..4147d9b31e 100644 --- a/doc/lemon.html +++ b/doc/lemon.html @@ -683,6 +683,7 @@

4.4 Special Directives

  • %endif
  • %extra_argument
  • %fallback +
  • %free
  • %if
  • %ifdef
  • %ifndef @@ -693,6 +694,7 @@

    4.4 Special Directives

  • %parse_accept
  • %parse_failure
  • %right +
  • %realloc
  • %stack_overflow
  • %stack_size
  • %start_symbol @@ -1200,6 +1202,21 @@

    4.4.25 The %wildcard directive

    the wildcard token and some other token, the other token is always used. The wildcard token is only matched if there are no alternatives.

    + +

    4.4.26 The %realloc and %free directives

    + +

    The %realloc and %free directives defines function +that allocate and free heap memory. The signatures of these functions +should be the same as the realloc() and free() functions from the standard +C library. + +

    If both of these functions are defined +then these functions are used to allocate and free +memory for supplemental parser stack space, if the initial +parse stack space is exceeded. The initial parser stack size +is specified by either %stack_size or the +-DYYSTACKDEPTH compile-time flag. +

    5.0 Error Processing

    @@ -1224,6 +1241,7 @@

    5.0 Error Processing

    first syntax error, of course, if there are no instances of the "error" non-terminal in your grammar.

    +

    6.0 History of Lemon

    diff --git a/manifest b/manifest index d546c7f2d5..42fb3ce813 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sNEVER()\sto\sa\sbranch\sthat\sis\sno\slonger\sreachable. -D 2024-01-24T21:08:57.555 +C Experimental\schanges\sthat\sprevent\sparser\sstack\soverflows\sby\sgrowing\sthe\nparser\sstack\swith\sheap\smemory\swhen\sit\sreaches\sits\slimit. +D 2024-01-26T20:34:48.241 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -40,7 +40,7 @@ F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md 50b27d77be96195c66031a3181cb8684ed822327ea834e07f9c014213e5e3bcf F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b -F doc/lemon.html 44a53a1d2b42d7751f7b2f478efb23c978e258d794bfd172442307a755b9fa44 +F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 F doc/testrunner.md 8d36ec692cf4994bb66d84a4645b9afa1ce9d47dc12cbf8d437c5a5fb6ddeedb F doc/trusted-schema.md 33625008620e879c7bcfbbfa079587612c434fa094d338b08242288d358c3e8a @@ -727,7 +727,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 020d80386eb216ec9520549106353c517d2bbc89be28752ffdca649a9eaf56ec +F src/parse.y 41926c507955f2c13b10bb344883874cde82ea3ed16cb3b7867a43298d040d79 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -2072,8 +2072,8 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c 19e368bc8e97ff4071115119a7911ca3b0c56eba7926d8ada8b4a86fcc69a176 -F tool/lempar.c 57478ea48420da05faa873c6d1616321caa5464644588c97fbe8e0ea04450748 +F tool/lemon.c 7e5c3c27062c94a40b73a980b8045a4201cb3335165b72ae476040dc513aa533 +F tool/lempar.c fa7ab4dd5bc069ffa276cbd85bea767e6472f4163106b94edd5ad01dd4babdc8 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669 @@ -2161,8 +2161,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 996cfdf9b5f70408faeaa68ba2ea9494e419be8f2c59d89ab702419056e3569c -R cc29f59aa57a1c6bea20c14e055ec6a4 +P 9411337a7b3237366768fc708396da53d67a7a17b6cdc5c6f8932c5ab32217a9 +R de3584eaf5d75ac532effc39455b51de +T *branch * growable-parser-stack +T *sym-growable-parser-stack * +T -sym-trunk * U drh -Z 22d3dca63255cbf92f3e39d6096754f7 +Z 64ba7e2f532c5b55e706d3959cc36418 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 48c5e7a6da..acfd13cd30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9411337a7b3237366768fc708396da53d67a7a17b6cdc5c6f8932c5ab32217a9 \ No newline at end of file +3fd062905fc20507b7cfc97fa976ac5b57c5b68926bf9136bd5ea4265d2d6528 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 19491192e3..0e41f54cf1 100644 --- a/src/parse.y +++ b/src/parse.y @@ -21,6 +21,10 @@ */ } +// Function used to enlarge the parser stack, if needed +%realloc sqlite3_realloc64 +%free sqlite3_free + // All token codes are small integers with #defines that begin with "TK_" %token_prefix TK_ diff --git a/tool/lemon.c b/tool/lemon.c index 7804837a06..c578b44bab 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -418,6 +418,8 @@ struct lemon { char *filename; /* Name of the input file */ char *outname; /* Name of the current output file */ char *tokenprefix; /* A prefix added to token names in the .h file */ + char *reallocFunc; /* Function to use to allocate stack space */ + char *freeFunc; /* Function to use to free stack space */ int nconflict; /* Number of parsing conflicts */ int nactiontab; /* Number of entries in the yy_action[] table */ int nlookaheadtab; /* Number of entries in yy_lookahead[] */ @@ -2531,6 +2533,12 @@ static void parseonetoken(struct pstate *psp) }else if( strcmp(x,"default_type")==0 ){ psp->declargslot = &(psp->gp->vartype); psp->insertLineMacro = 0; + }else if( strcmp(x,"realloc")==0 ){ + psp->declargslot = &(psp->gp->reallocFunc); + psp->insertLineMacro = 0; + }else if( strcmp(x,"free")==0 ){ + psp->declargslot = &(psp->gp->freeFunc); + psp->insertLineMacro = 0; }else if( strcmp(x,"stack_size")==0 ){ psp->declargslot = &(psp->gp->stacksize); psp->insertLineMacro = 0; @@ -4501,6 +4509,21 @@ void ReportTable( fprintf(out,"#define %sARG_FETCH\n",name); lineno++; fprintf(out,"#define %sARG_STORE\n",name); lineno++; } + if( lemp->reallocFunc ){ + fprintf(out,"#define YYREALLOC %s\n", lemp->reallocFunc); lineno++; + }else{ + fprintf(out,"#define YYREALLOC realloc\n"); lineno++; + } + if( lemp->freeFunc ){ + fprintf(out,"#define YYFREE %s\n", lemp->freeFunc); lineno++; + }else{ + fprintf(out,"#define YYFREE free\n"); lineno++; + } + if( lemp->reallocFunc && lemp->freeFunc ){ + fprintf(out,"#define YYDYNSTACK 1\n"); lineno++; + }else{ + fprintf(out,"#define YYDYNSTACK 0\n"); lineno++; + } if( lemp->ctx && lemp->ctx[0] ){ i = lemonStrlen(lemp->ctx); while( i>=1 && ISSPACE(lemp->ctx[i-1]) ) i--; diff --git a/tool/lempar.c b/tool/lempar.c index 8cc57897db..d8e64c40dd 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -67,6 +67,9 @@ ** ParseARG_STORE Code to store %extra_argument into yypParser ** ParseARG_FETCH Code to extract %extra_argument from yypParser ** ParseCTX_* As ParseARG_ except for %extra_context +** YYREALLOC Name of the realloc() function to use +** YYFREE Name of the free() function to use +** YYDYNSTACK True if stack space should be extended on heap ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. @@ -101,6 +104,22 @@ # define yytestcase(X) #endif +/* Macro to determine if stack space has the ability to grow using +** heap memory. +*/ +#if YYSTACKDEPTH<=0 || YYDYNSTACK +# define YYGROWABLESTACK 1 +#else +# define YYGROWABLESTACK 0 +#endif + +/* Guarantee a minimum number of initial stack slots. +*/ +#if YYSTACKDEPTH<=0 +# undef YYSTACKDEPTH +# define YYSTACKDEPTH 2 /* Need a minimum stack size */ +#endif + /* Next are the tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement @@ -212,14 +231,9 @@ struct yyParser { #endif ParseARG_SDECL /* A place to hold %extra_argument */ ParseCTX_SDECL /* A place to hold %extra_context */ -#if YYSTACKDEPTH<=0 - int yystksz; /* Current side of the stack */ - yyStackEntry *yystack; /* The parser's stack */ - yyStackEntry yystk0; /* First stack entry */ -#else - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ - yyStackEntry *yystackEnd; /* Last entry in the stack */ -#endif + yyStackEntry *yystackEnd; /* Last entry in the stack */ + yyStackEntry *yystack; /* The parser stack */ + yyStackEntry yystk0[YYSTACKDEPTH]; /* Initial stack space */ }; typedef struct yyParser yyParser; @@ -273,37 +287,45 @@ static const char *const yyRuleName[] = { #endif /* NDEBUG */ -#if YYSTACKDEPTH<=0 +#if YYGROWABLESTACK /* ** Try to increase the size of the parser stack. Return the number ** of errors. Return 0 on success. */ static int yyGrowStack(yyParser *p){ + int oldSize = 1 + (int)(p->yystackEnd - p->yystack)/sizeof(p->yystack[0]); int newSize; int idx; yyStackEntry *pNew; - newSize = p->yystksz*2 + 100; + newSize = oldSize*2 + 100; idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; - if( p->yystack==&p->yystk0 ){ - pNew = malloc(newSize*sizeof(pNew[0])); - if( pNew ) pNew[0] = p->yystk0; + if( p->yystack==p->yystk0 ){ + pNew = YYREALLOC(0, newSize*sizeof(pNew[0])); + if( pNew==0 ) return 1; + memcpy(pNew, p->yystk0, sizeof(p->yystk0)); }else{ - pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); + pNew = YYREALLOC(p->yystack, newSize*sizeof(pNew[0])); + if( pNew==0 ) return 1; } - if( pNew ){ - p->yystack = pNew; - p->yytos = &p->yystack[idx]; + p->yystack = pNew; + p->yytos = &p->yystack[idx]; #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", - yyTracePrompt, p->yystksz, newSize); - } -#endif - p->yystksz = newSize; + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", + yyTracePrompt, oldSize, newSize); } - return pNew==0; +#endif + p->yystackEnd = &p->yystack[newSize-1]; + return 0; } +#endif /* YYGROWABLESTACK */ + +#if !YYGROWABLESTACK +/* For builds that do no have a growable stack, yyGrowStack always +** returns an error. +*/ +# define yyGrowStack(X) 1 #endif /* Datatype of the argument to the memory allocated passed as the @@ -323,24 +345,14 @@ void ParseInit(void *yypRawParser ParseCTX_PDECL){ #ifdef YYTRACKMAXSTACKDEPTH yypParser->yyhwm = 0; #endif -#if YYSTACKDEPTH<=0 - yypParser->yytos = NULL; - yypParser->yystack = NULL; - yypParser->yystksz = 0; - if( yyGrowStack(yypParser) ){ - yypParser->yystack = &yypParser->yystk0; - yypParser->yystksz = 1; - } -#endif + yypParser->yystack = yypParser->yystk0; + yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif yypParser->yytos = yypParser->yystack; yypParser->yystack[0].stateno = 0; yypParser->yystack[0].major = 0; -#if YYSTACKDEPTH>0 - yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; -#endif } #ifndef Parse_ENGINEALWAYSONSTACK @@ -427,8 +439,8 @@ static void yy_pop_parser_stack(yyParser *pParser){ void ParseFinalize(void *p){ yyParser *pParser = (yyParser*)p; while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); -#if YYSTACKDEPTH<=0 - if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); +#if YYGROWABLESTACK + if( pParser->yystack!=pParser->yystk0 ) YYFREE(pParser->yystack); #endif } @@ -654,25 +666,19 @@ static void yy_shift( assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) ); } #endif -#if YYSTACKDEPTH>0 - if( yypParser->yytos>yypParser->yystackEnd ){ - yypParser->yytos--; - yyStackOverflow(yypParser); - return; - } -#else - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ + yytos = yypParser->yytos; + if( yytos>yypParser->yystackEnd ){ if( yyGrowStack(yypParser) ){ yypParser->yytos--; yyStackOverflow(yypParser); return; } + yytos = yypParser->yytos; + assert( yytos <= yypParser->yystackEnd ); } -#endif if( yyNewState > YY_MAX_SHIFT ){ yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; } - yytos = yypParser->yytos; yytos->stateno = yyNewState; yytos->major = yyMajor; yytos->minor.yy0 = yyMinor; @@ -911,19 +917,12 @@ void Parse( (int)(yypParser->yytos - yypParser->yystack)); } #endif -#if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ - yyStackOverflow(yypParser); - break; - } -#else - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); break; } } -#endif } yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ From 51f652de10fa5fdc28b990ec4ed60ff54233750b Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 26 Jan 2024 20:57:19 +0000 Subject: [PATCH 0052/1030] Bug fixes in the function that expands the parser stack. FossilOrigin-Name: e91179fe849760771c3508b1e7d75325183e5c3b029752d0a97dbdbd57188b97 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- test/misc5.test | 4 ++-- tool/lempar.c | 4 ++-- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 42fb3ce813..e783626ab4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Experimental\schanges\sthat\sprevent\sparser\sstack\soverflows\sby\sgrowing\sthe\nparser\sstack\swith\sheap\smemory\swhen\sit\sreaches\sits\slimit. -D 2024-01-26T20:34:48.241 +C Bug\sfixes\sin\sthe\sfunction\sthat\sexpands\sthe\sparser\sstack. +D 2024-01-26T20:57:19.823 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1413,7 +1413,7 @@ F test/misc1.test 8d138a4926ab90617c1aa29ce26e7785ae2b83a4d3a195d543b7374e05589d F test/misc2.test 71e746af479119386ac2ed7ab7d81d99970e75b49ffd3e8efffee100b4b5f350 F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e -F test/misc5.test c4aeaa0fa28faa08f2485309c38db4719e6cd1364215d5687a5b96d340a3fa58 +F test/misc5.test 48de5f4220ff1a27922b14b8cf1b977f73c5a49f82b2ccd66bd86c0e53c447d4 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test d912f3d45c2989191b797504a220ca225d6be80b21acad22ba0d35f4a9ee4579 F test/misc8.test 4db9f8be59834cea08c87e9658014080efa02678ef54a088f84fa5647e81fee0 @@ -2073,7 +2073,7 @@ F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f F tool/lemon.c 7e5c3c27062c94a40b73a980b8045a4201cb3335165b72ae476040dc513aa533 -F tool/lempar.c fa7ab4dd5bc069ffa276cbd85bea767e6472f4163106b94edd5ad01dd4babdc8 +F tool/lempar.c e560057d6e0f578be64894e70e3d86beee6ae26f4aa5a6fb74fdfff8e75ccb35 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669 @@ -2161,11 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9411337a7b3237366768fc708396da53d67a7a17b6cdc5c6f8932c5ab32217a9 -R de3584eaf5d75ac532effc39455b51de -T *branch * growable-parser-stack -T *sym-growable-parser-stack * -T -sym-trunk * +P 3fd062905fc20507b7cfc97fa976ac5b57c5b68926bf9136bd5ea4265d2d6528 +R 201c8ebb7c943c92d1f840025296ad42 U drh -Z 64ba7e2f532c5b55e706d3959cc36418 +Z 19d016796a5696ebb7583ab93b83b409 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index acfd13cd30..d41ff74d95 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3fd062905fc20507b7cfc97fa976ac5b57c5b68926bf9136bd5ea4265d2d6528 \ No newline at end of file +e91179fe849760771c3508b1e7d75325183e5c3b029752d0a97dbdbd57188b97 \ No newline at end of file diff --git a/test/misc5.test b/test/misc5.test index f7c6048d97..0307c3bb07 100644 --- a/test/misc5.test +++ b/test/misc5.test @@ -581,9 +581,9 @@ do_test misc5-7.1 { append sql "(1+" append tail ")" } - append sql 2$tail + append sql 2$tail) catchsql $sql -} {1 {parser stack overflow}} +} {0 {}} # Parser stack overflow is silently ignored when it occurs while parsing the # schema and PRAGMA writable_schema is turned on. diff --git a/tool/lempar.c b/tool/lempar.c index d8e64c40dd..1ea66e8402 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -293,7 +293,7 @@ static const char *const yyRuleName[] = { ** of errors. Return 0 on success. */ static int yyGrowStack(yyParser *p){ - int oldSize = 1 + (int)(p->yystackEnd - p->yystack)/sizeof(p->yystack[0]); + int oldSize = 1 + (int)(p->yystackEnd - p->yystack); int newSize; int idx; yyStackEntry *pNew; @@ -303,7 +303,7 @@ static int yyGrowStack(yyParser *p){ if( p->yystack==p->yystk0 ){ pNew = YYREALLOC(0, newSize*sizeof(pNew[0])); if( pNew==0 ) return 1; - memcpy(pNew, p->yystk0, sizeof(p->yystk0)); + memcpy(pNew, p->yystack, oldSize*sizeof(pNew[0])); }else{ pNew = YYREALLOC(p->yystack, newSize*sizeof(pNew[0])); if( pNew==0 ) return 1; From 3467698000de73695f7eee8473a16d0981fdd5a6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 27 Jan 2024 01:35:07 +0000 Subject: [PATCH 0053/1030] Omit the "parser stack overflow" error message, since it no longer occurs. Replace it with an ordinary "out of memory". FossilOrigin-Name: 33f17ec24880937892d47a5a321c43785ca18e03dde28a9a0d50ae86edb29679 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/parse.y | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e783626ab4..d83d65b92d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bug\sfixes\sin\sthe\sfunction\sthat\sexpands\sthe\sparser\sstack. -D 2024-01-26T20:57:19.823 +C Omit\sthe\s"parser\sstack\soverflow"\serror\smessage,\ssince\sit\sno\slonger\soccurs.\nReplace\sit\swith\san\sordinary\s"out\sof\smemory". +D 2024-01-27T01:35:07.422 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -727,7 +727,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 41926c507955f2c13b10bb344883874cde82ea3ed16cb3b7867a43298d040d79 +F src/parse.y 7505b34ab81f17c5af10cc2c4c40e94ece3035ef151fe544e21b9a3b0e4e8531 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3fd062905fc20507b7cfc97fa976ac5b57c5b68926bf9136bd5ea4265d2d6528 -R 201c8ebb7c943c92d1f840025296ad42 +P e91179fe849760771c3508b1e7d75325183e5c3b029752d0a97dbdbd57188b97 +R a326e9a9ce6869e2191b567c898735a6 U drh -Z 19d016796a5696ebb7583ab93b83b409 +Z 3729898b234031ff25c57e8984e9d7de # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d41ff74d95..7ea834c5c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e91179fe849760771c3508b1e7d75325183e5c3b029752d0a97dbdbd57188b97 \ No newline at end of file +33f17ec24880937892d47a5a321c43785ca18e03dde28a9a0d50ae86edb29679 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 0e41f54cf1..2d5dc8ee38 100644 --- a/src/parse.y +++ b/src/parse.y @@ -49,7 +49,7 @@ } } %stack_overflow { - sqlite3ErrorMsg(pParse, "parser stack overflow"); + sqlite3OomFault(pParse->db); } // The name of the generated procedure that implements the parser From 7659ce22c50d526fcd4c115b79ac6ff667ee70f0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 27 Jan 2024 02:21:25 +0000 Subject: [PATCH 0054/1030] Optimizations to ParseFinalize() to make up for the extra cleanup associated with the allocated parser stack. This branch now runs faster than trunk and is less than 300 bytes larger. FossilOrigin-Name: f7290db63cc2568090c14dffc4ea4eadfacb5b94b50a1852ef6eefd9e2e32533 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/lemon.c | 18 +++++++++++++++++- tool/lempar.c | 21 ++++++++++++++++++++- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index d83d65b92d..a87dfc1f4e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sthe\s"parser\sstack\soverflow"\serror\smessage,\ssince\sit\sno\slonger\soccurs.\nReplace\sit\swith\san\sordinary\s"out\sof\smemory". -D 2024-01-27T01:35:07.422 +C Optimizations\sto\sParseFinalize()\sto\smake\sup\sfor\sthe\sextra\scleanup\sassociated\nwith\sthe\sallocated\sparser\sstack.\s\sThis\sbranch\snow\sruns\sfaster\sthan\strunk\nand\sis\sless\sthan\s300\sbytes\slarger. +D 2024-01-27T02:21:25.832 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2072,8 +2072,8 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c 7e5c3c27062c94a40b73a980b8045a4201cb3335165b72ae476040dc513aa533 -F tool/lempar.c e560057d6e0f578be64894e70e3d86beee6ae26f4aa5a6fb74fdfff8e75ccb35 +F tool/lemon.c db6c77d899f565ab42217d924e5daee5b267724433c7747fb6d3329b3c919fa1 +F tool/lempar.c c85839df516cf3cee74829df59e968646275d327763c64c9e776bac92671f0ac F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e91179fe849760771c3508b1e7d75325183e5c3b029752d0a97dbdbd57188b97 -R a326e9a9ce6869e2191b567c898735a6 +P 33f17ec24880937892d47a5a321c43785ca18e03dde28a9a0d50ae86edb29679 +R 20cc75bdc335ec49c6e2f7e4614d84da U drh -Z 3729898b234031ff25c57e8984e9d7de +Z 297b67eb6c1efaf54d4488f8dcd81ddc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7ea834c5c4..6f41fa279d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -33f17ec24880937892d47a5a321c43785ca18e03dde28a9a0d50ae86edb29679 \ No newline at end of file +f7290db63cc2568090c14dffc4ea4eadfacb5b94b50a1852ef6eefd9e2e32533 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index c578b44bab..5b1702f4ee 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4317,7 +4317,7 @@ void ReportTable( struct action *ap; struct rule *rp; struct acttab *pActtab; - int i, j, n, sz; + int i, j, n, sz, mn, mx; int nLookAhead; int szActionType; /* sizeof(YYACTIONTYPE) */ int szCodeType; /* sizeof(YYCODETYPE) */ @@ -4647,6 +4647,22 @@ void ReportTable( fprintf(out,"#define YY_MIN_REDUCE %d\n", lemp->minReduce); lineno++; i = lemp->minReduce + lemp->nrule; fprintf(out,"#define YY_MAX_REDUCE %d\n", i-1); lineno++; + + /* Minimum and maximum token values that have a destructor */ + mn = mx = 0; + for(i=0; insymbol; i++){ + struct symbol *sp = lemp->symbols[i]; + + if( sp && sp->type!=TERMINAL && sp->destructor ){ + if( mn==0 || sp->indexindex; + if( sp->index>mx ) mx = sp->index; + } + } + if( lemp->tokendest ) mn = 0; + if( lemp->vardest ) mx = lemp->nsymbol-1; + fprintf(out,"#define YY_MIN_DSTRCTR %d\n", mn); lineno++; + fprintf(out,"#define YY_MAX_DSTRCTR %d\n", mx); lineno++; + tplt_xfer(lemp->name,in,out,&lineno); /* Now output the action table and its associates: diff --git a/tool/lempar.c b/tool/lempar.c index 1ea66e8402..9be2d409ed 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -83,6 +83,8 @@ ** YY_NO_ACTION The yy_action[] code for no-op ** YY_MIN_REDUCE Minimum value for reduce actions ** YY_MAX_REDUCE Maximum value for reduce actions +** YY_MIN_DSTRCTR Minimum symbol value that has a destructor +** YY_MAX_DSTRCTR Maximum symbol value that has a destructor */ #ifndef INTERFACE # define INTERFACE 1 @@ -438,7 +440,24 @@ static void yy_pop_parser_stack(yyParser *pParser){ */ void ParseFinalize(void *p){ yyParser *pParser = (yyParser*)p; - while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); + + /* In-lined version of calling yy_pop_parser_stack() for each + ** element left in the stack */ + yyStackEntry *yytos = pParser->yytos; + while( yytos>pParser->yystack ){ +#ifndef NDEBUG + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sPopping %s\n", + yyTracePrompt, + yyTokenName[yytos->major]); + } +#endif + if( yytos->major>=YY_MIN_DSTRCTR && yytos->major<=YY_MAX_DSTRCTR ){ + yy_destructor(pParser, yytos->major, &yytos->minor); + } + yytos--; + } + #if YYGROWABLESTACK if( pParser->yystack!=pParser->yystk0 ) YYFREE(pParser->yystack); #endif From 48e899a86e9a009fb0f7f32858f65c4adeebb073 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 27 Jan 2024 12:25:07 +0000 Subject: [PATCH 0055/1030] Use an alternative memory allocator for parser stack space that includes a call to sqlite3FaultSim() to facilitate testing. FossilOrigin-Name: 7c36d560ff4e8e1b3f8fad972ec7f07837e4fa4e6861fafde970ffccfda5a2f1 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/parse.y | 10 +++++++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 58d782416d..85a898e370 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allocate\snew\sparser\sstack\sspace\sfrom\sthe\sheap\sif\sneeded,\seliminating\sthe\npossibility\sof\sa\s"parser\sstack\soverflow"\serror\sas\slong\sas\sheap\smemory\sis\navailable. -D 2024-01-27T11:35:35.516 +C Use\san\salternative\smemory\sallocator\sfor\sparser\sstack\sspace\sthat\sincludes\na\scall\sto\ssqlite3FaultSim()\sto\sfacilitate\stesting. +D 2024-01-27T12:25:07.473 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -727,7 +727,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 7505b34ab81f17c5af10cc2c4c40e94ece3035ef151fe544e21b9a3b0e4e8531 +F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -2161,9 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9411337a7b3237366768fc708396da53d67a7a17b6cdc5c6f8932c5ab32217a9 f7290db63cc2568090c14dffc4ea4eadfacb5b94b50a1852ef6eefd9e2e32533 -R 20cc75bdc335ec49c6e2f7e4614d84da -T +closed f7290db63cc2568090c14dffc4ea4eadfacb5b94b50a1852ef6eefd9e2e32533 +P d87a2054774aa6ce54d9ccd78899b638f1eaf4f9a1d847bf22500018049c9f8d +R c777a6ad74adc955afb0be27604d5bbb U drh -Z c2cb0e9c7b04a3911872c4a743c7e226 +Z 010b198501e478def188acd882fee6aa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ae968423a2..77b98b4841 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d87a2054774aa6ce54d9ccd78899b638f1eaf4f9a1d847bf22500018049c9f8d \ No newline at end of file +7c36d560ff4e8e1b3f8fad972ec7f07837e4fa4e6861fafde970ffccfda5a2f1 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 2d5dc8ee38..12621b4348 100644 --- a/src/parse.y +++ b/src/parse.y @@ -22,7 +22,7 @@ } // Function used to enlarge the parser stack, if needed -%realloc sqlite3_realloc64 +%realloc parserStackRealloc %free sqlite3_free // All token codes are small integers with #defines that begin with "TK_" @@ -551,6 +551,14 @@ cmd ::= select(X). { } return pSelect; } + + /* Memory allocator for parser stack resizing. This is a thin wrapper around + ** sqlite3_realloc() that includes a call to sqlite3FaultSim() to facilitate + ** testing. + */ + static void *parserStackRealloc(void *pOld, sqlite3_uint64 newSize){ + return sqlite3FaultSim(700) ? 0 : sqlite3_realloc(pOld, newSize); + } } %ifndef SQLITE_OMIT_CTE From 21bdfe5884b2c3f05c6b73f2166ee3e6c121281b Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 27 Jan 2024 12:47:51 +0000 Subject: [PATCH 0056/1030] Performance enhancements to the parser template. FossilOrigin-Name: 2db8b30acdeaeaf7ec92dc0382a25f96bca4561fb68a72713ff963e27f39c63b --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 85a898e370..cd38b38091 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\san\salternative\smemory\sallocator\sfor\sparser\sstack\sspace\sthat\sincludes\na\scall\sto\ssqlite3FaultSim()\sto\sfacilitate\stesting. -D 2024-01-27T12:25:07.473 +C Performance\senhancements\sto\sthe\sparser\stemplate. +D 2024-01-27T12:47:51.250 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2073,7 +2073,7 @@ F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f F tool/lemon.c db6c77d899f565ab42217d924e5daee5b267724433c7747fb6d3329b3c919fa1 -F tool/lempar.c c85839df516cf3cee74829df59e968646275d327763c64c9e776bac92671f0ac +F tool/lempar.c e6b649778e5c027c8365ff01d7ef39297cd7285fa1f881cce31792689541e79f F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d87a2054774aa6ce54d9ccd78899b638f1eaf4f9a1d847bf22500018049c9f8d -R c777a6ad74adc955afb0be27604d5bbb +P 7c36d560ff4e8e1b3f8fad972ec7f07837e4fa4e6861fafde970ffccfda5a2f1 +R 04bb01319eb99c590d86659f5806b074 U drh -Z 010b198501e478def188acd882fee6aa +Z cbc91e2ee0fe61a39c4ed5ed8e1fb955 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 77b98b4841..0dbb2b454b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c36d560ff4e8e1b3f8fad972ec7f07837e4fa4e6861fafde970ffccfda5a2f1 \ No newline at end of file +2db8b30acdeaeaf7ec92dc0382a25f96bca4561fb68a72713ff963e27f39c63b \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 9be2d409ed..851a0e2e54 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -301,7 +301,7 @@ static int yyGrowStack(yyParser *p){ yyStackEntry *pNew; newSize = oldSize*2 + 100; - idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; + idx = (int)(p->yytos - p->yystack); if( p->yystack==p->yystk0 ){ pNew = YYREALLOC(0, newSize*sizeof(pNew[0])); if( pNew==0 ) return 1; @@ -452,7 +452,7 @@ void ParseFinalize(void *p){ yyTokenName[yytos->major]); } #endif - if( yytos->major>=YY_MIN_DSTRCTR && yytos->major<=YY_MAX_DSTRCTR ){ + if( yytos->major>=YY_MIN_DSTRCTR ){ yy_destructor(pParser, yytos->major, &yytos->minor); } yytos--; From 052f0a95d07062749836569fbf8f686d0d153203 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 27 Jan 2024 20:17:05 +0000 Subject: [PATCH 0057/1030] Improvements to parser stack overflow testing. [forum:/forumpost/99e181b5bf|Forum post 99e181b5bf]. FossilOrigin-Name: 556c43a937f1d1c19117da24e6d892852241189f4e47e1c86aa1e8c36461c5de --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/misc5.test | 24 ++++++++++++++++++------ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index cd38b38091..e5e4ee4b4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\senhancements\sto\sthe\sparser\stemplate. -D 2024-01-27T12:47:51.250 +C Improvements\sto\sparser\sstack\soverflow\stesting.\n[forum:/forumpost/99e181b5bf|Forum\spost\s99e181b5bf]. +D 2024-01-27T20:17:05.552 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1413,7 +1413,7 @@ F test/misc1.test 8d138a4926ab90617c1aa29ce26e7785ae2b83a4d3a195d543b7374e05589d F test/misc2.test 71e746af479119386ac2ed7ab7d81d99970e75b49ffd3e8efffee100b4b5f350 F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e -F test/misc5.test 48de5f4220ff1a27922b14b8cf1b977f73c5a49f82b2ccd66bd86c0e53c447d4 +F test/misc5.test 027cf0ac10314ea534173f335a33bb4059907ddabbac2c16786766d6f26c8923 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test d912f3d45c2989191b797504a220ca225d6be80b21acad22ba0d35f4a9ee4579 F test/misc8.test 4db9f8be59834cea08c87e9658014080efa02678ef54a088f84fa5647e81fee0 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7c36d560ff4e8e1b3f8fad972ec7f07837e4fa4e6861fafde970ffccfda5a2f1 -R 04bb01319eb99c590d86659f5806b074 +P 2db8b30acdeaeaf7ec92dc0382a25f96bca4561fb68a72713ff963e27f39c63b +R 605333aa92af75374c12db2870558f0c U drh -Z cbc91e2ee0fe61a39c4ed5ed8e1fb955 +Z 624bf4ea7db4f65352370ddfed55f7bd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0dbb2b454b..dc3d7b8571 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2db8b30acdeaeaf7ec92dc0382a25f96bca4561fb68a72713ff963e27f39c63b \ No newline at end of file +556c43a937f1d1c19117da24e6d892852241189f4e47e1c86aa1e8c36461c5de \ No newline at end of file diff --git a/test/misc5.test b/test/misc5.test index 0307c3bb07..84aa9586d3 100644 --- a/test/misc5.test +++ b/test/misc5.test @@ -569,11 +569,11 @@ ifcapable subquery&&compound { } # Overflow the lemon parser stack by providing an overly complex -# expression. Make sure that the overflow is detected and reported. +# expression. Make sure that the overflow is detected and the +# stack is grown automatically such that the application calling +# SQLite never notices. # -# This test fails when building with -DYYSTACKDEPTH=0 -# -do_test misc5-7.1 { +do_test misc5-7.1.1 { execsql {CREATE TABLE t1(x)} set sql "INSERT INTO t1 VALUES(" set tail "" @@ -581,9 +581,21 @@ do_test misc5-7.1 { append sql "(1+" append tail ")" } - append sql 2$tail) + append sql "0$tail); SELECT * FROM t1;" catchsql $sql -} {0 {}} +} {0 200} +do_test misc5-7.1.2 { + execsql {DELETE FROM t1} + set sql "INSERT INTO t1 VALUES(" + set tail "" + for {set i 0} {$i<900} {incr i} { + append sql "(1+" + append tail ")" + } + append sql "0$tail); SELECT * FROM t1;" + catchsql $sql +} {0 900} + # Parser stack overflow is silently ignored when it occurs while parsing the # schema and PRAGMA writable_schema is turned on. From d921533954deeea925b73e3f5fe9d6e2aff194ef Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 28 Jan 2024 00:31:47 +0000 Subject: [PATCH 0058/1030] Apply the same fix found in [99057383acc8f920] to descending scans. dbsqlfuzz afd1d61fc27d14938a0d78a50970fa1e9fbfee5. FossilOrigin-Name: e1d463c2d6e93e0ae0a60a05a79cd346bd07142de2fe631b370a9b946763b5d6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e5e4ee4b4c..75cb44bb83 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sparser\sstack\soverflow\stesting.\n[forum:/forumpost/99e181b5bf|Forum\spost\s99e181b5bf]. -D 2024-01-27T20:17:05.552 +C Apply\sthe\ssame\sfix\sfound\sin\s[99057383acc8f920]\sto\sdescending\sscans.\ndbsqlfuzz\safd1d61fc27d14938a0d78a50970fa1e9fbfee5. +D 2024-01-28T00:31:47.406 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -677,7 +677,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c dee25e097b749275333b55d64a5ffc079249576f8e88a2ee476468cf67510f4b +F src/btree.c c64df2b1623501e397128261de58d3ab44c301e4eb993a4055aa971444420200 F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 F src/build.c 05c9eb387638982092988d2ef4c00a91b0c29baa1b85923f082ce0cf2903ea7e @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2db8b30acdeaeaf7ec92dc0382a25f96bca4561fb68a72713ff963e27f39c63b -R 605333aa92af75374c12db2870558f0c +P 556c43a937f1d1c19117da24e6d892852241189f4e47e1c86aa1e8c36461c5de +R e3e119e442083642e5cebf8de0f05474 U drh -Z 624bf4ea7db4f65352370ddfed55f7bd +Z fd7b7cdec324b3b49688cdf78a121ede # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dc3d7b8571..640a499850 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -556c43a937f1d1c19117da24e6d892852241189f4e47e1c86aa1e8c36461c5de \ No newline at end of file +e1d463c2d6e93e0ae0a60a05a79cd346bd07142de2fe631b370a9b946763b5d6 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 907e37f1ea..c41fb811ab 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6280,7 +6280,10 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){ } pPage = pCur->pPage; - assert( pPage->isInit ); + if( sqlite3FaultSim(412) ) pPage->isInit = 0; + if( !pPage->isInit ){ + return SQLITE_CORRUPT_BKPT; + } if( !pPage->leaf ){ int idx = pCur->ix; rc = moveToChild(pCur, get4byte(findCell(pPage, idx))); From 5b480ead99fdc720f28fc0d6e32f1f0d3be22626 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 28 Jan 2024 17:39:31 +0000 Subject: [PATCH 0059/1030] Automatically disable the DISTINCT optimization during query planning if the ORDER BY clause exceeds 63 terms. dbsqlfuzz afd1d61fc27d14938a0d78a50970fa1e9fbfee58. FossilOrigin-Name: d4c193f0b49f4950b20c2f0e6aa037d2ed7d8c0b4687c14923b3a0d0d4a1b3fd --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 75cb44bb83..28c1a5ea28 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Apply\sthe\ssame\sfix\sfound\sin\s[99057383acc8f920]\sto\sdescending\sscans.\ndbsqlfuzz\safd1d61fc27d14938a0d78a50970fa1e9fbfee5. -D 2024-01-28T00:31:47.406 +C Automatically\sdisable\sthe\sDISTINCT\soptimization\sduring\squery\splanning\sif\sthe\nORDER\sBY\sclause\sexceeds\s63\sterms.\ndbsqlfuzz\safd1d61fc27d14938a0d78a50970fa1e9fbfee58. +D 2024-01-28T17:39:31.983 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -823,7 +823,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 217fe82a26c0fb6a3c7fd01865d821e752f9c01fb72f114af3f0b77ce234d1fb +F src/where.c 56277e7110e6c81918434908bb7d597b917adfa9a176f5d95eb954b93dbc57b8 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c dc5096eca5ed503999be3bdee8a90c51361289a678d396a220912e9cb73b3c00 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 556c43a937f1d1c19117da24e6d892852241189f4e47e1c86aa1e8c36461c5de -R e3e119e442083642e5cebf8de0f05474 +P e1d463c2d6e93e0ae0a60a05a79cd346bd07142de2fe631b370a9b946763b5d6 +R 1851f2761162021fbdb85251d9cef861 U drh -Z fd7b7cdec324b3b49688cdf78a121ede +Z 6fb9920f7dfa3ef526a5d4c61ad97c08 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 640a499850..db47f3ca2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1d463c2d6e93e0ae0a60a05a79cd346bd07142de2fe631b370a9b946763b5d6 \ No newline at end of file +d4c193f0b49f4950b20c2f0e6aa037d2ed7d8c0b4687c14923b3a0d0d4a1b3fd \ No newline at end of file diff --git a/src/where.c b/src/where.c index 4ff2815ba8..77813666e6 100644 --- a/src/where.c +++ b/src/where.c @@ -6056,7 +6056,10 @@ WhereInfo *sqlite3WhereBegin( /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ testcase( pOrderBy && pOrderBy->nExpr==BMS-1 ); - if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0; + if( pOrderBy && pOrderBy->nExpr>=BMS ){ + pOrderBy = 0; + wctrlFlags &= ~WHERE_WANT_DISTINCT; + } /* The number of tables in the FROM clause is limited by the number of ** bits in a Bitmask From 4c11a5251a084d307ab11a458749408a5623fd9e Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 28 Jan 2024 20:42:12 +0000 Subject: [PATCH 0060/1030] Use __ppc__ instead of __POWERPC__ to identify 32-bit PowerPC processors. [forum:/forumpost/34794846ce|Forum post 34794846ce]. FossilOrigin-Name: c974d9313b60591bcd554c3ec652a8040d382930e30778e6be8a875145b0b3da --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 28c1a5ea28..83633961ec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Automatically\sdisable\sthe\sDISTINCT\soptimization\sduring\squery\splanning\sif\sthe\nORDER\sBY\sclause\sexceeds\s63\sterms.\ndbsqlfuzz\safd1d61fc27d14938a0d78a50970fa1e9fbfee58. -D 2024-01-28T17:39:31.983 +C Use\s__ppc__\sinstead\sof\s__POWERPC__\sto\sidentify\s32-bit\sPowerPC\sprocessors.\n[forum:/forumpost/34794846ce|Forum\spost\s34794846ce]. +D 2024-01-28T20:42:12.641 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -743,7 +743,7 @@ F src/shell.c.in c6cb773b7703d76677529de19d1c40584520701966422c33da3e9334498a709 F src/sqlite.h.in 61a60b4ea04db8ead15e1579b20b64cb56e9f55d52c5f9f9694de630110593a3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 03e64e4a973f56035772421e94be7bf092ceceeb3dc91a74a2147030a822c392 +F src/sqliteInt.h 5013ac1f5642df4c0b76314f507f4c7b6f8efee0e1d7c2e93bf8b445ceea29bb F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e1d463c2d6e93e0ae0a60a05a79cd346bd07142de2fe631b370a9b946763b5d6 -R 1851f2761162021fbdb85251d9cef861 +P d4c193f0b49f4950b20c2f0e6aa037d2ed7d8c0b4687c14923b3a0d0d4a1b3fd +R 46f9da2da907badd19298ace66a20031 U drh -Z 6fb9920f7dfa3ef526a5d4c61ad97c08 +Z c2041b302fcfe4f462cbcda587ab473e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index db47f3ca2c..f8126df887 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d4c193f0b49f4950b20c2f0e6aa037d2ed7d8c0b4687c14923b3a0d0d4a1b3fd \ No newline at end of file +c974d9313b60591bcd554c3ec652a8040d382930e30778e6be8a875145b0b3da \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 06253cdd23..9d9657f3cc 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -886,7 +886,7 @@ typedef INT16_TYPE LogEst; # define SQLITE_PTRSIZE __SIZEOF_POINTER__ # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ defined(_M_ARM) || defined(__arm__) || defined(__x86) || \ - (defined(__APPLE__) && defined(__POWERPC__)) || \ + (defined(__APPLE__) && defined(__ppc__)) || \ (defined(__TOS_AIX__) && !defined(__64BIT__)) # define SQLITE_PTRSIZE 4 # else From 3fc7a34efc5b840c069a4d55f61f14b3d68df85b Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 29 Jan 2024 12:50:32 +0000 Subject: [PATCH 0061/1030] When rendering JSONB back into text JSON, report an error if a zero-length integer or floating-point node is encountered. Otherwise, if the node occurs at the very end of the JSONB, the rendering logic might read one byte past the end of the initialized part of the BLOB byte array. OSSFuzz 66284. FossilOrigin-Name: b0eb279ea83c1c788c39fb90e178ec99fa4c782195c376a420c661fedf4545a7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 83633961ec..e575ca5555 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\s__ppc__\sinstead\sof\s__POWERPC__\sto\sidentify\s32-bit\sPowerPC\sprocessors.\n[forum:/forumpost/34794846ce|Forum\spost\s34794846ce]. -D 2024-01-28T20:42:12.641 +C When\srendering\sJSONB\sback\sinto\stext\sJSON,\sreport\san\serror\sif\sa\szero-length\ninteger\sor\sfloating-point\snode\sis\sencountered.\s\sOtherwise,\sif\sthe\snode\soccurs\nat\sthe\svery\send\sof\sthe\sJSONB,\sthe\srendering\slogic\smight\sread\sone\sbyte\spast\nthe\send\sof\sthe\sinitialized\spart\sof\sthe\sBLOB\sbyte\sarray.\s\sOSSFuzz\s66284. +D 2024-01-29T12:50:32.533 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c b2189995bb2f5eeac20a0282983cc82198fc77f9429708468ba360bbacb6fa80 +F src/json.c bf20b47d110aa0ea316e0ab77ccb407bd9c73eac2604e8d238823ceedd270d5b F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d4c193f0b49f4950b20c2f0e6aa037d2ed7d8c0b4687c14923b3a0d0d4a1b3fd -R 46f9da2da907badd19298ace66a20031 +P c974d9313b60591bcd554c3ec652a8040d382930e30778e6be8a875145b0b3da +R 0207b7627e17db2286de3e2f665c21a5 U drh -Z c2041b302fcfe4f462cbcda587ab473e +Z b94072d2a610a36c15c6ae7e7c61c766 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f8126df887..d6e164585f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c974d9313b60591bcd554c3ec652a8040d382930e30778e6be8a875145b0b3da \ No newline at end of file +b0eb279ea83c1c788c39fb90e178ec99fa4c782195c376a420c661fedf4545a7 \ No newline at end of file diff --git a/src/json.c b/src/json.c index c7412d3c78..d69d967934 100644 --- a/src/json.c +++ b/src/json.c @@ -2124,6 +2124,7 @@ static u32 jsonTranslateBlobToText( } case JSONB_INT: case JSONB_FLOAT: { + if( sz==0 ) goto malformed_jsonb; jsonAppendRaw(pOut, (const char*)&pParse->aBlob[i+n], sz); break; } @@ -2132,6 +2133,7 @@ static u32 jsonTranslateBlobToText( sqlite3_uint64 u = 0; const char *zIn = (const char*)&pParse->aBlob[i+n]; int bOverflow = 0; + if( sz==0 ) goto malformed_jsonb; if( zIn[0]=='-' ){ jsonAppendChar(pOut, '-'); k++; @@ -2154,6 +2156,7 @@ static u32 jsonTranslateBlobToText( case JSONB_FLOAT5: { /* Float literal missing digits beside "." */ u32 k = 0; const char *zIn = (const char*)&pParse->aBlob[i+n]; + if( sz==0 ) goto malformed_jsonb; if( zIn[0]=='-' ){ jsonAppendChar(pOut, '-'); k++; @@ -2291,6 +2294,7 @@ static u32 jsonTranslateBlobToText( } default: { + malformed_jsonb: pOut->eErr |= JSTRING_MALFORMED; break; } From 7f9a1ff3f2f909773ea7861425046fc0286508f2 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 Jan 2024 15:30:35 +0000 Subject: [PATCH 0062/1030] Avoid a potential buffer overread when handling corrupt json blobs. FossilOrigin-Name: 738473dc0ac353731080d0785cc7dc9810b564906c176916bd91d6cfbb1a7b18 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/json.c | 4 ++-- test/jsonb01.test | 4 ++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index e575ca5555..60e0deb91e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\srendering\sJSONB\sback\sinto\stext\sJSON,\sreport\san\serror\sif\sa\szero-length\ninteger\sor\sfloating-point\snode\sis\sencountered.\s\sOtherwise,\sif\sthe\snode\soccurs\nat\sthe\svery\send\sof\sthe\sJSONB,\sthe\srendering\slogic\smight\sread\sone\sbyte\spast\nthe\send\sof\sthe\sinitialized\spart\sof\sthe\sBLOB\sbyte\sarray.\s\sOSSFuzz\s66284. -D 2024-01-29T12:50:32.533 +C Avoid\sa\spotential\sbuffer\soverread\swhen\shandling\scorrupt\sjson\sblobs. +D 2024-01-29T15:30:35.428 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c bf20b47d110aa0ea316e0ab77ccb407bd9c73eac2604e8d238823ceedd270d5b +F src/json.c 1658ff90bc260a5dbbfcbfafa0b18f34076d3dbf1ac84e31dc4a1cd0c569e7e8 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -1345,7 +1345,7 @@ F test/json106.test 1d46a9294e2ced35c7f87cebbcb9626d01abab04f1969d7ded7b6f6a1d9b F test/json107.test 59054e815c8f6b67d634d44ace421cf975828fb5651c4460aa66015c8e19d562 F test/json501.test ab168a12eb6eb14d479f8c1cdae3ac062fd5a4679f17f976e96f1af518408330 F test/json502.test 84634d3dbb521d2814e43624025b760c6198456c8197bbec6c977c0236648f5b -F test/jsonb01.test cace70765b36a36aec9a85a41ea65667d3bbf647d4400ddc3ac76f8fe7d94f90 +F test/jsonb01.test f4cdfb4cf5a0c940091b17675ed9583f45add0c938f07d65b0de0e19d3a9a101 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff F test/kvtest.c 6e0228409ea7ca0497dad503fbd109badb5e59545d131014b6aaac68b56f484a F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c974d9313b60591bcd554c3ec652a8040d382930e30778e6be8a875145b0b3da -R 0207b7627e17db2286de3e2f665c21a5 -U drh -Z b94072d2a610a36c15c6ae7e7c61c766 +P b0eb279ea83c1c788c39fb90e178ec99fa4c782195c376a420c661fedf4545a7 +R 3e003ebc54133c42f113fbce024a5a22 +U dan +Z b1da7a8f3b87229f95a14c44f483cdeb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d6e164585f..60d0910ce9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b0eb279ea83c1c788c39fb90e178ec99fa4c782195c376a420c661fedf4545a7 \ No newline at end of file +738473dc0ac353731080d0785cc7dc9810b564906c176916bd91d6cfbb1a7b18 \ No newline at end of file diff --git a/src/json.c b/src/json.c index d69d967934..94f5a3ef93 100644 --- a/src/json.c +++ b/src/json.c @@ -2073,8 +2073,8 @@ static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){ (pParse->aBlob[i+7]<<8) + pParse->aBlob[i+8]; n = 9; } - if( i+sz+n > pParse->nBlob - && i+sz+n > pParse->nBlob-pParse->delta + if( (i64)i+sz+n > pParse->nBlob + && (i64)i+sz+n > pParse->nBlob-pParse->delta ){ sz = 0; n = 0; diff --git a/test/jsonb01.test b/test/jsonb01.test index d1b53ae6cc..8f16428dcc 100644 --- a/test/jsonb01.test +++ b/test/jsonb01.test @@ -46,4 +46,8 @@ foreach {id path res} { } $res } +do_catchsql_test jsonb01-2.0 { + SELECT x'8ce6ffffffff171333' -> '$'; +} {1 {malformed JSON}} + finish_test From 581bf002ce9c979bce7b994de6e29746509c89be Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 Jan 2024 19:30:16 +0000 Subject: [PATCH 0063/1030] Consider an index for queries like "SELECT count(DISTINCT col) FROM ...", even if the index records are not smaller than the table records. FossilOrigin-Name: ad06868807a27f0c96fa5649ebd981e07909eb2c5e03781377c876fdec49abdc --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 4 +++- test/distinctagg.test | 9 ++++++++- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 60e0deb91e..bd32d81585 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sa\spotential\sbuffer\soverread\swhen\shandling\scorrupt\sjson\sblobs. -D 2024-01-29T15:30:35.428 +C Consider\san\sindex\sfor\squeries\slike\s"SELECT\scount(DISTINCT\scol)\sFROM\s...",\seven\sif\sthe\sindex\srecords\sare\snot\ssmaller\sthan\sthe\stable\srecords. +D 2024-01-29T19:30:16.573 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -823,7 +823,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 56277e7110e6c81918434908bb7d597b917adfa9a176f5d95eb954b93dbc57b8 +F src/where.c e38e37677884d644b825fe0ab72379a24a9a74f89d8add5eb134d61fea2358a3 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c dc5096eca5ed503999be3bdee8a90c51361289a678d396a220912e9cb73b3c00 @@ -1056,7 +1056,7 @@ F test/descidx3.test 953c831df7ea219c73826dfbf2f6ee02d95040725aa88ccb4fa43d1a199 F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e F test/distinct.test 691c9e850b0d0b56b66e7e235453198cb4cf0760e324b7403d3c5abbeab0a014 F test/distinct2.test bb71cc7b5e58e895787f9910a788c254f679928d324732d063fe9bc202ecbe71 -F test/distinctagg.test ad2b4cf1483cd4cf24867dfafbfa0abb61184d92085fcc9784cea0592b278d64 +F test/distinctagg.test 40d7169ae5846caaf62c6e307d2ca3c333daf9b6f7cde888956a339a97afe85f F test/e_blobbytes.test 4c01dfe4f12087b92b20705a3fdfded45dc4ed16d5a211fed4e1d2786ba68a52 F test/e_blobclose.test 692fc02a058476c2222a63d97e3f3b2b809c1842e5525ded7f854d540ac2e075 F test/e_blobopen.test 29f6055ee453b8e679fe9570c4d3acfedbef821622c5dad16875148c5952ef50 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b0eb279ea83c1c788c39fb90e178ec99fa4c782195c376a420c661fedf4545a7 -R 3e003ebc54133c42f113fbce024a5a22 +P 738473dc0ac353731080d0785cc7dc9810b564906c176916bd91d6cfbb1a7b18 +R f1c37c0e5edda3118ed05f6a7a2d3df0 U dan -Z b1da7a8f3b87229f95a14c44f483cdeb +Z 6c6c135247ccb8a93d3af9a3896ff5b2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 60d0910ce9..1ec528d5a1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -738473dc0ac353731080d0785cc7dc9810b564906c176916bd91d6cfbb1a7b18 \ No newline at end of file +ad06868807a27f0c96fa5649ebd981e07909eb2c5e03781377c876fdec49abdc \ No newline at end of file diff --git a/src/where.c b/src/where.c index 77813666e6..b0fe12e52b 100644 --- a/src/where.c +++ b/src/where.c @@ -3362,7 +3362,9 @@ static int indexMightHelpWithOrderBy( for(ii=0; iinExpr; ii++){ Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr); if( NEVER(pExpr==0) ) continue; - if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){ + if( (pExpr->op==TK_COLUMN || pExpr->op==TK_AGG_COLUMN) + && pExpr->iTable==iCursor + ){ if( pExpr->iColumn<0 ) return 1; for(jj=0; jjnKeyCol; jj++){ if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1; diff --git a/test/distinctagg.test b/test/distinctagg.test index 199ca0666e..9eedd35bd2 100644 --- a/test/distinctagg.test +++ b/test/distinctagg.test @@ -95,7 +95,7 @@ foreach {tn use_eph sql res} { 7 0 "SELECT count(DISTINCT a) FROM t2, t1" 5 8 1 "SELECT count(DISTINCT a+b) FROM t1, t2, t2, t2" 6 9 0 "SELECT count(DISTINCT c) FROM t1 WHERE c=2" 1 - 10 1 "SELECT count(DISTINCT t1.rowid) FROM t1, t2" 10 + 10 0 "SELECT count(DISTINCT t1.rowid) FROM t1, t2" 10 } { do_test 3.$tn.1 { set prg [db eval "EXPLAIN $sql"] @@ -148,6 +148,10 @@ do_execsql_test 3.0 { CREATE TABLE t3(x, y, z); INSERT INTO t3 VALUES(1,1,1); INSERT INTO t3 VALUES(2,2,2); + + CREATE TABLE t4(a); + CREATE INDEX t4a ON t4(a); + INSERT INTO t4 VALUES(1), (2), (2), (3), (1); } foreach {tn use_eph sql res} { @@ -158,6 +162,9 @@ foreach {tn use_eph sql res} { 4 0 "SELECT count(DISTINCT f) FROM t2 GROUP BY d, e" {1 2 2 3} 5 1 "SELECT count(DISTINCT f) FROM t2 GROUP BY d" {2 3} 6 0 "SELECT count(DISTINCT f) FROM t2 WHERE d IS 1 GROUP BY e" {1 2 2} + + 7 0 "SELECT count(DISTINCT a) FROM t1" {4} + 8 0 "SELECT count(DISTINCT a) FROM t4" {3} } { do_test 4.$tn.1 { set prg [db eval "EXPLAIN $sql"] From af3824d5fa56c7ab892dda7f929940a6eaa66b35 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 29 Jan 2024 20:36:17 +0000 Subject: [PATCH 0064/1030] When generated text JSON from JSONB, do not continue descending into nested structures after an error is seen. This avoids long loops and wait times. FossilOrigin-Name: 97666ec052ebaceab002874d7ca5c5e6883c3d04fb7d3992235a8c4c8d08407a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/json.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index bd32d81585..5fcb117e2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Consider\san\sindex\sfor\squeries\slike\s"SELECT\scount(DISTINCT\scol)\sFROM\s...",\seven\sif\sthe\sindex\srecords\sare\snot\ssmaller\sthan\sthe\stable\srecords. -D 2024-01-29T19:30:16.573 +C When\sgenerated\stext\sJSON\sfrom\sJSONB,\sdo\snot\scontinue\sdescending\sinto\nnested\sstructures\safter\san\serror\sis\sseen.\s\sThis\savoids\slong\sloops\sand\swait\ntimes. +D 2024-01-29T20:36:17.909 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 1658ff90bc260a5dbbfcbfafa0b18f34076d3dbf1ac84e31dc4a1cd0c569e7e8 +F src/json.c 25472b53ce9a07f2fd1388714596ab0a1cf626c9af8829fe1d9f6e2040a8d6f5 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 738473dc0ac353731080d0785cc7dc9810b564906c176916bd91d6cfbb1a7b18 -R f1c37c0e5edda3118ed05f6a7a2d3df0 -U dan -Z 6c6c135247ccb8a93d3af9a3896ff5b2 +P ad06868807a27f0c96fa5649ebd981e07909eb2c5e03781377c876fdec49abdc +R 62cbadfc42bb4fb45ef8f78c92a43c6e +U drh +Z 909c63b99a1f269d1aa20de0ece0fbe3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1ec528d5a1..4794e80ce4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad06868807a27f0c96fa5649ebd981e07909eb2c5e03781377c876fdec49abdc \ No newline at end of file +97666ec052ebaceab002874d7ca5c5e6883c3d04fb7d3992235a8c4c8d08407a \ No newline at end of file diff --git a/src/json.c b/src/json.c index 94f5a3ef93..2f0243651c 100644 --- a/src/json.c +++ b/src/json.c @@ -2270,7 +2270,7 @@ static u32 jsonTranslateBlobToText( jsonAppendChar(pOut, '['); j = i+n; iEnd = j+sz; - while( jeErr==0 ){ j = jsonTranslateBlobToText(pParse, j, pOut); jsonAppendChar(pOut, ','); } @@ -2283,7 +2283,7 @@ static u32 jsonTranslateBlobToText( jsonAppendChar(pOut, '{'); j = i+n; iEnd = j+sz; - while( jeErr==0 ){ j = jsonTranslateBlobToText(pParse, j, pOut); jsonAppendChar(pOut, (x++ & 1) ? ',' : ':'); } From 91981fe74e223f3fec2b354535e9fac437868765 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 29 Jan 2024 21:09:56 +0000 Subject: [PATCH 0065/1030] Detect malformed nested JSONB earlier and stop rendering to avoid long delays. FossilOrigin-Name: 72f3e1d0eca2b9ebd7c4b4cdccc6d7a0173b2fdb204cb1aa207917aedab6098a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5fcb117e2b..4733a4c7ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sgenerated\stext\sJSON\sfrom\sJSONB,\sdo\snot\scontinue\sdescending\sinto\nnested\sstructures\safter\san\serror\sis\sseen.\s\sThis\savoids\slong\sloops\sand\swait\ntimes. -D 2024-01-29T20:36:17.909 +C Detect\smalformed\snested\sJSONB\searlier\sand\sstop\srendering\sto\savoid\slong\ndelays. +D 2024-01-29T21:09:56.917 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 25472b53ce9a07f2fd1388714596ab0a1cf626c9af8829fe1d9f6e2040a8d6f5 +F src/json.c 4f824b70a65c426f4ff518f99adb9b4fb97d6c8692e59c4525cae453972853f5 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ad06868807a27f0c96fa5649ebd981e07909eb2c5e03781377c876fdec49abdc -R 62cbadfc42bb4fb45ef8f78c92a43c6e +P 97666ec052ebaceab002874d7ca5c5e6883c3d04fb7d3992235a8c4c8d08407a +R 95e4cc745d61f1468c48968bf1c52952 U drh -Z 909c63b99a1f269d1aa20de0ece0fbe3 +Z e9314520b095df0616cee88d0104a95d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4794e80ce4..093286cae5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -97666ec052ebaceab002874d7ca5c5e6883c3d04fb7d3992235a8c4c8d08407a \ No newline at end of file +72f3e1d0eca2b9ebd7c4b4cdccc6d7a0173b2fdb204cb1aa207917aedab6098a \ No newline at end of file diff --git a/src/json.c b/src/json.c index 2f0243651c..b683e65a9d 100644 --- a/src/json.c +++ b/src/json.c @@ -2274,6 +2274,7 @@ static u32 jsonTranslateBlobToText( j = jsonTranslateBlobToText(pParse, j, pOut); jsonAppendChar(pOut, ','); } + if( j>iEnd ) pOut->eErr |= JSTRING_MALFORMED; if( sz>0 ) jsonStringTrimOneChar(pOut); jsonAppendChar(pOut, ']'); break; @@ -2287,7 +2288,7 @@ static u32 jsonTranslateBlobToText( j = jsonTranslateBlobToText(pParse, j, pOut); jsonAppendChar(pOut, (x++ & 1) ? ',' : ':'); } - if( x & 1 ) pOut->eErr |= JSTRING_MALFORMED; + if( (x & 1)!=0 || j>iEnd ) pOut->eErr |= JSTRING_MALFORMED; if( sz>0 ) jsonStringTrimOneChar(pOut); jsonAppendChar(pOut, '}'); break; From b202a452ad2fd66430dd7d1375ed611cf753f982 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jan 2024 12:15:57 +0000 Subject: [PATCH 0066/1030] Fix a memory allocation bug in the (debug-use-only) json_parse() SQL function. FossilOrigin-Name: 32ce7dacf58bbf35cf70da8b03fa25f97fcea970edbc1f8aa12739ac4c8608fb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4733a4c7ee..2604713c72 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Detect\smalformed\snested\sJSONB\searlier\sand\sstop\srendering\sto\savoid\slong\ndelays. -D 2024-01-29T21:09:56.917 +C Fix\sa\smemory\sallocation\sbug\sin\sthe\s(debug-use-only)\sjson_parse()\sSQL\sfunction. +D 2024-01-31T12:15:57.302 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 4f824b70a65c426f4ff518f99adb9b4fb97d6c8692e59c4525cae453972853f5 +F src/json.c 192c5e5013607b14441a738f0bd73e9df057b13eeac4060b679b32021a25e018 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 97666ec052ebaceab002874d7ca5c5e6883c3d04fb7d3992235a8c4c8d08407a -R 95e4cc745d61f1468c48968bf1c52952 +P 72f3e1d0eca2b9ebd7c4b4cdccc6d7a0173b2fdb204cb1aa207917aedab6098a +R 1df2c3fb322d8908152fe23b99fe1f47 U drh -Z e9314520b095df0616cee88d0104a95d +Z d967a8cc96a8b8a2072c7fb0795b6f21 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 093286cae5..048895706f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -72f3e1d0eca2b9ebd7c4b4cdccc6d7a0173b2fdb204cb1aa207917aedab6098a \ No newline at end of file +32ce7dacf58bbf35cf70da8b03fa25f97fcea970edbc1f8aa12739ac4c8608fb \ No newline at end of file diff --git a/src/json.c b/src/json.c index b683e65a9d..8f8196bd75 100644 --- a/src/json.c +++ b/src/json.c @@ -3552,11 +3552,12 @@ static void jsonParseFunc( if( p==0 ) return; if( argc==1 ){ jsonDebugPrintBlob(p, 0, p->nBlob, 0, &out); - sqlite3_result_text64(ctx, out.zText, out.nChar, SQLITE_DYNAMIC, SQLITE_UTF8); + sqlite3_result_text64(ctx,out.zText,out.nChar,SQLITE_TRANSIENT,SQLITE_UTF8); }else{ jsonShowParse(p); } jsonParseFree(p); + sqlite3_str_reset(&out); } #endif /* SQLITE_DEBUG */ From c24f53635c3b17f732119a224255c61edc90a089 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jan 2024 13:46:44 +0000 Subject: [PATCH 0067/1030] Allow control characters in JSON5 string literals. [forum:/forumpost/05182119f69c3a92|Forum thread 05182119f69c3a92]. FossilOrigin-Name: 34709c7cc910539e23a830ad8b589a97a88be25e924a59670c1017fb51447dad --- manifest | 14 ++++----- manifest.uuid | 2 +- src/json.c | 78 +++++++++++++++++++++++++++++++---------------- test/json501.test | 27 ++++++++++++++++ 4 files changed, 86 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index 2604713c72..e88859a0db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sallocation\sbug\sin\sthe\s(debug-use-only)\sjson_parse()\sSQL\sfunction. -D 2024-01-31T12:15:57.302 +C Allow\scontrol\scharacters\sin\sJSON5\sstring\sliterals.\n[forum:/forumpost/05182119f69c3a92|Forum\sthread\s05182119f69c3a92]. +D 2024-01-31T13:46:44.886 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 192c5e5013607b14441a738f0bd73e9df057b13eeac4060b679b32021a25e018 +F src/json.c 366c4502167672d9ded0d45b1a955acb487ddabb531e889a7b8901fd3e46d013 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -1343,7 +1343,7 @@ F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba01143 F test/json105.test 043838b56e68f3252a0dcf5be1689016f6f3f05056f8dcfcdc9d074f4d932988 F test/json106.test 1d46a9294e2ced35c7f87cebbcb9626d01abab04f1969d7ded7b6f6a1d9be0f2 F test/json107.test 59054e815c8f6b67d634d44ace421cf975828fb5651c4460aa66015c8e19d562 -F test/json501.test ab168a12eb6eb14d479f8c1cdae3ac062fd5a4679f17f976e96f1af518408330 +F test/json501.test b95e2d14988b682a5cadf079dd6162f0f85fb74cd59c6b1f1624110104a974eb F test/json502.test 84634d3dbb521d2814e43624025b760c6198456c8197bbec6c977c0236648f5b F test/jsonb01.test f4cdfb4cf5a0c940091b17675ed9583f45add0c938f07d65b0de0e19d3a9a101 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 72f3e1d0eca2b9ebd7c4b4cdccc6d7a0173b2fdb204cb1aa207917aedab6098a -R 1df2c3fb322d8908152fe23b99fe1f47 +P 32ce7dacf58bbf35cf70da8b03fa25f97fcea970edbc1f8aa12739ac4c8608fb +R c7867d5f34f471f1c203d9ecfab6ff98 U drh -Z d967a8cc96a8b8a2072c7fb0795b6f21 +Z a250ac8f403a1bdc996f04e6b4453df0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 048895706f..aea1dec179 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32ce7dacf58bbf35cf70da8b03fa25f97fcea970edbc1f8aa12739ac4c8608fb \ No newline at end of file +34709c7cc910539e23a830ad8b589a97a88be25e924a59670c1017fb51447dad \ No newline at end of file diff --git a/src/json.c b/src/json.c index 8f8196bd75..d585189902 100644 --- a/src/json.c +++ b/src/json.c @@ -621,6 +621,40 @@ static void jsonAppendSeparator(JsonString *p){ jsonAppendChar(p, ','); } +/* c is a control character. Append the canonical JSON representation +** of that control character to p. +** +** This routine assumes that the output buffer has already been enlarged +** sufficiently to hold the worst-case encoding plus a nul terminator. +*/ +static void jsonAppendControlChar(JsonString *p, u8 c){ + static const char aSpecial[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + assert( sizeof(aSpecial)==32 ); + assert( aSpecial['\b']=='b' ); + assert( aSpecial['\f']=='f' ); + assert( aSpecial['\n']=='n' ); + assert( aSpecial['\r']=='r' ); + assert( aSpecial['\t']=='t' ); + assert( c>=0 && cnUsed+7 <= p->nAlloc ); + if( aSpecial[c] ){ + p->zBuf[p->nUsed] = '\\'; + p->zBuf[p->nUsed+1] = aSpecial[c]; + p->nUsed += 2; + }else{ + p->zBuf[p->nUsed] = '\\'; + p->zBuf[p->nUsed+1] = 'u'; + p->zBuf[p->nUsed+2] = '0'; + p->zBuf[p->nUsed+3] = '0'; + p->zBuf[p->nUsed+4] = "0123456789abcdef"[c>>4]; + p->zBuf[p->nUsed+5] = "0123456789abcdef"[c&0xf]; + p->nUsed += 6; + } +} + /* Append the N-byte string in zIn to the end of the JsonString string ** under construction. Enclose the string in double-quotes ("...") and ** escape any double-quotes or backslash characters contained within the @@ -680,35 +714,14 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ } c = z[0]; if( c=='"' || c=='\\' ){ - json_simple_escape: if( (p->nUsed+N+3 > p->nAlloc) && jsonStringGrow(p,N+3)!=0 ) return; p->zBuf[p->nUsed++] = '\\'; p->zBuf[p->nUsed++] = c; }else if( c=='\'' ){ p->zBuf[p->nUsed++] = c; }else{ - static const char aSpecial[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - assert( sizeof(aSpecial)==32 ); - assert( aSpecial['\b']=='b' ); - assert( aSpecial['\f']=='f' ); - assert( aSpecial['\n']=='n' ); - assert( aSpecial['\r']=='r' ); - assert( aSpecial['\t']=='t' ); - assert( c>=0 && cnUsed+N+7 > p->nAlloc) && jsonStringGrow(p,N+7)!=0 ) return; - p->zBuf[p->nUsed++] = '\\'; - p->zBuf[p->nUsed++] = 'u'; - p->zBuf[p->nUsed++] = '0'; - p->zBuf[p->nUsed++] = '0'; - p->zBuf[p->nUsed++] = "0123456789abcdef"[c>>4]; - p->zBuf[p->nUsed++] = "0123456789abcdef"[c&0xf]; + jsonAppendControlChar(p, c); } z++; N--; @@ -1409,6 +1422,9 @@ static u32 jsonbValidityCheck( if( !jsonIsOk[z[j]] && z[j]!='\'' ){ if( z[j]=='"' ){ if( x==JSONB_TEXTJ ) return j+1; + }else if( z[j]<=0x1f ){ + /* Control characters in JSON5 string literals are ok */ + if( x==JSONB_TEXTJ ) return j+1; }else if( z[j]!='\\' || j+1>=k ){ return j+1; }else if( strchr("\"\\/bfnrt",z[j+1])!=0 ){ @@ -1703,9 +1719,10 @@ static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){ return -1; } }else if( c<=0x1f ){ - /* Control characters are not allowed in strings */ - pParse->iErr = j; - return -1; + /* Control characters are not allowed in canonical JSON string + ** literals, but are allowed in JSON5 string literals. */ + opcode = JSONB_TEXT5; + pParse->hasNonstd = 1; }else if( c=='"' ){ opcode = JSONB_TEXT5; } @@ -2186,7 +2203,7 @@ static u32 jsonTranslateBlobToText( zIn = (const char*)&pParse->aBlob[i+n]; jsonAppendChar(pOut, '"'); while( sz2>0 ){ - for(k=0; k0 ){ jsonAppendRawNZ(pOut, zIn, k); if( k>=sz2 ){ @@ -2201,6 +2218,13 @@ static u32 jsonTranslateBlobToText( sz2--; continue; } + if( zIn[0]<=0x1f ){ + if( pOut->nUsed+7nAlloc && jsonStringGrow(pOut,7) ) break; + jsonAppendControlChar(pOut, zIn[0]); + zIn++; + sz2--; + continue; + } assert( zIn[0]=='\\' ); assert( sz2>=1 ); if( sz2<2 ){ @@ -4391,7 +4415,7 @@ static void jsonErrorFunc( /* Convert byte-offset s.iErr into a character offset */ u32 k; assert( s.zJson!=0 ); /* Because s.oom is false */ - for(k=0; k '$'; + } "{{\"label\":\"abc${e}xyz\"}}" +} + + finish_test From 9486178f39fe31e24ead8a196cf158829f78daf3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jan 2024 14:44:59 +0000 Subject: [PATCH 0068/1030] Fix failure to detect unterminated string literals in json_valid() in the previous check-in. FossilOrigin-Name: 5d725644621cf640fb743d59ccf89dac777540410e67501eb00b83638c8c857f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index e88859a0db..33bf52c0d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\scontrol\scharacters\sin\sJSON5\sstring\sliterals.\n[forum:/forumpost/05182119f69c3a92|Forum\sthread\s05182119f69c3a92]. -D 2024-01-31T13:46:44.886 +C Fix\sfailure\sto\sdetect\sunterminated\sstring\sliterals\sin\sjson_valid()\sin\sthe\nprevious\scheck-in. +D 2024-01-31T14:44:59.052 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 366c4502167672d9ded0d45b1a955acb487ddabb531e889a7b8901fd3e46d013 +F src/json.c 24f2517b5dc7e678ee3006eaa0c0e6b13ff90e71849f8c4064134eb28a97f618 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 32ce7dacf58bbf35cf70da8b03fa25f97fcea970edbc1f8aa12739ac4c8608fb -R c7867d5f34f471f1c203d9ecfab6ff98 +P 34709c7cc910539e23a830ad8b589a97a88be25e924a59670c1017fb51447dad +R b63eb752943f01d1de6f4800dabd8585 U drh -Z a250ac8f403a1bdc996f04e6b4453df0 +Z f52460ed1f18979ad0fa2f0cc99e3abc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aea1dec179..8b6f282a08 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -34709c7cc910539e23a830ad8b589a97a88be25e924a59670c1017fb51447dad \ No newline at end of file +5d725644621cf640fb743d59ccf89dac777540410e67501eb00b83638c8c857f \ No newline at end of file diff --git a/src/json.c b/src/json.c index d585189902..2d6195b797 100644 --- a/src/json.c +++ b/src/json.c @@ -1719,6 +1719,10 @@ static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){ return -1; } }else if( c<=0x1f ){ + if( c==0 ){ + pParse->iErr = j; + return -1; + } /* Control characters are not allowed in canonical JSON string ** literals, but are allowed in JSON5 string literals. */ opcode = JSONB_TEXT5; From 744581d3d63e653023de977d6375ededaa090014 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jan 2024 15:20:13 +0000 Subject: [PATCH 0069/1030] Add NEVER() and ALWAYS() macros for the JSON5-control-character change. Also fix an incorrect comparison used to determine if a buffer needed to be resized. FossilOrigin-Name: e3c0c0e686f3b7710f79587cf465b5aac52d8f2f2986a3de885a656f652cbfd3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 33bf52c0d0..685e93704d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfailure\sto\sdetect\sunterminated\sstring\sliterals\sin\sjson_valid()\sin\sthe\nprevious\scheck-in. -D 2024-01-31T14:44:59.052 +C Add\sNEVER()\sand\sALWAYS()\smacros\sfor\sthe\sJSON5-control-character\schange.\nAlso\sfix\san\sincorrect\scomparison\sused\sto\sdetermine\sif\sa\sbuffer\sneeded\sto\nbe\sresized. +D 2024-01-31T15:20:13.599 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -698,7 +698,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 24f2517b5dc7e678ee3006eaa0c0e6b13ff90e71849f8c4064134eb28a97f618 +F src/json.c e4e5f70b602c1dc9592b798166697bedeb84c61ffe857c9302ded54d5024603d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 34709c7cc910539e23a830ad8b589a97a88be25e924a59670c1017fb51447dad -R b63eb752943f01d1de6f4800dabd8585 +P 5d725644621cf640fb743d59ccf89dac777540410e67501eb00b83638c8c857f +R 877424d5c7313c59d7195755bacacb98 U drh -Z f52460ed1f18979ad0fa2f0cc99e3abc +Z b4bc4db54d1dcd1788bd56fd303b8ecb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8b6f282a08..29b4de9228 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d725644621cf640fb743d59ccf89dac777540410e67501eb00b83638c8c857f \ No newline at end of file +e3c0c0e686f3b7710f79587cf465b5aac52d8f2f2986a3de885a656f652cbfd3 \ No newline at end of file diff --git a/src/json.c b/src/json.c index 2d6195b797..47b83f1815 100644 --- a/src/json.c +++ b/src/json.c @@ -1425,7 +1425,7 @@ static u32 jsonbValidityCheck( }else if( z[j]<=0x1f ){ /* Control characters in JSON5 string literals are ok */ if( x==JSONB_TEXTJ ) return j+1; - }else if( z[j]!='\\' || j+1>=k ){ + }else if( NEVER(z[j]!='\\') || j+1>=k ){ return j+1; }else if( strchr("\"\\/bfnrt",z[j+1])!=0 ){ j++; @@ -2223,7 +2223,7 @@ static u32 jsonTranslateBlobToText( continue; } if( zIn[0]<=0x1f ){ - if( pOut->nUsed+7nAlloc && jsonStringGrow(pOut,7) ) break; + if( pOut->nUsed+7>pOut->nAlloc && jsonStringGrow(pOut,7) ) break; jsonAppendControlChar(pOut, zIn[0]); zIn++; sz2--; @@ -4419,7 +4419,7 @@ static void jsonErrorFunc( /* Convert byte-offset s.iErr into a character offset */ u32 k; assert( s.zJson!=0 ); /* Because s.oom is false */ - for(k=0; k Date: Wed, 31 Jan 2024 20:11:54 +0000 Subject: [PATCH 0070/1030] Replace an conditional assignment that was made obsolete by [d4c193f0b49f4950] with an assert(). The conditional was added by [d6fd512f50513ab7] as a fix for tickets [c36cdb4afd504dc1], [4051a7f931d9ba24], and [d6fd512f50513ab7] which means now [d4c193f0b49f4950] is the correct fix for those tickets. that check-in FossilOrigin-Name: 44b5524d522e749ad6bf76c94d754ff16c309c32439ec46802924663f64e8b09 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/where.c | 7 +++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index b46eb60302..b5659ca180 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\scontrol\scharacters\sin\sJSON5\sstring\sliterals.\n[forum:/forumpost/05182119f69c3a92|Forum\sthread\s05182119f69c3a92]. -D 2024-01-31T15:29:29.912 +C Replace\san\sconditional\sassignment\sthat\swas\smade\sobsolete\sby\s[d4c193f0b49f4950]\nwith\san\sassert().\s\sThe\sconditional\swas\sadded\sby\s[d6fd512f50513ab7]\sas\na\sfix\sfor\stickets\s[c36cdb4afd504dc1],\s[4051a7f931d9ba24],\sand\n[d6fd512f50513ab7]\swhich\smeans\snow\s[d4c193f0b49f4950]\sis\sthe\scorrect\sfix\nfor\sthose\stickets.\nthat\scheck-in +D 2024-01-31T20:11:54.024 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -823,7 +823,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c e38e37677884d644b825fe0ab72379a24a9a74f89d8add5eb134d61fea2358a3 +F src/where.c 0a6492afeb75f8d2a50e26b993eb78e9623b142e637cd3f2cdb85e896931d51d F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c dc5096eca5ed503999be3bdee8a90c51361289a678d396a220912e9cb73b3c00 @@ -2161,9 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 32ce7dacf58bbf35cf70da8b03fa25f97fcea970edbc1f8aa12739ac4c8608fb e3c0c0e686f3b7710f79587cf465b5aac52d8f2f2986a3de885a656f652cbfd3 -R 877424d5c7313c59d7195755bacacb98 -T +closed e3c0c0e686f3b7710f79587cf465b5aac52d8f2f2986a3de885a656f652cbfd3 +P 380f09c194caff557640692d2f255f8cdc1dcfed5976711686466692f4d7a60d +R 2ab0e5cc506f3fb919b7f44b2ff0cd53 U drh -Z 2c071c25594479aa12bff0fe9b315417 +Z 85535a5e43d2635944e90f9135f7853b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 70f3a70154..dcc6a1a493 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -380f09c194caff557640692d2f255f8cdc1dcfed5976711686466692f4d7a60d \ No newline at end of file +44b5524d522e749ad6bf76c94d754ff16c309c32439ec46802924663f64e8b09 \ No newline at end of file diff --git a/src/where.c b/src/where.c index b0fe12e52b..65022a65bb 100644 --- a/src/where.c +++ b/src/where.c @@ -5464,10 +5464,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){ pWInfo->eDistinct = WHERE_DISTINCT_ORDERED; } - if( pWInfo->pSelect->pOrderBy - && pWInfo->nOBSat > pWInfo->pSelect->pOrderBy->nExpr ){ - pWInfo->nOBSat = pWInfo->pSelect->pOrderBy->nExpr; - } + /* vvv--- See check-in [12ad822d9b827777] on 2023-03-16 ---vvv */ + assert( pWInfo->pSelect->pOrderBy==0 + || pWInfo->nOBSat <= pWInfo->pSelect->pOrderBy->nExpr ); }else{ pWInfo->revMask = pFrom->revLoop; if( pWInfo->nOBSat<=0 ){ From d87299cece175fe92418a8f3a11d14dd56cd9e6a Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Feb 2024 11:38:58 +0000 Subject: [PATCH 0071/1030] Add the test_oom_breakpoint() routine on debug builds, to serve as a convenient breakpoint to intercept OOM conditions. FossilOrigin-Name: e45df7dcd6b5766d7593ee87e59dd422a217cce0a1a8d369c03144bb21859428 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/malloc.c | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index b5659ca180..ace9856f05 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Replace\san\sconditional\sassignment\sthat\swas\smade\sobsolete\sby\s[d4c193f0b49f4950]\nwith\san\sassert().\s\sThe\sconditional\swas\sadded\sby\s[d6fd512f50513ab7]\sas\na\sfix\sfor\stickets\s[c36cdb4afd504dc1],\s[4051a7f931d9ba24],\sand\n[d6fd512f50513ab7]\swhich\smeans\snow\s[d4c193f0b49f4950]\sis\sthe\scorrect\sfix\nfor\sthose\stickets.\nthat\scheck-in -D 2024-01-31T20:11:54.024 +C Add\sthe\stest_oom_breakpoint()\sroutine\son\sdebug\sbuilds,\sto\sserve\sas\sa\nconvenient\sbreakpoint\sto\sintercept\sOOM\sconditions. +D 2024-02-01T11:38:58.054 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -702,7 +702,7 @@ F src/json.c e4e5f70b602c1dc9592b798166697bedeb84c61ffe857c9302ded54d5024603d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b -F src/malloc.c f016922435dc7d1f1f5083a03338a3e91f8c67ce2c5bdcfa4cdef62e612f5fcc +F src/malloc.c c31472af77e3421d993b69c93f07890277afd94247da4290e1b290ffc0d1f404 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 380f09c194caff557640692d2f255f8cdc1dcfed5976711686466692f4d7a60d -R 2ab0e5cc506f3fb919b7f44b2ff0cd53 +P 44b5524d522e749ad6bf76c94d754ff16c309c32439ec46802924663f64e8b09 +R cf60142a32287adf1c10b35b8571b6b1 U drh -Z 85535a5e43d2635944e90f9135f7853b +Z 5e6025aea61024ad1af737cfb95ff572 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dcc6a1a493..9376937a9e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -44b5524d522e749ad6bf76c94d754ff16c309c32439ec46802924663f64e8b09 \ No newline at end of file +e45df7dcd6b5766d7593ee87e59dd422a217cce0a1a8d369c03144bb21859428 \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index 356750682e..ef7d2e1edd 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -221,6 +221,24 @@ static void sqlite3MallocAlarm(int nByte){ sqlite3_mutex_enter(mem0.mutex); } +#ifdef SQLITE_DEBUG +/* +** This routine is called whenever an out-of-memory condition is seen, +** It's only purpose to to serve as a breakpoint for gdb or similar +** code debuggers when working on out-of-memory conditions, for example +** caused by PRAGMA hard_heap_limit=N. +*/ +static SQLITE_NOINLINE void test_oom_breakpoint(void){ + static u64 nOomFault = 0; + nOomFault++; + /* The assert() is never reached in a human lifetime. It is here mostly + ** to prevent code optimizers from optimizing out this function. */ + assert( (nOomFault>>32) < 0xffffffff ); +} +#else +# define test_oom_breakpoint(X) /* No-op for production builds */ +#endif + /* ** Do a memory allocation with statistics and alarms. Assume the ** lock is already held. @@ -247,6 +265,7 @@ static void mallocWithAlarm(int n, void **pp){ if( mem0.hardLimit ){ nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); if( nUsed >= mem0.hardLimit - nFull ){ + test_oom_breakpoint(); *pp = 0; return; } @@ -535,6 +554,7 @@ void *sqlite3Realloc(void *pOld, u64 nBytes){ sqlite3MallocAlarm(nDiff); if( mem0.hardLimit>0 && nUsed >= mem0.hardLimit - nDiff ){ sqlite3_mutex_leave(mem0.mutex); + test_oom_breakpoint(); return 0; } } From 1d09f4d01858e248bd6bbdc469e39245e2436ffb Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Feb 2024 14:17:01 +0000 Subject: [PATCH 0072/1030] Add tracing logic to the shared-cache locks in btree.c. The tracing is off by default. Enable by changing a single "#if 0" into "#if 1" and recompiling. Debugging code only - no changes to release builds. FossilOrigin-Name: f2b943f97ad7e47848ac6df3a3a1eba134b9e63c4a631f8eaf8bda77cc02ba7b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index ace9856f05..0a2814cf9b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\stest_oom_breakpoint()\sroutine\son\sdebug\sbuilds,\sto\sserve\sas\sa\nconvenient\sbreakpoint\sto\sintercept\sOOM\sconditions. -D 2024-02-01T11:38:58.054 +C Add\stracing\slogic\sto\sthe\sshared-cache\slocks\sin\sbtree.c.\s\sThe\stracing\sis\noff\sby\sdefault.\s\sEnable\sby\schanging\sa\ssingle\s"#if\s0"\sinto\s"#if\s1"\sand\nrecompiling.\s\sDebugging\scode\sonly\s-\sno\schanges\sto\srelease\sbuilds. +D 2024-02-01T14:17:01.624 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -677,7 +677,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c c64df2b1623501e397128261de58d3ab44c301e4eb993a4055aa971444420200 +F src/btree.c 186359bd695150d22b9f385ffb487b9a029ecea158658eed3a0268ee63ecbf9c F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 F src/build.c 05c9eb387638982092988d2ef4c00a91b0c29baa1b85923f082ce0cf2903ea7e @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 44b5524d522e749ad6bf76c94d754ff16c309c32439ec46802924663f64e8b09 -R cf60142a32287adf1c10b35b8571b6b1 +P e45df7dcd6b5766d7593ee87e59dd422a217cce0a1a8d369c03144bb21859428 +R 1c4d155f92c2e065cfacf61f3e9f41bd U drh -Z 5e6025aea61024ad1af737cfb95ff572 +Z 977fd1472c72116436cf99418d5cf571 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9376937a9e..f055fdee92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e45df7dcd6b5766d7593ee87e59dd422a217cce0a1a8d369c03144bb21859428 \ No newline at end of file +f2b943f97ad7e47848ac6df3a3a1eba134b9e63c4a631f8eaf8bda77cc02ba7b \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index c41fb811ab..57b2efc9e0 100644 --- a/src/btree.c +++ b/src/btree.c @@ -151,8 +151,47 @@ int corruptPageError(int lineno, MemPage *p){ # define SQLITE_CORRUPT_PAGE(pMemPage) SQLITE_CORRUPT_PGNO(pMemPage->pgno) #endif +/* Default value for SHARED_LOCK_TRACE macro if shared-cache is disabled +** or if the lock tracking is disabled. This is always the value for +** release builds. +*/ +#define SHARED_LOCK_TRACE(X,MSG,TAB,TYPE) /*no-op*/ + #ifndef SQLITE_OMIT_SHARED_CACHE +#if 0 +/* ^---- Change to 1 and recompile to enable shared-lock tracing +** for debugging purposes. +** +** Print all shared-cache locks on a BtShared. Debugging use only. +*/ +static void sharedLockTrace( + BtShared *pBt, + const char *zMsg, + int iRoot, + int eLockType +){ + BtLock *pLock; + if( iRoot>0 ){ + printf("%s-%p %u%s:", zMsg, pBt, iRoot, eLockType==READ_LOCK?"R":"W"); + }else{ + printf("%s-%p:", zMsg, pBt); + } + for(pLock=pBt->pLock; pLock; pLock=pLock->pNext){ + printf(" %p/%u%s", pLock->pBtree, pLock->iTable, + pLock->eLock==READ_LOCK ? "R" : "W"); + while( pLock->pNext && pLock->pBtree==pLock->pNext->pBtree ){ + pLock = pLock->pNext; + printf(",%u%s", pLock->iTable, pLock->eLock==READ_LOCK ? "R" : "W"); + } + } + printf("\n"); + fflush(stdout); +} +#undef SHARED_LOCK_TRACE +#define SHARED_LOCK_TRACE(X,MSG,TAB,TYPE) sharedLockTrace(X,MSG,TAB,TYPE) +#endif /* Shared-lock tracing */ + #ifdef SQLITE_DEBUG /* **** This function is only used as part of an assert() statement. *** @@ -229,6 +268,8 @@ static int hasSharedCacheTableLock( iTab = iRoot; } + SHARED_LOCK_TRACE(pBtree->pBt,"hasLock",iRoot,eLockType); + /* Search for the required lock. Either a write-lock on root-page iTab, a ** write-lock on the schema table, or (if the client is reading) a ** read-lock on iTab will suffice. Return 1 if any of these are found. */ @@ -362,6 +403,8 @@ static int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){ BtLock *pLock = 0; BtLock *pIter; + SHARED_LOCK_TRACE(pBt,"setLock", iTable, eLock); + assert( sqlite3BtreeHoldsMutex(p) ); assert( eLock==READ_LOCK || eLock==WRITE_LOCK ); assert( p->db!=0 ); @@ -429,6 +472,8 @@ static void clearAllSharedCacheTableLocks(Btree *p){ assert( p->sharable || 0==*ppIter ); assert( p->inTrans>0 ); + SHARED_LOCK_TRACE(pBt, "clearAllLocks", 0, 0); + while( *ppIter ){ BtLock *pLock = *ppIter; assert( (pBt->btsFlags & BTS_EXCLUSIVE)==0 || pBt->pWriter==pLock->pBtree ); @@ -467,6 +512,9 @@ static void clearAllSharedCacheTableLocks(Btree *p){ */ static void downgradeAllSharedCacheTableLocks(Btree *p){ BtShared *pBt = p->pBt; + + SHARED_LOCK_TRACE(pBt, "downgradeLocks", 0, 0); + if( pBt->pWriter==p ){ BtLock *pLock; pBt->pWriter = 0; From 64b76c0ed4ad645e4b4d5db86fe37ef00a56b55a Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Feb 2024 14:57:24 +0000 Subject: [PATCH 0073/1030] In PRAGMA integrity_check, defer running xIntegrity on virtual tables until after all ordinary tables have been checked. FossilOrigin-Name: 8f4b1ceafe4a271b23e17493a244a34c1732a3d35c5533c37394b9f3dc158435 --- manifest | 12 +++++------ manifest.uuid | 2 +- src/pragma.c | 59 +++++++++++++++++++++++++++++---------------------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/manifest b/manifest index 0a2814cf9b..9040a87866 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stracing\slogic\sto\sthe\sshared-cache\slocks\sin\sbtree.c.\s\sThe\stracing\sis\noff\sby\sdefault.\s\sEnable\sby\schanging\sa\ssingle\s"#if\s0"\sinto\s"#if\s1"\sand\nrecompiling.\s\sDebugging\scode\sonly\s-\sno\schanges\sto\srelease\sbuilds. -D 2024-02-01T14:17:01.624 +C In\sPRAGMA\sintegrity_check,\sdefer\srunning\sxIntegrity\son\svirtual\stables\suntil\nafter\sall\sordinary\stables\shave\sbeen\schecked. +D 2024-02-01T14:57:24.429 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -731,7 +731,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c b5b4cff830575e6188cd56a295a57448d2b9dbc53f0dae58e22b97354cda3781 +F src/pragma.c f9b6bb9a044a0dfda1f31c2d1523c7970f850688b450f06e61e23672d70adac0 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e45df7dcd6b5766d7593ee87e59dd422a217cce0a1a8d369c03144bb21859428 -R 1c4d155f92c2e065cfacf61f3e9f41bd +P f2b943f97ad7e47848ac6df3a3a1eba134b9e63c4a631f8eaf8bda77cc02ba7b +R 570d0c161255e22a4bbedff4048d62e5 U drh -Z 977fd1472c72116436cf99418d5cf571 +Z bbe0d55da8a6fc00ff4106f6aecfdfa4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f055fdee92..d50c977ea9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f2b943f97ad7e47848ac6df3a3a1eba134b9e63c4a631f8eaf8bda77cc02ba7b \ No newline at end of file +8f4b1ceafe4a271b23e17493a244a34c1732a3d35c5533c37394b9f3dc158435 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 4c90574182..79c4e0ae84 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1762,31 +1762,7 @@ void sqlite3Pragma( int mxCol; /* Maximum non-virtual column number */ if( pObjTab && pObjTab!=pTab ) continue; - if( !IsOrdinaryTable(pTab) ){ -#ifndef SQLITE_OMIT_VIRTUALTABLE - sqlite3_vtab *pVTab; - int a1; - if( !IsVirtual(pTab) ) continue; - if( pTab->nCol<=0 ){ - const char *zMod = pTab->u.vtab.azArg[0]; - if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue; - } - sqlite3ViewGetColumnNames(pParse, pTab); - if( pTab->u.vtab.p==0 ) continue; - pVTab = pTab->u.vtab.p->pVtab; - if( NEVER(pVTab==0) ) continue; - if( NEVER(pVTab->pModule==0) ) continue; - if( pVTab->pModule->iVersion<4 ) continue; - if( pVTab->pModule->xIntegrity==0 ) continue; - sqlite3VdbeAddOp3(v, OP_VCheck, i, 3, isQuick); - pTab->nTabRef++; - sqlite3VdbeAppendP4(v, pTab, P4_TABLEREF); - a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); - integrityCheckResultRow(v); - sqlite3VdbeJumpHere(v, a1); -#endif - continue; - } + if( !IsOrdinaryTable(pTab) ) continue; if( isQuick || HasRowid(pTab) ){ pPk = 0; r2 = 0; @@ -2111,6 +2087,39 @@ void sqlite3Pragma( } } } + +#ifndef SQLITE_OMIT_VIRTUALTABLE + /* Second pass to invoke the xIntegrity method on all virtual + ** tables. + */ + for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ + Table *pTab = sqliteHashData(x); + sqlite3_vtab *pVTab; + int a1; + if( pObjTab && pObjTab!=pTab ) continue; + if( IsOrdinaryTable(pTab) ) continue; + if( !IsVirtual(pTab) ) continue; + if( pTab->nCol<=0 ){ + const char *zMod = pTab->u.vtab.azArg[0]; + if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue; + } + sqlite3ViewGetColumnNames(pParse, pTab); + if( pTab->u.vtab.p==0 ) continue; + pVTab = pTab->u.vtab.p->pVtab; + if( NEVER(pVTab==0) ) continue; + if( NEVER(pVTab->pModule==0) ) continue; + if( pVTab->pModule->iVersion<4 ) continue; + if( pVTab->pModule->xIntegrity==0 ) continue; + sqlite3VdbeAddOp3(v, OP_VCheck, i, 3, isQuick); + pTab->nTabRef++; + sqlite3VdbeAppendP4(v, pTab, P4_TABLEREF); + a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); + integrityCheckResultRow(v); + sqlite3VdbeJumpHere(v, a1); +#endif + continue; + } + } { static const int iLn = VDBE_OFFSET_LINENO(2); From adea051707fc225ba61772278b3288d002738382 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 1 Feb 2024 15:21:55 +0000 Subject: [PATCH 0074/1030] Ensure the fts3 xIntegrity method correctly returns error codes unrelated to corruption or missing SQL elements. FossilOrigin-Name: 1bdb8cbaf7e733e0731de2ecd7a05ddf44db5d8595dcc7aaf0927ed0aa5b33d3 --- ext/fts3/fts3.c | 12 +++++++----- ext/fts3/fts3_write.c | 7 ++++++- manifest | 18 +++++++++--------- manifest.uuid | 2 +- test/fts3fault3.test | 28 ++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 379590188d..f977aabfbc 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4014,22 +4014,24 @@ static int fts3IntegrityMethod( char **pzErr /* Write error message here */ ){ Fts3Table *p = (Fts3Table*)pVtab; - int rc; + int rc = SQLITE_OK; int bOk = 0; UNUSED_PARAMETER(isQuick); rc = sqlite3Fts3IntegrityCheck(p, &bOk); - assert( rc!=SQLITE_CORRUPT_VTAB || bOk==0 ); - if( rc!=SQLITE_OK && rc!=SQLITE_CORRUPT_VTAB ){ + assert( rc!=SQLITE_CORRUPT_VTAB ); + if( rc==SQLITE_ERROR || (rc&0xFF)==SQLITE_CORRUPT ){ *pzErr = sqlite3_mprintf("unable to validate the inverted index for" " FTS%d table %s.%s: %s", p->bFts4 ? 4 : 3, zSchema, zTabname, sqlite3_errstr(rc)); - }else if( bOk==0 ){ + if( *pzErr ) rc = SQLITE_OK; + }else if( rc==SQLITE_OK && bOk==0 ){ *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s", p->bFts4 ? 4 : 3, zSchema, zTabname); + if( *pzErr==0 ) rc = SQLITE_NOMEM; } sqlite3Fts3SegmentsClose(p); - return SQLITE_OK; + return rc; } diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 2516a39083..5a449dec1e 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -5372,7 +5372,12 @@ int sqlite3Fts3IntegrityCheck(Fts3Table *p, int *pbOk){ sqlite3_finalize(pStmt); } - *pbOk = (rc==SQLITE_OK && cksum1==cksum2); + if( rc==SQLITE_CORRUPT_VTAB ){ + rc = SQLITE_OK; + *pbOk = 0; + }else{ + *pbOk = (rc==SQLITE_OK && cksum1==cksum2); + } return rc; } diff --git a/manifest b/manifest index 9040a87866..c5b03d78bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sPRAGMA\sintegrity_check,\sdefer\srunning\sxIntegrity\son\svirtual\stables\suntil\nafter\sall\sordinary\stables\shave\sbeen\schecked. -D 2024-02-01T14:57:24.429 +C Ensure\sthe\sfts3\sxIntegrity\smethod\scorrectly\sreturns\serror\scodes\sunrelated\sto\scorruption\sor\smissing\sSQL\selements. +D 2024-02-01T15:21:55.952 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -63,7 +63,7 @@ F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers b92bdeb8b46503f0dd301d364efc5ef59ef9fa8e2758b8e742f39fa93a2e422d F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c fd64a588471ce00b19da08acb0d6f904277a21ac1d15141d5913c83591afa027 +F ext/fts3/fts3.c c922380b62bd15bce953dae3350337acbd0fff07c10cdc805819409791eb480a F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 968f7d7cae541a6926146e9fd3fb2b2ccbd3845b7890a8ed03de0c06ac776682 F ext/fts3/fts3_aux.c 7eab82a9cf0830f6551ba3abfdbe73ed39e322a4d3940ee82fbf723674ecd9f3 @@ -81,7 +81,7 @@ F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c c1de4ae28356ad98ccb8b2e3388a7fdcce7607b5523738c9afb6275dab765154 F ext/fts3/fts3_unicode.c de426ff05c1c2e7bce161cf6b706638419c3a1d9c2667de9cb9dc0458c18e226 F ext/fts3/fts3_unicode2.c 416eb7e1e81142703520d284b768ca2751d40e31fa912cae24ba74860532bf0f -F ext/fts3/fts3_write.c c2d7a8dfb6e7a00c6c88ce626785cf4c50ed18eba34b5fbd53cacd60af96d0f2 +F ext/fts3/fts3_write.c 81cd8f7e8003e427a1801e04842776b731af26dd93af206e4e66ea5ae319cad1 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/tool/fts3cov.sh c331d006359456cf6f8f953e37f2b9c7d568f3863f00bb5f7eb87fea4ac01b73 F ext/fts3/tool/fts3view.c 413c346399159df81f86c4928b7c4a455caab73bfbc8cd68f950f632e5751674 @@ -1168,7 +1168,7 @@ F test/fts3expr5.test a5b9a053becbdb8e973fbf4d6d3abaabeb42d511d1848bd57931f3e0a1 F test/fts3f.test 8c438d5e1cab526b0021988fb1dc70cf3597b006a33ffd6c955ee89929077fe3 F test/fts3fault.test f4e1342acfe6d216a001490e8cd52afac1f9ffe4a11bbcdcb296129a45c5df45 F test/fts3fault2.test 7b2741e5095367238380b0fcdb837f36c24484c7a5f353659b387df63cf039ec -F test/fts3fault3.test 4a39a1618546776255dc1de306213b600aef87eca589ca8428a70c00fd11961b +F test/fts3fault3.test ccdd2292dd2d4e21e30fc5f4c8e064f79e516087eec5ff57ab6bc4f6a7714097 F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641 F test/fts3fuzz001.test c78afcd8ad712ea0b8d2ed50851a8aab3bc9dc52c64a536291e07112f519357c F test/fts3integrity.test 0c6fe7353d7b24d78862f4272ee9df4da2f32b3ff30fa3396945cda8119580a8 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f2b943f97ad7e47848ac6df3a3a1eba134b9e63c4a631f8eaf8bda77cc02ba7b -R 570d0c161255e22a4bbedff4048d62e5 -U drh -Z bbe0d55da8a6fc00ff4106f6aecfdfa4 +P 8f4b1ceafe4a271b23e17493a244a34c1732a3d35c5533c37394b9f3dc158435 +R 5c2528728c1ae6f17248d6aeeec1d716 +U dan +Z 9a20d0bd91d2ec45e34040ddfece9f98 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d50c977ea9..69cd49c094 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f4b1ceafe4a271b23e17493a244a34c1732a3d35c5533c37394b9f3dc158435 \ No newline at end of file +1bdb8cbaf7e733e0731de2ecd7a05ddf44db5d8595dcc7aaf0927ed0aa5b33d3 \ No newline at end of file diff --git a/test/fts3fault3.test b/test/fts3fault3.test index 6e1c0cd672..ae204718b4 100644 --- a/test/fts3fault3.test +++ b/test/fts3fault3.test @@ -50,5 +50,33 @@ do_faultsim_test 1 -faults oom* -prep { faultsim_test_result {0 {}} } +#------------------------------------------------------------------- +reset_db + +do_execsql_test 2.0 { + BEGIN; + CREATE VIRTUAL TABLE t1 USING fts3(a); + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50 + ) + INSERT INTO t1 SELECT 'abc def ghi jkl mno pqr' FROM s; + COMMIT; +} + +faultsim_save_and_close +do_faultsim_test 2 -faults oom-t* -prep { + faultsim_restore_and_reopen + execsql { + BEGIN; + CREATE TABLE x1(a PRIMARY KEY); + } +} -body { + execsql { + PRAGMA integrity_check; + } +} -test { + faultsim_test_result {0 ok} $::TMPDBERROR +} + finish_test From 09768559b68951149fdb00f3b3462262c0090127 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 1 Feb 2024 15:42:22 +0000 Subject: [PATCH 0075/1030] Ensure the fts5 xIntegrity method correctly returns error codes unrelated to corruption or missing SQL elements. FossilOrigin-Name: d18d9a05c2d6f290d7b16eafced0cde4eb8dd3f869778a49103812d35a0cee65 --- ext/fts5/fts5_main.c | 3 ++- ext/fts5/test/fts5fault8.test | 14 +++++++++++++- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 7c818ce747..f609f7f34a 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2979,6 +2979,7 @@ static int fts5IntegrityMethod( if( (rc&0xff)==SQLITE_CORRUPT ){ *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", zSchema, zTabname); + rc = (*pzErr) ? SQLITE_OK : SQLITE_NOMEM; }else if( rc!=SQLITE_OK ){ *pzErr = sqlite3_mprintf("unable to validate the inverted index for" " FTS5 table %s.%s: %s", @@ -2986,7 +2987,7 @@ static int fts5IntegrityMethod( } sqlite3Fts5IndexCloseReader(pTab->p.pIndex); - return SQLITE_OK; + return rc; } static int fts5Init(sqlite3 *db){ diff --git a/ext/fts5/test/fts5fault8.test b/ext/fts5/test/fts5fault8.test index 5afab77541..dc060a1592 100644 --- a/ext/fts5/test/fts5fault8.test +++ b/ext/fts5/test/fts5fault8.test @@ -57,7 +57,6 @@ foreach_detail_mode $testprefix { } ;# foreach_detail_mode... - do_execsql_test 4.0 { CREATE VIRTUAL TABLE x2 USING fts5(a); INSERT INTO x2(x2, rank) VALUES('crisismerge', 2); @@ -80,5 +79,18 @@ do_faultsim_test 4 -faults oom-* -prep { faultsim_test_result {0 {}} {1 SQLITE_NOMEM} } +set TMPDBERROR {1 {unable to open a temporary database file for storing temporary tables}} + +do_faultsim_test 5 -faults oom-t* -prep { + faultsim_restore_and_reopen + execsql { PRAGMA temp_store = memory } +} -body { + execsql { PRAGMA integrity_check } +} -test { + if {[string match {*error code=7*} $testresult]==0} { + faultsim_test_result {0 ok} {1 SQLITE_NOMEM} $::TMPDBERROR + } +} + finish_test diff --git a/manifest b/manifest index c5b03d78bd..576583dc9c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthe\sfts3\sxIntegrity\smethod\scorrectly\sreturns\serror\scodes\sunrelated\sto\scorruption\sor\smissing\sSQL\selements. -D 2024-02-01T15:21:55.952 +C Ensure\sthe\sfts5\sxIntegrity\smethod\scorrectly\sreturns\serror\scodes\sunrelated\sto\scorruption\sor\smissing\sSQL\selements. +D 2024-02-01T15:42:22.671 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -98,7 +98,7 @@ F ext/fts5/fts5_config.c 8072a207034b51ae9b7694121d1b5715c794e94b275e088f70ae532 F ext/fts5/fts5_expr.c e91156ebdcc08d837f4f324168f69f3c0d7fdef0e521fd561efb48ef3297b696 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c bb1965c3965f6fe5f64160bf1c0694a9684a790a783f293a76da1d38d319b258 -F ext/fts5/fts5_main.c cd56ed9619e9bc55ae603ecafd5965c3684bb4c1de7dd00893c307ddf98afe88 +F ext/fts5/fts5_main.c d68bd9533d5a638b7f6fae61c3cb0a15257dcdcccedaf3d0b3c9f55940c85048 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c cf0fd0dbe64ec272491b749e0d594f563cda03336aeb60900129e6d18b0aefb8 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -163,7 +163,7 @@ F ext/fts5/test/fts5fault4.test 87a10d0caee57da587c7588b0c8d25d2930197399b4812ad F ext/fts5/test/fts5fault5.test a336e4e11847de24c9497f80cce18e00bb3fab7fb11f97d04eb9af898900a762 F ext/fts5/test/fts5fault6.test a0fc0a8f99e4b16500c31dfc7e38e1defe0f1693ac47650517ac7b723b1956f8 F ext/fts5/test/fts5fault7.test 0acbec416edb24b8881f154e99c31e9ccf73f539cfcd164090be139e9e97ed4c -F ext/fts5/test/fts5fault8.test 318238659d35f82ad215ecb57ca4c87486ea85d45dbeedaee42f148ff5105ee2 +F ext/fts5/test/fts5fault8.test 9353fe6a2a993c3231e09c49b0f4a12c8d306319555ff2ca6672b5b86fe9b0dd F ext/fts5/test/fts5fault9.test 098e6b894bbdf9b2192f994a30f4043673fb3f338b6b8ab1624c704422f39119 F ext/fts5/test/fts5faultA.test be4487576bff8c22cee6597d1893b312f306504a8c6ccd3c53ca85af12290c8c F ext/fts5/test/fts5faultB.test d606bdb8e81aaeb6f41de3fc9fc7ae315733f0903fbff05cf54f5b045b729ab5 @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8f4b1ceafe4a271b23e17493a244a34c1732a3d35c5533c37394b9f3dc158435 -R 5c2528728c1ae6f17248d6aeeec1d716 +P 1bdb8cbaf7e733e0731de2ecd7a05ddf44db5d8595dcc7aaf0927ed0aa5b33d3 +R 1556903ce72520c2bcec86245b58e4bf U dan -Z 9a20d0bd91d2ec45e34040ddfece9f98 +Z ab6b3bfbcf0d40402d16029c30c5525d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 69cd49c094..0a82b7b6e9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1bdb8cbaf7e733e0731de2ecd7a05ddf44db5d8595dcc7aaf0927ed0aa5b33d3 \ No newline at end of file +d18d9a05c2d6f290d7b16eafced0cde4eb8dd3f869778a49103812d35a0cee65 \ No newline at end of file From 3a32690a5519f7927947076bf17f64f4243c4396 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 2 Feb 2024 11:37:03 +0000 Subject: [PATCH 0076/1030] Fix typo in vdbe.c comment. No changes to code. FossilOrigin-Name: 62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 576583dc9c..a24b4aa0b9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthe\sfts5\sxIntegrity\smethod\scorrectly\sreturns\serror\scodes\sunrelated\sto\scorruption\sor\smissing\sSQL\selements. -D 2024-02-01T15:42:22.671 +C Fix\stypo\sin\svdbe.c\scomment.\sNo\schanges\sto\scode. +D 2024-02-02T11:37:03.045 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -808,7 +808,7 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 92910d536e0b77505599cd6ae5d9d449e4a5d31ada61da4c0bb84f6ccb2c3189 +F src/vdbe.c dd340f5add924a8397401f7fe4faf2304ffd49ab5853d32ffc1736093b9c5080 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1bdb8cbaf7e733e0731de2ecd7a05ddf44db5d8595dcc7aaf0927ed0aa5b33d3 -R 1556903ce72520c2bcec86245b58e4bf +P d18d9a05c2d6f290d7b16eafced0cde4eb8dd3f869778a49103812d35a0cee65 +R aba3b7802d437f5dcd3a746bf90a6079 U dan -Z ab6b3bfbcf0d40402d16029c30c5525d +Z 006ae05388cb62c50458a12f4ef45e94 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0a82b7b6e9..c4830dab2b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d18d9a05c2d6f290d7b16eafced0cde4eb8dd3f869778a49103812d35a0cee65 \ No newline at end of file +62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 84eccf5334..1e0d776536 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -7101,8 +7101,8 @@ case OP_DropTrigger: { ** ** The register P3 contains one less than the maximum number of allowed errors. ** At most reg(P3) errors will be reported. -** In other words, the analysis stops as soon as reg(P1) errors are -** seen. Reg(P1) is updated with the number of errors remaining. +** In other words, the analysis stops as soon as reg(P3) errors are +** seen. Reg(P3) is updated with the number of errors remaining. ** ** The root page numbers of all tables in the database are integers ** stored in P4_INTARRAY argument. From d90ecb5d6e10682548045f3ff72e3e670c0436ee Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 2 Feb 2024 16:51:24 +0000 Subject: [PATCH 0077/1030] Have "PRAGMA quick_check" compare the number of entries in tables and indexes. FossilOrigin-Name: cc294c041b4c7a044ff344989f872415ced5263a0b654112371b2da7c852a688 --- manifest | 35 +++++++++++++++-------------- manifest.uuid | 2 +- src/btree.c | 23 +++++++++++++------ src/btree.h | 1 + src/btreeInt.h | 1 + src/pragma.c | 54 +++++++++++++++++++++++++++++---------------- src/vdbe.c | 22 +++++++++--------- src/vdbe.h | 2 ++ src/vdbemem.c | 5 +++++ test/corruptD.test | 2 +- test/e_reindex.test | 6 ++--- test/pragma.test | 32 +++++++++++++-------------- test/pragma4.test | 2 +- 13 files changed, 112 insertions(+), 75 deletions(-) diff --git a/manifest b/manifest index a24b4aa0b9..fc70cdcfa3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\svdbe.c\scomment.\sNo\schanges\sto\scode. -D 2024-02-02T11:37:03.045 +C Have\s"PRAGMA\squick_check"\scompare\sthe\snumber\sof\sentries\sin\stables\sand\sindexes. +D 2024-02-02T16:51:24.901 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -677,9 +677,9 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 186359bd695150d22b9f385ffb487b9a029ecea158658eed3a0268ee63ecbf9c -F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 -F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 +F src/btree.c d49ecac72d677faa9ef604ea67248847acb1599579204c4f3b108b2ee1ca7037 +F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 +F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 05c9eb387638982092988d2ef4c00a91b0c29baa1b85923f082ce0cf2903ea7e F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e @@ -731,7 +731,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c f9b6bb9a044a0dfda1f31c2d1523c7970f850688b450f06e61e23672d70adac0 +F src/pragma.c cf46ab7d7d4c9ea53edfff52412215538b1ac96e52718b3e1279458e26b6f26e F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -808,13 +808,13 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c dd340f5add924a8397401f7fe4faf2304ffd49ab5853d32ffc1736093b9c5080 -F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb +F src/vdbe.c c91a1555921f1573ef267210c8a5eeb91d28d83a1059d43a9a850c52a9bf6e39 +F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b F src/vdbeaux.c c5a471b34e9c4cfc0295a3e10734fd197670ffaebcb742f284c8e17e8026ceea F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 -F src/vdbemem.c 3e37dab421b74e9ce55c1e88fbc7bc6fead590b5ab258bc684f8b70abb1d6e71 +F src/vdbemem.c 6f1728ea70d9523cc446567d3bf1cca3f26515d15160dd9f540fc549cdfbe2a6 F src/vdbesort.c 00c1fb15171205063556c2f1cf454e24c0b41c1effb0c876b850dce91f21bc64 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 @@ -998,7 +998,7 @@ F test/corrupt9.test 730a3db08d4ab9aa43392ea30d9c2b4879cbff85 F test/corruptA.test 112f4b2ae0b95ebf3ea63718642fb969a93acea557ace3a307234d19c245989b F test/corruptB.test 73a8d6c0b9833697ecf16b63e3c5c05c945b5dec F test/corruptC.test 9cf32275dae3ca33f645afe5d1d3f5ba5ac2af2b0833dfb5282f9dccb6fb81bb -F test/corruptD.test a828c788535946a372a56a750b242cd96287cd823657abe5a73c5e51b91bdd28 +F test/corruptD.test 614320aa519f6bf6c7dd2f581f9513ff7b6826954180cca1a606d0e25ea084a3 F test/corruptE.test 4143791f2dfb443aec5b7fabfa5821e6063eccc3b49b06f212c2f014715fd476 F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4 F test/corruptG.test adf79b669cbfd19e28c8191a610d083ae53a6d51 @@ -1070,7 +1070,7 @@ F test/e_expr.test b950818a48269506d75a41c819003bd77a0893bc4a4f2fdee191bc74109c1 F test/e_fkey.test feeba6238aeff9d809fb6236b351da8df4ae9bda89e088e54526b31a0cbfeec5 F test/e_fts3.test 17ba7c373aba4d4f5696ba147ee23fd1a1ef70782af050e03e262ca187c5ee07 F test/e_insert.test f02f7f17852b2163732c6611d193f84fc67bc641fb4882c77a464076e5eba80e -F test/e_reindex.test 2b0e29344497d9a8a999453a003cb476b6b1d2eef2d6c120f83c2d3a429f3164 +F test/e_reindex.test 027bb13d2c7e9e865886eed6349f126a273f8037899b636bf5fb53c7fc815921 F test/e_resolve.test a61751c368b109db73df0f20fc75fb47e166b1d8 F test/e_select.test 327a15f14068bbd6f647cedc67210f8680fcb2f05e481a0a855fccd2abfa1292 F test/e_select2.test aceb80ab927d46fba5ce7586ebabf23e2bb0604f @@ -1481,10 +1481,10 @@ F test/pendingrace.test 6aa33756b950c4529f79c4f3817a9a1e4025bd0d9961571a05c0279b F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff F test/permutations.test f7caf8dd5c7b1da74842a48df116f7f193399c656d4ffc805cd0d9658568c675 F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f -F test/pragma.test 57a36226218c03cfb381019fe43234b2cefbd8a1f12825514f906a17ccf7991e +F test/pragma.test 6e0bb3277d7293328a0cec417b967db62beb1700ae8e4e3cdb52be585705cbdd F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 -F test/pragma4.test ca5e4dfc46adfe490f75d73734f70349d95a199e6510973899e502eef2c8b1f8 +F test/pragma4.test 9559cf5173864bf47c0431873d158fbeb72f920a59905b1f46069d8543eccdab F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d9102 F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8 F test/prefixes.test b524a1c44bffec225b9aec98bd728480352aa8532ac4c15771fb85e8beef65d9 @@ -2161,8 +2161,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d18d9a05c2d6f290d7b16eafced0cde4eb8dd3f869778a49103812d35a0cee65 -R aba3b7802d437f5dcd3a746bf90a6079 +P 62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d +R f7f56a51df263c734cbee718d29c6a34 +T *branch * quick-check-counts +T *sym-quick-check-counts * +T -sym-trunk * U dan -Z 006ae05388cb62c50458a12f4ef45e94 +Z 3682eb48d291ba0b263b9d8bf9a6accb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c4830dab2b..a1cc104156 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d \ No newline at end of file +cc294c041b4c7a044ff344989f872415ced5263a0b654112371b2da7c852a688 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 57b2efc9e0..c21736e49c 100644 --- a/src/btree.c +++ b/src/btree.c @@ -10791,6 +10791,9 @@ static int checkTreePage( ** number of cells on the page. */ nCell = get2byte(&data[hdr+3]); assert( pPage->nCell==nCell ); + if( pPage->leaf || pPage->intKey==0 ){ + pCheck->nRow += nCell; + } /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page ** immediately follows the b-tree page header. */ @@ -11001,6 +11004,7 @@ int sqlite3BtreeIntegrityCheck( sqlite3 *db, /* Database connection that is running the check */ Btree *p, /* The btree to be checked */ Pgno *aRoot, /* An array of root pages numbers for individual trees */ + Mem *aCnt, /* Memory cells to write counts for each tree to */ int nRoot, /* Number of entries in aRoot[] */ int mxErr, /* Stop reporting errors after this many */ int *pnErr, /* OUT: Write number of errors seen to this variable */ @@ -11087,15 +11091,20 @@ int sqlite3BtreeIntegrityCheck( testcase( pBt->db->flags & SQLITE_CellSizeCk ); pBt->db->flags &= ~(u64)SQLITE_CellSizeCk; for(i=0; (int)iautoVacuum && aRoot[i]>1 && !bPartial ){ - checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0); - } + if( pBt->autoVacuum && aRoot[i]>1 && !bPartial ){ + checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0); + } #endif - sCheck.v0 = aRoot[i]; - checkTreePage(&sCheck, aRoot[i], ¬Used, LARGEST_INT64); + sCheck.v0 = aRoot[i]; + checkTreePage(&sCheck, aRoot[i], ¬Used, LARGEST_INT64); + } + if( aCnt ){ + sqlite3MemSetArrayInt64(aCnt, i, sCheck.nRow); + } } pBt->db->flags = savedDbFlags; diff --git a/src/btree.h b/src/btree.h index b45ace7e1d..9731b8f2dc 100644 --- a/src/btree.h +++ b/src/btree.h @@ -331,6 +331,7 @@ int sqlite3BtreeIntegrityCheck( sqlite3 *db, /* Database connection that is running the check */ Btree *p, /* The btree to be checked */ Pgno *aRoot, /* An array of root pages numbers for individual trees */ + sqlite3_value *aCnt, /* OUT: entry counts for each btree in aRoot[] */ int nRoot, /* Number of entries in aRoot[] */ int mxErr, /* Stop reporting errors after this many */ int *pnErr, /* OUT: Write number of errors seen to this variable */ diff --git a/src/btreeInt.h b/src/btreeInt.h index 67a7db25c2..1213297253 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -707,6 +707,7 @@ struct IntegrityCk { StrAccum errMsg; /* Accumulate the error message text here */ u32 *heap; /* Min-heap used for analyzing cell coverage */ sqlite3 *db; /* Database connection running the check */ + i64 nRow; /* Number of rows visited in current tree */ }; /* diff --git a/src/pragma.c b/src/pragma.c index 79c4e0ae84..7f5ccef61d 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1692,7 +1692,6 @@ void sqlite3Pragma( Hash *pTbls; /* Set of all tables in the schema */ int *aRoot; /* Array of root page numbers of all btrees */ int cnt = 0; /* Number of entries in aRoot[] */ - int mxIdx = 0; /* Maximum number of indexes for any table */ if( OMIT_TEMPDB && i==1 ) continue; if( iDb>=0 && i!=iDb ) continue; @@ -1714,7 +1713,6 @@ void sqlite3Pragma( if( pObjTab && pObjTab!=pTab ) continue; if( HasRowid(pTab) ) cnt++; for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; } - if( nIdx>mxIdx ) mxIdx = nIdx; } if( cnt==0 ) continue; if( pObjTab ) cnt++; @@ -1734,11 +1732,11 @@ void sqlite3Pragma( aRoot[0] = cnt; /* Make sure sufficient number of registers have been allocated */ - sqlite3TouchRegister(pParse, 8+mxIdx); + sqlite3TouchRegister(pParse, 8+cnt); sqlite3ClearTempRegCache(pParse); /* Do the b-tree integrity checks */ - sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY); + sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY); sqlite3VdbeChangeP5(v, (u8)i); addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v); sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, @@ -1748,6 +1746,36 @@ void sqlite3Pragma( integrityCheckResultRow(v); sqlite3VdbeJumpHere(v, addr); + /* Check that the indexes all have the right number of rows */ + cnt = pObjTab ? 1 : 0; + sqlite3VdbeLoadString(v, 2, "wrong # of entries in index "); + for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ + int iTab = 0; + Table *pTab = sqliteHashData(x); + Index *pIdx; + if( pObjTab && pObjTab!=pTab ) continue; + if( HasRowid(pTab) ){ + iTab = cnt++; + }else{ + iTab = cnt; + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + if( IsPrimaryKeyIndex(pIdx) ) break; + iTab++; + } + } + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + if( pIdx->pPartIdxWhere==0 ){ + addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+cnt, 0, 8+iTab); + VdbeCoverage(v); + sqlite3VdbeLoadString(v, 4, pIdx->zName); + sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3); + integrityCheckResultRow(v); + sqlite3VdbeJumpHere(v, addr); + } + cnt++; + } + } + /* Make sure all the indices are constructed correctly. */ for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ @@ -2070,21 +2098,9 @@ void sqlite3Pragma( } sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v); sqlite3VdbeJumpHere(v, loopTop-1); - if( !isQuick ){ - sqlite3VdbeLoadString(v, 2, "wrong # of entries in index "); - for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ - if( pPk==pIdx ) continue; - sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3); - addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v); - sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); - sqlite3VdbeLoadString(v, 4, pIdx->zName); - sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3); - integrityCheckResultRow(v); - sqlite3VdbeJumpHere(v, addr); - } - if( pPk ){ - sqlite3ReleaseTempRange(pParse, r2, pPk->nKeyCol); - } + if( pPk ){ + assert( !isQuick ); + sqlite3ReleaseTempRange(pParse, r2, pPk->nKeyCol); } } diff --git a/src/vdbe.c b/src/vdbe.c index 1e0d776536..f810bc5182 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -7096,13 +7096,13 @@ case OP_DropTrigger: { /* Opcode: IntegrityCk P1 P2 P3 P4 P5 ** ** Do an analysis of the currently open database. Store in -** register P1 the text of an error message describing any problems. -** If no problems are found, store a NULL in register P1. +** register (P1+1) the text of an error message describing any problems. +** If no problems are found, store a NULL in register (P1+1). ** -** The register P3 contains one less than the maximum number of allowed errors. -** At most reg(P3) errors will be reported. -** In other words, the analysis stops as soon as reg(P3) errors are -** seen. Reg(P3) is updated with the number of errors remaining. +** The register (P1) contains one less than the maximum number of allowed +** errors. At most reg(P1) errors will be reported. +** In other words, the analysis stops as soon as reg(P1) errors are +** seen. Reg(P1) is updated with the number of errors remaining. ** ** The root page numbers of all tables in the database are integers ** stored in P4_INTARRAY argument. @@ -7124,15 +7124,15 @@ case OP_IntegrityCk: { aRoot = pOp->p4.ai; assert( nRoot>0 ); assert( aRoot[0]==(Pgno)nRoot ); - assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); - pnErr = &aMem[pOp->p3]; + assert( pOp->p1>0 && (pOp->p1+1)<=(p->nMem+1 - p->nCursor) ); + pnErr = &aMem[pOp->p1]; assert( (pnErr->flags & MEM_Int)!=0 ); assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 ); - pIn1 = &aMem[pOp->p1]; + pIn1 = &aMem[pOp->p1+1]; assert( pOp->p5nDb ); assert( DbMaskTest(p->btreeMask, pOp->p5) ); - rc = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1], nRoot, - (int)pnErr->u.i+1, &nErr, &z); + rc = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1], + &aMem[pOp->p3], nRoot, (int)pnErr->u.i+1, &nErr, &z); sqlite3VdbeMemSetNull(pIn1); if( nErr==0 ){ assert( z==0 ); diff --git a/src/vdbe.h b/src/vdbe.h index 25bda6be7a..9001ace2ee 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -296,6 +296,8 @@ RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*); void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); int sqlite3VdbeHasSubProgram(Vdbe*); +void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val); + int sqlite3NotPureFunc(sqlite3_context*); #ifdef SQLITE_ENABLE_BYTECODE_VTAB int sqlite3VdbeBytecodeVtabInit(sqlite3*); diff --git a/src/vdbemem.c b/src/vdbemem.c index cbc6712bfd..03c58f3024 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -943,6 +943,11 @@ void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){ } } +void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val){ + aMem[iIdx].u.i = val; + aMem[iIdx].flags = MEM_Int; +} + /* A no-op destructor */ void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); } diff --git a/test/corruptD.test b/test/corruptD.test index c35388adfb..381e52c808 100644 --- a/test/corruptD.test +++ b/test/corruptD.test @@ -113,7 +113,7 @@ do_test corruptD-1.1.1 { hexio_write test.db [expr 1024+1] FFFF catchsql { PRAGMA quick_check } } {0 {{*** in database main *** -Tree 2 page 2: free space corruption}}} +Tree 2 page 2: free space corruption} {wrong # of entries in index i1}}} do_test corruptD-1.1.2 { incr_change_counter hexio_write test.db [expr 1024+1] [hexio_render_int32 1021] diff --git a/test/e_reindex.test b/test/e_reindex.test index 00291b76a6..50d2e7d516 100644 --- a/test/e_reindex.test +++ b/test/e_reindex.test @@ -73,12 +73,12 @@ sqlite3 db test.db do_execsql_test e_reindex-1.3 { PRAGMA integrity_check; } [list \ + {wrong # of entries in index i2} \ + {wrong # of entries in index i1} \ {row 3 missing from index i2} \ {row 3 missing from index i1} \ {row 4 missing from index i2} \ - {row 4 missing from index i1} \ - {wrong # of entries in index i2} \ - {wrong # of entries in index i1} + {row 4 missing from index i1} ] do_execsql_test e_reindex-1.4 { diff --git a/test/pragma.test b/test/pragma.test index 5b45a74400..2853e5afe7 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -372,27 +372,27 @@ ifcapable attach { db close sqlite3 db test.db execsql {PRAGMA integrity_check} - } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}} + } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}} do_test pragma-3.3 { execsql {PRAGMA integrity_check=1} - } {{row 1 missing from index i2}} + } {{wrong # of entries in index i2}} do_test pragma-3.4 { execsql { ATTACH DATABASE 'test.db' AS t2; PRAGMA integrity_check } - } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}} + } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}} do_test pragma-3.5 { execsql { PRAGMA integrity_check=4 } - } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2}} + } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}} do_catchsql_test pragma-3.6 { PRAGMA integrity_check=xyz } {1 {no such table: xyz}} do_catchsql_test pragma-3.6b { PRAGMA integrity_check=t2 - } {0 {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}} + } {0 {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}}} do_catchsql_test pragma-3.6c { PRAGMA integrity_check=sqlite_schema } {0 ok} @@ -400,7 +400,7 @@ ifcapable attach { execsql { PRAGMA integrity_check=0 } - } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}} + } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}} # Add additional corruption by appending unused pages to the end of # the database file testerr.db @@ -435,10 +435,10 @@ ifcapable attach { } {{*** in database t2 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}} +Page 6: never used} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}} do_execsql_test pragma-3.9b { PRAGMA t2.integrity_check=t2; - } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}} + } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}} do_execsql_test pragma-3.9c { PRAGMA t2.integrity_check=sqlite_schema; } {ok} @@ -455,7 +455,7 @@ Page 4: never used}} } {{*** in database t2 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2} {row 2 missing from index i2}} +Page 6: never used} {wrong # of entries in index i2} {row 1 missing from index i2}} do_test pragma-3.12 { execsql { PRAGMA integrity_check=4 @@ -463,7 +463,7 @@ Page 6: never used} {row 1 missing from index i2} {row 2 missing from index i2}} } {{*** in database t2 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2}} +Page 6: never used} {wrong # of entries in index i2}} do_test pragma-3.13 { execsql { PRAGMA integrity_check=3 @@ -487,10 +487,10 @@ Page 5: never used}} } {{*** in database t2 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 *** +Page 6: never used} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {*** in database t3 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}} +Page 6: never used} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}} do_test pragma-3.16 { execsql { PRAGMA integrity_check(10) @@ -498,10 +498,10 @@ Page 6: never used} {row 1 missing from index i2} {row 2 missing from index i2} } {{*** in database t2 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 *** +Page 6: never used} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {*** in database t3 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2}} +Page 6: never used} {wrong # of entries in index i2}} do_test pragma-3.17 { execsql { PRAGMA integrity_check=8 @@ -509,7 +509,7 @@ Page 6: never used} {row 1 missing from index i2}} } {{*** in database t2 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 *** +Page 6: never used} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {*** in database t3 *** Page 4: never used Page 5: never used}} do_test pragma-3.18 { @@ -519,7 +519,7 @@ Page 5: never used}} } {{*** in database t2 *** Page 4: never used Page 5: never used -Page 6: never used} {row 1 missing from index i2}} +Page 6: never used} {wrong # of entries in index i2}} } do_test pragma-3.19 { catch {db close} diff --git a/test/pragma4.test b/test/pragma4.test index b82df81cbd..9d5a363d65 100644 --- a/test/pragma4.test +++ b/test/pragma4.test @@ -97,7 +97,7 @@ do_test pragma4-2.100 { } string map {\[ x \] x \173 {} \175 {}} \ [db eval {EXPLAIN PRAGMA integrity_check}] -} {/ IntegrityCk 2 2 1 x[0-9]+,1x /} +} {/ IntegrityCk 1 2 8 x[0-9]+,1x /} #-------------------------------------------------------------------------- From 50f9caf2707d7e64fd17bcaf424b35d3093cf4e6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Feb 2024 18:42:09 +0000 Subject: [PATCH 0078/1030] More extensive use of SQLITE_CORRUPT_PGNO. FossilOrigin-Name: 3838332cffb87f77a7c6b357066a59b9dc4f65ef4b3496767ad7ad7c14a77be2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 46 +++++++++++++++++++++++----------------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index a24b4aa0b9..6bfc7a2a61 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\svdbe.c\scomment.\sNo\schanges\sto\scode. -D 2024-02-02T11:37:03.045 +C More\sextensive\suse\sof\sSQLITE_CORRUPT_PGNO. +D 2024-02-02T18:42:09.735 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -677,7 +677,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 186359bd695150d22b9f385ffb487b9a029ecea158658eed3a0268ee63ecbf9c +F src/btree.c bf659f4b1622c120ec6a863ba96c63f1861595ca21124950d977cec1477dd922 F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 F src/build.c 05c9eb387638982092988d2ef4c00a91b0c29baa1b85923f082ce0cf2903ea7e @@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d18d9a05c2d6f290d7b16eafced0cde4eb8dd3f869778a49103812d35a0cee65 -R aba3b7802d437f5dcd3a746bf90a6079 -U dan -Z 006ae05388cb62c50458a12f4ef45e94 +P 62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d +R ce828c7f8969aa9dd36f079e0d3d1a31 +U drh +Z a60787a93d78c5cb2066cabdbdc63c36 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c4830dab2b..29bf8b3ac3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d \ No newline at end of file +3838332cffb87f77a7c6b357066a59b9dc4f65ef4b3496767ad7ad7c14a77be2 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 57b2efc9e0..058f246701 100644 --- a/src/btree.c +++ b/src/btree.c @@ -8310,7 +8310,7 @@ static int balance_nonroot( ** table-interior, index-leaf, or index-interior). */ if( pOld->aData[0]!=apOld[0]->aData[0] ){ - rc = SQLITE_CORRUPT_BKPT; + rc = SQLITE_CORRUPT_PAGE(pOld); goto balance_cleanup; } @@ -8334,7 +8334,7 @@ static int balance_nonroot( memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow)); if( pOld->nOverflow>0 ){ if( NEVER(limitaiOvfl[0]) ){ - rc = SQLITE_CORRUPT_BKPT; + rc = SQLITE_CORRUPT_PAGE(pOld); goto balance_cleanup; } limit = pOld->aiOvfl[0]; @@ -8977,7 +8977,7 @@ static int anotherValidCursor(BtCursor *pCur){ && pOther->eState==CURSOR_VALID && pOther->pPage==pCur->pPage ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pCur->pPage); } } return SQLITE_OK; @@ -9037,7 +9037,7 @@ static int balance(BtCursor *pCur){ /* The page being written is not a root page, and there is currently ** more than one reference to it. This only happens if the page is one ** of its own ancestor pages. Corruption. */ - rc = SQLITE_CORRUPT_BKPT; + rc = SQLITE_CORRUPT_PAGE(pPage); }else{ MemPage * const pParent = pCur->apPage[iPage-1]; int const iIdx = pCur->aiIdx[iPage-1]; @@ -9201,7 +9201,7 @@ static SQLITE_NOINLINE int btreeOverwriteOverflowCell( rc = btreeGetPage(pBt, ovflPgno, &pPage, 0); if( rc ) return rc; if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 || pPage->isInit ){ - rc = SQLITE_CORRUPT_BKPT; + rc = SQLITE_CORRUPT_PAGE(pPage); }else{ if( iOffset+ovflPageSize<(u32)nTotal ){ ovflPgno = get4byte(pPage->aData); @@ -9229,7 +9229,7 @@ static int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){ if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd || pCur->info.pPayload < pPage->aData + pPage->cellOffset ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pPage); } if( pCur->info.nLocal==nTotal ){ /* The entire cell is local */ @@ -9310,7 +9310,7 @@ int sqlite3BtreeInsert( ** Which can only happen if the SQLITE_NoSchemaError flag was set when ** the schema was loaded. This cannot be asserted though, as a user might ** set the flag, load the schema, and then unset the flag. */ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PGNO(pCur->pgnoRoot); } } @@ -9433,7 +9433,7 @@ int sqlite3BtreeInsert( if( pPage->nFree<0 ){ if( NEVER(pCur->eState>CURSOR_INVALID) ){ /* ^^^^^--- due to the moveToRoot() call above */ - rc = SQLITE_CORRUPT_BKPT; + rc = SQLITE_CORRUPT_PAGE(pPage); }else{ rc = btreeComputeFreeSpace(pPage); } @@ -9472,7 +9472,7 @@ int sqlite3BtreeInsert( CellInfo info; assert( idx>=0 ); if( idx>=pPage->nCell ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pPage); } rc = sqlite3PagerWrite(pPage->pDbPage); if( rc ){ @@ -9499,10 +9499,10 @@ int sqlite3BtreeInsert( ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry. */ assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */ if( oldCell < pPage->aData+pPage->hdrOffset+10 ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pPage); } if( oldCell+szNew > pPage->aDataEnd ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pPage); } memcpy(oldCell, newCell, szNew); return SQLITE_OK; @@ -9604,7 +9604,7 @@ int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64 iKey){ nIn = pSrc->info.nLocal; aIn = pSrc->info.pPayload; if( aIn+nIn>pSrc->pPage->aDataEnd ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pSrc->pPage); } nRem = pSrc->info.nPayload; if( nIn==nRem && nInpPage->maxLocal ){ @@ -9629,7 +9629,7 @@ int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64 iKey){ if( nRem>nIn ){ if( aIn+nIn+4>pSrc->pPage->aDataEnd ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pSrc->pPage); } ovflIn = get4byte(&pSrc->info.pPayload[nIn]); } @@ -9725,7 +9725,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID ); if( rc || pCur->eState!=CURSOR_VALID ) return rc; }else{ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PGNO(pCur->pgnoRoot); } } assert( pCur->eState==CURSOR_VALID ); @@ -9734,14 +9734,14 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ iCellIdx = pCur->ix; pPage = pCur->pPage; if( pPage->nCell<=iCellIdx ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pPage); } pCell = findCell(pPage, iCellIdx); if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pPage); } if( pCell<&pPage->aCellIdx[pPage->nCell] ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PAGE(pPage); } /* If the BTREE_SAVEPOSITION bit is on, then the cursor position must @@ -9832,7 +9832,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ n = pCur->pPage->pgno; } pCell = findCell(pLeaf, pLeaf->nCell-1); - if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_BKPT; + if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_PAGE(pLeaf); nCell = pLeaf->xCellSize(pLeaf, pCell); assert( MX_CELL_SIZE(pBt) >= nCell ); pTmp = pBt->pTmpSpace; @@ -9948,7 +9948,7 @@ static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){ */ sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &pgnoRoot); if( pgnoRoot>btreePagecount(pBt) ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PGNO(pgnoRoot); } pgnoRoot++; @@ -9996,7 +9996,7 @@ static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){ } rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage); if( eType==PTRMAP_ROOTPAGE || eType==PTRMAP_FREEPAGE ){ - rc = SQLITE_CORRUPT_BKPT; + rc = SQLITE_CORRUPT_PGNO(pgnoRoot); } if( rc!=SQLITE_OK ){ releasePage(pRoot); @@ -10086,14 +10086,14 @@ static int clearDatabasePage( assert( sqlite3_mutex_held(pBt->mutex) ); if( pgno>btreePagecount(pBt) ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PGNO(pgno); } rc = getAndInitPage(pBt, pgno, &pPage, 0); if( rc ) return rc; if( (pBt->openFlags & BTREE_SINGLE)==0 && sqlite3PagerPageRefcount(pPage->pDbPage) != (1 + (pgno==1)) ){ - rc = SQLITE_CORRUPT_BKPT; + rc = SQLITE_CORRUPT_PAGE(pPage); goto cleardatabasepage_out; } hdr = pPage->hdrOffset; @@ -10197,7 +10197,7 @@ static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){ assert( p->inTrans==TRANS_WRITE ); assert( iTable>=2 ); if( iTable>btreePagecount(pBt) ){ - return SQLITE_CORRUPT_BKPT; + return SQLITE_CORRUPT_PGNO(iTable); } rc = sqlite3BtreeClearTable(p, iTable, 0); From 7d6f33046f6c52b308d58ed89e894cb37ad5a18b Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 3 Feb 2024 19:19:18 +0000 Subject: [PATCH 0079/1030] Following a ROLLBACK that reverts changes to an RTREE, any pending queries against that same RTREE abort with code SQLITE_ABORT_ROLLBACK. dbsqlfuzz de7d17b72d0e842352c998dd86a47b7d0f707be9. FossilOrigin-Name: af5c425114f32c2f84aea20edd4fa46eb1bfdeb3747fce357540e15978a070c8 --- ext/rtree/rtree.c | 21 +++++- ext/rtree/rtreeJ.test | 159 ++++++++++++++++++++++++++++++++++++++++++ manifest | 13 ++-- manifest.uuid | 2 +- 4 files changed, 186 insertions(+), 9 deletions(-) create mode 100644 ext/rtree/rtreeJ.test diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 013bb0b5b8..93a849cf0f 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -170,6 +170,7 @@ struct Rtree { u32 nBusy; /* Current number of users of this structure */ i64 nRowEst; /* Estimated number of rows in this table */ u32 nCursor; /* Number of open cursors */ + u32 iGeneration; /* Cursors with smaller iGeneration are stale */ u32 nNodeRef; /* Number RtreeNodes with positive nRef */ char *zReadAuxSql; /* SQL for statement to read aux data */ @@ -286,6 +287,7 @@ struct RtreeCursor { u8 atEOF; /* True if at end of search */ u8 bPoint; /* True if sPoint is valid */ u8 bAuxValid; /* True if pReadAux is valid */ + u32 iGeneration; /* Stale if too small */ int iStrategy; /* Copy of idxNum search parameter */ int nConstraint; /* Number of entries in aConstraint */ RtreeConstraint *aConstraint; /* Search constraints. */ @@ -1087,6 +1089,7 @@ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ if( pCsr ){ memset(pCsr, 0, sizeof(RtreeCursor)); pCsr->base.pVtab = pVTab; + pCsr->iGeneration = pRtree->iGeneration; rc = SQLITE_OK; pRtree->nCursor++; } @@ -1627,6 +1630,9 @@ static int rtreeStepToLeaf(RtreeCursor *pCur){ int eInt; RtreeSearchPoint x; + if( pCur->iGenerationiGeneration ){ + return SQLITE_ABORT_ROLLBACK; + } eInt = pRtree->eCoordType==RTREE_COORD_INT32; while( (p = rtreeSearchPointFirst(pCur))!=0 && p->iLevel>0 ){ u8 *pCellData; @@ -1854,6 +1860,7 @@ static int rtreeFilter( /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ resetCursor(pCsr); + pCsr->iGeneration = pRtree->iGeneration; pCsr->iStrategy = idxNum; if( idxNum==1 ){ @@ -3234,6 +3241,16 @@ static int rtreeEndTransaction(sqlite3_vtab *pVtab){ nodeBlobReset(pRtree); return SQLITE_OK; } +static int rtreeRollback(sqlite3_vtab *pVtab){ + Rtree *pRtree = (Rtree *)pVtab; + pRtree->iGeneration++; + return rtreeEndTransaction(pVtab); +} +static int rtreeRollbackTo(sqlite3_vtab *pVtab, int notUsed){ + Rtree *pRtree = (Rtree *)pVtab; + pRtree->iGeneration++; + return SQLITE_OK; +} /* ** The xRename method for rtree module virtual tables. @@ -3352,12 +3369,12 @@ static sqlite3_module rtreeModule = { rtreeBeginTransaction, /* xBegin - begin transaction */ rtreeEndTransaction, /* xSync - sync transaction */ rtreeEndTransaction, /* xCommit - commit transaction */ - rtreeEndTransaction, /* xRollback - rollback transaction */ + rtreeRollback, /* xRollback - rollback transaction */ 0, /* xFindFunction - function overloading */ rtreeRename, /* xRename - rename the table */ rtreeSavepoint, /* xSavepoint */ 0, /* xRelease */ - 0, /* xRollbackTo */ + rtreeRollbackTo, /* xRollbackTo */ rtreeShadowName, /* xShadowName */ rtreeIntegrity /* xIntegrity */ }; diff --git a/ext/rtree/rtreeJ.test b/ext/rtree/rtreeJ.test new file mode 100644 index 0000000000..4d9c01d29b --- /dev/null +++ b/ext/rtree/rtreeJ.test @@ -0,0 +1,159 @@ +# 2024-02-03 +# +# 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. +# +#*********************************************************************** +# +# ROLLBACK in the middle of an RTREE query +# +if {![info exists testdir]} { + set testdir [file join [file dirname [info script]] .. .. test] +} +source $testdir/tester.tcl +set testprefix rtreeJ + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2); + INSERT INTO t1 VALUES(1, 1, 1), (2, 2, 2); +} {} + +do_execsql_test 1.1 { + SELECT * FROM t1 +} {1 1.0 1.0 2 2.0 2.0} + +# If a ROLLBACK occurs that backs out changes to the RTREE, then +# all pending queries to the RTREE are aborted. +# +do_test 1.2 { + db eval { + BEGIN; + INSERT INTO t1 VALUES(3, 3, 3); + INSERT INTO t1 VALUES(4, 4, 4); + } + set rc [catch { + db eval { SELECT * FROM t1 } { + if {$id==1} { + db eval { ROLLBACK } + } + lappend res $id $x1 $x2 + } + } msg] + list $rc $msg +} {1 {abort due to ROLLBACK}} + +do_execsql_test 1.3 { + SELECT * FROM t1; +} {1 1.0 1.0 2 2.0 2.0} + +# A COMMIT of changes to the RTREE does not affect pending queries +# +do_test 1.4 { + set res {} + db eval { + BEGIN; + INSERT INTO t1 VALUES(5, 5, 5); + INSERT INTO t1 VALUES(6, 6, 6); + } + db eval { SELECT * FROM t1 } { + if {$id==1} { + db eval { COMMIT } + } + lappend res $id $x1 $x2 + } + set res +} {1 1.0 1.0 2 2.0 2.0 5 5.0 5.0 6 6.0 6.0} + +do_execsql_test 1.5 { + SELECT * FROM t1; +} {1 1.0 1.0 2 2.0 2.0 5 5.0 5.0 6 6.0 6.0} + +do_execsql_test 1.6 { + DELETE FROM t1; + INSERT INTO t1 VALUES(1,1,1),(2,2,2),(3,3,3),(4,4,4); + CREATE TABLE t2(x); + SELECT * FROM t1; +} {1 1.0 1.0 2 2.0 2.0 3 3.0 3.0 4 4.0 4.0} + +# A rollback that does not affect the rtree table because +# the rtree table has not been written to does not cause +# a query abort. +# +do_test 1.7 { + set res {} + db eval { + BEGIN; + INSERT INTO t2(x) VALUES(12345); + } + db eval { SELECT * FROM t1 } { + if {$id==1} { + db eval { ROLLBACK } + } + lappend res $id $x1 $x2 + } + set res +} {1 1.0 1.0 2 2.0 2.0 3 3.0 3.0 4 4.0 4.0} + +# ROLLBACK TO that affects the RTREE does cause a query abort. +# +do_test 1.8 { + db eval { + DELETE FROM t1 WHERE rowid>1; + BEGIN; + DELETE FROM t2; + INSERT INTO t2(x) VALUES(23456); + SAVEPOINT 'one'; + INSERT INTO t1 VALUES(2,2,2),(3,3,3); + } + set rc [catch { + db eval { SELECT * FROM t1 } { + if {$id==1} { + db eval { ROLLBACK TO 'one'; } + } + lappend res $id $x1 $x2 + } + } msg] + list $rc $msg +} {1 {abort due to ROLLBACK}} + +do_execsql_test 1.9 { + COMMIT; + SELECT * FROM t1; +} {1 1.0 1.0} + +# ROLLBACK TO that does not affect the RTREE does not cause a query abort. +# +do_execsql_test 1.10 { + DELETE FROM t1; + INSERT INTO t1 VALUES(1,1,1),(2,2,2),(3,3,3); + BEGIN; + DELETE FROM t2; + INSERT INTO t2(x) VALUES(34567); + SAVEPOINT 'one'; + INSERT INTO t2(x) VALUES('a string'); + SELECT * FROM t1; +} {1 1.0 1.0 2 2.0 2.0 3 3.0 3.0} +do_test 1.11 { + set rc [catch { + set res {} + db eval { SELECT * FROM t1 } { + if {$id==2} { + # db eval { ROLLBACK TO 'one'; } + } + lappend res $id $x1 $x2 + } + set res + } msg] + list $rc $msg +} {0 {1 1.0 1.0 2 2.0 2.0 3 3.0 3.0}} + +do_execsql_test 1.12 { + COMMIT; + SELECT * FROM t1; +} {1 1.0 1.0 2 2.0 2.0 3 3.0 3.0} + +finish_test diff --git a/manifest b/manifest index 6bfc7a2a61..df44228dfa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\sextensive\suse\sof\sSQLITE_CORRUPT_PGNO. -D 2024-02-02T18:42:09.735 +C Following\sa\sROLLBACK\sthat\sreverts\schanges\sto\san\sRTREE,\sany\spending\squeries\nagainst\sthat\ssame\sRTREE\sabort\swith\scode\sSQLITE_ABORT_ROLLBACK.\ndbsqlfuzz\sde7d17b72d0e842352c998dd86a47b7d0f707be9. +D 2024-02-03T19:19:18.306 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -495,7 +495,7 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 0dd4775e896cee6067979d67aff7c998e75c2c9d9cd8d62a1a790c09cde7adca -F ext/rtree/rtree.c d0134bb75bc92b18a1dc011ec10419642f055c67af8ff44fc4a07c5fa9f189cb +F ext/rtree/rtree.c 32e67b122e37138694d9f499cdc72241e372058560ac2d4577cfd68ccd692953 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test 2b5b8c719c6a4abe377f57766f428a49af36a93061cb146cccfdc3b30000c0a4 F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d @@ -515,6 +515,7 @@ F ext/rtree/rtreeF.test 81ffa7ef51c4e4618d497a57328c265bf576990c7070633b623b23cd F ext/rtree/rtreeG.test 1b9ca6e3effb48f4161edaa463ddeaa8fca4b2526d084f9cbf5dbe4e0184939c F ext/rtree/rtreeH.test 0885151ee8429242625600ae47142cca935332c70a06737f35af53a7bd7aaf90 F ext/rtree/rtreeI.test 608e77f7fde9be5a12eae316baef640fffaafcfa90a3d67443e78123e19c4ca4 +F ext/rtree/rtreeJ.test bafa7616d6b29448bf19132ce4963a69b629b9ca6ab29f4b76889c8d542b8dfc F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195 F ext/rtree/rtree_util.tcl 202ca70df1f0645ef9d5a2170e62d378a28098d9407f0569e85c9c1cf1bd020a F ext/rtree/rtreecheck.test 934546ad9b563e090ee0c5cbdc69ad014189ad76e5df7320526797a9a345661f @@ -2161,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d -R ce828c7f8969aa9dd36f079e0d3d1a31 +P 3838332cffb87f77a7c6b357066a59b9dc4f65ef4b3496767ad7ad7c14a77be2 +R 11b673cea59b4f2c437d0cc603cd3823 U drh -Z a60787a93d78c5cb2066cabdbdc63c36 +Z 6e995078df88af9da02ef42e8af5819d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 29bf8b3ac3..11d5e14d8d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3838332cffb87f77a7c6b357066a59b9dc4f65ef4b3496767ad7ad7c14a77be2 \ No newline at end of file +af5c425114f32c2f84aea20edd4fa46eb1bfdeb3747fce357540e15978a070c8 \ No newline at end of file From 3ab9c021ff7076dd8c942b67b658ad013587d132 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 4 Feb 2024 04:01:11 +0000 Subject: [PATCH 0080/1030] Fix harmless compiler warnings seen with MSVC. FossilOrigin-Name: e52c87420b072fa68d921eda66069542d50accbfaf1110ac4cc1543a4162200d --- ext/consio/console_io.c | 11 +++++++++++ ext/fts5/fts5_tcl.c | 2 +- ext/recover/test_recover.c | 2 +- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/json.c | 6 +++--- tool/lemon.c | 2 +- 7 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ext/consio/console_io.c b/ext/consio/console_io.c index 3acb0daa27..3e2f556f52 100755 --- a/ext/consio/console_io.c +++ b/ext/consio/console_io.c @@ -29,6 +29,9 @@ #ifndef HAVE_CONSOLE_IO_H # include "console_io.h" #endif +#if defined(_MSC_VER) +# pragma warning(disable : 4204) +#endif #ifndef SQLITE_CIO_NO_TRANSLATE # if (defined(_WIN32) || defined(WIN32)) && !SQLITE_OS_WINRT @@ -127,6 +130,10 @@ static short streamOfConsole(FILE *pf, /* out */ PerStreamTags *ppst){ # endif } +# ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING +# define ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x4) +# endif + # if CIO_WIN_WC_XLATE /* Define console modes for use with the Windows Console API. */ # define SHELL_CONI_MODE \ @@ -677,4 +684,8 @@ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){ } #endif /* !defined(SQLITE_CIO_NO_TRANSLATE) */ +#if defined(_MSC_VER) +# pragma warning(default : 4204) +#endif + #undef SHELL_INVALID_FILE_PTR diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 853a41865e..c5b5f41f83 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -1169,7 +1169,7 @@ struct OriginTextTokenizer { */ static void f5tOrigintextTokenizerDelete(void *pCtx){ OriginTextCtx *p = (OriginTextCtx*)pCtx; - ckfree(p); + ckfree((char*)p); } static int f5tOrigintextCreate( diff --git a/ext/recover/test_recover.c b/ext/recover/test_recover.c index 1c333df8e0..ba8ef6da11 100644 --- a/ext/recover/test_recover.c +++ b/ext/recover/test_recover.c @@ -236,7 +236,7 @@ static int test_sqlite3_recover_init( zDb = Tcl_GetString(objv[2]); if( zDb[0]=='\0' ) zDb = 0; - pNew = ckalloc(sizeof(TestRecover)); + pNew = (TestRecover*)ckalloc(sizeof(TestRecover)); if( bSql==0 ){ zUri = Tcl_GetString(objv[3]); pNew->p = sqlite3_recover_init(db, zDb, zUri); diff --git a/manifest b/manifest index df44228dfa..58e123f71a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Following\sa\sROLLBACK\sthat\sreverts\schanges\sto\san\sRTREE,\sany\spending\squeries\nagainst\sthat\ssame\sRTREE\sabort\swith\scode\sSQLITE_ABORT_ROLLBACK.\ndbsqlfuzz\sde7d17b72d0e842352c998dd86a47b7d0f707be9. -D 2024-02-03T19:19:18.306 +C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. +D 2024-02-04T04:01:11.343 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -51,7 +51,7 @@ F ext/README.md fd5f78013b0a2bc6f0067afb19e6ad040e89a10179b4f6f03eee58fac5f169bd F ext/async/README.txt e12275968f6fde133a80e04387d0e839b0c51f91 F ext/async/sqlite3async.c 6f247666b495c477628dd19364d279c78ea48cd90c72d9f9b98ad1aff3294f94 F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a49808287f04aa5309a -F ext/consio/console_io.c e1be639e79e54264b3ae97ca291728987a9aa82e6a4526458e6400f5e083e524 x +F ext/consio/console_io.c f32b757c9ee7fdf68e7586bee306f8368759e7cd12febb2a6839199b1c1af395 x F ext/consio/console_io.h 0548b83d7c4b7270ad544a67f2bb90cebc519637fa39b1838df4744cf0d87646 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 @@ -100,7 +100,7 @@ F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a F ext/fts5/fts5_index.c bb1965c3965f6fe5f64160bf1c0694a9684a790a783f293a76da1d38d319b258 F ext/fts5/fts5_main.c d68bd9533d5a638b7f6fae61c3cb0a15257dcdcccedaf3d0b3c9f55940c85048 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 -F ext/fts5/fts5_tcl.c cf0fd0dbe64ec272491b749e0d594f563cda03336aeb60900129e6d18b0aefb8 +F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c 83cfcede3898001cab84432a36ce1503e3080cf9b1c682b022ec82e267ea4c13 @@ -483,7 +483,7 @@ F ext/recover/recoverslowidx.test 5205a9742dd9490ee99950dabb622307355ef1662dea6a F ext/recover/recoversql.test e66d01f95302a223bcd3fd42b5ee58dc2b53d70afa90b0d00e41e4b8eab20486 F ext/recover/sqlite3recover.c e6eb20c469bcdb96f297f2241860bccabf9f036bfa7f3d47bcc6ca1191b108dc F ext/recover/sqlite3recover.h 011c799f02deb70ab685916f6f538e6bb32c4e0025e79bfd0e24ff9c74820959 -F ext/recover/test_recover.c 1a34e2d04533d919a30ae4d5caeb1643f6684e9ccd7597ca27721d8af81f4ade +F ext/recover/test_recover.c fd871a40f2238022bedcbdf3cb493b91225edaa94d6ae8892af97a10e7ccc4ba F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15 F ext/repair/checkfreelist.c e21f06995ff4efdc1622dcceaea4dcba2caa83ca2f31a1607b98a8509168a996 F ext/repair/checkindex.c af5c66463f51462d8a6f796b2c44ef8cfa1116bbdc35a15da07c67a705388bfd @@ -699,7 +699,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c e4e5f70b602c1dc9592b798166697bedeb84c61ffe857c9302ded54d5024603d +F src/json.c ae8847ccf8e212650d8a79277750f2123a03ae040d21d96ff5010114bd5b1040 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2073,7 +2073,7 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c db6c77d899f565ab42217d924e5daee5b267724433c7747fb6d3329b3c919fa1 +F tool/lemon.c 7f264d5d06450f929a20fa63a1b7e8f2df47dfaa6d7f80e4afef3639157497a4 F tool/lempar.c e6b649778e5c027c8365ff01d7ef39297cd7285fa1f881cce31792689541e79f F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3838332cffb87f77a7c6b357066a59b9dc4f65ef4b3496767ad7ad7c14a77be2 -R 11b673cea59b4f2c437d0cc603cd3823 -U drh -Z 6e995078df88af9da02ef42e8af5819d +P af5c425114f32c2f84aea20edd4fa46eb1bfdeb3747fce357540e15978a070c8 +R a9037c628a989a39c2fbbc040b232de2 +U mistachkin +Z 153e5721794f58c625079135ecdb0115 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 11d5e14d8d..e1dca3b4f3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -af5c425114f32c2f84aea20edd4fa46eb1bfdeb3747fce357540e15978a070c8 \ No newline at end of file +e52c87420b072fa68d921eda66069542d50accbfaf1110ac4cc1543a4162200d \ No newline at end of file diff --git a/src/json.c b/src/json.c index 47b83f1815..c50ded3135 100644 --- a/src/json.c +++ b/src/json.c @@ -3526,10 +3526,10 @@ static void jsonDebugPrintBlob( if( sz==0 && x<=JSONB_FALSE ){ sqlite3_str_append(pOut, "\n", 1); }else{ - u32 i; + u32 j; sqlite3_str_appendall(pOut, ": \""); - for(i=iStart+n; iaBlob[i]; + for(j=iStart+n; jaBlob[j]; if( c<0x20 || c>=0x7f ) c = '.'; sqlite3_str_append(pOut, (char*)&c, 1); } diff --git a/tool/lemon.c b/tool/lemon.c index 5b1702f4ee..0239b2d86f 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4806,7 +4806,7 @@ void ReportTable( /* Generate the table of fallback tokens. */ if( lemp->has_fallback ){ - int mx = lemp->nterminal - 1; + mx = lemp->nterminal - 1; /* 2019-08-28: Generate fallback entries for every token to avoid ** having to do a range check on the index */ /* while( mx>0 && lemp->symbols[mx]->fallback==0 ){ mx--; } */ From 7718c866e156a99320c829475ff3c29ca4b4dada Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 4 Feb 2024 04:18:29 +0000 Subject: [PATCH 0081/1030] Fix a minor test file locking issue on Windows. FossilOrigin-Name: 6cd70b71df5c0d45412081590316bced302ec4403d565250b56e611882204821 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/memdb1.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 58e123f71a..09817ef57c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. -D 2024-02-04T04:01:11.343 +C Fix\sa\sminor\stest\sfile\slocking\sissue\son\sWindows. +D 2024-02-04T04:18:29.898 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1398,7 +1398,7 @@ F test/malloctraceviewer.tcl 3e3ddf11e30d2b20f53aa16aa6615082fb24a100bea61cca721 F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7 -F test/memdb1.test cd6b6b1632cf2f76c8a6f35be013f4011f3ab2c8d74d3d1424576f29bfa4a9a1 +F test/memdb1.test 2fb27d5dadd4e7784d2229e570f6368b059fc0b7fe88ca25e46e17150ba8ad4c F test/memdb2.test 4ba1fc09e2f51df80d148a540e4a3fa66d0462e91167b27497084de4d1f6b5b4 F test/memjournal.test 70f3a00c7f84ee2978ad14e831231caa1e7f23915a2c54b4f775a021d5740c6c F test/memjournal2.test dbc2c5cb5f7b38950f4f6dc3e73fcecf0fcbed3fc32c7ce913bba164d288da1e @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P af5c425114f32c2f84aea20edd4fa46eb1bfdeb3747fce357540e15978a070c8 -R a9037c628a989a39c2fbbc040b232de2 +P e52c87420b072fa68d921eda66069542d50accbfaf1110ac4cc1543a4162200d +R b26d5bf3c069446abfcc515c5650300e U mistachkin -Z 153e5721794f58c625079135ecdb0115 +Z 46cb4b90611f7a098915a0eaa15bb642 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e1dca3b4f3..1a3e9f0d33 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e52c87420b072fa68d921eda66069542d50accbfaf1110ac4cc1543a4162200d \ No newline at end of file +6cd70b71df5c0d45412081590316bced302ec4403d565250b56e611882204821 \ No newline at end of file diff --git a/test/memdb1.test b/test/memdb1.test index e6820da4a2..3a31c8e284 100644 --- a/test/memdb1.test +++ b/test/memdb1.test @@ -84,7 +84,6 @@ do_test 152 { catchsql {INSERT INTO t1 VALUES(3,4);} } {1 {attempt to write a readonly database}} -breakpoint do_test 160 { db deserialize -maxsize 32768 $db1 db eval {SELECT * FROM t1} @@ -248,6 +247,7 @@ if {[wal_is_capable]} { set fd [open test.db] fconfigure $fd -translation binary -encoding binary set data [read $fd [expr 20*1024]] + close $fd sqlite3 db "" db deserialize $data From 0009d40325bf63ede33ae74a4c653e25ac95d0e3 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 5 Feb 2024 02:36:10 +0000 Subject: [PATCH 0082/1030] wasm: squelch a new (and, in our case, invalid) warning from emcc 3.1.52. FossilOrigin-Name: d294a23ed6d1d2b567a02552b8a2e4921cd21891ee86e63f8f9945569e3262d3 --- ext/wasm/GNUmakefile | 3 +++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 0865492cf5..226010ba8f 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -981,6 +981,9 @@ emcc.speedtest1.common += -sABORTING_MALLOC emcc.speedtest1.common += -sSTRICT_JS=0 emcc.speedtest1.common += -sMODULARIZE emcc.speedtest1.common += -Wno-limited-postlink-optimizations +emcc.speedtest1 += -Wno-unused-main +# ^^^^ -Wno-unused-main is for emcc 3.1.52+. speedtest1 has a wasm_main() which is +# exported and called by the JS code. EXPORTED_FUNCTIONS.speedtest1 := $(abspath $(dir.tmp)/EXPORTED_FUNCTIONS.speedtest1) emcc.speedtest1.common += -sSTACK_SIZE=512KB emcc.speedtest1.common += -sEXPORTED_FUNCTIONS=@$(EXPORTED_FUNCTIONS.speedtest1) diff --git a/manifest b/manifest index 09817ef57c..a67cb1e328 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sminor\stest\sfile\slocking\sissue\son\sWindows. -D 2024-02-04T04:18:29.898 +C wasm:\ssquelch\sa\snew\s(and,\sin\sour\scase,\sinvalid)\swarning\sfrom\semcc\s3.1.52. +D 2024-02-05T02:36:10.589 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -576,7 +576,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 867c903a27fa0d53a3bf1b01d8c7bb713456f87e0939c3cac9f07faa68f58734 +F ext/wasm/GNUmakefile a0de0b77d6e75c819c25999e738a7505e2c41ac3d8d283c8d1b55053690702ce F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e52c87420b072fa68d921eda66069542d50accbfaf1110ac4cc1543a4162200d -R b26d5bf3c069446abfcc515c5650300e -U mistachkin -Z 46cb4b90611f7a098915a0eaa15bb642 +P 6cd70b71df5c0d45412081590316bced302ec4403d565250b56e611882204821 +R 0ab4464af386acb25db258a324b067da +U stephan +Z c0b47723711993434189903dacb2adb6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1a3e9f0d33..441b22d3e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6cd70b71df5c0d45412081590316bced302ec4403d565250b56e611882204821 \ No newline at end of file +d294a23ed6d1d2b567a02552b8a2e4921cd21891ee86e63f8f9945569e3262d3 \ No newline at end of file From 7d3cd38034fc9cd8c322900287bf11d7bdd79f6e Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 5 Feb 2024 03:37:54 +0000 Subject: [PATCH 0083/1030] wasm: pass the promiser function to the promiser onready() callback to simplify access to it in certain usage patterns. FossilOrigin-Name: f8a8b9ee2eddf5f875c7c4399e750ccf1941f767560ebc2c88c083560f5aaae0 --- ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | 5 +++-- ext/wasm/demo-worker1-promiser.js | 2 ++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js index cd78ed4bcf..68846209e5 100644 --- a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js +++ b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js @@ -156,6 +156,7 @@ globalThis.sqlite3Worker1Promiser = function callee(config = callee.defaultConfi if(!config.worker) config.worker = callee.defaultConfig.worker; if('function'===typeof config.worker) config.worker = config.worker(); let dbId; + let promiserFunc; config.worker.onmessage = function(ev){ ev = ev.data; debug('worker1.onmessage',ev); @@ -163,7 +164,7 @@ globalThis.sqlite3Worker1Promiser = function callee(config = callee.defaultConfi if(!msgHandler){ if(ev && 'sqlite3-api'===ev.type && 'worker1-ready'===ev.result) { /*fired one time when the Worker1 API initializes*/ - if(config.onready) config.onready(); + if(config.onready) config.onready(promiserFunc); return; } msgHandler = handlerMap[ev.type] /* check for exec per-row callback */; @@ -192,7 +193,7 @@ globalThis.sqlite3Worker1Promiser = function callee(config = callee.defaultConfi try {msgHandler.resolve(ev)} catch(e){msgHandler.reject(e)} }/*worker.onmessage()*/; - return function(/*(msgType, msgArgs) || (msgEnvelope)*/){ + return promiserFunc = function(/*(msgType, msgArgs) || (msgEnvelope)*/){ let msg; if(1===arguments.length){ msg = arguments[0]; diff --git a/ext/wasm/demo-worker1-promiser.js b/ext/wasm/demo-worker1-promiser.js index c2d24623a3..4327f7487d 100644 --- a/ext/wasm/demo-worker1-promiser.js +++ b/ext/wasm/demo-worker1-promiser.js @@ -49,6 +49,8 @@ error("Unhandled worker message:",ev.data); }, onready: function(){ + T.affirm(arguments[0] === workerPromise + /* as of version 3.46. Prior to that this callback had no arguments */); self.sqlite3TestModule.setStatus(null)/*hide the HTML-side is-loading spinner*/; runTests(); }, diff --git a/manifest b/manifest index a67cb1e328..484160968f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C wasm:\ssquelch\sa\snew\s(and,\sin\sour\scase,\sinvalid)\swarning\sfrom\semcc\s3.1.52. -D 2024-02-05T02:36:10.589 +C wasm:\spass\sthe\spromiser\sfunction\sto\sthe\spromiser\sonready()\scallback\sto\ssimplify\saccess\sto\sit\sin\scertain\susage\spatterns. +D 2024-02-05T03:37:54.834 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -605,7 +605,7 @@ F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 595953994aa3ae2287c889c4da39ab3d F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js ebf6c7e997cd8948b35b3afc550b0503dd53febd9d2b56354efd11d985e5f0f2 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 -F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js f234191fe6bf41a5a1e59c9f43ed816e74a522b3d60d3f556f66c3085c448503 +F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js e8135b44a568badfe197e2379f6b42899f2240b5c3a77fa044331110f7ce8e50 F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd @@ -622,7 +622,7 @@ F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32 F ext/wasm/demo-jsstorage.html 409c4be4af5f207fb2877160724b91b33ea36a3cd8c204e8da1acb828ffe588e F ext/wasm/demo-jsstorage.js 44e3ae7ec2483b6c511384c3c290beb6f305c721186bcf5398ca4e00004a06b8 F ext/wasm/demo-worker1-promiser.html 1de7c248c7c2cfd4a5783d2aa154bce62d74c6de98ab22f5786620b3354ed15f -F ext/wasm/demo-worker1-promiser.js 5e5c7d7c91cd7aae9cc733afd02569ba9c6928292db413b550e8b842f4b75e87 +F ext/wasm/demo-worker1-promiser.js 786ae8a3214c2a29f6fb2c80eb4f90cc401fcc5b524d95c35fdc66a454e32bad F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 3a851858aad72e246a5d9c5aaf6b6a144305f1bf898ac1846760ea7bab95c9a3 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6cd70b71df5c0d45412081590316bced302ec4403d565250b56e611882204821 -R 0ab4464af386acb25db258a324b067da +P d294a23ed6d1d2b567a02552b8a2e4921cd21891ee86e63f8f9945569e3262d3 +R d80b32c2d930bb7fce3089d7ed46767b U stephan -Z c0b47723711993434189903dacb2adb6 +Z 14a50a83c75676e662aa799b27f4eeff # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 441b22d3e8..e1a1e2a3b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d294a23ed6d1d2b567a02552b8a2e4921cd21891ee86e63f8f9945569e3262d3 \ No newline at end of file +f8a8b9ee2eddf5f875c7c4399e750ccf1941f767560ebc2c88c083560f5aaae0 \ No newline at end of file From 21ded98df5182fce4c20eb0338f4c92db529cadd Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 5 Feb 2024 03:56:02 +0000 Subject: [PATCH 0084/1030] Extend [d294a23ed6d] to apply to all wasm speedtest1 builds. FossilOrigin-Name: 26f848e5e0ac34e545d2f27cf33abc46eac13e04ed9cd71084b0f7d47136ff97 --- ext/wasm/GNUmakefile | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 226010ba8f..75fc785182 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -981,7 +981,7 @@ emcc.speedtest1.common += -sABORTING_MALLOC emcc.speedtest1.common += -sSTRICT_JS=0 emcc.speedtest1.common += -sMODULARIZE emcc.speedtest1.common += -Wno-limited-postlink-optimizations -emcc.speedtest1 += -Wno-unused-main +emcc.speedtest1.common += -Wno-unused-main # ^^^^ -Wno-unused-main is for emcc 3.1.52+. speedtest1 has a wasm_main() which is # exported and called by the JS code. EXPORTED_FUNCTIONS.speedtest1 := $(abspath $(dir.tmp)/EXPORTED_FUNCTIONS.speedtest1) diff --git a/manifest b/manifest index 484160968f..ff359ab048 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C wasm:\spass\sthe\spromiser\sfunction\sto\sthe\spromiser\sonready()\scallback\sto\ssimplify\saccess\sto\sit\sin\scertain\susage\spatterns. -D 2024-02-05T03:37:54.834 +C Extend\s[d294a23ed6d]\sto\sapply\sto\sall\swasm\sspeedtest1\sbuilds. +D 2024-02-05T03:56:02.476 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -576,7 +576,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile a0de0b77d6e75c819c25999e738a7505e2c41ac3d8d283c8d1b55053690702ce +F ext/wasm/GNUmakefile 316349101671037a30311fbb40bd0b8702d9a223b5205a6a5eae8bac7b8dc1a0 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d294a23ed6d1d2b567a02552b8a2e4921cd21891ee86e63f8f9945569e3262d3 -R d80b32c2d930bb7fce3089d7ed46767b +P f8a8b9ee2eddf5f875c7c4399e750ccf1941f767560ebc2c88c083560f5aaae0 +R 8054a7da52bc11a97b67caaa9fc96227 U stephan -Z 14a50a83c75676e662aa799b27f4eeff +Z 47b7f55b1ab54c273898a455c5270730 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e1a1e2a3b3..16ae9edaa3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f8a8b9ee2eddf5f875c7c4399e750ccf1941f767560ebc2c88c083560f5aaae0 \ No newline at end of file +26f848e5e0ac34e545d2f27cf33abc46eac13e04ed9cd71084b0f7d47136ff97 \ No newline at end of file From 8e4d004ba197a17da4780bc140a780c8b297abec Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 5 Feb 2024 17:35:36 +0000 Subject: [PATCH 0085/1030] Return SQLITE_ABORT if the underlying shadow tables change in the middle of an rtree query in such a way as to invalidate an rtree internal priority queue entry. FossilOrigin-Name: 478280ef67efed854988ab4f740a38ae1937204c0434ad8da11f1869a12a6d06 --- ext/rtree/rtree.c | 23 +++------ ext/rtree/rtreeJ.test | 117 +++++++++++++++++++++++++++++++++++++++++- manifest | 19 ++++--- manifest.uuid | 2 +- 4 files changed, 135 insertions(+), 26 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 93a849cf0f..3b26878c9e 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -170,7 +170,6 @@ struct Rtree { u32 nBusy; /* Current number of users of this structure */ i64 nRowEst; /* Estimated number of rows in this table */ u32 nCursor; /* Number of open cursors */ - u32 iGeneration; /* Cursors with smaller iGeneration are stale */ u32 nNodeRef; /* Number RtreeNodes with positive nRef */ char *zReadAuxSql; /* SQL for statement to read aux data */ @@ -287,7 +286,6 @@ struct RtreeCursor { u8 atEOF; /* True if at end of search */ u8 bPoint; /* True if sPoint is valid */ u8 bAuxValid; /* True if pReadAux is valid */ - u32 iGeneration; /* Stale if too small */ int iStrategy; /* Copy of idxNum search parameter */ int nConstraint; /* Number of entries in aConstraint */ RtreeConstraint *aConstraint; /* Search constraints. */ @@ -948,6 +946,7 @@ static void nodeGetCoord( int iCoord, /* Which coordinate to extract */ RtreeCoord *pCoord /* OUT: Space to write result to */ ){ + assert( iCellzData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord); } @@ -1089,7 +1088,6 @@ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ if( pCsr ){ memset(pCsr, 0, sizeof(RtreeCursor)); pCsr->base.pVtab = pVTab; - pCsr->iGeneration = pRtree->iGeneration; rc = SQLITE_OK; pRtree->nCursor++; } @@ -1630,9 +1628,6 @@ static int rtreeStepToLeaf(RtreeCursor *pCur){ int eInt; RtreeSearchPoint x; - if( pCur->iGenerationiGeneration ){ - return SQLITE_ABORT_ROLLBACK; - } eInt = pRtree->eCoordType==RTREE_COORD_INT32; while( (p = rtreeSearchPointFirst(pCur))!=0 && p->iLevel>0 ){ u8 *pCellData; @@ -1726,7 +1721,11 @@ static int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){ int rc = SQLITE_OK; RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc); if( rc==SQLITE_OK && ALWAYS(p) ){ - *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell); + if( p->iCell>=NCELL(pNode) ){ + rc = SQLITE_ABORT; + }else{ + *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell); + } } return rc; } @@ -1744,6 +1743,7 @@ static int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ if( rc ) return rc; if( NEVER(p==0) ) return SQLITE_OK; + if( p->iCell>=NCELL(pNode) ) return SQLITE_ABORT; if( i==0 ){ sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell)); }else if( i<=pRtree->nDim2 ){ @@ -1860,7 +1860,6 @@ static int rtreeFilter( /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ resetCursor(pCsr); - pCsr->iGeneration = pRtree->iGeneration; pCsr->iStrategy = idxNum; if( idxNum==1 ){ @@ -3243,14 +3242,8 @@ static int rtreeEndTransaction(sqlite3_vtab *pVtab){ } static int rtreeRollback(sqlite3_vtab *pVtab){ Rtree *pRtree = (Rtree *)pVtab; - pRtree->iGeneration++; return rtreeEndTransaction(pVtab); } -static int rtreeRollbackTo(sqlite3_vtab *pVtab, int notUsed){ - Rtree *pRtree = (Rtree *)pVtab; - pRtree->iGeneration++; - return SQLITE_OK; -} /* ** The xRename method for rtree module virtual tables. @@ -3374,7 +3367,7 @@ static sqlite3_module rtreeModule = { rtreeRename, /* xRename - rename the table */ rtreeSavepoint, /* xSavepoint */ 0, /* xRelease */ - rtreeRollbackTo, /* xRollbackTo */ + 0, /* xRollbackTo */ rtreeShadowName, /* xShadowName */ rtreeIntegrity /* xIntegrity */ }; diff --git a/ext/rtree/rtreeJ.test b/ext/rtree/rtreeJ.test index 4d9c01d29b..cff77857c7 100644 --- a/ext/rtree/rtreeJ.test +++ b/ext/rtree/rtreeJ.test @@ -44,7 +44,7 @@ do_test 1.2 { } } msg] list $rc $msg -} {1 {abort due to ROLLBACK}} +} {1 {query aborted}} do_execsql_test 1.3 { SELECT * FROM t1; @@ -118,7 +118,7 @@ do_test 1.8 { } } msg] list $rc $msg -} {1 {abort due to ROLLBACK}} +} {1 {query aborted}} do_execsql_test 1.9 { COMMIT; @@ -156,4 +156,117 @@ do_execsql_test 1.12 { SELECT * FROM t1; } {1 1.0 1.0 2 2.0 2.0 3 3.0 3.0} +#---------------------------------------------------------------------- + +reset_db +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2); + INSERT INTO t1 VALUES(1, 1, 1), (2, 2, 2); + CREATE TABLE t2(x); +} {} + +do_test 2.1 { + db eval { + BEGIN; + INSERT INTO t1 VALUES(3, 3, 3); + PRAGMA writable_schema = RESET; + } + + set rc [catch { + db eval { SELECT x1, x2 FROM t1 } { + if {$x1==1} { + db eval { ROLLBACK } + } + lappend res $x1 $x2 + } + } msg] + list $rc $msg +} {1 {query aborted}} + +do_execsql_test 2.1 { + CREATE TABLE bak_node(nodeno, data); + CREATE TABLE bak_parent(nodeno, parentnode); + CREATE TABLE bak_rowid(rowid, nodeno); +} +proc save_t1 {} { + db eval { + DELETE FROM bak_node; + DELETE FROM bak_parent; + DELETE FROM bak_rowid; + INSERT INTO bak_node SELECT * FROM t1_node; + INSERT INTO bak_parent SELECT * FROM t1_parent; + INSERT INTO bak_rowid SELECT * FROM t1_rowid; + } +} +proc restore_t1 {} { + db eval { + DELETE FROM t1_node; + DELETE FROM t1_parent; + DELETE FROM t1_rowid; + INSERT INTO t1_node SELECT * FROM bak_node; + INSERT INTO t1_parent SELECT * FROM bak_parent; + INSERT INTO t1_rowid SELECT * FROM bak_rowid; + } +} + +do_test 2.3 { + save_t1 + db eval { + INSERT INTO t1 VALUES(3, 3, 3); + } + set rc [catch { + db eval { SELECT rowid, x1, x2 FROM t1 } { + if {$x1==1} { + restore_t1 + } + lappend res $x1 $x2 + } + } msg] + list $rc $msg +} {1 {query aborted}} +do_execsql_test 2.4 { + SELECT * FROM t1 +} {1 1.0 1.0 2 2.0 2.0} + +do_test 2.5 { + save_t1 + db eval { + INSERT INTO t1 VALUES(3, 3, 3); + } + set rc [catch { + db eval { SELECT x1 FROM t1 } { + if {$x1==1} { + restore_t1 + } + lappend res $x1 $x2 + } + } msg] + list $rc $msg +} {1 {query aborted}} +do_execsql_test 2.6 { + SELECT * FROM t1 +} {1 1.0 1.0 2 2.0 2.0} + +do_test 2.7 { + save_t1 + db eval { + INSERT INTO t1 VALUES(3, 3, 3); + } + set ::res [list] + set rc [catch { + db eval { SELECT 'abc' FROM t1 } { + if {$::res==[list]} { + restore_t1 + set ::bDone 1 + } + lappend res abc + } + } msg] + set res +} {abc abc abc} +do_execsql_test 2.6 { + SELECT * FROM t1 +} {1 1.0 1.0 2 2.0 2.0} + + finish_test diff --git a/manifest b/manifest index ff359ab048..b07bcfff0d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Extend\s[d294a23ed6d]\sto\sapply\sto\sall\swasm\sspeedtest1\sbuilds. -D 2024-02-05T03:56:02.476 +C Return\sSQLITE_ABORT\sif\sthe\sunderlying\sshadow\stables\schange\sin\sthe\smiddle\sof\san\srtree\squery\sin\ssuch\sa\sway\sas\sto\sinvalidate\san\srtree\sinternal\spriority\squeue\sentry. +D 2024-02-05T17:35:36.153 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -495,7 +495,7 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 0dd4775e896cee6067979d67aff7c998e75c2c9d9cd8d62a1a790c09cde7adca -F ext/rtree/rtree.c 32e67b122e37138694d9f499cdc72241e372058560ac2d4577cfd68ccd692953 +F ext/rtree/rtree.c d96c5d34eafcd46bc4b7645c26a4bcc3169d9e70e9df707ef91c2e90870d00d9 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test 2b5b8c719c6a4abe377f57766f428a49af36a93061cb146cccfdc3b30000c0a4 F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d @@ -515,7 +515,7 @@ F ext/rtree/rtreeF.test 81ffa7ef51c4e4618d497a57328c265bf576990c7070633b623b23cd F ext/rtree/rtreeG.test 1b9ca6e3effb48f4161edaa463ddeaa8fca4b2526d084f9cbf5dbe4e0184939c F ext/rtree/rtreeH.test 0885151ee8429242625600ae47142cca935332c70a06737f35af53a7bd7aaf90 F ext/rtree/rtreeI.test 608e77f7fde9be5a12eae316baef640fffaafcfa90a3d67443e78123e19c4ca4 -F ext/rtree/rtreeJ.test bafa7616d6b29448bf19132ce4963a69b629b9ca6ab29f4b76889c8d542b8dfc +F ext/rtree/rtreeJ.test ba4e25c409ebed4b96bf1270e72760c1344d0a464478d221dbe91e8471ac9ac6 F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195 F ext/rtree/rtree_util.tcl 202ca70df1f0645ef9d5a2170e62d378a28098d9407f0569e85c9c1cf1bd020a F ext/rtree/rtreecheck.test 934546ad9b563e090ee0c5cbdc69ad014189ad76e5df7320526797a9a345661f @@ -2162,8 +2162,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f8a8b9ee2eddf5f875c7c4399e750ccf1941f767560ebc2c88c083560f5aaae0 -R 8054a7da52bc11a97b67caaa9fc96227 -U stephan -Z 47b7f55b1ab54c273898a455c5270730 +P 26f848e5e0ac34e545d2f27cf33abc46eac13e04ed9cd71084b0f7d47136ff97 +R ac07ea666046dd35038bc77784e8d419 +T *branch * rtree-fix +T *sym-rtree-fix * +T -sym-trunk * +U dan +Z 6f11e0396699443c7473bed77f9c3651 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 16ae9edaa3..19b20648c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -26f848e5e0ac34e545d2f27cf33abc46eac13e04ed9cd71084b0f7d47136ff97 \ No newline at end of file +478280ef67efed854988ab4f740a38ae1937204c0434ad8da11f1869a12a6d06 \ No newline at end of file From db9cc74c9ce786947c34497d778216b3acd9b373 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 6 Feb 2024 08:25:23 +0000 Subject: [PATCH 0086/1030] Make explicit that using the importDb() methods of the OPFS VFSes has undefined results if the being-imported db is currently open. Doc changes only. FossilOrigin-Name: f28b9924b401b359e59a73918a34b29cde719164a6b4ac5a9d23da6294b701bd --- ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js | 5 +++-- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 3 +++ manifest | 17 ++++++++--------- manifest.uuid | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 870073cc09..f3664fd4b8 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -1137,8 +1137,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ existing content. Throws if the pool has no available file slots, on I/O error, or if the input does not appear to be a database. In the latter case, only a cursory examination is made. - Note that this routine is _only_ for importing database files, - not arbitrary files, the reason being that this VFS will + Results are undefined if the given db name refers to an opened + db. Note that this routine is _only_ for importing database + files, not arbitrary files, the reason being that this VFS will automatically clean up any non-database files so importing them is pointless. diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index f7c92100a0..0d695e524e 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -1193,6 +1193,9 @@ const installOpfsVfs = function callee(options){ Asynchronously imports the given bytes (a byte array or ArrayBuffer) into the given database file. + Results are undefined if the given db name refers to an opened + db. + If passed a function for its second argument, its behaviour changes to async and it imports its data in chunks fed to it by the given callback function. It calls the callback (which may diff --git a/manifest b/manifest index 1639f718b8..c31056920d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Return\sSQLITE_ABORT\sif\sthe\sunderlying\sshadow\stables\schange\sin\sthe\smiddle\sof\san\srtree\squery\sin\ssuch\sa\sway\sas\sto\sinvalidate\san\srtree\sinternal\spriority\squeue\sentry.\sThis\sreplaces\sthe\sSQLITE_ABORT_ROLLBACK\smechanism\sadded\sin\s[af5c4251]. -D 2024-02-05T17:54:03.662 +C Make\sexplicit\sthat\susing\sthe\simportDb()\smethods\sof\sthe\sOPFS\sVFSes\shas\sundefined\sresults\sif\sthe\sbeing-imported\sdb\sis\scurrently\sopen.\sDoc\schanges\sonly. +D 2024-02-06T08:25:23.546 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -601,8 +601,8 @@ F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b59 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 595953994aa3ae2287c889c4da39ab3d6f17b6461ecf4bec334b7a3faafddb02 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js ebf6c7e997cd8948b35b3afc550b0503dd53febd9d2b56354efd11d985e5f0f2 +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aaedc1bb45489b8365bff7e955a83a8d42a +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 87b947b25ffa0c8f661092564c7491b8eea96964f1a5e8e530a3c67c91715e3e F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js e8135b44a568badfe197e2379f6b42899f2240b5c3a77fa044331110f7ce8e50 @@ -2162,9 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 26f848e5e0ac34e545d2f27cf33abc46eac13e04ed9cd71084b0f7d47136ff97 478280ef67efed854988ab4f740a38ae1937204c0434ad8da11f1869a12a6d06 -R 23677f173f1ac581895d1554488f83a5 -T +closed 478280ef67efed854988ab4f740a38ae1937204c0434ad8da11f1869a12a6d06 -U dan -Z 1c1abeb44ec4a55c053a1bd1e00c844a +P 32f85a5ce8e32506ad0cf309c86589958f38d924b4b3de532bec8bdb8e385fad +R f5c99d8b43326c6a4a8c0c192ca7fcea +U stephan +Z 3bdb798c91ad2510474753c9351d5d94 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4f37fd460d..e16cd7286d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32f85a5ce8e32506ad0cf309c86589958f38d924b4b3de532bec8bdb8e385fad \ No newline at end of file +f28b9924b401b359e59a73918a34b29cde719164a6b4ac5a9d23da6294b701bd \ No newline at end of file From 72c7bb3e1afd4f542eb74da834ff66092f3d972c Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 6 Feb 2024 08:59:59 +0000 Subject: [PATCH 0087/1030] Correct docs about the first OFPS VFS's importDb() method being synchronous (it's not, whereas the second VFS's importDb() is). FossilOrigin-Name: ae7505fa5e112f39a329befb35eff6ddf46a53f5deb610906550bf67f56fc157 --- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 17 ++++++++--------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index 0d695e524e..f7fd951a40 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -1197,15 +1197,14 @@ const installOpfsVfs = function callee(options){ db. If passed a function for its second argument, its behaviour - changes to async and it imports its data in chunks fed to it by - the given callback function. It calls the callback (which may - be async) repeatedly, expecting either a Uint8Array or - ArrayBuffer (to denote new input) or undefined (to denote - EOF). For so long as the callback continues to return - non-undefined, it will append incoming data to the given - VFS-hosted database file. When called this way, the resolved - value of the returned Promise is the number of bytes written to - the target file. + changes: imports its data in chunks fed to it by the given + callback function. It calls the callback (which may be async) + repeatedly, expecting either a Uint8Array or ArrayBuffer (to + denote new input) or undefined (to denote EOF). For so long as + the callback continues to return non-undefined, it will append + incoming data to the given VFS-hosted database file. When + called this way, the resolved value of the returned Promise is + the number of bytes written to the target file. It very specifically requires the input to be an SQLite3 database and throws if that's not the case. It does so in diff --git a/manifest b/manifest index c31056920d..492071588e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sexplicit\sthat\susing\sthe\simportDb()\smethods\sof\sthe\sOPFS\sVFSes\shas\sundefined\sresults\sif\sthe\sbeing-imported\sdb\sis\scurrently\sopen.\sDoc\schanges\sonly. -D 2024-02-06T08:25:23.546 +C Correct\sdocs\sabout\sthe\sfirst\sOFPS\sVFS's\simportDb()\smethod\sbeing\ssynchronous\s(it's\snot,\swhereas\sthe\ssecond\sVFS's\simportDb()\sis). +D 2024-02-06T08:59:59.394 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -602,7 +602,7 @@ F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d299 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aaedc1bb45489b8365bff7e955a83a8d42a -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 87b947b25ffa0c8f661092564c7491b8eea96964f1a5e8e530a3c67c91715e3e +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js fe427645e1499618f5fa7bc670af850577d8bcc132df982078690c9bf8400baa F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js e8135b44a568badfe197e2379f6b42899f2240b5c3a77fa044331110f7ce8e50 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 32f85a5ce8e32506ad0cf309c86589958f38d924b4b3de532bec8bdb8e385fad -R f5c99d8b43326c6a4a8c0c192ca7fcea +P f28b9924b401b359e59a73918a34b29cde719164a6b4ac5a9d23da6294b701bd +R d8475422eb55a236e4813bd575b83968 U stephan -Z 3bdb798c91ad2510474753c9351d5d94 +Z 87c60489a9bd431cc3758cc39138e437 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e16cd7286d..71b6a414d3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f28b9924b401b359e59a73918a34b29cde719164a6b4ac5a9d23da6294b701bd \ No newline at end of file +ae7505fa5e112f39a329befb35eff6ddf46a53f5deb610906550bf67f56fc157 \ No newline at end of file From 8babc0189224773fc41aed95ee603d056385908f Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 6 Feb 2024 18:33:01 +0000 Subject: [PATCH 0088/1030] Slight change to OOM handling in JSON to catch a corner case found by dbsqlfuzz. FossilOrigin-Name: 6a2b3266c586d12b51e11fe63cda5881be9373207aa16671ab77f547830eb790 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/json.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 492071588e..e10d300129 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correct\sdocs\sabout\sthe\sfirst\sOFPS\sVFS's\simportDb()\smethod\sbeing\ssynchronous\s(it's\snot,\swhereas\sthe\ssecond\sVFS's\simportDb()\sis). -D 2024-02-06T08:59:59.394 +C Slight\schange\sto\sOOM\shandling\sin\sJSON\sto\scatch\sa\scorner\scase\sfound\sby\ndbsqlfuzz. +D 2024-02-06T18:33:01.726 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -699,7 +699,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c ae8847ccf8e212650d8a79277750f2123a03ae040d21d96ff5010114bd5b1040 +F src/json.c 0c98979fac084ea5055738fb3467cd431543aaa94acf374d412cac4b89b1acbf F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f28b9924b401b359e59a73918a34b29cde719164a6b4ac5a9d23da6294b701bd -R d8475422eb55a236e4813bd575b83968 -U stephan -Z 87c60489a9bd431cc3758cc39138e437 +P ae7505fa5e112f39a329befb35eff6ddf46a53f5deb610906550bf67f56fc157 +R bb17ade8dce33fbd8ddcb5bbd3943bbd +U drh +Z 8a6aaa8f9831a5f71eadc202a02ba963 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 71b6a414d3..278abcfe72 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ae7505fa5e112f39a329befb35eff6ddf46a53f5deb610906550bf67f56fc157 \ No newline at end of file +6a2b3266c586d12b51e11fe63cda5881be9373207aa16671ab77f547830eb790 \ No newline at end of file diff --git a/src/json.c b/src/json.c index c50ded3135..1a4ce3af19 100644 --- a/src/json.c +++ b/src/json.c @@ -3359,8 +3359,9 @@ static JsonParse *jsonParseFuncArg( } p->zJson = (char*)sqlite3_value_text(pArg); p->nJson = sqlite3_value_bytes(pArg); + if( db->mallocFailed ) goto json_pfa_oom; if( p->nJson==0 ) goto json_pfa_malformed; - if( NEVER(p->zJson==0) ) goto json_pfa_oom; + assert( p->zJson!=0 ); if( jsonConvertTextToBlob(p, (flgs & JSON_KEEPERROR) ? 0 : ctx) ){ if( flgs & JSON_KEEPERROR ){ p->nErr = 1; From 71cdea8f5f0551e1a77a11705ad65ce4b583db2c Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 7 Feb 2024 14:05:38 +0000 Subject: [PATCH 0089/1030] Detect and respond to an OOM on the jsonStringTerminate() call of jsonReturnStringAsBlob() routine. FossilOrigin-Name: 881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/json.c | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index e10d300129..33b0966c6b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Slight\schange\sto\sOOM\shandling\sin\sJSON\sto\scatch\sa\scorner\scase\sfound\sby\ndbsqlfuzz. -D 2024-02-06T18:33:01.726 +C Detect\sand\srespond\sto\san\sOOM\son\sthe\sjsonStringTerminate()\scall\sof\njsonReturnStringAsBlob()\sroutine. +D 2024-02-07T14:05:38.048 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -699,7 +699,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 0c98979fac084ea5055738fb3467cd431543aaa94acf374d412cac4b89b1acbf +F src/json.c a0346bef35804e468b9ea0c34a08960f4f543a61683182a3ec1fe30df3b98140 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ae7505fa5e112f39a329befb35eff6ddf46a53f5deb610906550bf67f56fc157 -R bb17ade8dce33fbd8ddcb5bbd3943bbd +P 6a2b3266c586d12b51e11fe63cda5881be9373207aa16671ab77f547830eb790 +R f921e7ed48eb9865e88c87b2fd0e4d7e U drh -Z 8a6aaa8f9831a5f71eadc202a02ba963 +Z 643b9a87bc06a07fb41a72f9a7566e9f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 278abcfe72..a559efd0b5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a2b3266c586d12b51e11fe63cda5881be9373207aa16671ab77f547830eb790 \ No newline at end of file +881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a \ No newline at end of file diff --git a/src/json.c b/src/json.c index 1a4ce3af19..3aa4b4e500 100644 --- a/src/json.c +++ b/src/json.c @@ -1623,6 +1623,7 @@ static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){ case '[': { /* Parse array */ iThis = pParse->nBlob; + assert( i<=pParse->nJson ); jsonBlobAppendNode(pParse, JSONB_ARRAY, pParse->nJson - i, 0); iStart = pParse->nBlob; if( pParse->oom ) return -1; @@ -2027,6 +2028,10 @@ static void jsonReturnStringAsBlob(JsonString *pStr){ JsonParse px; memset(&px, 0, sizeof(px)); jsonStringTerminate(pStr); + if( pStr->eErr ){ + sqlite3_result_error_nomem(pStr->pCtx); + return; + } px.zJson = pStr->zBuf; px.nJson = pStr->nUsed; px.db = sqlite3_context_db_handle(pStr->pCtx); From 204b41955ee3d3784dc4ee12f09085a2fd6af80d Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 7 Feb 2024 19:17:44 +0000 Subject: [PATCH 0090/1030] Turns out the branch is reachable, so back out the NEVER(). FossilOrigin-Name: 0af36a3223d2dabda887830390a603ab4781baca7e2f1698ec6c5f2cf03faf04 --- manifest | 13 +++++++------ manifest.uuid | 2 +- src/vdbesort.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 33b0966c6b..5689557247 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Detect\sand\srespond\sto\san\sOOM\son\sthe\sjsonStringTerminate()\scall\sof\njsonReturnStringAsBlob()\sroutine. -D 2024-02-07T14:05:38.048 +C Turns\sout\sthe\sbranch\sis\sreachable,\sso\sback\sout\sthe\sNEVER(). +D 2024-02-07T19:17:44.741 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -816,7 +816,7 @@ F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b F src/vdbeaux.c c5a471b34e9c4cfc0295a3e10734fd197670ffaebcb742f284c8e17e8026ceea F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 3e37dab421b74e9ce55c1e88fbc7bc6fead590b5ab258bc684f8b70abb1d6e71 -F src/vdbesort.c 00c1fb15171205063556c2f1cf454e24c0b41c1effb0c876b850dce91f21bc64 +F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 F src/vtab.c 11948e105f56e84099ca17f1f434b1944539ea84de26d0d767eadfbc670ce1ea @@ -2162,8 +2162,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a2b3266c586d12b51e11fe63cda5881be9373207aa16671ab77f547830eb790 -R f921e7ed48eb9865e88c87b2fd0e4d7e +P 881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a +Q -9411337a7b3237366768fc708396da53d67a7a17b6cdc5c6f8932c5ab32217a9 +R f3327a0935c4e5c636d36e7e0586529c U drh -Z 643b9a87bc06a07fb41a72f9a7566e9f +Z a7ed96a42f4b8ee08a15aed5a446fbe9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a559efd0b5..32dea90bc5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a \ No newline at end of file +0af36a3223d2dabda887830390a603ab4781baca7e2f1698ec6c5f2cf03faf04 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 324c7c43e3..0083690308 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -1290,7 +1290,7 @@ static void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){ sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_CHUNK_SIZE, &chunksize); sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_SIZE_HINT, &nByte); sqlite3OsFetch(pFd, 0, (int)nByte, &p); - if( NEVER(p) ) sqlite3OsUnfetch(pFd, 0, p); + if( p ) sqlite3OsUnfetch(pFd, 0, p); } } #else From 722bd1fe89da923720fcaab13fb4498c5e00575d Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 7 Feb 2024 19:52:03 +0000 Subject: [PATCH 0091/1030] Bring test cases into alignment with the latest enhancements. FossilOrigin-Name: cd017c28d516399e25b5ee9e8fcd7390ca2be9128c7c41f1007f37bc01a35717 --- ext/rtree/rtreeJ.test | 1 + manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/sqllimits1.test | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ext/rtree/rtreeJ.test b/ext/rtree/rtreeJ.test index cff77857c7..b091d2c686 100644 --- a/ext/rtree/rtreeJ.test +++ b/ext/rtree/rtreeJ.test @@ -16,6 +16,7 @@ if {![info exists testdir]} { } source $testdir/tester.tcl set testprefix rtreeJ +ifcapable !rtree { finish_test ; return } do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2); diff --git a/manifest b/manifest index 5689557247..f1c4317f1e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Turns\sout\sthe\sbranch\sis\sreachable,\sso\sback\sout\sthe\sNEVER(). -D 2024-02-07T19:17:44.741 +C Bring\stest\scases\sinto\salignment\swith\sthe\slatest\senhancements. +D 2024-02-07T19:52:03.118 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -515,7 +515,7 @@ F ext/rtree/rtreeF.test 81ffa7ef51c4e4618d497a57328c265bf576990c7070633b623b23cd F ext/rtree/rtreeG.test 1b9ca6e3effb48f4161edaa463ddeaa8fca4b2526d084f9cbf5dbe4e0184939c F ext/rtree/rtreeH.test 0885151ee8429242625600ae47142cca935332c70a06737f35af53a7bd7aaf90 F ext/rtree/rtreeI.test 608e77f7fde9be5a12eae316baef640fffaafcfa90a3d67443e78123e19c4ca4 -F ext/rtree/rtreeJ.test ba4e25c409ebed4b96bf1270e72760c1344d0a464478d221dbe91e8471ac9ac6 +F ext/rtree/rtreeJ.test 93227ccd4d6c328f5ac46a902b8880041509dd2d68f6ce71560f0d8ab5bb507a F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195 F ext/rtree/rtree_util.tcl 202ca70df1f0645ef9d5a2170e62d378a28098d9407f0569e85c9c1cf1bd020a F ext/rtree/rtreecheck.test 934546ad9b563e090ee0c5cbdc69ad014189ad76e5df7320526797a9a345661f @@ -1633,7 +1633,7 @@ F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 F test/spellfix4.test 51c7c26514ade169855c66bcf130bd5acfb4d7fd090cc624645ab275ae6a41fb F test/sqldiff1.test 1b7ab4f312442c5cc6b3a5f299fa8ca051416d1dd173cb1126fd51bf64f2c3fb -F test/sqllimits1.test b28e5cc8d337aaf290614d96a47e8fbfb720bb7ad35620c9d5432996fd413ac4 +F test/sqllimits1.test 5880a2f107185744ba4d93637f44c78d17706a9899a38b694d50f209735c81cc F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a F test/startup.c 1beb5ca66fcc0fce95c3444db9d1674f90fc605499a574ae2434dcfc10d22805 F test/stat.test 123212a20ceb496893d5254a5f6c76442ce549fdc08d1702d8288a2bbaac8408 @@ -2162,9 +2162,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a -Q -9411337a7b3237366768fc708396da53d67a7a17b6cdc5c6f8932c5ab32217a9 -R f3327a0935c4e5c636d36e7e0586529c +P 0af36a3223d2dabda887830390a603ab4781baca7e2f1698ec6c5f2cf03faf04 +Q +81bd7aee093ddb7405bf12e9c9a915d410fb3103d3b19cce21be63d97256904c +R 8fc57b3ff811df04d2f88b3e6328966f U drh -Z a7ed96a42f4b8ee08a15aed5a446fbe9 +Z e908575b96347b2a10ba2f1656de4a56 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 32dea90bc5..33a20b533f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0af36a3223d2dabda887830390a603ab4781baca7e2f1698ec6c5f2cf03faf04 \ No newline at end of file +cd017c28d516399e25b5ee9e8fcd7390ca2be9128c7c41f1007f37bc01a35717 \ No newline at end of file diff --git a/test/sqllimits1.test b/test/sqllimits1.test index f16208f234..e9e20f40cc 100644 --- a/test/sqllimits1.test +++ b/test/sqllimits1.test @@ -707,6 +707,7 @@ if {$SQLITE_MAX_EXPR_DEPTH==0} { }] } "1 {Expression tree is too large (maximum depth $::SQLITE_MAX_EXPR_DEPTH)}" +if 0 { # Attempting to beat the expression depth limit using nested SELECT # queries causes a parser stack overflow. do_test sqllimits1-9.2 { @@ -718,7 +719,6 @@ if {$SQLITE_MAX_EXPR_DEPTH==0} { catchsql [subst { $expr }] } "1 {parser stack overflow}" -if 0 { do_test sqllimits1-9.3 { execsql { PRAGMA max_page_count = 1000000; -- 1 GB From 0f777cd622d19a5112a58ada3ff67af4c4af831d Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 7 Feb 2024 20:45:38 +0000 Subject: [PATCH 0092/1030] Fix an #endif (added in the wrong place by [8f4b1ceafe4a271b]) so that the build works with SQLITE_OMIT_VIRTUAL_TABLE. FossilOrigin-Name: 7070924eebce1d089fde911dc0427ab8f3764d57ace24caff2b79954b42d1b51 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/pragma.c | 3 +-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f1c4317f1e..33cb6032bb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bring\stest\scases\sinto\salignment\swith\sthe\slatest\senhancements. -D 2024-02-07T19:52:03.118 +C Fix\san\s#endif\s(added\sin\sthe\swrong\splace\sby\s[8f4b1ceafe4a271b])\sso\sthat\nthe\sbuild\sworks\swith\sSQLITE_OMIT_VIRTUAL_TABLE. +D 2024-02-07T20:45:38.362 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c f9b6bb9a044a0dfda1f31c2d1523c7970f850688b450f06e61e23672d70adac0 +F src/pragma.c 017c04c842da70c04f31df5163d139e01693fdaa48a9058843fd520eee0ad426 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -2162,9 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0af36a3223d2dabda887830390a603ab4781baca7e2f1698ec6c5f2cf03faf04 -Q +81bd7aee093ddb7405bf12e9c9a915d410fb3103d3b19cce21be63d97256904c -R 8fc57b3ff811df04d2f88b3e6328966f +P cd017c28d516399e25b5ee9e8fcd7390ca2be9128c7c41f1007f37bc01a35717 +R 2d9fa4a2af3419f8f53f008b15026f33 U drh -Z e908575b96347b2a10ba2f1656de4a56 +Z e59ddf9aaf84b24c6fc5197c4cee87c1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 33a20b533f..a7c1376605 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd017c28d516399e25b5ee9e8fcd7390ca2be9128c7c41f1007f37bc01a35717 \ No newline at end of file +7070924eebce1d089fde911dc0427ab8f3764d57ace24caff2b79954b42d1b51 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 79c4e0ae84..775c990f98 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2116,10 +2116,9 @@ void sqlite3Pragma( a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); integrityCheckResultRow(v); sqlite3VdbeJumpHere(v, a1); -#endif continue; } - +#endif } { static const int iLn = VDBE_OFFSET_LINENO(2); From 25e172d429e2f549b148024ef75470db871b93e3 Mon Sep 17 00:00:00 2001 From: larrybr Date: Thu, 8 Feb 2024 01:19:46 +0000 Subject: [PATCH 0093/1030] Mention limited lifetime of string arrays passed to sqlite3_exec() callback. FossilOrigin-Name: 717f67f3189a59842f5c17a25e8db0e24ec4405886fc22ab6eeb3954fba5a964 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 33cb6032bb..9aa176bf1f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\s#endif\s(added\sin\sthe\swrong\splace\sby\s[8f4b1ceafe4a271b])\sso\sthat\nthe\sbuild\sworks\swith\sSQLITE_OMIT_VIRTUAL_TABLE. -D 2024-02-07T20:45:38.362 +C Mention\slimited\slifetime\sof\sstring\sarrays\spassed\sto\ssqlite3_exec()\scallback. +D 2024-02-08T01:19:46.361 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -741,7 +741,7 @@ F src/resolve.c 0ed10ebb70d15dcf3f1882051931ccfaf9c3f4debe67dbd114047d9e2adb9523 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da F src/shell.c.in c6cb773b7703d76677529de19d1c40584520701966422c33da3e9334498a7099 -F src/sqlite.h.in 61a60b4ea04db8ead15e1579b20b64cb56e9f55d52c5f9f9694de630110593a3 +F src/sqlite.h.in ebb9636c0e99d692bdc22e70df3766dc615120aeddde81214547f51998bbd21d F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 5013ac1f5642df4c0b76314f507f4c7b6f8efee0e1d7c2e93bf8b445ceea29bb @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cd017c28d516399e25b5ee9e8fcd7390ca2be9128c7c41f1007f37bc01a35717 -R 2d9fa4a2af3419f8f53f008b15026f33 -U drh -Z e59ddf9aaf84b24c6fc5197c4cee87c1 +P 7070924eebce1d089fde911dc0427ab8f3764d57ace24caff2b79954b42d1b51 +R 2754c4cd5c9c2d2fe3f97bd6f57b4998 +U larrybr +Z bdbab30aa887dd5009861f5b93382dca # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a7c1376605..da391229d2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7070924eebce1d089fde911dc0427ab8f3764d57ace24caff2b79954b42d1b51 \ No newline at end of file +717f67f3189a59842f5c17a25e8db0e24ec4405886fc22ab6eeb3954fba5a964 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 4a19fe918a..ddd8fc6939 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -420,6 +420,8 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. **
  • The application must not modify the SQL statement text passed into ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. +**
  • The application must not dereference the arrays or string pointers +** passed as the 3rd and 4th parameters after the callback returns. ** */ int sqlite3_exec( From 589c407f1257d8fa4a13da753b15d72eb282cbcf Mon Sep 17 00:00:00 2001 From: larrybr Date: Sat, 10 Feb 2024 03:11:42 +0000 Subject: [PATCH 0094/1030] Further clarify sqlite3_exec() callback parameter lifetime. FossilOrigin-Name: 993a1a843177b19a9cb5598f57d1e05c01e1695f164faaa9ae22810ad4533eba --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9aa176bf1f..7fa4237cf2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Mention\slimited\slifetime\sof\sstring\sarrays\spassed\sto\ssqlite3_exec()\scallback. -D 2024-02-08T01:19:46.361 +C Further\sclarify\ssqlite3_exec()\scallback\sparameter\slifetime. +D 2024-02-10T03:11:42.492 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -741,7 +741,7 @@ F src/resolve.c 0ed10ebb70d15dcf3f1882051931ccfaf9c3f4debe67dbd114047d9e2adb9523 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da F src/shell.c.in c6cb773b7703d76677529de19d1c40584520701966422c33da3e9334498a7099 -F src/sqlite.h.in ebb9636c0e99d692bdc22e70df3766dc615120aeddde81214547f51998bbd21d +F src/sqlite.h.in 020d7b7307dda51420dc48b47e5334eaface77baba6bd9818375d392eb3ab5b5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 5013ac1f5642df4c0b76314f507f4c7b6f8efee0e1d7c2e93bf8b445ceea29bb @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7070924eebce1d089fde911dc0427ab8f3764d57ace24caff2b79954b42d1b51 -R 2754c4cd5c9c2d2fe3f97bd6f57b4998 +P 717f67f3189a59842f5c17a25e8db0e24ec4405886fc22ab6eeb3954fba5a964 +R 64f77dbf6c9a67d1a6681b063264b76b U larrybr -Z bdbab30aa887dd5009861f5b93382dca +Z 925b1d0fbc30e91dd097edf85eb7f5c3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index da391229d2..153c997809 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -717f67f3189a59842f5c17a25e8db0e24ec4405886fc22ab6eeb3954fba5a964 \ No newline at end of file +993a1a843177b19a9cb5598f57d1e05c01e1695f164faaa9ae22810ad4533eba \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ddd8fc6939..f21cffd51a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -421,7 +421,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); **
  • The application must not modify the SQL statement text passed into ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. **
  • The application must not dereference the arrays or string pointers -** passed as the 3rd and 4th parameters after the callback returns. +** passed as the 3rd and 4th callback parameters after it returns. ** */ int sqlite3_exec( From ece3567aec217b9e302e56295968966d8d7a3782 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 11 Feb 2024 18:53:48 +0000 Subject: [PATCH 0095/1030] Improved AggInfo tracing in debug builds. No changes to deliverable code. FossilOrigin-Name: bb31f9c44794e02a46ed3edbcc96eb48c5870d3f82cb404586ded9a3efa7a859 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7fa4237cf2..4216332915 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\sclarify\ssqlite3_exec()\scallback\sparameter\slifetime. -D 2024-02-10T03:11:42.492 +C Improved\sAggInfo\stracing\sin\sdebug\sbuilds.\s\sNo\schanges\sto\sdeliverable\scode. +D 2024-02-11T18:53:48.466 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -739,7 +739,7 @@ F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 0ed10ebb70d15dcf3f1882051931ccfaf9c3f4debe67dbd114047d9e2adb9523 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da +F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 F src/shell.c.in c6cb773b7703d76677529de19d1c40584520701966422c33da3e9334498a7099 F src/sqlite.h.in 020d7b7307dda51420dc48b47e5334eaface77baba6bd9818375d392eb3ab5b5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 717f67f3189a59842f5c17a25e8db0e24ec4405886fc22ab6eeb3954fba5a964 -R 64f77dbf6c9a67d1a6681b063264b76b -U larrybr -Z 925b1d0fbc30e91dd097edf85eb7f5c3 +P 993a1a843177b19a9cb5598f57d1e05c01e1695f164faaa9ae22810ad4533eba +R b08d58139ab071fec772aaa3f5cfa8ae +U drh +Z 8c006f746e6086c64fa306e943cc82cc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 153c997809..764a7523c6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -993a1a843177b19a9cb5598f57d1e05c01e1695f164faaa9ae22810ad4533eba \ No newline at end of file +bb31f9c44794e02a46ed3edbcc96eb48c5870d3f82cb404586ded9a3efa7a859 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 1215727791..81e802d6e4 100644 --- a/src/select.c +++ b/src/select.c @@ -6444,6 +6444,8 @@ void sqlite3SelectPrep( */ static void printAggInfo(AggInfo *pAggInfo){ int ii; + sqlite3DebugPrintf("AggInfo %d/%p:\n", + pAggInfo->selId, pAggInfo); for(ii=0; iinColumn; ii++){ struct AggInfo_col *pCol = &pAggInfo->aCol[ii]; sqlite3DebugPrintf( @@ -8546,6 +8548,12 @@ int sqlite3Select( sqlite3ExprListDelete(db, pMinMaxOrderBy); #ifdef SQLITE_DEBUG if( pAggInfo && !db->mallocFailed ){ +#if TREETRACE_ENABLED + if( sqlite3TreeTrace & 0x20 ){ + TREETRACE(0x20,pParse,p,("Finished with AggInfo\n")); + printAggInfo(pAggInfo); + } +#endif for(i=0; inColumn; i++){ Expr *pExpr = pAggInfo->aCol[i].pCExpr; if( pExpr==0 ) continue; From 3c5a810646a060aeb3019942bf66278168df8f3b Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 11 Feb 2024 20:53:14 +0000 Subject: [PATCH 0096/1030] If a term of an ORDER BY or GROUP BY contains an aggregate function or column, then it is not an alias that needs to be resolved, so don't try to. This fixes a harmless assertion found by dbsqlfuzz. This yet another problem that orginated at check-in [6e6b3729e0549de0]. FossilOrigin-Name: d4ec2a5d2297cd9ead0a8768dcf003ea76c74d8d68d88c40f62363f484a4a4d3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/resolve.c | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 4216332915..2940231722 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sAggInfo\stracing\sin\sdebug\sbuilds.\s\sNo\schanges\sto\sdeliverable\scode. -D 2024-02-11T18:53:48.466 +C If\sa\sterm\sof\san\sORDER\sBY\sor\sGROUP\sBY\scontains\san\saggregate\sfunction\sor\scolumn,\nthen\sit\sis\snot\san\salias\sthat\sneeds\sto\sbe\sresolved,\sso\sdon't\stry\sto.\s\sThis\sfixes\na\sharmless\sassertion\sfound\sby\sdbsqlfuzz.\s\sThis\syet\sanother\sproblem\sthat\norginated\sat\scheck-in\s[6e6b3729e0549de0]. +D 2024-02-11T20:53:14.723 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -737,7 +737,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 0ed10ebb70d15dcf3f1882051931ccfaf9c3f4debe67dbd114047d9e2adb9523 +F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 F src/shell.c.in c6cb773b7703d76677529de19d1c40584520701966422c33da3e9334498a7099 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 993a1a843177b19a9cb5598f57d1e05c01e1695f164faaa9ae22810ad4533eba -R b08d58139ab071fec772aaa3f5cfa8ae +P bb31f9c44794e02a46ed3edbcc96eb48c5870d3f82cb404586ded9a3efa7a859 +R 420903d8a166efd58090018027845648 U drh -Z 8c006f746e6086c64fa306e943cc82cc +Z 77dfb496104764f5c2dcbb370d30ed43 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 764a7523c6..bbcaf95855 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bb31f9c44794e02a46ed3edbcc96eb48c5870d3f82cb404586ded9a3efa7a859 \ No newline at end of file +d4ec2a5d2297cd9ead0a8768dcf003ea76c74d8d68d88c40f62363f484a4a4d3 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 29975f385a..5d0801e82e 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -79,6 +79,8 @@ static void resolveAlias( assert( iCol>=0 && iColnExpr ); pOrig = pEList->a[iCol].pExpr; assert( pOrig!=0 ); + assert( !ExprHasProperty(pExpr, EP_Reduced|EP_TokenOnly) ); + if( pExpr->pAggInfo ) return; db = pParse->db; pDup = sqlite3ExprDup(db, pOrig, 0); if( db->mallocFailed ){ From 18b6019cdd2e036496b91c764b2b953b167545d5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 11 Feb 2024 22:56:12 +0000 Subject: [PATCH 0097/1030] In the RTREE extension, allow the xBeginTransaction() entry point to be invoked multiple times without intervening calls to xEndTransaction(). FossilOrigin-Name: f023cb541b5dd72c996f0574210344179217666a2229bc8d3fe057fdbc5c2245 --- ext/rtree/rtree.c | 3 +-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 578e6e8623..2b3adc842e 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -3225,8 +3225,7 @@ static int rtreeUpdate( */ static int rtreeBeginTransaction(sqlite3_vtab *pVtab){ Rtree *pRtree = (Rtree *)pVtab; - assert( pRtree->inWrTrans==0 ); - pRtree->inWrTrans++; + pRtree->inWrTrans = 1; return SQLITE_OK; } diff --git a/manifest b/manifest index 2940231722..8796f34b8c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\sterm\sof\san\sORDER\sBY\sor\sGROUP\sBY\scontains\san\saggregate\sfunction\sor\scolumn,\nthen\sit\sis\snot\san\salias\sthat\sneeds\sto\sbe\sresolved,\sso\sdon't\stry\sto.\s\sThis\sfixes\na\sharmless\sassertion\sfound\sby\sdbsqlfuzz.\s\sThis\syet\sanother\sproblem\sthat\norginated\sat\scheck-in\s[6e6b3729e0549de0]. -D 2024-02-11T20:53:14.723 +C In\sthe\sRTREE\sextension,\sallow\sthe\sxBeginTransaction()\sentry\spoint\sto\sbe\ninvoked\smultiple\stimes\swithout\sintervening\scalls\sto\sxEndTransaction(). +D 2024-02-11T22:56:12.780 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -495,7 +495,7 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 0dd4775e896cee6067979d67aff7c998e75c2c9d9cd8d62a1a790c09cde7adca -F ext/rtree/rtree.c 920884cfeb88e8a77ef23d70bc696c1a59f2de03b8e877c0966ae81ea61aa41a +F ext/rtree/rtree.c 1b6422e7b9aff51583477bf8c49b51655b19bd9905b4d8fe48f4c1f0c95b2359 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test 2b5b8c719c6a4abe377f57766f428a49af36a93061cb146cccfdc3b30000c0a4 F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bb31f9c44794e02a46ed3edbcc96eb48c5870d3f82cb404586ded9a3efa7a859 -R 420903d8a166efd58090018027845648 +P d4ec2a5d2297cd9ead0a8768dcf003ea76c74d8d68d88c40f62363f484a4a4d3 +R ee61d12c62e00e1e12755723a284535a U drh -Z 77dfb496104764f5c2dcbb370d30ed43 +Z 02dccfc637ae0768eeec52f6adfd1264 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bbcaf95855..2acfec195a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d4ec2a5d2297cd9ead0a8768dcf003ea76c74d8d68d88c40f62363f484a4a4d3 \ No newline at end of file +f023cb541b5dd72c996f0574210344179217666a2229bc8d3fe057fdbc5c2245 \ No newline at end of file From b29047838d7b8de39467800944b3d169cf1f495b Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 12 Feb 2024 13:28:10 +0000 Subject: [PATCH 0098/1030] Add support for the ".testctrl fault_install" dot-command in the CLI when launched with the --unsafe-testing option. FossilOrigin-Name: 5ba7fee1a9b49df82387e355d2ab7de58663d3fa824e50717608b27e0f7ac874 --- manifest | 12 +++---- manifest.uuid | 2 +- src/shell.c.in | 92 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 98 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8796f34b8c..4a3f57ce5e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sRTREE\sextension,\sallow\sthe\sxBeginTransaction()\sentry\spoint\sto\sbe\ninvoked\smultiple\stimes\swithout\sintervening\scalls\sto\sxEndTransaction(). -D 2024-02-11T22:56:12.780 +C Add\ssupport\sfor\sthe\s".testctrl\sfault_install"\sdot-command\sin\sthe\sCLI\swhen\nlaunched\swith\sthe\s--unsafe-testing\soption. +D 2024-02-12T13:28:10.404 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -740,7 +740,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in c6cb773b7703d76677529de19d1c40584520701966422c33da3e9334498a7099 +F src/shell.c.in 2382dc2327e47af76b37a7a468152a509dc0a8e72dad887fb868102ecbd94fe8 F src/sqlite.h.in 020d7b7307dda51420dc48b47e5334eaface77baba6bd9818375d392eb3ab5b5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d4ec2a5d2297cd9ead0a8768dcf003ea76c74d8d68d88c40f62363f484a4a4d3 -R ee61d12c62e00e1e12755723a284535a +P f023cb541b5dd72c996f0574210344179217666a2229bc8d3fe057fdbc5c2245 +R c8236513dfcf0ef943c428e779c4a525 U drh -Z 02dccfc637ae0768eeec52f6adfd1264 +Z 58d2be401311d1f16e9ad87e4e189606 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2acfec195a..ed3511505f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f023cb541b5dd72c996f0574210344179217666a2229bc8d3fe057fdbc5c2245 \ No newline at end of file +5ba7fee1a9b49df82387e355d2ab7de58663d3fa824e50717608b27e0f7ac874 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 353db72ede..6bd81a0470 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -7884,6 +7884,38 @@ static int outputDumpWarning(ShellState *p, const char *zLike){ return rc; } +/* +** Fault-Simulator state and logic. +*/ +static struct { + int iId; /* ID that triggers a simulated fault. -1 means "any" */ + int iErr; /* The error code to return on a fault */ + int iCnt; /* Trigger the fault only if iCnt is already zero */ + int iInterval; /* Reset iCnt to this value after each fault */ + int eVerbose; /* When to print output */ +} faultsim_state = {-1, 0, 0, 0, 0}; + +/* +** This is the fault-sim callback +*/ +static int faultsim_callback(int iArg){ + if( faultsim_state.iId>0 && faultsim_state.iId!=iArg ){ + return SQLITE_OK; + } + if( faultsim_state.iCnt>0 ){ + faultsim_state.iCnt--; + if( faultsim_state.eVerbose>=2 ){ + oputf("FAULT-SIM id=%d no-fault (cnt=%d)\n", iArg, faultsim_state.iCnt); + } + return SQLITE_OK; + } + if( faultsim_state.eVerbose>=1 ){ + oputf("FAULT-SIM id=%d returns %d\n", iArg, faultsim_state.iErr); + } + faultsim_state.iCnt = faultsim_state.iInterval; + return faultsim_state.iErr; +} + /* ** If an input line begins with "." then invoke this routine to ** process that line. @@ -10772,7 +10804,7 @@ static int do_meta_command(char *zLine, ShellState *p){ /*{"bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, 1, "" },*/ {"byteorder", SQLITE_TESTCTRL_BYTEORDER, 0, "" }, {"extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,0,"BOOLEAN" }, - /*{"fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, 1,"" },*/ + {"fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, 1,"args..." }, {"fk_no_action", SQLITE_TESTCTRL_FK_NO_ACTION, 0, "BOOLEAN" }, {"imposter", SQLITE_TESTCTRL_IMPOSTER,1,"SCHEMA ON/OFF ROOTPAGE"}, {"internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS,0,"" }, @@ -11005,6 +11037,64 @@ static int do_meta_command(char *zLine, ShellState *p){ } sqlite3_test_control(testctrl, &rc2); break; + case SQLITE_TESTCTRL_FAULT_INSTALL: { + int kk; + int bShowHelp = nArg<=2; + isOk = 3; + for(kk=2; kk0 ) faultsim_state.eVerbose--; + }else if( cli_strcmp(z,"-id")==0 && kk+1=0 ){ From 84dea8264b783dcfe780633ddae1e57b5f37be57 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 12 Feb 2024 13:51:08 +0000 Subject: [PATCH 0099/1030] Add a new sqlite3FaultSim() call in the btree logic, for testing. FossilOrigin-Name: e0558f79b8184ea6741fb20b710dab854f5bdb71aa47d5a6701eeb7389540c8c --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/btree.c | 9 ++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 4a3f57ce5e..22930876aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sthe\s".testctrl\sfault_install"\sdot-command\sin\sthe\sCLI\swhen\nlaunched\swith\sthe\s--unsafe-testing\soption. -D 2024-02-12T13:28:10.404 +C Add\sa\snew\ssqlite3FaultSim()\scall\sin\sthe\sbtree\slogic,\sfor\stesting. +D 2024-02-12T13:51:08.316 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -678,7 +678,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c bf659f4b1622c120ec6a863ba96c63f1861595ca21124950d977cec1477dd922 +F src/btree.c dfd351decf9f819393dae8fb7294cae69c3818069d27f47fee34d5b505e37b47 F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 F src/build.c 05c9eb387638982092988d2ef4c00a91b0c29baa1b85923f082ce0cf2903ea7e @@ -2162,8 +2162,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f023cb541b5dd72c996f0574210344179217666a2229bc8d3fe057fdbc5c2245 -R c8236513dfcf0ef943c428e779c4a525 +P 5ba7fee1a9b49df82387e355d2ab7de58663d3fa824e50717608b27e0f7ac874 +R 0edcf4f3ab18268eaee9147c5810abce +T *branch * new-btree-faultsim +T *sym-new-btree-faultsim * +T -sym-trunk * U drh -Z 58d2be401311d1f16e9ad87e4e189606 +Z 917d838d939c74582a89abdf802d5804 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ed3511505f..d1246e8e86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5ba7fee1a9b49df82387e355d2ab7de58663d3fa824e50717608b27e0f7ac874 \ No newline at end of file +e0558f79b8184ea6741fb20b710dab854f5bdb71aa47d5a6701eeb7389540c8c \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 058f246701..49c07c81a6 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5128,9 +5128,12 @@ static int accessPayload( if( pCur->aOverflow==0 || nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow) ){ - Pgno *aNew = (Pgno*)sqlite3Realloc( - pCur->aOverflow, nOvfl*2*sizeof(Pgno) - ); + Pgno *aNew; + if( sqlite3FaultSim(413) ){ + aNew = 0; + }else{ + aNew = (Pgno*)sqlite3Realloc(pCur->aOverflow, nOvfl*2*sizeof(Pgno)); + } if( aNew==0 ){ return SQLITE_NOMEM_BKPT; }else{ From 98a8ffb3b3592cdf16a5bee21f15aa2a7f5bb584 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 12 Feb 2024 16:12:25 +0000 Subject: [PATCH 0100/1030] Have rtree avoid keeping a blob handle open following an error. FossilOrigin-Name: 1cd5d4623f44af25ab4f5af580354b3ae22cf5de4109e008ca41055125bb708d --- ext/rtree/rtree.c | 14 +++++++------- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 2b3adc842e..02127fa117 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -694,11 +694,9 @@ static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){ ** Clear the Rtree.pNodeBlob object */ static void nodeBlobReset(Rtree *pRtree){ - if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){ - sqlite3_blob *pBlob = pRtree->pNodeBlob; - pRtree->pNodeBlob = 0; - sqlite3_blob_close(pBlob); - } + sqlite3_blob *pBlob = pRtree->pNodeBlob; + pRtree->pNodeBlob = 0; + sqlite3_blob_close(pBlob); } /* @@ -742,7 +740,6 @@ static int nodeAcquire( &pRtree->pNodeBlob); } if( rc ){ - nodeBlobReset(pRtree); *ppNode = 0; /* If unable to open an sqlite3_blob on the desired row, that can only ** be because the shadow tables hold erroneous data. */ @@ -802,6 +799,7 @@ static int nodeAcquire( } *ppNode = pNode; }else{ + nodeBlobReset(pRtree); if( pNode ){ pRtree->nNodeRef--; sqlite3_free(pNode); @@ -1136,7 +1134,9 @@ static int rtreeClose(sqlite3_vtab_cursor *cur){ sqlite3_finalize(pCsr->pReadAux); sqlite3_free(pCsr); pRtree->nCursor--; - nodeBlobReset(pRtree); + if( pRtree->nCursor==0 && pRtree->inWrTrans==0 ){ + nodeBlobReset(pRtree); + } return SQLITE_OK; } diff --git a/manifest b/manifest index dd40f4c05a..aec907f877 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\ssqlite3FaultSim()\sto\sbtree\sfor\sbetter\sfault\sanalysis. -D 2024-02-12T14:44:35.288 +C Have\srtree\savoid\skeeping\sa\sblob\shandle\sopen\sfollowing\san\serror. +D 2024-02-12T16:12:25.013 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -495,7 +495,7 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 0dd4775e896cee6067979d67aff7c998e75c2c9d9cd8d62a1a790c09cde7adca -F ext/rtree/rtree.c 1b6422e7b9aff51583477bf8c49b51655b19bd9905b4d8fe48f4c1f0c95b2359 +F ext/rtree/rtree.c bdf97fac91b37b3a6041ab4a0dd06e81c7ba1541601733b40f97fb51e76e79ce F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test 2b5b8c719c6a4abe377f57766f428a49af36a93061cb146cccfdc3b30000c0a4 F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d @@ -2162,9 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5ba7fee1a9b49df82387e355d2ab7de58663d3fa824e50717608b27e0f7ac874 e0558f79b8184ea6741fb20b710dab854f5bdb71aa47d5a6701eeb7389540c8c -R 0edcf4f3ab18268eaee9147c5810abce -T +closed e0558f79b8184ea6741fb20b710dab854f5bdb71aa47d5a6701eeb7389540c8c -U drh -Z b0ed70b83eb4a1ec81d9b2beb169bda8 +P 2c675bd30568d3c530300beb3fcfaa17c9f063cdcb9a39ac68b9902100f641a6 +R 7630f9e2445b646399b67a3fa625e210 +U dan +Z 2ae954926487fe7e892424e070aafe51 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 882750191a..4a963ad93e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2c675bd30568d3c530300beb3fcfaa17c9f063cdcb9a39ac68b9902100f641a6 \ No newline at end of file +1cd5d4623f44af25ab4f5af580354b3ae22cf5de4109e008ca41055125bb708d \ No newline at end of file From 8e821c251d27816352f3330e9992dcc3b5dceeaa Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 12 Feb 2024 19:12:30 +0000 Subject: [PATCH 0101/1030] Replace the assert() that was removed by [f023cb541b5dd72c] because [1cd5d4623f44af25] made it true again. FossilOrigin-Name: 189a49f165dfc348a8730ad2b2288b9b2b2089b1de99fa2d515f2a90c9e7bd4e --- ext/rtree/rtree.c | 1 + manifest | 15 ++++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 02127fa117..11996d110c 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -3225,6 +3225,7 @@ static int rtreeUpdate( */ static int rtreeBeginTransaction(sqlite3_vtab *pVtab){ Rtree *pRtree = (Rtree *)pVtab; + assert( pRtree->inWrTrans==0 ); pRtree->inWrTrans = 1; return SQLITE_OK; } diff --git a/manifest b/manifest index aec907f877..92c04c0d06 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\srtree\savoid\skeeping\sa\sblob\shandle\sopen\sfollowing\san\serror. -D 2024-02-12T16:12:25.013 +C Replace\sthe\sassert()\sthat\swas\sremoved\sby\s[f023cb541b5dd72c]\sbecause\n[1cd5d4623f44af25]\smade\sit\strue\sagain. +D 2024-02-12T19:12:30.456 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -495,7 +495,7 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 0dd4775e896cee6067979d67aff7c998e75c2c9d9cd8d62a1a790c09cde7adca -F ext/rtree/rtree.c bdf97fac91b37b3a6041ab4a0dd06e81c7ba1541601733b40f97fb51e76e79ce +F ext/rtree/rtree.c 1baf9f6aa7251ddecdb019d914df4db46eb227720c00f89c485c66dbfdc7863d F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test 2b5b8c719c6a4abe377f57766f428a49af36a93061cb146cccfdc3b30000c0a4 F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d @@ -2162,8 +2162,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2c675bd30568d3c530300beb3fcfaa17c9f063cdcb9a39ac68b9902100f641a6 -R 7630f9e2445b646399b67a3fa625e210 -U dan -Z 2ae954926487fe7e892424e070aafe51 +P 1cd5d4623f44af25ab4f5af580354b3ae22cf5de4109e008ca41055125bb708d +Q -f023cb541b5dd72c996f0574210344179217666a2229bc8d3fe057fdbc5c2245 +R d8d7ed01b0a724bd44cf51cd5b54db00 +U drh +Z 301c11d3df27d865badec38ed88ff9b4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4a963ad93e..aac78a6d6d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1cd5d4623f44af25ab4f5af580354b3ae22cf5de4109e008ca41055125bb708d \ No newline at end of file +189a49f165dfc348a8730ad2b2288b9b2b2089b1de99fa2d515f2a90c9e7bd4e \ No newline at end of file From 54eb54c7de06e050023d97dc521e77308bf3df64 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 13 Feb 2024 17:11:19 +0000 Subject: [PATCH 0102/1030] Changes to vtabCallConstructor() to avoid a harmless static analyzer warning and to help prove that the UAF reported by [forum:/forumpost/cafbe582e8|forum post cafbe582e8] is a false-positive. FossilOrigin-Name: 4892440b93306e5a245f18c0d3d295d851e6712260e420016c0d70e12abf8901 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/vtab.c | 4 +++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 92c04c0d06..a1a83bb1fe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Replace\sthe\sassert()\sthat\swas\sremoved\sby\s[f023cb541b5dd72c]\sbecause\n[1cd5d4623f44af25]\smade\sit\strue\sagain. -D 2024-02-12T19:12:30.456 +C Changes\sto\svtabCallConstructor()\sto\savoid\sa\sharmless\sstatic\sanalyzer\swarning\nand\sto\shelp\sprove\sthat\sthe\sUAF\sreported\sby\n[forum:/forumpost/cafbe582e8|forum\spost\scafbe582e8]\sis\sa\sfalse-positive. +D 2024-02-13T17:11:19.402 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -819,7 +819,7 @@ F src/vdbemem.c 3e37dab421b74e9ce55c1e88fbc7bc6fead590b5ab258bc684f8b70abb1d6e71 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 -F src/vtab.c 11948e105f56e84099ca17f1f434b1944539ea84de26d0d767eadfbc670ce1ea +F src/vtab.c 38fcf63832f7e606755fa47b028c2eb6d6cd5facb40e280d66fbda4ed9a52188 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 @@ -2162,9 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1cd5d4623f44af25ab4f5af580354b3ae22cf5de4109e008ca41055125bb708d -Q -f023cb541b5dd72c996f0574210344179217666a2229bc8d3fe057fdbc5c2245 -R d8d7ed01b0a724bd44cf51cd5b54db00 +P 189a49f165dfc348a8730ad2b2288b9b2b2089b1de99fa2d515f2a90c9e7bd4e +R c17ff8a1420ebd333737eedeb07f4b72 U drh -Z 301c11d3df27d865badec38ed88ff9b4 +Z 905b73f73ae952da68046cffedfa5860 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aac78a6d6d..c332564904 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -189a49f165dfc348a8730ad2b2288b9b2b2089b1de99fa2d515f2a90c9e7bd4e \ No newline at end of file +4892440b93306e5a245f18c0d3d295d851e6712260e420016c0d70e12abf8901 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index f839216787..67226c63c8 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -611,6 +611,8 @@ static int vtabCallConstructor( db->pVtabCtx = &sCtx; pTab->nTabRef++; rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr); + assert( pTab!=0 ); + assert( pTab->nTabRef>1 || rc!=SQLITE_OK ); sqlite3DeleteTable(db, pTab); db->pVtabCtx = sCtx.pPrior; if( rc==SQLITE_NOMEM ) sqlite3OomFault(db); @@ -633,7 +635,7 @@ static int vtabCallConstructor( pVTable->nRef = 1; if( sCtx.bDeclared==0 ){ const char *zFormat = "vtable constructor did not declare schema: %s"; - *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName); + *pzErr = sqlite3MPrintf(db, zFormat, zModuleName); sqlite3VtabUnlock(pVTable); rc = SQLITE_ERROR; }else{ From 95b5295f52a5db0d09b1ace8a6854f7d53fc0cfa Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 13 Feb 2024 18:41:46 +0000 Subject: [PATCH 0103/1030] Fix a bug in PRAGMA integrity_check introduced by enhancement (8a) in [https://sqlite.org/releaselog/3_42_0.html|release 3.42.0] and first reported by [forum:/forumpost/ee4f6fa5ab|forum post ee4f6fa5ab]. FossilOrigin-Name: 460353dfff8f2fb03f9c8666d0c367ec7be4cfa96dfcb0cea10f144d043223bb --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pragma.c | 1 + test/pragma.test | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a1a83bb1fe..5a67d9340c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\svtabCallConstructor()\sto\savoid\sa\sharmless\sstatic\sanalyzer\swarning\nand\sto\shelp\sprove\sthat\sthe\sUAF\sreported\sby\n[forum:/forumpost/cafbe582e8|forum\spost\scafbe582e8]\sis\sa\sfalse-positive. -D 2024-02-13T17:11:19.402 +C Fix\sa\sbug\sin\sPRAGMA\sintegrity_check\sintroduced\sby\senhancement\s(8a)\sin\n[https://sqlite.org/releaselog/3_42_0.html|release\s3.42.0]\sand\sfirst\sreported\sby\n[forum:/forumpost/ee4f6fa5ab|forum\spost\see4f6fa5ab]. +D 2024-02-13T18:41:46.416 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 017c04c842da70c04f31df5163d139e01693fdaa48a9058843fd520eee0ad426 +F src/pragma.c b61a1a1801befe6763e787b96988deb156a56e82a2b4dea004bc78e4551c9d5c F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -1482,7 +1482,7 @@ F test/pendingrace.test 6aa33756b950c4529f79c4f3817a9a1e4025bd0d9961571a05c0279b F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff F test/permutations.test f7caf8dd5c7b1da74842a48df116f7f193399c656d4ffc805cd0d9658568c675 F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f -F test/pragma.test 57a36226218c03cfb381019fe43234b2cefbd8a1f12825514f906a17ccf7991e +F test/pragma.test cddd4b534d7fb5cf113d1308dea4231f3548e8a7f3a65d7d1cf4810c87090b5a F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 F test/pragma4.test ca5e4dfc46adfe490f75d73734f70349d95a199e6510973899e502eef2c8b1f8 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 189a49f165dfc348a8730ad2b2288b9b2b2089b1de99fa2d515f2a90c9e7bd4e -R c17ff8a1420ebd333737eedeb07f4b72 +P 4892440b93306e5a245f18c0d3d295d851e6712260e420016c0d70e12abf8901 +R 6caa0669ab38f9f6a39aaa796ed2bee2 U drh -Z 905b73f73ae952da68046cffedfa5860 +Z f4541a674d73c1bd74cd3c989d7c9de5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c332564904..a6e3849faf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4892440b93306e5a245f18c0d3d295d851e6712260e420016c0d70e12abf8901 \ No newline at end of file +460353dfff8f2fb03f9c8666d0c367ec7be4cfa96dfcb0cea10f144d043223bb \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 775c990f98..a1243acc16 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1897,6 +1897,7 @@ void sqlite3Pragma( ** is REAL, we have to load the actual data using OP_Column ** to reliably determine if the value is a NULL. */ sqlite3VdbeAddOp3(v, OP_Column, p1, p3, 3); + sqlite3ColumnDefault(v, pTab, j, 3); jmp3 = sqlite3VdbeAddOp2(v, OP_NotNull, 3, labelOk); VdbeCoverage(v); } diff --git a/test/pragma.test b/test/pragma.test index 5b45a74400..8f78a7e026 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -556,6 +556,21 @@ ifcapable altertable { do_execsql_test pragma-3.23 { PRAGMA integrity_check(1); } {{non-unique entry in index t1a}} + + # forum post https://sqlite.org/forum/forumpost/ee4f6fa5ab + do_execsql_test pragma-3.24 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(a); + INSERT INTO t1 VALUES (1); + ALTER TABLE t1 ADD COLUMN b NOT NULL DEFAULT 0.25; + SELECT * FROM t1; + PRAGMA integrity_check(t1); + } {1 0.25 ok} + do_execsql_test pragma-3.25 { + ALTER TABLE t1 ADD COLUMN c CHECK (1); + SELECT * FROM t1; + PRAGMA integrity_check(t1); + } {1 0.25 {} ok} } # PRAGMA integrity check (or more specifically the sqlite3BtreeCount() From 5e5831a760e066318f0a63e0665dae7aa39afe6c Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 16 Feb 2024 11:41:47 +0000 Subject: [PATCH 0104/1030] Handle an OOM case in fts5 code to query tokendata=1 tables. FossilOrigin-Name: 01222d96b9ab24c7013a2587544304ba32c1f039b08c06a04d8d58ec9c790db0 --- ext/fts5/fts5_index.c | 11 +++++++---- ext/fts5/test/fts5faultH.test | 11 ++++++++++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 8eb8f328f6..333fefa2d3 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -6837,23 +6837,26 @@ static void fts5IterSetOutputsTokendata(Fts5Iter *pIter){ static void fts5TokendataIterNext(Fts5Iter *pIter, int bFrom, i64 iFrom){ int ii; Fts5TokenDataIter *pT = pIter->pTokenDataIter; + Fts5Index *pIndex = pIter->pIndex; for(ii=0; iinIter; ii++){ Fts5Iter *p = pT->apIter[ii]; if( p->base.bEof==0 && (p->base.iRowid==pIter->base.iRowid || (bFrom && p->base.iRowidpIndex, p, bFrom, iFrom); + fts5MultiIterNext(pIndex, p, bFrom, iFrom); while( bFrom && p->base.bEof==0 && p->base.iRowidpIndex->rc==SQLITE_OK + && pIndex->rc==SQLITE_OK ){ - fts5MultiIterNext(p->pIndex, p, 0, 0); + fts5MultiIterNext(pIndex, p, 0, 0); } } } - fts5IterSetOutputsTokendata(pIter); + if( pIndex->rc==SQLITE_OK ){ + fts5IterSetOutputsTokendata(pIter); + } } /* diff --git a/ext/fts5/test/fts5faultH.test b/ext/fts5/test/fts5faultH.test index 540b889f37..df430f20fa 100644 --- a/ext/fts5/test/fts5faultH.test +++ b/ext/fts5/test/fts5faultH.test @@ -127,7 +127,7 @@ do_execsql_test 3.0 { COMMIT; } -do_faultsim_test 3 -faults oom* -prep { +do_faultsim_test 3.1 -faults oom* -prep { } -body { execsql { SELECT rowid FROM t1('BBB AND AAA'); @@ -136,6 +136,15 @@ do_faultsim_test 3 -faults oom* -prep { faultsim_integrity_check faultsim_test_result {0 {10 35}} } +do_faultsim_test 3.2 -faults oom* -prep { +} -body { + execsql { + SELECT count(*) FROM t1('BBB'); + } +} -test { + faultsim_integrity_check + faultsim_test_result {0 27} +} finish_test diff --git a/manifest b/manifest index 5a67d9340c..af610a8e0e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\sPRAGMA\sintegrity_check\sintroduced\sby\senhancement\s(8a)\sin\n[https://sqlite.org/releaselog/3_42_0.html|release\s3.42.0]\sand\sfirst\sreported\sby\n[forum:/forumpost/ee4f6fa5ab|forum\spost\see4f6fa5ab]. -D 2024-02-13T18:41:46.416 +C Handle\san\sOOM\scase\sin\sfts5\scode\sto\squery\stokendata=1\stables. +D 2024-02-16T11:41:47.064 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -97,7 +97,7 @@ F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70 F ext/fts5/fts5_config.c 8072a207034b51ae9b7694121d1b5715c794e94b275e088f70ae532378ca5cdf F ext/fts5/fts5_expr.c e91156ebdcc08d837f4f324168f69f3c0d7fdef0e521fd561efb48ef3297b696 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 -F ext/fts5/fts5_index.c bb1965c3965f6fe5f64160bf1c0694a9684a790a783f293a76da1d38d319b258 +F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 F ext/fts5/fts5_main.c d68bd9533d5a638b7f6fae61c3cb0a15257dcdcccedaf3d0b3c9f55940c85048 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 @@ -171,7 +171,7 @@ F ext/fts5/test/fts5faultD.test e7ed7895abfe6bc98a5e853826f6b74956e7ba7f594f1860 F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e4710c77eb8ce7075 F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test d2e5a4d9a34e08dcaadcaeafef74d10cbc2abdd11aa2659a18af0294bf2812d3 -F ext/fts5/test/fts5faultH.test 57f53c87ffd59be0265840f2b54a16811f9cb9012db86aad9b41d0d14d85dfe3 +F ext/fts5/test/fts5faultH.test b5c3b62642b7d321504a0a4f424eb80b4f6927969173334c8ca20df388557622 F ext/fts5/test/fts5first.test 3fcf2365c00a15fc9704233674789a3b95131d12de18a9b996159f6909dc8079 F ext/fts5/test/fts5full.test e1701a112354e0ff9a1fdffb0c940c576530c33732ee20ac5e8361777070d717 F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4892440b93306e5a245f18c0d3d295d851e6712260e420016c0d70e12abf8901 -R 6caa0669ab38f9f6a39aaa796ed2bee2 -U drh -Z f4541a674d73c1bd74cd3c989d7c9de5 +P 460353dfff8f2fb03f9c8666d0c367ec7be4cfa96dfcb0cea10f144d043223bb +R f8da140c9660a1305ed16f2a20382e32 +U dan +Z 434c4140de6f11763b5cde367e07b573 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a6e3849faf..376869bc29 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -460353dfff8f2fb03f9c8666d0c367ec7be4cfa96dfcb0cea10f144d043223bb \ No newline at end of file +01222d96b9ab24c7013a2587544304ba32c1f039b08c06a04d8d58ec9c790db0 \ No newline at end of file From 9d00aba8959abc5ea57360d43e8160fb6136c663 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 16 Feb 2024 12:57:04 +0000 Subject: [PATCH 0105/1030] Rename the TF_StatsUsed flag to TF_MaybeReanalyze, to more accurately reflect its usage. No logic changes. FossilOrigin-Name: b4790da5e0d6f0f617e6c3a17fc2606842e41cab14339392abd335410fec0aa3 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/pragma.c | 2 +- src/sqliteInt.h | 3 +-- src/where.c | 4 ++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index af610a8e0e..4b23b6788b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Handle\san\sOOM\scase\sin\sfts5\scode\sto\squery\stokendata=1\stables. -D 2024-02-16T11:41:47.064 +C Rename\sthe\sTF_StatsUsed\sflag\sto\sTF_MaybeReanalyze,\sto\smore\saccurately\nreflect\sits\susage.\s\sNo\slogic\schanges. +D 2024-02-16T12:57:04.964 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c b61a1a1801befe6763e787b96988deb156a56e82a2b4dea004bc78e4551c9d5c +F src/pragma.c 24584cc928538426e047db670f21f3816286812e48dfd391a40e788f14d3cea2 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -744,7 +744,7 @@ F src/shell.c.in 2382dc2327e47af76b37a7a468152a509dc0a8e72dad887fb868102ecbd94fe F src/sqlite.h.in 020d7b7307dda51420dc48b47e5334eaface77baba6bd9818375d392eb3ab5b5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 5013ac1f5642df4c0b76314f507f4c7b6f8efee0e1d7c2e93bf8b445ceea29bb +F src/sqliteInt.h 2f3a38c3e0470b6152ec14f698e6f3310831e3c09b6e56f046a12c3e3bdd5cd4 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -824,7 +824,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 0a6492afeb75f8d2a50e26b993eb78e9623b142e637cd3f2cdb85e896931d51d +F src/where.c 0e7bf004a578eb70d54300503fdbcaaea857de6ba0204aae1adf572edb79c2c6 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c dc5096eca5ed503999be3bdee8a90c51361289a678d396a220912e9cb73b3c00 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 460353dfff8f2fb03f9c8666d0c367ec7be4cfa96dfcb0cea10f144d043223bb -R f8da140c9660a1305ed16f2a20382e32 -U dan -Z 434c4140de6f11763b5cde367e07b573 +P 01222d96b9ab24c7013a2587544304ba32c1f039b08c06a04d8d58ec9c790db0 +R 5e5b0ae5c12dce6d73ff009cddfe3c44 +U drh +Z a8dd3bda9012a6e778f3b0295c3fea74 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 376869bc29..a222b41c70 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -01222d96b9ab24c7013a2587544304ba32c1f039b08c06a04d8d58ec9c790db0 \ No newline at end of file +b4790da5e0d6f0f617e6c3a17fc2606842e41cab14339392abd335410fec0aa3 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index a1243acc16..872177e131 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2450,7 +2450,7 @@ void sqlite3Pragma( /* If table pTab has not been used in a way that would benefit from ** having analysis statistics during the current session, then skip it. ** This also has the effect of skipping virtual tables and views */ - if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue; + if( (pTab->tabFlags & TF_MaybeReanalyze)==0 ) continue; /* Reanalyze if the table is 25 times larger than the last analysis */ szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 ); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 9d9657f3cc..1c1055f42f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2476,8 +2476,7 @@ struct Table { #define TF_HasStored 0x00000040 /* Has one or more STORED columns */ #define TF_HasGenerated 0x00000060 /* Combo: HasVirtual + HasStored */ #define TF_WithoutRowid 0x00000080 /* No rowid. PRIMARY KEY is the key */ -#define TF_StatsUsed 0x00000100 /* Query planner decisions affected by - ** Index.aiRowLogEst[] values */ +#define TF_MaybeReanalyze 0x00000100 /* Maybe run ANALYZE on this table */ #define TF_NoVisibleRowid 0x00000200 /* No user-visible "rowid" column */ #define TF_OOOHidden 0x00000400 /* Out-of-Order hidden columns */ #define TF_HasNotNull 0x00000800 /* Contains NOT NULL constraints */ diff --git a/src/where.c b/src/where.c index 65022a65bb..0e526b3372 100644 --- a/src/where.c +++ b/src/where.c @@ -3970,7 +3970,7 @@ static int whereLoopAddBtree( ** unique index is used (making the index functionally non-unique) ** then the sqlite_stat1 data becomes important for scoring the ** plan */ - pTab->tabFlags |= TF_StatsUsed; + pTab->tabFlags |= TF_MaybeReanalyze; } #ifdef SQLITE_ENABLE_STAT4 sqlite3Stat4ProbeFree(pBuilder->pRec); @@ -5805,7 +5805,7 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful( SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab]; Table *pTab = pItem->pTab; if( (pTab->tabFlags & TF_HasStat1)==0 ) break; - pTab->tabFlags |= TF_StatsUsed; + pTab->tabFlags |= TF_MaybeReanalyze; if( i>=1 && (pLoop->wsFlags & reqFlags)==reqFlags /* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */ From 816f677c1c2ec9d3331c9c329a6176bedca4178e Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 16 Feb 2024 16:04:31 +0000 Subject: [PATCH 0106/1030] Work around a __VA_ARGS__ complaint in fiddle builds. FossilOrigin-Name: 7d750248c58ccbf87036ea7db053def1c83c7a8ed428a5c47895756302b36200 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 4b23b6788b..e93487a996 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\sthe\sTF_StatsUsed\sflag\sto\sTF_MaybeReanalyze,\sto\smore\saccurately\nreflect\sits\susage.\s\sNo\slogic\schanges. -D 2024-02-16T12:57:04.964 +C Work\saround\sa\s__VA_ARGS__\scomplaint\sin\sfiddle\sbuilds. +D 2024-02-16T16:04:31.416 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -740,7 +740,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in 2382dc2327e47af76b37a7a468152a509dc0a8e72dad887fb868102ecbd94fe8 +F src/shell.c.in d0092ec6794ea162f0b1553d7be8d1275726cb504f170035a4e0742a1a3fba75 F src/sqlite.h.in 020d7b7307dda51420dc48b47e5334eaface77baba6bd9818375d392eb3ab5b5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 01222d96b9ab24c7013a2587544304ba32c1f039b08c06a04d8d58ec9c790db0 -R 5e5b0ae5c12dce6d73ff009cddfe3c44 -U drh -Z a8dd3bda9012a6e778f3b0295c3fea74 +P b4790da5e0d6f0f617e6c3a17fc2606842e41cab14339392abd335410fec0aa3 +R 759fda60be6ab3de32b04d89f6276871 +U stephan +Z d154d8c6872615f4f0b58afcdd6f17b3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a222b41c70..170ef3c3b7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b4790da5e0d6f0f617e6c3a17fc2606842e41cab14339392abd335410fec0aa3 \ No newline at end of file +7d750248c58ccbf87036ea7db053def1c83c7a8ed428a5c47895756302b36200 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 6bd81a0470..780cdb925b 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -280,9 +280,9 @@ INCLUDE ../ext/consio/console_io.c #else /* For Fiddle, all console handling and emit redirection is omitted. */ # define sputz(fp,z) fputs(z,fp) -# define sputf(fp,fmt, ...) fprintf(fp,fmt,__VA_ARGS__) +# define sputf fprintf # define oputz(z) fputs(z,stdout) -# define oputf(fmt, ...) printf(fmt,__VA_ARGS__) +# define oputf printf # define eputz(z) fputs(z,stderr) # define eputf(fmt, ...) fprintf(stderr,fmt,__VA_ARGS__) # define oputb(buf,na) fwrite(buf,1,na,stdout) From fd2500f98b3c385953a3de83545aa6ddcfcadce0 Mon Sep 17 00:00:00 2001 From: larrybr Date: Fri, 16 Feb 2024 18:34:21 +0000 Subject: [PATCH 0107/1030] Retweak last check-in to retain compile-time checking of xprintf() arguments. FossilOrigin-Name: 670174916c660b24ba70e96a42984eb65ee52da50e9828bdeca4c9ff4bf92e20 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 19 ++++++++++++++----- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index e93487a996..2c5c35e07a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Work\saround\sa\s__VA_ARGS__\scomplaint\sin\sfiddle\sbuilds. -D 2024-02-16T16:04:31.416 +C Retweak\slast\scheck-in\sto\sretain\scompile-time\schecking\sof\sxprintf()\sarguments. +D 2024-02-16T18:34:21.033 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -740,7 +740,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in d0092ec6794ea162f0b1553d7be8d1275726cb504f170035a4e0742a1a3fba75 +F src/shell.c.in e4a38496290d3979ea3d953fba0bc187d350d6e80f8e33c2e37b9a924850439b F src/sqlite.h.in 020d7b7307dda51420dc48b47e5334eaface77baba6bd9818375d392eb3ab5b5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b4790da5e0d6f0f617e6c3a17fc2606842e41cab14339392abd335410fec0aa3 -R 759fda60be6ab3de32b04d89f6276871 -U stephan -Z d154d8c6872615f4f0b58afcdd6f17b3 +P 7d750248c58ccbf87036ea7db053def1c83c7a8ed428a5c47895756302b36200 +R 6ea6e9f84387bdd065f35367386a097e +U larrybr +Z 849b6ec66e03430774f8a485b79fa305 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 170ef3c3b7..7e879107f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7d750248c58ccbf87036ea7db053def1c83c7a8ed428a5c47895756302b36200 \ No newline at end of file +670174916c660b24ba70e96a42984eb65ee52da50e9828bdeca4c9ff4bf92e20 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 780cdb925b..da377982e1 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -268,6 +268,9 @@ INCLUDE ../ext/consio/console_io.c * setOutputStream(FILE *pf) * This is normally the stream that CLI normal output goes to. * For the stand-alone CLI, it is stdout with no .output redirect. + * + * The ?putz(z) forms are required for the Fiddle builds for string literal + * output, in aid of enforcing format string to argument correspondence. */ # define sputz(s,z) fPutsUtf8(z,s) # define sputf fPrintfUtf8 @@ -279,12 +282,18 @@ INCLUDE ../ext/consio/console_io.c #else /* For Fiddle, all console handling and emit redirection is omitted. */ -# define sputz(fp,z) fputs(z,fp) -# define sputf fprintf +/* These next 3 macros are for emitting formatted output. When complaints + * from the WASM build are issued for non-formatted output, (when a mere + * string literal is to be emitted, the ?putz(z) forms should be used. + * (This permits compile-time checking of format string / argument mismatch.) + */ +# define oputf(fmt, ...) printf(fmt,__VA_ARGS__) +# define eputf(fmt, ...) fprintf(stderr,fmt,__VA_ARGS__) +# define sputf(fp,fmt, ...) fprintf(fp,fmt,__VA_ARGS__) +/* These next 3 macros are for emitting simple string literals. */ # define oputz(z) fputs(z,stdout) -# define oputf printf # define eputz(z) fputs(z,stderr) -# define eputf(fmt, ...) fprintf(stderr,fmt,__VA_ARGS__) +# define sputz(fp,z) fputs(z,fp) # define oputb(buf,na) fwrite(buf,1,na,stdout) #endif @@ -11079,7 +11088,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } } if( bShowHelp ){ - oputf( + oputz( "Usage: .testctrl fault_install ARGS\n" "Possible arguments:\n" " off Disable faultsim\n" From 4dd59fd997fbee21fc83384b3bd3f7635523739d Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 16 Feb 2024 21:30:08 +0000 Subject: [PATCH 0108/1030] Fix the subtype on the value column from json_each/json_tree for cases when the value is an array or object. Fix for the bug reported by [forum:/forumpost/ecb94cd210|forum post ecb94cd210]. FossilOrigin-Name: 1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/json.c | 3 +++ test/json101.test | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2c5c35e07a..8a1169a17b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Retweak\slast\scheck-in\sto\sretain\scompile-time\schecking\sof\sxprintf()\sarguments. -D 2024-02-16T18:34:21.033 +C Fix\sthe\ssubtype\son\sthe\svalue\scolumn\sfrom\sjson_each/json_tree\sfor\scases\nwhen\sthe\svalue\sis\san\sarray\sor\sobject.\s\sFix\sfor\sthe\sbug\sreported\sby\n[forum:/forumpost/ecb94cd210|forum\spost\secb94cd210]. +D 2024-02-16T21:30:08.580 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -699,7 +699,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c a0346bef35804e468b9ea0c34a08960f4f543a61683182a3ec1fe30df3b98140 +F src/json.c a412d7f1550a8597470d30e1d9f8d3dcf111b96ef3877b74bb1c363086bcfb51 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -1337,7 +1337,7 @@ F test/json/json-generator.tcl dc0dd0f393800c98658fc4c47eaa6af29d4e17527380cd286 F test/json/json-q1.txt 65f9d1cdcc4cffa9823fb73ed936aae5658700cd001fde448f68bfb91c807307 F test/json/json-speed-check.sh 912ee03e700a65c827ee0c7b4752c21ec5ef69cf7679d2f482ca817042bead52 x F test/json/jsonb-q1.txt 1e180fe6491efab307e318b22879e3a736ac9a96539bbde7911a13ee5b33abc7 -F test/json101.test 70587d7d35ef9e2126364ba70f0c951f70827cfbd28649d779ff3df7e8f87547 +F test/json101.test 30db5b055b103ccabc53a29cfe6cda3345d07e171aeb25403dafa04f19e98b19 F test/json102.test 557a46e16df1aa9bdbc4076a71a45814ea0e7503d6621d87d42a8c04cbc2b0ef F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba0114348c1 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7d750248c58ccbf87036ea7db053def1c83c7a8ed428a5c47895756302b36200 -R 6ea6e9f84387bdd065f35367386a097e -U larrybr -Z 849b6ec66e03430774f8a485b79fa305 +P 670174916c660b24ba70e96a42984eb65ee52da50e9828bdeca4c9ff4bf92e20 +R e9613550f9ab9d1defe8fcc96e4778a1 +U drh +Z a380dd04602de7f2ac17d4bbe29cc262 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7e879107f6..b30f95cb8a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -670174916c660b24ba70e96a42984eb65ee52da50e9828bdeca4c9ff4bf92e20 \ No newline at end of file +1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e \ No newline at end of file diff --git a/src/json.c b/src/json.c index 3aa4b4e500..c33b63556a 100644 --- a/src/json.c +++ b/src/json.c @@ -4944,6 +4944,9 @@ static int jsonEachColumn( case JEACH_VALUE: { u32 i = jsonSkipLabel(p); jsonReturnFromBlob(&p->sParse, i, ctx, 1); + if( (p->sParse.aBlob[i] & 0x0f)>=JSONB_ARRAY ){ + sqlite3_result_subtype(ctx, JSON_SUBTYPE); + } break; } case JEACH_TYPE: { diff --git a/test/json101.test b/test/json101.test index bae68e7344..3963ffbb6b 100644 --- a/test/json101.test +++ b/test/json101.test @@ -378,6 +378,20 @@ do_execsql_test json101-5.8 { WHERE jx.value<>jx.atom AND type NOT IN ('array','object'); } {} +# 2024-02-16 https://sqlite.org/forum/forumpost/ecb94cd210 +# Regression in json_tree()/json_each(). The value column +# should have the "J" subtype if the value is an array or +# object. +# +do_execsql_test json101-5.10 { + SELECT json_insert('{}','$.a',value) FROM json_tree('[1,2,3]') WHERE atom IS NULL; +} {{{"a":[1,2,3]}}} +# ^^^^^^^--- In double-quotes, a string literal, prior to bug fix + +do_execsql_test json101-5.11 { + SELECT json_insert('{}','$.a',value) FROM json_tree('"[1,2,3]"'); +} {{{"a":"[1,2,3]"}}} + do_execsql_test json101-6.1 { SELECT json_valid('{"a":55,"b":72,}'); } {0} From 837efb4cbe1fa71b991f42efa9f9057fcf4a7c6b Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 17 Feb 2024 01:12:58 +0000 Subject: [PATCH 0109/1030] The PRAGMA optimize command invokes ANALYZE if a table shrinks by 25 times in addition to if it grows by 25 times. FossilOrigin-Name: 40532ffba91cf332c1ea4add80184031a9d6e10514d2d9b9a6cfd613091b81f7 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/pragma.c | 13 ++++++++----- src/vdbe.c | 21 +++++++++++++++------ 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 8a1169a17b..3582a19a3e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\ssubtype\son\sthe\svalue\scolumn\sfrom\sjson_each/json_tree\sfor\scases\nwhen\sthe\svalue\sis\san\sarray\sor\sobject.\s\sFix\sfor\sthe\sbug\sreported\sby\n[forum:/forumpost/ecb94cd210|forum\spost\secb94cd210]. -D 2024-02-16T21:30:08.580 +C The\sPRAGMA\soptimize\scommand\sinvokes\sANALYZE\sif\sa\stable\sshrinks\sby\s25\stimes\nin\saddition\sto\sif\sit\sgrows\sby\s25\stimes. +D 2024-02-17T01:12:58.951 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 24584cc928538426e047db670f21f3816286812e48dfd391a40e788f14d3cea2 +F src/pragma.c 2a49dd92e9f14eb7433c06d02f5d02b7e2890b05117e7c5be103a9da1251ba0d F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -809,7 +809,7 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c dd340f5add924a8397401f7fe4faf2304ffd49ab5853d32ffc1736093b9c5080 +F src/vdbe.c a9b83d5ecd34d7e9d50dc7b643351541ddac74b5e2b19770cb3f2686cb815066 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -2162,8 +2162,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 670174916c660b24ba70e96a42984eb65ee52da50e9828bdeca4c9ff4bf92e20 -R e9613550f9ab9d1defe8fcc96e4778a1 +P 1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e +R 56c40cfd7fd1a612586d6162b2f4f953 +T *branch * optimize-after-shrink +T *sym-optimize-after-shrink * +T -sym-trunk * U drh -Z a380dd04602de7f2ac17d4bbe29cc262 +Z ebc951629700e2b49319b3c4b80fffe0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b30f95cb8a..942fd1732c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e \ No newline at end of file +40532ffba91cf332c1ea4add80184031a9d6e10514d2d9b9a6cfd613091b81f7 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 872177e131..367c9fba2f 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2453,17 +2453,20 @@ void sqlite3Pragma( if( (pTab->tabFlags & TF_MaybeReanalyze)==0 ) continue; /* Reanalyze if the table is 25 times larger than the last analysis */ - szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 ); + szThreshold = pTab->nRowLogEst; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ if( !pIdx->hasStat1 ){ - szThreshold = 0; /* Always analyze if any index lacks statistics */ + szThreshold = -1; /* Always analyze if any index lacks statistics */ break; } } - if( szThreshold ){ + if( szThreshold>=0 ){ sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); - sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur, - sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold); + sqlite3VdbeAddOp4Int(v, OP_IfSizeBetween, iTabCur, + sqlite3VdbeCurrentAddr(v)+3+(opMask&1), + szThreshold>=46 ? szThreshold-46 : -1, + szThreshold+46); + sqlite3VdbeAddOp1(v, OP_Close, iTabCur); VdbeCoverage(v); } zSubSql = sqlite3MPrintf(db, "ANALYZE \"%w\".\"%w\"", diff --git a/src/vdbe.c b/src/vdbe.c index 1e0d776536..da3eeeae91 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6192,28 +6192,37 @@ case OP_Last: { /* jump, ncycle */ break; } -/* Opcode: IfSmaller P1 P2 P3 * * +/* Opcode: IfSizeBetween P1 P2 P3 P4 * ** -** Estimate the number of rows in the table P1. Jump to P2 if that -** estimate is less than approximately 2**(0.1*P3). +** Let N be the approximate number of rows in the table or index +** with cursor P1 and let X be 10*log2(N) if N is positive or -1 +** if N is zero. Thus X will be within the range of -1 to 640, inclusive +** Jump to P2 if X is in between P3 and P4, inclusive. */ -case OP_IfSmaller: { /* jump */ +case OP_IfSizeBetween: { /* jump */ VdbeCursor *pC; BtCursor *pCrsr; int res; i64 sz; assert( pOp->p1>=0 && pOp->p1nCursor ); + assert( pOp->p4type==P4_INT32 ); + assert( pOp->p3>=-1 && pOp->p3<=640 ); + assert( pOp->p4.i>=-1 && pOp->p4.i<=640 ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); pCrsr = pC->uc.pCursor; assert( pCrsr ); rc = sqlite3BtreeFirst(pCrsr, &res); if( rc ) goto abort_due_to_error; - if( res==0 ){ + if( res!=0 ){ + sz = -1; /* -Infinity encoding */ + }else{ sz = sqlite3BtreeRowCountEst(pCrsr); - if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)p3 ) res = 1; + assert( sz>0 ); + sz = sqlite3LogEst((u64)sz); } + res = sz>=pOp->p3 && sz<=pOp->p4.i; VdbeBranchTaken(res!=0,2); if( res ) goto jump_to_p2; break; From 6161cdd446eec170f7c0edf58d0d72a2cd3c5f85 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 17 Feb 2024 03:32:31 +0000 Subject: [PATCH 0110/1030] Fix rounding in zero-precision %f and %g printf conversions. [forum:/info/393708f4a8|Forum post 393708f4a8]. This bug was introduced by check-in [32befb224b254639] and first appeared in version 3.43.0. FossilOrigin-Name: 7fca1bc482fc2456d75392eb42f768fda72631c9070de46b8123b1126e78306f --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/printf.c | 1 + src/util.c | 2 +- test/printf.test | 17 +++++++++++++++++ 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8a1169a17b..ab0f22bde5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\ssubtype\son\sthe\svalue\scolumn\sfrom\sjson_each/json_tree\sfor\scases\nwhen\sthe\svalue\sis\san\sarray\sor\sobject.\s\sFix\sfor\sthe\sbug\sreported\sby\n[forum:/forumpost/ecb94cd210|forum\spost\secb94cd210]. -D 2024-02-16T21:30:08.580 +C Fix\srounding\sin\szero-precision\s%f\sand\s%g\sprintf\sconversions.\n[forum:/info/393708f4a8|Forum\spost\s393708f4a8].\s\sThis\sbug\swas\nintroduced\sby\scheck-in\s[32befb224b254639]\sand\sfirst\sappeared\sin\sversion\s3.43.0. +D 2024-02-17T03:32:31.878 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -735,7 +735,7 @@ F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 F src/pragma.c 24584cc928538426e047db670f21f3816286812e48dfd391a40e788f14d3cea2 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c -F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 +F src/printf.c d3392b2a20ee314ddeef34fb43c904bf4619eb20ff9a9e07e3950a7e4dcd6912 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 @@ -807,7 +807,7 @@ F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b +F src/util.c 3ed7ded64ecc8670acdcbb72e8df9b0a58845cb0c36639573eb0d5155121901a F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c dd340f5add924a8397401f7fe4faf2304ffd49ab5853d32ffc1736093b9c5080 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb @@ -1489,7 +1489,7 @@ F test/pragma4.test ca5e4dfc46adfe490f75d73734f70349d95a199e6510973899e502eef2c8 F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d9102 F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8 F test/prefixes.test b524a1c44bffec225b9aec98bd728480352aa8532ac4c15771fb85e8beef65d9 -F test/printf.test 512152dca7f2f578f045a5a732e7bee08e4f47a8a212f83ce46791b518eba70f +F test/printf.test 685fec5a0c5af2490ab0632775a301554361d674211d690f5bee0a97b05333de F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224cce60 F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 670174916c660b24ba70e96a42984eb65ee52da50e9828bdeca4c9ff4bf92e20 -R e9613550f9ab9d1defe8fcc96e4778a1 +P 1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e +R e3e534a124d08ab0760f858683268942 U drh -Z a380dd04602de7f2ac17d4bbe29cc262 +Z 25ef9b1be0189ee473aa53bd8732a56c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b30f95cb8a..1e28ec46dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e \ No newline at end of file +7fca1bc482fc2456d75392eb42f768fda72631c9070de46b8123b1126e78306f \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index c6b3803ca9..2e09431bf2 100644 --- a/src/printf.c +++ b/src/printf.c @@ -498,6 +498,7 @@ void sqlite3_str_vappendf( if( xtype==etFLOAT ){ iRound = -precision; }else if( xtype==etGENERIC ){ + if( precision==0 ) precision = 1; iRound = precision; }else{ iRound = precision+1; diff --git a/src/util.c b/src/util.c index 207b901bad..4aa82d0636 100644 --- a/src/util.c +++ b/src/util.c @@ -1069,7 +1069,7 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ assert( p->n>0 ); assert( p->nzBuf) ); p->iDP = p->n + exp; - if( iRound<0 ){ + if( iRound<=0 ){ iRound = p->iDP - iRound; if( iRound==0 && p->zBuf[i+1]>='5' ){ iRound = 1; diff --git a/test/printf.test b/test/printf.test index 6d4ad71d28..cc439e6172 100644 --- a/test/printf.test +++ b/test/printf.test @@ -3833,4 +3833,21 @@ do_execsql_test printf-18.1 { SELECT length( format('%,.249f', -5.0e-300) ); } {252} +# 2024-02-16 +# https://sqlite.org/forum/info/393708f4a8 +# +# The problem introduced by on 2023-07-03 by +# https://sqlite.org/src/info/32befb224b254639 +# +do_execsql_test printf-19.1 { + SELECT format('%0.0f %0.0g %0.0g', 0.9, 0.09, 1.9); +} {{1 0.09 2}} +do_execsql_test printf-19.2 { + SELECT format('%0.0f %#0.0f',0.0, 0.0); +} {{0 0.}} +do_execsql_test printf-19.3 { + SELECT format('%,.0f %,.0f',12345e+10, 12345e+11); +} {{123,450,000,000,000 1,234,500,000,000,000}} + + finish_test From 42eb6a91cdb5fe221171e7a0e588abd73d50542d Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 17 Feb 2024 16:39:52 +0000 Subject: [PATCH 0111/1030] Add new MASK bits to PRAGMA optimize: 0x70000. FossilOrigin-Name: dd4497062569eec9ddfdaa7d6394c83ff40a7a59c6697a161bc4ff6d8af3bb29 --- manifest | 19 +++++------ manifest.uuid | 2 +- src/build.c | 4 +-- src/pragma.c | 94 ++++++++++++++++++++++++++++++++++++--------------- src/vdbe.c | 21 +++++++++--- 5 files changed, 94 insertions(+), 46 deletions(-) diff --git a/manifest b/manifest index 3582a19a3e..18e8630874 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sPRAGMA\soptimize\scommand\sinvokes\sANALYZE\sif\sa\stable\sshrinks\sby\s25\stimes\nin\saddition\sto\sif\sit\sgrows\sby\s25\stimes. -D 2024-02-17T01:12:58.951 +C Add\snew\sMASK\sbits\sto\sPRAGMA\soptimize:\s\s0x70000. +D 2024-02-17T16:39:52.117 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -681,7 +681,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c dfd351decf9f819393dae8fb7294cae69c3818069d27f47fee34d5b505e37b47 F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 -F src/build.c 05c9eb387638982092988d2ef4c00a91b0c29baa1b85923f082ce0cf2903ea7e +F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 2a49dd92e9f14eb7433c06d02f5d02b7e2890b05117e7c5be103a9da1251ba0d +F src/pragma.c c5b767e7538a808fac4f17f8891acb1f14b4eed3458d971ddea4dd82f7623e0c F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -809,7 +809,7 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c a9b83d5ecd34d7e9d50dc7b643351541ddac74b5e2b19770cb3f2686cb815066 +F src/vdbe.c 6d2aecc9ab2f9db557b4841775d016e2697ff6312242e9a492cdf3e2529dffa6 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -2162,11 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e -R 56c40cfd7fd1a612586d6162b2f4f953 -T *branch * optimize-after-shrink -T *sym-optimize-after-shrink * -T -sym-trunk * +P 40532ffba91cf332c1ea4add80184031a9d6e10514d2d9b9a6cfd613091b81f7 +R 518017150456f4f932816e90c763b561 U drh -Z ebc951629700e2b49319b3c4b80fffe0 +Z 4ff4c253b76c891ec5769cfa9bfe8766 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 942fd1732c..c4b9f73820 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -40532ffba91cf332c1ea4add80184031a9d6e10514d2d9b9a6cfd613091b81f7 \ No newline at end of file +dd4497062569eec9ddfdaa7d6394c83ff40a7a59c6697a161bc4ff6d8af3bb29 \ No newline at end of file diff --git a/src/build.c b/src/build.c index cfa2c886c5..15f8fe1d24 100644 --- a/src/build.c +++ b/src/build.c @@ -2923,11 +2923,11 @@ void sqlite3EndTable( /* Test for cycles in generated columns and illegal expressions ** in CHECK constraints and in DEFAULT clauses. */ if( p->tabFlags & TF_HasGenerated ){ - sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, + sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0, sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"", db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); } - sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, + sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0, sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)", db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); } diff --git a/src/pragma.c b/src/pragma.c index 367c9fba2f..40a31846bb 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2383,44 +2383,57 @@ void sqlite3Pragma( ** ** The optional argument is a bitmask of optimizations to perform: ** - ** 0x0001 Debugging mode. Do not actually perform any optimizations - ** but instead return one line of text for each optimization - ** that would have been done. Off by default. + ** 0x00001 Debugging mode. Do not actually perform any optimizations + ** but instead return one line of text for each optimization + ** that would have been done. Off by default. ** - ** 0x0002 Run ANALYZE on tables that might benefit. On by default. - ** See below for additional information. + ** 0x00002 Run ANALYZE on tables that might benefit. On by default. + ** See below for additional information. ** - ** 0x0004 (Not yet implemented) Record usage and performance - ** information from the current session in the - ** database file so that it will be available to "optimize" - ** pragmas run by future database connections. + ** 0x10000 Look at tables to see if they need to be reanalyzed + ** even if they have not been queried during the current + ** connection. Off by default. ** - ** 0x0008 (Not yet implemented) Create indexes that might have - ** been helpful to recent queries + ** 0x20000 Run all ANALYZE operations using an analysis_limit that + ** is the lessor of the current analysis_limit and the + ** SQLITE_DEFAULT_OPTIMIZE_LIMIT compile-time option, + ** nominally 400. Off by default. ** - ** The default MASK is and always shall be 0xfffe. 0xfffe means perform all - ** of the optimizations listed above except Debug Mode, including new - ** optimizations that have not yet been invented. If new optimizations are - ** ever added that should be off by default, those off-by-default - ** optimizations will have bitmasks of 0x10000 or larger. + ** 0x40000 Tables become candidates for reanalysis if their size + ** grows or shrinks by 10x. Without this option, they + ** become candidates for reanalysis if their size grows + ** or shrinks by 25x. Off (25x mode) by default. + ** + ** The default MASK is and always shall be 0x0fffe. In the current + ** implementation, the default mask only covers the 0x00002 optimization, + ** though additional optimizations that are covered by 0x0fffe might be + ** added in the future. Optimizations that are off by default and must + ** be explicitly requested have masks of 0x10000 or greater. ** ** DETERMINATION OF WHEN TO RUN ANALYZE ** ** In the current implementation, a table is analyzed if only if all of ** the following are true: ** - ** (1) MASK bit 0x02 is set. + ** (1) MASK bit 0x00002 is set. ** - ** (2) The query planner used sqlite_stat1-style statistics for one or - ** more indexes of the table at some point during the lifetime of - ** the current connection. + ** (2) Either the 0x10000 MASK bit is set or else the query planner used + ** sqlite_stat1-style statistics for one or more indexes of the table + ** at some point during the lifetime of the current connection. ** ** (3) One or more indexes of the table are currently unanalyzed OR - ** the number of rows in the table has increased by 25 times or more + ** the number of rows in the table has increased or decreased + ** 25 times or more (10 times or more if the 0x40000 bit is set) ** since the last time ANALYZE was run. ** + ** (4) The table is an ordinary table, not a virtual table or view. + ** + ** (5) The table name does not begin with "sqlite_". + ** ** The rules for when tables are analyzed are likely to change in - ** future releases. + ** future releases. Future versions of SQLite might accept a string + ** literal argument to this pragma that contains a mnemonic description + ** of the options rather than a bitmap. */ case PragTyp_OPTIMIZE: { int iDbLast; /* Loop termination point for the schema loop */ @@ -2432,6 +2445,11 @@ void sqlite3Pragma( LogEst szThreshold; /* Size threshold above which reanalysis needed */ char *zSubSql; /* SQL statement for the OP_SqlExec opcode */ u32 opMask; /* Mask of operations to perform */ + int nLimit; /* Analysis limit to use */ + +#ifndef SQLITE_DEFAULT_OPTIMIZE_LIMIT +# define SQLITE_DEFAULT_OPTIMIZE_LIMIT 400 +#endif if( zRight ){ opMask = (u32)sqlite3Atoi(zRight); @@ -2439,6 +2457,14 @@ void sqlite3Pragma( }else{ opMask = 0xfffe; } + if( (opMask & 0x20000)==0 ){ + nLimit = 0; + }else if( db->nAnalysisLimit>0 + && db->nAnalysisLimitnTab++; for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){ if( iDb==1 ) continue; @@ -2447,10 +2473,20 @@ void sqlite3Pragma( for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ pTab = (Table*)sqliteHashData(k); + /* This only works for ordinary tables */ + if( !IsOrdinaryTable(pTab) ) continue; + + /* Do not scan system tables */ + if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ) continue; + /* If table pTab has not been used in a way that would benefit from - ** having analysis statistics during the current session, then skip it. - ** This also has the effect of skipping virtual tables and views */ - if( (pTab->tabFlags & TF_MaybeReanalyze)==0 ) continue; + ** having analysis statistics during the current session, then skip it, + ** unless the 0x10000 MASK bit is set. */ + if( (pTab->tabFlags & TF_MaybeReanalyze)==0 + && (opMask & 0x10000)==0 + ){ + continue; + } /* Reanalyze if the table is 25 times larger than the last analysis */ szThreshold = pTab->nRowLogEst; @@ -2461,11 +2497,12 @@ void sqlite3Pragma( } } if( szThreshold>=0 ){ + LogEst iRange = (opMask & 0x40000) ? 33 : 46; sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); sqlite3VdbeAddOp4Int(v, OP_IfSizeBetween, iTabCur, sqlite3VdbeCurrentAddr(v)+3+(opMask&1), - szThreshold>=46 ? szThreshold-46 : -1, - szThreshold+46); + szThreshold>=iRange ? szThreshold-iRange : -1, + szThreshold+iRange); sqlite3VdbeAddOp1(v, OP_Close, iTabCur); VdbeCoverage(v); } @@ -2476,7 +2513,8 @@ void sqlite3Pragma( sqlite3VdbeAddOp4(v, OP_String8, 0, r1, 0, zSubSql, P4_DYNAMIC); sqlite3VdbeAddOp2(v, OP_ResultRow, r1, 1); }else{ - sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC); + sqlite3VdbeAddOp4(v, OP_SqlExec, nLimit ? 0x02 : 00, nLimit, 0, + zSubSql, P4_DYNAMIC); } } } diff --git a/src/vdbe.c b/src/vdbe.c index da3eeeae91..3b52c13fa7 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6922,11 +6922,18 @@ case OP_CreateBtree: { /* out2 */ break; } -/* Opcode: SqlExec * * * P4 * +/* Opcode: SqlExec P1 P2 * P4 * ** ** Run the SQL statement or statements specified in the P4 string. -** Disable Auth and Trace callbacks while those statements are running if -** P1 is true. +** +** The P1 parameter is a bitmask of options: +** +** 0x0001 Disable Auth and Trace callbacks while the statements +** in P4 are running. +** +** 0x0002 Set db->nAnalysisLimit to P2 while the statements in +** P4 are running. +** */ case OP_SqlExec: { char *zErr; @@ -6934,6 +6941,7 @@ case OP_SqlExec: { sqlite3_xauth xAuth; #endif u8 mTrace; + int savedAnalysisLimit; sqlite3VdbeIncrWriteCounter(p, 0); db->nSqlExec++; @@ -6942,18 +6950,23 @@ case OP_SqlExec: { xAuth = db->xAuth; #endif mTrace = db->mTrace; - if( pOp->p1 ){ + savedAnalysisLimit = db->nAnalysisLimit; + if( pOp->p1 & 0x0001 ){ #ifndef SQLITE_OMIT_AUTHORIZATION db->xAuth = 0; #endif db->mTrace = 0; } + if( pOp->p1 & 0x0002 ){ + db->nAnalysisLimit = pOp->p2; + } rc = sqlite3_exec(db, pOp->p4.z, 0, 0, &zErr); db->nSqlExec--; #ifndef SQLITE_OMIT_AUTHORIZATION db->xAuth = xAuth; #endif db->mTrace = mTrace; + db->nAnalysisLimit = savedAnalysisLimit; if( zErr || rc ){ sqlite3VdbeError(p, "%s", zErr); sqlite3_free(zErr); From 99a94a124c6ff0b0428fa6ff7e880443edef8dcb Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Feb 2024 20:55:01 +0000 Subject: [PATCH 0112/1030] Add start of extension for incremental integrity-checks to ext/intck/. FossilOrigin-Name: 444e3c9210026da7eae1ed98850722e002433aa2cc77dbc6b6f80327a6b7a390 --- Makefile.in | 2 + Makefile.msc | 2 + ext/intck/intck1.test | 192 +++++++++++ ext/intck/intck2.test | 70 ++++ ext/intck/intck_common.tcl | 49 +++ ext/intck/sqlite3intck.c | 647 +++++++++++++++++++++++++++++++++++++ ext/intck/sqlite3intck.h | 55 ++++ ext/intck/test_intck.c | 185 +++++++++++ main.mk | 4 +- manifest | 29 +- manifest.uuid | 2 +- src/test_tclsh.c | 2 + 12 files changed, 1227 insertions(+), 12 deletions(-) create mode 100644 ext/intck/intck1.test create mode 100644 ext/intck/intck2.test create mode 100644 ext/intck/intck_common.tcl create mode 100644 ext/intck/sqlite3intck.c create mode 100644 ext/intck/sqlite3intck.h create mode 100644 ext/intck/test_intck.c diff --git a/Makefile.in b/Makefile.in index cb894666d9..509ad4884f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -418,6 +418,8 @@ TESTSRC = \ $(TOP)/ext/recover/sqlite3recover.c \ $(TOP)/ext/recover/dbdata.c \ $(TOP)/ext/recover/test_recover.c \ + $(TOP)/ext/intck/test_intck.c \ + $(TOP)/ext/intck/sqlite3intck.c \ $(TOP)/ext/rbu/test_rbu.c # Statically linked extensions diff --git a/Makefile.msc b/Makefile.msc index 19bfe2f386..7d9dbd2c2b 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1595,6 +1595,8 @@ TESTEXT = \ $(TOP)\ext\rtree\test_rtreedoc.c \ $(TOP)\ext\recover\sqlite3recover.c \ $(TOP)\ext\recover\test_recover.c \ + $(TOP)\ext\intck\test_intck.c \ + $(TOP)\ext\intck\sqlite3intck.c \ $(TOP)\ext\recover\dbdata.c # If use of zlib is enabled, add the "zipfile.c" source file. diff --git a/ext/intck/intck1.test b/ext/intck/intck1.test new file mode 100644 index 0000000000..c46a7d6b2d --- /dev/null +++ b/ext/intck/intck1.test @@ -0,0 +1,192 @@ +# 2008 Feb 19 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# The focus of this file is testing the r-tree extension. +# + +source [file join [file dirname [info script]] intck_common.tcl] +set testprefix intck1 + +foreach {tn sql} { + 1 "CREATE TABLE t1(a PRIMARY KEY, b)" + 2 "CREATE TABLE t2(a PRIMARY KEY, b) WITHOUT ROWID " + 3 "CREATE TABLE t3(a PRIMARY KEY, b) WITHOUT rowID;" + 4 "CREATE TABLE t4(a PRIMARY KEY, ROWID)" + 5 {CREATE TABLE t5(a PRIMARY KEY, ROWID) WITHOUT ROWID + } +} { + do_test 1.1.$tn { + db eval $sql + set {} {} + } {} +} + +set space " \n\v\t\r\f" + +do_execsql_test 1.2 { + SELECT name, (rtrim(sql, $space) LIKE '%rowid') + FROM sqlite_schema WHERE type='table' + ORDER BY 1 +} { + t1 0 + t2 1 + t3 1 + t4 0 + t5 1 +} + +do_execsql_test 1.3 { + CREATE TABLE x1(a COLLATE nocase, b INTEGER, c BLOB); + INSERT INTO x1 VALUES('lEtTeRs', 1234, 1234); +} +do_execsql_test 1.3.1 { + WITH wrapper(c1, c2, c3) AS ( + SELECT a, b, c FROM x1 + ) + SELECT * FROM wrapper WHERE c1='letters'; +} {lEtTeRs 1234 1234} +do_execsql_test 1.3.2 { + WITH wrapper(c1, c2, c3) AS ( + SELECT a, b, c FROM x1 + ) + SELECT * FROM wrapper WHERE c2='1234'; +} {lEtTeRs 1234 1234} +do_execsql_test 1.3.2 { + WITH wrapper(c1, c2, c3) AS ( + SELECT a, b, c FROM x1 + ) + SELECT * FROM wrapper WHERE c3='1234'; +} {} + +do_execsql_test 1.4 { + CREATE TABLE z1(a, b); + CREATE INDEX z1ab ON z1(a+b COLLATE nocase); +} +do_execsql_test 1.4.1 { + SELECT * FROM z1 INDEXED BY z1ab +} + +do_catchsql_test 1.5.1 { + CREATE INDEX z1b ON z1(b ASC NULLS LAST); +} {1 {unsupported use of NULLS LAST}} +do_catchsql_test 1.5.2 { + CREATE INDEX z1b ON z1(b DESC NULLS LAST); +} {1 {unsupported use of NULLS LAST}} +do_catchsql_test 1.5.3 { + CREATE INDEX z1b ON z1(b ASC NULLS FIRST); +} {1 {unsupported use of NULLS FIRST}} +do_catchsql_test 1.5.4 { + CREATE INDEX z1b ON z1(b DESC NULLS FIRST); +} {1 {unsupported use of NULLS FIRST}} + + +#------------------------------------------------------------------------- +reset_db + +do_test 2.0 { + set ic [sqlite3_intck db main ""] + $ic close +} {} + +do_execsql_test 2.1 { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t1 VALUES(3, 4); + + CREATE INDEX i1 ON t1(a COLLATE nocase); + CREATE INDEX i2 ON t1(b, a); + CREATE INDEX i3 ON t1(b + a COLLATE nocase) WHERE a!=1; +} + +do_intck_test 2.2 { +} + +# Delete a row from each of the i1 and i2 indexes using the imposter +# table interface. +# +do_test 2.3 { + db eval {SELECT name, rootpage FROM sqlite_schema} { + set R($name) $rootpage + } + sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 1 $R(i1) + db eval { CREATE TABLE imp1(a PRIMARY KEY, rowid) WITHOUT ROWID; } + sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 1 $R(i2) + db eval { CREATE TABLE imp2(b, a, rowid, PRIMARY KEY(b, a)) WITHOUT ROWID; } + sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 0 0 + + db eval { + DELETE FROM imp1 WHERE rowid=1; + DELETE FROM imp2 WHERE rowid=2; + } + + db close + sqlite3 db test.db +} {} + +do_intck_test 2.4 { + {entry (1,1) missing from index i1} + {entry (4,3,2) missing from index i2} +} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 3.0 { + CREATE TABLE x1(a, b, c, PRIMARY KEY(c, b)) WITHOUT ROWID; + CREATE INDEX x1a ON x1(a COLLATE nocase); + + INSERT INTO x1 VALUES(1, 2, 'three'); + INSERT INTO x1 VALUES(4, 5, 'six'); + INSERT INTO x1 VALUES(7, 8, 'nine'); +} + +do_intck_test 3.1 { } + +do_test 3.2 { + db eval {SELECT name, rootpage FROM sqlite_schema} { + set R($name) $rootpage + } + sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 1 $R(x1a) + db eval { CREATE TABLE imp1(c, b, a, PRIMARY KEY(c, b)) WITHOUT ROWID } + sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 0 0 + + db eval { + DELETE FROM imp1 WHERE a=5; + } + execsql_pp { + } + + db close + sqlite3 db test.db +} {} + +puts "[intck_sql db x1a]" +execsql_pp "EXPLAIN QUERY PLAN [intck_sql db x1a]" +do_intck_test 3.3 { + {entry (4,'six',5) missing from index x1a} +} + +#explain_i [intck_sql db x1] +#puts [intck_sql db x1] +#puts [intck_sql db x1a] + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 4.0 { + CREATE TABLE www(x, y, z); + CREATE INDEX w1 ON www( (x+1), z ); + INSERT INTO www VALUES(1, 1, 1), (2, 2, 2); +} + +do_intck_test 4.1 { } + +finish_test + + diff --git a/ext/intck/intck2.test b/ext/intck/intck2.test new file mode 100644 index 0000000000..bc9aebeea8 --- /dev/null +++ b/ext/intck/intck2.test @@ -0,0 +1,70 @@ +# 2008 Feb 19 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# The focus of this file is testing the r-tree extension. +# + +source [file join [file dirname [info script]] intck_common.tcl] +set testprefix intck2 + + +do_execsql_test 1.0 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); + INSERT INTO t1 VALUES(1, 'one'); + INSERT INTO t1 VALUES(2, 'two'); + INSERT INTO t1 VALUES(3, 'three'); + CREATE INDEX i1 ON t1(b); +} + +proc imposter_edit {obj create sql} { + sqlite3 xdb test.db + set pgno [xdb one {SELECT rootpage FROM sqlite_schema WHERE name=$obj}] + + sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER xdb main 1 $pgno + xdb eval $create + sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER xdb main 0 0 + xdb eval $sql + xdb close +} + +imposter_edit i1 { + CREATE TABLE imp(b, a, PRIMARY KEY(b)) WITHOUT ROWID; +} { + DELETE FROM imp WHERE b='two'; + INSERT INTO imp(b, a) VALUES('four', 4); +} + +do_intck_test 1.1 { + {entry ('two',2) missing from index i1} + {surplus entry ('four',4) in index i1} +} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 { + CREATE TABLE x1(a, b, "c d"); + CREATE INDEX x1a ON x1(a COLLATE nocase DESC , b ASC); + CREATE INDEX x1b ON x1( a || b || ' "''" ' COLLATE binary ASC ); + CREATE INDEX x1c ON x1( format('%s', a)ASC, format('%d', "c d" ) ); + INSERT INTO x1 VALUES('one', 2, 3); + INSERT INTO x1 VALUES('One', 4, 5); + INSERT INTO x1 VALUES('ONE', 6, 7); + INSERT INTO x1 VALUES(NULL, NULL, NULL); +} + +do_intck_test 2.1 {} +puts [intck_sql db x1] + + + +finish_test + + diff --git a/ext/intck/intck_common.tcl b/ext/intck/intck_common.tcl new file mode 100644 index 0000000000..0763d13266 --- /dev/null +++ b/ext/intck/intck_common.tcl @@ -0,0 +1,49 @@ +# 2024 Feb 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. +# +#*********************************************************************** +# + +if {![info exists testdir]} { + set testdir [file join [file dirname [info script]] .. .. test] +} +source $testdir/tester.tcl + +proc do_intck {db} { + set ic [sqlite3_intck $db main ""] + + set ret [list] + while {"SQLITE_OK"==[$ic step]} { + set msg [$ic message] + if {$msg!=""} { + lappend ret $msg + } + } + + set err [$ic error] + if {[lindex $err 0]!="SQLITE_OK"} { + error $err + } + $ic close + + return $ret +} + +proc intck_sql {db tbl} { + set ic [sqlite3_intck $db main ""] + set sql [$ic test_sql $tbl] + $ic close + return $sql +} + +proc do_intck_test {tn expect} { + uplevel [list do_test $tn [list do_intck db] [list {*}$expect]] +} + + diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c new file mode 100644 index 0000000000..7610d44a9b --- /dev/null +++ b/ext/intck/sqlite3intck.c @@ -0,0 +1,647 @@ +/* +** 2024-02-08 +** +** 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. +** +************************************************************************* +*/ + +#include "sqlite3intck.h" +#include +#include +#include + +struct sqlite3_intck { + sqlite3 *db; + const char *zDb; /* Copy of zDb parameter to _open() */ + + sqlite3_stmt *pListTables; + + sqlite3_stmt *pCheck; + int nCheck; + + int rc; /* SQLite error code */ + char *zErr; /* Error message */ + + char *zTestSql; /* Returned by sqlite3_intck_test_sql() */ +}; + + +/* +** Some error has occurred while using database p->db. Save the error message +** and error code currently held by the database handle in p->rc and p->zErr. +*/ +static void intckSaveErrmsg(sqlite3_intck *p){ + const char *zDberr = sqlite3_errmsg(p->db); + p->rc = sqlite3_errcode(p->db); + if( zDberr ){ + sqlite3_free(p->zErr); + p->zErr = sqlite3_mprintf("%s", zDberr); + } +} + +static sqlite3_stmt *intckPrepare(sqlite3_intck *p, const char *zFmt, ...){ + sqlite3_stmt *pRet = 0; + va_list ap; + char *zSql = 0; + va_start(ap, zFmt); + zSql = sqlite3_vmprintf(zFmt, ap); + if( p->rc==SQLITE_OK ){ + if( zSql==0 ){ + p->rc = SQLITE_NOMEM; + }else{ + p->rc = sqlite3_prepare_v2(p->db, zSql, -1, &pRet, 0); + fflush(stdout); + if( p->rc!=SQLITE_OK ){ + printf("ERROR: %s\n", zSql); + printf("MSG: %s\n", sqlite3_errmsg(p->db)); + if( sqlite3_error_offset(p->db)>=0 ){ + int iOff = sqlite3_error_offset(p->db); + printf("AT: %.40s\n", &zSql[iOff]); + } + fflush(stdout); + intckSaveErrmsg(p); + assert( pRet==0 ); + } + } + } + sqlite3_free(zSql); + va_end(ap); + return pRet; +} + +static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){ + int rc = sqlite3_finalize(pStmt); + if( p->rc==SQLITE_OK && rc!=SQLITE_OK ){ + intckSaveErrmsg(p); + } +} + +/* +** Return an SQL statement that will itself return a single row for each +** table in the target schema. The row contains two columns: +** +** 0: table_name - name of table +** 1: without_rowid - true for WITHOUT ROWID tables, false otherwise. +** +*/ +static sqlite3_stmt *intckListTables(sqlite3_intck *p){ + return intckPrepare(p, + "WITH tables(table_name) AS (" + " SELECT name" + " FROM %Q.sqlite_schema WHERE type='table' OR type='index'" + " UNION ALL " + " SELECT 'sqlite_schema'" + ")" + "SELECT * FROM tables" + , p->zDb + ); +} + +static char *intckStrdup(sqlite3_intck *p, const char *zIn){ + char *zOut = 0; + if( p->rc==SQLITE_OK ){ + int nIn = strlen(zIn); + zOut = sqlite3_malloc(nIn+1); + if( zOut==0 ){ + p->rc = SQLITE_NOMEM; + }else{ + memcpy(zOut, zIn, nIn+1); + } + } + return zOut; +} + +/* +** Return the size in bytes of the first token in nul-terminated buffer z. +** For the purposes of this call, a token is either: +** +** * a quoted SQL string, +* * a contiguous series of ascii alphabet characters, or +* * any other single byte. +*/ +static int intckGetToken(const char *z){ + char c = z[0]; + int iRet = 1; + if( c=='\'' || c=='"' || c=='`' ){ + while( 1 ){ + if( z[iRet]==c ){ + iRet++; + if( z[iRet+1]!=c ) break; + } + iRet++; + } + } + else if( c=='[' ){ + while( z[iRet++]!=']' && z[iRet] ); + } + else if( (c>='A' && c<='Z') || (c>='a' && c<='z') ){ + while( (z[iRet]>='A' && z[iRet]<='Z') || (z[iRet]>='a' && z[iRet]<='z') ){ + iRet++; + } + } + + return iRet; +} + +static int intckIsSpace(char c){ + return (c==' ' || c=='\t' || c=='\n' || c=='\r'); +} + +static int intckTokenMatch( + const char *zToken, + int nToken, + const char *z1, + const char *z2 +){ + return ( + (strlen(z1)==nToken && 0==sqlite3_strnicmp(zToken, z1, nToken)) + || (z2 && strlen(z2)==nToken && 0==sqlite3_strnicmp(zToken, z2, nToken)) + ); +} + +/* +** Argument z points to the text of a CREATE INDEX statement. This function +** identifies the part of the text that contains either the index WHERE +** clause (if iCol<0) or the iCol'th column of the index. +** +** If (iCol<0), the identified fragment does not include the "WHERE" keyword, +** only the expression that follows it. If (iCol>=0) then the identified +** fragment does not include any trailing sort-order keywords - "ASC" or +** "DESC". +** +** If the CREATE INDEX statement does not contain the requested field or +** clause, NULL is returned and (*pnByte) is set to 0. Otherwise, a pointer to +** the identified fragment is returned and output parameter (*pnByte) set +** to its size in bytes. +*/ +static const char *intckParseCreateIndex(const char *z, int iCol, int *pnByte){ + int iOff = 0; + int iThisCol = 0; + int iStart = 0; + int nOpen = 0; + + const char *zRet = 0; + int nRet = 0; + + int iEndOfCol = 0; + + /* Skip forward until the first "(" token */ + while( z[iOff]!='(' ){ + iOff += intckGetToken(&z[iOff]); + if( z[iOff]=='\0' ) return 0; + } + assert( z[iOff]=='(' ); + + nOpen = 1; + iOff++; + iStart = iOff; + while( z[iOff] ){ + const char *zToken = &z[iOff]; + int nToken = 0; + + /* Check if this is the end of the current column - either a "," or ")" + ** when nOpen==1. */ + if( nOpen==1 ){ + if( z[iOff]==',' || z[iOff]==')' ){ + if( iCol==iThisCol ){ + int iEnd = iEndOfCol ? iEndOfCol : iOff; + nRet = (iEnd - iStart); + zRet = &z[iStart]; + break; + } + iStart = iOff+1; + while( intckIsSpace(z[iStart]) ) iStart++; + iThisCol++; + } + if( z[iOff]==')' ) break; + } + if( z[iOff]=='(' ) nOpen++; + if( z[iOff]==')' ) nOpen--; + nToken = intckGetToken(zToken); + + if( intckTokenMatch(zToken, nToken, "ASC", "DESC") ){ + iEndOfCol = iOff; + }else if( 0==intckIsSpace(zToken[0]) ){ + iEndOfCol = 0; + } + + iOff += nToken; + } + + /* iStart is now the byte offset of 1 byte passed the final ')' in the + ** CREATE INDEX statement. Try to find a WHERE clause to return. */ + while( zRet==0 && z[iOff] ){ + int n = intckGetToken(&z[iOff]); + if( n==5 && 0==sqlite3_strnicmp(&z[iOff], "where", 5) ){ + zRet = &z[iOff+5]; + nRet = strlen(zRet); + } + iOff += n; + } + + /* Trim any whitespace from the start and end of the returned string. */ + if( zRet ){ + while( intckIsSpace(zRet[0]) ){ + nRet--; + zRet++; + } + while( nRet>0 && intckIsSpace(zRet[nRet-1]) ) nRet--; + } + + *pnByte = nRet; + return zRet; +} + +static void parseCreateIndexFunc( + sqlite3_context *pCtx, + int nVal, + sqlite3_value **apVal +){ + const char *zSql = (const char*)sqlite3_value_text(apVal[0]); + int idx = sqlite3_value_int(apVal[1]); + const char *zRes = 0; + int nRes = 0; + + assert( nVal==2 ); + if( zSql ){ + zRes = intckParseCreateIndex(zSql, idx, &nRes); + } + sqlite3_result_text(pCtx, zRes, nRes, SQLITE_TRANSIENT); +} + +/* +** Return true if sqlite3_intck.db has automatic indexes enabled, false +** otherwise. +*/ +static int intckGetAutoIndex(sqlite3_intck *p){ + int bRet = 0; + sqlite3_stmt *pStmt = 0; + pStmt = intckPrepare(p, "PRAGMA automatic_index"); + if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ + bRet = sqlite3_column_int(pStmt, 0); + } + intckFinalize(p, pStmt); + return bRet; +} + +/* +** Return true if zObj is an index, or false otherwise. +*/ +static int intckIsIndex(sqlite3_intck *p, const char *zObj){ + int bRet = 0; + sqlite3_stmt *pStmt = 0; + pStmt = intckPrepare(p, + "SELECT 1 FROM %Q.sqlite_schema WHERE name=%Q AND type='index'", + p->zDb, zObj + ); + if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ + bRet = 1; + } + intckFinalize(p, pStmt); + return bRet; +} + +static void intckExec(sqlite3_intck *p, const char *zSql){ + sqlite3_stmt *pStmt = 0; + pStmt = intckPrepare(p, "%s", zSql); + while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ); + intckFinalize(p, pStmt); +} + +static char *intckCheckObjectSql(sqlite3_intck *p, const char *zObj){ + char *zRet = 0; + sqlite3_stmt *pStmt = 0; + int bAutoIndex = 0; + int bIsIndex = 0; + + const char *zCommon = + /* Relation without_rowid also contains just one row. Column "b" is + ** set to true if the table being examined is a WITHOUT ROWID table, + ** or false otherwise. */ + ", without_rowid(b) AS (" + " SELECT EXISTS (" + " SELECT 1 FROM tabname, pragma_index_list(tab, db) AS l" + " WHERE origin='pk' " + " AND NOT EXISTS (SELECT 1 FROM sqlite_schema WHERE name=l.name)" + " )" + ")" + "" + /* Table idx_cols contains 1 row for each column in each index on the + ** table being checked. Columns are: + ** + ** idx_name: Name of the index. + ** idx_ispk: True if this index is the PK of a WITHOUT ROWID table. + ** col_name: Name of indexed column, or NULL for index on expression. + ** col_expr: Indexed expression, including COLLATE clause. + ** col_alias: Alias used for column in 'intck_wrapper' table. + */ + ", idx_cols(idx_name, idx_ispk, col_name, col_expr, col_alias) AS (" + " SELECT l.name, (l.origin=='pk' AND w.b), i.name, COALESCE((" + " SELECT parse_create_index(sql, i.seqno) FROM " + " sqlite_schema WHERE name = l.name" + " ), format('\"%w\"', i.name) || ' COLLATE ' || quote(i.coll))," + " 'c' || row_number() OVER ()" + " FROM " + " tabname t," + " without_rowid w," + " pragma_index_list(t.tab, t.db) l," + " pragma_index_xinfo(l.name) i" + " WHERE i.key" + " UNION ALL" + " SELECT '', 1, '_rowid_', '_rowid_', 'r1' FROM without_rowid WHERE b=0" + ")" + "" + "" + ", tabpk(db, tab, idx, o_pk, i_pk, q_pk, eq_pk, ps_pk, pk_pk) AS (" + " WITH pkfields(f, a) AS (" + " SELECT i.col_name, i.col_alias FROM idx_cols i WHERE i.idx_ispk" + " )" + " SELECT t.db, t.tab, t.idx, " + " group_concat('o.'||a, ', '), " + " group_concat('i.'||quote(f), ', '), " + " group_concat('quote(o.'||a||')', ' || '','' || '), " + " format('(%s)==(%s)'," + " group_concat('o.'||a, ', '), " + " group_concat(format('\"%w\"', f), ', ')" + " )," + " group_concat('%s', ',')," + " group_concat('quote('||a||')', ', ') " + " FROM tabname t, pkfields" + ")" + "" + ", idx(name, match_expr, partial, partial_alias, idx_ps, idx_idx) AS (" + " SELECT idx_name," + " format('(%s) IS (%s)', " + " group_concat(i.col_expr, ', ')," + " group_concat('o.'||i.col_alias, ', ')" + " ), " + " parse_create_index(" + " (SELECT sql FROM sqlite_schema WHERE name=idx_name), -1" + " )," + " 'cond' || row_number() OVER ()" + " , group_concat('%s', ',')" + " , group_concat('quote('||i.col_alias||')', ', ')" + " FROM tabpk t, " + " without_rowid w," + " idx_cols i" + " WHERE i.idx_ispk==0 " + " GROUP BY idx_name" + ")" + "" + ", wrapper_with(s) AS (" + " SELECT 'intck_wrapper AS (\n SELECT\n ' || (" + " WITH f(a, b) AS (" + " SELECT col_expr, col_alias FROM idx_cols" + " UNION ALL " + " SELECT partial, partial_alias FROM idx WHERE partial IS NOT NULL" + " )" + " SELECT group_concat(format('%s AS %s', a, b), ',\n ') FROM f" + " )" + " || format('\n FROM %Q.%Q ', t.db, t.tab)" + /* If the object being checked is a table, append "NOT INDEXED". + ** Otherwise, append "INDEXED BY ", and then, if the index + ** is a partial index " WHERE ". */ + " || CASE WHEN t.idx IS NULL THEN " + " 'NOT INDEXED'" + " ELSE" + " format('INDEXED BY %Q%s', t.idx, ' WHERE '||i.partial)" + " END" + " || '\n)'" + " FROM tabname t LEFT JOIN idx i ON (i.name=t.idx)" + ")" + "" + ; + + bAutoIndex = intckGetAutoIndex(p); + if( bAutoIndex ) intckExec(p, "PRAGMA automatic_index = 0"); + + bIsIndex = intckIsIndex(p, zObj); + if( bIsIndex ){ + pStmt = intckPrepare(p, + /* Table idxname contains a single row. The first column, "db", contains + ** the name of the db containing the table (e.g. "main") and the second, + ** "tab", the name of the table itself. */ + "WITH tabname(db, tab, idx) AS (" + " SELECT %Q, (SELECT tbl_name FROM %Q.sqlite_schema WHERE name=%Q), %Q " + ")" + "%s" /* zCommon */ + "" + ", case_statement(c) AS (" + " SELECT " + " 'CASE WHEN (' || group_concat(col_alias, ', ') || ') IS (\n ' " + " || 'SELECT ' || group_concat(col_expr, ', ') || ' FROM '" + " || format('%%Q.%%Q NOT INDEXED WHERE %%s\n)', t.db, t.tab, p.eq_pk)" + " || '\nTHEN NULL\n'" + " || 'ELSE format(''surplus entry ('" + " || group_concat('%%s', ',') || ',' || p.ps_pk" + " || ') in index ' || t.idx || ''', ' " + " || group_concat('quote('||i.col_alias||')', ', ') || ', ' || p.pk_pk" + " || ')'" + " || '\nEND'" + " FROM tabname t, tabpk p, idx_cols i WHERE i.idx_name=t.idx" + "" + ")" + "" + ", main_select(m) AS (" + " SELECT format(" + " 'WITH %%s\nSELECT %%s\nFROM intck_wrapper AS o'," + " ww.s, c" + " )" + " FROM case_statement, wrapper_with ww" + ")" + + "SELECT m FROM main_select" + , p->zDb, p->zDb, zObj, zObj + , zCommon + ); + }else{ + pStmt = intckPrepare(p, + /* Table tabname contains a single row. The first column, "db", contains + ** the name of the db containing the table (e.g. "main") and the second, + ** "tab", the name of the table itself. */ + "WITH tabname(db, tab, idx) AS (SELECT %Q, %Q, NULL)" + "" + "%s" /* zCommon */ + + /* expr(e) contains one row for each index on table zObj. Value e + ** is set to an expression that evaluates to NULL if the required + ** entry is present in the index, or an error message otherwise. */ + ", expr(e, p) AS (" + " SELECT format('CASE WHEN (%%s) IN\n" + " (SELECT %%s FROM %%Q.%%Q AS i INDEXED BY %%Q WHERE %%s%%s)\n" + " THEN NULL\n" + " ELSE format(''entry (%%s,%%s) missing from index %%s'', %%s, %%s)\n" + " END\n'" + " , t.o_pk, t.i_pk, t.db, t.tab, i.name, i.match_expr, " + " ' AND (' || partial || ')'," + " i.idx_ps, t.ps_pk, i.name, i.idx_idx, t.pk_pk)," + " CASE WHEN partial IS NULL THEN NULL ELSE i.partial_alias END" + " FROM tabpk t, idx i" + ")" + + ", numbered(ii, cond, e) AS (" + " SELECT 0, 'n.ii=0', 'NULL'" + " UNION ALL " + " SELECT row_number() OVER ()," + " '(n.ii='||row_number() OVER ()||COALESCE(' AND '||p||')', ')'), e" + " FROM expr" + ")" + + ", counter_with(w) AS (" + " SELECT 'WITH intck_counter(ii) AS (\n ' || " + " group_concat('SELECT '||ii, ' UNION ALL\n ') " + " || '\n)' FROM numbered" + ")" + "" + ", case_statement(c) AS (" + " SELECT 'CASE ' || " + " group_concat(format('\n WHEN %%s THEN (%%s)', cond, e), '') ||" + " '\nEND AS error_message'" + " FROM numbered" + ")" + + ", main_select(m) AS (" + " SELECT format(" + " '%%s, %%s\nSELECT %%s\nFROM intck_wrapper AS o" + ", intck_counter AS n ORDER BY %%s', " + " w, ww.s, c, t.o_pk" + " )" + " FROM case_statement, tabpk t, counter_with, wrapper_with ww" + ")" + + "SELECT m FROM main_select", + p->zDb, zObj, zCommon + ); + } + + while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ +#if 0 + int nField = sqlite3_column_count(pStmt); + int ii; + for(ii=0; iipListTables, 0); + char *zSql = intckCheckObjectSql(p, zTab); + p->pCheck = intckPrepare(p, "%s", zSql); + sqlite3_free(zSql); +} + +int sqlite3_intck_open( + sqlite3 *db, /* Database handle to operate on */ + const char *zDbArg, /* "main", "temp" etc. */ + const char *zFile, /* Path to save-state db on disk (or NULL) */ + sqlite3_intck **ppOut /* OUT: New integrity-check handle */ +){ + sqlite3_intck *pNew = 0; + int rc = SQLITE_OK; + const char *zDb = zDbArg ? zDbArg : "main"; + int nDb = strlen(zDb); + + pNew = (sqlite3_intck*)sqlite3_malloc(sizeof(*pNew) + nDb + 1); + if( pNew==0 ){ + rc = SQLITE_NOMEM; + }else{ + memset(pNew, 0, sizeof(*pNew)); + pNew->db = db; + pNew->zDb = (const char*)&pNew[1]; + memcpy(&pNew[1], zDb, nDb+1); + sqlite3_create_function(db, "parse_create_index", + 2, SQLITE_UTF8, 0, parseCreateIndexFunc, 0, 0 + ); + } + + *ppOut = pNew; + return rc; +} + +void sqlite3_intck_close(sqlite3_intck *p){ + if( p && p->db ){ + sqlite3_create_function( + p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0 + ); + } + sqlite3_free(p->zTestSql); + sqlite3_free(p->zErr); + sqlite3_free(p); +} + +int sqlite3_intck_step(sqlite3_intck *p){ + if( p->rc==SQLITE_OK ){ + if( p->pListTables==0 ){ + p->pListTables = intckListTables(p); + } + assert( p->pListTables || p->rc!=SQLITE_OK ); + + if( p->rc==SQLITE_OK && p->pCheck==0 ){ + if( sqlite3_step(p->pListTables)==SQLITE_ROW ){ + intckCheckObject(p); + }else{ + int rc = sqlite3_finalize(p->pListTables); + if( rc==SQLITE_OK ){ + p->rc = SQLITE_DONE; + }else{ + intckSaveErrmsg(p); + } + p->pListTables = 0; + } + } + + if( p->rc==SQLITE_OK ){ + if( sqlite3_step(p->pCheck)==SQLITE_ROW ){ + /* Fine, whatever... */ + }else{ + if( sqlite3_finalize(p->pCheck)!=SQLITE_OK ){ + intckSaveErrmsg(p); + } + p->pCheck = 0; + } + } + } + + return p->rc; +} + +const char *sqlite3_intck_message(sqlite3_intck *p){ + if( p->pCheck ){ + return (const char*)sqlite3_column_text(p->pCheck, 0); + } + return 0; +} + +int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){ + *pzErr = p->zErr; + return (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc); +} + +int sqlite3_intck_suspend(sqlite3_intck *pCk){ + return SQLITE_OK; +} + +const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){ + sqlite3_free(p->zTestSql); + p->zTestSql = intckCheckObjectSql(p, zObj); + return p->zTestSql; +} + diff --git a/ext/intck/sqlite3intck.h b/ext/intck/sqlite3intck.h new file mode 100644 index 0000000000..8846812e75 --- /dev/null +++ b/ext/intck/sqlite3intck.h @@ -0,0 +1,55 @@ +/* +** 2024-02-08 +** +** 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. +** +************************************************************************* +*/ + +#ifndef _SQLITE_INTCK_H +#define _SQLITE_INTCK_H + +#include "sqlite3.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct sqlite3_intck sqlite3_intck; + +int sqlite3_intck_open( + sqlite3 *db, + const char *zDb, + const char *zFile, + sqlite3_intck **ppOut +); + +void sqlite3_intck_close(sqlite3_intck*); + +int sqlite3_intck_step(sqlite3_intck *pCk); + +const char *sqlite3_intck_message(sqlite3_intck *pCk); + +int sqlite3_intck_error(sqlite3_intck *pCk, const char **pzErr); + +int sqlite3_intck_suspend(sqlite3_intck *pCk); + +/* +** This API is used for testing only. It returns the full-text of an SQL +** statement used to test object zObj, which may be a table or index. +** The returned buffer is valid until the next call to either this function +** or sqlite3_intck_close() on the same sqlite3_intck handle. +*/ +const char *sqlite3_intck_test_sql(sqlite3_intck *pCk, const char *zObj); + + +#ifdef __cplusplus +} /* end of the 'extern "C"' block */ +#endif + +#endif /* ifndef _SQLITE_INTCK_H */ diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c new file mode 100644 index 0000000000..33129ec275 --- /dev/null +++ b/ext/intck/test_intck.c @@ -0,0 +1,185 @@ +/* +** 2010 August 28 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** Code for testing all sorts of SQLite interfaces. This code +** is not included in the SQLite library. +*/ + +#include "sqlite3.h" +#include "sqlite3intck.h" + +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif + +#include +#include + +/* In test1.c */ +int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); +const char *sqlite3ErrName(int); + +typedef struct TestIntck TestIntck; +struct TestIntck { + sqlite3_intck *intck; +}; + +static int testIntckCmd( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + struct Subcmd { + const char *zName; + int nArg; + const char *zExpect; + } aCmd[] = { + {"close", 0, ""}, /* 0 */ + {"step", 0, ""}, /* 1 */ + {"message", 0, ""}, /* 2 */ + {"error", 0, ""}, /* 3 */ + {"suspend", 0, ""}, /* 4 */ + {"test_sql", 1, ""}, /* 5 */ + {0 , 0} + }; + int rc = TCL_OK; + int iIdx = -1; + TestIntck *p = (TestIntck*)clientData; + + if( objc<2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "SUB-COMMAND ..."); + return TCL_ERROR; + } + + rc = Tcl_GetIndexFromObjStruct( + interp, objv[1], aCmd, sizeof(aCmd[0]), "SUB-COMMAND", 0, &iIdx + ); + if( rc ) return rc; + + if( objc!=2+aCmd[iIdx].nArg ){ + Tcl_WrongNumArgs(interp, 2, objv, aCmd[iIdx].zExpect); + return TCL_ERROR; + } + + switch( iIdx ){ + case 0: assert( 0==strcmp("close", aCmd[iIdx].zName) ); { + Tcl_DeleteCommand(interp, Tcl_GetStringFromObj(objv[0], 0)); + break; + } + + case 1: assert( 0==strcmp("step", aCmd[iIdx].zName) ); { + int rc = sqlite3_intck_step(p->intck); + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); + break; + } + + case 2: assert( 0==strcmp("message", aCmd[iIdx].zName) ); { + const char *z = sqlite3_intck_message(p->intck); + Tcl_SetObjResult(interp, Tcl_NewStringObj(z ? z : "", -1)); + break; + } + + case 3: assert( 0==strcmp("error", aCmd[iIdx].zName) ); { + const char *zErr = 0; + int rc = sqlite3_intck_error(p->intck, &zErr); + Tcl_Obj *pRes = Tcl_NewObj(); + + Tcl_ListObjAppendElement( + interp, pRes, Tcl_NewStringObj(sqlite3ErrName(rc), -1) + ); + Tcl_ListObjAppendElement( + interp, pRes, Tcl_NewStringObj(zErr ? zErr : 0, -1) + ); + Tcl_SetObjResult(interp, pRes); + break; + } + + case 4: assert( 0==strcmp("suspend", aCmd[iIdx].zName) ); { + int rc = sqlite3_intck_suspend(p->intck); + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); + break; + } + + case 5: assert( 0==strcmp("test_sql", aCmd[iIdx].zName) ); { + const char *zObj = Tcl_GetString(objv[2]); + const char *zSql = sqlite3_intck_test_sql(p->intck, zObj); + Tcl_SetObjResult(interp, Tcl_NewStringObj(zSql, -1)); + break; + } + } + + return TCL_OK; +} + +/* +** Destructor for commands created by test_sqlite3_intck(). +*/ +static void testIntckFree(void *clientData){ + TestIntck *p = (TestIntck*)clientData; + sqlite3_intck_close(p->intck); + ckfree(p); +} + +/* +** tclcmd: sqlite3_intck DB DBNAME PATH +*/ +static int test_sqlite3_intck( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + char zName[64]; + int iName = 0; + Tcl_CmdInfo info; + TestIntck *p = 0; + sqlite3 *db = 0; + const char *zDb = 0; + const char *zFile = 0; + int rc = SQLITE_OK; + + if( objc!=4 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME PATH"); + return TCL_ERROR; + } + + p = (TestIntck*)ckalloc(sizeof(TestIntck)); + memset(p, 0, sizeof(TestIntck)); + + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ + return TCL_ERROR; + } + zDb = Tcl_GetString(objv[2]); + zFile = Tcl_GetString(objv[3]); + + rc = sqlite3_intck_open(db, zDb, zFile, &p->intck); + if( rc!=SQLITE_OK ){ + ckfree(p); + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errstr(rc), -1)); + return TCL_ERROR; + } + + do { + sprintf(zName, "intck%d", iName); + }while( Tcl_GetCommandInfo(interp, zName, &info)!=0 ); + Tcl_CreateObjCommand(interp, zName, testIntckCmd, (void*)p, testIntckFree); + Tcl_SetObjResult(interp, Tcl_NewStringObj(zName, -1)); + + return TCL_OK; +} + +int Sqlitetestintck_Init(Tcl_Interp *interp){ + Tcl_CreateObjCommand(interp, "sqlite3_intck", test_sqlite3_intck, 0, 0); + return TCL_OK; +} diff --git a/main.mk b/main.mk index 081e0cd3b5..0a0af725d0 100644 --- a/main.mk +++ b/main.mk @@ -375,7 +375,9 @@ TESTSRC += \ $(TOP)/ext/rtree/test_rtreedoc.c \ $(TOP)/ext/recover/sqlite3recover.c \ $(TOP)/ext/recover/dbdata.c \ - $(TOP)/ext/recover/test_recover.c + $(TOP)/ext/recover/test_recover.c \ + $(TOP)/ext/intck/test_intck.c \ + $(TOP)/ext/intck/sqlite3intck.c #TESTSRC += $(TOP)/ext/fts3/fts3_tokenizer.c diff --git a/manifest b/manifest index ab0f22bde5..a378ab14eb 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Fix\srounding\sin\szero-precision\s%f\sand\s%g\sprintf\sconversions.\n[forum:/info/393708f4a8|Forum\spost\s393708f4a8].\s\sThis\sbug\swas\nintroduced\sby\scheck-in\s[32befb224b254639]\sand\sfirst\sappeared\sin\sversion\s3.43.0. -D 2024-02-17T03:32:31.878 +C Add\sstart\sof\sextension\sfor\sincremental\sintegrity-checks\sto\sext/intck/. +D 2024-02-17T20:55:01.343 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 24be65ae641c5727bbc247d60286a15ecc24fb80f14f8fb2d32533bf0ec96e79 +F Makefile.in 216eea0cc5a9613d9f4f21402a4b759c2fce2a0cb9567513933562b65e30670b F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc df56c06ef05add5ebcdcc9d4823fb2ec66ac16b06acb6971a7420859025886fa +F Makefile.msc a496ca640052c1e102daaa6e2d2216ae482f22995498c7c9492fd7f841481400 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 F VERSION c84541c6a9e8426462176fbb1f9ecb5cfd7d1bb56228053ff7eeba8841673eb6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -248,6 +248,12 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 +F ext/intck/intck1.test 0fcf3696b59aff6c344553647d612921dd529600796ff7172c02679955cecdcf +F ext/intck/intck2.test dd06719eca145b317ae380c81f04cd8a096a7cfdb71074cc6b6e7f195058b0d0 +F ext/intck/intck_common.tcl 1f2599d50033d21d5df89f5ed54cc29af472d86e3927e116db50c5ba94d903b9 +F ext/intck/sqlite3intck.c 14300998e91cd8788f483d97e53be9406f2c0be8af1867f399b80fef5e3721fb +F ext/intck/sqlite3intck.h 342ee2e2c7636b4daf29fa195d0a3a658272b76b283d586fba50f6bc80fc143d +F ext/intck/test_intck.c 3f9a950978842340df7492f0a4190022979f23ff904e90873a5e262adf30b78c F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -659,7 +665,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk ef8d6b0e76b27d2b32d7b71ea30a2b2626b668f998a4f32f6171c9623a310a53 +F main.mk 678f023e03c5dca755570ed964a8355e44a6435f679e3763a6f9fe3d309f9986 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -790,7 +796,7 @@ F src/test_schema.c cbfd7a9a9b6b40d4377d0c76a6c5b2a58387385977f26edab4e77eb5f90a F src/test_sqllog.c 540feaea7280cd5f926168aee9deb1065ae136d0bbbe7361e2ef3541783e187a F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e F src/test_syscall.c 9fdb13b1df05e639808d44fcb8f6064aaded32b6565c00b215cfd05a060d1aca -F src/test_tclsh.c 3ff5d188a72f00807425954ea3b493dfd3a4b890ecc6700ea83bad2fd1332ecf +F src/test_tclsh.c aaf0d1de4a518a8db5ad38e5262be3e48b4a74ad1909f2dba753cecb30979d5d F src/test_tclvar.c 3273f9d59395b336e381b53cfc68ec6ebdaada4e93106a2e976ffb0550504e1c F src/test_thread.c 7ddcf0c8b79fa3c1d172f82f322302c963d923cdb503c6171f3c8081586d0b01 F src/test_vdbecov.c f60c6f135ec42c0de013a1d5136777aa328a776d33277f92abac648930453d43 @@ -2162,8 +2168,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e -R e3e534a124d08ab0760f858683268942 -U drh -Z 25ef9b1be0189ee473aa53bd8732a56c +P 7fca1bc482fc2456d75392eb42f768fda72631c9070de46b8123b1126e78306f +R f8dccfe308ed2507020014beca90ae47 +T *branch * incr-integrity-check +T *sym-incr-integrity-check * +T -sym-trunk * +U dan +Z 8b8b6eda2ec7249d41ba58db982258fb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e28ec46dd..7ea8d90d42 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7fca1bc482fc2456d75392eb42f768fda72631c9070de46b8123b1126e78306f \ No newline at end of file +444e3c9210026da7eae1ed98850722e002433aa2cc77dbc6b6f80327a6b7a390 \ No newline at end of file diff --git a/src/test_tclsh.c b/src/test_tclsh.c index 32aee42675..4697c3b856 100644 --- a/src/test_tclsh.c +++ b/src/test_tclsh.c @@ -108,6 +108,7 @@ const char *sqlite3TestInit(Tcl_Interp *interp){ extern int Sqlitetest_window_Init(Tcl_Interp *); extern int Sqlitetestvdbecov_Init(Tcl_Interp *); extern int TestRecover_Init(Tcl_Interp*); + extern int Sqlitetestintck_Init(Tcl_Interp*); Tcl_CmdInfo cmdInfo; @@ -175,6 +176,7 @@ const char *sqlite3TestInit(Tcl_Interp *interp){ Sqlitetest_window_Init(interp); Sqlitetestvdbecov_Init(interp); TestRecover_Init(interp); + Sqlitetestintck_Init(interp); Tcl_CreateObjCommand( interp, "load_testfixture_extensions", load_testfixture_extensions,0,0 From d43e7adca7eb5d8c1ac6b345aa2470ed0f8b2c06 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 18 Feb 2024 01:12:22 +0000 Subject: [PATCH 0113/1030] Hold a transaction during PRAGMA optimize, for performance. FossilOrigin-Name: d13b79eae6df7f9d1f3b8062ddc75a12ff038196b3d752d2672a9925fa45ca56 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 18e8630874..e3c3328eb1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sMASK\sbits\sto\sPRAGMA\soptimize:\s\s0x70000. -D 2024-02-17T16:39:52.117 +C Hold\sa\stransaction\sduring\sPRAGMA\soptimize,\sfor\sperformance. +D 2024-02-18T01:12:22.988 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c c5b767e7538a808fac4f17f8891acb1f14b4eed3458d971ddea4dd82f7623e0c +F src/pragma.c c7ef49d3332badd6e17ac46e0aca762d7973c1e28156bc480c47aa3e56ae4d03 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 40532ffba91cf332c1ea4add80184031a9d6e10514d2d9b9a6cfd613091b81f7 -R 518017150456f4f932816e90c763b561 +P dd4497062569eec9ddfdaa7d6394c83ff40a7a59c6697a161bc4ff6d8af3bb29 +R 5aca31e5331abdce830c908f0aade7ae U drh -Z 4ff4c253b76c891ec5769cfa9bfe8766 +Z 497aafa2ad4da05132856bc0e0f3518f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c4b9f73820..0aec312a78 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dd4497062569eec9ddfdaa7d6394c83ff40a7a59c6697a161bc4ff6d8af3bb29 \ No newline at end of file +d13b79eae6df7f9d1f3b8062ddc75a12ff038196b3d752d2672a9925fa45ca56 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 40a31846bb..9bb971ed77 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2446,6 +2446,7 @@ void sqlite3Pragma( char *zSubSql; /* SQL statement for the OP_SqlExec opcode */ u32 opMask; /* Mask of operations to perform */ int nLimit; /* Analysis limit to use */ + int once = 0; /* One-time initialization done */ #ifndef SQLITE_DEFAULT_OPTIMIZE_LIMIT # define SQLITE_DEFAULT_OPTIMIZE_LIMIT 400 @@ -2488,6 +2489,12 @@ void sqlite3Pragma( continue; } + /* Hold a write transaction open for efficiency */ + if( !once ){ + sqlite3BeginWriteOperation(pParse, 0, iDb); + once = 1; + } + /* Reanalyze if the table is 25 times larger than the last analysis */ szThreshold = pTab->nRowLogEst; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ From e0a9935be1c506646566f6b7845eb381bb219e16 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 19 Feb 2024 12:20:46 +0000 Subject: [PATCH 0114/1030] Extend the strerror_r() result type discrepancy check in os_unix.c to include the Android NDK, as reported in [forum post 3f13857fa4062301|forum:3f13857fa4062301]. The NDK's strerror_r() signature is version-dependent, whereas this change assumes int return (POSIX semantic) across all versions. FossilOrigin-Name: f18b2524da6bbbcf372b292df52fbe6efa49fd6e1f1f13ef2447279d559f7a08 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ab0f22bde5..1fd935940c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\srounding\sin\szero-precision\s%f\sand\s%g\sprintf\sconversions.\n[forum:/info/393708f4a8|Forum\spost\s393708f4a8].\s\sThis\sbug\swas\nintroduced\sby\scheck-in\s[32befb224b254639]\sand\sfirst\sappeared\sin\sversion\s3.43.0. -D 2024-02-17T03:32:31.878 +C Extend\sthe\sstrerror_r()\sresult\stype\sdiscrepancy\scheck\sin\sos_unix.c\sto\sinclude\sthe\sAndroid\sNDK,\sas\sreported\sin\s[forum\spost\s3f13857fa4062301|forum:3f13857fa4062301].\sThe\sNDK's\sstrerror_r()\ssignature\sis\sversion-dependent,\swhereas\sthis\schange\sassumes\sint\sreturn\s(POSIX\ssemantic)\sacross\sall\sversions. +D 2024-02-19T12:20:46.413 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -723,7 +723,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c fa9b81b642e60e77ffaf98bd1a2e5fde16c1c2317614ec178bf3bd5864772356 +F src/os_unix.c 8d7533b3b4d0d2d6ddd34d1ebc92f50a91f04e722a3a9295a000bc3c25128e2f F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e -R e3e534a124d08ab0760f858683268942 -U drh -Z 25ef9b1be0189ee473aa53bd8732a56c +P 7fca1bc482fc2456d75392eb42f768fda72631c9070de46b8123b1126e78306f +R a2e48d1032c74dc590366e533d9ce522 +U stephan +Z f46d908a23e6be0d034c20949f0d6956 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e28ec46dd..ed8ee25bd1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7fca1bc482fc2456d75392eb42f768fda72631c9070de46b8123b1126e78306f \ No newline at end of file +f18b2524da6bbbcf372b292df52fbe6efa49fd6e1f1f13ef2447279d559f7a08 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 4b3d63c2c1..4663c22d94 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1295,8 +1295,12 @@ static int unixLogErrorAtLine( ** available, the error message will often be an empty string. Not a ** huge problem. Incorrectly concluding that the GNU version is available ** could lead to a segfault though. + ** + ** Forum post 3f13857fa4062301 reports that the Android SDK may use + ** int-type return, depending on its version. */ -#if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU) +#if (defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)) \ + && !defined(ANDROID) && !defined(__ANDROID__) zErr = # endif strerror_r(iErrno, aErr, sizeof(aErr)-1); From 9f34a05e98c3cffe48d935979bf745cc267efe4e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Feb 2024 13:06:27 +0000 Subject: [PATCH 0115/1030] Change the 0x20000 bit (use analysis limit) to 0x10, meaning that this feature is on by default. The default analysis limit is changed to 2000 which is almost always sufficient for accurate analysis results. FossilOrigin-Name: 4abd47b5917099a2f74e53e12c987da0722304a5e9a93b6d43015c1f45c48444 --- manifest | 14 +++++------ manifest.uuid | 2 +- src/pragma.c | 66 ++++++++++++++++++++++++++++++++++---------------- test/busy.test | 2 +- 4 files changed, 54 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index e3c3328eb1..54ba56837e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Hold\sa\stransaction\sduring\sPRAGMA\soptimize,\sfor\sperformance. -D 2024-02-18T01:12:22.988 +C Change\sthe\s0x20000\sbit\s(use\sanalysis\slimit)\sto\s0x10,\smeaning\sthat\sthis\sfeature\nis\son\sby\sdefault.\s\sThe\sdefault\sanalysis\slimit\sis\schanged\sto\s2000\swhich\sis\nalmost\salways\ssufficient\sfor\saccurate\sanalysis\sresults. +D 2024-02-19T13:06:27.586 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c c7ef49d3332badd6e17ac46e0aca762d7973c1e28156bc480c47aa3e56ae4d03 +F src/pragma.c b877efa88ea41560ee5dd95daa30c8cadb743381c59b8921a5143bf0792c6e3b F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -947,7 +947,7 @@ F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b F test/btree01.test fef17d9e999ac4f04095948e3438fbe674f4e07bb2c63bb1cad41d87baee077f F test/btree02.test 7555a5440453d900410160a52554fe6478af4faf53098f7235f1f443d5a1d6cc F test/btreefault.test a82a23b0578bc587afbf9a622c8f54a54f63762f062ba8a35613cfee38ab42f9 -F test/busy.test 510dc6daaad18bcbbc085bcc6217d6dc418def5e73f72ce1475eea0cb7834727 +F test/busy.test caff7164c16ce06a53af51f9e4c2753d4cc64250e00790a5e48b9c4f4be37597 F test/busy2.test 20823a5d7c42fb257d9f108c66312d90b1bb4ec3d80ba6b4e371073727560f98 F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de F test/cacheflush.test af25bb1509df04c1da10e38d8f322d66eceedf61 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dd4497062569eec9ddfdaa7d6394c83ff40a7a59c6697a161bc4ff6d8af3bb29 -R 5aca31e5331abdce830c908f0aade7ae +P d13b79eae6df7f9d1f3b8062ddc75a12ff038196b3d752d2672a9925fa45ca56 +R e258fa6228ef566d2b5670b2822a20d1 U drh -Z 497aafa2ad4da05132856bc0e0f3518f +Z e864b92d6fb5e0c6f09ca55fa83dd960 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0aec312a78..9cda73c43e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d13b79eae6df7f9d1f3b8062ddc75a12ff038196b3d752d2672a9925fa45ca56 \ No newline at end of file +4abd47b5917099a2f74e53e12c987da0722304a5e9a93b6d43015c1f45c48444 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 9bb971ed77..6e1fc8bc00 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -30,6 +30,34 @@ ** ../tool/mkpragmatab.tcl. */ #include "pragma.h" +/* +** When the 0x10 bit of PRAGMA optimize is set, any ANALYZE commands +** will be run with an analysis_limit set to the lessor of the value of +** the following macro or to the actual analysis_limit if it is non-zero, +** in order to prevent PRAGMA optimize from running for too long. +** +** The value of 2000 is chosen emperically so that the worst-case run-time +** for PRAGMA optimize does not exceed 100 milliseconds against a variety +** of test databases on a RaspberryPI-4 compiled using -Os and without +** -DSQLITE_DEBUG. Of course, your mileage may vary. For the purpose of +** his paragraph, "worst-case" means that ANALYZE ends up being +** run on every table in the database. The worst case typically only +** happens if PRAGMA optimize is run on a database file for which ANALYZE +** has not been previously run and the 0x10000 flag is included so that +** all tables are analyzed. The usual case for PRAGMA optimize is that +** no ANALYZE commands will be run at all, or if any ANALYZE happens it +** will be against a single table, so that expected timing for PRAGMA +** optimize on a PI-4 is more like 1 millisecond or less with the 0x10000 +** flag or less than 100 microseconds without the 0x10000 flag. +** +** An analysis limit of 2000 is almost always sufficient for the query +** planner to fully characterize an index. The additional accuracy from +** a larger analysis is not usually helpful. +*/ +#ifndef SQLITE_DEFAULT_OPTIMIZE_LIMIT +# define SQLITE_DEFAULT_OPTIMIZE_LIMIT 2000 +#endif + /* ** Interpret the given string as a safety level. Return 0 for OFF, ** 1 for ON or NORMAL, 2 for FULL, and 3 for EXTRA. Return 1 for an empty or @@ -2390,20 +2418,19 @@ void sqlite3Pragma( ** 0x00002 Run ANALYZE on tables that might benefit. On by default. ** See below for additional information. ** + ** 0x00010 Run all ANALYZE operations using an analysis_limit that + ** is the lessor of the current analysis_limit and the + ** SQLITE_DEFAULT_OPTIMIZE_LIMIT compile-time option. + ** The default value of SQLITE_DEFAULT_OPTIMIZE_LIMIT is + ** currently (2024-02-19) set to 2000, which is such that + ** the worst case run-time for PRAGMA optimize on a 100MB + ** database will usually be less than 100 milliseconds on + ** a RaspberryPI-4 class machine. Off by default. + ** ** 0x10000 Look at tables to see if they need to be reanalyzed ** even if they have not been queried during the current ** connection. Off by default. ** - ** 0x20000 Run all ANALYZE operations using an analysis_limit that - ** is the lessor of the current analysis_limit and the - ** SQLITE_DEFAULT_OPTIMIZE_LIMIT compile-time option, - ** nominally 400. Off by default. - ** - ** 0x40000 Tables become candidates for reanalysis if their size - ** grows or shrinks by 10x. Without this option, they - ** become candidates for reanalysis if their size grows - ** or shrinks by 25x. Off (25x mode) by default. - ** ** The default MASK is and always shall be 0x0fffe. In the current ** implementation, the default mask only covers the 0x00002 optimization, ** though additional optimizations that are covered by 0x0fffe might be @@ -2422,9 +2449,9 @@ void sqlite3Pragma( ** at some point during the lifetime of the current connection. ** ** (3) One or more indexes of the table are currently unanalyzed OR - ** the number of rows in the table has increased or decreased - ** 25 times or more (10 times or more if the 0x40000 bit is set) - ** since the last time ANALYZE was run. + ** the number of rows in the table has increased or decreased by + ** 10-fold (the new size is either greater than 10 times the old + ** size or less than 1/10th of the old size). ** ** (4) The table is an ordinary table, not a virtual table or view. ** @@ -2448,17 +2475,13 @@ void sqlite3Pragma( int nLimit; /* Analysis limit to use */ int once = 0; /* One-time initialization done */ -#ifndef SQLITE_DEFAULT_OPTIMIZE_LIMIT -# define SQLITE_DEFAULT_OPTIMIZE_LIMIT 400 -#endif - if( zRight ){ opMask = (u32)sqlite3Atoi(zRight); if( (opMask & 0x02)==0 ) break; }else{ opMask = 0xfffe; } - if( (opMask & 0x20000)==0 ){ + if( (opMask & 0x10)==0 ){ nLimit = 0; }else if( db->nAnalysisLimit>0 && db->nAnalysisLimitnRowLogEst; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ if( !pIdx->hasStat1 ){ @@ -2504,7 +2528,7 @@ void sqlite3Pragma( } } if( szThreshold>=0 ){ - LogEst iRange = (opMask & 0x40000) ? 33 : 46; + LogEst iRange = 33; /* 10x size change */ sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); sqlite3VdbeAddOp4Int(v, OP_IfSizeBetween, iTabCur, sqlite3VdbeCurrentAddr(v)+3+(opMask&1), diff --git a/test/busy.test b/test/busy.test index be0515b013..896c7fa651 100644 --- a/test/busy.test +++ b/test/busy.test @@ -106,7 +106,7 @@ do_test 3.4 { proc busy_handler {n} { return 1 } do_test 3.5 { catchsql { PRAGMA optimize } -} {0 {}} +} {1 {database is locked}} do_test 3.6 { execsql { COMMIT } db2 From 6c6356f7f2f3c6e717d445d117407e2edecccac5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Feb 2024 13:50:09 +0000 Subject: [PATCH 0116/1030] Simplifications to PRAGMA optimize to make it easier to use. It always tries to ANALYZE unanalyzed indexes. The 0x10000 flag just makes it check for size changes in all tables. FossilOrigin-Name: 44ed7f4cd07a88a2fdd303a2c78e6babe01d7344b399bd2b80ed68d75a77aaa2 --- manifest | 12 ++++---- manifest.uuid | 2 +- src/pragma.c | 77 +++++++++++++++++++++++++++++++++------------------ 3 files changed, 57 insertions(+), 34 deletions(-) diff --git a/manifest b/manifest index 54ba56837e..fdb16737f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\s0x20000\sbit\s(use\sanalysis\slimit)\sto\s0x10,\smeaning\sthat\sthis\sfeature\nis\son\sby\sdefault.\s\sThe\sdefault\sanalysis\slimit\sis\schanged\sto\s2000\swhich\sis\nalmost\salways\ssufficient\sfor\saccurate\sanalysis\sresults. -D 2024-02-19T13:06:27.586 +C Simplifications\sto\sPRAGMA\soptimize\sto\smake\sit\seasier\sto\suse.\s\sIt\salways\ntries\sto\sANALYZE\sunanalyzed\sindexes.\s\sThe\s0x10000\sflag\sjust\smakes\sit\scheck\nfor\ssize\schanges\sin\sall\stables. +D 2024-02-19T13:50:09.987 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c b877efa88ea41560ee5dd95daa30c8cadb743381c59b8921a5143bf0792c6e3b +F src/pragma.c 9197331dd283a6010bb4e2c129a9015f854203d27fa6fbe89e1aea742b78351c F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d13b79eae6df7f9d1f3b8062ddc75a12ff038196b3d752d2672a9925fa45ca56 -R e258fa6228ef566d2b5670b2822a20d1 +P 4abd47b5917099a2f74e53e12c987da0722304a5e9a93b6d43015c1f45c48444 +R 39db09ba2f5384fee677814cc2cbe4fe U drh -Z e864b92d6fb5e0c6f09ca55fa83dd960 +Z cf23276671f3baaf4e4f3579488af586 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9cda73c43e..f1cc73e3f0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4abd47b5917099a2f74e53e12c987da0722304a5e9a93b6d43015c1f45c48444 \ No newline at end of file +44ed7f4cd07a88a2fdd303a2c78e6babe01d7344b399bd2b80ed68d75a77aaa2 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 6e1fc8bc00..53dc9ced30 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2425,11 +2425,15 @@ void sqlite3Pragma( ** currently (2024-02-19) set to 2000, which is such that ** the worst case run-time for PRAGMA optimize on a 100MB ** database will usually be less than 100 milliseconds on - ** a RaspberryPI-4 class machine. Off by default. + ** a RaspberryPI-4 class machine. On by default. + ** + ** 0x00020 Run ANALYZE on any table that has a complete index + ** (an index without a WHERE clause) that lacks an entry + ** in the sqlite_stat1 table. On by default. ** ** 0x10000 Look at tables to see if they need to be reanalyzed - ** even if they have not been queried during the current - ** connection. Off by default. + ** due to growth or shrinkage even if they have not been + ** queried during the current connection. Off by default. ** ** The default MASK is and always shall be 0x0fffe. In the current ** implementation, the default mask only covers the 0x00002 optimization, @@ -2444,18 +2448,25 @@ void sqlite3Pragma( ** ** (1) MASK bit 0x00002 is set. ** - ** (2) Either the 0x10000 MASK bit is set or else the query planner used - ** sqlite_stat1-style statistics for one or more indexes of the table - ** at some point during the lifetime of the current connection. + ** (2) The table is an ordinary table, not a virtual table or view. ** - ** (3) One or more indexes of the table are currently unanalyzed OR - ** the number of rows in the table has increased or decreased by - ** 10-fold (the new size is either greater than 10 times the old - ** size or less than 1/10th of the old size). + ** (3) The table name does not begin with "sqlite_". ** - ** (4) The table is an ordinary table, not a virtual table or view. + ** (4) One or more of the following is true: + ** (4a) The 0x10000 MASK bit is set. + ** (4b) One or more complete indexes on the table lacks an entry + ** in the sqlite_stat1 table. + ** (4c) The query planner used sqlite_stat1-style statistics for one + ** or more indexes of the tableat some point during the lifetime + ** of the current connection. ** - ** (5) The table name does not begin with "sqlite_". + ** (5) One or more of the following is true: + ** (5a) One or mroe complete indexes on the table lacks an entry + ** in the sqlite_stat1 table. (Same as 4a) + ** (5b) The number of rows in the table has increased or decreased by + ** 10-fold. In other words, the current size of the table is + ** 10 times larger than the size in sqlite_stat1 or else the + ** current size is less than 1/10th the size in sqlite_stat1. ** ** The rules for when tables are analyzed are likely to change in ** future releases. Future versions of SQLite might accept a string @@ -2473,7 +2484,7 @@ void sqlite3Pragma( char *zSubSql; /* SQL statement for the OP_SqlExec opcode */ u32 opMask; /* Mask of operations to perform */ int nLimit; /* Analysis limit to use */ - int once = 0; /* One-time initialization done */ + int nCheck = 0; /* Number of tables to be optimized */ if( zRight ){ opMask = (u32)sqlite3Atoi(zRight); @@ -2503,30 +2514,42 @@ void sqlite3Pragma( /* Do not scan system tables */ if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ) continue; + /* Find the size of the table as last recorded in sqlite_stat1. + ** If any complete index (index without a WHERE clause) is unanalyzed, + ** then the threshold is -1 to indicate a new, unanalyzed index + */ + szThreshold = pTab->nRowLogEst; + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + if( !pIdx->hasStat1 && pIdx->pPartIdxWhere==0 ){ + szThreshold = -1; /* Always analyze if any index lacks statistics */ + break; + } + } + /* If table pTab has not been used in a way that would benefit from ** having analysis statistics during the current session, then skip it, ** unless the 0x10000 MASK bit is set. */ - if( (pTab->tabFlags & TF_MaybeReanalyze)==0 - && (opMask & 0x10000)==0 - ){ + if( (pTab->tabFlags & TF_MaybeReanalyze)!=0 ){ + /* Check for size change if stat1 has been used for a query */ + }else if( opMask & 0x10000 ){ + /* Check for size change if 0x10000 is set */ + }else if( pTab->pIndex!=0 && szThreshold<0 ){ + /* Do analysis if unanalyzed complete indexes exists */ + }else{ + /* Otherwise, we can skip this table */ continue; } - /* Hold a write transaction open for efficiency */ - if( !once || 1 ){ + nCheck++; + if( nCheck==2 ){ + /* If ANALYZE might be invoked two or more times, hold a write + ** transaction for efficiency */ sqlite3BeginWriteOperation(pParse, 0, iDb); - once = 1; } /* Reanalyze if the table is 10 times larger or smaller than - ** the last analysis */ - szThreshold = pTab->nRowLogEst; - for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ - if( !pIdx->hasStat1 ){ - szThreshold = -1; /* Always analyze if any index lacks statistics */ - break; - } - } + ** the last analysis. Unconditional reanalysis if there are + ** unanalyzed complete indexes. */ if( szThreshold>=0 ){ LogEst iRange = 33; /* 10x size change */ sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); From e7bdb2172c717f7ba64e15fb65b930524e759d71 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Feb 2024 16:22:58 +0000 Subject: [PATCH 0117/1030] If a table has one or more rows and it has a partial index has zero rows, still make an entry in the sqlite_stat1 table for the partial index, so that we know that "PRAGMA optimize" does not need to redo the whole table. FossilOrigin-Name: e147b18991dd462fff367442acb0504fdf193a31843ed34ec8c1ced30747bf8a --- ext/session/sessionstat1.test | 4 +- manifest | 20 +++++----- manifest.uuid | 2 +- src/analyze.c | 74 ++++++++++++++++++++--------------- src/btree.c | 8 ++-- src/pragma.c | 19 +++++---- src/vdbe.c | 2 +- 7 files changed, 70 insertions(+), 59 deletions(-) diff --git a/ext/session/sessionstat1.test b/ext/session/sessionstat1.test index 2757d60440..16dc4e2727 100644 --- a/ext/session/sessionstat1.test +++ b/ext/session/sessionstat1.test @@ -92,7 +92,7 @@ do_test 2.1 { } {} do_execsql_test -db db2 2.2 { - SELECT * FROM sqlite_stat1 + SELECT * FROM sqlite_stat1 ORDER BY tbl, idx } { t1 sqlite_autoindex_t1_1 {32 1} t1 t1b {32 4} @@ -104,7 +104,7 @@ do_test 2.3 { } {} do_execsql_test -db db2 2.4 { - SELECT * FROM sqlite_stat1 + SELECT * FROM sqlite_stat1 ORDER BY tbl, idx; } { t1 sqlite_autoindex_t1_1 {32 1} t1 t1b {32 4} diff --git a/manifest b/manifest index fdb16737f1..c12c473dca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sPRAGMA\soptimize\sto\smake\sit\seasier\sto\suse.\s\sIt\salways\ntries\sto\sANALYZE\sunanalyzed\sindexes.\s\sThe\s0x10000\sflag\sjust\smakes\sit\scheck\nfor\ssize\schanges\sin\sall\stables. -D 2024-02-19T13:50:09.987 +C If\sa\stable\shas\sone\sor\smore\srows\sand\sit\shas\sa\spartial\sindex\shas\szero\srows,\nstill\smake\san\sentry\sin\sthe\ssqlite_stat1\stable\sfor\sthe\spartial\sindex,\sso\sthat\nwe\sknow\sthat\s"PRAGMA\soptimize"\sdoes\snot\sneed\sto\sredo\sthe\swhole\stable. +D 2024-02-19T16:22:58.040 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -567,7 +567,7 @@ F ext/session/sessionnoop2.test de4672dce88464396ec9f30ed08c6c01643a69c53ae540fa F ext/session/sessionrebase.test 702378bdcb5062f1106e74457beca8797d09c113a81768734a58b197b5b334e2 F ext/session/sessionrowid.test 85187c2f1b38861a5844868126f69f9ec62223a03449a98a80600a44396f7363 F ext/session/sessionsize.test 8fcf4685993c3dbaa46a24183940ab9f5aa9ed0d23e5fb63bfffbdb56134b795 -F ext/session/sessionstat1.test b039e38e2ba83767b464baf39b297cc0b1cc6f3292255cb467ea7e12d0d0280c +F ext/session/sessionstat1.test 5e718d5888c0c49bbb33a7a4f816366db85f59f6a4f97544a806421b85dc2dec F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009ecef8511f4cf3fc F ext/session/sqlite3session.c 829d468f0f3d2710aace56b0116a7ca3f414683ce78e3125ae5e21547a895078 F ext/session/sqlite3session.h 4cf19a51975746d7cff2fdd74db8b769c570958e1c3639ac150d824ac1553b3e @@ -672,13 +672,13 @@ F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 F src/alter.c 30c2333b8bb3af71e4eb9adeadee8aa20edb15917ed44b8422e5cd15f3dfcddc -F src/analyze.c 0f15753308c3bca7674f31fa7e0807ffcb8b120c36eef7d00b62b33079ddc854 +F src/analyze.c dacc8f062bbda02c8ed3bbca0ab6122de010d094101d568df266a7b0d665d74f F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39 F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c dfd351decf9f819393dae8fb7294cae69c3818069d27f47fee34d5b505e37b47 +F src/btree.c 2f9dcf7c27879edb7897354029343bcab0c5a3dd2bde3bf3fd8f814b71344d22 F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 9197331dd283a6010bb4e2c129a9015f854203d27fa6fbe89e1aea742b78351c +F src/pragma.c 0bd3737acf69282fb1733e170a88a5caf3dba088092665e603ee5a6d651c0e2f F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640 @@ -809,7 +809,7 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 078f040366d5bd5f47658d045f901c768c1c636c6eaea121f3a1cbd63c3edb5b F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 6d2aecc9ab2f9db557b4841775d016e2697ff6312242e9a492cdf3e2529dffa6 +F src/vdbe.c 805af8bec9cae76a873b0ec4c91c3d1bd49b38e86c1c533ed87ec7a07a5042a5 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4abd47b5917099a2f74e53e12c987da0722304a5e9a93b6d43015c1f45c48444 -R 39db09ba2f5384fee677814cc2cbe4fe +P 44ed7f4cd07a88a2fdd303a2c78e6babe01d7344b399bd2b80ed68d75a77aaa2 +R 425f4513952a4b2a7a3cf3f40b480a46 U drh -Z cf23276671f3baaf4e4f3579488af586 +Z 08209902059a589603329b04ece67a70 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f1cc73e3f0..5ae06f96c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -44ed7f4cd07a88a2fdd303a2c78e6babe01d7344b399bd2b80ed68d75a77aaa2 \ No newline at end of file +e147b18991dd462fff367442acb0504fdf193a31843ed34ec8c1ced30747bf8a \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 59e3d98377..e7c1068ae0 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -872,7 +872,7 @@ static void statGet( if( iVal==2 && p->nRow*10 <= nDistinct*11 ) iVal = 1; sqlite3_str_appendf(&sStat, " %llu", iVal); #ifdef SQLITE_ENABLE_STAT4 - assert( p->current.anEq[i] ); + assert( p->current.anEq[i] || p->nRow==0 ); #endif } sqlite3ResultStrAccum(context, &sStat); @@ -1057,7 +1057,7 @@ static void analyzeOneTable( for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ int nCol; /* Number of columns in pIdx. "N" */ - int addrRewind; /* Address of "OP_Rewind iIdxCur" */ + int addrGotoEnd; /* Address of "OP_Rewind iIdxCur" */ int addrNextRow; /* Address of "next_row:" */ const char *zIdxName; /* Name of the index */ int nColTest; /* Number of columns to test for changes */ @@ -1081,9 +1081,14 @@ static void analyzeOneTable( /* ** Pseudo-code for loop that calls stat_push(): ** - ** Rewind csr - ** if eof(csr) goto end_of_scan; ** regChng = 0 + ** Rewind csr + ** if eof(csr){ + ** stat_init() with count = 0; + ** goto end_of_scan; + ** } + ** count() + ** stat_init() ** goto chng_addr_0; ** ** next_row: @@ -1122,41 +1127,36 @@ static void analyzeOneTable( sqlite3VdbeSetP4KeyInfo(pParse, pIdx); VdbeComment((v, "%s", pIdx->zName)); - /* Invoke the stat_init() function. The arguments are: - ** + /* Implementation of the following: + ** + ** regChng = 0 + ** Rewind csr + ** if eof(csr){ + ** stat_init() with count = 0; + ** goto end_of_scan; + ** } + ** count() + ** stat_init() + ** goto chng_addr_0; + */ + assert( regTemp2==regStat+4 ); + sqlite3VdbeAddOp2(v, OP_Integer, db->nAnalysisLimit, regTemp2); + + /* Arguments to stat_init(): ** (1) the number of columns in the index including the rowid ** (or for a WITHOUT ROWID table, the number of PK columns), ** (2) the number of columns in the key without the rowid/pk - ** (3) estimated number of rows in the index, - */ + ** (3) estimated number of rows in the index. */ sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat+1); assert( regRowid==regStat+2 ); sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regRowid); -#ifdef SQLITE_ENABLE_STAT4 - if( OptimizationEnabled(db, SQLITE_Stat4) ){ - sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regTemp); - addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur); - VdbeCoverage(v); - }else -#endif - { - addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur); - VdbeCoverage(v); - sqlite3VdbeAddOp3(v, OP_Count, iIdxCur, regTemp, 1); - } - assert( regTemp2==regStat+4 ); - sqlite3VdbeAddOp2(v, OP_Integer, db->nAnalysisLimit, regTemp2); + sqlite3VdbeAddOp3(v, OP_Count, iIdxCur, regTemp, + OptimizationDisabled(db, SQLITE_Stat4)); sqlite3VdbeAddFunctionCall(pParse, 0, regStat+1, regStat, 4, &statInitFuncdef, 0); + addrGotoEnd = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur); + VdbeCoverage(v); - /* Implementation of the following: - ** - ** Rewind csr - ** if eof(csr) goto end_of_scan; - ** regChng = 0 - ** goto next_push_0; - ** - */ sqlite3VdbeAddOp2(v, OP_Integer, 0, regChng); addrNextRow = sqlite3VdbeCurrentAddr(v); @@ -1263,6 +1263,12 @@ static void analyzeOneTable( } /* Add the entry to the stat1 table. */ + if( pIdx->pPartIdxWhere ){ + /* Partial indexes might get a zero-entry in sqlite_stat1. But + ** an empty table is omitted from sqlite_stat1. */ + sqlite3VdbeJumpHere(v, addrGotoEnd); + addrGotoEnd = 0; + } callStatGet(pParse, regStat, STAT_GET_STAT1, regStat1); assert( "BBB"[0]==SQLITE_AFF_TEXT ); sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, "BBB", 0); @@ -1286,6 +1292,12 @@ static void analyzeOneTable( int addrIsNull; u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound; + /* No STAT4 data is generated if the number of rows is zero */ + if( addrGotoEnd==0 ){ + sqlite3VdbeAddOp2(v, OP_Cast, regStat1, SQLITE_AFF_INTEGER); + addrGotoEnd = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); + } + if( doOnce ){ int mxCol = nCol; Index *pX; @@ -1338,7 +1350,7 @@ static void analyzeOneTable( #endif /* SQLITE_ENABLE_STAT4 */ /* End of analysis */ - sqlite3VdbeJumpHere(v, addrRewind); + if( addrGotoEnd ) sqlite3VdbeJumpHere(v, addrGotoEnd); } diff --git a/src/btree.c b/src/btree.c index 49c07c81a6..16b683abe7 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6182,10 +6182,10 @@ i64 sqlite3BtreeRowCountEst(BtCursor *pCur){ assert( cursorOwnsBtShared(pCur) ); assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); - /* Currently this interface is only called by the OP_IfSmaller - ** opcode, and it that case the cursor will always be valid and - ** will always point to a leaf node. */ - if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1; + /* Currently this interface is only called by the OP_IfSizeBetween + ** opcode and the OP_Count opcode with P3=1. In either case, + ** the cursor will always be valid unless the btree is empty. */ + if( pCur->eState!=CURSOR_VALID ) return 0; if( NEVER(pCur->pPage->leaf==0) ) return -1; n = pCur->pPage->nCell; diff --git a/src/pragma.c b/src/pragma.c index 53dc9ced30..77ec9a57e2 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2427,9 +2427,8 @@ void sqlite3Pragma( ** database will usually be less than 100 milliseconds on ** a RaspberryPI-4 class machine. On by default. ** - ** 0x00020 Run ANALYZE on any table that has a complete index - ** (an index without a WHERE clause) that lacks an entry - ** in the sqlite_stat1 table. On by default. + ** 0x00020 Run ANALYZE on any table that has a index that lacks an + ** entry in the sqlite_stat1 table. On by default. ** ** 0x10000 Look at tables to see if they need to be reanalyzed ** due to growth or shrinkage even if they have not been @@ -2454,14 +2453,14 @@ void sqlite3Pragma( ** ** (4) One or more of the following is true: ** (4a) The 0x10000 MASK bit is set. - ** (4b) One or more complete indexes on the table lacks an entry + ** (4b) One or more indexes on the table lacks an entry ** in the sqlite_stat1 table. ** (4c) The query planner used sqlite_stat1-style statistics for one ** or more indexes of the tableat some point during the lifetime ** of the current connection. ** ** (5) One or more of the following is true: - ** (5a) One or mroe complete indexes on the table lacks an entry + ** (5a) One or mroe indexes on the table lacks an entry ** in the sqlite_stat1 table. (Same as 4a) ** (5b) The number of rows in the table has increased or decreased by ** 10-fold. In other words, the current size of the table is @@ -2515,12 +2514,12 @@ void sqlite3Pragma( if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ) continue; /* Find the size of the table as last recorded in sqlite_stat1. - ** If any complete index (index without a WHERE clause) is unanalyzed, - ** then the threshold is -1 to indicate a new, unanalyzed index + ** If any index is unanalyzed, then the threshold is -1 to + ** indicate a new, unanalyzed index */ szThreshold = pTab->nRowLogEst; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ - if( !pIdx->hasStat1 && pIdx->pPartIdxWhere==0 ){ + if( !pIdx->hasStat1 ){ szThreshold = -1; /* Always analyze if any index lacks statistics */ break; } @@ -2534,7 +2533,7 @@ void sqlite3Pragma( }else if( opMask & 0x10000 ){ /* Check for size change if 0x10000 is set */ }else if( pTab->pIndex!=0 && szThreshold<0 ){ - /* Do analysis if unanalyzed complete indexes exists */ + /* Do analysis if unanalyzed indexes exists */ }else{ /* Otherwise, we can skip this table */ continue; @@ -2549,7 +2548,7 @@ void sqlite3Pragma( /* Reanalyze if the table is 10 times larger or smaller than ** the last analysis. Unconditional reanalysis if there are - ** unanalyzed complete indexes. */ + ** unanalyzed indexes. */ if( szThreshold>=0 ){ LogEst iRange = 33; /* 10x size change */ sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); diff --git a/src/vdbe.c b/src/vdbe.c index 3b52c13fa7..48a029dbf8 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2086,7 +2086,7 @@ case OP_RealAffinity: { /* in1 */ } #endif -#ifndef SQLITE_OMIT_CAST +#if !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_ANALYZE) /* Opcode: Cast P1 P2 * * * ** Synopsis: affinity(r[P1]) ** From cfc62ceefdfb19ed162b725cdca30fdea6a055e0 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 19 Feb 2024 18:03:53 +0000 Subject: [PATCH 0118/1030] Add implementation of sqlite3_intck_suspend(). FossilOrigin-Name: c36ada868da74e030ff5002de1f3b31b639b0c43714b91c2e5ca0eda16bb6bc2 --- ext/intck/intck1.test | 9 +- ext/intck/intck2.test | 6 +- ext/intck/intck_common.tcl | 6 +- ext/intck/sqlite3intck.c | 191 +++++++++++++++++++++++++------------ ext/intck/test_intck.c | 2 +- manifest | 23 ++--- manifest.uuid | 2 +- 7 files changed, 157 insertions(+), 82 deletions(-) diff --git a/ext/intck/intck1.test b/ext/intck/intck1.test index c46a7d6b2d..e5a25dda8e 100644 --- a/ext/intck/intck1.test +++ b/ext/intck/intck1.test @@ -167,8 +167,8 @@ do_test 3.2 { sqlite3 db test.db } {} -puts "[intck_sql db x1a]" -execsql_pp "EXPLAIN QUERY PLAN [intck_sql db x1a]" +#puts "[intck_sql db x1a]" +#execsql_pp "EXPLAIN QUERY PLAN [intck_sql db x1a]" do_intck_test 3.3 { {entry (4,'six',5) missing from index x1a} } @@ -185,6 +185,11 @@ do_execsql_test 4.0 { INSERT INTO www VALUES(1, 1, 1), (2, 2, 2); } +#puts [intck_sql db w1] +#execsql_pp [intck_sql db www] +#execsql_pp [intck_sql db w1] +#puts [intck_sql db w1] + do_intck_test 4.1 { } finish_test diff --git a/ext/intck/intck2.test b/ext/intck/intck2.test index bc9aebeea8..90f263f880 100644 --- a/ext/intck/intck2.test +++ b/ext/intck/intck2.test @@ -43,8 +43,8 @@ imposter_edit i1 { } do_intck_test 1.1 { - {entry ('two',2) missing from index i1} {surplus entry ('four',4) in index i1} + {entry ('two',2) missing from index i1} } #------------------------------------------------------------------------- @@ -61,9 +61,7 @@ do_execsql_test 2.0 { } do_intck_test 2.1 {} -puts [intck_sql db x1] - - +#puts [intck_sql db x1] finish_test diff --git a/ext/intck/intck_common.tcl b/ext/intck/intck_common.tcl index 0763d13266..757ca82b3f 100644 --- a/ext/intck/intck_common.tcl +++ b/ext/intck/intck_common.tcl @@ -15,7 +15,7 @@ if {![info exists testdir]} { } source $testdir/tester.tcl -proc do_intck {db} { +proc do_intck {db {bSuspend 0}} { set ic [sqlite3_intck $db main ""] set ret [list] @@ -24,6 +24,7 @@ proc do_intck {db} { if {$msg!=""} { lappend ret $msg } + if {$bSuspend} { $ic suspend } } set err [$ic error] @@ -43,7 +44,8 @@ proc intck_sql {db tbl} { } proc do_intck_test {tn expect} { - uplevel [list do_test $tn [list do_intck db] [list {*}$expect]] + uplevel [list do_test $tn.a [list do_intck db] [list {*}$expect]] + uplevel [list do_test $tn.b [list do_intck db 1] [list {*}$expect]] } diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index 7610d44a9b..b08b499a43 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -20,10 +20,10 @@ struct sqlite3_intck { sqlite3 *db; const char *zDb; /* Copy of zDb parameter to _open() */ - sqlite3_stmt *pListTables; + char *zObj; /* Current object. Or NULL. */ + char *zKey; /* Key saved by _suspect() call. */ sqlite3_stmt *pCheck; - int nCheck; int rc; /* SQLite error code */ char *zErr; /* Error message */ @@ -58,11 +58,15 @@ static sqlite3_stmt *intckPrepare(sqlite3_intck *p, const char *zFmt, ...){ p->rc = sqlite3_prepare_v2(p->db, zSql, -1, &pRet, 0); fflush(stdout); if( p->rc!=SQLITE_OK ){ +#if 1 printf("ERROR: %s\n", zSql); printf("MSG: %s\n", sqlite3_errmsg(p->db)); +#endif if( sqlite3_error_offset(p->db)>=0 ){ +#if 1 int iOff = sqlite3_error_offset(p->db); printf("AT: %.40s\n", &zSql[iOff]); +#endif } fflush(stdout); intckSaveErrmsg(p); @@ -82,27 +86,6 @@ static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){ } } -/* -** Return an SQL statement that will itself return a single row for each -** table in the target schema. The row contains two columns: -** -** 0: table_name - name of table -** 1: without_rowid - true for WITHOUT ROWID tables, false otherwise. -** -*/ -static sqlite3_stmt *intckListTables(sqlite3_intck *p){ - return intckPrepare(p, - "WITH tables(table_name) AS (" - " SELECT name" - " FROM %Q.sqlite_schema WHERE type='table' OR type='index'" - " UNION ALL " - " SELECT 'sqlite_schema'" - ")" - "SELECT * FROM tables" - , p->zDb - ); -} - static char *intckStrdup(sqlite3_intck *p, const char *zIn){ char *zOut = 0; if( p->rc==SQLITE_OK ){ @@ -117,6 +100,42 @@ static char *intckStrdup(sqlite3_intck *p, const char *zIn){ return zOut; } +static void intckFindObject(sqlite3_intck *p){ + sqlite3_stmt *pStmt = 0; + char *zPrev = p->zObj; + p->zObj = 0; + + assert( p->rc==SQLITE_OK ); + pStmt = intckPrepare(p, + "WITH tables(table_name) AS (" + " SELECT name" + " FROM %Q.sqlite_schema WHERE type='table' OR type='index'" + " UNION ALL " + " SELECT 'sqlite_schema'" + ")" + "SELECT table_name FROM tables " + "WHERE ?1 IS NULL OR table_name%s?1 " + "ORDER BY 1" + , p->zDb, (p->zKey ? ">=" : ">") + ); + + if( p->rc==SQLITE_OK ){ + sqlite3_bind_text(pStmt, 1, zPrev, -1, SQLITE_TRANSIENT); + if( sqlite3_step(pStmt)==SQLITE_ROW ){ + p->zObj = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0)); + } + } + intckFinalize(p, pStmt); + + /* If this is a new object, ensure the previous key value is cleared. */ + if( sqlite3_stricmp(p->zObj, zPrev) ){ + sqlite3_free(p->zKey); + p->zKey = 0; + } + + sqlite3_free(zPrev); +} + /* ** Return the size in bytes of the first token in nul-terminated buffer z. ** For the purposes of this call, a token is either: @@ -314,7 +333,11 @@ static void intckExec(sqlite3_intck *p, const char *zSql){ intckFinalize(p, pStmt); } -static char *intckCheckObjectSql(sqlite3_intck *p, const char *zObj){ +static char *intckCheckObjectSql( + sqlite3_intck *p, + const char *zObj, + const char *zPrev +){ char *zRet = 0; sqlite3_stmt *pStmt = 0; int bAutoIndex = 0; @@ -427,45 +450,61 @@ static char *intckCheckObjectSql(sqlite3_intck *p, const char *zObj){ /* Table idxname contains a single row. The first column, "db", contains ** the name of the db containing the table (e.g. "main") and the second, ** "tab", the name of the table itself. */ - "WITH tabname(db, tab, idx) AS (" - " SELECT %Q, (SELECT tbl_name FROM %Q.sqlite_schema WHERE name=%Q), %Q " + "WITH tabname(db, tab, idx, prev) AS (" + " SELECT %Q, (SELECT tbl_name FROM %Q.sqlite_schema WHERE name=%Q), " + " %Q, %Q " ")" "%s" /* zCommon */ "" ", case_statement(c) AS (" " SELECT " - " 'CASE WHEN (' || group_concat(col_alias, ', ') || ') IS (\n ' " + " 'CASE WHEN (' || group_concat(col_alias, ', ') || ') IS (\n ' " " || 'SELECT ' || group_concat(col_expr, ', ') || ' FROM '" - " || format('%%Q.%%Q NOT INDEXED WHERE %%s\n)', t.db, t.tab, p.eq_pk)" - " || '\nTHEN NULL\n'" + " || format('%%Q.%%Q NOT INDEXED WHERE %%s\n', t.db, t.tab, p.eq_pk)" + " || ' )\n THEN NULL\n '" " || 'ELSE format(''surplus entry ('" " || group_concat('%%s', ',') || ',' || p.ps_pk" " || ') in index ' || t.idx || ''', ' " " || group_concat('quote('||i.col_alias||')', ', ') || ', ' || p.pk_pk" " || ')'" - " || '\nEND'" + " || '\nEND AS error_message'" " FROM tabname t, tabpk p, idx_cols i WHERE i.idx_name=t.idx" + ")" "" + ", thiskey(k) AS (" + " SELECT format('format(''(%%s,%%s)'', %%s, %%s) AS thiskey', " + " group_concat('%%s', ','), p.ps_pk, " + " group_concat('quote('||i.col_alias||')',', '), p.pk_pk" + " ) FROM tabpk p, idx_cols i WHERE i.idx_name=p.idx" + ")" + "" + ", whereclause(w_c) AS (" + " SELECT CASE WHEN prev!='' THEN " + " '\nWHERE (' || group_concat(i.col_alias, ',') || ',' " + " || o_pk || ') > ' || prev" + " ELSE ''" + " END" + " FROM tabpk, tabname, idx_cols i WHERE i.idx_name=tabpk.idx" ")" "" ", main_select(m) AS (" " SELECT format(" - " 'WITH %%s\nSELECT %%s\nFROM intck_wrapper AS o'," - " ww.s, c" + " 'WITH %%s\nSELECT %%s,\n%%s\nFROM intck_wrapper AS o%%s'," + " ww.s, c, t.k, whereclause.w_c" " )" - " FROM case_statement, wrapper_with ww" + " FROM case_statement, wrapper_with ww, thiskey t, whereclause" ")" "SELECT m FROM main_select" , p->zDb, p->zDb, zObj, zObj - , zCommon + , zPrev, zCommon ); }else{ pStmt = intckPrepare(p, /* Table tabname contains a single row. The first column, "db", contains ** the name of the db containing the table (e.g. "main") and the second, ** "tab", the name of the table itself. */ - "WITH tabname(db, tab, idx) AS (SELECT %Q, %Q, NULL)" + "WITH tabname(db, tab, idx, prev) AS (SELECT %Q, %Q, NULL, %Q)" "" "%s" /* zCommon */ @@ -505,18 +544,41 @@ static char *intckCheckObjectSql(sqlite3_intck *p, const char *zObj){ " '\nEND AS error_message'" " FROM numbered" ")" + "" + /* This table contains a single row consisting of a single value - + ** the text of an SQL expression that may be used by the main SQL + ** statement to output an SQL literal that can be used to resume + ** the scan if it is suspended. e.g. for a rowid table, an expression + ** like: + ** + ** format('(%d,%d)', _rowid_, n.ii) + */ + ", thiskey(k) AS (" + " SELECT 'format(''(' || ps_pk || ',%%d)'', ' || pk_pk || ', n.ii)'" + " FROM tabpk" + ")" + "" + ", whereclause(w_c) AS (" + " SELECT CASE WHEN prev!='' THEN " + " '\nWHERE (' || o_pk ||', n.ii) > ' || prev" + " ELSE ''" + " END" + " FROM tabpk, tabname" + ")" + "" ", main_select(m) AS (" " SELECT format(" - " '%%s, %%s\nSELECT %%s\nFROM intck_wrapper AS o" - ", intck_counter AS n ORDER BY %%s', " - " w, ww.s, c, t.o_pk" + " '%%s, %%s\nSELECT %%s,\n%%s AS thiskey\nFROM intck_wrapper AS o" + ", intck_counter AS n%%s\nORDER BY %%s', " + " w, ww.s, c, thiskey.k, whereclause.w_c, t.o_pk" " )" - " FROM case_statement, tabpk t, counter_with, wrapper_with ww" + " FROM case_statement, tabpk t, counter_with, " + " wrapper_with ww, thiskey, whereclause" ")" "SELECT m FROM main_select", - p->zDb, zObj, zCommon + p->zDb, zObj, zPrev, zCommon ); } @@ -542,10 +604,11 @@ static char *intckCheckObjectSql(sqlite3_intck *p, const char *zObj){ } static void intckCheckObject(sqlite3_intck *p){ - const char *zTab = (const char*)sqlite3_column_text(p->pListTables, 0); - char *zSql = intckCheckObjectSql(p, zTab); + char *zSql = intckCheckObjectSql(p, p->zObj, p->zKey); p->pCheck = intckPrepare(p, "%s", zSql); sqlite3_free(zSql); + sqlite3_free(p->zKey); + p->zKey = 0; } int sqlite3_intck_open( @@ -582,6 +645,8 @@ void sqlite3_intck_close(sqlite3_intck *p){ p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0 ); } + sqlite3_free(p->zObj); + sqlite3_free(p->zKey); sqlite3_free(p->zTestSql); sqlite3_free(p->zErr); sqlite3_free(p); @@ -589,26 +654,19 @@ void sqlite3_intck_close(sqlite3_intck *p){ int sqlite3_intck_step(sqlite3_intck *p){ if( p->rc==SQLITE_OK ){ - if( p->pListTables==0 ){ - p->pListTables = intckListTables(p); - } - assert( p->pListTables || p->rc!=SQLITE_OK ); - - if( p->rc==SQLITE_OK && p->pCheck==0 ){ - if( sqlite3_step(p->pListTables)==SQLITE_ROW ){ - intckCheckObject(p); - }else{ - int rc = sqlite3_finalize(p->pListTables); - if( rc==SQLITE_OK ){ - p->rc = SQLITE_DONE; + if( p->pCheck==0 ){ + intckFindObject(p); + if( p->rc==SQLITE_OK ){ + if( p->zObj ){ + intckCheckObject(p); }else{ - intckSaveErrmsg(p); + p->rc = SQLITE_DONE; } - p->pListTables = 0; } } if( p->rc==SQLITE_OK ){ + assert( p->pCheck ); if( sqlite3_step(p->pCheck)==SQLITE_ROW ){ /* Fine, whatever... */ }else{ @@ -635,13 +693,28 @@ int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){ return (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc); } -int sqlite3_intck_suspend(sqlite3_intck *pCk){ - return SQLITE_OK; +int sqlite3_intck_suspend(sqlite3_intck *p){ + if( p->pCheck && p->rc==SQLITE_OK ){ + assert( p->zKey==0 ); + p->zKey = intckStrdup(p, (const char*)sqlite3_column_text(p->pCheck, 1)); + intckFinalize(p, p->pCheck); + p->pCheck = 0; + } + return p->rc; } const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){ sqlite3_free(p->zTestSql); - p->zTestSql = intckCheckObjectSql(p, zObj); + if( zObj ){ + p->zTestSql = intckCheckObjectSql(p, zObj, 0); + }else{ + if( p->zObj ){ + p->zTestSql = intckCheckObjectSql(p, p->zObj, p->zKey); + }else{ + sqlite3_free(p->zTestSql); + p->zTestSql = 0; + } + } return p->zTestSql; } diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c index 33129ec275..d14fc92a6c 100644 --- a/ext/intck/test_intck.c +++ b/ext/intck/test_intck.c @@ -113,7 +113,7 @@ static int testIntckCmd( case 5: assert( 0==strcmp("test_sql", aCmd[iIdx].zName) ); { const char *zObj = Tcl_GetString(objv[2]); - const char *zSql = sqlite3_intck_test_sql(p->intck, zObj); + const char *zSql = sqlite3_intck_test_sql(p->intck, zObj[0] ? zObj : 0); Tcl_SetObjResult(interp, Tcl_NewStringObj(zSql, -1)); break; } diff --git a/manifest b/manifest index a378ab14eb..bb8e46b123 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sstart\sof\sextension\sfor\sincremental\sintegrity-checks\sto\sext/intck/. -D 2024-02-17T20:55:01.343 +C Add\simplementation\sof\ssqlite3_intck_suspend(). +D 2024-02-19T18:03:53.963 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -248,12 +248,12 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/intck/intck1.test 0fcf3696b59aff6c344553647d612921dd529600796ff7172c02679955cecdcf -F ext/intck/intck2.test dd06719eca145b317ae380c81f04cd8a096a7cfdb71074cc6b6e7f195058b0d0 -F ext/intck/intck_common.tcl 1f2599d50033d21d5df89f5ed54cc29af472d86e3927e116db50c5ba94d903b9 -F ext/intck/sqlite3intck.c 14300998e91cd8788f483d97e53be9406f2c0be8af1867f399b80fef5e3721fb +F ext/intck/intck1.test c831bc6ff67da3c5b6c9568640f87ad0442d4fc98ef97bc837133b94bcc645b3 +F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 +F ext/intck/intck_common.tcl 2895854e7aaf5e199a15f6f82538a00999fd8fc55553bc1f04619af7aa86c0d0 +F ext/intck/sqlite3intck.c 703ff16bc936192cff20d06b015d66279f4594e88371c00b18d17fec4f01ff5c F ext/intck/sqlite3intck.h 342ee2e2c7636b4daf29fa195d0a3a658272b76b283d586fba50f6bc80fc143d -F ext/intck/test_intck.c 3f9a950978842340df7492f0a4190022979f23ff904e90873a5e262adf30b78c +F ext/intck/test_intck.c eb596269c4a690a9b8ee689b1e52ff6e3306013ec706e319d5b97af05a08f0b9 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -2168,11 +2168,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7fca1bc482fc2456d75392eb42f768fda72631c9070de46b8123b1126e78306f -R f8dccfe308ed2507020014beca90ae47 -T *branch * incr-integrity-check -T *sym-incr-integrity-check * -T -sym-trunk * +P 444e3c9210026da7eae1ed98850722e002433aa2cc77dbc6b6f80327a6b7a390 +R 6b69910b5d388b58f98078e173b37781 U dan -Z 8b8b6eda2ec7249d41ba58db982258fb +Z 3045521be4122627d743cbd6c4ab9b9c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7ea8d90d42..fa3faa50cd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -444e3c9210026da7eae1ed98850722e002433aa2cc77dbc6b6f80327a6b7a390 \ No newline at end of file +c36ada868da74e030ff5002de1f3b31b639b0c43714b91c2e5ca0eda16bb6bc2 \ No newline at end of file From 74b0aad09f0931c6645a1c43a0290ab1ee6ab4ff Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Feb 2024 19:56:40 +0000 Subject: [PATCH 0119/1030] In PRAGMA optimize, scale back the analysis_limit when many different tables and indexes must be scanned. FossilOrigin-Name: 636615358aebfef80a657d09f15f608df9e64882b2aaa5574ce31a4f1c71fd70 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 22 +++++++++++++++++++++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 690d3adac6..aef3dc3eee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\sfixes\sinto\sthe\sbetter-optimize\sbranch. -D 2024-02-19T18:55:32.241 +C In\sPRAGMA\soptimize,\sscale\sback\sthe\sanalysis_limit\swhen\smany\sdifferent\stables\nand\sindexes\smust\sbe\sscanned. +D 2024-02-19T19:56:40.420 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 0bd3737acf69282fb1733e170a88a5caf3dba088092665e603ee5a6d651c0e2f +F src/pragma.c c72ba9c8b300d713a318e7d199bc1d3f717f961c75de403f8db291841f2f58aa F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c d3392b2a20ee314ddeef34fb43c904bf4619eb20ff9a9e07e3950a7e4dcd6912 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e147b18991dd462fff367442acb0504fdf193a31843ed34ec8c1ced30747bf8a f18b2524da6bbbcf372b292df52fbe6efa49fd6e1f1f13ef2447279d559f7a08 -R fada2b9bf9b286f261a00cb9eda0fee2 +P 2cf78a5b5fce7f2d49ce185d27f50722c91a1d6c91bbcecebd4bb5244a76769f +R c2c83408fc346dde3baee32faaf6bad7 U drh -Z 513df274231a3535cbd843c1569f620b +Z ec6824937a1b6fb54f3b9fdcf77219f7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b04ec72a34..aa9236de91 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2cf78a5b5fce7f2d49ce185d27f50722c91a1d6c91bbcecebd4bb5244a76769f \ No newline at end of file +636615358aebfef80a657d09f15f608df9e64882b2aaa5574ce31a4f1c71fd70 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 77ec9a57e2..18fc88aceb 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2460,7 +2460,7 @@ void sqlite3Pragma( ** of the current connection. ** ** (5) One or more of the following is true: - ** (5a) One or mroe indexes on the table lacks an entry + ** (5a) One or more indexes on the table lacks an entry ** in the sqlite_stat1 table. (Same as 4a) ** (5b) The number of rows in the table has increased or decreased by ** 10-fold. In other words, the current size of the table is @@ -2484,6 +2484,8 @@ void sqlite3Pragma( u32 opMask; /* Mask of operations to perform */ int nLimit; /* Analysis limit to use */ int nCheck = 0; /* Number of tables to be optimized */ + int nBtree = 0; /* Number of btrees to scan */ + int nIndex; /* Number of indexes on the current table */ if( zRight ){ opMask = (u32)sqlite3Atoi(zRight); @@ -2518,7 +2520,9 @@ void sqlite3Pragma( ** indicate a new, unanalyzed index */ szThreshold = pTab->nRowLogEst; + nIndex = 0; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + nIndex++; if( !pIdx->hasStat1 ){ szThreshold = -1; /* Always analyze if any index lacks statistics */ break; @@ -2545,6 +2549,7 @@ void sqlite3Pragma( ** transaction for efficiency */ sqlite3BeginWriteOperation(pParse, 0, iDb); } + nBtree += nIndex+1; /* Reanalyze if the table is 10 times larger or smaller than ** the last analysis. Unconditional reanalysis if there are @@ -2572,6 +2577,21 @@ void sqlite3Pragma( } } sqlite3VdbeAddOp0(v, OP_Expire); + + /* In a schema with a large number of tables and indexes, scale back + ** the analysis_limit to avoid excess run-time in the worst case. + */ + if( !db->mallocFailed && nBtree>100 ){ + int iAddr, iEnd; + VdbeOp *aOp; + int nLimit = 100*SQLITE_DEFAULT_OPTIMIZE_LIMIT/nBtree; + if( nLimit<100 ) nLimit = 100; + aOp = sqlite3VdbeGetOp(v, 0); + iEnd = sqlite3VdbeCurrentAddr(v); + for(iAddr=0; iAddr Date: Mon, 19 Feb 2024 20:12:30 +0000 Subject: [PATCH 0120/1030] If there is no mention of a table in sqlite_stat1, use OP_Rewind to see if the table is empty prior to invoking ANALYZE. FossilOrigin-Name: 0cc93b19de597866292e0696f89fbd0e22a6cbb374678f5cc096fb889210fe3c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 15 +++++++++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index aef3dc3eee..0449436b9d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sPRAGMA\soptimize,\sscale\sback\sthe\sanalysis_limit\swhen\smany\sdifferent\stables\nand\sindexes\smust\sbe\sscanned. -D 2024-02-19T19:56:40.420 +C If\sthere\sis\sno\smention\sof\sa\stable\sin\ssqlite_stat1,\suse\sOP_Rewind\sto\ssee\sif\nthe\stable\sis\sempty\sprior\sto\sinvoking\sANALYZE. +D 2024-02-19T20:12:30.657 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c c72ba9c8b300d713a318e7d199bc1d3f717f961c75de403f8db291841f2f58aa +F src/pragma.c 280945eb4a7b78c82cd1b4d0bdefbb69af685a654f8fbfeb3bfd7dc8fede5fda F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c d3392b2a20ee314ddeef34fb43c904bf4619eb20ff9a9e07e3950a7e4dcd6912 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2cf78a5b5fce7f2d49ce185d27f50722c91a1d6c91bbcecebd4bb5244a76769f -R c2c83408fc346dde3baee32faaf6bad7 +P 636615358aebfef80a657d09f15f608df9e64882b2aaa5574ce31a4f1c71fd70 +R 98db8daafbcb183bee3a0d5c6d6f3dec U drh -Z ec6824937a1b6fb54f3b9fdcf77219f7 +Z 53d562a05375d893c6e8245ccbe9b40a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aa9236de91..b4d235c325 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -636615358aebfef80a657d09f15f608df9e64882b2aaa5574ce31a4f1c71fd70 \ No newline at end of file +0cc93b19de597866292e0696f89fbd0e22a6cbb374678f5cc096fb889210fe3c \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 18fc88aceb..e65233389e 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2486,6 +2486,7 @@ void sqlite3Pragma( int nCheck = 0; /* Number of tables to be optimized */ int nBtree = 0; /* Number of btrees to scan */ int nIndex; /* Number of indexes on the current table */ + int hasStat1; /* True if any STAT1 info available for the table */ if( zRight ){ opMask = (u32)sqlite3Atoi(zRight); @@ -2520,10 +2521,13 @@ void sqlite3Pragma( ** indicate a new, unanalyzed index */ szThreshold = pTab->nRowLogEst; + hasStat1 = (pTab->tabFlags & TF_HasStat1)!=0; nIndex = 0; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ nIndex++; - if( !pIdx->hasStat1 ){ + if( pIdx->hasStat1 ){ + hasStat1 = 1; + }else{ szThreshold = -1; /* Always analyze if any index lacks statistics */ break; } @@ -2555,14 +2559,17 @@ void sqlite3Pragma( ** the last analysis. Unconditional reanalysis if there are ** unanalyzed indexes. */ if( szThreshold>=0 ){ - LogEst iRange = 33; /* 10x size change */ + const LogEst iRange = 33; /* 10x size change */ sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); sqlite3VdbeAddOp4Int(v, OP_IfSizeBetween, iTabCur, - sqlite3VdbeCurrentAddr(v)+3+(opMask&1), + sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold>=iRange ? szThreshold-iRange : -1, szThreshold+iRange); - sqlite3VdbeAddOp1(v, OP_Close, iTabCur); VdbeCoverage(v); + }else if( !hasStat1 ){ + sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); + sqlite3VdbeAddOp2(v, OP_Rewind, iTabCur, + sqlite3VdbeCurrentAddr(v)+2+(opMask&1)); } zSubSql = sqlite3MPrintf(db, "ANALYZE \"%w\".\"%w\"", db->aDb[iDb].zDbSName, pTab->zName); From ebea8458e2a00e7564986d05a0ce91c8613fefd7 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 19 Feb 2024 20:15:44 +0000 Subject: [PATCH 0121/1030] Use more efficient SQL to verify that indexes contain entries that match their tables. FossilOrigin-Name: c01e008c28895e50b14531b2a1f3f1110aab3b54df41ebdbd416fbac7b1bba94 --- ext/intck/sqlite3intck.c | 56 ++++++++++++++++++++-------------------- ext/intck/sqlite3intck.h | 2 +- ext/intck/test_intck.c | 53 +++++++++++++++++++++++++++++++++++++ manifest | 16 ++++++------ manifest.uuid | 2 +- 5 files changed, 91 insertions(+), 38 deletions(-) diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index b08b499a43..05eaa81a93 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -19,15 +19,11 @@ struct sqlite3_intck { sqlite3 *db; const char *zDb; /* Copy of zDb parameter to _open() */ - char *zObj; /* Current object. Or NULL. */ - char *zKey; /* Key saved by _suspect() call. */ - - sqlite3_stmt *pCheck; - - int rc; /* SQLite error code */ + char *zKey; /* Key saved by _intck_suspend() call. */ + sqlite3_stmt *pCheck; /* Current check statement */ + int rc; /* Error code */ char *zErr; /* Error message */ - char *zTestSql; /* Returned by sqlite3_intck_test_sql() */ }; @@ -109,7 +105,7 @@ static void intckFindObject(sqlite3_intck *p){ pStmt = intckPrepare(p, "WITH tables(table_name) AS (" " SELECT name" - " FROM %Q.sqlite_schema WHERE type='table' OR type='index'" + " FROM %Q.sqlite_schema WHERE (type='table' OR type='index') AND rootpage" " UNION ALL " " SELECT 'sqlite_schema'" ")" @@ -400,9 +396,9 @@ static char *intckCheckObjectSql( "" ", idx(name, match_expr, partial, partial_alias, idx_ps, idx_idx) AS (" " SELECT idx_name," - " format('(%s) IS (%s)', " - " group_concat(i.col_expr, ', ')," - " group_concat('o.'||i.col_alias, ', ')" + " format('(%s,%s) IS (%s,%s)', " + " group_concat(i.col_expr, ', '), i_pk," + " group_concat('o.'||i.col_alias, ', '), o_pk" " ), " " parse_create_index(" " (SELECT sql FROM sqlite_schema WHERE name=idx_name), -1" @@ -512,13 +508,12 @@ static char *intckCheckObjectSql( ** is set to an expression that evaluates to NULL if the required ** entry is present in the index, or an error message otherwise. */ ", expr(e, p) AS (" - " SELECT format('CASE WHEN (%%s) IN\n" - " (SELECT %%s FROM %%Q.%%Q AS i INDEXED BY %%Q WHERE %%s%%s)\n" + " SELECT format('CASE WHEN EXISTS \n" + " (SELECT 1 FROM %%Q.%%Q AS i INDEXED BY %%Q WHERE %%s%%s)\n" " THEN NULL\n" " ELSE format(''entry (%%s,%%s) missing from index %%s'', %%s, %%s)\n" " END\n'" - " , t.o_pk, t.i_pk, t.db, t.tab, i.name, i.match_expr, " - " ' AND (' || partial || ')'," + " , t.db, t.tab, i.name, i.match_expr, ' AND (' || partial || ')'," " i.idx_ps, t.ps_pk, i.name, i.idx_idx, t.pk_pk)," " CASE WHEN partial IS NULL THEN NULL ELSE i.partial_alias END" " FROM tabpk t, idx i" @@ -626,30 +621,35 @@ int sqlite3_intck_open( if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ + sqlite3_create_function(db, "parse_create_index", + 2, SQLITE_UTF8, 0, parseCreateIndexFunc, 0, 0 + ); memset(pNew, 0, sizeof(*pNew)); pNew->db = db; pNew->zDb = (const char*)&pNew[1]; memcpy(&pNew[1], zDb, nDb+1); - sqlite3_create_function(db, "parse_create_index", - 2, SQLITE_UTF8, 0, parseCreateIndexFunc, 0, 0 - ); } *ppOut = pNew; return rc; } -void sqlite3_intck_close(sqlite3_intck *p){ - if( p && p->db ){ - sqlite3_create_function( - p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0 - ); +int sqlite3_intck_close(sqlite3_intck *p){ + int rc = SQLITE_OK; + if( p ){ + rc = (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc); + if( p->db ){ + sqlite3_create_function( + p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0 + ); + } + sqlite3_free(p->zObj); + sqlite3_free(p->zKey); + sqlite3_free(p->zTestSql); + sqlite3_free(p->zErr); + sqlite3_free(p); } - sqlite3_free(p->zObj); - sqlite3_free(p->zKey); - sqlite3_free(p->zTestSql); - sqlite3_free(p->zErr); - sqlite3_free(p); + return rc; } int sqlite3_intck_step(sqlite3_intck *p){ diff --git a/ext/intck/sqlite3intck.h b/ext/intck/sqlite3intck.h index 8846812e75..c7c24e42c9 100644 --- a/ext/intck/sqlite3intck.h +++ b/ext/intck/sqlite3intck.h @@ -29,7 +29,7 @@ int sqlite3_intck_open( sqlite3_intck **ppOut ); -void sqlite3_intck_close(sqlite3_intck*); +int sqlite3_intck_close(sqlite3_intck*); int sqlite3_intck_step(sqlite3_intck *pCk); diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c index d14fc92a6c..75bcfa298a 100644 --- a/ext/intck/test_intck.c +++ b/ext/intck/test_intck.c @@ -179,7 +179,60 @@ static int test_sqlite3_intck( return TCL_OK; } +/* +** tclcmd: test_do_intck DB DBNAME +*/ +static int test_do_intck( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3 *db = 0; + const char *zDb = 0; + int rc = SQLITE_OK; + sqlite3_intck *pCk = 0; + Tcl_Obj *pRet = 0; + const char *zErr = 0; + + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ + return TCL_ERROR; + } + zDb = Tcl_GetString(objv[2]); + + pRet = Tcl_NewObj(); + Tcl_IncrRefCount(pRet); + + rc = sqlite3_intck_open(db, zDb, 0, &pCk); + if( rc==SQLITE_OK ){ + while( sqlite3_intck_step(pCk)==SQLITE_OK ){ + const char *zMsg = sqlite3_intck_message(pCk); + if( zMsg ){ + Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(zMsg, -1)); + } + } + rc = sqlite3_intck_error(pCk, &zErr); + } + if( rc!=SQLITE_OK ){ + if( zErr ){ + Tcl_SetObjResult(interp, Tcl_NewStringObj(zErr, -1)); + }else{ + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); + } + }else{ + Tcl_SetObjResult(interp, pRet); + } + Tcl_DecrRefCount(pRet); + sqlite3_intck_close(pCk); + return rc ? TCL_ERROR : TCL_OK; +} + int Sqlitetestintck_Init(Tcl_Interp *interp){ Tcl_CreateObjCommand(interp, "sqlite3_intck", test_sqlite3_intck, 0, 0); + Tcl_CreateObjCommand(interp, "test_do_intck", test_do_intck, 0, 0); return TCL_OK; } diff --git a/manifest b/manifest index bb8e46b123..cf37766470 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\simplementation\sof\ssqlite3_intck_suspend(). -D 2024-02-19T18:03:53.963 +C Use\smore\sefficient\sSQL\sto\sverify\sthat\sindexes\scontain\sentries\sthat\smatch\stheir\stables. +D 2024-02-19T20:15:44.802 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -251,9 +251,9 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/intck/intck1.test c831bc6ff67da3c5b6c9568640f87ad0442d4fc98ef97bc837133b94bcc645b3 F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 F ext/intck/intck_common.tcl 2895854e7aaf5e199a15f6f82538a00999fd8fc55553bc1f04619af7aa86c0d0 -F ext/intck/sqlite3intck.c 703ff16bc936192cff20d06b015d66279f4594e88371c00b18d17fec4f01ff5c -F ext/intck/sqlite3intck.h 342ee2e2c7636b4daf29fa195d0a3a658272b76b283d586fba50f6bc80fc143d -F ext/intck/test_intck.c eb596269c4a690a9b8ee689b1e52ff6e3306013ec706e319d5b97af05a08f0b9 +F ext/intck/sqlite3intck.c 5f319b7c72b0c01cfa28bb5fdd19be5781eb11f5a5216af2a0870dc7e001414d +F ext/intck/sqlite3intck.h d9501ea480b7c41c0555f39f4f1b7c3e8d54fc1ea6d115de5e1211e0bc11d3e7 +F ext/intck/test_intck.c 06206b35f1428961015c060dd35201246c849625cfdff461e0eeaaf76bda545c F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -2168,8 +2168,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 444e3c9210026da7eae1ed98850722e002433aa2cc77dbc6b6f80327a6b7a390 -R 6b69910b5d388b58f98078e173b37781 +P c36ada868da74e030ff5002de1f3b31b639b0c43714b91c2e5ca0eda16bb6bc2 +R 830041ceb0564db12655be53580aeb6a U dan -Z 3045521be4122627d743cbd6c4ab9b9c +Z f8e44044aacffa331f677c80763fe8b6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fa3faa50cd..eb805d0954 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c36ada868da74e030ff5002de1f3b31b639b0c43714b91c2e5ca0eda16bb6bc2 \ No newline at end of file +c01e008c28895e50b14531b2a1f3f1110aab3b54df41ebdbd416fbac7b1bba94 \ No newline at end of file From a1507a3fa02b8789665e326c8c014f1e58fcd80d Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Feb 2024 20:47:59 +0000 Subject: [PATCH 0122/1030] Fix a minor hiccup in the computation of the number of btrees to be scanned. FossilOrigin-Name: 91302d9b2720d6b5184e1c24db55d351544adfde4b3d2ddcdc1561f79f11985a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 0449436b9d..0ef40d6de1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sthere\sis\sno\smention\sof\sa\stable\sin\ssqlite_stat1,\suse\sOP_Rewind\sto\ssee\sif\nthe\stable\sis\sempty\sprior\sto\sinvoking\sANALYZE. -D 2024-02-19T20:12:30.657 +C Fix\sa\sminor\shiccup\sin\sthe\scomputation\sof\sthe\snumber\sof\sbtrees\sto\sbe\sscanned. +D 2024-02-19T20:47:59.472 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 280945eb4a7b78c82cd1b4d0bdefbb69af685a654f8fbfeb3bfd7dc8fede5fda +F src/pragma.c d0e7832bd99ea1c2695466894401f59fd4589ad98f93285a1d600877d0420070 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c d3392b2a20ee314ddeef34fb43c904bf4619eb20ff9a9e07e3950a7e4dcd6912 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 636615358aebfef80a657d09f15f608df9e64882b2aaa5574ce31a4f1c71fd70 -R 98db8daafbcb183bee3a0d5c6d6f3dec +P 0cc93b19de597866292e0696f89fbd0e22a6cbb374678f5cc096fb889210fe3c +R d2d796f1af82f58905d69562436e5dd5 U drh -Z 53d562a05375d893c6e8245ccbe9b40a +Z d7a267289f8d852622ceaa2fe9f0686a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b4d235c325..71cf5e34f0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0cc93b19de597866292e0696f89fbd0e22a6cbb374678f5cc096fb889210fe3c \ No newline at end of file +91302d9b2720d6b5184e1c24db55d351544adfde4b3d2ddcdc1561f79f11985a \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index e65233389e..571d993714 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2529,7 +2529,6 @@ void sqlite3Pragma( hasStat1 = 1; }else{ szThreshold = -1; /* Always analyze if any index lacks statistics */ - break; } } From ae71fa5d59fa9da292770ec3d14b1f330c079e79 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Feb 2024 23:58:26 +0000 Subject: [PATCH 0123/1030] Minor fixes. FossilOrigin-Name: ed5afebc410e3d430e2428d35f027bffb218e5f11036a42f97b080153e89016e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 0ef40d6de1..007c09ab9b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sminor\shiccup\sin\sthe\scomputation\sof\sthe\snumber\sof\sbtrees\sto\sbe\sscanned. -D 2024-02-19T20:47:59.472 +C Minor\sfixes. +D 2024-02-19T23:58:26.332 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c d0e7832bd99ea1c2695466894401f59fd4589ad98f93285a1d600877d0420070 +F src/pragma.c 613d27816d26e9db585fd4a34a627cfb436dc5b63edd73546b0fdaacdfa33772 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c d3392b2a20ee314ddeef34fb43c904bf4619eb20ff9a9e07e3950a7e4dcd6912 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0cc93b19de597866292e0696f89fbd0e22a6cbb374678f5cc096fb889210fe3c -R d2d796f1af82f58905d69562436e5dd5 +P 91302d9b2720d6b5184e1c24db55d351544adfde4b3d2ddcdc1561f79f11985a +R f5703f8a3a60803127fbc9cadd6a43fe U drh -Z d7a267289f8d852622ceaa2fe9f0686a +Z 926161dae17b79fd58ce2e39147c492e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 71cf5e34f0..51dda07214 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -91302d9b2720d6b5184e1c24db55d351544adfde4b3d2ddcdc1561f79f11985a \ No newline at end of file +ed5afebc410e3d430e2428d35f027bffb218e5f11036a42f97b080153e89016e \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 571d993714..ca34e80af0 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2569,6 +2569,7 @@ void sqlite3Pragma( sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); sqlite3VdbeAddOp2(v, OP_Rewind, iTabCur, sqlite3VdbeCurrentAddr(v)+2+(opMask&1)); + VdbeCoverage(v); } zSubSql = sqlite3MPrintf(db, "ANALYZE \"%w\".\"%w\"", db->aDb[iDb].zDbSName, pTab->zName); @@ -2587,10 +2588,10 @@ void sqlite3Pragma( /* In a schema with a large number of tables and indexes, scale back ** the analysis_limit to avoid excess run-time in the worst case. */ - if( !db->mallocFailed && nBtree>100 ){ + if( !db->mallocFailed && nLimit>0 && nBtree>100 ){ int iAddr, iEnd; VdbeOp *aOp; - int nLimit = 100*SQLITE_DEFAULT_OPTIMIZE_LIMIT/nBtree; + nLimit = 100*nLimit/nBtree; if( nLimit<100 ) nLimit = 100; aOp = sqlite3VdbeGetOp(v, 0); iEnd = sqlite3VdbeCurrentAddr(v); From 4189c44cff384341fb2a7780a7b5b35c734db9af Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Feb 2024 12:14:07 +0000 Subject: [PATCH 0124/1030] Another simplification of the PRAGMA optimize logic for improved coverage. FossilOrigin-Name: 6c5a0c85454e3c658e51fab611c169c034447174022eebc52fd8619b528a4765 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 007c09ab9b..e83a2aea80 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sfixes. -D 2024-02-19T23:58:26.332 +C Another\ssimplification\sof\sthe\sPRAGMA\soptimize\slogic\sfor\simproved\scoverage. +D 2024-02-20T12:14:07.075 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 613d27816d26e9db585fd4a34a627cfb436dc5b63edd73546b0fdaacdfa33772 +F src/pragma.c cc9ccfde12caf4db782332dc7edd6c0aaf0bfa9bb8c0bff86a3f138521f11b27 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c d3392b2a20ee314ddeef34fb43c904bf4619eb20ff9a9e07e3950a7e4dcd6912 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 91302d9b2720d6b5184e1c24db55d351544adfde4b3d2ddcdc1561f79f11985a -R f5703f8a3a60803127fbc9cadd6a43fe +P ed5afebc410e3d430e2428d35f027bffb218e5f11036a42f97b080153e89016e +R 1d7e6aefb784a3b060fc17ebc00f9588 U drh -Z 926161dae17b79fd58ce2e39147c492e +Z 39fd458c30bb322f77d1633b20055bca # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 51dda07214..a30b6b2081 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ed5afebc410e3d430e2428d35f027bffb218e5f11036a42f97b080153e89016e \ No newline at end of file +6c5a0c85454e3c658e51fab611c169c034447174022eebc52fd8619b528a4765 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index ca34e80af0..877fb3f721 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2557,16 +2557,15 @@ void sqlite3Pragma( /* Reanalyze if the table is 10 times larger or smaller than ** the last analysis. Unconditional reanalysis if there are ** unanalyzed indexes. */ + sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); if( szThreshold>=0 ){ const LogEst iRange = 33; /* 10x size change */ - sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); sqlite3VdbeAddOp4Int(v, OP_IfSizeBetween, iTabCur, sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold>=iRange ? szThreshold-iRange : -1, szThreshold+iRange); VdbeCoverage(v); - }else if( !hasStat1 ){ - sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); + }else{ sqlite3VdbeAddOp2(v, OP_Rewind, iTabCur, sqlite3VdbeCurrentAddr(v)+2+(opMask&1)); VdbeCoverage(v); From 4b2eeb289bef1735ab56aa4867f2c3b69550b9c2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Feb 2024 13:10:46 +0000 Subject: [PATCH 0125/1030] Remove an unused variable from the merge in the previous check-in. FossilOrigin-Name: 5c26bf379e18e28d800525bd03e2d5597e2f37674979302f351b99abfc064749 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/pragma.c | 6 +----- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index c071235824..abca404cf5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\sPRAGMA\soptimize\sand\sANALYZE.\s\sAdd\sthe\s0x10000\sflag\sto\nPRAGMA\soptimize.\s\sANALYZE\snow\srecords\szero-size\spartial\sindexes\sin\sthe\nsqlite_stat1\stable.\s\sPRAGMA\soptimize\slooks\sfor\sboth\sgrowth\sand\sshrinkage\nin\stable\ssizes,\sand\suses\stighter\sbounds\s(10x\srather\sthan\s25x)\sto\strigger\na\sre-analyze.\s\sPRAGMA\soptimize\sautomatically\suses\sare\sreasonable\nanalysis_limit\sto\sprevent\sexcessive\sruntimes. -D 2024-02-20T12:48:00.737 +C Remove\san\sunused\svariable\sfrom\sthe\smerge\sin\sthe\sprevious\scheck-in. +D 2024-02-20T13:10:46.615 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c cc9ccfde12caf4db782332dc7edd6c0aaf0bfa9bb8c0bff86a3f138521f11b27 +F src/pragma.c f35ba8fb0b3782ef671cc38b3cdaa457e82befe022558f343240344e57d5f5f4 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c d3392b2a20ee314ddeef34fb43c904bf4619eb20ff9a9e07e3950a7e4dcd6912 @@ -2162,9 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f18b2524da6bbbcf372b292df52fbe6efa49fd6e1f1f13ef2447279d559f7a08 6c5a0c85454e3c658e51fab611c169c034447174022eebc52fd8619b528a4765 -R 1d7e6aefb784a3b060fc17ebc00f9588 -T +closed 6c5a0c85454e3c658e51fab611c169c034447174022eebc52fd8619b528a4765 +P 63ef234e88857a653fa3541e80d59802ceccb806ac8296e8bae79a385b7086f7 +R a21cfe7fc11d4cc3af701137f92d89ba U drh -Z b62a3cf41afb08b6428ca7c918282668 +Z d6568f521192ee23916aac9c92a235a6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 54028cc0d8..262b24e277 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -63ef234e88857a653fa3541e80d59802ceccb806ac8296e8bae79a385b7086f7 \ No newline at end of file +5c26bf379e18e28d800525bd03e2d5597e2f37674979302f351b99abfc064749 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 877fb3f721..af51d18657 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2486,7 +2486,6 @@ void sqlite3Pragma( int nCheck = 0; /* Number of tables to be optimized */ int nBtree = 0; /* Number of btrees to scan */ int nIndex; /* Number of indexes on the current table */ - int hasStat1; /* True if any STAT1 info available for the table */ if( zRight ){ opMask = (u32)sqlite3Atoi(zRight); @@ -2521,13 +2520,10 @@ void sqlite3Pragma( ** indicate a new, unanalyzed index */ szThreshold = pTab->nRowLogEst; - hasStat1 = (pTab->tabFlags & TF_HasStat1)!=0; nIndex = 0; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ nIndex++; - if( pIdx->hasStat1 ){ - hasStat1 = 1; - }else{ + if( !pIdx->hasStat1 ){ szThreshold = -1; /* Always analyze if any index lacks statistics */ } } From b468e6832288292695ff5dc6782dd1e5334ee8f6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Feb 2024 13:11:27 +0000 Subject: [PATCH 0126/1030] Remove an unreachable branch from printf(). Change it into an assert(). FossilOrigin-Name: 4c9886b692706723f4b68f58dfef07ab19b192fd19b953917f23b55655af3e02 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/printf.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index abca404cf5..40152b32a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunused\svariable\sfrom\sthe\smerge\sin\sthe\sprevious\scheck-in. -D 2024-02-20T13:10:46.615 +C Remove\san\sunreachable\sbranch\sfrom\sprintf().\s\sChange\sit\sinto\san\sassert(). +D 2024-02-20T13:11:27.626 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -735,7 +735,7 @@ F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 F src/pragma.c f35ba8fb0b3782ef671cc38b3cdaa457e82befe022558f343240344e57d5f5f4 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c -F src/printf.c d3392b2a20ee314ddeef34fb43c904bf4619eb20ff9a9e07e3950a7e4dcd6912 +F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 63ef234e88857a653fa3541e80d59802ceccb806ac8296e8bae79a385b7086f7 -R a21cfe7fc11d4cc3af701137f92d89ba +P 5c26bf379e18e28d800525bd03e2d5597e2f37674979302f351b99abfc064749 +R 521cc3374b233ca8db7b57619e6235d0 U drh -Z d6568f521192ee23916aac9c92a235a6 +Z f1be525f7ee6098da75f01bd7c5e0ac8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 262b24e277..a714b19d22 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c26bf379e18e28d800525bd03e2d5597e2f37674979302f351b99abfc064749 \ No newline at end of file +4c9886b692706723f4b68f58dfef07ab19b192fd19b953917f23b55655af3e02 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 2e09431bf2..186e95bb85 100644 --- a/src/printf.c +++ b/src/printf.c @@ -534,13 +534,14 @@ void sqlite3_str_vappendf( } exp = s.iDP-1; - if( xtype==etGENERIC && precision>0 ) precision--; /* ** If the field type is etGENERIC, then convert to either etEXP ** or etFLOAT, as appropriate. */ if( xtype==etGENERIC ){ + assert( precision>0 ); + precision--; flag_rtz = !flag_alternateform; if( exp<-4 || exp>precision ){ xtype = etEXP; From 21eda699d7154c045c72e8c848ebe2ade011165f Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Feb 2024 15:38:36 +0000 Subject: [PATCH 0127/1030] Fixes to comments associated with the recent PRAGMA optimize enhancements. No changes to code. FossilOrigin-Name: 27a2113d78b35e324e9aedda7403c96c56ad0bed8c6b139fc5a179e8800b9109 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 5 +---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 40152b32a7..8ad3679fb6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunreachable\sbranch\sfrom\sprintf().\s\sChange\sit\sinto\san\sassert(). -D 2024-02-20T13:11:27.626 +C Fixes\sto\scomments\sassociated\swith\sthe\srecent\sPRAGMA\soptimize\senhancements.\nNo\schanges\sto\scode. +D 2024-02-20T15:38:36.661 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c f35ba8fb0b3782ef671cc38b3cdaa457e82befe022558f343240344e57d5f5f4 +F src/pragma.c f5cb82c15b7455d42e748cad8a6c367db18ada0fadc9b4adba03de953a81d46a F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5c26bf379e18e28d800525bd03e2d5597e2f37674979302f351b99abfc064749 -R 521cc3374b233ca8db7b57619e6235d0 +P 4c9886b692706723f4b68f58dfef07ab19b192fd19b953917f23b55655af3e02 +R 40f50207938b86842b8686e871138379 U drh -Z f1be525f7ee6098da75f01bd7c5e0ac8 +Z 751534f3f8e8461179e5c9344b944b7a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a714b19d22..a82c127f34 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4c9886b692706723f4b68f58dfef07ab19b192fd19b953917f23b55655af3e02 \ No newline at end of file +27a2113d78b35e324e9aedda7403c96c56ad0bed8c6b139fc5a179e8800b9109 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index af51d18657..62fd17911a 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2427,9 +2427,6 @@ void sqlite3Pragma( ** database will usually be less than 100 milliseconds on ** a RaspberryPI-4 class machine. On by default. ** - ** 0x00020 Run ANALYZE on any table that has a index that lacks an - ** entry in the sqlite_stat1 table. On by default. - ** ** 0x10000 Look at tables to see if they need to be reanalyzed ** due to growth or shrinkage even if they have not been ** queried during the current connection. Off by default. @@ -2456,7 +2453,7 @@ void sqlite3Pragma( ** (4b) One or more indexes on the table lacks an entry ** in the sqlite_stat1 table. ** (4c) The query planner used sqlite_stat1-style statistics for one - ** or more indexes of the tableat some point during the lifetime + ** or more indexes of the table at some point during the lifetime ** of the current connection. ** ** (5) One or more of the following is true: From 626d6192185c33a047966144392d5d3b6b3597ed Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 20 Feb 2024 16:04:27 +0000 Subject: [PATCH 0128/1030] Consider using "=" and IS operators with even low-quality indexes in cases where they are selected explicitly using an INDEXED BY clause. FossilOrigin-Name: 43cbbea82132db2d0ddb4f34cc2b6910b3a1243ae6d4e837b1b27bfe91b84834 --- ext/intck/intck1.test | 14 ++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 4 +++- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ext/intck/intck1.test b/ext/intck/intck1.test index e5a25dda8e..7f60f1fdc6 100644 --- a/ext/intck/intck1.test +++ b/ext/intck/intck1.test @@ -88,6 +88,20 @@ do_catchsql_test 1.5.4 { } {1 {unsupported use of NULLS FIRST}} +reset_db +do_execsql_test 1.6.1 { + CREATE TABLE t1(i INTEGER PRIMARY KEY, b, c); + CREATE INDEX i1 ON t1(b); + ANALYZE; + INSERT INTO sqlite_stat1 VALUES('t1', 'i1', '10000 10000'); + ANALYZE sqlite_schema; +} {} +do_eqp_test 1.6.2 { + SELECT 1 FROM t1 INDEXED BY i1 WHERE (b, i) IS (?, ?); +} {SEARCH} + + + #------------------------------------------------------------------------- reset_db diff --git a/manifest b/manifest index cf37766470..e254a597a2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\smore\sefficient\sSQL\sto\sverify\sthat\sindexes\scontain\sentries\sthat\smatch\stheir\stables. -D 2024-02-19T20:15:44.802 +C Consider\susing\s"="\sand\sIS\soperators\swith\seven\slow-quality\sindexes\sin\scases\swhere\sthey\sare\sselected\sexplicitly\susing\san\sINDEXED\sBY\sclause. +D 2024-02-20T16:04:27.694 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -248,7 +248,7 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/intck/intck1.test c831bc6ff67da3c5b6c9568640f87ad0442d4fc98ef97bc837133b94bcc645b3 +F ext/intck/intck1.test 5b3c9800e119b4dd50a381974f34cee6cfd5b7434286fb8da83b7c8ff1d6bb3c F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 F ext/intck/intck_common.tcl 2895854e7aaf5e199a15f6f82538a00999fd8fc55553bc1f04619af7aa86c0d0 F ext/intck/sqlite3intck.c 5f319b7c72b0c01cfa28bb5fdd19be5781eb11f5a5216af2a0870dc7e001414d @@ -830,7 +830,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 0e7bf004a578eb70d54300503fdbcaaea857de6ba0204aae1adf572edb79c2c6 +F src/where.c 33eaaeef3aef10c2b9e82096e70a174d6636e35cb0b180321b8ddf804590e5cd F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c dc5096eca5ed503999be3bdee8a90c51361289a678d396a220912e9cb73b3c00 @@ -2168,8 +2168,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c36ada868da74e030ff5002de1f3b31b639b0c43714b91c2e5ca0eda16bb6bc2 -R 830041ceb0564db12655be53580aeb6a +P c01e008c28895e50b14531b2a1f3f1110aab3b54df41ebdbd416fbac7b1bba94 +R 8db173421c176ccb487011bd9440e123 U dan -Z f8e44044aacffa331f677c80763fe8b6 +Z d4e70ffeb295fbc1a103b9adca306ecc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index eb805d0954..4565b3d528 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c01e008c28895e50b14531b2a1f3f1110aab3b54df41ebdbd416fbac7b1bba94 \ No newline at end of file +43cbbea82132db2d0ddb4f34cc2b6910b3a1243ae6d4e837b1b27bfe91b84834 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 0e526b3372..9850d22cc3 100644 --- a/src/where.c +++ b/src/where.c @@ -2975,7 +2975,9 @@ static int whereLoopAddBtreeIndex( } if( pProbe->bUnordered || pProbe->bLowQual ){ if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); - if( pProbe->bLowQual ) opMask &= ~(WO_EQ|WO_IN|WO_IS); + if( pProbe->bLowQual && pSrc->fg.isIndexedBy==0 ){ + opMask &= ~(WO_EQ|WO_IN|WO_IS); + } } assert( pNew->u.btree.nEqnColumn ); From cfcb3b9208236e6d40633bf574de2b7559ad4c9f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 20 Feb 2024 18:17:06 +0000 Subject: [PATCH 0129/1030] Use fewer cycles to generate the "next key" value used by sqlite3_intck_suspend() function in the intck extension. FossilOrigin-Name: 95f01426f948cf435d0b400dc7ae06fa699eee32cff498fe77e74a1257a4e09b --- ext/intck/sqlite3intck.c | 218 ++++++++++++++++++++++++++++++++------- manifest | 12 +-- manifest.uuid | 2 +- 3 files changed, 189 insertions(+), 43 deletions(-) diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index 05eaa81a93..6d54526928 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -16,12 +16,25 @@ #include #include +/* +** apKeyVal: +** If sqlite3_intck_suspend() is called when there is a running pCheck +** statement, this array is allocated and populated with the key values +** required to restart the check. If the intck object has not been +** suspended, this is set to NULL. +** +** nKeyVal: +** The size of the apKeyVal[] array, if it is allocated. +*/ struct sqlite3_intck { sqlite3 *db; const char *zDb; /* Copy of zDb parameter to _open() */ char *zObj; /* Current object. Or NULL. */ - char *zKey; /* Key saved by _intck_suspend() call. */ + sqlite3_stmt *pCheck; /* Current check statement */ + int nKeyVal; + sqlite3_value **apKeyVal; + int rc; /* Error code */ char *zErr; /* Error message */ char *zTestSql; /* Returned by sqlite3_intck_test_sql() */ @@ -82,18 +95,117 @@ static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){ } } +/* +** Wrapper around sqlite3_malloc64() that uses the sqlite3_intck error +** code convention. +*/ +static void *intckMalloc(sqlite3_intck *p, sqlite3_int64 nByte){ + void *pRet = 0; + assert( nByte>0 ); + if( p->rc==SQLITE_OK ){ + pRet = sqlite3_malloc64(nByte); + if( pRet==0 ){ + p->rc = SQLITE_NOMEM; + } + } + return pRet; +} + +/* +** If p->rc is other than SQLITE_OK when this function is called, it +** immediately returns NULL. Otherwise, it attempts to create a copy of +** nul-terminated string zIn in a buffer obtained from sqlite3_malloc(). +** If successful, a pointer to this buffer is returned and it becomes +** the responsibility of the caller to release it using sqlite3_free() +** at some point in the future. +** +** Or, if an allocation fails within this function, p->rc is set to +** SQLITE_NOMEM and NULL is returned. +*/ static char *intckStrdup(sqlite3_intck *p, const char *zIn){ char *zOut = 0; + int nIn = strlen(zIn); + zOut = (char*)intckMalloc(p, nIn+1); + if( zOut ){ + memcpy(zOut, zIn, nIn+1); + } + return zOut; +} + +/* +** A wrapper around sqlite3_mprintf() that: +** +** + Always returns 0 if p->rc is other than SQLITE_OK when it is called, and +** + Sets p->rc to SQLITE_NOMEM if an allocation fails. +*/ +static char *intckMprintf(sqlite3_intck *p, const char *zFmt, ...){ + va_list ap; + char *zRet = 0; + va_start(ap, zFmt); + zRet = sqlite3_vmprintf(zFmt, ap); if( p->rc==SQLITE_OK ){ - int nIn = strlen(zIn); - zOut = sqlite3_malloc(nIn+1); - if( zOut==0 ){ + if( zRet==0 ){ p->rc = SQLITE_NOMEM; - }else{ - memcpy(zOut, zIn, nIn+1); } + }else{ + sqlite3_free(zRet); + zRet = 0; + } + return zRet; +} + +/* +** Free the sqlite3_intck.apKeyVal, if it is allocated and populated. +*/ +static void intckSavedKeyClear(sqlite3_intck *p){ + if( p->apKeyVal ){ + int ii; + for(ii=0; iinKeyVal; ii++){ + sqlite3_value_free(p->apKeyVal[ii]); + } + sqlite3_free(p->apKeyVal); + p->apKeyVal = 0; } - return zOut; +} + +/* +** If the apKeyVal array is currently allocated and populated, return +** a pointer to a buffer containing a nul-terminated string representing +** the values as an SQL vector. e.g. +** +** "('abc', NULL, 2)" +** +** If apKeyVal is not allocated, return NULL. Or, if an error (e.g. OOM) +** occurs within this function, set sqlite3_intck.rc before returning +** and return NULL. +*/ +static char *intckSavedKeyToText(sqlite3_intck *p){ + char *zRet = 0; + if( p->apKeyVal ){ + int ii; + const char *zSep = "SELECT '(' || "; + char *zSql = 0; + sqlite3_stmt *pStmt = 0; + + for(ii=0; iinKeyVal; ii++){ + zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep); + zSep = " || ', ' || "; + } + zSql = intckMprintf(p, "%z || ')'", zSql); + + pStmt = intckPrepare(p, "%s", zSql); + if( p->rc==SQLITE_OK ){ + for(ii=0; iinKeyVal; ii++){ + sqlite3_bind_value(pStmt, ii+1, p->apKeyVal[ii]); + } + if( SQLITE_ROW==sqlite3_step(pStmt) ){ + zRet = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0)); + } + intckFinalize(p, pStmt); + } + sqlite3_free(zSql); + } + return zRet; } static void intckFindObject(sqlite3_intck *p){ @@ -112,7 +224,7 @@ static void intckFindObject(sqlite3_intck *p){ "SELECT table_name FROM tables " "WHERE ?1 IS NULL OR table_name%s?1 " "ORDER BY 1" - , p->zDb, (p->zKey ? ">=" : ">") + , p->zDb, (p->apKeyVal ? ">=" : ">") ); if( p->rc==SQLITE_OK ){ @@ -125,8 +237,7 @@ static void intckFindObject(sqlite3_intck *p){ /* If this is a new object, ensure the previous key value is cleared. */ if( sqlite3_stricmp(p->zObj, zPrev) ){ - sqlite3_free(p->zKey); - p->zKey = 0; + intckSavedKeyClear(p); } sqlite3_free(zPrev); @@ -332,7 +443,8 @@ static void intckExec(sqlite3_intck *p, const char *zSql){ static char *intckCheckObjectSql( sqlite3_intck *p, const char *zObj, - const char *zPrev + const char *zPrev, + int *pnKeyVal /* OUT: Number of key-values for this scan */ ){ char *zRet = 0; sqlite3_stmt *pStmt = 0; @@ -377,7 +489,16 @@ static char *intckCheckObjectSql( ")" "" "" - ", tabpk(db, tab, idx, o_pk, i_pk, q_pk, eq_pk, ps_pk, pk_pk) AS (" + /* + ** For a PK declared as "PRIMARY KEY(a, b) ... WITHOUT ROWID", where + ** the intck_wrapper aliases of "a" and "b" are "c1" and "c2": + ** + ** o_pk: "o.c1, o.c2" + ** i_pk: "i.'a', i.'b'" + ** ... + ** n_pk: 2 + */ + ", tabpk(db, tab, idx, o_pk, i_pk, q_pk, eq_pk, ps_pk, pk_pk, n_pk) AS (" " WITH pkfields(f, a) AS (" " SELECT i.col_name, i.col_alias FROM idx_cols i WHERE i.idx_ispk" " )" @@ -390,7 +511,8 @@ static char *intckCheckObjectSql( " group_concat(format('\"%w\"', f), ', ')" " )," " group_concat('%s', ',')," - " group_concat('quote('||a||')', ', ') " + " group_concat('quote('||a||')', ', '), " + " count(*)" " FROM tabname t, pkfields" ")" "" @@ -467,11 +589,10 @@ static char *intckCheckObjectSql( " FROM tabname t, tabpk p, idx_cols i WHERE i.idx_name=t.idx" ")" "" - ", thiskey(k) AS (" - " SELECT format('format(''(%%s,%%s)'', %%s, %%s) AS thiskey', " - " group_concat('%%s', ','), p.ps_pk, " - " group_concat('quote('||i.col_alias||')',', '), p.pk_pk" - " ) FROM tabpk p, idx_cols i WHERE i.idx_name=p.idx" + ", thiskey(k, n) AS (" + " SELECT group_concat(i.col_alias, ', ') || ', ' || p.o_pk, " + " count(*) + p.n_pk " + " FROM tabpk p, idx_cols i WHERE i.idx_name=p.idx" ")" "" ", whereclause(w_c) AS (" @@ -483,15 +604,15 @@ static char *intckCheckObjectSql( " FROM tabpk, tabname, idx_cols i WHERE i.idx_name=tabpk.idx" ")" "" - ", main_select(m) AS (" + ", main_select(m, n) AS (" " SELECT format(" " 'WITH %%s\nSELECT %%s,\n%%s\nFROM intck_wrapper AS o%%s'," " ww.s, c, t.k, whereclause.w_c" - " )" + " ), t.n" " FROM case_statement, wrapper_with ww, thiskey t, whereclause" ")" - "SELECT m FROM main_select" + "SELECT m, n FROM main_select" , p->zDb, p->zDb, zObj, zObj , zPrev, zCommon ); @@ -549,9 +670,8 @@ static char *intckCheckObjectSql( ** ** format('(%d,%d)', _rowid_, n.ii) */ - ", thiskey(k) AS (" - " SELECT 'format(''(' || ps_pk || ',%%d)'', ' || pk_pk || ', n.ii)'" - " FROM tabpk" + ", thiskey(k, n) AS (" + " SELECT o_pk || ', n.ii', n_pk+1 FROM tabpk" ")" "" ", whereclause(w_c) AS (" @@ -562,17 +682,17 @@ static char *intckCheckObjectSql( " FROM tabpk, tabname" ")" "" - ", main_select(m) AS (" + ", main_select(m, n) AS (" " SELECT format(" " '%%s, %%s\nSELECT %%s,\n%%s AS thiskey\nFROM intck_wrapper AS o" ", intck_counter AS n%%s\nORDER BY %%s', " " w, ww.s, c, thiskey.k, whereclause.w_c, t.o_pk" - " )" + " ), thiskey.n" " FROM case_statement, tabpk t, counter_with, " " wrapper_with ww, thiskey, whereclause" ")" - "SELECT m FROM main_select", + "SELECT m, n FROM main_select", p->zDb, zObj, zPrev, zCommon ); } @@ -590,6 +710,9 @@ static char *intckCheckObjectSql( fflush(stdout); #else zRet = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0)); + if( pnKeyVal ){ + *pnKeyVal = sqlite3_column_int(pStmt, 1); + } #endif } intckFinalize(p, pStmt); @@ -599,11 +722,14 @@ static char *intckCheckObjectSql( } static void intckCheckObject(sqlite3_intck *p){ - char *zSql = intckCheckObjectSql(p, p->zObj, p->zKey); + char *zSql = 0; + char *zKey = 0; + zKey = intckSavedKeyToText(p); + zSql = intckCheckObjectSql(p, p->zObj, zKey, &p->nKeyVal); p->pCheck = intckPrepare(p, "%s", zSql); sqlite3_free(zSql); - sqlite3_free(p->zKey); - p->zKey = 0; + sqlite3_free(zKey); + intckSavedKeyClear(p); } int sqlite3_intck_open( @@ -644,7 +770,7 @@ int sqlite3_intck_close(sqlite3_intck *p){ ); } sqlite3_free(p->zObj); - sqlite3_free(p->zKey); + intckSavedKeyClear(p); sqlite3_free(p->zTestSql); sqlite3_free(p->zErr); sqlite3_free(p); @@ -668,12 +794,13 @@ int sqlite3_intck_step(sqlite3_intck *p){ if( p->rc==SQLITE_OK ){ assert( p->pCheck ); if( sqlite3_step(p->pCheck)==SQLITE_ROW ){ - /* Fine, whatever... */ + /* Normal case, do nothing. */ }else{ if( sqlite3_finalize(p->pCheck)!=SQLITE_OK ){ intckSaveErrmsg(p); } p->pCheck = 0; + p->nKeyVal = 0; } } } @@ -693,10 +820,27 @@ int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){ return (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc); } + +static sqlite3_value *intckValueDup(sqlite3_intck *p, sqlite3_value *pIn){ + sqlite3_value *pRet = 0; + if( p->rc==SQLITE_OK ){ + pRet = sqlite3_value_dup(pIn); + if( pRet==0 ){ + p->rc = SQLITE_NOMEM; + } + } + return pRet; +} + int sqlite3_intck_suspend(sqlite3_intck *p){ if( p->pCheck && p->rc==SQLITE_OK ){ - assert( p->zKey==0 ); - p->zKey = intckStrdup(p, (const char*)sqlite3_column_text(p->pCheck, 1)); + const int nByte = sizeof(sqlite3_value*) * p->nKeyVal; + int ii; + assert( p->apKeyVal==0 && p->nKeyVal>0 ); + p->apKeyVal = (sqlite3_value**)intckMalloc(p, nByte); + for(ii=0; p->rc==SQLITE_OK && iinKeyVal; ii++){ + p->apKeyVal[ii] = intckValueDup(p, sqlite3_column_value(p->pCheck, ii+1)); + } intckFinalize(p, p->pCheck); p->pCheck = 0; } @@ -706,10 +850,12 @@ int sqlite3_intck_suspend(sqlite3_intck *p){ const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){ sqlite3_free(p->zTestSql); if( zObj ){ - p->zTestSql = intckCheckObjectSql(p, zObj, 0); + p->zTestSql = intckCheckObjectSql(p, zObj, 0, 0); }else{ if( p->zObj ){ - p->zTestSql = intckCheckObjectSql(p, p->zObj, p->zKey); + char *zKey = intckSavedKeyToText(p); + p->zTestSql = intckCheckObjectSql(p, p->zObj, zKey, 0); + sqlite3_free(zKey); }else{ sqlite3_free(p->zTestSql); p->zTestSql = 0; diff --git a/manifest b/manifest index e254a597a2..39fc17cfc5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Consider\susing\s"="\sand\sIS\soperators\swith\seven\slow-quality\sindexes\sin\scases\swhere\sthey\sare\sselected\sexplicitly\susing\san\sINDEXED\sBY\sclause. -D 2024-02-20T16:04:27.694 +C Use\sfewer\scycles\sto\sgenerate\sthe\s"next\skey"\svalue\sused\sby\ssqlite3_intck_suspend()\sfunction\sin\sthe\sintck\sextension. +D 2024-02-20T18:17:06.096 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -251,7 +251,7 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/intck/intck1.test 5b3c9800e119b4dd50a381974f34cee6cfd5b7434286fb8da83b7c8ff1d6bb3c F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 F ext/intck/intck_common.tcl 2895854e7aaf5e199a15f6f82538a00999fd8fc55553bc1f04619af7aa86c0d0 -F ext/intck/sqlite3intck.c 5f319b7c72b0c01cfa28bb5fdd19be5781eb11f5a5216af2a0870dc7e001414d +F ext/intck/sqlite3intck.c 7a795f23424a29f656f3d4c7b83d23484746b57cdc25d3fb98ec805d017fc935 F ext/intck/sqlite3intck.h d9501ea480b7c41c0555f39f4f1b7c3e8d54fc1ea6d115de5e1211e0bc11d3e7 F ext/intck/test_intck.c 06206b35f1428961015c060dd35201246c849625cfdff461e0eeaaf76bda545c F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 @@ -2168,8 +2168,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c01e008c28895e50b14531b2a1f3f1110aab3b54df41ebdbd416fbac7b1bba94 -R 8db173421c176ccb487011bd9440e123 +P 43cbbea82132db2d0ddb4f34cc2b6910b3a1243ae6d4e837b1b27bfe91b84834 +R 9dcf98c64d0302d62dce4c3c1b529641 U dan -Z d4e70ffeb295fbc1a103b9adca306ecc +Z c2dbf2f2090bfeaba66446a197f3ad62 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4565b3d528..69d33b6938 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -43cbbea82132db2d0ddb4f34cc2b6910b3a1243ae6d4e837b1b27bfe91b84834 \ No newline at end of file +95f01426f948cf435d0b400dc7ae06fa699eee32cff498fe77e74a1257a4e09b \ No newline at end of file From eb715f022f71d912e11b51ba7ab68f77d92e0234 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 20 Feb 2024 20:18:02 +0000 Subject: [PATCH 0130/1030] Have the intck extension better handle corruption at the b-tree layer. FossilOrigin-Name: ecd775d108f77d39a1303316c1e0f0b0ae3ffc5218222e1ebfe2ef6783829b85 --- ext/intck/intck1.test | 2 +- ext/intck/intck_common.tcl | 4 +- ext/intck/intckcorrupt.test | 235 ++++++++++++++++++++++++++++++++++++ ext/intck/sqlite3intck.c | 53 ++++++-- ext/intck/sqlite3intck.h | 3 +- ext/intck/test_intck.c | 11 +- manifest | 21 ++-- manifest.uuid | 2 +- 8 files changed, 297 insertions(+), 34 deletions(-) create mode 100644 ext/intck/intckcorrupt.test diff --git a/ext/intck/intck1.test b/ext/intck/intck1.test index 7f60f1fdc6..4110ece049 100644 --- a/ext/intck/intck1.test +++ b/ext/intck/intck1.test @@ -106,7 +106,7 @@ do_eqp_test 1.6.2 { reset_db do_test 2.0 { - set ic [sqlite3_intck db main ""] + set ic [sqlite3_intck db main] $ic close } {} diff --git a/ext/intck/intck_common.tcl b/ext/intck/intck_common.tcl index 757ca82b3f..f00a465b3c 100644 --- a/ext/intck/intck_common.tcl +++ b/ext/intck/intck_common.tcl @@ -16,7 +16,7 @@ if {![info exists testdir]} { source $testdir/tester.tcl proc do_intck {db {bSuspend 0}} { - set ic [sqlite3_intck $db main ""] + set ic [sqlite3_intck $db main] set ret [list] while {"SQLITE_OK"==[$ic step]} { @@ -37,7 +37,7 @@ proc do_intck {db {bSuspend 0}} { } proc intck_sql {db tbl} { - set ic [sqlite3_intck $db main ""] + set ic [sqlite3_intck $db main] set sql [$ic test_sql $tbl] $ic close return $sql diff --git a/ext/intck/intckcorrupt.test b/ext/intck/intckcorrupt.test new file mode 100644 index 0000000000..40f009f9c2 --- /dev/null +++ b/ext/intck/intckcorrupt.test @@ -0,0 +1,235 @@ +# 2024 Feb 21 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# The focus of this file is testing the intck extensions response +# to corruption at the b-tree level. +# + +source [file join [file dirname [info script]] intck_common.tcl] +set testprefix intckcorrupt + +#------------------------------------------------------------------------- +reset_db +do_test 1.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +| size 356352 pagesize 4096 filename crash-acaae0347204ae.db +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 10 00 01 01 00 40 20 20 00 00 00 00 d0 00 00 00 .....@ ........ +| 32: 40 00 ea 00 00 00 00 00 00 40 00 00 00 40 00 00 @........@...@.. +| 96: 00 00 00 00 0d 00 00 00 04 0e 9c 00 0f ad 0f 4f ...............O +| 112: 0e fc 0e 9c 00 00 00 00 00 00 00 00 00 00 00 00 ................ +| 3728: 00 00 00 00 00 00 00 00 00 00 00 00 5e 04 07 17 ............^... +| 3744: 1f 1f 01 81 0b 74 61 62 6c 65 74 31 5f 70 61 72 .....tablet1_par +| 3760: 65 6e 74 74 31 5f 70 61 72 65 6e 74 04 43 52 45 entt1_parent.CRE +| 3776: 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 70 61 ATE TABLE .t1_pa +| 3792: 72 65 6e 74 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 rent.(nodeno INT +| 3808: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY +| 3824: 2c 70 61 72 65 6e 74 6e 6f 64 65 29 51 03 06 17 ,parentnode)Q... +| 3840: 1b 1b 01 7b 74 61 62 6c 65 74 31 5f 6e 6f 64 65 ....tablet1_node +| 3856: 74 31 5f 6e 6f 64 65 03 43 52 45 41 54 45 20 54 t1_node.CREATE T +| 3872: 41 42 4c 45 20 22 74 31 5f 6e 6f 64 65 22 28 6e ABLE .t1_node.(n +| 3888: 6f 64 65 6e 6f 20 49 4e 54 45 47 45 52 20 50 52 odeno INTEGER PR +| 3904: 49 4d 41 52 59 20 4b 45 59 2c 64 61 74 61 29 5c IMARY KEY,data). +| 3920: 02 07 17 1d 1d 01 81 0b 74 61 62 6c 65 74 31 5f ........tablet1_ +| 3936: 72 6f 77 69 64 74 31 5f 72 6f 77 69 64 02 43 52 rowidt1_rowid.CR +| 3952: 45 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 72 EATE TABLE .t1_r +| 3968: 6f 77 69 64 22 28 72 6f 77 69 64 20 49 4e 54 45 owid.(rowid INTE +| 3984: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY, +| 4000: 6e 6f 64 65 6e 6f 2c 61 30 2c 61 31 29 51 01 07 nodeno,a0,a1)Q.. +| 4016: 17 11 11 08 81 0f 74 61 62 6c 65 74 31 74 31 43 ......tablet1t1C +| 4032: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA +| 4048: 42 4c 45 20 74 31 20 55 53 49 4e 47 20 72 74 72 BLE t1 USING rtr +| 4064: 65 65 28 69 64 2c 78 30 20 50 52 49 4d 41 52 59 ee(id,x0 PRIMARY +| 4080: 20 4b 45 59 2c 70 61 72 65 6e 74 6e 6f 64 65 29 KEY,parentnode) +| page 2 offset 4096 +| 0: 51 03 06 17 1b 1b 01 7b 74 61 62 6c 65 74 31 5f Q.......tablet1_ +| 16: 6e 6f 64 65 74 31 5f 6e 6f 64 65 03 43 52 45 41 nodet1_node.CREA +| 32: 54 45 20 54 41 42 4c 45 20 22 74 31 5f 6e 6f 64 TE TABLE .t1_nod +| 48: 65 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 45 47 45 e.(nodeno INTEGE +| 64: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 64 61 R PRIMARY KEY,da +| 80: 74 61 29 5c 02 07 17 1d 1d 01 81 0b 74 61 62 6c ta).........tabl +| 96: 65 74 31 5f 72 6f 77 69 64 74 31 5f 72 6f 77 69 et1_rowidt1_rowi +| 112: 64 02 43 52 45 41 54 45 20 54 41 42 4c 45 00 00 d.CREATE TABLE.. +| 128: 01 0a 02 00 00 00 01 0e 0d 00 00 00 00 24 0e 0d .............$.. +| 144: 0c 1a 06 85 50 46 60 27 70 08 00 00 00 00 00 00 ....PF`'p....... +| 3824: 00 00 00 00 00 00 00 0d 0e 05 00 09 1d 00 74 6f ..............to +| 3840: 79 20 68 61 6c 66 10 0d 05 00 09 23 00 62 6f 74 y half.....#.bot +| 3856: 74 6f 6d 20 68 61 6c 66 0f 0c 05 00 09 21 00 72 tom half.....!.r +| 3872: 69 67 68 74 20 68 61 6c 66 0e 0b 05 00 09 1f 00 ight half....... +| 3888: 6c 65 66 74 20 43 15 f6 e6 f6 46 50 34 35 24 54 left C....FP45$T +| 3904: 15 44 52 05 44 14 24 c4 52 02 27 43 15 f6 e6 f6 .DR.D.$.R.'C.... +| 3920: 46 52 22 8e 6f 64 65 6e 6f 20 49 4e 54 45 47 45 FR..odeno INTEGE +| 3936: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 64 61 R PRIMARY KEY,da +| 3952: 74 61 29 5c 02 07 17 1d 1d 01 81 0b 74 61 62 6c ta).........tabl +| 3968: 65 74 31 5f 72 6f 74 74 6f 6d 20 65 64 67 65 0f et1_rottom edge. +| 3984: 07 05 00 09 21 00 72 69 67 68 74 20 65 64 67 65 ....!.right edge +| 4000: 0e 06 05 00 09 1f 00 6c 65 66 74 20 65 64 67 65 .......left edge +| 4016: 0b 05 05 00 09 19 00 63 65 6e 74 65 72 17 04 05 .......center... +| 4032: 00 09 31 00 75 70 70 65 72 2d 72 69 67 68 74 20 ..1.upper-right +| 4048: 63 6f 72 6e 65 72 17 03 05 00 09 31 00 6c 6f 77 corner.....1.low +| 4064: 65 72 2d 72 69 67 68 74 20 63 6f 72 6e 65 72 16 er-right corner. +| 4080: 02 05 00 09 2f 00 75 70 70 65 72 2d 6c 65 66 74 ..../.upper-left +| page 3 offset 8192 +| 0: 20 63 6f 72 6e 65 72 16 01 05 00 09 2f 01 8c 6f corner...../..o +| 16: 77 65 72 2d 6c 53 51 4c 69 74 65 20 66 6f 72 6d wer-lSQLite form +| 32: 61 74 20 33 00 10 00 01 01 00 40 20 20 00 00 00 at 3......@ ... +| 48: 00 00 00 00 2f 00 00 0d eb 13 00 00 00 03 00 00 ..../........... +| 64: 00 04 00 00 00 00 00 00 00 06 00 00 00 01 00 00 ................ +| 80: 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 ................ +| page 6 offset 20480 +| 128: 00 00 00 00 00 00 00 00 97 3d 04 ae 7c 01 00 00 .........=..|... +| 624: 00 00 00 00 00 00 21 97 3d 04 ae 7c 01 00 00 00 ......!.=..|.... +| 1120: 00 00 00 00 00 20 97 3d 04 ae 7c 01 00 00 00 00 ..... .=..|..... +| 1616: 00 00 00 00 1f 97 3d 04 ae 7c 01 00 00 00 00 00 ......=..|...... +| 2112: 00 00 00 1e 97 3d 04 ae 7c 01 00 00 00 00 00 00 .....=..|....... +| 2608: 00 00 1d 97 d3 d0 4a e7 c0 00 00 00 00 00 00 00 ......J......... +| 3088: 00 00 00 00 00 00 00 00 00 00 00 00 01 f3 00 00 ................ +| 3600: 23 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 00 00 #.=..|.......... +| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26 ...............& +| page 8 offset 28672 +| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0...... +| 1072: 97 4d 1e 14 00 ae 7c 00 00 00 00 00 00 00 00 00 .M....|......... +| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................ +| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 ................ +| page 10 offset 36864 +| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0...... +| 1072: 9a ee c1 80 fd 78 1f ce 1b ae eb b4 00 00 00 00 .....x.......... +| 1088: 13 20 ff 20 00 70 00 00 00 60 50 00 00 00 11 e0 . . .p...`P..... +| 1104: 00 00 00 70 00 00 00 60 50 05 35 14 c6 97 46 52 ...p...`P.5...FR +| 1120: 06 66 f7 26 d6 17 42 03 30 01 00 00 10 10 04 02 .f.&..B.0....... +| 1136: 02 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 .........@...... +| 1152: 00 00 00 00 00 40 00 00 00 40 00 00 00 00 00 00 .....@...@...... +| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................ +| page 12 offset 45056 +| 0: 0d 00 00 00 01 04 30 00 04 30 e1 b4 30 97 4d 46 ......0..0..0.MF +| 16: 14 00 ae 7c 00 00 00 00 00 00 00 03 00 00 43 00 ...|..........C. +| page 47 offset 188416 +| 2512: 00 00 00 00 00 00 00 00 be 00 00 00 00 00 00 00 ................ +| page 87 offset 352256 +| 2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00 ................ +| end crash-acaae0347204ae.db +}]} {} + +do_intck_test 1.1 { + {corruption found while reading database schema} +} + +#------------------------------------------------------------------------- +reset_db +do_test 2.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +| size 28672 pagesize 4096 filename crash-3afa1ca9e9c1bd.db +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........ +| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................ +| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ +| 96: 00 00 00 00 0d 00 00 00 06 0e 88 00 0f b8 0f 6d ...............m +| 112: 0f 3a 0f 0b 0e d5 0e 88 01 00 00 00 00 00 00 00 .:.............. +| 3712: 00 00 00 00 00 00 00 00 4b 06 06 17 25 25 01 5b ........K...%%.[ +| 3728: 74 61 62 6c 65 73 71 6c 69 74 65 5f 73 74 61 74 tablesqlite_stat +| 3744: 31 73 71 6c 69 74 65 5f 73 74 61 74 31 07 43 52 1sqlite_stat1.CR +| 3760: 45 41 54 45 20 54 41 42 4c 45 20 73 71 6c 69 74 EATE TABLE sqlit +| 3776: 65 5f 73 74 61 74 31 28 74 62 6c 2c 69 64 78 2c e_stat1(tbl,idx, +| 3792: 73 74 61 74 29 34 05 06 17 13 11 01 53 69 6e 64 stat)4......Sind +| 3808: 65 78 63 31 63 63 31 06 43 52 45 41 54 45 20 55 exc1cc1.CREATE U +| 3824: 4e 49 51 55 45 20 49 4e 44 45 58 20 63 31 63 20 NIQUE INDEX c1c +| 3840: 4f 4e 20 63 31 28 63 2c 20 62 29 2d 04 06 17 13 ON c1(c, b)-.... +| 3856: 11 01 45 69 6e 64 65 78 63 31 64 63 31 05 43 52 ..Eindexc1dc1.CR +| 3872: 45 41 54 45 20 49 4e 44 45 58 20 63 31 64 20 4f EATE INDEX c1d O +| 3888: 4e 20 63 31 28 64 2c 20 62 29 31 03 06 17 13 11 N c1(d, b)1..... +| 3904: 01 4d 69 6e 64 65 78 62 31 63 62 31 05 43 52 45 .Mindexb1cb1.CRE +| 3920: 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44 45 58 ATE UNIQUE INDEX +| 3936: 20 62 31 63 20 4f 4e 20 62 31 28 63 29 49 02 06 b1c ON b1(c)I.. +| 3952: 17 11 11 0f 7f 74 61 62 6c 65 63 31 63 31 03 43 .....tablec1c1.C +| 3968: 52 45 41 54 45 20 54 41 42 4c 45 20 63 31 28 61 REATE TABLE c1(a +| 3984: 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 INT PRIMARY KEY +| 4000: 2c 20 62 2c 20 63 2c 20 64 29 20 57 49 54 48 4f , b, c, d) WITHO +| 4016: 55 54 20 52 4f 57 49 44 46 01 06 17 11 11 01 79 UT ROWIDF......y +| 4032: 74 61 62 6c 65 62 31 62 31 02 43 52 45 41 54 45 tableb1b1.CREATE +| 4048: 20 54 41 42 4c 45 20 62 31 28 61 20 49 4e 54 20 TABLE b1(a INT +| 4064: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 20 PRIMARY KEY, b, +| 4080: 63 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 c) WITHOUT ROWID +| page 2 offset 4096 +| 0: 0a 00 00 00 07 0f ca 00 0f fa 0f f2 0f ea 0f e2 ................ +| 16: 0f da 00 00 00 01 00 00 00 00 00 00 00 00 00 00 ................ +| 4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 06 ................ +| 4048: 67 07 07 04 01 0f 01 06 66 06 07 04 01 0f 01 05 g.......f....... +| 4064: 65 05 07 04 01 0f 01 04 64 04 07 04 01 0f 01 03 e.......d....... +| 4080: 63 03 07 04 01 0f 01 02 62 0f 05 04 09 0f 09 61 c.......b......a +| page 3 offset 8192 +| 0: 0a 00 00 00 07 0f bd 00 0f f9 0f ef 0f e5 0f db ................ +| 16: 0f d1 0f c7 0f bd 00 00 00 00 01 00 00 00 00 00 ................ +| 4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 09 05 01 ................ +| 4032: 0f 01 01 07 61 07 07 09 05 01 0f 01 01 06 61 06 ....a.........a. +| 4048: 06 09 05 01 0f 01 01 05 61 05 05 09 05 01 0f 01 ........a....... +| 4064: 01 04 61 04 04 09 05 01 0f 01 01 03 61 03 03 09 ..a.........a... +| 4080: 05 01 0f 01 01 02 61 0f 02 06 05 09 0f 09 09 61 ......a........a +| page 4 offset 12288 +| 0: 0a 00 00 00 07 0f d8 00 0f fc 0f f0 0f ea 0f e4 ................ +| 16: 0f de 0f d8 0f f6 00 00 00 00 00 00 00 00 00 00 ................ +| 4048: 00 00 00 00 00 00 00 00 05 03 01 01 07 07 05 03 ................ +| 4064: 01 01 06 06 05 03 01 01 05 05 05 03 01 01 04 04 ................ +| 4080: 05 03 01 01 03 03 05 03 01 01 0f 02 03 03 09 09 ................ +| page 5 offset 16384 +| 0: 0a 00 00 00 07 0f ca 00 0f fa 0f f2 0f ea 0f 00 ................ +| 4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 07 ................ +| 4048: 61 07 07 04 01 0f 01 06 61 06 07 04 01 0f 01 05 a.......a....... +| 4064: 61 05 07 04 01 1f 01 04 61 04 07 04 01 0f 01 03 a.......a....... +| 4080: 61 03 07 04 01 0f 01 02 61 02 05 04 09 0f 09 61 a.......a......a +| page 6 offset 20480 +| 0: 0a 00 00 00 07 0f ca 00 0f fa 0f ea 0f e2 00 00 ................ +| 4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 07 ................ +| 4048: 61 07 07 04 01 0f 01 06 61 06 07 04 01 0f 01 05 a.......a....... +| 4064: 61 05 07 04 01 0f 01 04 61 04 07 04 01 0f 01 03 a.......a....... +| 4080: 61 03 07 04 01 0f 01 0f 61 02 05 04 09 0f 09 61 a.......a......a +| page 7 offset 24576 +| 0: 0d 00 00 00 05 0f 1c 00 0f f0 0f e0 0f d3 0f c5 ................ +| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +| 4016: 00 00 00 00 00 00 00 00 0b 05 04 11 11 13 62 31 ..............b1 +| 4032: 62 31 37 20 31 0c 04 04 11 13 13 62 31 62 31 63 b17 1......b1b1c +| 4048: 37 20 31 0b 03 04 11 11 13 63 31 63 31 37 20 31 7 1......c1c17 1 +| 4064: 0e 02 04 11 13 07 63 31 63 31 64 37 20 31 20 31 ......c1c1d7 1 1 +| 4080: 0e 01 04 11 13 17 63 31 63 31 63 37 20 31 00 00 ......c1c1c7 1.. +| end crash-3afa1ca9e9c1bd.db +}]} {} + +do_intck_test 2.1 { + {corruption found while reading database schema} +} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 3.0 { + PRAGMA page_size = 1024; + CREATE TABLE t1(a, b); + CREATE INDEX i1 ON t1(a); + INSERT INTO t1 VALUES(1, 1), (2, 2), (3, 3); +} + +do_test 3.1 { + set pgno [db one {SELECT rootpage FROM sqlite_schema WHERE name='t1'}] + db close + hexio_write test.db [expr ($pgno-1)*1024] 0000 +} {2} + +sqlite3 db test.db +do_intck_test 3.2 { + {corruption found while scanning database object i1} + {corruption found while scanning database object t1} +} + +finish_test + + diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index 6d54526928..f23dbbd1d7 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -35,6 +35,9 @@ struct sqlite3_intck { int nKeyVal; sqlite3_value **apKeyVal; + char *zMessage; + int bCorruptSchema; + int rc; /* Error code */ char *zErr; /* Error message */ char *zTestSql; /* Returned by sqlite3_intck_test_sql() */ @@ -67,12 +70,12 @@ static sqlite3_stmt *intckPrepare(sqlite3_intck *p, const char *zFmt, ...){ p->rc = sqlite3_prepare_v2(p->db, zSql, -1, &pRet, 0); fflush(stdout); if( p->rc!=SQLITE_OK ){ -#if 1 +#if 0 printf("ERROR: %s\n", zSql); printf("MSG: %s\n", sqlite3_errmsg(p->db)); #endif if( sqlite3_error_offset(p->db)>=0 ){ -#if 1 +#if 0 int iOff = sqlite3_error_offset(p->db); printf("AT: %.40s\n", &zSql[iOff]); #endif @@ -208,12 +211,19 @@ static char *intckSavedKeyToText(sqlite3_intck *p){ return zRet; } +/* +** Find the next database object (table or index) to check. If successful, +** set sqlite3_intck.zObj to point to a nul-terminated buffer containing +** the object's name before returning. +*/ static void intckFindObject(sqlite3_intck *p){ sqlite3_stmt *pStmt = 0; char *zPrev = p->zObj; p->zObj = 0; assert( p->rc==SQLITE_OK ); + assert( p->pCheck==0 ); + pStmt = intckPrepare(p, "WITH tables(table_name) AS (" " SELECT name" @@ -735,7 +745,6 @@ static void intckCheckObject(sqlite3_intck *p){ int sqlite3_intck_open( sqlite3 *db, /* Database handle to operate on */ const char *zDbArg, /* "main", "temp" etc. */ - const char *zFile, /* Path to save-state db on disk (or NULL) */ sqlite3_intck **ppOut /* OUT: New integrity-check handle */ ){ sqlite3_intck *pNew = 0; @@ -760,10 +769,8 @@ int sqlite3_intck_open( return rc; } -int sqlite3_intck_close(sqlite3_intck *p){ - int rc = SQLITE_OK; +void sqlite3_intck_close(sqlite3_intck *p){ if( p ){ - rc = (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc); if( p->db ){ sqlite3_create_function( p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0 @@ -775,11 +782,19 @@ int sqlite3_intck_close(sqlite3_intck *p){ sqlite3_free(p->zErr); sqlite3_free(p); } - return rc; } int sqlite3_intck_step(sqlite3_intck *p){ if( p->rc==SQLITE_OK ){ + + if( p->zMessage ){ + sqlite3_free(p->zMessage); + p->zMessage = 0; + } + + if( p->bCorruptSchema ){ + p->rc = SQLITE_DONE; + }else if( p->pCheck==0 ){ intckFindObject(p); if( p->rc==SQLITE_OK ){ @@ -788,19 +803,29 @@ int sqlite3_intck_step(sqlite3_intck *p){ }else{ p->rc = SQLITE_DONE; } + }else if( p->rc==SQLITE_CORRUPT ){ + p->rc = SQLITE_OK; + p->zMessage = intckStrdup(p, + "corruption found while reading database schema" + ); + p->bCorruptSchema = 1; } } - if( p->rc==SQLITE_OK ){ - assert( p->pCheck ); + if( p->pCheck ){ + assert( p->rc==SQLITE_OK ); if( sqlite3_step(p->pCheck)==SQLITE_ROW ){ /* Normal case, do nothing. */ }else{ - if( sqlite3_finalize(p->pCheck)!=SQLITE_OK ){ - intckSaveErrmsg(p); - } + intckFinalize(p, p->pCheck); p->pCheck = 0; p->nKeyVal = 0; + if( p->rc==SQLITE_CORRUPT ){ + p->rc = SQLITE_OK; + p->zMessage = intckMprintf(p, + "corruption found while scanning database object %s", p->zObj + ); + } } } } @@ -809,6 +834,10 @@ int sqlite3_intck_step(sqlite3_intck *p){ } const char *sqlite3_intck_message(sqlite3_intck *p){ + assert( p->pCheck==0 || p->zMessage==0 ); + if( p->zMessage ){ + return p->zMessage; + } if( p->pCheck ){ return (const char*)sqlite3_column_text(p->pCheck, 0); } diff --git a/ext/intck/sqlite3intck.h b/ext/intck/sqlite3intck.h index c7c24e42c9..e39825fc7e 100644 --- a/ext/intck/sqlite3intck.h +++ b/ext/intck/sqlite3intck.h @@ -25,11 +25,10 @@ typedef struct sqlite3_intck sqlite3_intck; int sqlite3_intck_open( sqlite3 *db, const char *zDb, - const char *zFile, sqlite3_intck **ppOut ); -int sqlite3_intck_close(sqlite3_intck*); +void sqlite3_intck_close(sqlite3_intck*); int sqlite3_intck_step(sqlite3_intck *pCk); diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c index 75bcfa298a..0e2aebf056 100644 --- a/ext/intck/test_intck.c +++ b/ext/intck/test_intck.c @@ -132,7 +132,7 @@ static void testIntckFree(void *clientData){ } /* -** tclcmd: sqlite3_intck DB DBNAME PATH +** tclcmd: sqlite3_intck DB DBNAME */ static int test_sqlite3_intck( void * clientData, @@ -149,8 +149,8 @@ static int test_sqlite3_intck( const char *zFile = 0; int rc = SQLITE_OK; - if( objc!=4 ){ - Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME PATH"); + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); return TCL_ERROR; } @@ -161,9 +161,8 @@ static int test_sqlite3_intck( return TCL_ERROR; } zDb = Tcl_GetString(objv[2]); - zFile = Tcl_GetString(objv[3]); - rc = sqlite3_intck_open(db, zDb, zFile, &p->intck); + rc = sqlite3_intck_open(db, zDb, &p->intck); if( rc!=SQLITE_OK ){ ckfree(p); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errstr(rc), -1)); @@ -207,7 +206,7 @@ static int test_do_intck( pRet = Tcl_NewObj(); Tcl_IncrRefCount(pRet); - rc = sqlite3_intck_open(db, zDb, 0, &pCk); + rc = sqlite3_intck_open(db, zDb, &pCk); if( rc==SQLITE_OK ){ while( sqlite3_intck_step(pCk)==SQLITE_OK ){ const char *zMsg = sqlite3_intck_message(pCk); diff --git a/manifest b/manifest index 39fc17cfc5..6b38631176 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sfewer\scycles\sto\sgenerate\sthe\s"next\skey"\svalue\sused\sby\ssqlite3_intck_suspend()\sfunction\sin\sthe\sintck\sextension. -D 2024-02-20T18:17:06.096 +C Have\sthe\sintck\sextension\sbetter\shandle\scorruption\sat\sthe\sb-tree\slayer. +D 2024-02-20T20:18:02.615 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -248,12 +248,13 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/intck/intck1.test 5b3c9800e119b4dd50a381974f34cee6cfd5b7434286fb8da83b7c8ff1d6bb3c +F ext/intck/intck1.test 15e94ee868e939c6d3aef6884c5652d969b28d3eac940a15585511cf8aec71ad F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 -F ext/intck/intck_common.tcl 2895854e7aaf5e199a15f6f82538a00999fd8fc55553bc1f04619af7aa86c0d0 -F ext/intck/sqlite3intck.c 7a795f23424a29f656f3d4c7b83d23484746b57cdc25d3fb98ec805d017fc935 -F ext/intck/sqlite3intck.h d9501ea480b7c41c0555f39f4f1b7c3e8d54fc1ea6d115de5e1211e0bc11d3e7 -F ext/intck/test_intck.c 06206b35f1428961015c060dd35201246c849625cfdff461e0eeaaf76bda545c +F ext/intck/intck_common.tcl 6e5df126e55d6a0d7e3be9757400d5fb87bd291726d01b72a9fe77a7201967e4 +F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 +F ext/intck/sqlite3intck.c 0f9674952f84084741eb4e945d7532b02996ba8ea938b060228d7874f15557f9 +F ext/intck/sqlite3intck.h dec4a37584024154ad5734cf6ee98dc484ce25c26af88652a096be402fe51833 +F ext/intck/test_intck.c eb84e825a3a0fd43ae1e4280305280a19c9ef42c2bdef3110b282b115de60463 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -2168,8 +2169,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 43cbbea82132db2d0ddb4f34cc2b6910b3a1243ae6d4e837b1b27bfe91b84834 -R 9dcf98c64d0302d62dce4c3c1b529641 +P 95f01426f948cf435d0b400dc7ae06fa699eee32cff498fe77e74a1257a4e09b +R 2f81579b76b29691695c15522ce87fed U dan -Z c2dbf2f2090bfeaba66446a197f3ad62 +Z 5af5831e9af2fce3b2d0c2673f03eefa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 69d33b6938..f905e93b9b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95f01426f948cf435d0b400dc7ae06fa699eee32cff498fe77e74a1257a4e09b \ No newline at end of file +ecd775d108f77d39a1303316c1e0f0b0ae3ffc5218222e1ebfe2ef6783829b85 \ No newline at end of file From b2897c221da108280e88b1abcd9858c96dca4d99 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 21 Feb 2024 16:15:50 +0000 Subject: [PATCH 0131/1030] Ensure intck tests are run by testrunner.tcl. FossilOrigin-Name: 11d6816c060b6edb9cd61f29297ab95e75e2b46f29c0a796820d94fc13586f6d --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/permutations.test | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 7a0b8e41ea..43263453a2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\schanges\sinto\sthis\sbranch. -D 2024-02-21T16:12:23.138 +C Ensure\sintck\stests\sare\srun\sby\stestrunner.tcl. +D 2024-02-21T16:15:50.181 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1487,7 +1487,7 @@ F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/pendingrace.test 6aa33756b950c4529f79c4f3817a9a1e4025bd0d9961571a05c0279bd183d9c6 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff -F test/permutations.test f7caf8dd5c7b1da74842a48df116f7f193399c656d4ffc805cd0d9658568c675 +F test/permutations.test 405542f1d659942994a6b38a9e024cf5cfd23eaa68c806aeb24a72d7c9186e80 F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f F test/pragma.test cddd4b534d7fb5cf113d1308dea4231f3548e8a7f3a65d7d1cf4810c87090b5a F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f @@ -2169,8 +2169,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ecd775d108f77d39a1303316c1e0f0b0ae3ffc5218222e1ebfe2ef6783829b85 27a2113d78b35e324e9aedda7403c96c56ad0bed8c6b139fc5a179e8800b9109 -R 73b41ee05e607fc52a1cc8e54ddf3838 +P 63e8846ac1dc1cf1f7071c4634ccbfec3c13560db6afec376cd91515b62430d3 +R f5edb7901b3b1288ef6973d26c0dbe97 U dan -Z 458475bfe24db2c8e52b55b2e9078f6a +Z 5466cb7224bcaecbaa43fd497cf85347 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fc124a8b54..1a133ba48f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -63e8846ac1dc1cf1f7071c4634ccbfec3c13560db6afec376cd91515b62430d3 \ No newline at end of file +11d6816c060b6edb9cd61f29297ab95e75e2b46f29c0a796820d94fc13586f6d \ No newline at end of file diff --git a/test/permutations.test b/test/permutations.test index 25aa7de018..c26d6ead14 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -95,6 +95,7 @@ foreach f [glob -nocomplain \ $testdir/../ext/lsm1/test/*.test \ $testdir/../ext/recover/*.test \ $testdir/../ext/rbu/*.test \ + $testdir/../ext/intck/*.test \ ] { lappend alltests $f } From b783f56c587304d57702580ec8aff11d8d67641f Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 21 Feb 2024 19:17:45 +0000 Subject: [PATCH 0132/1030] Add documentation to ext/intck/sqlite3intck.h. FossilOrigin-Name: 4cc19bd74f05fe92658cc392a1d1afa173d93181a77303af6bc5684436ae832e --- ext/intck/intck_common.tcl | 2 +- ext/intck/sqlite3intck.c | 6 +- ext/intck/sqlite3intck.h | 129 +++++++++++++++++++++++++++++++++++-- ext/intck/test_intck.c | 7 +- manifest | 18 +++--- manifest.uuid | 2 +- 6 files changed, 140 insertions(+), 24 deletions(-) diff --git a/ext/intck/intck_common.tcl b/ext/intck/intck_common.tcl index f00a465b3c..cea1a247a3 100644 --- a/ext/intck/intck_common.tcl +++ b/ext/intck/intck_common.tcl @@ -24,7 +24,7 @@ proc do_intck {db {bSuspend 0}} { if {$msg!=""} { lappend ret $msg } - if {$bSuspend} { $ic suspend } + if {$bSuspend} { $ic unlock } } set err [$ic error] diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index f23dbbd1d7..d00b5ef529 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -18,7 +18,7 @@ /* ** apKeyVal: -** If sqlite3_intck_suspend() is called when there is a running pCheck +** If sqlite3_intck_unlock() is called when there is a running pCheck ** statement, this array is allocated and populated with the key values ** required to restart the check. If the intck object has not been ** suspended, this is set to NULL. @@ -845,7 +845,7 @@ const char *sqlite3_intck_message(sqlite3_intck *p){ } int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){ - *pzErr = p->zErr; + if( pzErr ) *pzErr = p->zErr; return (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc); } @@ -861,7 +861,7 @@ static sqlite3_value *intckValueDup(sqlite3_intck *p, sqlite3_value *pIn){ return pRet; } -int sqlite3_intck_suspend(sqlite3_intck *p){ +int sqlite3_intck_unlock(sqlite3_intck *p){ if( p->pCheck && p->rc==SQLITE_OK ){ const int nByte = sizeof(sqlite3_value*) * p->nKeyVal; int ii; diff --git a/ext/intck/sqlite3intck.h b/ext/intck/sqlite3intck.h index e39825fc7e..e08a86f289 100644 --- a/ext/intck/sqlite3intck.h +++ b/ext/intck/sqlite3intck.h @@ -11,6 +11,50 @@ ************************************************************************* */ +/* +** Incremental Integrity-Check Extension +** ------------------------------------- +** +** This module contains code to check whether or not an SQLite database +** is well-formed or corrupt. This is the same task as performed by SQLite's +** built-in "PRAGMA integrity_check" command. This module differs from +** "PRAGMA integrity_check" in that: +** +** + It is less thorough - this module does not detect certain types +** of corruption that are detected by the PRAGMA command. However, +** it does detect all kinds of corruption that are likely to cause +** errors in SQLite applications. +** +** + It is slower. Sometimes up to three times slower. +** +** + It allows integrity-check operations to be split into multiple +** transactions, so that the database does not need to be read-locked +** for the duration of the integrity-check. +** +** One way to use the API to run integrity-check on the "main" database +** of handle db is: +** +** int rc = SQLITE_OK; +** sqlite3_intck *p = 0; +** +** sqlite3_intck_open(db, "main", &p); +** while( SQLITE_OK==sqlite3_intck_step(p) ){ +** const char *zMsg = sqlite3_intck_message(p); +** if( zMsg ) printf("corruption: %s\n", zMsg); +** } +** rc = sqlite3_intck_error(p, &zErr); +** if( rc!=SQLITE_OK ){ +** printf("error occured (rc=%d), (errmsg=%s)\n", rc, zErr); +** } +** sqlite3_intck_close(p); +** +** Usually, the sqlite3_intck object opens a read transaction within the +** first call to sqlite3_intck_step() and holds it open until the +** integrity-check is complete. However, if sqlite3_intck_unlock() is +** called, the read transaction is ended and a new read transaction opened +** by the subsequent call to sqlite3_intck_step(). +*/ + #ifndef _SQLITE_INTCK_H #define _SQLITE_INTCK_H @@ -20,23 +64,96 @@ extern "C" { #endif +/* +** An ongoing incremental integrity-check operation is represented by an +** opaque pointer of the following type. +*/ typedef struct sqlite3_intck sqlite3_intck; +/* +** Open a new incremental integrity-check object. If successful, populate +** output variable (*ppOut) with the new object handle and return SQLITE_OK. +** Or, if an error occurs, set (*ppOut) to NULL and return an SQLite error +** code (e.g. SQLITE_NOMEM). +** +** The integrity-check will be conducted on database zDb (which must be "main", +** "temp", or the name of an attached database) of database handle db. Once +** this function has been called successfully, the caller should not use +** database handle db until the integrity-check object has been destroyed +** using sqlite3_intck_close(). +*/ int sqlite3_intck_open( - sqlite3 *db, - const char *zDb, - sqlite3_intck **ppOut + sqlite3 *db, /* Database handle */ + const char *zDb, /* Database name ("main", "temp" etc.) */ + sqlite3_intck **ppOut /* OUT: New sqlite3_intck handle */ ); -void sqlite3_intck_close(sqlite3_intck*); +/* +** Close and release all resources associated with a handle opened by an +** earlier call to sqlite3_intck_open(). The results of using an +** integrity-check handle after it has been passed to this function are +** undefined. +*/ +void sqlite3_intck_close(sqlite3_intck *pCk); +/* +** Do the next step of the integrity-check operation specified by the handle +** passed as the only argument. This function returns SQLITE_DONE if the +** integrity-check operation is finished, or an SQLite error code if +** an error occurs, or SQLITE_OK if no error occurs but the integrity-check +** is not finished. It is not considered an error if database corruption +** is encountered. +** +** Following a successful call to sqlite3_intck_step() (one that returns +** SQLITE_OK), sqlite3_intck_message() returns a non-NULL value if +** corruption was detected in the db. +** +** If an error occurs and a value other than SQLITE_OK or SQLITE_DONE is +** returned, then the integrity-check handle is placed in an error state. +** In this state all subsequent calls to sqlite3_intck_step() or +** sqlite3_intck_unlock() will immediately return the same error. The +** sqlite3_intck_error() method may be used to obtain an English language +** error message in this case. +*/ int sqlite3_intck_step(sqlite3_intck *pCk); +/* +** If the previous call to sqlite3_intck_step() encountered corruption +** within the database, then this function returns a pointer to a buffer +** containing a nul-terminated string describing the corruption in +** English. If the previous call to sqlite3_intck_step() did not encounter +** corruption, or if there was no previous call, this function returns +** NULL. +*/ const char *sqlite3_intck_message(sqlite3_intck *pCk); -int sqlite3_intck_error(sqlite3_intck *pCk, const char **pzErr); +/* +** Close any read-transaction opened by an earlier call to +** sqlite3_intck_step(). Any subsequent call to sqlite3_intck_step() will +** open a new transaction. Return SQLITE_OK if successful, or an SQLite error +** code otherwise. +** +** If an error occurs, then the integrity-check handle is placed in an error +** state. In this state all subsequent calls to sqlite3_intck_step() or +** sqlite3_intck_unlock() will immediately return the same error. The +** sqlite3_intck_error() method may be used to obtain an English language +** error message in this case. +*/ +int sqlite3_intck_unlock(sqlite3_intck *pCk); -int sqlite3_intck_suspend(sqlite3_intck *pCk); +/* +** If an error has occurred in an earlier call to sqlite3_intck_step() +** or sqlite3_intck_unlock(), then this method returns the associated +** SQLite error code. Additionally, if pzErr is not NULL, then (*pzErr) +** may be set to point to a nul-terminated string containing an English +** language error message. Or, if no error message is available, to +** NULL. +** +** If no error has occurred within sqlite3_intck_step() or +** sqlite_intck_unlock() calls on the handle passed as the first argument, +** then SQLITE_OK is returned and (*pzErr) set to NULL. +*/ +int sqlite3_intck_error(sqlite3_intck *pCk, const char **pzErr); /* ** This API is used for testing only. It returns the full-text of an SQL diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c index 0e2aebf056..4c34e2fd26 100644 --- a/ext/intck/test_intck.c +++ b/ext/intck/test_intck.c @@ -49,7 +49,7 @@ static int testIntckCmd( {"step", 0, ""}, /* 1 */ {"message", 0, ""}, /* 2 */ {"error", 0, ""}, /* 3 */ - {"suspend", 0, ""}, /* 4 */ + {"unlock", 0, ""}, /* 4 */ {"test_sql", 1, ""}, /* 5 */ {0 , 0} }; @@ -105,8 +105,8 @@ static int testIntckCmd( break; } - case 4: assert( 0==strcmp("suspend", aCmd[iIdx].zName) ); { - int rc = sqlite3_intck_suspend(p->intck); + case 4: assert( 0==strcmp("unlock", aCmd[iIdx].zName) ); { + int rc = sqlite3_intck_unlock(p->intck); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); break; } @@ -146,7 +146,6 @@ static int test_sqlite3_intck( TestIntck *p = 0; sqlite3 *db = 0; const char *zDb = 0; - const char *zFile = 0; int rc = SQLITE_OK; if( objc!=3 ){ diff --git a/manifest b/manifest index 43263453a2..32648946aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sintck\stests\sare\srun\sby\stestrunner.tcl. -D 2024-02-21T16:15:50.181 +C Add\sdocumentation\sto\sext/intck/sqlite3intck.h. +D 2024-02-21T19:17:45.632 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -250,11 +250,11 @@ F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 F ext/intck/intck1.test 15e94ee868e939c6d3aef6884c5652d969b28d3eac940a15585511cf8aec71ad F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 -F ext/intck/intck_common.tcl 6e5df126e55d6a0d7e3be9757400d5fb87bd291726d01b72a9fe77a7201967e4 +F ext/intck/intck_common.tcl b8a63ae820dbcdf50ddaba474f130b43c26ba81f4b7720ff1d8b9a6592bdd420 F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 -F ext/intck/sqlite3intck.c 0f9674952f84084741eb4e945d7532b02996ba8ea938b060228d7874f15557f9 -F ext/intck/sqlite3intck.h dec4a37584024154ad5734cf6ee98dc484ce25c26af88652a096be402fe51833 -F ext/intck/test_intck.c eb84e825a3a0fd43ae1e4280305280a19c9ef42c2bdef3110b282b115de60463 +F ext/intck/sqlite3intck.c edc93065be0e16394891bb6ad7d279cb54220db65cc66228ac6d6e0bc3919a63 +F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 +F ext/intck/test_intck.c dec07fc82e2626a1450e58be474e351643627b04ee08ce8fae6495a533b87e85 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -2169,8 +2169,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 63e8846ac1dc1cf1f7071c4634ccbfec3c13560db6afec376cd91515b62430d3 -R f5edb7901b3b1288ef6973d26c0dbe97 +P 11d6816c060b6edb9cd61f29297ab95e75e2b46f29c0a796820d94fc13586f6d +R f33ba3131334feff25011177f18e259c U dan -Z 5466cb7224bcaecbaa43fd497cf85347 +Z fc231a0a5c69f02b295f0b4d4c9d9f6a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1a133ba48f..12f0b62ab8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -11d6816c060b6edb9cd61f29297ab95e75e2b46f29c0a796820d94fc13586f6d \ No newline at end of file +4cc19bd74f05fe92658cc392a1d1afa173d93181a77303af6bc5684436ae832e \ No newline at end of file From 6a00f707e8dab995f652470283b7d766575210f1 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 21 Feb 2024 19:31:00 +0000 Subject: [PATCH 0133/1030] Simplify the way the restart key is saved internally by the intck extension. FossilOrigin-Name: 0e39962baae8a82a3021077676b792ac30c79426bcd8c075b5e92bee55e8c3a5 --- ext/intck/sqlite3intck.c | 97 +++++++++++++--------------------------- manifest | 12 ++--- manifest.uuid | 2 +- 3 files changed, 39 insertions(+), 72 deletions(-) diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index d00b5ef529..24bceb27d0 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -17,14 +17,9 @@ #include /* -** apKeyVal: -** If sqlite3_intck_unlock() is called when there is a running pCheck -** statement, this array is allocated and populated with the key values -** required to restart the check. If the intck object has not been -** suspended, this is set to NULL. -** ** nKeyVal: -** The size of the apKeyVal[] array, if it is allocated. +** The number of values that make up the 'key' for the current pCheck +** statement. */ struct sqlite3_intck { sqlite3 *db; @@ -32,8 +27,8 @@ struct sqlite3_intck { char *zObj; /* Current object. Or NULL. */ sqlite3_stmt *pCheck; /* Current check statement */ + char *zKey; int nKeyVal; - sqlite3_value **apKeyVal; char *zMessage; int bCorruptSchema; @@ -161,14 +156,8 @@ static char *intckMprintf(sqlite3_intck *p, const char *zFmt, ...){ ** Free the sqlite3_intck.apKeyVal, if it is allocated and populated. */ static void intckSavedKeyClear(sqlite3_intck *p){ - if( p->apKeyVal ){ - int ii; - for(ii=0; iinKeyVal; ii++){ - sqlite3_value_free(p->apKeyVal[ii]); - } - sqlite3_free(p->apKeyVal); - p->apKeyVal = 0; - } + sqlite3_free(p->zKey); + p->zKey = 0; } /* @@ -182,33 +171,33 @@ static void intckSavedKeyClear(sqlite3_intck *p){ ** occurs within this function, set sqlite3_intck.rc before returning ** and return NULL. */ -static char *intckSavedKeyToText(sqlite3_intck *p){ - char *zRet = 0; - if( p->apKeyVal ){ - int ii; - const char *zSep = "SELECT '(' || "; - char *zSql = 0; - sqlite3_stmt *pStmt = 0; +static void intckSavedKeySave(sqlite3_intck *p){ + int ii; + const char *zSep = "SELECT '(' || "; + char *zSql = 0; + sqlite3_stmt *pStmt = 0; + + assert( p->pCheck ); + assert( p->zKey==0 ); + + + for(ii=0; iinKeyVal; ii++){ + zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep); + zSep = " || ', ' || "; + } + zSql = intckMprintf(p, "%z || ')'", zSql); + pStmt = intckPrepare(p, "%s", zSql); + if( p->rc==SQLITE_OK ){ for(ii=0; iinKeyVal; ii++){ - zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep); - zSep = " || ', ' || "; + sqlite3_bind_value(pStmt, ii+1, sqlite3_column_value(p->pCheck, ii+1)); } - zSql = intckMprintf(p, "%z || ')'", zSql); - - pStmt = intckPrepare(p, "%s", zSql); - if( p->rc==SQLITE_OK ){ - for(ii=0; iinKeyVal; ii++){ - sqlite3_bind_value(pStmt, ii+1, p->apKeyVal[ii]); - } - if( SQLITE_ROW==sqlite3_step(pStmt) ){ - zRet = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0)); - } - intckFinalize(p, pStmt); + if( SQLITE_ROW==sqlite3_step(pStmt) ){ + p->zKey = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0)); } - sqlite3_free(zSql); + intckFinalize(p, pStmt); } - return zRet; + sqlite3_free(zSql); } /* @@ -234,7 +223,7 @@ static void intckFindObject(sqlite3_intck *p){ "SELECT table_name FROM tables " "WHERE ?1 IS NULL OR table_name%s?1 " "ORDER BY 1" - , p->zDb, (p->apKeyVal ? ">=" : ">") + , p->zDb, (p->zKey ? ">=" : ">") ); if( p->rc==SQLITE_OK ){ @@ -733,12 +722,9 @@ static char *intckCheckObjectSql( static void intckCheckObject(sqlite3_intck *p){ char *zSql = 0; - char *zKey = 0; - zKey = intckSavedKeyToText(p); - zSql = intckCheckObjectSql(p, p->zObj, zKey, &p->nKeyVal); + zSql = intckCheckObjectSql(p, p->zObj, p->zKey, &p->nKeyVal); p->pCheck = intckPrepare(p, "%s", zSql); sqlite3_free(zSql); - sqlite3_free(zKey); intckSavedKeyClear(p); } @@ -849,27 +835,10 @@ int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){ return (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc); } - -static sqlite3_value *intckValueDup(sqlite3_intck *p, sqlite3_value *pIn){ - sqlite3_value *pRet = 0; - if( p->rc==SQLITE_OK ){ - pRet = sqlite3_value_dup(pIn); - if( pRet==0 ){ - p->rc = SQLITE_NOMEM; - } - } - return pRet; -} - int sqlite3_intck_unlock(sqlite3_intck *p){ if( p->pCheck && p->rc==SQLITE_OK ){ - const int nByte = sizeof(sqlite3_value*) * p->nKeyVal; - int ii; - assert( p->apKeyVal==0 && p->nKeyVal>0 ); - p->apKeyVal = (sqlite3_value**)intckMalloc(p, nByte); - for(ii=0; p->rc==SQLITE_OK && iinKeyVal; ii++){ - p->apKeyVal[ii] = intckValueDup(p, sqlite3_column_value(p->pCheck, ii+1)); - } + assert( p->zKey==0 && p->nKeyVal>0 ); + intckSavedKeySave(p); intckFinalize(p, p->pCheck); p->pCheck = 0; } @@ -882,9 +851,7 @@ const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){ p->zTestSql = intckCheckObjectSql(p, zObj, 0, 0); }else{ if( p->zObj ){ - char *zKey = intckSavedKeyToText(p); - p->zTestSql = intckCheckObjectSql(p, p->zObj, zKey, 0); - sqlite3_free(zKey); + p->zTestSql = intckCheckObjectSql(p, p->zObj, p->zKey, 0); }else{ sqlite3_free(p->zTestSql); p->zTestSql = 0; diff --git a/manifest b/manifest index 32648946aa..172f8e8435 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sdocumentation\sto\sext/intck/sqlite3intck.h. -D 2024-02-21T19:17:45.632 +C Simplify\sthe\sway\sthe\srestart\skey\sis\ssaved\sinternally\sby\sthe\sintck\sextension. +D 2024-02-21T19:31:00.293 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -252,7 +252,7 @@ F ext/intck/intck1.test 15e94ee868e939c6d3aef6884c5652d969b28d3eac940a15585511cf F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 F ext/intck/intck_common.tcl b8a63ae820dbcdf50ddaba474f130b43c26ba81f4b7720ff1d8b9a6592bdd420 F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 -F ext/intck/sqlite3intck.c edc93065be0e16394891bb6ad7d279cb54220db65cc66228ac6d6e0bc3919a63 +F ext/intck/sqlite3intck.c c437aaa1f4af77621ba984718a62c57722ad9d071151be79335fd87f2c2c2dde F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 F ext/intck/test_intck.c dec07fc82e2626a1450e58be474e351643627b04ee08ce8fae6495a533b87e85 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 @@ -2169,8 +2169,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 11d6816c060b6edb9cd61f29297ab95e75e2b46f29c0a796820d94fc13586f6d -R f33ba3131334feff25011177f18e259c +P 4cc19bd74f05fe92658cc392a1d1afa173d93181a77303af6bc5684436ae832e +R 735ea6d5058bc579028d0f5e808c7418 U dan -Z fc231a0a5c69f02b295f0b4d4c9d9f6a +Z b84fa961179c349189e714cd49d2cd34 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 12f0b62ab8..4d5fa2bca4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4cc19bd74f05fe92658cc392a1d1afa173d93181a77303af6bc5684436ae832e \ No newline at end of file +0e39962baae8a82a3021077676b792ac30c79426bcd8c075b5e92bee55e8c3a5 \ No newline at end of file From 9591a9f0699b50dc4dab84ff48b10d3b65bb2ee7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Feb 2024 20:21:46 +0000 Subject: [PATCH 0134/1030] Fix typo in comment. [https://fossil-scm.org/forum/forumpost/cc20266bf2|Fossil forum post cc20266bf2]. FossilOrigin-Name: 7e3c46eed1290964a3e25662686c6ba1149bf8687d05719b684772e65d660c09 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8ad3679fb6..67ee4024d3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sto\scomments\sassociated\swith\sthe\srecent\sPRAGMA\soptimize\senhancements.\nNo\schanges\sto\scode. -D 2024-02-20T15:38:36.661 +C Fix\stypo\sin\scomment.\s[https://fossil-scm.org/forum/forumpost/cc20266bf2|Fossil\sforum\spost\scc20266bf2]. +D 2024-02-21T20:21:46.267 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -732,7 +732,7 @@ F src/parse.y bfd6da46fc895cd8237400ff485d04ab0b32e47eb56de20982bb7f53e56c1f42 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c f5cb82c15b7455d42e748cad8a6c367db18ada0fadc9b4adba03de953a81d46a +F src/pragma.c 65ec09bbe7322ebbe2ca3a77405ae8df3c85d2c58c122f544a173813940ce3fc F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4c9886b692706723f4b68f58dfef07ab19b192fd19b953917f23b55655af3e02 -R 40f50207938b86842b8686e871138379 +P 27a2113d78b35e324e9aedda7403c96c56ad0bed8c6b139fc5a179e8800b9109 +R 1a616a32dc6ef4389da85028142db3e7 U drh -Z 751534f3f8e8461179e5c9344b944b7a +Z 046bb5ba6f502774560061e8a489ed3b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a82c127f34..b20144c9e0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -27a2113d78b35e324e9aedda7403c96c56ad0bed8c6b139fc5a179e8800b9109 \ No newline at end of file +7e3c46eed1290964a3e25662686c6ba1149bf8687d05719b684772e65d660c09 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 62fd17911a..4ff640a657 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -40,7 +40,7 @@ ** for PRAGMA optimize does not exceed 100 milliseconds against a variety ** of test databases on a RaspberryPI-4 compiled using -Os and without ** -DSQLITE_DEBUG. Of course, your mileage may vary. For the purpose of -** his paragraph, "worst-case" means that ANALYZE ends up being +** this paragraph, "worst-case" means that ANALYZE ends up being ** run on every table in the database. The worst case typically only ** happens if PRAGMA optimize is run on a database file for which ANALYZE ** has not been previously run and the 0x10000 flag is included so that From 639db50a026fb019cf08c167bd6534ddcf8d9033 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 21 Feb 2024 20:58:48 +0000 Subject: [PATCH 0135/1030] Fix various issues in sqlite3intck.c. FossilOrigin-Name: 8a7bfa74525a495f45b1ea212b1718633b637295090d514dd777f9263477d514 --- ext/intck/sqlite3intck.c | 248 ++++++++++++++++++++++----------------- manifest | 12 +- manifest.uuid | 2 +- 3 files changed, 145 insertions(+), 117 deletions(-) diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index 24bceb27d0..e683577bb7 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -14,12 +14,25 @@ #include "sqlite3intck.h" #include #include -#include /* ** nKeyVal: ** The number of values that make up the 'key' for the current pCheck ** statement. +** +** rc: +** Error code returned by most recent sqlite3_intck_step() or +** sqlite3_intck_unlock() call. This is set to SQLITE_DONE when +** the integrity-check operation is finished. +** +** zErr: +** If the object has entered the error state, this is the error message. +** Is freed using sqlite3_free() when the object is deleted. +** +** zTestSql: +** The value returned by the most recent call to sqlite3_intck_testsql(). +** Each call to testsql() frees the previous zTestSql value (using +** sqlite3_free()) and replaces it with the new value it will return. */ struct sqlite3_intck { sqlite3 *db; @@ -52,40 +65,56 @@ static void intckSaveErrmsg(sqlite3_intck *p){ } } -static sqlite3_stmt *intckPrepare(sqlite3_intck *p, const char *zFmt, ...){ +/* +** If the handle passed as the first argument is already in the error state, +** then this function is a no-op (returns NULL immediately). Otherwise, if an +** error occurs within this function, it leaves an error in said handle. +** +** Otherwise, this function attempts to prepare SQL statement zSql and +** return the resulting statement handle to the user. +*/ +static sqlite3_stmt *intckPrepare(sqlite3_intck *p, const char *zSql){ + sqlite3_stmt *pRet = 0; + if( p->rc==SQLITE_OK ){ + p->rc = sqlite3_prepare_v2(p->db, zSql, -1, &pRet, 0); + if( p->rc!=SQLITE_OK ){ + intckSaveErrmsg(p); + assert( pRet==0 ); + } + } + return pRet; +} + +/* +** If the handle passed as the first argument is already in the error state, +** then this function is a no-op (returns NULL immediately). Otherwise, if an +** error occurs within this function, it leaves an error in said handle. +** +** Otherwise, this function treats argument zFmt as a printf() style format +** string. It formats it according to the trailing arguments and then +** attempts to prepare the results and return the resulting prepared +** statement. +*/ +static sqlite3_stmt *intckPrepareFmt(sqlite3_intck *p, const char *zFmt, ...){ sqlite3_stmt *pRet = 0; va_list ap; char *zSql = 0; va_start(ap, zFmt); zSql = sqlite3_vmprintf(zFmt, ap); - if( p->rc==SQLITE_OK ){ - if( zSql==0 ){ - p->rc = SQLITE_NOMEM; - }else{ - p->rc = sqlite3_prepare_v2(p->db, zSql, -1, &pRet, 0); - fflush(stdout); - if( p->rc!=SQLITE_OK ){ -#if 0 - printf("ERROR: %s\n", zSql); - printf("MSG: %s\n", sqlite3_errmsg(p->db)); -#endif - if( sqlite3_error_offset(p->db)>=0 ){ -#if 0 - int iOff = sqlite3_error_offset(p->db); - printf("AT: %.40s\n", &zSql[iOff]); -#endif - } - fflush(stdout); - intckSaveErrmsg(p); - assert( pRet==0 ); - } - } + if( p->rc==SQLITE_OK && zSql==0 ){ + p->rc = SQLITE_NOMEM; } + pRet = intckPrepare(p, zSql); sqlite3_free(zSql); va_end(ap); return pRet; } +/* +** Finalize SQL statement pStmt. If an error occurs and the handle passed +** as the first argument does not already contain an error, store the +** error in the handle. +*/ static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){ int rc = sqlite3_finalize(pStmt); if( p->rc==SQLITE_OK && rc!=SQLITE_OK ){ @@ -93,6 +122,18 @@ static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){ } } +/* +** Execute SQL statement zSql. There is no way to obtain any results +** returned by the statement. This function uses the sqlite3_intck error +** code convention. +*/ +static void intckExec(sqlite3_intck *p, const char *zSql){ + sqlite3_stmt *pStmt = 0; + pStmt = intckPrepare(p, zSql); + while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ); + intckFinalize(p, pStmt); +} + /* ** Wrapper around sqlite3_malloc64() that uses the sqlite3_intck error ** code convention. @@ -110,15 +151,8 @@ static void *intckMalloc(sqlite3_intck *p, sqlite3_int64 nByte){ } /* -** If p->rc is other than SQLITE_OK when this function is called, it -** immediately returns NULL. Otherwise, it attempts to create a copy of -** nul-terminated string zIn in a buffer obtained from sqlite3_malloc(). -** If successful, a pointer to this buffer is returned and it becomes -** the responsibility of the caller to release it using sqlite3_free() -** at some point in the future. -** -** Or, if an allocation fails within this function, p->rc is set to -** SQLITE_NOMEM and NULL is returned. +** Like strdup(), but uses the sqlite3_intck error code convention. Any +** returned buffer should eventually be freed using sqlite3_free(). */ static char *intckStrdup(sqlite3_intck *p, const char *zIn){ char *zOut = 0; @@ -131,10 +165,8 @@ static char *intckStrdup(sqlite3_intck *p, const char *zIn){ } /* -** A wrapper around sqlite3_mprintf() that: -** -** + Always returns 0 if p->rc is other than SQLITE_OK when it is called, and -** + Sets p->rc to SQLITE_NOMEM if an allocation fails. +** A wrapper around sqlite3_mprintf() that uses the sqlite3_intck error +** code convention. */ static char *intckMprintf(sqlite3_intck *p, const char *zFmt, ...){ va_list ap; @@ -153,25 +185,11 @@ static char *intckMprintf(sqlite3_intck *p, const char *zFmt, ...){ } /* -** Free the sqlite3_intck.apKeyVal, if it is allocated and populated. -*/ -static void intckSavedKeyClear(sqlite3_intck *p){ - sqlite3_free(p->zKey); - p->zKey = 0; -} - -/* -** If the apKeyVal array is currently allocated and populated, return -** a pointer to a buffer containing a nul-terminated string representing -** the values as an SQL vector. e.g. -** -** "('abc', NULL, 2)" -** -** If apKeyVal is not allocated, return NULL. Or, if an error (e.g. OOM) -** occurs within this function, set sqlite3_intck.rc before returning -** and return NULL. +** This is used by sqlite3_intck_unlock() to save the vector key value +** required to restart the current pCheck query as a nul-terminated string +** in p->zKey. */ -static void intckSavedKeySave(sqlite3_intck *p){ +static void intckSaveKey(sqlite3_intck *p){ int ii; const char *zSep = "SELECT '(' || "; char *zSql = 0; @@ -180,14 +198,13 @@ static void intckSavedKeySave(sqlite3_intck *p){ assert( p->pCheck ); assert( p->zKey==0 ); - for(ii=0; iinKeyVal; ii++){ zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep); zSep = " || ', ' || "; } zSql = intckMprintf(p, "%z || ')'", zSql); - pStmt = intckPrepare(p, "%s", zSql); + pStmt = intckPrepare(p, zSql); if( p->rc==SQLITE_OK ){ for(ii=0; iinKeyVal; ii++){ sqlite3_bind_value(pStmt, ii+1, sqlite3_column_value(p->pCheck, ii+1)); @@ -213,7 +230,7 @@ static void intckFindObject(sqlite3_intck *p){ assert( p->rc==SQLITE_OK ); assert( p->pCheck==0 ); - pStmt = intckPrepare(p, + pStmt = intckPrepareFmt(p, "WITH tables(table_name) AS (" " SELECT name" " FROM %Q.sqlite_schema WHERE (type='table' OR type='index') AND rootpage" @@ -236,7 +253,8 @@ static void intckFindObject(sqlite3_intck *p){ /* If this is a new object, ensure the previous key value is cleared. */ if( sqlite3_stricmp(p->zObj, zPrev) ){ - intckSavedKeyClear(p); + sqlite3_free(p->zKey); + p->zKey = 0; } sqlite3_free(zPrev); @@ -274,22 +292,13 @@ static int intckGetToken(const char *z){ return iRet; } +/* +** Return true if argument c is an ascii whitespace character. +*/ static int intckIsSpace(char c){ return (c==' ' || c=='\t' || c=='\n' || c=='\r'); } -static int intckTokenMatch( - const char *zToken, - int nToken, - const char *z1, - const char *z2 -){ - return ( - (strlen(z1)==nToken && 0==sqlite3_strnicmp(zToken, z1, nToken)) - || (z2 && strlen(z2)==nToken && 0==sqlite3_strnicmp(zToken, z2, nToken)) - ); -} - /* ** Argument z points to the text of a CREATE INDEX statement. This function ** identifies the part of the text that contains either the index WHERE @@ -350,7 +359,9 @@ static const char *intckParseCreateIndex(const char *z, int iCol, int *pnByte){ if( z[iOff]==')' ) nOpen--; nToken = intckGetToken(zToken); - if( intckTokenMatch(zToken, nToken, "ASC", "DESC") ){ + if( (nToken==3 && 0==sqlite3_strnicmp(zToken, "ASC", nToken)) + || (nToken==4 && 0==sqlite3_strnicmp(zToken, "DESC", nToken)) + ){ iEndOfCol = iOff; }else if( 0==intckIsSpace(zToken[0]) ){ iEndOfCol = 0; @@ -383,7 +394,12 @@ static const char *intckParseCreateIndex(const char *z, int iCol, int *pnByte){ return zRet; } -static void parseCreateIndexFunc( +/* +** User-defined SQL function wrapper for intckParseCreateIndex(): +** +** SELECT parse_create_index(, ); +*/ +static void intckParseCreateIndexFunc( sqlite3_context *pCtx, int nVal, sqlite3_value **apVal @@ -421,7 +437,7 @@ static int intckGetAutoIndex(sqlite3_intck *p){ static int intckIsIndex(sqlite3_intck *p, const char *zObj){ int bRet = 0; sqlite3_stmt *pStmt = 0; - pStmt = intckPrepare(p, + pStmt = intckPrepareFmt(p, "SELECT 1 FROM %Q.sqlite_schema WHERE name=%Q AND type='index'", p->zDb, zObj ); @@ -432,17 +448,20 @@ static int intckIsIndex(sqlite3_intck *p, const char *zObj){ return bRet; } -static void intckExec(sqlite3_intck *p, const char *zSql){ - sqlite3_stmt *pStmt = 0; - pStmt = intckPrepare(p, "%s", zSql); - while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ); - intckFinalize(p, pStmt); -} - +/* +** Return a pointer to a nul-terminated buffer containing the SQL statement +** used to check database object zObj (a table or index) for corruption. +** If parameter zPrev is not NULL, then it must be a string containing the +** vector key required to restart the check where it left off last time. +** If pnKeyVal is not NULL, then (*pnKeyVal) is set to the number of +** columns in the vector key value for the specified object. +** +** This function uses the sqlite3_intck error code convention. +*/ static char *intckCheckObjectSql( - sqlite3_intck *p, - const char *zObj, - const char *zPrev, + sqlite3_intck *p, /* Integrity check object */ + const char *zObj, /* Object (table or index) to scan */ + const char *zPrev, /* Restart key vector, if any */ int *pnKeyVal /* OUT: Number of key-values for this scan */ ){ char *zRet = 0; @@ -563,7 +582,7 @@ static char *intckCheckObjectSql( bIsIndex = intckIsIndex(p, zObj); if( bIsIndex ){ - pStmt = intckPrepare(p, + pStmt = intckPrepareFmt(p, /* Table idxname contains a single row. The first column, "db", contains ** the name of the db containing the table (e.g. "main") and the second, ** "tab", the name of the table itself. */ @@ -616,7 +635,7 @@ static char *intckCheckObjectSql( , zPrev, zCommon ); }else{ - pStmt = intckPrepare(p, + pStmt = intckPrepareFmt(p, /* Table tabname contains a single row. The first column, "db", contains ** the name of the db containing the table (e.g. "main") and the second, ** "tab", the name of the table itself. */ @@ -697,22 +716,10 @@ static char *intckCheckObjectSql( } while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ -#if 0 - int nField = sqlite3_column_count(pStmt); - int ii; - for(ii=0; iizObj, p->zKey, &p->nKeyVal); - p->pCheck = intckPrepare(p, "%s", zSql); - sqlite3_free(zSql); - intckSavedKeyClear(p); -} - +/* +** Open a new integrity-check object. +*/ int sqlite3_intck_open( sqlite3 *db, /* Database handle to operate on */ const char *zDbArg, /* "main", "temp" etc. */ @@ -743,7 +745,7 @@ int sqlite3_intck_open( rc = SQLITE_NOMEM; }else{ sqlite3_create_function(db, "parse_create_index", - 2, SQLITE_UTF8, 0, parseCreateIndexFunc, 0, 0 + 2, SQLITE_UTF8, 0, intckParseCreateIndexFunc, 0, 0 ); memset(pNew, 0, sizeof(*pNew)); pNew->db = db; @@ -755,6 +757,9 @@ int sqlite3_intck_open( return rc; } +/* +** Free the integrity-check object. +*/ void sqlite3_intck_close(sqlite3_intck *p){ if( p ){ if( p->db ){ @@ -763,13 +768,16 @@ void sqlite3_intck_close(sqlite3_intck *p){ ); } sqlite3_free(p->zObj); - intckSavedKeyClear(p); + sqlite3_free(p->zKey); sqlite3_free(p->zTestSql); sqlite3_free(p->zErr); sqlite3_free(p); } } +/* +** Step the integrity-check object. +*/ int sqlite3_intck_step(sqlite3_intck *p){ if( p->rc==SQLITE_OK ){ @@ -785,7 +793,12 @@ int sqlite3_intck_step(sqlite3_intck *p){ intckFindObject(p); if( p->rc==SQLITE_OK ){ if( p->zObj ){ - intckCheckObject(p); + char *zSql = 0; + zSql = intckCheckObjectSql(p, p->zObj, p->zKey, &p->nKeyVal); + p->pCheck = intckPrepare(p, zSql); + sqlite3_free(zSql); + sqlite3_free(p->zKey); + p->zKey = 0; }else{ p->rc = SQLITE_DONE; } @@ -819,6 +832,10 @@ int sqlite3_intck_step(sqlite3_intck *p){ return p->rc; } +/* +** Return a message describing the corruption encountered by the most recent +** call to sqlite3_intck_step(), or NULL if no corruption was encountered. +*/ const char *sqlite3_intck_message(sqlite3_intck *p){ assert( p->pCheck==0 || p->zMessage==0 ); if( p->zMessage ){ @@ -830,21 +847,32 @@ const char *sqlite3_intck_message(sqlite3_intck *p){ return 0; } +/* +** Return the error code and message. +*/ int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){ if( pzErr ) *pzErr = p->zErr; return (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc); } +/* +** Close any read transaction the integrity-check object is holding open +** on the database. +*/ int sqlite3_intck_unlock(sqlite3_intck *p){ if( p->pCheck && p->rc==SQLITE_OK ){ assert( p->zKey==0 && p->nKeyVal>0 ); - intckSavedKeySave(p); + intckSaveKey(p); intckFinalize(p, p->pCheck); p->pCheck = 0; } return p->rc; } +/* +** Return the SQL statement used to check object zObj. Or, if zObj is +** NULL, the current SQL statement. +*/ const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){ sqlite3_free(p->zTestSql); if( zObj ){ diff --git a/manifest b/manifest index 172f8e8435..316837de51 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplify\sthe\sway\sthe\srestart\skey\sis\ssaved\sinternally\sby\sthe\sintck\sextension. -D 2024-02-21T19:31:00.293 +C Fix\svarious\sissues\sin\ssqlite3intck.c. +D 2024-02-21T20:58:48.924 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -252,7 +252,7 @@ F ext/intck/intck1.test 15e94ee868e939c6d3aef6884c5652d969b28d3eac940a15585511cf F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 F ext/intck/intck_common.tcl b8a63ae820dbcdf50ddaba474f130b43c26ba81f4b7720ff1d8b9a6592bdd420 F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 -F ext/intck/sqlite3intck.c c437aaa1f4af77621ba984718a62c57722ad9d071151be79335fd87f2c2c2dde +F ext/intck/sqlite3intck.c 3fa96647dde4c719a477f7dbdd1edf76b2f245549b1a4de7f7d60447b24a14df F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 F ext/intck/test_intck.c dec07fc82e2626a1450e58be474e351643627b04ee08ce8fae6495a533b87e85 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 @@ -2169,8 +2169,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4cc19bd74f05fe92658cc392a1d1afa173d93181a77303af6bc5684436ae832e -R 735ea6d5058bc579028d0f5e808c7418 +P 0e39962baae8a82a3021077676b792ac30c79426bcd8c075b5e92bee55e8c3a5 +R 2d481f6c889817bf845056ed7696633c U dan -Z b84fa961179c349189e714cd49d2cd34 +Z 13c318cbe203f9a86dd5c12df0ee017f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4d5fa2bca4..092b5c01d4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e39962baae8a82a3021077676b792ac30c79426bcd8c075b5e92bee55e8c3a5 \ No newline at end of file +8a7bfa74525a495f45b1ea212b1718633b637295090d514dd777f9263477d514 \ No newline at end of file From 0b8c3126f4ac61a1e8cb4aeee19396f4e2b3862e Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 22 Feb 2024 00:50:54 +0000 Subject: [PATCH 0136/1030] Fix debugging code so that it compiles on MSVC. FossilOrigin-Name: ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/malloc.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 67ee4024d3..50c2f0e0af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\scomment.\s[https://fossil-scm.org/forum/forumpost/cc20266bf2|Fossil\sforum\spost\scc20266bf2]. -D 2024-02-21T20:21:46.267 +C Fix\sdebugging\scode\sso\sthat\sit\scompiles\son\sMSVC. +D 2024-02-22T00:50:54.956 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -703,7 +703,7 @@ F src/json.c a412d7f1550a8597470d30e1d9f8d3dcf111b96ef3877b74bb1c363086bcfb51 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b -F src/malloc.c c31472af77e3421d993b69c93f07890277afd94247da4290e1b290ffc0d1f404 +F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 27a2113d78b35e324e9aedda7403c96c56ad0bed8c6b139fc5a179e8800b9109 -R 1a616a32dc6ef4389da85028142db3e7 +P 7e3c46eed1290964a3e25662686c6ba1149bf8687d05719b684772e65d660c09 +R 365ecee93146612474dc5afdd7dbd0ae U drh -Z 046bb5ba6f502774560061e8a489ed3b +Z a2e66d96e9a847508f80a325e0644c11 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b20144c9e0..6da1bb3887 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7e3c46eed1290964a3e25662686c6ba1149bf8687d05719b684772e65d660c09 \ No newline at end of file +ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3 \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index ef7d2e1edd..9a635e7162 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -228,9 +228,9 @@ static void sqlite3MallocAlarm(int nByte){ ** code debuggers when working on out-of-memory conditions, for example ** caused by PRAGMA hard_heap_limit=N. */ -static SQLITE_NOINLINE void test_oom_breakpoint(void){ +static SQLITE_NOINLINE void test_oom_breakpoint(u64 n){ static u64 nOomFault = 0; - nOomFault++; + nOomFault += n; /* The assert() is never reached in a human lifetime. It is here mostly ** to prevent code optimizers from optimizing out this function. */ assert( (nOomFault>>32) < 0xffffffff ); @@ -265,7 +265,7 @@ static void mallocWithAlarm(int n, void **pp){ if( mem0.hardLimit ){ nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); if( nUsed >= mem0.hardLimit - nFull ){ - test_oom_breakpoint(); + test_oom_breakpoint(1); *pp = 0; return; } @@ -554,7 +554,7 @@ void *sqlite3Realloc(void *pOld, u64 nBytes){ sqlite3MallocAlarm(nDiff); if( mem0.hardLimit>0 && nUsed >= mem0.hardLimit - nDiff ){ sqlite3_mutex_leave(mem0.mutex); - test_oom_breakpoint(); + test_oom_breakpoint(1); return 0; } } From f7ad684c5a3f79565e8d9e4ba0706fcdc80507da Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 22 Feb 2024 18:15:08 +0000 Subject: [PATCH 0137/1030] Fix harmless compiler warning seen with MSVC. FossilOrigin-Name: e5db08993127dfc18cc2b621a13cbfef52974f0f504f4d8208093bfad1ffdcc5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/json.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 50c2f0e0af..a2ef0141ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sdebugging\scode\sso\sthat\sit\scompiles\son\sMSVC. -D 2024-02-22T00:50:54.956 +C Fix\sharmless\scompiler\swarning\sseen\swith\sMSVC. +D 2024-02-22T18:15:08.241 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -699,7 +699,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c a412d7f1550a8597470d30e1d9f8d3dcf111b96ef3877b74bb1c363086bcfb51 +F src/json.c 3b4e2778d95d923d6d77e8a5efd51a6265017b466782d597303f5f094fcd68af F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7e3c46eed1290964a3e25662686c6ba1149bf8687d05719b684772e65d660c09 -R 365ecee93146612474dc5afdd7dbd0ae -U drh -Z a2e66d96e9a847508f80a325e0644c11 +P ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3 +R 63d9d369c3456decb924739dc3e48ce6 +U mistachkin +Z 5c46c4e87cc4943d1671979de864e7c2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6da1bb3887..37d995b0c3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3 \ No newline at end of file +e5db08993127dfc18cc2b621a13cbfef52974f0f504f4d8208093bfad1ffdcc5 \ No newline at end of file diff --git a/src/json.c b/src/json.c index c33b63556a..1227ada78e 100644 --- a/src/json.c +++ b/src/json.c @@ -1623,7 +1623,7 @@ static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){ case '[': { /* Parse array */ iThis = pParse->nBlob; - assert( i<=pParse->nJson ); + assert( i<=(u32)pParse->nJson ); jsonBlobAppendNode(pParse, JSONB_ARRAY, pParse->nJson - i, 0); iStart = pParse->nBlob; if( pParse->oom ) return -1; From 1545243368a908367f357dbf4e3c705574d645db Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 23 Feb 2024 15:13:53 +0000 Subject: [PATCH 0138/1030] Fix problems with resuming integrity-check operations on indexes with mixed ASC and DESC columns, and on indexes that contain NULL values. FossilOrigin-Name: 0f68b35a000ef9f4691c59797c66ed6c3435fc5c503e9d24f891afec6aceeada --- ext/intck/intck1.test | 20 +++--- ext/intck/intck2.test | 52 +++++++++++++++ ext/intck/intck_common.tcl | 7 +- ext/intck/sqlite3intck.c | 129 ++++++++++++++++++++++++++++--------- manifest | 18 +++--- manifest.uuid | 2 +- 6 files changed, 177 insertions(+), 51 deletions(-) diff --git a/ext/intck/intck1.test b/ext/intck/intck1.test index 4110ece049..4e86e4f2fc 100644 --- a/ext/intck/intck1.test +++ b/ext/intck/intck1.test @@ -181,16 +181,10 @@ do_test 3.2 { sqlite3 db test.db } {} -#puts "[intck_sql db x1a]" -#execsql_pp "EXPLAIN QUERY PLAN [intck_sql db x1a]" do_intck_test 3.3 { {entry (4,'six',5) missing from index x1a} } -#explain_i [intck_sql db x1] -#puts [intck_sql db x1] -#puts [intck_sql db x1a] - #------------------------------------------------------------------------- reset_db do_execsql_test 4.0 { @@ -199,13 +193,17 @@ do_execsql_test 4.0 { INSERT INTO www VALUES(1, 1, 1), (2, 2, 2); } -#puts [intck_sql db w1] -#execsql_pp [intck_sql db www] -#execsql_pp [intck_sql db w1] -#puts [intck_sql db w1] - do_intck_test 4.1 { } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 5.0 { + CREATE TABLE t1(a, b); + CREATE INDEX i1 ON t1(a COLLATE NOCASE); +} + +#puts [intck_sql db i1] + finish_test diff --git a/ext/intck/intck2.test b/ext/intck/intck2.test index 90f263f880..bb57886968 100644 --- a/ext/intck/intck2.test +++ b/ext/intck/intck2.test @@ -61,6 +61,58 @@ do_execsql_test 2.0 { } do_intck_test 2.1 {} + +imposter_edit x1 { + CREATE TABLE imp(a, b, c); +} { + DELETE FROM imp WHERE c=7; +} +puts [intck_sql db x1b] +do_intck_test 2.2 { + {surplus entry ('ONE',6,3) in index x1a} + {surplus entry ('ONE6 "''" ',3) in index x1b} + {surplus entry ('ONE','7',3) in index x1c} +} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 3.0 { + CREATE TABLE x1(a, b, c); + CREATE INDEX x1all ON x1(a DESC, b ASC, c DESC); + INSERT INTO x1 VALUES(2, 1, 2); + INSERT INTO x1 VALUES(2, 1, 1); + INSERT INTO x1 VALUES(2, 2, 2); + INSERT INTO x1 VALUES(2, 2, 1); + INSERT INTO x1 VALUES(1, 1, 2); + INSERT INTO x1 VALUES(1, 1, 1); + INSERT INTO x1 VALUES(1, 2, 2); + INSERT INTO x1 VALUES(1, 2, 1); +} + +do_intck_test 3.1 { +} + +imposter_edit x1 { + CREATE TABLE imp(a, b, c); +} { + DELETE FROM imp WHERE 1; +} + +db close +sqlite3 db test.db + +do_intck_test 3.2 { + {surplus entry (2,1,2,1) in index x1all} + {surplus entry (2,1,1,2) in index x1all} + {surplus entry (2,2,2,3) in index x1all} + {surplus entry (2,2,1,4) in index x1all} + {surplus entry (1,1,2,5) in index x1all} + {surplus entry (1,1,1,6) in index x1all} + {surplus entry (1,2,2,7) in index x1all} + {surplus entry (1,2,1,8) in index x1all} +} + +#puts [intck_sql db x1all] #puts [intck_sql db x1] finish_test diff --git a/ext/intck/intck_common.tcl b/ext/intck/intck_common.tcl index cea1a247a3..7d6579ae03 100644 --- a/ext/intck/intck_common.tcl +++ b/ext/intck/intck_common.tcl @@ -24,7 +24,12 @@ proc do_intck {db {bSuspend 0}} { if {$msg!=""} { lappend ret $msg } - if {$bSuspend} { $ic unlock } + if {$bSuspend} { + $ic unlock + #puts "SQL: [$ic test_sql {}]" + #execsql_pp "EXPLAIN query plan [$ic test_sql {}]" + #explain_i [$ic test_sql {}] + } } set err [$ic error] diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index e683577bb7..287ec157c3 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -15,6 +15,9 @@ #include #include +#include +#include + /* ** nKeyVal: ** The number of values that make up the 'key' for the current pCheck @@ -187,22 +190,87 @@ static char *intckMprintf(sqlite3_intck *p, const char *zFmt, ...){ /* ** This is used by sqlite3_intck_unlock() to save the vector key value ** required to restart the current pCheck query as a nul-terminated string -** in p->zKey. +** in p->zKey. */ static void intckSaveKey(sqlite3_intck *p){ int ii; - const char *zSep = "SELECT '(' || "; char *zSql = 0; sqlite3_stmt *pStmt = 0; + sqlite3_stmt *pXinfo = 0; + const char *zDir = 0; assert( p->pCheck ); assert( p->zKey==0 ); - for(ii=0; iinKeyVal; ii++){ - zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep); - zSep = " || ', ' || "; + pXinfo = intckPrepareFmt(p, + "SELECT group_concat(desc, '') FROM %Q.sqlite_schema s, " + "pragma_index_xinfo(%Q, %Q) " + "WHERE s.type='index' AND s.name=%Q", + p->zDb, p->zObj, p->zDb, p->zObj + ); + if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXinfo) ){ + zDir = (const char*)sqlite3_column_text(pXinfo, 0); + } + + if( zDir==0 ){ + /* Object is a table, not an index. This is the easy case,as there are + ** no DESC columns or NULL values in a primary key. */ + const char *zSep = "SELECT '(' || "; + for(ii=0; iinKeyVal; ii++){ + zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep); + zSep = " || ', ' || "; + } + zSql = intckMprintf(p, "%z || ')'", zSql); + }else{ + + /* Object is an index. */ + assert( p->nKeyVal>1 ); + for(ii=p->nKeyVal; ii>0; ii--){ + int bLastIsDesc = zDir[ii-1]=='1'; + int bLastIsNull = sqlite3_column_type(p->pCheck, ii)==SQLITE_NULL; + const char *zLast = sqlite3_column_name(p->pCheck, ii); + char *zLhs = 0; + char *zRhs = 0; + char *zWhere = 0; + + if( bLastIsNull ){ + if( bLastIsDesc ) continue; + zWhere = intckMprintf(p, "'%s IS NOT NULL'", zLast); + }else{ + const char *zOp = bLastIsDesc ? "<" : ">"; + zWhere = intckMprintf(p, "'%s %s ' || quote(?%d)", zLast, zOp, ii); + } + + if( ii>1 ){ + const char *zLhsSep = ""; + const char *zRhsSep = ""; + int jj; + for(jj=0; jjpCheck,jj+1); + zLhs = intckMprintf(p, "%z%s%s", zLhs, zLhsSep, zAlias); + zRhs = intckMprintf(p, "%z%squote(?%d)", zRhs, zRhsSep, jj+1); + zLhsSep = ","; + zRhsSep = " || ',' || "; + } + + zWhere = intckMprintf(p, + "'(%z) IS (' || %z || ') AND ' || %z", + zLhs, zRhs, zWhere); + } + zWhere = intckMprintf(p, "'WHERE ' || %z", zWhere); + + zSql = intckMprintf(p, "%z%s(quote( %z ) )", + zSql, + (zSql==0 ? "VALUES" : ",\n "), + zWhere + ); + } + zSql = intckMprintf(p, + "WITH wc(q) AS (\n%z\n)" + "SELECT 'VALUES' || group_concat('(' || q || ')', ',\n ') FROM wc" + , zSql + ); } - zSql = intckMprintf(p, "%z || ')'", zSql); pStmt = intckPrepare(p, zSql); if( p->rc==SQLITE_OK ){ @@ -214,7 +282,9 @@ static void intckSaveKey(sqlite3_intck *p){ } intckFinalize(p, pStmt); } + sqlite3_free(zSql); + intckFinalize(p, pXinfo); } /* @@ -521,7 +591,7 @@ static char *intckCheckObjectSql( " SELECT i.col_name, i.col_alias FROM idx_cols i WHERE i.idx_ispk" " )" " SELECT t.db, t.tab, t.idx, " - " group_concat('o.'||a, ', '), " + " group_concat(a, ', '), " " group_concat('i.'||quote(f), ', '), " " group_concat('quote(o.'||a||')', ' || '','' || '), " " format('(%s)==(%s)'," @@ -586,24 +656,26 @@ static char *intckCheckObjectSql( /* Table idxname contains a single row. The first column, "db", contains ** the name of the db containing the table (e.g. "main") and the second, ** "tab", the name of the table itself. */ - "WITH tabname(db, tab, idx, prev) AS (" - " SELECT %Q, (SELECT tbl_name FROM %Q.sqlite_schema WHERE name=%Q), " - " %Q, %Q " + "WITH tabname(db, tab, idx) AS (" + " SELECT %Q, (SELECT tbl_name FROM %Q.sqlite_schema WHERE name=%Q), %Q " ")" + "" + ", whereclause(w_c) AS (%s)" + "" "%s" /* zCommon */ "" ", case_statement(c) AS (" " SELECT " - " 'CASE WHEN (' || group_concat(col_alias, ', ') || ') IS (\n ' " + " 'CASE WHEN (' || group_concat(col_alias, ', ') || ') IS (\n ' " " || 'SELECT ' || group_concat(col_expr, ', ') || ' FROM '" " || format('%%Q.%%Q NOT INDEXED WHERE %%s\n', t.db, t.tab, p.eq_pk)" - " || ' )\n THEN NULL\n '" + " || ' )\n THEN NULL\n '" " || 'ELSE format(''surplus entry ('" " || group_concat('%%s', ',') || ',' || p.ps_pk" " || ') in index ' || t.idx || ''', ' " " || group_concat('quote('||i.col_alias||')', ', ') || ', ' || p.pk_pk" " || ')'" - " || '\nEND AS error_message'" + " || '\n END AS error_message'" " FROM tabname t, tabpk p, idx_cols i WHERE i.idx_name=t.idx" ")" "" @@ -613,26 +685,25 @@ static char *intckCheckObjectSql( " FROM tabpk p, idx_cols i WHERE i.idx_name=p.idx" ")" "" - ", whereclause(w_c) AS (" - " SELECT CASE WHEN prev!='' THEN " - " '\nWHERE (' || group_concat(i.col_alias, ',') || ',' " - " || o_pk || ') > ' || prev" - " ELSE ''" - " END" - " FROM tabpk, tabname, idx_cols i WHERE i.idx_name=tabpk.idx" - ")" - "" ", main_select(m, n) AS (" " SELECT format(" - " 'WITH %%s\nSELECT %%s,\n%%s\nFROM intck_wrapper AS o%%s'," - " ww.s, c, t.k, whereclause.w_c" + " 'WITH %%s\n' ||" + " ', idx_checker AS (\n' ||" + " ' SELECT %%s,\n' ||" + " ' %%s\n' || " + " ' FROM intck_wrapper AS o\n' ||" + " ')\n'," + " ww.s, c, t.k" " ), t.n" - " FROM case_statement, wrapper_with ww, thiskey t, whereclause" + " FROM case_statement, wrapper_with ww, thiskey t" ")" - "SELECT m, n FROM main_select" + "SELECT m || " + " group_concat('SELECT * FROM idx_checker ' || w_c, ' UNION ALL '), n" + " FROM " + "main_select, whereclause " , p->zDb, p->zDb, zObj, zObj - , zPrev, zCommon + , zPrev ? zPrev : "VALUES('')", zCommon ); }else{ pStmt = intckPrepareFmt(p, @@ -689,7 +760,7 @@ static char *intckCheckObjectSql( ** format('(%d,%d)', _rowid_, n.ii) */ ", thiskey(k, n) AS (" - " SELECT o_pk || ', n.ii', n_pk+1 FROM tabpk" + " SELECT o_pk || ', ii', n_pk+1 FROM tabpk" ")" "" ", whereclause(w_c) AS (" @@ -702,7 +773,7 @@ static char *intckCheckObjectSql( "" ", main_select(m, n) AS (" " SELECT format(" - " '%%s, %%s\nSELECT %%s,\n%%s AS thiskey\nFROM intck_wrapper AS o" + " '%%s, %%s\nSELECT %%s,\n%%s\nFROM intck_wrapper AS o" ", intck_counter AS n%%s\nORDER BY %%s', " " w, ww.s, c, thiskey.k, whereclause.w_c, t.o_pk" " ), thiskey.n" diff --git a/manifest b/manifest index 316837de51..7508c5a2f6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\svarious\sissues\sin\ssqlite3intck.c. -D 2024-02-21T20:58:48.924 +C Fix\sproblems\swith\sresuming\sintegrity-check\soperations\son\sindexes\swith\smixed\sASC\sand\sDESC\scolumns,\sand\son\sindexes\sthat\scontain\sNULL\svalues. +D 2024-02-23T15:13:53.489 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -248,11 +248,11 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/intck/intck1.test 15e94ee868e939c6d3aef6884c5652d969b28d3eac940a15585511cf8aec71ad -F ext/intck/intck2.test b65d7f627342f767e1d2c447d25619666cec36f516786dd56568bd741e5d7e67 -F ext/intck/intck_common.tcl b8a63ae820dbcdf50ddaba474f130b43c26ba81f4b7720ff1d8b9a6592bdd420 +F ext/intck/intck1.test e73c4f87b54176291b9a01b52dbc9dd88f42f3ec8aea48c8e0bd7f87a1440a40 +F ext/intck/intck2.test 9d083ccb06c9239400569846b077fb9867a19b12233ce9dcbc124540e12d38df +F ext/intck/intck_common.tcl 9e51458126576783f11051ac0fd25bea3f6b17f570a55884223737f3200b214b F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 -F ext/intck/sqlite3intck.c 3fa96647dde4c719a477f7dbdd1edf76b2f245549b1a4de7f7d60447b24a14df +F ext/intck/sqlite3intck.c b7dd8354b4c3255cecc8cc190f7f980a667d3aec7409900703248296472b358f F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 F ext/intck/test_intck.c dec07fc82e2626a1450e58be474e351643627b04ee08ce8fae6495a533b87e85 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 @@ -2169,8 +2169,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0e39962baae8a82a3021077676b792ac30c79426bcd8c075b5e92bee55e8c3a5 -R 2d481f6c889817bf845056ed7696633c +P 8a7bfa74525a495f45b1ea212b1718633b637295090d514dd777f9263477d514 +R afa6cae1c52ecb818ac1cff0c8856821 U dan -Z 13c318cbe203f9a86dd5c12df0ee017f +Z d57af7b6bfe17ed12101d02b696a832f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 092b5c01d4..391414ddf6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8a7bfa74525a495f45b1ea212b1718633b637295090d514dd777f9263477d514 \ No newline at end of file +0f68b35a000ef9f4691c59797c66ed6c3435fc5c503e9d24f891afec6aceeada \ No newline at end of file From 5956d1d94288cd816af1f1c1c667be472fdccdbd Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 23 Feb 2024 17:10:39 +0000 Subject: [PATCH 0139/1030] Fix detection of surplus index entries when all indexed fields are NULL. FossilOrigin-Name: 5f310fb7be450c96f01c21e6fd1377d4a274784377d0bd811922ab63e612bd11 --- ext/intck/intck2.test | 33 ++++++++++++++++++++++++++++++--- ext/intck/sqlite3intck.c | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/ext/intck/intck2.test b/ext/intck/intck2.test index bb57886968..54c392b0f5 100644 --- a/ext/intck/intck2.test +++ b/ext/intck/intck2.test @@ -67,7 +67,6 @@ imposter_edit x1 { } { DELETE FROM imp WHERE c=7; } -puts [intck_sql db x1b] do_intck_test 2.2 { {surplus entry ('ONE',6,3) in index x1a} {surplus entry ('ONE6 "''" ',3) in index x1b} @@ -112,8 +111,36 @@ do_intck_test 3.2 { {surplus entry (1,2,1,8) in index x1all} } -#puts [intck_sql db x1all] -#puts [intck_sql db x1] +do_execsql_test 3.3 { + DELETE FROM x1; + INSERT INTO x1 VALUES(NULL, NULL, NULL); + INSERT INTO x1 VALUES(NULL, NULL, NULL); + INSERT INTO x1 VALUES(NULL, NULL, NULL); + INSERT INTO x1 VALUES(NULL, NULL, NULL); +} + +do_intck_test 3.4 { +} + +imposter_edit x1 { + CREATE TABLE imp(a, b, c); +} { + DELETE FROM imp WHERE 1; + INSERT INTO imp(rowid) VALUES(-123); + INSERT INTO imp(rowid) VALUES(456); +} + +db close +sqlite3 db test.db + +do_intck_test 3.5 { + {entry (NULL,NULL,NULL,-123) missing from index x1all} + {entry (NULL,NULL,NULL,456) missing from index x1all} + {surplus entry (NULL,NULL,NULL,1) in index x1all} + {surplus entry (NULL,NULL,NULL,2) in index x1all} + {surplus entry (NULL,NULL,NULL,3) in index x1all} + {surplus entry (NULL,NULL,NULL,4) in index x1all} +} finish_test diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index 287ec157c3..23f93eb318 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -666,8 +666,8 @@ static char *intckCheckObjectSql( "" ", case_statement(c) AS (" " SELECT " - " 'CASE WHEN (' || group_concat(col_alias, ', ') || ') IS (\n ' " - " || 'SELECT ' || group_concat(col_expr, ', ') || ' FROM '" + " 'CASE WHEN (' || group_concat(col_alias, ', ') || ', 1) IS (\n' " + " || ' SELECT ' || group_concat(col_expr, ', ') || ', 1 FROM '" " || format('%%Q.%%Q NOT INDEXED WHERE %%s\n', t.db, t.tab, p.eq_pk)" " || ' )\n THEN NULL\n '" " || 'ELSE format(''surplus entry ('" diff --git a/manifest b/manifest index 7508c5a2f6..f702e591f9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sproblems\swith\sresuming\sintegrity-check\soperations\son\sindexes\swith\smixed\sASC\sand\sDESC\scolumns,\sand\son\sindexes\sthat\scontain\sNULL\svalues. -D 2024-02-23T15:13:53.489 +C Fix\sdetection\sof\ssurplus\sindex\sentries\swhen\sall\sindexed\sfields\sare\sNULL. +D 2024-02-23T17:10:39.995 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -249,10 +249,10 @@ F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f4 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 F ext/intck/intck1.test e73c4f87b54176291b9a01b52dbc9dd88f42f3ec8aea48c8e0bd7f87a1440a40 -F ext/intck/intck2.test 9d083ccb06c9239400569846b077fb9867a19b12233ce9dcbc124540e12d38df +F ext/intck/intck2.test 348a8c505bfe843eceaedd911f91ba4516b5e9c2d4aa83a300a6e84de6ff0955 F ext/intck/intck_common.tcl 9e51458126576783f11051ac0fd25bea3f6b17f570a55884223737f3200b214b F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 -F ext/intck/sqlite3intck.c b7dd8354b4c3255cecc8cc190f7f980a667d3aec7409900703248296472b358f +F ext/intck/sqlite3intck.c c8515c1ed1bc725e156fc5053e8f9c8cff3c440f3bca47a8309e76d2411fc73d F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 F ext/intck/test_intck.c dec07fc82e2626a1450e58be474e351643627b04ee08ce8fae6495a533b87e85 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 @@ -2169,8 +2169,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8a7bfa74525a495f45b1ea212b1718633b637295090d514dd777f9263477d514 -R afa6cae1c52ecb818ac1cff0c8856821 +P 0f68b35a000ef9f4691c59797c66ed6c3435fc5c503e9d24f891afec6aceeada +R 67e774420e8bc9ef111ef98dbd2b2abc U dan -Z d57af7b6bfe17ed12101d02b696a832f +Z f383f29167401158528bd4b4e88fca49 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 391414ddf6..1b5128f2f2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f68b35a000ef9f4691c59797c66ed6c3435fc5c503e9d24f891afec6aceeada \ No newline at end of file +5f310fb7be450c96f01c21e6fd1377d4a274784377d0bd811922ab63e612bd11 \ No newline at end of file From b088e892a09a95b6929e87a4cc7091644d75fa47 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 23 Feb 2024 18:02:31 +0000 Subject: [PATCH 0140/1030] Typo fixes [forum:c19bbf245d|reported in the forum]. No code changes. FossilOrigin-Name: 67d8bae0f695c0839e724c1aadea0a22f736fdd9664d40a29b4d82c91fb89ab3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index a2ef0141ff..0dcfda40aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning\sseen\swith\sMSVC. -D 2024-02-22T18:15:08.241 +C Typo\sfixes\s[forum:c19bbf245d|reported\sin\sthe\sforum].\sNo\scode\schanges. +D 2024-02-23T18:02:31.402 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -741,7 +741,7 @@ F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 F src/shell.c.in e4a38496290d3979ea3d953fba0bc187d350d6e80f8e33c2e37b9a924850439b -F src/sqlite.h.in 020d7b7307dda51420dc48b47e5334eaface77baba6bd9818375d392eb3ab5b5 +F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 2f3a38c3e0470b6152ec14f698e6f3310831e3c09b6e56f046a12c3e3bdd5cd4 @@ -2162,8 +2162,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3 -R 63d9d369c3456decb924739dc3e48ce6 -U mistachkin -Z 5c46c4e87cc4943d1671979de864e7c2 +P e5db08993127dfc18cc2b621a13cbfef52974f0f504f4d8208093bfad1ffdcc5 +R fbd01c060093cc83561018ffcc839787 +U stephan +Z 3309f779a4e95b40300e717423266d54 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 37d995b0c3..75ab08df22 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e5db08993127dfc18cc2b621a13cbfef52974f0f504f4d8208093bfad1ffdcc5 \ No newline at end of file +67d8bae0f695c0839e724c1aadea0a22f736fdd9664d40a29b4d82c91fb89ab3 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index f21cffd51a..e05d7b231a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -764,11 +764,11 @@ struct sqlite3_file { ** ** xLock() upgrades the database file lock. In other words, xLock() moves the ** database file lock in the direction NONE toward EXCLUSIVE. The argument to -** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never +** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never ** SQLITE_LOCK_NONE. If the database file lock is already at or above the ** requested lock, then the call to xLock() is a no-op. ** xUnlock() downgrades the database file lock to either SHARED or NONE. -* If the lock is already at or below the requested lock state, then the call +** If the lock is already at or below the requested lock state, then the call ** to xUnlock() is a no-op. ** The xCheckReservedLock() method checks whether any database connection, ** either in this process or in some other process, is holding a RESERVED, From 645f21f15baf64486ac4c81543aa19476e10869e Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 23 Feb 2024 18:21:51 +0000 Subject: [PATCH 0141/1030] Add the ".intck ?STEPS_PER_UNLOCK?" command to the shell tool. FossilOrigin-Name: cfd051836b72f7d4e38cc9614f6ae5c003de4ce377359fd391adf06fe1ddf6b9 --- ext/intck/intck2.test | 33 +++++++++++++++++++++++++-- manifest | 14 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 53 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 10 deletions(-) diff --git a/ext/intck/intck2.test b/ext/intck/intck2.test index 54c392b0f5..c168118535 100644 --- a/ext/intck/intck2.test +++ b/ext/intck/intck2.test @@ -1,4 +1,4 @@ -# 2008 Feb 19 +# 2024 Feb 19 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: @@ -142,6 +142,35 @@ do_intck_test 3.5 { {surplus entry (NULL,NULL,NULL,4) in index x1all} } -finish_test +reset_db + +do_execsql_test 3.6 { + CREATE TABLE w1(a PRIMARY KEY, b, c); + INSERT INTO w1 VALUES(1.0, NULL, NULL); + INSERT INTO w1 VALUES(33.0, NULL, NULL); + INSERT INTO w1 VALUES(100.0, NULL, NULL); + CREATE INDEX w1bc ON w1(b, c); +} +do_intck_test 3.7 { +} + +imposter_edit w1 { + CREATE TABLE imp(a, b, c); +} { + DELETE FROM imp WHERE a=33; + INSERT INTO imp(a) VALUES(1234.5); + INSERT INTO imp(a) VALUES(-1234.5); +} + +do_intck_test 3.8 { + {surplus entry (33.0,2) in index sqlite_autoindex_w1_1} + {entry (1234.5,4) missing from index sqlite_autoindex_w1_1} + {entry (NULL,NULL,4) missing from index w1bc} + {entry (-1234.5,5) missing from index sqlite_autoindex_w1_1} + {entry (NULL,NULL,5) missing from index w1bc} + {surplus entry (NULL,NULL,2) in index w1bc} +} + +finish_test diff --git a/manifest b/manifest index f702e591f9..266c84bd6a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sdetection\sof\ssurplus\sindex\sentries\swhen\sall\sindexed\sfields\sare\sNULL. -D 2024-02-23T17:10:39.995 +C Add\sthe\s".intck\s?STEPS_PER_UNLOCK?"\scommand\sto\sthe\sshell\stool. +D 2024-02-23T18:21:51.131 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -249,7 +249,7 @@ F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f4 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 F ext/intck/intck1.test e73c4f87b54176291b9a01b52dbc9dd88f42f3ec8aea48c8e0bd7f87a1440a40 -F ext/intck/intck2.test 348a8c505bfe843eceaedd911f91ba4516b5e9c2d4aa83a300a6e84de6ff0955 +F ext/intck/intck2.test 97daaf43b8a3c870ba7c2fd421dc1887053f5b30188896fa64677ce8174c206f F ext/intck/intck_common.tcl 9e51458126576783f11051ac0fd25bea3f6b17f570a55884223737f3200b214b F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 F ext/intck/sqlite3intck.c c8515c1ed1bc725e156fc5053e8f9c8cff3c440f3bca47a8309e76d2411fc73d @@ -747,7 +747,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in e4a38496290d3979ea3d953fba0bc187d350d6e80f8e33c2e37b9a924850439b +F src/shell.c.in 0c13f7cc3bb8c31190efbd96f5c1d8f2fafdbcad549424b7e7850cb5617b115a F src/sqlite.h.in 020d7b7307dda51420dc48b47e5334eaface77baba6bd9818375d392eb3ab5b5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2169,8 +2169,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0f68b35a000ef9f4691c59797c66ed6c3435fc5c503e9d24f891afec6aceeada -R 67e774420e8bc9ef111ef98dbd2b2abc +P 5f310fb7be450c96f01c21e6fd1377d4a274784377d0bd811922ab63e612bd11 +R 86a36a81ccd4a5a3ded74d8234b0250a U dan -Z f383f29167401158528bd4b4e88fca49 +Z 39f7083bcdb0c03c315a581938028ce8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1b5128f2f2..ff9880a342 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f310fb7be450c96f01c21e6fd1377d4a274784377d0bd811922ab63e612bd11 \ No newline at end of file +cfd051836b72f7d4e38cc9614f6ae5c003de4ce377359fd391adf06fe1ddf6b9 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index da377982e1..07e4b201ce 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1222,6 +1222,9 @@ INCLUDE ../ext/misc/sqlar.c INCLUDE ../ext/expert/sqlite3expert.h INCLUDE ../ext/expert/sqlite3expert.c +INCLUDE ../ext/intck/sqlite3intck.h +INCLUDE ../ext/intck/sqlite3intck.c + #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) #define SQLITE_SHELL_HAVE_RECOVER 1 #else @@ -4741,6 +4744,7 @@ static const char *(azHelp[]) = { ".indexes ?TABLE? Show names of indexes", " If TABLE is specified, only show indexes for", " tables matching TABLE using the LIKE operator.", + ".intck ?STEPS_PER_UNLOCK? Run an incremental integrity check on the db", #ifdef SQLITE_ENABLE_IOTRACE ",iotrace FILE Enable I/O diagnostic logging to FILE", #endif @@ -7650,6 +7654,40 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){ } #endif /* SQLITE_SHELL_HAVE_RECOVER */ +/* +** Implementation of ".intck STEPS_PER_UNLOCK" command. +*/ +static int intckDatabaseCmd(ShellState *pState, i64 nStepPerUnlock){ + sqlite3_intck *p = 0; + int rc = SQLITE_OK; + + rc = sqlite3_intck_open(pState->db, "main", &p); + if( rc==SQLITE_OK ){ + i64 nStep = 0; + i64 nError = 0; + const char *zErr = 0; + while( SQLITE_OK==sqlite3_intck_step(p) ){ + const char *zMsg = sqlite3_intck_message(p); + if( zMsg ){ + oputf("%s\n", zMsg); + nError++; + } + nStep++; + if( nStepPerUnlock && (nStep % nStepPerUnlock)==0 ){ + sqlite3_intck_unlock(p); + } + } + rc = sqlite3_intck_error(p, &zErr); + if( zErr ){ + eputf("%s\n", zErr); + } + sqlite3_intck_close(p); + + oputf("%lld steps, %lld errors\n", nStep, nError); + } + + return rc; +} /* * zAutoColumn(zCol, &db, ?) => Maybe init db, add column zCol to it. @@ -9140,6 +9178,21 @@ static int do_meta_command(char *zLine, ShellState *p){ }else #endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */ + if( c=='i' && cli_strncmp(azArg[0], "intck", n)==0 ){ + i64 iArg = 0; + if( nArg==2 ){ + iArg = integerValue(azArg[1]); + if( iArg==0 ) iArg = -1; + } + if( (nArg!=1 && nArg!=2) || iArg<0 ){ + eputf("Usage: .intck STEPS_PER_UNLOCK\n"); + rc = 1; + goto meta_command_exit; + } + open_db(p, 0); + rc = intckDatabaseCmd(p, iArg); + }else + #ifdef SQLITE_ENABLE_IOTRACE if( c=='i' && cli_strncmp(azArg[0], "iotrace", n)==0 ){ SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...); From ee299cc7d4c5d72cf25cf59478212c3731848f5a Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 23 Feb 2024 20:51:06 +0000 Subject: [PATCH 0142/1030] Add tests for the new code on this branch. FossilOrigin-Name: 351d46b2373f08bc8033d0902d9f67cd6c8bcc16c0d9f787e4fb279c0a76da87 --- ext/intck/intckfault.test | 45 +++++++++++++++++++++++++++++++++++++++ ext/intck/sqlite3intck.c | 20 +++++++++++------ manifest | 13 +++++------ manifest.uuid | 2 +- 4 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 ext/intck/intckfault.test diff --git a/ext/intck/intckfault.test b/ext/intck/intckfault.test new file mode 100644 index 0000000000..5c383681ac --- /dev/null +++ b/ext/intck/intckfault.test @@ -0,0 +1,45 @@ +# 2024 February 24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +source [file join [file dirname [info script]] intck_common.tcl] +set testprefix intckfault + + + +do_execsql_test 1.0 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); + INSERT INTO t1 VALUES(1, 2, 3); + INSERT INTO t1 VALUES(2, 'two', 'three'); + INSERT INTO t1 VALUES(3, NULL, NULL); + CREATE INDEX i1 ON t1(b, c); +} + +do_faultsim_test 1 -faults oom-t* -prep { +} -body { + set ::ic [sqlite3_intck db main] + set nStep 0 + while {"SQLITE_OK"==[$::ic step]} { + incr nStep + if {$nStep==3} { $::ic unlock } + } + set res [$::ic error] + $::ic close + set res +} -test { + catch { $::ic close } +puts $testresult +puts $testnfail + faultsim_test_result {0 {SQLITE_OK {}}} {0 {SQLITE_NOMEM {}}} {0 {SQLITE_NOMEM {out of memory}}} +} + +finish_test + diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index 23f93eb318..b61035f157 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -159,10 +159,12 @@ static void *intckMalloc(sqlite3_intck *p, sqlite3_int64 nByte){ */ static char *intckStrdup(sqlite3_intck *p, const char *zIn){ char *zOut = 0; - int nIn = strlen(zIn); - zOut = (char*)intckMalloc(p, nIn+1); - if( zOut ){ - memcpy(zOut, zIn, nIn+1); + if( zIn ){ + int nIn = strlen(zIn); + zOut = (char*)intckMalloc(p, nIn+1); + if( zOut ){ + memcpy(zOut, zIn, nIn+1); + } } return zOut; } @@ -815,13 +817,17 @@ int sqlite3_intck_open( if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ - sqlite3_create_function(db, "parse_create_index", - 2, SQLITE_UTF8, 0, intckParseCreateIndexFunc, 0, 0 - ); memset(pNew, 0, sizeof(*pNew)); pNew->db = db; pNew->zDb = (const char*)&pNew[1]; memcpy(&pNew[1], zDb, nDb+1); + rc = sqlite3_create_function(db, "parse_create_index", + 2, SQLITE_UTF8, 0, intckParseCreateIndexFunc, 0, 0 + ); + if( rc!=SQLITE_OK ){ + sqlite3_intck_close(pNew); + pNew = 0; + } } *ppOut = pNew; diff --git a/manifest b/manifest index 266c84bd6a..068e592cd0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s".intck\s?STEPS_PER_UNLOCK?"\scommand\sto\sthe\sshell\stool. -D 2024-02-23T18:21:51.131 +C Add\stests\sfor\sthe\snew\scode\son\sthis\sbranch. +D 2024-02-23T20:51:06.837 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -252,7 +252,8 @@ F ext/intck/intck1.test e73c4f87b54176291b9a01b52dbc9dd88f42f3ec8aea48c8e0bd7f87 F ext/intck/intck2.test 97daaf43b8a3c870ba7c2fd421dc1887053f5b30188896fa64677ce8174c206f F ext/intck/intck_common.tcl 9e51458126576783f11051ac0fd25bea3f6b17f570a55884223737f3200b214b F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 -F ext/intck/sqlite3intck.c c8515c1ed1bc725e156fc5053e8f9c8cff3c440f3bca47a8309e76d2411fc73d +F ext/intck/intckfault.test ba0213c9c8dce08d519d5251268a3bab076a184b4d07acdea23b65e89c9ae03c +F ext/intck/sqlite3intck.c 642f57a4604580513547df9d8489cdb49b8f5f3af1981c7ffb87bc37e5ce1439 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 F ext/intck/test_intck.c dec07fc82e2626a1450e58be474e351643627b04ee08ce8fae6495a533b87e85 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 @@ -2169,8 +2170,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5f310fb7be450c96f01c21e6fd1377d4a274784377d0bd811922ab63e612bd11 -R 86a36a81ccd4a5a3ded74d8234b0250a +P cfd051836b72f7d4e38cc9614f6ae5c003de4ce377359fd391adf06fe1ddf6b9 +R aa9167c841a6524a2987fc0088c3a9be U dan -Z 39f7083bcdb0c03c315a581938028ce8 +Z 2a1b98d11090580141aae0cbd3e3021e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ff9880a342..c043830657 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cfd051836b72f7d4e38cc9614f6ae5c003de4ce377359fd391adf06fe1ddf6b9 \ No newline at end of file +351d46b2373f08bc8033d0902d9f67cd6c8bcc16c0d9f787e4fb279c0a76da87 \ No newline at end of file From 9c59c87448c2c8a7411bb65b4a163a1f634db8ab Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 24 Feb 2024 16:26:15 +0000 Subject: [PATCH 0143/1030] Add further tests for the intck module. FossilOrigin-Name: c253e276b29de28a18270d01b60d95157ce3fc4b37e246d991f9119d26e718d7 --- ext/intck/intck1.test | 125 ++++++++++++++++++++++++++++++++++++++- ext/intck/intckbusy.test | 48 +++++++++++++++ ext/intck/sqlite3intck.c | 74 ++++++++--------------- ext/intck/test_intck.c | 8 ++- manifest | 17 +++--- manifest.uuid | 2 +- 6 files changed, 211 insertions(+), 63 deletions(-) create mode 100644 ext/intck/intckbusy.test diff --git a/ext/intck/intck1.test b/ext/intck/intck1.test index 4e86e4f2fc..e05ae06166 100644 --- a/ext/intck/intck1.test +++ b/ext/intck/intck1.test @@ -200,9 +200,132 @@ reset_db do_execsql_test 5.0 { CREATE TABLE t1(a, b); CREATE INDEX i1 ON t1(a COLLATE NOCASE); + INSERT INTO t1 VALUES(1, 1); + INSERT INTO t1 VALUES(2, 2); } -#puts [intck_sql db i1] +do_test 5.1 { + set ic [sqlite3_intck db nosuchdb] + $ic step +} {SQLITE_ERROR} + +do_test 5.2 { + $ic close + set ic [sqlite3_intck db {}] + while {[$ic step]=="SQLITE_OK"} {} + set res [$ic error] + $ic close + set res +} {SQLITE_OK {}} + +do_test 5.3 { test_do_intck db "main" } {} + +do_test 5.4 { + set ret {} + set ic [sqlite3_intck db main] + db eval [$ic test_sql t1] { + if {$error_message!=""} { lappend ret $error_message } + } + $ic close + set ret +} {} + +do_test 5.5 { + set ret {} + set ic [sqlite3_intck db main] + db eval [$ic test_sql {}] { + if {$error_message!=""} { lappend ret $error_message } + } + $ic close + set ret +} {} + +db cache flush + +do_test 5.6 { + set ret {} + set ic [sqlite3_intck db main] + $ic step + db eval [$ic test_sql {}] { + if {$error_message!=""} { lappend ret $error_message } + } + $ic close + set ret +} {} + +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 6.0 { + CREATE TABLE t1(x, y, PRIMARY KEY(x)) WITHOUT ROWID; + CREATE INDEX i1 ON t1(y, x); + INSERT INTO t1 VALUES(X'0000', X'1111'); +} + +do_intck_test 6.1 {} + +do_execsql_test 6.2.1 { + PRAGMA writable_schema = 1; + UPDATE sqlite_schema SET sql = 'CREATE INDEX i1' WHERE name='i1'; +} {} +do_intck_test 6.2.2 {} + +do_execsql_test 6.3.1 { + UPDATE sqlite_schema SET sql = 'CREATE INDEX i1(y' WHERE name='i1'; +} {} +do_intck_test 6.3.2 {} + +do_execsql_test 6.4.1 { + UPDATE sqlite_schema + SET sql = 'CREATE INDEX i1(y) hello world' + WHERE name='i1'; +} {} +do_intck_test 6.4.2 {} + +do_execsql_test 6.5.1 { + UPDATE sqlite_schema + SET sql = 'CREATE INDEX i1(y, x) WHERE 1 ' + WHERE name='i1'; +} {} +do_intck_test 6.5.2 {} + +do_execsql_test 6.6.1 { + UPDATE sqlite_schema + SET sql = 'CREATE INDEX i1( , ) WHERE 1 ' + WHERE name='i1'; +} {} + +do_test 6.7.2 { + set ic [sqlite3_intck db main] + $ic step +} {SQLITE_ERROR} +do_test 6.5.3 { + $ic error +} {SQLITE_ERROR {near "AS": syntax error}} +$ic close + +do_execsql_test 6.6.1 { + UPDATE sqlite_schema + SET sql = 'CREATE INDEX i1([y' + WHERE name='i1'; +} {} +do_intck_test 6.6.2 {} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 7.0 { + CREATE TABLE x1("1", "22", "3333", four); + CREATE INDEX i1 ON x1( "1" , "22", NULL); + INSERT INTO x1 VALUES(1, 22, 3333, NULL); + INSERT INTO x1 VALUES(1, 22, 3333, NULL); +} +do_execsql_test 7.1 " CREATE INDEX i2 ON x1( \"1\"\r\n\t ) " +do_execsql_test 7.2 { CREATE INDEX i3 ON x1( "22" || 'abc''def' || `1` ) } +do_execsql_test 7.3 { CREATE INDEX i4 ON x1( [22] + [1] ) } +do_execsql_test 7.4 { CREATE INDEX i5 ON x1( four||'hello' ) } + +do_intck_test 7.5 {} + finish_test diff --git a/ext/intck/intckbusy.test b/ext/intck/intckbusy.test new file mode 100644 index 0000000000..edfedf5ae8 --- /dev/null +++ b/ext/intck/intckbusy.test @@ -0,0 +1,48 @@ +# 2024 February 24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +source [file join [file dirname [info script]] intck_common.tcl] +set testprefix intckbusy + + + +do_execsql_test 1.0 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); + INSERT INTO t1 VALUES(1, 2, 3); + INSERT INTO t1 VALUES(2, 'two', 'three'); + INSERT INTO t1 VALUES(3, NULL, NULL); + CREATE INDEX i1 ON t1(b, c); +} + +sqlite3 db2 test.db + +do_execsql_test -db db2 1.1 { + BEGIN EXCLUSIVE; + INSERT INTO t1 VALUES(4, 5, 6); +} + +do_test 1.2 { + set ic [sqlite3_intck db main] + $ic step +} {SQLITE_BUSY} +do_test 1.3 { + $ic unlock +} {SQLITE_BUSY} +do_test 1.4 { + $ic error +} {SQLITE_BUSY {database is locked}} +do_test 1.4 { + $ic close +} {} + +finish_test + diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index b61035f157..12d205e4d9 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -60,12 +60,9 @@ struct sqlite3_intck { ** and error code currently held by the database handle in p->rc and p->zErr. */ static void intckSaveErrmsg(sqlite3_intck *p){ - const char *zDberr = sqlite3_errmsg(p->db); p->rc = sqlite3_errcode(p->db); - if( zDberr ){ - sqlite3_free(p->zErr); - p->zErr = sqlite3_mprintf("%s", zDberr); - } + sqlite3_free(p->zErr); + p->zErr = sqlite3_mprintf("%s", sqlite3_errmsg(p->db)); } /* @@ -125,6 +122,15 @@ static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){ } } +/* +** If there is already an error in handle p, return it. Otherwise, call +** sqlite3_step() on the statement handle and return that value. +*/ +static int intckStep(sqlite3_intck *p, sqlite3_stmt *pStmt){ + if( p->rc ) return p->rc; + return sqlite3_step(pStmt); +} + /* ** Execute SQL statement zSql. There is no way to obtain any results ** returned by the statement. This function uses the sqlite3_intck error @@ -133,42 +139,10 @@ static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){ static void intckExec(sqlite3_intck *p, const char *zSql){ sqlite3_stmt *pStmt = 0; pStmt = intckPrepare(p, zSql); - while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ); + intckStep(p, pStmt); intckFinalize(p, pStmt); } -/* -** Wrapper around sqlite3_malloc64() that uses the sqlite3_intck error -** code convention. -*/ -static void *intckMalloc(sqlite3_intck *p, sqlite3_int64 nByte){ - void *pRet = 0; - assert( nByte>0 ); - if( p->rc==SQLITE_OK ){ - pRet = sqlite3_malloc64(nByte); - if( pRet==0 ){ - p->rc = SQLITE_NOMEM; - } - } - return pRet; -} - -/* -** Like strdup(), but uses the sqlite3_intck error code convention. Any -** returned buffer should eventually be freed using sqlite3_free(). -*/ -static char *intckStrdup(sqlite3_intck *p, const char *zIn){ - char *zOut = 0; - if( zIn ){ - int nIn = strlen(zIn); - zOut = (char*)intckMalloc(p, nIn+1); - if( zOut ){ - memcpy(zOut, zIn, nIn+1); - } - } - return zOut; -} - /* ** A wrapper around sqlite3_mprintf() that uses the sqlite3_intck error ** code convention. @@ -280,7 +254,7 @@ static void intckSaveKey(sqlite3_intck *p){ sqlite3_bind_value(pStmt, ii+1, sqlite3_column_value(p->pCheck, ii+1)); } if( SQLITE_ROW==sqlite3_step(pStmt) ){ - p->zKey = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0)); + p->zKey = intckMprintf(p,"%s",(const char*)sqlite3_column_text(pStmt, 0)); } intckFinalize(p, pStmt); } @@ -318,7 +292,7 @@ static void intckFindObject(sqlite3_intck *p){ if( p->rc==SQLITE_OK ){ sqlite3_bind_text(pStmt, 1, zPrev, -1, SQLITE_TRANSIENT); if( sqlite3_step(pStmt)==SQLITE_ROW ){ - p->zObj = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0)); + p->zObj = intckMprintf(p,"%s",(const char*)sqlite3_column_text(pStmt, 0)); } } intckFinalize(p, pStmt); @@ -347,7 +321,7 @@ static int intckGetToken(const char *z){ while( 1 ){ if( z[iRet]==c ){ iRet++; - if( z[iRet+1]!=c ) break; + if( z[iRet]!=c ) break; } iRet++; } @@ -496,7 +470,7 @@ static int intckGetAutoIndex(sqlite3_intck *p){ int bRet = 0; sqlite3_stmt *pStmt = 0; pStmt = intckPrepare(p, "PRAGMA automatic_index"); - if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ + if( SQLITE_ROW==intckStep(p, pStmt) ){ bRet = sqlite3_column_int(pStmt, 0); } intckFinalize(p, pStmt); @@ -789,7 +763,7 @@ static char *intckCheckObjectSql( } while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ - zRet = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0)); + zRet = intckMprintf(p, "%s", (const char*)sqlite3_column_text(pStmt, 0)); if( pnKeyVal ){ *pnKeyVal = sqlite3_column_int(pStmt, 1); } @@ -839,15 +813,15 @@ int sqlite3_intck_open( */ void sqlite3_intck_close(sqlite3_intck *p){ if( p ){ - if( p->db ){ - sqlite3_create_function( - p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0 - ); - } + sqlite3_finalize(p->pCheck); + sqlite3_create_function( + p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0 + ); sqlite3_free(p->zObj); sqlite3_free(p->zKey); sqlite3_free(p->zTestSql); sqlite3_free(p->zErr); + sqlite3_free(p->zMessage); sqlite3_free(p); } } @@ -881,7 +855,7 @@ int sqlite3_intck_step(sqlite3_intck *p){ } }else if( p->rc==SQLITE_CORRUPT ){ p->rc = SQLITE_OK; - p->zMessage = intckStrdup(p, + p->zMessage = intckMprintf(p, "%s", "corruption found while reading database schema" ); p->bCorruptSchema = 1; @@ -937,7 +911,7 @@ int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){ ** on the database. */ int sqlite3_intck_unlock(sqlite3_intck *p){ - if( p->pCheck && p->rc==SQLITE_OK ){ + if( p->rc==SQLITE_OK && p->pCheck ){ assert( p->zKey==0 && p->nKeyVal>0 ); intckSaveKey(p); intckFinalize(p, p->pCheck); diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c index 4c34e2fd26..72f72d8c13 100644 --- a/ext/intck/test_intck.c +++ b/ext/intck/test_intck.c @@ -92,12 +92,12 @@ static int testIntckCmd( case 3: assert( 0==strcmp("error", aCmd[iIdx].zName) ); { const char *zErr = 0; - int rc = sqlite3_intck_error(p->intck, &zErr); + int rc = sqlite3_intck_error(p->intck, 0); Tcl_Obj *pRes = Tcl_NewObj(); - Tcl_ListObjAppendElement( interp, pRes, Tcl_NewStringObj(sqlite3ErrName(rc), -1) ); + sqlite3_intck_error(p->intck, &zErr); Tcl_ListObjAppendElement( interp, pRes, Tcl_NewStringObj(zErr ? zErr : 0, -1) ); @@ -160,6 +160,7 @@ static int test_sqlite3_intck( return TCL_ERROR; } zDb = Tcl_GetString(objv[2]); + if( zDb[0]=='\0' ) zDb = 0; rc = sqlite3_intck_open(db, zDb, &p->intck); if( rc!=SQLITE_OK ){ @@ -169,7 +170,7 @@ static int test_sqlite3_intck( } do { - sprintf(zName, "intck%d", iName); + sprintf(zName, "intck%d", iName++); }while( Tcl_GetCommandInfo(interp, zName, &info)!=0 ); Tcl_CreateObjCommand(interp, zName, testIntckCmd, (void*)p, testIntckFree); Tcl_SetObjResult(interp, Tcl_NewStringObj(zName, -1)); @@ -226,6 +227,7 @@ static int test_do_intck( } Tcl_DecrRefCount(pRet); sqlite3_intck_close(pCk); + sqlite3_intck_close(0); return rc ? TCL_ERROR : TCL_OK; } diff --git a/manifest b/manifest index 068e592cd0..732ad1f72c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sfor\sthe\snew\scode\son\sthis\sbranch. -D 2024-02-23T20:51:06.837 +C Add\sfurther\stests\sfor\sthe\sintck\smodule. +D 2024-02-24T16:26:15.674 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -248,14 +248,15 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/intck/intck1.test e73c4f87b54176291b9a01b52dbc9dd88f42f3ec8aea48c8e0bd7f87a1440a40 +F ext/intck/intck1.test 866f0937911bf3a10491af6ce319b75bcd587c39dc8decf2444746b946aa4f3e F ext/intck/intck2.test 97daaf43b8a3c870ba7c2fd421dc1887053f5b30188896fa64677ce8174c206f F ext/intck/intck_common.tcl 9e51458126576783f11051ac0fd25bea3f6b17f570a55884223737f3200b214b +F ext/intck/intckbusy.test 0732fe3efbb9e0a53ffdcc240073f6ff2777ea82c3e08812b16494f650763fe1 F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 F ext/intck/intckfault.test ba0213c9c8dce08d519d5251268a3bab076a184b4d07acdea23b65e89c9ae03c -F ext/intck/sqlite3intck.c 642f57a4604580513547df9d8489cdb49b8f5f3af1981c7ffb87bc37e5ce1439 +F ext/intck/sqlite3intck.c 52381a627637504a49e93400814b36e99afa0b972a9a24ef1732b8268bb27fa8 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 -F ext/intck/test_intck.c dec07fc82e2626a1450e58be474e351643627b04ee08ce8fae6495a533b87e85 +F ext/intck/test_intck.c d63f1707432802f5db125ee40b794923af77d4686869bd8d3a7eb43332344267 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -2170,8 +2171,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cfd051836b72f7d4e38cc9614f6ae5c003de4ce377359fd391adf06fe1ddf6b9 -R aa9167c841a6524a2987fc0088c3a9be +P 351d46b2373f08bc8033d0902d9f67cd6c8bcc16c0d9f787e4fb279c0a76da87 +R 38b420c887519ac9a48b5a886e5c9758 U dan -Z 2a1b98d11090580141aae0cbd3e3021e +Z 449a9c9353165606d5987b5f74af35a1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c043830657..af08de7704 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -351d46b2373f08bc8033d0902d9f67cd6c8bcc16c0d9f787e4fb279c0a76da87 \ No newline at end of file +c253e276b29de28a18270d01b60d95157ce3fc4b37e246d991f9119d26e718d7 \ No newline at end of file From 7598e7d70e30d963b172ef5902e2e51cf161fef5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 24 Feb 2024 19:58:15 +0000 Subject: [PATCH 0144/1030] Add two GIFs that contain the feather logo. FossilOrigin-Name: 5f21e6a8ee709d8c5ec12c45e8dc702a7d0bb041f31b5715e28cd904dfd566b0 --- art/icon-243x273.gif | Bin 0 -> 24689 bytes art/icon-80x90.gif | Bin 0 -> 3392 bytes manifest | 14 ++++++++------ manifest.uuid | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 art/icon-243x273.gif create mode 100644 art/icon-80x90.gif diff --git a/art/icon-243x273.gif b/art/icon-243x273.gif new file mode 100644 index 0000000000000000000000000000000000000000..e1cdfd0b5142092b56108852d86776a7da5366ee GIT binary patch literal 24689 zcmZ@;^;gu-*MD!pvP&%8uyo792XP5?=|;LyT2fIEDP z5CjBK;qm(iJagv9nKLuz&YgM1)zDJM%GncV8z>2K;XDX4>P zngF+~5Q>I~>stIb)j_xH$yM~2Rdm5Brj#lsU^N?rnl)JKE~T~&xt1xtstKE_37wi1 zy^alst~HC6Da6Q{&B#VT$3n=^T3pKjtnPqNa|CHQAatD|YVIH%cci`>Le-s4&w)kH z32Nv>Y2*ww^gtSW&{%mfnz#abkD*#mz(ziRNf6xPDWlaB5px$A>-$2cZnDmgSsk9L zyFb-`=CYuI9}f@VZUVQC$DYdI`?D(W!$Q6%xdMUtB7p_hpXKWMhnWS0>x3jZ zKaT)C?*cs^pm^2^JRgG*S`ndb@X%U@&}P=KdWNtHf#`@YIAhbg9)ENKLhG(!LS6Wg0l z9BD(K@NrP=IC<<8<*U!IS6>*C$5~UyIo?h%zn!Ivo#apG;ZNunebp=Wx}QH~fG=ZG zEOSaIV^%tQS|MjjCTB)IdmfuUs6d>)`EK?)aZd8xvRv+(bk3@JR=-N_v`X%*PQjdh z@q*6#NyEYg)8ZxTvL(}^NwcEQP9J96s^_0H&byZmY80-Tm9E&7uNW4t*i>)ass8Ht zVZ*6%&9ipHy>aJJ{l=5VuK_Jvfvr2fO}qZ>hru0N&pUVg`%i<%{|3!n`AuGV_MA9% zokW(@zNu@CEvZU;SCH1&^P+7kvVA6|zAv}6KfH4`yyHuH?|5PFP|@I2-PBywr!R!w zZ{Y(6QG?$ihmT@Mjzas6Vm}{;PyUIX_#HWU_G_++WuMabufL{UMDL6DMh#fEB^rANX z74NztQGD8&nw7adu`K_&FZ5UD^}R%^#BgX;-Ry7!j;g=|9pU6)sH=thi})J6(m7JDCJELoy!)z$LIKBEDV;M}&@R zF@s%s_h29-+2k1DO~2wR9M`+Bd<_Guo%d;?QekwjMWqU< z#XQlwWT-TQ&S+l$bDoE^*fTx~wC~l=bqaOaLOZe<%ME?GVoIeR1{Z_XFnZlIo}S8n z!P32|J|iVq)o4n`UZuXS$A0aMwxLAzeb=A}dMC|F)mnY=cl#AxDXXgWQ?DuynkGX_ z%bUJyAMH0Uzj`Fu@O}5&L4{M;d^f9}Op-cEdV!3M0ut!55=iyiV(l*aL%sDwc!kPm zxiXoKZZ5k89%;_IimNbAA3Ugcz!#q+Jt&exNyd3+*sz)z`@*n#Krm1In8RWCbJY;0 zUXgt4zt?*|hLz|gWH=?n;;TRVMuBRFZu}0eVRnGp_D$P`aQcqn+Jj|gm3(f>PHWWL z*3El$1=r1o%_v54Ig5V|L*e?bh_m;pA=Ka%s?tL6>aB!^X($5&3kd9~+pSBdY5-DW zxT8w=#bPia)w`7wbRf5#|MX@reU8ebi(P}LO8K37Mi~SoHetP{I(E`tppPe z)#ZW83AahBqQY-X5FS~f!Vq-@tMks zQi;q$T*-$Yxaw`M`IvH0`o2^fiUsu`z&scnY_|(#2JN7c- zTy1%xbEz#Sa(2+qkv-)!!ddFubaT^Gb*ljc*=b^W3Yz?{B=DX%h4xs;MG>@88UzR9 z@U>U`svK&hP}W>;@}+`P=J~@2@AAs{H3T#J5-H+QEA7IXym{lN_zynu-)uI`p0bbC z9{3gpS?(;8)9T`@GsQ1lC^xEUNB%-xdFyP~clKhb3y7hf74tbX6GZ;X&@I{R$S3 z!UQd-DT7>lFuPXE7hr7bWw;c6tNGq(-AwQCoA1H%8B|}_{F^TqCF3J0*S${8T49?X zUpZ%P{9a?`z+94HUy0wlWWx^Lxm)$BG>OW);T;+J+$fD(5VW01tC~abPPM_{nZs7D zG*I3I3UR(r+TcxZ0bW9q2|%Fvj^_D_QKom%jL?PWvCkw*V{I1h2{S+aEcyH>@2$i{c0H=&}si87gKH;z4Qo*2y z=ob|bqzTZ)94LmgWBJ84MXGP5Xgl_IoZHeNlYcJR>T_DhzWv?wfE2K>PEh!}4cwJ) zdQW|7$Zo-?jm4$ei>*!|l2wYcW-2|rLxFyKDnTqBvb)E_m?j7HrU6~tdO-lStfE&~ zz$|1(;Yxc-EK7$yxgi~Qb-Mg_Oj6~2sY2XK>N9q~VE;^f-9HbT585gCpeQT*(zaWH zvvF%Nc%8m2;9);YV-AgXAm5d5@p?LGP7?z!$zr9&5@DSY6&{B36_81sBv0ZCj=Q8( zi`m9CV)X9}C5$NO5I1iI*s*kyDD1se7MIRl9xFWz_^Q5i2)Xm%YP_;zX*4qDD0`Ib z+rXW`J%{OW?S~;7ACoRV&0k&WeQ(*$x_tf{d4BmjGUV)jAYg&ls}G3!;u{r#pRuEw zBT}tzlHEp$eUidfoSGcb`vobP7BPamBcWe`U_Jxzh}oktS`ZHkB)H~BJqB=jqaNGA zCT_s(ag<#vRLkB}9;e6w=Ky4sZ9(e2?0Tv%IQ->P{4Mq8<>rAf*XKI*c+G|YHF!9x zKO`nHif|ALj8$rqC|{B2 z(F+%54PL7gW;i2=3?Sda1!Fszi>J7}g}nZlFtHH<@~cNM6FX`D2}3H2z%OI?FQ@<% zoY3G$MFS^jVjpB^gzTEfKr}-Lg)ep^sHRttU_bY_Y0T>HZw91mq2HlaX&5K<$~t?o9DPb3?NY!J;bw%NQ^#i#o7_I(y3m*^!YFZ78r0yU%0h zR-)$sYVrWQeUwLke@y#KSXr7)D?Bhm*lxKmFyB0;>O90S$|LnWq|G9Re%5h}B^GKK zcRn4PFC5F=7@}AB{E|6BEA?*p4ZEpCn9vmf%Bxg^b`q#nr07U4-Q=J)br1tS!3LK= zeyF`)q{c(1&POzWqNrhysMT>W*=llEfU-k4aGLZA7Vrw}5?6qYGqQ;3p9z@ni>Opo(S zMRes;F!>>?qO|9I1}O%WWCR_z@ED`#3ia>`Kw}4F9hsP#vLDQFV2xh>QbBEDpue%? zPGj(P@96kwpSS(duz`#~x5PBfkU4xtOIoxMOB}srU|U6|ys#bRuZ-4#*e6N73fwf|Ue9}3Veh8^IkIq)FR7?|~OI-!e|PM!Bi*!tAf8e&haZbue?A$MGXx33@@ z2D0w`N~LU!&i2n9)(ly+jIP|KvZcU3Xv`dD%w5>Y+?C5q*Ua0TjmwV8^ZOHp3lC^G@IE9X%F`%MMMOqe`DhvcgRmWRim%5GtuqZ$z5wdkiEr$V7 zuRPLW6+_i=RsP^%+UB9gfvCnF)4Ri}e?j9(Z+@C5R$_B$u(?|US(9@4s@ky~X)*HK zDdkvi`{LB+(Ya|?McMw^`Fp<#L+0W(8w)eB54MV*W6$2iYv&~eqz++=r|hVfSMrdQ;8G)i7j|a;i{z@6zDewP^B(p3R zjx9X8a?4L{syY$P8kfrz3QByPUbrV;qT`-7OGM7pBIfb&Lf+sY9+q@RdFdBe%RIRbeKK083uOGj@d_$CoVnDTDY@4m5!@A!ft-kKm$zvX&1}0S-gf&>*X|djrVYeb zR?0QyE$EGv50lGD!($H&3X5hqP)c?+BSopyHP{0ZhX5O?1#C}kf$o%b%$Or0mH%{k z*>q1~x<*!7i&-c~3>swrbPf^gy%+kPw={_DAxFHs%6@lw%_5iZP@$^|R{9C6BR(C_ z^_Kzwnt=$SNQ6K@

    %cs;vAR!eVq7mii7mJ|csO7HSO-yQb2~*7WX&R(D%P-vqKh z;alG{ic)hpQ(CNlX+B1^rSoA~SNL#!`(EFK*if%xYtvyD#~^~;^*-vjpS7>YUI@aq z1u&98FmK2#85Pukp~^If{&(r&dXMNBhkPi&wnFXsthC({LlYzwCF_Q=6{;6uXY1kpZz|Q~1&9#QG*o|InY#|H?W`SH{GKN2f5z?4iD& z9DQ6_!#e3mFD*z7xc3`Rf=!u~seqTz*rOE?(7}V^N(8rD^(JftPkdkRX_psZB!bA4 zsCoXt2nL-kL@Kp%BI8v2~P7q7C+Js%;E;Jq{Vvf<$I@$(2!2 z-E3_%=wDM9)@-3{BXzNSY8u+39J2XbivJuqKgr73CmYx8Uyf8A9&JT^rr96;Gdw!9 zLq-nNj>Q#R`4+t0;XnZpK@>==s`6}%i~V`fA&#|?{{770f@ofvUMs5C0j9((7sbK!y~#zY;q4XkLM?O1ztMV}Id}Bt zW9G-GY!|n_H8vbpK|js&{cg-bu6_+_d%EAicrAzFT5Hp%g`q#w!+)!Wh@W%BRs)+U zB@Y@~Znhm+uE&b4H4v$8w)HVSgFdmiUorSv0M*P>#m+|r=N&OiQ~aCpSt)LI{&8_pnRO^!2qu%;$GD~Azmy=W@QzO^f7XFS7HSXsK z&!=45!!PVv?jwVrtvcE+e$H-dNThn(hL8t9t24}z)we>Dz7imx>K|dr55W}PW#CF` zP7FX#V*cP>dA`*1G5gWIyDz0~uIPA^-!tfJA|gvZA)6|YG6#({dh=C#N00UQeux|} zF0D82QT|u95E9?*`KQswYscZr_Q$IS(+*zKQrB`CDz+Byera7f*33libM3!AIND-A z2}+n8qh7t9{dv3e^UaZ|h6;pb#cMX%_lj>t5p%ny-&pS(^?+$Mt||s%KAU0w-rOF^!+S& z@x1+D{gd~RzT|PWL~D)SnqhnIcEZ6>@KNK+S%%~)o8G}I>Qx7cU(BPwq^|ABwD;Li ztxt`uGwxG9#z8Z%tK2z} zM$L6NV`-Y1B=EFN(akA#`h)Ggr>0%+CEj*~a?_5?omb4Mha>4nl;?*IN=#cx`W&tX z*0W)Ah>^f%+BNHN>Qq{N-LpMhXe0lf6mjn#%XOagWR#xy3T6PWtA}*+4m=1+gyeVq09ERv9 z-DQaE86Zj;usthh@|&(o2>HAl7~62NR{M~fj;Rcp`r&TC{y~oB>~jqOIau^=gzbkX zPaR4*R+@}`72?G}*!`MkN373%&Oc zUVom*k{J;+45E%zf-*+T;hUJVN=NGGGII~QX)APG6tadZm1E@gqH@LVBG#O%etWwK z;(lL#d)(H}YxDiq&y+{oE$$EAd8Q6Di5IcnK=Qu6IS&5MRsSb8<7gt6ApuhL5<*rB@&|EK-j{o*Z9Uw z@tf}QDY(Q_O$wYh8VpX`7=a77r8#O_|GYpjhi>e-ww|sj(~!i!PllJ*dpCxUBEKu9 z=-gmE_LOoWcPtzI{im9S_wiT96s7)tus7>18WScyxFtm{6cVbsTW2L^YgoW^s}+xT zC`l&+F&JRcH+IcF`Sviny?)Z9s}r>n%I@15$-zfVeymvGS9zyOPQ}m9MtMlSZs@h# zI=$g_A0D%+)(=z_mU7qAE81S~TNm9_sSJ~=9vP$8OtpTG6o+4ziPwDQi<$R&vFSuGQr@Ca)Ui8)YBkqt5iR>Bu_;x6&d!HDj22~K zWFGhayfZ=Q$F&RBytk+05Br)W^&UeCC47B8b8A@sZudIinzLjQ(6J3=nDSw*Na+br zO^qkB^m$pgSm!kGBnpWv>Hx5>EH`3B#fyo#Ej-G`8a}fcgohS;I>2vS49`JHt zyyB;b>j&`_0Se*~QbM{f#p-~u)21_J7H|~bp;o_ygTG2&M`;k7*6Y6<8fmWkoe_&Z zJk{qiMe&*mmf6<5G)&&1FdU%yL7uk2s;ZcKF#%*kn=oVKAe-W9aHH6W_}g^3~(RHkvj{B4rR^-szBOk)J=r91`4G?jlc z^bnp*CXf03wgg%F=TfVhcjI%y8ig08QS!cw<^tQe0mK(;z=XNpphq;ACo)-F4W{;% zx_j43tVKBvB<~-MBqI@MbR8AsqJW#>gG%eBUh+m8NeB}FOo>{#@~Ce?+}_7Uh8%#2 z9q!wfl~x9$x!2#BQ|-Hcb~g)4VXC2EbdWGXj$2vC)J+L@g51I2J|?x-G^HMU$!82? z4LC44ssqA?kK5ZFO3<+ann;?;A6Gq_4<{Do6`=ep(EhY~4JM9;>0T364$N3|UTw!LlxN^qx*}%ox$(LMa zt2g@rNUPKI zf}BjZ{aXnx9!b;e%PL}WV-VBuSlBbyi(7%8^94@w97`R`5o~Qowl&XLz1&n^)=yMA zmnIljB4bNJ85=>`td0odR2Nob`Un7mAVutVL&%AtwlNC}O0w%y0@vKjp0L~L-?&RC z*0+Vm+9JnvUd)Y0q{!wg>FvAUx1OKFL2J0@&1J~#y?U5kDNxGt82a7u9{xk2uuMIveiD3Yg$-uP={woH z$?eB!e3Ow+4@Tt#5GPF-`ZNV$C_9E!3d0-@!D^78mR{ZIT&kA3M<4)d(pBI<2V1>Bm zHjY#)iD$NppR`O>cU(YjL%TaChm_S+yTvD!r>s?PAGcT+bx*M?Yl^E@yy%4LiYW&x ztG6gY`Bkrilue_;lO97*-XKUC#xn4_eUON4@*AWk9zK_FEea38fK0T|qI1k*>6{Pg z2rvwRJ`GP^l-AcJARZN}cn-$6)^Y2SaMr3<$G64z+BG+Bt3vzqpc>va-D=6I8kylH z=sumA4)x4#EzfRk-P-|_eJUsIy1E+T`K{dkw-y`N;K3q(vCYAaBw#F*Za&%#jc35( z+2Hu?#{xP8&Z`;AXckxXKxCSmOr#hdeCRK)v!M~Bd-KGn{fUXzW6$p3nvRIq8nw;x zL19X!-dZe9v2T*K{;iZbsbz}m4$4%0Vxo~btZeEHp^u`rPQJbrlxFebhW$`8B9TmR z77WILP-yiXJm;oDSzZ*OJQ(0`?SH`+iQ|Au`Zwui-ewiouA5N}P}KGhQ=0bCN~i1# zU>JOQqNUN@$9kgUE3To_JrG!Tbw3^$ru5yethUt>_KCNtgvRwI;$#3{{@6+;z zL5{CRCUnFkN`E&$d^^mL@fpklI@0Z%+>;4IT!&el7@GQrTNyxTz46<2TuY_tQtmOA zVHh%uJh?vs>i?;PC6XGQ)?gpa{i}XknjKTZxPxOKQ3XL~6lV6Q$xp%RM1w2D6Ag=C zL)KbDixz#Z+Oe-3`YR`$6r9E87+7C0jQx5zy4Dc+Nx#2E-y&G;_P#z>JPciKz|pG3 zeL7*T3FEHSFVcZ23YaYX89`8uo9l)%?~n9!>#3fOt*VBzVG$dy1Rne9%S>uUIG$<- z50C&3(rDHSXe|o3&Yn#rjo6{1vwBPViUVFM8jBM{F%1y-8<<>{fw6a=d4;|WW*WBUI5qQczI|?t<_7O49tuo8E&D>dZ!Bpt zt^LfHyWGSpYmDlB_$_CXZ)IO7Zo)JqMrG3C-_V1YP+$D3;!%lju66=rC^Yd-i_zXF zJmSz)Y)!YqWV}0&Jr%Fcjv4CfVwr7uQ5b55coMD+oAjNU^wl#@ubs`PHPLCce6&CD zebNNCKankAMclW{DWCSuf@PY{WxSuw`ega&boN{KY#)bJmZ_C`ILyOz#u#p4lE$2Z zp-p2ikyngCvh`cj;@P9f1y>2=uGBfA+2a4~bbF%rV6x6T0EmLjEKmp~=`lJ&&7)xE z!r=(mT)yo>zVlqZnpJQ7Lb|EVK-L#yEUd45q5nyEdb~{$r`4dE)rTyYg)pp6IQ)kU z%mig}Lzuv15KW6h^onM8mljeh^CgRc5dL^5mQ0X>{0bo9HxqMFRn&`f`7k=;H$|Lt z&Ui9|**CS|*~w~+M3}KR%repPQ@o9Zh0WmNQbty|QPjc_?B4O;kt2zFqp-Q}J(j^= ztt|Y*jkcG3)nJC#!Nx`zFUojRQF&6za&R07JOipHa&y@I3tU zSF4FyLqmf_lfy84cX^%Ve_c4%e||SHb_hiXziO!DZV@uy)CQO&Jaw)3^ z60nI@d*Z1hmdtj7aoJsOnf=!Ke+LtCDV9twPPnh@CRj)FG}v1;n1&k6#Nfqr{B`d^ z=5Tv)vlzVe6yx7uypZXeh8K5eq+4d>VkmR*ROlt0M|eah@cy^8jdp`4<+{wlim&Oi zhW^}jeMh$JFF({a%+nkdn9N7?HZ#83+-ke)%w@$SxM+DkH_m8(E5U{JuG8B^mm|Fm zZ!W7Ny}AD`ziM0y*F121XlCn0Wi4%FB$8k~S0MuKcgS)jV@KgB@IXm%R)a{{$K>}C zPokr!5abv@#MHrN$>Cu9Ka4ueaK-WJ?$YKjiA67c$M}TJqaN2=OsidQ?m3OD%PhGV zt!!SuweU^C&3I{TT*EB(xG1e`qVB_KQaARC}zT$iI&&HCs zz?E$@T=O4#kLE1G|6?RDt`grLgPYCPn|5XCq4CUVcpwdM>vql}u^b>?>?XmYQ^KP! ztOzqXufoAxCS%A?ig2ikP=*ydOcKry0$ER)6{oyK3FnG@A6?; zcId|56wQ>>QA4)@cRM=wG5kwY0dQ7=ZwWP-GP*`CkG6`MRYa(2iK0gLosvHo!vvd+ zfPH9PIOuU@+jKO-+T7aQzw(mZJ3n<UGAsoug}XKtZ^L>3%ruZ zCePn2zpLHOKG)zZq^ta$>_|+)ybaIvUNKCsDHDkxLY^{s3hZ-guy& zPbzO>`1{gOGaLobuzZ_(u&)4zN@5^}4K{|v{h=oh8n`@{4!-^R>#CaV^y_qUJK}(H z>tM+*d@FmoHT!V$=OHEcgES_$IQ^s81dr{_{p{yQo)O`OM3{*tgf5Y=36YicK%CrV z%pBa44JH8o_)GrYnm6xrjS&CIqf<2J-v;4Bv;ZeQ4+f)mH&NjR+a40P!`lkHByPJ| zoIjQlf=S+XlQw^FMR8+i@you{9UshnA8Br%w#y$&`p3UuK8%I?(vm(Bkv>uywzsY= zj^A|i*KZs*Y0KB-N(sUvqP_=3MatR%5d0_{t&Y;X!GDFO?qXiB%Vtpmkf=k@L-2G$ zs2F#+IL-0U*B`ReKa_Hg&1jA#X^s_M9-EQ-{Fmcn(f;J_mWR@`SC^U3-9n%L&bEyY z!;FPNtOg?Ys+qmz2^+L)wa`>N+%E5g*a&}Fj4S{}sM$uin8`AP?;6vMYlHYJ~ zbW$@f{2zw<(}WMHJt<5LtbZ9;{QZ2aJ#a$u?}X&DG4sC_cb-kXd{%xHIQ22G^65o2 z&AAck?^P3xkIB6Y89XStv}d+;SVt)-*Mb1S0UGU*4lMYSOM7UbfQ3(VmU-bU@jaq~ zFi37AhK3AJ2O9z~L)UPF{@-7?VFuW%h0(ydvvUJsSfj?X+0^|nsega>g?t&kIwp@Y z0F%>+W3|yDgj{6_&mwPoVS@^?1ZiieDg`adOcMoCR@I>8QhUX}Lkf?gU?vM|-umIJ z$PVHS=4X}WA9%^5q=^TN`1L6m_)!uRt37xJ$y8~tx#R^#A)h@(Dafw77$L8YDR}11 zDybC8^IX6mGbwBUo}x1;{fX|r<2+Bz@FcMu*NCVc+1Gi*Aj&2nU4q9bJAHZ;6LRHl zlhpBI!T}<9zL$0`xITnS`&4_hXjNg7f=#HxX zIMU1c`9o1X*^`j*j39}*jfeMXCau{6Eau$8L*}0S!7i;dsW`*bv=7YgVC*PeXn~^p z@kF&`Z`2wHd;O1L(=TeFBd2afd1qLy9Rs1P}WG6;hEzvo#k82nEFM? zTFZPPjA&<(8NqV5XZ699?RD+&A%X>Gw1Bn+r$3$k^lB83(adU?xLKM*42KIWTd2r_ zM@5~tXa(miS02ft&Ihe{Vf>l$P+9NS(S3S@%Tx1Y4IUdD;6@hsmW{!$?RTbPXD+g8;-iyQX?`tU*Zja5=t2=D`TmI zKvj(GI4B*->^h(tR&e&3&LpQ&vh@E{S$!szJOooLIw?L-^M3Pul;#O9ugu{u;}Pgp zE-i?lxPct(8fA;I&!7?dGtf0C`i&=|gNfWLviDkWkuXh()J!cW=i95-hU6`1l9ayJ z5ec-}S@yXIjho9!RB2jlCz;HTTzQzx(-co_}w=g;I*k}}bW_OdagxgRIQgnZ=oV~n^x25< zJ77Og^yREUNS#s6Rle&vOW>ep4VXUlP?gPs6#6H4GvoIvYv50M(4>R_D+R6t#6g4r z-abgN*%3S762lG+I8!ueIp;N zMB{7VE|7UK`RqaM2h*=&W{tajEuBA0?G{DdAC;Qk4y~aNpD_O#B;OU(SK zhxz+8pX`kOEe#J;zIO^kjOrs2;$J;1hi-z%KtF&8lpe``e4u^pH9$vYT|z~Pe@}Eq z7-o5!Oo*D+W+bYb@=4h==&yZzep+tsr8U(qT1%>ngAzJ+rvUPqdh&zsAwkWPtrw;Z zI;Mx7mGU-!tt?1?I6vIGzG`CHWKT9B5Pen5UqQGe#eymQL10m0a)IYNFbxr>r*Frd znLBj*%8)RGu5d`i0{^Oa$AYq6vE>C4+Td;9jZf#7m$ZL%QXhCdrwX<+@l>1P5NUDI_ow&f8HH`eHWNJ``84?t1K#;|TQ$hU!!}C4b z95r{798eZkfJ7iGa~#*FjbtQV*+ssOx2I2P_{i_z_09MxE8X7nv*J&GA83%+muf%U zXgecGqg7PUSD~( z^c=yok+CBrX&Prl2I1hhS_C(qsr327AMc&9=eM*@Ab z;`s8k4n(etTm9^W+)QWynyUnwzH{~Jqe2JuJraa7ec5ALEa!aa z>NY?|1gO!V%jE@IFe-CMpFqmX?+%gq437gKia5xmu5m>N1U2A-*Wa}3eeS6rsFtb8 z5CLt#L!meX5vS9?Y=pP|TfW3ey30FE3&F^lG1vD=>|?!ULC9_RX3O}Ttzhoa`$ z|4T$6-qBpx(Q#ezpxAh5*H-4fqInfN`LLnUUK3jOBRpQ}d3Fg93=V?fFfLPp*a0vD z(w3M0jknW~Io10pJ#aS&8JNY`g1(dj^O5dSfjjy3&~#ipjMThn-c>Xi5APokJuesy z=jAct;g#p*q=Rrf}01-$Mkp3DQit-7hsIcLuhro^(c%+tR@slUb(>Oh^aCM>x-PqkzQN{j-F^Lr6(8D(m!GIaPZ^ODj??gt8TID+?LR$8<_HE%EsCVy*bp zUGmkH*JW<4^SC++JkG=NhH|@ZXaw@f8LbM-^2&=QsAEZ5JC<nqvl;+0LsF1Y zlX1lt;7D|{8x-5D>|AtBd*uJkhCxYAFa{iruoJQ*Vwb9uLpYSLA)A-KlLynOZnYts zy@8I%y^*k?nY&?rmv7&mPtecN(ji|nRDdzT@xPJ{z6&0<%nmynYljv`E&H%hG>mhc z1%e@w;Q$Jbf&}~dAv+2q<;>ATRzm|4loC(w%Wl%tJ*`C8oh1~AD4UI-Z6dA&gc4kA zA_}y}xon>2*{H8uQRiaY3atI|EX~%1ukmVFt?>~FV{ZV2E`D@@CU66K2W$3JLQTPy zWM>5AQaHo$s*}$U!`+U#?~C*|||yg(;+Fn_?SEsKP&{wZ4? zodtpELIDN$gHpBv+U^HceGN=kG3pIPtvx(hk8F zTUsNo!Bt-^>V$$Xm7ez&#kV=fhdRfR74vX}@_0IiG;LEd?eHaE@e#)Hc2PK}E-o~p zdo2^kxWfPgaR15lC~S}*nmhlnxuIu~y@0br8lEDI1Qy4oJB%2Sksx+>U;%h#f8WoD zu=}ZlUdEA^p_3AF@}K@q6yso_j4i&{hx0n>Wc>4`qw>bxH|KwMQeE71E`C+u^u&d#gZbv z6=qteHv=WUmNg1XZ?!KKoZBP=!Xf9st2u8!SbTl$)f^<{6X?sA)q+t^r422U{hA6^4Oxn<~ulW7xz&tFS)uG}^g2lCLqWv*@ z16Cdb>EgK&o%nqv8TXj@@}<|>xcG|t zgXIem^a&y1lJIVX$oq%Dm`$Jrt~yXe5F1>H0_zn+AW?7#!c|`-O5sYR!(|i)01h$( zQR54YdY*1-j3JJNcY$n$#ICCH=!2KZ+79!f66c23zfDwuKkx`EuZ4=QXN#Yxe>}bQ zaK-B3>0QY)7s-CJ?|teIc~3f;FFTe3%Xs!W_|gcdei9|1M4wOCO2KvIPDjZKK@;s* z0y&Hqbm1)OdYQ-|#m`tCiXx``@J$>CCEHO-@3fv0moBUdti1V?z`e2m)9)eKQ^|fh zH=efhjpV^qR=X=dohcNn`KEY64Ae1kYKvO{?P@i0UhJC9Fcja>pQY}RzbHOEpM9QdeAK(7{2*-Y` z!tJBPEYr_bh3xtv^}U085`$7bvg;=?n&?Dd%tksSZ0GYpEcSKERQ?H90`c^6Fg&CN zx2^{uC<~Odg%uUl6bw{oYE%@>tyIWDIr%@T|1L%|`~JH=DqD|vWKNW>j+Mk@ROnA| z3Qr^@WiT|p#t)yUIG(Cr`Iw|i@hty`{07>R1yLQc=IlG7FkaEOK0hzR!?6IHAI_=& zj_z?B5>G-H3_@FQKv6YGK3twfg3N4pHChW9YsCbHZ%7&FNeGkRYapDS7A zpfcl^r^a_`TweaXfBV!F>C5w{nmhTC$7@NR?GCQE13N=NBdms&MQMogEj`~NT=x8LD?cvB#I1qp%_r-%LA3{=JxQoYUx5;vERC8}DaXHnI zXZWdk)bgHyxMgb0@?=%&pIS8Euo$ZE>-2lpSLx9%+y9ebl|i6!3WG2dz%hd~MID6Q zw>iK3SiZRFh)L;g=0Ycd1{p5E8=o)HgC&93eQ{)HA+QaAXaPXMKxy~!%@%EyIVCaU zI_G=d+%@%PuOD(v-tatD3LLG%oq@PEK!NS&fgf+gcggvG&GafxW@uHlhZdLkMUeK&fiUv?RZxEC?Ke5G0}KEv$N5W#KnZM4 zXF$LKxIr~I!y24`0iZxYj=WGrW&m(R0Jwm}Tl&f9!c zTXw#ivChMLzUTYA=lqYy^3YedzPEe7zdO-0I?fM#83V!@RG$otKc(?Nb zxZAvXH+{VmzTpqP;eYp$FTKv!eBwVo(wn<$o58E|Fi5bYWgM*fjQ;=y>;QJ(!wp=( zl`alQlt2sAKoC$|5}5#^jlKB+1$Id$15|*Sv%EPp0X+};9K`(0XFBBne&R2F)8hf~ z7ysiAzPXP9AS}YvJM9O?B;#?$I7uMhH@6bowN4?%2&@2<{N@21KnR$C1XLVQG#(1X z>5;MgpR2}HsCXXafgp7IAPmCe6Tk68ejVJuW!u000|Xy|eCiAon5U1QF=Q5*5h82KYBimGPP(p$T2@*<-s0aZUB$kjE zf&qpGZ$=h1dK76=rAtMcGcx6i9XoUM@DWs~&>*XP@Zb^H)&C$@u3p7{9azwy*MeTj z5)`<0AltWY4Z`i(Hf`CjZPA7uNC;2DGGwZlL9+yiPl*y-j@Zapr3erX9^62BgM)#I ziWg(t8RF)F5j9q3yeILxl6;247bW-j534(LI^a>Xaa`*I2$1Z5Xk!}f()2B>i>-g99TgjnBwDUB?m6j$RZOY z&<{1qDoTNYV+@>fN^z`k0*^27z^$r61Q7(eyTbepLowZA&O)$?BXch?)pCxwGRN90 zPP^3V>pDU7ND+t`d{|R5pj^Gg zV^1l3m|+GW&_Dw`7BEuDM*S8AfwiN;>3{(h;uFEW$R>gbQ;tCBh)4%on81J=+94I* z*T})*)GzX=BM&|Bz)Fw_hm{l9Ib#+0I$D1XR{vM&1S+^hw!l=*#JCFj601P;_-+Om z{A3~xBMR-Wq7lZkw4w*%;L%6-T8J;D8z&NZr;J=;%mD~q2tWg4;@w#(a;%VIkS_wM zW7RLe#KSi*$6UJCFym6QE2U$Fnrbtx{f(iyS>IMcVP=V3|c)Caev{JZ#mRd#rm6y=jBHAD{g4w>LVE zGR|m$vHoK4;fgC*XCYAt+Rg|y2}CvO7y>BRASER@KnVC&z>1(oG!mG=05~wW=poKj zL9@dh^ng7<1Og9txC;iO#<>n2?Q$IS;IE_x!V!wFD;NZm3NI%nrJ=Bc2V0?->|m=w zL}(CrAj1%3AcB*WfCR5QgAe)>xZ1f)0y{Da4+t=Um6RX^Q5+t)#5FF9pypf@@IWyh z7(H>&t9nGMLm;k#LF|Rlg)qb*3TNo13%0O?E*v4|#Kgi8#t;uIoFN@ID2N*lB7H(& z!3Yd6DH6zl21-bqMjT_iy-^?}MgOTs0V;4K5~KhDmm=Ooj0b__QGfwF=wkF}Lj|GD zVGeY#U?3)FhptHFm3VOFEO8}ESIUxxxXh*IwpKpvaqpG~3+6AyfITmzFENx^2@47p zgds?P1=kAF1SpV!qa=d>Iiq>Xx6hJnCcnJTmCbb_N-|?uNP2V z5)_y=)!a?pL`zuGGnm&C!~enraR)OHQGxJ5jS6U>0~&k_i#D3T19WDT4j^D98(2(E zGD3pA1!4qPo(83*PzAbIT-wu@ZkhuwYx+yW=CYr= zv?VUbFp!0o!3QMx9eJe1OdZ%~GZtYR1|m5UY9t^9E19SWA`k(dkU*0`f&d9<^nd}Z z0j|(1xT}Xm?1eD+?RXSo#y6V!B@Wg6W&g4fmcrt>sa5nbhIJa}Pd%!MQ9Y zE!5NitHzr^0BoSUqO<`47Z{HS#A;dsUdlb;lFtYzAb=aNBerpcDP8UQrNR2Oxyk)& z4e`m`-~Q65_B5z(@c%nLsmv0mH{Iu#>M#W%Om`yI^+^lFRZ))!0Je1N0F%PC5+?CY z1(xav1PtJTXv9~(P+_Mk$#}t@7PY@Py$f%Ty1iNMGq12buy69f%HR4|m_N?%D-nF- z+kPn!cc8-(h`1TlC}ssB!xViUU;!nLL>&akfCGqEnzLRCCL$|j3b=^k!_j66bDc_E zt@EV`?w6i3w(*Sr`&Swob)LU9ZXOV9OC8g)xBN|TbLXtR^W}>UXGjcZ-X;PAxWG~+ zfItf(@Bj@sP$bDn00x|R){!k{A}WZc0v|xmjGB38^Ewq6?vP3iwmFu@z3EAXACUI&uL5h_Wd0utB(Y!jfyJBq9>18QvU#0S0W` z9qm3d7O1DCIk5SzHB9VsrQ%b24^`QEMw%=cbYP$7hLx`LG0%(b^MKw`g9kP?9&$L9 z!6KKSWGKTDK4qhc--t*k2mmsS5)A@ifCA;(n`kYff)+$X1p&~302ok!uBv=zR&v4@ zT>jh(9{-%qyq$+z)3eFt|LSc?<+A^PN*2 z+gaf?XYQ?yUC%jq;l6~o!yt;BK|b$%_=K0`f)eiM0|Qc)Kvk;4eINr6m;fd=8t+65 zaDfKAt0+6Lo3~C&q;g}#0R}kN1Q^f&0GN~ZJo};);B7rRcy0mKiTH*i@0RKi} z9se`{117~H%*vZY4u4AE1wtSID&PjzKpygsXXd5lTCJF*A^?Z$0D-UZa?Aj8%#|Le z<`OFpw1W9&=??13_!cYars6hw?s|SNua>RV7Gx0a;MZF14tNih9;YD4z~NX&1Sr5G zMkXcfgEG*gD2$s*nzhZTBLtx$x`=kB;Af zPwAX)3nOoPbW0Pzpbp3om8vk=tgpxfPq%PoL2TvKGN_dbun)w549tLaG@>+a#86n^ z0V<%(NWy<8;84cKtcC{yazg7O01n&%9tyGce&+V-VBVyn5ns(2?H~~3%^7XU*#D-& z&UEd*7|-W)&H7Nu0S7A&PVrvw<@sJI*cOE8S`8ePO)8>LdoT!=2+H5Kgb>8w45$uM zEafy*!UY(B0o1{(5Fi3xzyVyM1nB1gN+1S8-~ucz0eB$vkP(9DB@m+G3l>rLCMfw1 zOdi)L=zgyw@oez6L6m`Fy$BjhXFLe+wOrKI)DH!00kZ@B1(Wh7Qh4$fB zrO_E#Y4@bDBQH=be-GH2@Th!a3?C;Aoo_Cy5c!g?3cI4!reX|rOAD3m8~-tJE@esH zcE}CI1+^q?13)PUjDi`oj6Faua7y3=qG$jJpbI)nD-XwKr~uyTAS3^8_wWELLsA-p zE+m6a*MRK#9EFEIb|<$8)4XEP6y4iqi%4w&yHd(P)j3FrjxE>TGg9B~dDE-@|z z1W=2-Kq0w&<0Fk&VQAOJi72bclnWwST=lkT2i4vJF@?otcK;0%OdTE0ml*ed{_ z!6-bS0;baeq-6nUAOsvB1qfgV#=$!uXnN@G4!)8OPIG8{lY>mN8~+tAC$X{FI?~@B z5F261K0h&o=3qhU3MOqOKAn#4d^7Um6P3Jx?iR!e|FburfDDM>VKH)Pbfz&sb?>=?(_=wa- zI}t~XbSjKAK5J7*k?#vM$cE}bK;<$>3H1z^;4m@8Gbm%-iXs^(0PHG)1#Y4S3?Kut z5=Hb<)sqqc(LEQ125*wFgIWGz)u^ z6HRhRzu*Z3R6y_YBI_Uu%0O9SLKBP8GfDns<_hO!_41^))X23TrSALty6z?9$( z44$Ak=YXBU@B^7K5WJvD-G*5BV=@yYx#g&zwAPS^F2u#2y7E~oZV)lx{1}K12YQh0PuIayV0E z4vw`7V&uz2V0juK7w@4REWjX#QR{L5TR%2>$l)ovat^>1l~(LOzX17c_W17Q4!q!O zQML+ml}E!CSA|py!2n5d_CI~JH+Ay(j1*Onk0$vO`Ts~1V9`?Qm@Hz4Cju@20VYx; znjruTasY5305aePt`=*d$7gJ#3hQe3Mze46%?m&?Hx|STJ{3p#l}ODrE)CW4Hv_ zX#X`(eYS(u6o2jXN5wV`HAsvD6*PsGdy$lldsIlmN>UqXY*8y!Fg^&_;jM-3?hW~VncXLu~WBMgSSSNG(Kk4?CY&utwv`__GqL+Dw z^HrMn^=6k~21p>Jeun`nRwRz$0{~zh>^gdoIVxHWEXh)b3-uD;xPyH<4Qm=4A=*`C zct_b-ux;D5)pv%UfXUj~MmB%};2`|~z;Hy{q^;L0pP-*9@C$Ufc5Rw_aW-E^IkxYX zjqw&&S9@Pc7@NJijmudK3RShcRtgSy0e+hSG*u)Nz%q>cuA|z7OH>-gmJVFq?AT-hd^Tx&neTFTiL;cgdA}jL#*eQ!z4*%OfDD+7 z1gNt9iUJunyvTp>$P;my^Jq`$fch5ure(>>uY5>#d$DuXKLyWE4VzAV+OQ9sIN4AJ zPCx`qjsuFK2YT?#4YB1QSwQUo-kLkWd(`-#oH&`WrvH3yKUaPCG(B@RNuS`h6}pH0R6DVU_mliEqJ$6vqLcjoDBL zP5_h`;O*vJ|7bnl=s*n4aK*G*9W5Q$b-b);8qWh<@U$CWMLoAOJ*ew;q4SmDE1azm zS>kyH&1fqlJ(xeib!=}GUICl#(3yKn8(qm*)crJE<+ZG*!a(nwb?-8!J9x5*6SiM2 zovT`_#o55?z!imH1`dFEFfHcc#T>8zDryT1hA@v({ICC$40WJ+{U90mT+w zzuLNAa?gnt@3WlpdvhTK$$lCD@OkE>X-mt)wQ&mAPH`1pU#+3*^b~7z98>-Y-d5oA zwr|_@XaAS!#d+v!{LvFW%5N0KZN3iZV4YE7%u7FBPQP(7GF(|Hh+&%8pTJdNTJS7? zuy)q*pPtlnb9%Kmdp+t-fzlfPQ z=Viz`1phOFgjtZKL^@7{$Pn>h$GxFMiyA$OG^x_1Oq)7=TC|*zGG7jQf%3#lRXbp6 zHarQFWYvRp@L0t7! z!M+4-1diZ098D*>oq~9QZkY?({1i_Pzs!5HN^PK^)EQF{dv0a{HC<#$kpj8!@jB}9pA$onTHdjU%1=<-{ zW(DV!tM;k6Wu*ntF$EDMgit{=p)MPwJ8m!m#utj@I3XTP!emukEV>pYSf{0A2mg8| z+HsLg!scX0W_L&?tFOX-L{hl4`c)7Z#0o(|2?$WbY`+S!0<9NdL?I!CgoYq?zQ~oCCtgeDaQ<^zpx&#R(R1l88COdZx7MR`vhFhtMpY96WCb8UPf*%JvP2vG9LRx9RC5L1NlMId1W z65>FBN=x=2p}7W^M`;aLF@`g`&CzK%G1_)Ta@$SOp_*xR2YOXvHe5#)X-7EAQGg-D z0t*lz&DD-0<^~l}gh9D>U7bn?%VBKx1;mchw(e#EPh@Y3DQ0`AYY!$|+5d14p7!LE zUqmLFk$-Y0Qf;-*0okxKvMjLa+ocG`g-;F(1{H~)(7`m1KmXJ>R&2+$evm=N^1xkX zk5KF}A&KM@NVW`_y<&_1gq{hl&;I&i*jrirV#MEm{qrYT|MddR583?*fiVX7r7wI0 ze8P5$^#ccZARf?bAf4Qh1u5(y5KMZM!b%sd;Rvrbmgx$T{_+Hx?B)*h8&2<@G!PUT zt%N76106)jJKh<|g~Wl3lVm8v*o7}EeM`vvI-)=9A;g1S5g4YbumA^Wz=2Fm3OJI$ z1Sim8Nr4zd<%Gth3O!0_OWIAtP1P_8> z4I3Y(lDeR=Dp07x3=U9%CJNFhtT=)Yp74b*SaA?u>l_&M*f}PBtwPtTAlT4YK`>gY zGnVWkCo9-FH0lwQRKy|{DaghyqSBP0q@XKZ$x1JQVF^9}fdB@H%X_fH4M%W-7pmwr zEpDVjG_yc+j1R-)!N8&&Kbjx`xx}S3 z+|UF%P_B_+D2o{KV4E+@CzR$n$k_1mg^hp+TXR{FGo>W459u*AUqXrLUSgK+)a52Y z+b5O?6&n`{AqFkDWjP0ljw=*NE0#;2gd`*eGUNyf<@2BzPXCJ1l#*e75)z0&o*>dB zjR7(sP3fryl2S2zbblv>f=}G zQI0eSp$vO~!W7{5(I`0eItJ`Y6s~uww5HXCNg}G)+{)6WvJ`VXb&^usiqw!Ib)`xD zXdQG~Q?W@%d>}x}F zy3>{h^`Bo2>sbGJ7reNI4l2+9W#xI-yav@8G|&J%_j=gGM$j7?5bRrZiZ{K_0R$apf3c&Ax;}RJSD8PONj_?LX1KGk(xWlbh?gm8r;S@g^02+|(iff!% z9&q=@KMpD$G~fduFL|8a-~k1geB}x<#s?IDW0uQ&IqFb=0z5VIoGa$#=+?Q<4YLCU z)cfZ|ZwfL1@B!i$ed$N3xdL>}^r#Od9yvEqfO4dc^&TkT-B^!$G!*awd2~JM^7sI@ k#~yX9XB_QCrv@^_&i1&=eeQIxyWQ`O_q+#b9svOWJ3OQjr2qf` literal 0 HcmV?d00001 diff --git a/art/icon-80x90.gif b/art/icon-80x90.gif new file mode 100644 index 0000000000000000000000000000000000000000..ebb2390005ce48bf41e6db5b428a18ad7a9bdc5e GIT binary patch literal 3392 zcmV-G4Zre7Nk%w1VNd{C0QUd@3^F_eJ4_5bOa(SZ6Fp28J4OLLQ~*9&3OrE?HAy5r zMgcxy2SZI4LrelgRSZK^0!3U3MOy+%UJOcH2T4^EL{u6?R1!s66H8niOj{U9RRdC6 z8d6*(OIRmSTP#UX0!CsAMPmU;VhT)T14U{9OKJ;FX$nMY5=~+lO=JX7WDHVe1W{`X zQ)>@eZ532#08MfPNp%8Ja{yF(2v~O&T6HN`W;9!8Csk=SWpWu}cSdS=PH%WP7P6KJ-5q9uByDSDl!vTKD34Ou< ze$WMhy$XW92!gc~g1Z@nw-ki1C5gB-iLg6?o>qjCW{H<9GJ@ih0+0w(g%yx z43g0WlGYTI(ixZ19GTM>nb{JH)Fh6@B#y``lEy2O$Rw7@Bb(GKoYg0r*)pEjJD=4w zpV&H{+c=uaJD}G+q1iQ{+ApEsIilh+pW#NG$U~ynL!#MBrrJ)a+)Jg@QK#Hhsoq2bH@ zb-Cqvyytqo>2$j4c)##`!RLO$>3GQXeA4}U+W&Uc|7^wdWW)4_sinqt2y~u^a*@eN@n#R(n#>=S6)wb2zvdz|k#_NU2?ug3khs^Pd&hdiB z@r%*(h1C3s)BA_i_mb52mCow9+2pO?`L5XJt>pWy=>DiG5T_CX>@2HM@dak03rDV0RRB^04x9i002+`S^xkD{{Zg^ z97wRB!Gj1BDqP60p~Hs|6~5`R<;D#jZz5{k7?B#A3lc<#6ait!F^(ux7JOp^q(})c zVcKY;vgSrM6GX%e38H6-5;vM1T;+)jm7_?LDqYI7sZ*s=q%<*7BjiY!BYVQ!Qczi% zCu0^hT12+2*t2HSsx8~7ty;Ha$Ht9|#z%>fc(Y=?fQ(?8Igy5O8%(&c;lqd%D@N=s z%U!E^^Ns+)W*{pmn7n1nwvF?)&zwDf9!;9G=+2u>gZ3;sbT&62bV9~EqQyuOBRmKk zH|5T+&A@{TA5Ofu@#5R$jEJ0d1Q**dLx`Y2Qw|tQ*tTKYzC9Z@@7=+3{~u4jy!rFl zv8`gUJTF!WaJ0OX5S#ivWn)flw?>{nHvjvX$De-#7T6zp*!U8}YBqh8$}6UxpcWDB_4D7N~}F?nNj88*k(!VMq~laUUI{Xk$$^8djs@jyv9% zBaS!n2&9le21%rmtVqb*4sU2cpI#K+H%E=t_(J5BRbr{-mO}PYgGjOEH9-z>C2pS)=6hCa?V*zFLmx&XD@j2X{VKQ@~MVwk&U1MMIelzWS9}; za32_-6l$rTfchfnopxrrX{VspnIv-~wULYm6XKQTbjD0NiY~hJ|B{O?zT^TZptAxB zYplJ%noBOV);jC1y8MbOtg;r{tENhjDgp>xZ6Uz~IjI_w4FW0S1tq)UQtYqbDhqD7 z#P&MtxVC=#t+Bu2l8YS9iXiD5AyJDaOp@NW?Jn((>u$K{;v(>`xBTlbxCSGfi@U4n zz+gxcWROt~BgAyC2$kteiNFO5?D5AShb*$k3x`~?z;1-_um}^#2;m4WMg~(xQc_}z zEw|*X^Ugf??DNk*tMcV+(~59|KsPuG@zL4NVKdIP>>RbuQ|DYY)mCGDOD$1%y|vD6 zOc>@%E#K1ygOQcpG$mZO?e^Pn$1V5VwFv#}*e~sHk1NZ z`RubPoCKlY@)9ICEtFSo`Q?~ret9jLQ?5!7sfO7TO>d;&cL*WK82B8A#M1feuxmcc zER`!qTTD0z)CJmCL0pXFth;W?E5sLX{PD;qZ~XAY&;E)jrXUennipjBMg~~P{1R8d z|3N(T;D;~%_~eWKJ@l`*^1LT3Oc;}+`SOrc_VZa)eOIiDQhq6}sBelZ(BmHf2gtwS zsqcUQgkAyxn2Id8r&?TT1NL-+H+$)XY26b=DM(R@4th|4{d0u}`}e^PhOmSv?BFSA zfTlF*?H+81z|qa8s($2)$aj-lw|9`y*wPFNqFae@;a=&}zfOk8YfFcu;|H?dQLK2Y(s6YjZ&Vd?qpanfBK_`I) zY_jYE$+*WcD1ZXIy<{XDI0--LkOxUf0uqpj1V~3JP)Hzxq#q@zNI|+%mIgGWkr0AI zC-A~8R4YZ>TZp#ukO-5G)Tbu}=}8em)SnWys7FnzQ6Dh_p77*;#>l`$X~;4R@^cP( zAnGBK%GIuR^$=V2DpwaF1E)SKUtNd*>Q)vpnt2neiAV%kw>np_YPGI)MZ{e1n%6%d zLavVx!kR_`0oCmw0uX~t2-1WBH+s_xdmySI3}M$pOjfIuwXA08I$69@wzGaM#3P!} zgc3{u1k#y69PR;!2|%#~%fVM0e%BBS|K(w_gqW;ucdOgn^7gmD{ljF@FoP@5fIceQ z=MEqPF$(NpwGh$P9&+mk;QE%ggvhQTe9K+zR@VAMFYOrQiosF(yU@Vhp+HbOLIkruR&0~@@zwsW{ccIQiB z`VyiK7oM<&F-+kLci6-8)k9N70E71IbCe;`0UY3vg9$`n0w{1RgzZ3xLh#|nIL@(- zb4-XG`R1>0*v77Qw()@NW8Oo_HK9f)jKyVZm4cD&`?ZEo)Y z4`UGQduY;yYGGvpx>2_m<}h!18~or1KXx6OkY@-0uHTEL4-Sqo4V7q%;MnFiw-L_m z2p=2c2xm38N0I?*+`|KE|5}skYI5;v9dewB8!x(-r5=FM*0uk~6 zZEezWJAho?G>7@km%eJF-`oy4x5F5QtP@4rR0JlmN#F)PXr?>8<{$q$)5p&AFU)}n zkI6_EF0g~4YrW`X2RqpZ9(ShG;R|1Yf(%6907=~-2NBi!)|38qvFE(*OsD(J>Av&n z#Gwrx(5T>>His{W9r1`CxZ)3gb1(oQ1RS^rGFCo$DG}W4m{&aJ5l;jXD3bK0*A}%e zUw6*0e(ZEu0tt@Rm(p*Y>rYQT*=>*eRa2n^!t{O9=s^48Xa44#=lsB>zyeDv|30W+ zdh>B!ch%2*4o+af|30s;FE4ms_^T)Ws>A=t>!&j6aliceS3Uo+N1^)U7YH-PVEg*V z9rgalbWp$ol6QU100oMNcejUrWCsN$AQbs`51wFl(l-ZmV17AgeqI0u8fbwQXnq{H zfnGod8K{Bg7X>8{4H0+`%s>T!5C$)Ia7SlwGx!8Du!8#M1z$jdbN~i(FoHZtf*crx zJZOPJNQ6N+f;NbQ0^tm9Fa;MFVcEBRAGdnhH-IY0gySFwtRM$+;0d1Kg#@{&;fObgKuDcc}RZA*N4~FWPs>N%N5CA)90y>lc literal 0 HcmV?d00001 diff --git a/manifest b/manifest index 0dcfda40aa..71bc736efa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Typo\sfixes\s[forum:c19bbf245d|reported\sin\sthe\sforum].\sNo\scode\schanges. -D 2024-02-23T18:02:31.402 +C Add\stwo\sGIFs\sthat\scontain\sthe\sfeather\slogo. +D 2024-02-24T19:58:15.434 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -9,6 +9,8 @@ F Makefile.msc df56c06ef05add5ebcdcc9d4823fb2ec66ac16b06acb6971a7420859025886fa F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 F VERSION c84541c6a9e8426462176fbb1f9ecb5cfd7d1bb56228053ff7eeba8841673eb6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 +F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 +F art/icon-80x90.gif 65509ce3e5f86a9cd64fe7fca2d23954199f31fe44c1e09e208c80fb83d87031 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 @@ -2162,8 +2164,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e5db08993127dfc18cc2b621a13cbfef52974f0f504f4d8208093bfad1ffdcc5 -R fbd01c060093cc83561018ffcc839787 -U stephan -Z 3309f779a4e95b40300e717423266d54 +P 67d8bae0f695c0839e724c1aadea0a22f736fdd9664d40a29b4d82c91fb89ab3 +R dab9490920c21cf9a17070c8cfa63576 +U drh +Z 37fca3febc4fffca5469b7a46e713d26 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 75ab08df22..ec8bd6f0d0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67d8bae0f695c0839e724c1aadea0a22f736fdd9664d40a29b4d82c91fb89ab3 \ No newline at end of file +5f21e6a8ee709d8c5ec12c45e8dc702a7d0bb041f31b5715e28cd904dfd566b0 \ No newline at end of file From dfd991c3b947f3d746ee56ba3295acd8074eead2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 25 Feb 2024 21:30:33 +0000 Subject: [PATCH 0145/1030] Make sure key comprisons are done correctly if the index key contains NaN values that have not been shifted into NULLs. That can only happen due to database corruption, but we need to deal with it nevertheless. FossilOrigin-Name: 7e4c743f9e6ef33500795543e6db9a77c533025bf00c2ee97abd433a3871b5a1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 71bc736efa..034aae79aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stwo\sGIFs\sthat\scontain\sthe\sfeather\slogo. -D 2024-02-24T19:58:15.434 +C Make\ssure\skey\scomprisons\sare\sdone\scorrectly\sif\sthe\sindex\skey\scontains\sNaN\nvalues\sthat\shave\snot\sbeen\sshifted\sinto\sNULLs.\s\sThat\scan\sonly\shappen\sdue\sto\ndatabase\scorruption,\sbut\swe\sneed\sto\sdeal\swith\sit\snevertheless. +D 2024-02-25T21:30:33.710 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -815,7 +815,7 @@ F src/vdbe.c 805af8bec9cae76a873b0ec4c91c3d1bd49b38e86c1c533ed87ec7a07a5042a5 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b -F src/vdbeaux.c c5a471b34e9c4cfc0295a3e10734fd197670ffaebcb742f284c8e17e8026ceea +F src/vdbeaux.c 56900c9a41f23260c8346f212bd6005eb9171f9a2f70d0cfb1441a078a0e4b84 F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 3e37dab421b74e9ce55c1e88fbc7bc6fead590b5ab258bc684f8b70abb1d6e71 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 @@ -2164,8 +2164,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 67d8bae0f695c0839e724c1aadea0a22f736fdd9664d40a29b4d82c91fb89ab3 -R dab9490920c21cf9a17070c8cfa63576 +P 5f21e6a8ee709d8c5ec12c45e8dc702a7d0bb041f31b5715e28cd904dfd566b0 +R 6483dab5f9a5754b844e2de29e4108e4 U drh -Z 37fca3febc4fffca5469b7a46e713d26 +Z 27901e47f4de6ad53eaa2c16e520ba30 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ec8bd6f0d0..ccb9a0f0ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f21e6a8ee709d8c5ec12c45e8dc702a7d0bb041f31b5715e28cd904dfd566b0 \ No newline at end of file +7e4c743f9e6ef33500795543e6db9a77c533025bf00c2ee97abd433a3871b5a1 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 420365e930..fe0dbd6b0e 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4060,6 +4060,23 @@ static void serialGet( pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real; } } +static int serialGet7( + const unsigned char *buf, /* Buffer to deserialize from */ + Mem *pMem /* Memory cell to write value into */ +){ + u64 x = FOUR_BYTE_UINT(buf); + u32 y = FOUR_BYTE_UINT(buf+4); + x = (x<<32) + y; + assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 ); + swapMixedEndianFloat(x); + memcpy(&pMem->u.r, &x, sizeof(x)); + if( IsNaN(x) ){ + pMem->flags = MEM_Null; + return 1; + } + pMem->flags = MEM_Real; + return 0; +} void sqlite3VdbeSerialGet( const unsigned char *buf, /* Buffer to deserialize from */ u32 serial_type, /* Serial type to deserialize */ @@ -4739,7 +4756,7 @@ int sqlite3VdbeRecordCompareWithSkip( }else if( serial_type==0 ){ rc = -1; }else if( serial_type==7 ){ - sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1); + serialGet7(&aKey1[d1], &mem1); rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r); }else{ i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]); @@ -4764,14 +4781,18 @@ int sqlite3VdbeRecordCompareWithSkip( }else if( serial_type==0 ){ rc = -1; }else{ - sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1); if( serial_type==7 ){ - if( mem1.u.ru.r ){ + if( serialGet7(&aKey1[d1], &mem1) ){ + rc = -1; /* mem1 is a NaN */ + }else if( mem1.u.ru.r ){ rc = -1; }else if( mem1.u.r>pRhs->u.r ){ rc = +1; + }else{ + assert( rc==0 ); } }else{ + sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1); rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r); } } @@ -4841,7 +4862,14 @@ int sqlite3VdbeRecordCompareWithSkip( /* RHS is null */ else{ serial_type = aKey1[idx1]; - rc = (serial_type!=0 && serial_type!=10); + if( serial_type==0 + || serial_type==10 + || (serial_type==7 && serialGet7(&aKey1[d1], &mem1)!=0) + ){ + assert( rc==0 ); + }else{ + rc = 1; + } } if( rc!=0 ){ From f286ad9211dceab80dc81e9207afdeac80bc777e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 26 Feb 2024 11:43:44 +0000 Subject: [PATCH 0146/1030] Remove a local variable from sqlite3IntFloatCompare() that was being optimized out anyhow, in order to get back to 100% MC/DC. FossilOrigin-Name: 52b13d6acbb738b9281f7dd44edd6c3c9585d22d98b1951b7059534fbd16fac0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 10 ++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 034aae79aa..012a9a59e8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\skey\scomprisons\sare\sdone\scorrectly\sif\sthe\sindex\skey\scontains\sNaN\nvalues\sthat\shave\snot\sbeen\sshifted\sinto\sNULLs.\s\sThat\scan\sonly\shappen\sdue\sto\ndatabase\scorruption,\sbut\swe\sneed\sto\sdeal\swith\sit\snevertheless. -D 2024-02-25T21:30:33.710 +C Remove\sa\slocal\svariable\sfrom\ssqlite3IntFloatCompare()\sthat\swas\sbeing\soptimized\nout\sanyhow,\sin\sorder\sto\sget\sback\sto\s100%\sMC/DC. +D 2024-02-26T11:43:44.331 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -815,7 +815,7 @@ F src/vdbe.c 805af8bec9cae76a873b0ec4c91c3d1bd49b38e86c1c533ed87ec7a07a5042a5 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b -F src/vdbeaux.c 56900c9a41f23260c8346f212bd6005eb9171f9a2f70d0cfb1441a078a0e4b84 +F src/vdbeaux.c 66161ba75c4a2d86aab124fe3cbcc2a752d8e4b1fc8c1fc6e00625db4798168c F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 3e37dab421b74e9ce55c1e88fbc7bc6fead590b5ab258bc684f8b70abb1d6e71 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 @@ -2164,8 +2164,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5f21e6a8ee709d8c5ec12c45e8dc702a7d0bb041f31b5715e28cd904dfd566b0 -R 6483dab5f9a5754b844e2de29e4108e4 +P 7e4c743f9e6ef33500795543e6db9a77c533025bf00c2ee97abd433a3871b5a1 +R c6dffb6e7b319997a7eba2ad9ac6eb44 U drh -Z 27901e47f4de6ad53eaa2c16e520ba30 +Z d409ac0ab10fc8970bce183981ba2543 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ccb9a0f0ae..31f714bf7c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7e4c743f9e6ef33500795543e6db9a77c533025bf00c2ee97abd433a3871b5a1 \ No newline at end of file +52b13d6acbb738b9281f7dd44edd6c3c9585d22d98b1951b7059534fbd16fac0 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index fe0dbd6b0e..209d02a049 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4516,17 +4516,15 @@ int sqlite3IntFloatCompare(i64 i, double r){ return (xr); }else{ i64 y; - double s; if( r<-9223372036854775808.0 ) return +1; if( r>=9223372036854775808.0 ) return -1; y = (i64)r; if( iy ) return +1; - s = (double)i; - testcase( doubleLt(s,r) ); - testcase( doubleLt(r,s) ); - testcase( doubleEq(r,s) ); - return (sr); + testcase( doubleLt(((double)i),r) ); + testcase( doubleLt(r,((double)i)) ); + testcase( doubleEq(r,((double)i)) ); + return (((double)i)r); } } From 1103eb423e7c975ba77f8a9a10b0667636191be8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 26 Feb 2024 11:51:21 +0000 Subject: [PATCH 0147/1030] Fix header comments on test scripts. FossilOrigin-Name: 9fe9670c977ce7ad2c19657783a63998769dbb7741a587889c72ecc04d895793 --- ext/intck/intck1.test | 5 ++--- ext/intck/intck2.test | 4 ++-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ext/intck/intck1.test b/ext/intck/intck1.test index e05ae06166..1708406304 100644 --- a/ext/intck/intck1.test +++ b/ext/intck/intck1.test @@ -9,7 +9,8 @@ # #*********************************************************************** # -# The focus of this file is testing the r-tree extension. +# The focus of this file is testing the incremental integrity check +# (intck) extension. # source [file join [file dirname [info script]] intck_common.tcl] @@ -328,5 +329,3 @@ do_intck_test 7.5 {} finish_test - - diff --git a/ext/intck/intck2.test b/ext/intck/intck2.test index c168118535..c8503042c9 100644 --- a/ext/intck/intck2.test +++ b/ext/intck/intck2.test @@ -9,7 +9,8 @@ # #*********************************************************************** # -# The focus of this file is testing the r-tree extension. +# The focus of this file is testing the incremental integrity check +# (intck) extension. # source [file join [file dirname [info script]] intck_common.tcl] @@ -173,4 +174,3 @@ do_intck_test 3.8 { } finish_test - diff --git a/manifest b/manifest index f34154f890..912b02d07c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\slatest\strunk\schanges\sinto\sthis\sbranch. -D 2024-02-26T10:56:54.404 +C Fix\sheader\scomments\son\stest\sscripts. +D 2024-02-26T11:51:21.317 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -250,8 +250,8 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/intck/intck1.test 866f0937911bf3a10491af6ce319b75bcd587c39dc8decf2444746b946aa4f3e -F ext/intck/intck2.test 97daaf43b8a3c870ba7c2fd421dc1887053f5b30188896fa64677ce8174c206f +F ext/intck/intck1.test 8a879640c90fdff5e91e6c2c41d509485ee634e8077fe0ca9f76be4cbd441fa3 +F ext/intck/intck2.test 47afb44681d13d11072cd8906e6aa877c967e65be788b01f6139922fd91474ef F ext/intck/intck_common.tcl 9e51458126576783f11051ac0fd25bea3f6b17f570a55884223737f3200b214b F ext/intck/intckbusy.test 0732fe3efbb9e0a53ffdcc240073f6ff2777ea82c3e08812b16494f650763fe1 F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 @@ -2173,8 +2173,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c253e276b29de28a18270d01b60d95157ce3fc4b37e246d991f9119d26e718d7 7e4c743f9e6ef33500795543e6db9a77c533025bf00c2ee97abd433a3871b5a1 -R d91900a2b738ceadf979774120590e4a -U dan -Z 9b2321809e4d89643b001730f06f9a2c +P b6371ff9f5c3d4e87a5b1127a82970202f74c790b828dda20df88dd727bcc9b4 +R 3add559ac6b3cdeca1489f677e09e848 +U drh +Z 4a33c5af1c72f813c7944d5f457e89df # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b5e0bfba97..391e1cbab5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b6371ff9f5c3d4e87a5b1127a82970202f74c790b828dda20df88dd727bcc9b4 \ No newline at end of file +9fe9670c977ce7ad2c19657783a63998769dbb7741a587889c72ecc04d895793 \ No newline at end of file From 7c6433cfff58499a7ee2c9b103590359e0cf5226 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 26 Feb 2024 15:27:33 +0000 Subject: [PATCH 0148/1030] When inserting a 3-byte cell into a btree, ensure that the extra padding byte is 0x00. This is not necessary for security, as far as I can tell, but it seems like a reasonable precaution. FossilOrigin-Name: 5766f1279dab91e030d4dcf5133659e5cedf914a1628ccf00d67d8e50a9957fd --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/btree.c | 10 ++++++++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index aea982c3aa..38fe85d7c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sintck\sextension.\sFor\sperforming\sincremental\sintegrity-check\son\sa\sdatabase. -D 2024-02-26T12:16:02.164 +C When\sinserting\sa\s3-byte\scell\sinto\sa\sbtree,\sensure\sthat\sthe\sextra\spadding\sbyte\nis\s0x00.\s\sThis\sis\snot\snecessary\sfor\ssecurity,\sas\sfar\sas\sI\scan\stell,\sbut\sit\nseems\slike\sa\sreasonable\sprecaution. +D 2024-02-26T15:27:33.122 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -689,7 +689,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 2f9dcf7c27879edb7897354029343bcab0c5a3dd2bde3bf3fd8f814b71344d22 +F src/btree.c 5e86e2b4c4ddb094c4a5e782b79d5fde5d52a7b516182494787e4edd01e86435 F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240 F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062 F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f @@ -2173,9 +2173,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 52b13d6acbb738b9281f7dd44edd6c3c9585d22d98b1951b7059534fbd16fac0 9fe9670c977ce7ad2c19657783a63998769dbb7741a587889c72ecc04d895793 -R bbd9def4c46dfeeca89016db47528759 -T +closed 9fe9670c977ce7ad2c19657783a63998769dbb7741a587889c72ecc04d895793 -U dan -Z ac496782ea3735f2c2a49bf7149a7694 +P 141d8bb059f8987d05d18327b97c4d36e98258f657b41a3d4d8877fe8b4e72e3 +R 814829b1dbfec006c60cbfc4ee055b02 +U drh +Z 06102cc64bbcbae3a093de2757fdfb8e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b5c3adb2b1..ae9679a05c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -141d8bb059f8987d05d18327b97c4d36e98258f657b41a3d4d8877fe8b4e72e3 \ No newline at end of file +5766f1279dab91e030d4dcf5133659e5cedf914a1628ccf00d67d8e50a9957fd \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 16b683abe7..3e08dc6a1b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7007,7 +7007,10 @@ static int fillInCell( n = nHeader + nPayload; testcase( n==3 ); testcase( n==4 ); - if( n<4 ) n = 4; + if( n<4 ){ + n = 4; + pPayload[nPayload] = 0; + } *pnSize = n; assert( nSrc<=nPayload ); testcase( nSrcpBt->nPreformatSize; - if( szNew<4 ) szNew = 4; + if( szNew<4 ){ + szNew = 4; + newCell[3] = 0; + } if( ISAUTOVACUUM(p->pBt) && szNew>pPage->maxLocal ){ CellInfo info; pPage->xParseCell(pPage, newCell, &info); From f79b0bdcbfb46164cfd665d256f2862bf3f42a7c Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 26 Feb 2024 22:28:21 +0000 Subject: [PATCH 0149/1030] The quote() SQL function should convert +Inf into 9.0e+999 and -Inf into -9.0e+999. See [forum:/forumpost/6675b25108|forum post 6675b25108]. FossilOrigin-Name: 85dd79a6edecfc8c6307c6d215998f76dab086aa14528ddc64eb9955501becfd --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 4 ++-- test/func.test | 5 +++++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 38fe85d7c4..406669c1d8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sinserting\sa\s3-byte\scell\sinto\sa\sbtree,\sensure\sthat\sthe\sextra\spadding\sbyte\nis\s0x00.\s\sThis\sis\snot\snecessary\sfor\ssecurity,\sas\sfar\sas\sI\scan\stell,\sbut\sit\nseems\slike\sa\sreasonable\sprecaution. -D 2024-02-26T15:27:33.122 +C The\squote()\sSQL\sfunction\sshould\sconvert\s+Inf\sinto\s9.0e+999\sand\s-Inf\sinto\n-9.0e+999.\s\sSee\s[forum:/forumpost/6675b25108|forum\spost\s6675b25108]. +D 2024-02-26T22:28:21.332 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -703,7 +703,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c 3381ee4c9aa7ccde22a2a7f35ce343925a7a25d96bdc943649131f9decdebad2 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 -F src/func.c c71b81223e165722cd81fa71fb869a235de5998c4c5142a5dfa2725d6331f539 +F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb F src/global.c 765a0656d6cbf043cb272ff0ae38f39cc46713539ffe6793258ed3eb4b188b52 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -1228,7 +1228,7 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75 F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9 F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test da1332f6ab70338b83f5e2d594e72c7aa438c9b68406915e5a54618d601c09ee +F test/func.test 504d202650c7940b5aa98364dd68f242df87f39f829e51074a55d79fc7bc7414 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a F test/func4.test e8ef9b2bd6a192a213cbd5cf31a3b35e25cd6ff2fdaeea0b58d63be31b03d220 @@ -2173,8 +2173,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 141d8bb059f8987d05d18327b97c4d36e98258f657b41a3d4d8877fe8b4e72e3 -R 814829b1dbfec006c60cbfc4ee055b02 +P 5766f1279dab91e030d4dcf5133659e5cedf914a1628ccf00d67d8e50a9957fd +R 3cd78a5a9341c0a117222898fc0a6308 U drh -Z 06102cc64bbcbae3a093de2757fdfb8e +Z 7d29334815d11708910ce9fb84e949e7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ae9679a05c..c1fa5c043b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5766f1279dab91e030d4dcf5133659e5cedf914a1628ccf00d67d8e50a9957fd \ No newline at end of file +85dd79a6edecfc8c6307c6d215998f76dab086aa14528ddc64eb9955501becfd \ No newline at end of file diff --git a/src/func.c b/src/func.c index 249c17857e..9fbd1e9e1c 100644 --- a/src/func.c +++ b/src/func.c @@ -1101,13 +1101,13 @@ void sqlite3QuoteValue(StrAccum *pStr, sqlite3_value *pValue){ double r1, r2; const char *zVal; r1 = sqlite3_value_double(pValue); - sqlite3_str_appendf(pStr, "%!.15g", r1); + sqlite3_str_appendf(pStr, "%!0.15g", r1); zVal = sqlite3_str_value(pStr); if( zVal ){ sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8); if( r1!=r2 ){ sqlite3_str_reset(pStr); - sqlite3_str_appendf(pStr, "%!.20e", r1); + sqlite3_str_appendf(pStr, "%!0.20e", r1); } } break; diff --git a/test/func.test b/test/func.test index 82f51b857d..c7b8f72352 100644 --- a/test/func.test +++ b/test/func.test @@ -786,6 +786,11 @@ do_test func-16.1 { } } {X'616263' NULL} +# Test the quote function for +Inf and -Inf +do_execsql_test func-16.2 { + SELECT quote(4.2e+859), quote(-7.8e+904); +} {9.0e+999 -9.0e+999} + # Correctly handle function error messages that include %. Ticket #1354 # do_test func-17.1 { From 8732fce9856632c3cce29787263f2770a1f0c6aa Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 27 Feb 2024 14:31:31 +0000 Subject: [PATCH 0150/1030] Ensure memory cells are properly freed before they are overwritten by OP_IntegrityCk. FossilOrigin-Name: e50acaf934f44f8833bc588e0ae1abd59df907b9a42d4cafd5518427a8c7b627 --- manifest | 14 +++++----- manifest.uuid | 2 +- src/vdbemem.c | 6 ++-- test/pragma6.test | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 test/pragma6.test diff --git a/manifest b/manifest index bf570f6644..c7341f42f2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\s"PRAGMA\squick_check"\scompare\sthe\snumber\sof\sentries\sin\stables\sand\sindexes. -D 2024-02-27T11:03:10.418 +C Ensure\smemory\scells\sare\sproperly\sfreed\sbefore\sthey\sare\soverwritten\sby\sOP_IntegrityCk. +D 2024-02-27T14:31:31.983 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -826,7 +826,7 @@ F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b F src/vdbeaux.c 66161ba75c4a2d86aab124fe3cbcc2a752d8e4b1fc8c1fc6e00625db4798168c F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 -F src/vdbemem.c 6f1728ea70d9523cc446567d3bf1cca3f26515d15160dd9f540fc549cdfbe2a6 +F src/vdbemem.c 213bf303826c0ef702e3a2a69dab2309d84b8381b822c6787885859fd7cd4c4e F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 @@ -1500,6 +1500,7 @@ F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 F test/pragma4.test 9559cf5173864bf47c0431873d158fbeb72f920a59905b1f46069d8543eccdab F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d9102 +F test/pragma6.test fc3b670ab8ed985b2e5faa870f0f81aba1bfd5c3877ef3214e2df88592ccd3e5 F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8 F test/prefixes.test b524a1c44bffec225b9aec98bd728480352aa8532ac4c15771fb85e8beef65d9 F test/printf.test 685fec5a0c5af2490ab0632775a301554361d674211d690f5bee0a97b05333de @@ -2175,9 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 61676f1e18a405e4f3b6007488f2e68f3f55b312c107359ae5e52929f0c104c8 cc294c041b4c7a044ff344989f872415ced5263a0b654112371b2da7c852a688 -R 5ed88641845fcb2fc70cf72b4cd45874 -T +closed cc294c041b4c7a044ff344989f872415ced5263a0b654112371b2da7c852a688 +P b736519d3d2e93c76fa36253143f2664b9dd12e26acba555f0bf9c4d44705499 +R 725744da1444e5fefe1d2ce5b7ed4e0a U dan -Z 4d80cc60a3752c9ff93baadf82143f0e +Z 55bcecaeff9ae7b0e1973c81cc615ff2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a8b2d749cb..e98dc9d1dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b736519d3d2e93c76fa36253143f2664b9dd12e26acba555f0bf9c4d44705499 \ No newline at end of file +e50acaf934f44f8833bc588e0ae1abd59df907b9a42d4cafd5518427a8c7b627 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index 03c58f3024..d0015206d5 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -943,9 +943,11 @@ void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){ } } +/* +** Set the iIdx'th entry of array aMem[] to contain integer value val. +*/ void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val){ - aMem[iIdx].u.i = val; - aMem[iIdx].flags = MEM_Int; + sqlite3VdbeMemSetInt64(&aMem[iIdx], val); } /* A no-op destructor */ diff --git a/test/pragma6.test b/test/pragma6.test new file mode 100644 index 0000000000..8e4233a536 --- /dev/null +++ b/test/pragma6.test @@ -0,0 +1,71 @@ +# 2024 February 27 +# +# 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 tests for PRAGMAs quick_check and integrity_check. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix pragma6 + +database_may_be_corrupt + +#------------------------------------------------------------------------- +# +do_test 1.0 { + sqlite3 db {} + db deserialize [decode_hexdb { + .open --hexdb + | size 12288 pagesize 4096 filename crash-540f4c1eb1e7ac.db + | page 1 offset 0 + | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. + | 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 03 .....@ ........ + | 32: 00 bb 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + | 96: 00 00 00 00 0d 00 00 00 02 0f 7f 00 0f c3 0f 7f ................ + | 3952: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ...............B + | 3968: 02 06 17 11 11 01 71 74 61 62 6c 65 74 32 74 32 ......qtablet2t2 + | 3984: 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32 .CREATE TABLE t2 + | 4000: 28 61 20 49 4e 54 2c 20 62 20 41 53 20 28 61 2a (a INT, b AS (a* + | 4016: 32 29 20 53 54 4f 52 45 44 20 4e 4f 54 20 4e 55 2) STORED NOT NU + | 4032: 4c 4c 29 3b 01 06 17 11 11 01 63 74 61 62 6c 65 LL);......ctable + | 4048: 74 31 74 31 02 43 52 45 41 54 45 20 54 41 42 4c t1t1.CREATE TABL + | 4064: 45 20 74 31 28 61 20 49 4e 54 2c 20 62 20 41 53 E t1(a INT, b AS + | 4080: 20 28 61 2a 32 29 20 4e 4f 54 20 4e 55 4c 4c 29 (a*2) NOT NULL) + | page 2 offset 4096 + | 0: 0d 00 00 00 05 0f e7 00 00 00 00 00 00 00 00 00 ................ + | 4064: 00 00 00 00 00 00 00 00 03 05 02 01 05 03 04 02 ................ + | 4080: 01 04 03 03 02 01 03 03 02 02 01 02 02 01 02 09 ................ + | page 3 offset 8192 + | 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + | 4048: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 05 ................ + | 4064: 03 01 01 05 0a 05 04 03 01 01 04 08 05 03 03 01 ................ + | 4080: 01 03 06 05 02 03 00 00 00 00 00 00 00 00 00 00 ................ + | end crash-540f4c1eb1e7ac.db + }] +} {} + +do_execsql_test 1.1 { + CREATE TEMP TABLE t2( + a t1 PRIMARY KEY default 27, + b default(current_timestamp), + d TEXT UNIQUE DEFAULT 'ch`arlie', + c TEXT UNIQUE DEFAULT 084, + UNIQUE(c,b,b,a,b) + ) WITHOUT ROWID; + INSERT INTO t1(a) VALUES(zeroblob(40000)); +} + +do_test 1.2 { + execsql { PRAGMA integrity_check; } + execsql { PRAGMA quick_check; } + set {} {} +} {} + +finish_test From 39670a5345e438104d2618480e124ce7581a2f88 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Feb 2024 15:33:54 +0000 Subject: [PATCH 0151/1030] Remove unreachable branches from the PRAGMA integrity_check enhancement of [b736519d3d2e93c7]. FossilOrigin-Name: 6d02fb233fb86f9907cc374d06a7ed71a638091d6e75abc199001c42eab51e5c --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/btree.c | 8 ++++---- src/pragma.c | 2 +- src/vdbe.c | 2 ++ 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index c7341f42f2..12161e7bd5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\smemory\scells\sare\sproperly\sfreed\sbefore\sthey\sare\soverwritten\sby\sOP_IntegrityCk. -D 2024-02-27T14:31:31.983 +C Remove\sunreachable\sbranches\sfrom\sthe\sPRAGMA\sintegrity_check\senhancement\sof\n[b736519d3d2e93c7]. +D 2024-02-27T15:33:54.328 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -689,7 +689,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 28a97cee62ec9d701ee4d45d034dab1a113a81f0db53773db4c298d79a1dbce1 +F src/btree.c 9f2278fa80de5cd7ef31de42a1ed636c9c5d39d0a0053b1a0bd011f0a6374ad1 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f @@ -743,7 +743,7 @@ F src/parse.y 6209f01e8e7495379571454744fa82a5cfc2e7eeb89e46dee3f410d73ea6252d F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 3b6ffa36e3b7520e35e958814f1865d4474e53d5cac87773e2a6b11c2a26adc8 +F src/pragma.c 35d3d604e5a2770b4ac9d7fc22092a06ca8c71784dc0c388d474760af28cfcf8 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a @@ -820,7 +820,7 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 7a49c6a5442757bb6344e7839e0b1f6ba8e54df4e4d092b439c6f6b7035bb01a F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c f1097e0a5faf9c3939d1431beade2536487be9704ee020416c74eddea46dc4bc +F src/vdbe.c 523a88b3df328810fbcbb407738c352dd9d5163b7af4c953e6e9887a4b582859 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b736519d3d2e93c76fa36253143f2664b9dd12e26acba555f0bf9c4d44705499 -R 725744da1444e5fefe1d2ce5b7ed4e0a -U dan -Z 55bcecaeff9ae7b0e1973c81cc615ff2 +P e50acaf934f44f8833bc588e0ae1abd59df907b9a42d4cafd5518427a8c7b627 +R 65aed5a318a1485a77b2828f417462c5 +U drh +Z 14ec372b01ad9570d9528860ace49e84 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e98dc9d1dc..a75c3adf6f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e50acaf934f44f8833bc588e0ae1abd59df907b9a42d4cafd5518427a8c7b627 \ No newline at end of file +6d02fb233fb86f9907cc374d06a7ed71a638091d6e75abc199001c42eab51e5c \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index f5bd5349cc..46c077a038 100644 --- a/src/btree.c +++ b/src/btree.c @@ -11027,7 +11027,9 @@ int sqlite3BtreeIntegrityCheck( int bPartial = 0; /* True if not checking all btrees */ int bCkFreelist = 1; /* True to scan the freelist */ VVA_ONLY( int nRef ); + assert( nRoot>0 ); + assert( aCnt!=0 ); /* aRoot[0]==0 means this is a partial check */ if( aRoot[0]==0 ){ @@ -11101,7 +11103,7 @@ int sqlite3BtreeIntegrityCheck( pBt->db->flags &= ~(u64)SQLITE_CellSizeCk; for(i=0; (int)iautoVacuum && aRoot[i]>1 && !bPartial ){ @@ -11111,9 +11113,7 @@ int sqlite3BtreeIntegrityCheck( sCheck.v0 = aRoot[i]; checkTreePage(&sCheck, aRoot[i], ¬Used, LARGEST_INT64); } - if( aCnt ){ - sqlite3MemSetArrayInt64(aCnt, i, sCheck.nRow); - } + sqlite3MemSetArrayInt64(aCnt, i, sCheck.nRow); } pBt->db->flags = savedDbFlags; diff --git a/src/pragma.c b/src/pragma.c index 529cdc83a1..a3ac1f370f 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1786,7 +1786,7 @@ void sqlite3Pragma( iTab = cnt++; }else{ iTab = cnt; - for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + for(pIdx=pTab->pIndex; ALWAYS(pIdx); pIdx=pIdx->pNext){ if( IsPrimaryKeyIndex(pIdx) ) break; iTab++; } diff --git a/src/vdbe.c b/src/vdbe.c index 55f5290ec4..489c4825f4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -7142,9 +7142,11 @@ case OP_IntegrityCk: { Mem *pnErr; /* Register keeping track of errors remaining */ assert( p->bIsReader ); + assert( pOp->p4type==P4_INTARRAY ); nRoot = pOp->p2; aRoot = pOp->p4.ai; assert( nRoot>0 ); + assert( aRoot!=0 ); assert( aRoot[0]==(Pgno)nRoot ); assert( pOp->p1>0 && (pOp->p1+1)<=(p->nMem+1 - p->nCursor) ); pnErr = &aMem[pOp->p1]; From 2aea6083bdb2c57ca79578e75b33910bd8192d13 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Feb 2024 16:36:40 +0000 Subject: [PATCH 0152/1030] Adjust a VdbeCoverage() macro in PRAGMA integrity_check to account for the fact that arguments to the OP_Eq opcode used are never NULL. FossilOrigin-Name: 759ccea3f6e21493c0153f884b601988efd59e409b113b28f8cf23f59a74e418 --- manifest | 13 +++++++------ manifest.uuid | 2 +- src/pragma.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 12161e7bd5..23f6c9aa67 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunreachable\sbranches\sfrom\sthe\sPRAGMA\sintegrity_check\senhancement\sof\n[b736519d3d2e93c7]. -D 2024-02-27T15:33:54.328 +C Adjust\sa\sVdbeCoverage()\smacro\sin\sPRAGMA\sintegrity_check\sto\saccount\sfor\sthe\nfact\sthat\sarguments\sto\sthe\sOP_Eq\sopcode\sused\sare\snever\sNULL. +D 2024-02-27T16:36:40.485 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -743,7 +743,7 @@ F src/parse.y 6209f01e8e7495379571454744fa82a5cfc2e7eeb89e46dee3f410d73ea6252d F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 35d3d604e5a2770b4ac9d7fc22092a06ca8c71784dc0c388d474760af28cfcf8 +F src/pragma.c e8221d6310c9923c80f6fa6d09b7ea7c5263a671f53db8d0894df23efcdb617b F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a @@ -2176,8 +2176,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e50acaf934f44f8833bc588e0ae1abd59df907b9a42d4cafd5518427a8c7b627 -R 65aed5a318a1485a77b2828f417462c5 +P 6d02fb233fb86f9907cc374d06a7ed71a638091d6e75abc199001c42eab51e5c +Q +8c788fc4b2ff21e4f051c9ddc6103ecddf2bbbaf2b6448f1b6dd465d6bd7630d +R aa090c9c9f482341f70a36ba64dc71b9 U drh -Z 14ec372b01ad9570d9528860ace49e84 +Z f5f75171aadd4bf4f2a1819642f85884 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a75c3adf6f..85bf861b4b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d02fb233fb86f9907cc374d06a7ed71a638091d6e75abc199001c42eab51e5c \ No newline at end of file +759ccea3f6e21493c0153f884b601988efd59e409b113b28f8cf23f59a74e418 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index a3ac1f370f..d3b0198236 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1794,7 +1794,7 @@ void sqlite3Pragma( for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ if( pIdx->pPartIdxWhere==0 ){ addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+cnt, 0, 8+iTab); - VdbeCoverage(v); + VdbeCoverageNeverNull(v); sqlite3VdbeLoadString(v, 4, pIdx->zName); sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3); integrityCheckResultRow(v); From 6324cdfdcde2362a0e641e41b60a7200563f18fb Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Feb 2024 19:57:31 +0000 Subject: [PATCH 0153/1030] Add an assert() to help scan-build recognize that a variable is initialized. FossilOrigin-Name: 10d26f1ee8e7624cbb957332b4397d2f1fcdaf916acec93077f2ddd33e01f1d8 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/btree.c | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 23f6c9aa67..90edfbec04 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sa\sVdbeCoverage()\smacro\sin\sPRAGMA\sintegrity_check\sto\saccount\sfor\sthe\nfact\sthat\sarguments\sto\sthe\sOP_Eq\sopcode\sused\sare\snever\sNULL. -D 2024-02-27T16:36:40.485 +C Add\san\sassert()\sto\shelp\sscan-build\srecognize\sthat\sa\svariable\sis\sinitialized. +D 2024-02-27T19:57:31.283 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -689,7 +689,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 9f2278fa80de5cd7ef31de42a1ed636c9c5d39d0a0053b1a0bd011f0a6374ad1 +F src/btree.c 285b493d843e7ba8ef78b6ae7d31238e904901dbc0c484f7904de4cf18fd8802 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f @@ -2176,9 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6d02fb233fb86f9907cc374d06a7ed71a638091d6e75abc199001c42eab51e5c -Q +8c788fc4b2ff21e4f051c9ddc6103ecddf2bbbaf2b6448f1b6dd465d6bd7630d -R aa090c9c9f482341f70a36ba64dc71b9 +P 759ccea3f6e21493c0153f884b601988efd59e409b113b28f8cf23f59a74e418 +R c66f74a56da0d53be1c2b9694225d21a U drh -Z f5f75171aadd4bf4f2a1819642f85884 +Z c9bf8cf4057f71ba3123aac76ae5d8bc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 85bf861b4b..3d2dc9e7b5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -759ccea3f6e21493c0153f884b601988efd59e409b113b28f8cf23f59a74e418 \ No newline at end of file +10d26f1ee8e7624cbb957332b4397d2f1fcdaf916acec93077f2ddd33e01f1d8 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 46c077a038..ddfa3c63f3 100644 --- a/src/btree.c +++ b/src/btree.c @@ -10914,6 +10914,7 @@ static int checkTreePage( btreeHeapInsert(heap, (pc<<16)|(pc+size-1)); } } + assert( heap!=0 ); /* Add the freeblocks to the min-heap ** ** EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header From b542933cba507c9660dd41df6e73866cc4c7d601 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Feb 2024 20:19:32 +0000 Subject: [PATCH 0154/1030] Fix an eputf() macro without its argument in the CLI. FossilOrigin-Name: c2f5e257d2cfb91341f5261ed3924dc4ec2a6f854f3692fb416043f5c654a963 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 90edfbec04..4fc938e015 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sassert()\sto\shelp\sscan-build\srecognize\sthat\sa\svariable\sis\sinitialized. -D 2024-02-27T19:57:31.283 +C Fix\san\seputf()\smacro\swithout\sits\sargument\sin\sthe\sCLI. +D 2024-02-27T20:19:32.980 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -751,7 +751,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in 0c13f7cc3bb8c31190efbd96f5c1d8f2fafdbcad549424b7e7850cb5617b115a +F src/shell.c.in 2ec564ed3ff0147036be313efeb47b3dbfb8753d5eb5ea0e90636427c6b3a365 F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 759ccea3f6e21493c0153f884b601988efd59e409b113b28f8cf23f59a74e418 -R c66f74a56da0d53be1c2b9694225d21a +P 10d26f1ee8e7624cbb957332b4397d2f1fcdaf916acec93077f2ddd33e01f1d8 +R 5abca0ff3e66ec32c7da5aae96062851 U drh -Z c9bf8cf4057f71ba3123aac76ae5d8bc +Z 174bf550e5155919f4d414b95c3db5bd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3d2dc9e7b5..d100fcde72 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -10d26f1ee8e7624cbb957332b4397d2f1fcdaf916acec93077f2ddd33e01f1d8 \ No newline at end of file +c2f5e257d2cfb91341f5261ed3924dc4ec2a6f854f3692fb416043f5c654a963 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 07e4b201ce..05583b2f34 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -9185,7 +9185,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( iArg==0 ) iArg = -1; } if( (nArg!=1 && nArg!=2) || iArg<0 ){ - eputf("Usage: .intck STEPS_PER_UNLOCK\n"); + eputf("%s","Usage: .intck STEPS_PER_UNLOCK\n"); rc = 1; goto meta_command_exit; } From 8597eee1196c263be80f9d03639360b40fe17307 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Feb 2024 01:12:21 +0000 Subject: [PATCH 0155/1030] Always convert 32-bit integer literals into EP_IntValue notation, even if they contain "_" separators. FossilOrigin-Name: 2dfc427f676255cbe189a26bfec2405d41d31ccc4512c55b31e6e633261d7a23 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 11 ++++++----- src/util.c | 10 ++++++++++ test/literal.test | 7 +++++++ 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 4fc938e015..a458d26d4f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\seputf()\smacro\swithout\sits\sargument\sin\sthe\sCLI. -D 2024-02-27T20:19:32.980 +C Always\sconvert\s32-bit\sinteger\sliterals\sinto\sEP_IntValue\snotation,\seven\sif\nthey\scontain\s"_"\sseparators. +D 2024-02-28T01:12:21.520 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 90df32c2d8b2a38dd2e83d32e47802629305c4882fb2ec75c9ecdcd75b68bcb2 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 3381ee4c9aa7ccde22a2a7f35ce343925a7a25d96bdc943649131f9decdebad2 +F src/expr.c 2803f5e7e3458ced24c0de48ec3640cd7a68ec61350d99c9f30b1bcd6640bd61 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -818,7 +818,7 @@ F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c 7a49c6a5442757bb6344e7839e0b1f6ba8e54df4e4d092b439c6f6b7035bb01a +F src/util.c 0765014847e2a06c952dd64aef0bea5144cd5b335a161eb0768ebe4f63dfe216 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c 523a88b3df328810fbcbb407738c352dd9d5163b7af4c953e6e9887a4b582859 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f @@ -1368,7 +1368,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test c4f6f281964ac5ab48a32bd978e80644affac822664879d7558762b2fad7aff5 +F test/literal.test a65dca9fef86e51b8e45544268e37abbd4bb94ba35fd65f6fdcab2f288cd8f79 F test/literal2.tcl 1499037beaf661aeecdbe48801220a181d805372a64c6128d5f26bb6a4a8f0ce F test/literal2.test b149e16b5fc9ee6249069a8858ed41052f222014fe0ba7ad43c2fb989c2dada2 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 10d26f1ee8e7624cbb957332b4397d2f1fcdaf916acec93077f2ddd33e01f1d8 -R 5abca0ff3e66ec32c7da5aae96062851 +P c2f5e257d2cfb91341f5261ed3924dc4ec2a6f854f3692fb416043f5c654a963 +R a81000c304b1245e80843833b1cb44da U drh -Z 174bf550e5155919f4d414b95c3db5bd +Z 74cbb43b6190c4a6f68e781473d23cde # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d100fcde72..25ba439edc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c2f5e257d2cfb91341f5261ed3924dc4ec2a6f854f3692fb416043f5c654a963 \ No newline at end of file +2dfc427f676255cbe189a26bfec2405d41d31ccc4512c55b31e6e633261d7a23 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index f9b280bbc5..e2cc15cfd6 100644 --- a/src/expr.c +++ b/src/expr.c @@ -914,11 +914,12 @@ void sqlite3ExprSetErrorOffset(Expr *pExpr, int iOfst){ ** appear to be quoted. If the quotes were of the form "..." (double-quotes) ** then the EP_DblQuoted flag is set on the expression node. ** -** Special case: If op==TK_INTEGER and pToken points to a string that -** can be translated into a 32-bit integer, then the token is not -** stored in u.zToken. Instead, the integer values is written -** into u.iValue and the EP_IntValue flag is set. No extra storage +** Special case (tag-20240227-a): If op==TK_INTEGER and pToken points to +** a string that can be translated into a 32-bit integer, then the token is +** not stored in u.zToken. Instead, the integer values is written +** into u.iValue and the EP_IntValue flag is set. No extra storage ** is allocated to hold the integer text and the dequote flag is ignored. +** See also tag-20240227-b. */ Expr *sqlite3ExprAlloc( sqlite3 *db, /* Handle for sqlite3DbMallocRawNN() */ @@ -934,7 +935,7 @@ Expr *sqlite3ExprAlloc( if( pToken ){ if( op!=TK_INTEGER || pToken->z==0 || sqlite3GetInt32(pToken->z, &iValue)==0 ){ - nExtra = pToken->n+1; + nExtra = pToken->n+1; /* tag-20240227-a */ assert( iValue>=0 ); } } diff --git a/src/util.c b/src/util.c index bdf92d9c4f..311b7385a6 100644 --- a/src/util.c +++ b/src/util.c @@ -317,10 +317,12 @@ void sqlite3DequoteExpr(Expr *p){ ** that contain '_' characters that must be removed before further processing. */ void sqlite3DequoteNumber(Parse *pParse, Expr *p){ + assert( p!=0 || pParse->db->mallocFailed ); if( p ){ const char *pIn = p->u.zToken; char *pOut = p->u.zToken; int bHex = (pIn[0]=='0' && (pIn[1]=='x' || pIn[1]=='X')); + int iValue; assert( p->op==TK_QNUMBER ); p->op = TK_INTEGER; do { @@ -336,6 +338,14 @@ void sqlite3DequoteNumber(Parse *pParse, Expr *p){ } }while( *pIn++ ); if( bHex ) p->op = TK_INTEGER; + + /* tag-20240227-a: If after dequoting, the number is an integer that + ** fits in 32 bits, then it must be converted into EP_IntValue. Other + ** parts of the code expect this. See also tag-20240227-b. */ + if( p->op==TK_INTEGER && sqlite3GetInt32(p->u.zToken, &iValue) ){ + p->u.iValue = iValue; + p->flags |= EP_IntValue; + } } } diff --git a/test/literal.test b/test/literal.test index 30205692c9..5aa331e39b 100644 --- a/test/literal.test +++ b/test/literal.test @@ -93,4 +93,11 @@ foreach {tn lit unrec} { test_literal_error 4.$tn $lit $unrec } +# dbsqlfuzz e3186a9e7826e9cd7f4085aa4452f8696485f9e1 +# See tag-20240224-a and -b +# +do_catchsql_test 5.1 { + SELECT 1 ORDER BY 2_3; +} {1 {1st ORDER BY term out of range - should be between 1 and 1}} + finish_test From 09a71d8d44697adb592ec7064559b1b2145241e6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Feb 2024 15:32:32 +0000 Subject: [PATCH 0156/1030] Add in a VdbeCoverage() macro needed by STAT4 that should have been part of check-in [63ef234e88857a65]. FossilOrigin-Name: d51c699ae413215d534f954c129691ef5d95d540dc5d4304cbba576c976d931c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/analyze.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index a458d26d4f..ff9e226028 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Always\sconvert\s32-bit\sinteger\sliterals\sinto\sEP_IntValue\snotation,\seven\sif\nthey\scontain\s"_"\sseparators. -D 2024-02-28T01:12:21.520 +C Add\sin\sa\sVdbeCoverage()\smacro\sneeded\sby\sSTAT4\sthat\sshould\shave\sbeen\spart\sof\ncheck-in\s[63ef234e88857a65]. +D 2024-02-28T15:32:32.228 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -683,7 +683,7 @@ F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 F src/alter.c 30c2333b8bb3af71e4eb9adeadee8aa20edb15917ed44b8422e5cd15f3dfcddc -F src/analyze.c dacc8f062bbda02c8ed3bbca0ab6122de010d094101d568df266a7b0d665d74f +F src/analyze.c a3df28274e2565ba5656577d7e3fd262169a213e6eb0bd47890e0f0729a4031c F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39 F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c2f5e257d2cfb91341f5261ed3924dc4ec2a6f854f3692fb416043f5c654a963 -R a81000c304b1245e80843833b1cb44da +P 2dfc427f676255cbe189a26bfec2405d41d31ccc4512c55b31e6e633261d7a23 +R fc556e11bf89363bdfe386e7578ab33b U drh -Z 74cbb43b6190c4a6f68e781473d23cde +Z 7f63c0d877ef8881aed016b2612db7ff # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 25ba439edc..709e981bf9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2dfc427f676255cbe189a26bfec2405d41d31ccc4512c55b31e6e633261d7a23 \ No newline at end of file +d51c699ae413215d534f954c129691ef5d95d540dc5d4304cbba576c976d931c \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index e7c1068ae0..8c48a8ff2a 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1296,6 +1296,7 @@ static void analyzeOneTable( if( addrGotoEnd==0 ){ sqlite3VdbeAddOp2(v, OP_Cast, regStat1, SQLITE_AFF_INTEGER); addrGotoEnd = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); + VdbeCoverage(v); } if( doOnce ){ From 087e6c9ada2306e34a9dddd6e1b4eb8565d14502 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 29 Feb 2024 03:45:18 +0000 Subject: [PATCH 0157/1030] Fix two -Werror=lto-type-mismatch warnings reported in [forum:ef62b57bd5|forum post ef62b57bd5]. FossilOrigin-Name: 29f94610dc8319709b8d3726a60e2a7a33ffbf4998c681f772da26c9701cc0b0 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- test/fuzzcheck.c | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index ff9e226028..2f85e3833f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sin\sa\sVdbeCoverage()\smacro\sneeded\sby\sSTAT4\sthat\sshould\shave\sbeen\spart\sof\ncheck-in\s[63ef234e88857a65]. -D 2024-02-28T15:32:32.228 +C Fix\stwo\s-Werror=lto-type-mismatch\swarnings\sreported\sin\s[forum:ef62b57bd5|forum\spost\sef62b57bd5]. +D 2024-02-29T03:45:18.006 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1244,7 +1244,7 @@ F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2 -F test/fuzzcheck.c 7e1bcc242dc4b42e43e4708c8140fe268db83a6901fbc681d150c77aa185e328 +F test/fuzzcheck.c e6a40f53ac5624aa5b7c4f31c385f09ba088d524cecc4512fd3057caeed8f530 F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -2176,8 +2176,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2dfc427f676255cbe189a26bfec2405d41d31ccc4512c55b31e6e633261d7a23 -R fc556e11bf89363bdfe386e7578ab33b -U drh -Z 7f63c0d877ef8881aed016b2612db7ff +P d51c699ae413215d534f954c129691ef5d95d540dc5d4304cbba576c976d931c +R 728f9a968510fa9cb95ea7ce7eec45f1 +T *branch * lto-type-mismatch +T *sym-lto-type-mismatch * +T -sym-trunk * Cancelled\sby\sbranch. +U stephan +Z 4ef24b5fab0d660b380d1bcfc2ce1289 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 709e981bf9..83e3daf352 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d51c699ae413215d534f954c129691ef5d95d540dc5d4304cbba576c976d931c \ No newline at end of file +29f94610dc8319709b8d3726a60e2a7a33ffbf4998c681f772da26c9701cc0b0 \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index dd49120115..e4ad1c1137 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -161,8 +161,8 @@ static struct GlobalVars { /* ** Include the external vt02.c and randomjson.c modules. */ -extern int sqlite3_vt02_init(sqlite3*,char***,void*); -extern int sqlite3_randomjson_init(sqlite3*,char***,void*); +extern int sqlite3_vt02_init(sqlite3*,char**,const sqlite3_api_routines*); +extern int sqlite3_randomjson_init(sqlite3*,char**,const sqlite3_api_routines*); /* From 696400584766e3c49edf22863ce463c6655ea775 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 2 Mar 2024 13:38:46 +0000 Subject: [PATCH 0158/1030] Proof-of-concept for new time-interval operator "pg-month" and "pg-year" that use the truncate-to-month algorithm for month overflow instead of the wrap-to-next-month algorithm that is used by SQLite by default. FossilOrigin-Name: b606c0965788f56547435c9318b60e32990877e14a9640d887f33f39d1bdc7c3 --- manifest | 18 ++++++++++-------- manifest.uuid | 2 +- src/date.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 28b15c7a43..9ca9c979c5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stwo\s-Werror=lto-type-mismatch\swarnings\sreported\sin\s[forum:ef62b57bd5|forum\spost\sef62b57bd5]. -D 2024-02-29T10:55:02.008 +C Proof-of-concept\sfor\snew\stime-interval\soperator\s"pg-month"\sand\s"pg-year"\sthat\nuse\sthe\struncate-to-month\salgorithm\sfor\smonth\soverflow\sinstead\sof\sthe\nwrap-to-next-month\salgorithm\sthat\sis\sused\sby\sSQLite\sby\sdefault. +D 2024-03-02T13:38:46.691 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -696,7 +696,7 @@ F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c 90df32c2d8b2a38dd2e83d32e47802629305c4882fb2ec75c9ecdcd75b68bcb2 +F src/date.c f0bde50092368a0eaff79e25ab24c3c91763859adffd91af6bf47cbc13cc7512 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -2176,9 +2176,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d51c699ae413215d534f954c129691ef5d95d540dc5d4304cbba576c976d931c 29f94610dc8319709b8d3726a60e2a7a33ffbf4998c681f772da26c9701cc0b0 -R 728f9a968510fa9cb95ea7ce7eec45f1 -T +closed 29f94610dc8319709b8d3726a60e2a7a33ffbf4998c681f772da26c9701cc0b0 Closed\sby\sintegrate-merge. -U stephan -Z 37dee8fa6539319388e07ab4c515c697 +P 803481f25020f3c25941f1e7d1a8071937820dea951e8798198b0b0fa3fb48ce +R 736136842d7746223f17212059cfe765 +T *branch * month-truncate +T *sym-month-truncate * +T -sym-trunk * +U drh +Z e1892067371eb0569faf26bcf07d7955 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2f2c96f612..5a462d35fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -803481f25020f3c25941f1e7d1a8071937820dea951e8798198b0b0fa3fb48ce \ No newline at end of file +b606c0965788f56547435c9318b60e32990877e14a9640d887f33f39d1bdc7c3 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 026d83391a..fd225d1e29 100644 --- a/src/date.c +++ b/src/date.c @@ -626,16 +626,18 @@ static int toLocaltime( */ static const struct { u8 nName; /* Length of the name */ - char zName[7]; /* Name of the transformation */ + char zName[9]; /* Name of the transformation */ float rLimit; /* Maximum NNN value for this transform */ float rXform; /* Constant used for this transform */ } aXformType[] = { - { 6, "second", 4.6427e+14, 1.0 }, - { 6, "minute", 7.7379e+12, 60.0 }, - { 4, "hour", 1.2897e+11, 3600.0 }, - { 3, "day", 5373485.0, 86400.0 }, - { 5, "month", 176546.0, 2592000.0 }, - { 4, "year", 14713.0, 31536000.0 }, + { 6, "second", 4.6427e+14, 1.0 }, + { 6, "minute", 7.7379e+12, 60.0 }, + { 4, "hour", 1.2897e+11, 3600.0 }, + { 3, "day", 5373485.0, 86400.0 }, + { 5, "month", 176546.0, 2592000.0 }, + { 4, "year", 14713.0, 31536000.0 }, + { 8, "pg-month", 176546.0, 2592000.0 }, + { 7, "pg-year", 14713.0, 31536000.0 }, }; /* @@ -966,22 +968,31 @@ static int parseModifier( && sqlite3_strnicmp(aXformType[i].zName, z, n)==0 && r>-aXformType[i].rLimit && rM += (int)r; x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12; p->Y += x; p->M -= x*12; + assert( p->M>=1 && p->M<=12 ); + if( i==6 ) targetMonth = p->M; p->validJD = 0; r -= (int)r; break; } + case 7: case 5: { /* Special processing to add years */ int y = (int)r; - assert( strcmp(aXformType[i].zName,"year")==0 ); + assert( strcmp(aXformType[i].zName,"year")==0 + || strcmp(aXformType[i].zName,"pg-year")==0 ); computeYMD_HMS(p); + assert( p->M>=1 && p->M<=12 ); + if( i==7 ) targetMonth = p->M; p->Y += y; p->validJD = 0; r -= (int)r; @@ -989,6 +1000,12 @@ static int parseModifier( } } computeJD(p); + if( targetMonth>0 ){ + p->validYMD = 0; + computeYMD(p); + if( p->M==targetMonth+1 ) p->iJD -= p->D*86400000; + p->validYMD = 0; + } p->iJD += (sqlite3_int64)(r*1000.0*aXformType[i].rXform + rRounder); rc = 0; break; From f52afaf738f97ea024d54cfb8fb17fa11fc4fe5e Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 2 Mar 2024 20:50:56 +0000 Subject: [PATCH 0159/1030] Change the magic time-interval names that do truncate-to-same-month to be "mnth" and "yr" - "month" and "year" without the vowels. FossilOrigin-Name: 296b46c529d79385d7f4db2c789254a992c01ff66fe8ba6d3a3ce4aaac0203fb --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/date.c | 38 +++++++++++++++++++------------------- test/date.test | 9 +++++++++ 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index 9ca9c979c5..ad4067ae8c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Proof-of-concept\sfor\snew\stime-interval\soperator\s"pg-month"\sand\s"pg-year"\sthat\nuse\sthe\struncate-to-month\salgorithm\sfor\smonth\soverflow\sinstead\sof\sthe\nwrap-to-next-month\salgorithm\sthat\sis\sused\sby\sSQLite\sby\sdefault. -D 2024-03-02T13:38:46.691 +C Change\sthe\smagic\stime-interval\snames\sthat\sdo\struncate-to-same-month\sto\sbe\n"mnth"\sand\s"yr"\s-\s"month"\sand\s"year"\swithout\sthe\svowels. +D 2024-03-02T20:50:56.172 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -696,7 +696,7 @@ F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c f0bde50092368a0eaff79e25ab24c3c91763859adffd91af6bf47cbc13cc7512 +F src/date.c 89083264f1832e2bb892d6b313a6c642a5cd730cfcc89574019aa06c69192dcd F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -1042,7 +1042,7 @@ F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c47 F test/cursorhint.test 05cf0febe5c5f8a31f199401fd1c9322249e753950d55f26f9d5aca61408a270 F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8 -F test/date.test b1a5208e6a9c390cf1d1fa4e38a910386b427b0e27046901c6b0fb995d19800e +F test/date.test 9583b421058d8366a06d4a07135ced29b64e31b5e7dafd03a2040bf84ef69adb F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1 F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5 F test/date4.test 75dc8401e8c0639a228cd26a6eaa4ff5ea8ccda912b9853d1c9462c476670e17 @@ -2176,11 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 803481f25020f3c25941f1e7d1a8071937820dea951e8798198b0b0fa3fb48ce -R 736136842d7746223f17212059cfe765 -T *branch * month-truncate -T *sym-month-truncate * -T -sym-trunk * +P b606c0965788f56547435c9318b60e32990877e14a9640d887f33f39d1bdc7c3 +R e86e5c292ead4f22cefd158cafe4f8bc U drh -Z e1892067371eb0569faf26bcf07d7955 +Z 74c79cb89bee4e9b933a0e487d4797f3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5a462d35fa..607ef1e19e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b606c0965788f56547435c9318b60e32990877e14a9640d887f33f39d1bdc7c3 \ No newline at end of file +296b46c529d79385d7f4db2c789254a992c01ff66fe8ba6d3a3ce4aaac0203fb \ No newline at end of file diff --git a/src/date.c b/src/date.c index fd225d1e29..d4c3afdd38 100644 --- a/src/date.c +++ b/src/date.c @@ -626,18 +626,18 @@ static int toLocaltime( */ static const struct { u8 nName; /* Length of the name */ - char zName[9]; /* Name of the transformation */ + char zName[7]; /* Name of the transformation */ float rLimit; /* Maximum NNN value for this transform */ float rXform; /* Constant used for this transform */ } aXformType[] = { - { 6, "second", 4.6427e+14, 1.0 }, - { 6, "minute", 7.7379e+12, 60.0 }, - { 4, "hour", 1.2897e+11, 3600.0 }, - { 3, "day", 5373485.0, 86400.0 }, - { 5, "month", 176546.0, 2592000.0 }, - { 4, "year", 14713.0, 31536000.0 }, - { 8, "pg-month", 176546.0, 2592000.0 }, - { 7, "pg-year", 14713.0, 31536000.0 }, + /* 0 */ { 6, "second", 4.6427e+14, 1.0 }, + /* 1 */ { 6, "minute", 7.7379e+12, 60.0 }, + /* 2 */ { 4, "hour", 1.2897e+11, 3600.0 }, + /* 3 */ { 3, "day", 5373485.0, 86400.0 }, + /* 4 */ { 5, "month", 176546.0, 30.0*86400.0 }, + /* 5 */ { 4, "mnth", 176546.0, 30.0*86400.0 }, + /* 6 */ { 4, "year", 14713.0, 365.0*86400.0 }, + /* 7 */ { 2, "yr", 14713.0, 365.0*86400.0 }, }; /* @@ -958,7 +958,7 @@ static int parseModifier( z += n; while( sqlite3Isspace(*z) ) z++; n = sqlite3Strlen30(z); - if( n>10 || n<3 ) break; + if( n>10 || n<2 ) break; if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--; computeJD(p); assert( rc==1 ); @@ -970,26 +970,26 @@ static int parseModifier( ){ int targetMonth = 0; switch( i ){ - case 6: - case 4: { /* Special processing to add months */ - assert( strcmp(aXformType[i].zName,"month")==0 - || strcmp(aXformType[i].zName,"pg-month")==0 ); + case 4: + case 5: { /* Special processing to add months */ + assert( strcmp(aXformType[4].zName,"month")==0 ); + assert( strcmp(aXformType[5].zName,"mnth")==0 ); computeYMD_HMS(p); p->M += (int)r; x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12; p->Y += x; p->M -= x*12; assert( p->M>=1 && p->M<=12 ); - if( i==6 ) targetMonth = p->M; + if( i==5 ) targetMonth = p->M; p->validJD = 0; r -= (int)r; break; } - case 7: - case 5: { /* Special processing to add years */ + case 6: + case 7: { /* Special processing to add years */ int y = (int)r; - assert( strcmp(aXformType[i].zName,"year")==0 - || strcmp(aXformType[i].zName,"pg-year")==0 ); + assert( strcmp(aXformType[6].zName,"year")==0 ); + assert( strcmp(aXformType[7].zName,"yr")==0 ); computeYMD_HMS(p); assert( p->M>=1 && p->M<=12 ); if( i==7 ) targetMonth = p->M; diff --git a/test/date.test b/test/date.test index d536c65fce..f0616f6570 100644 --- a/test/date.test +++ b/test/date.test @@ -148,6 +148,15 @@ datetest 2.51 {datetime('2003-10-22 12:24','nonsense')} NULL datetest 2.60 {datetime('2023-02-31')} {2023-03-03 00:00:00} +datetest 2.70 {date('2024-01-31','+1 month')} {2024-03-02} +datetest 2.71 {date('2024-01-31','+1 mnth')} {2024-02-29} +datetest 2.72 {date('2023-01-31','+1 month')} {2023-03-03} +datetest 2.73 {date('2023-01-31','+1 mnth')} {2023-02-28} +datetest 2.74 {date('2024-02-29','+1 year')} {2025-03-01} +datetest 2.75 {date('2024-02-29','+1 yr')} {2025-02-28} +datetest 2.76 {date('2024-02-29','-110 years')} {1914-03-01} +datetest 2.77 {date('2024-02-29','-110 yrs')} {1914-02-28} + datetest 3.1 {strftime('%d','2003-10-31 12:34:56.432')} 31 datetest 3.2.1 {strftime('pre%fpost','2003-10-31 12:34:56.432')} pre56.432post datetest 3.2.2 {strftime('%f','2003-10-31 12:34:59.9999999')} 59.999 From aefa7afddbe11afa11aa972fe096d34ec0338ce2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 3 Mar 2024 20:15:36 +0000 Subject: [PATCH 0160/1030] Back out the previous change. Replace it with new date modifiers "ceiling" and "floor". FossilOrigin-Name: f0831cced2c919e409214d936c81473ae321a98c5bd78b5b729c1269bf71bc45 --- manifest | 15 ++++---- manifest.uuid | 2 +- src/date.c | 100 ++++++++++++++++++++++++++++++++++++------------- test/date.test | 56 ++++++++++++++++++++++----- 4 files changed, 130 insertions(+), 43 deletions(-) diff --git a/manifest b/manifest index 8e0dc8a667..69581e9a5b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\sdate/time\smodifiers\s"mnth"\sand\s"yr"\swork\slike\s"month"\sand\s"year"\sbut\nresolve\sday-of-month\soverflow\sby\struncating\srather\sthan\srolling\sover\sinto\nthe\snext\smonth.\s[forum:/forumpost/232d1abb5d|Forum\sthread\s232d1abb5d] -D 2024-03-02T21:02:41.160 +C Back\sout\sthe\sprevious\schange.\s\sReplace\sit\swith\snew\sdate\smodifiers\s"ceiling"\nand\s"floor". +D 2024-03-03T20:15:36.398 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -696,7 +696,7 @@ F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c 89083264f1832e2bb892d6b313a6c642a5cd730cfcc89574019aa06c69192dcd +F src/date.c b36a3cc75ac691bf72b4759130b04ac2926af6fd4ca98df3400ff20d34a15878 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -1042,7 +1042,7 @@ F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c47 F test/cursorhint.test 05cf0febe5c5f8a31f199401fd1c9322249e753950d55f26f9d5aca61408a270 F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8 -F test/date.test 9583b421058d8366a06d4a07135ced29b64e31b5e7dafd03a2040bf84ef69adb +F test/date.test 99bfd3a77a3f9ae54eebd374a4301af960f2b2e9a581cf63e26445bae830a435 F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1 F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5 F test/date4.test 75dc8401e8c0639a228cd26a6eaa4ff5ea8ccda912b9853d1c9462c476670e17 @@ -2176,9 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 803481f25020f3c25941f1e7d1a8071937820dea951e8798198b0b0fa3fb48ce 296b46c529d79385d7f4db2c789254a992c01ff66fe8ba6d3a3ce4aaac0203fb -R e86e5c292ead4f22cefd158cafe4f8bc -T +closed 296b46c529d79385d7f4db2c789254a992c01ff66fe8ba6d3a3ce4aaac0203fb +P 5d392c16bb5658bc92f60d250ab82c45cc109e32d58a073498c9a487b8625e96 +R 9967c002ac0a5c05f7a39fb253518624 U drh -Z b02519e2fed4e4d80162d593e160efa1 +Z 10e35251deea062b6c8093330abd75ed # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d954bb7e4a..deb11dc730 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d392c16bb5658bc92f60d250ab82c45cc109e32d58a073498c9a487b8625e96 \ No newline at end of file +f0831cced2c919e409214d936c81473ae321a98c5bd78b5b729c1269bf71bc45 \ No newline at end of file diff --git a/src/date.c b/src/date.c index d4c3afdd38..37bf7fdb4f 100644 --- a/src/date.c +++ b/src/date.c @@ -71,13 +71,14 @@ struct DateTime { int tz; /* Timezone offset in minutes */ double s; /* Seconds */ char validJD; /* True (1) if iJD is valid */ - char rawS; /* Raw numeric value stored in s */ char validYMD; /* True (1) if Y,M,D are valid */ char validHMS; /* True (1) if h,m,s are valid */ char validTZ; /* True (1) if tz is valid */ - char tzSet; /* Timezone was set explicitly */ - char isError; /* An overflow has occurred */ - char useSubsec; /* Display subsecond precision */ + char nFloor; /* Days to implement "floor" */ + unsigned rawS : 1; /* Raw numeric value stored in s */ + unsigned tzSet : 1; /* Timezone was set explicitly */ + unsigned isError : 1; /* An overflow has occurred */ + unsigned useSubsec : 1; /* Display subsecond precision */ }; @@ -287,6 +288,29 @@ static void computeJD(DateTime *p){ } } +/* +** Given the YYYY-MM-DD information current in p, determine if there +** is day-of-month overflow and set nFloor to the number of days that +** would need to be subtracted from the date in order to bring the +** date back to the end of the month. +*/ +static void computeFloor(DateTime *p){ + assert( p->validYMD || p->isError ); + assert( (p->D>=1 && p->D<=31) || p->isError ); + assert( (p->M>=1 && p->M<=12) || p->isError ); + if( p->D<=28 ){ + p->nFloor = 0; + }else if( (1<M) & 0x15aa ){ + p->nFloor = 0; + }else if( p->M!=2 ){ + p->nFloor = (p->D==31); + }else if( p->Y%4!=0 || (p->Y%100==0 && p->Y%400!=0) ){ + p->nFloor = p->D - 28; + }else{ + p->nFloor = p->D - 29; + } +} + /* ** Parse dates of the form ** @@ -325,6 +349,7 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){ p->Y = neg ? -Y : Y; p->M = M; p->D = D; + computeFloor(p); if( p->validTZ ){ computeJD(p); } @@ -635,9 +660,7 @@ static const struct { /* 2 */ { 4, "hour", 1.2897e+11, 3600.0 }, /* 3 */ { 3, "day", 5373485.0, 86400.0 }, /* 4 */ { 5, "month", 176546.0, 30.0*86400.0 }, - /* 5 */ { 4, "mnth", 176546.0, 30.0*86400.0 }, - /* 6 */ { 4, "year", 14713.0, 365.0*86400.0 }, - /* 7 */ { 2, "yr", 14713.0, 365.0*86400.0 }, + /* 5 */ { 4, "year", 14713.0, 365.0*86400.0 }, }; /* @@ -669,14 +692,20 @@ static void autoAdjustDate(DateTime *p){ ** NNN.NNNN seconds ** NNN months ** NNN years +** +/-YYYY-MM-DD HH:MM:SS.SSS +** ceiling +** floor ** start of month ** start of year ** start of week ** start of day ** weekday N ** unixepoch +** auto ** localtime ** utc +** subsec +** subsecond ** ** Return 0 on success and 1 if there is any kind of error. If the error ** is in a system call (i.e. localtime()), then an error message is written @@ -707,6 +736,37 @@ static int parseModifier( } break; } + case 'c': { + /* + ** ceiling + ** + ** Resolve day-of-month overflow by rolling forward into the next + ** month. As this is the default action, this modifier is really + ** a no-op that is only included for symmetry. See "floor". + */ + if( sqlite3_stricmp(z, "ceiling")==0 ){ + computeJD(p); + clearYMD_HMS_TZ(p); + rc = 0; + p->nFloor = 0; + } + break; + } + case 'f': { + /* + ** floor + ** + ** Resolve day-of-month overflow by rolling back to the end of the + ** previous month. + */ + if( sqlite3_stricmp(z, "floor")==0 ){ + computeJD(p); + p->iJD -= p->nFloor*86400000; + clearYMD_HMS_TZ(p); + rc = 0; + } + break; + } case 'j': { /* ** julianday @@ -912,6 +972,7 @@ static int parseModifier( x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12; p->Y += x; p->M -= x*12; + computeFloor(p); computeJD(p); p->validHMS = 0; p->validYMD = 0; @@ -958,54 +1019,43 @@ static int parseModifier( z += n; while( sqlite3Isspace(*z) ) z++; n = sqlite3Strlen30(z); - if( n>10 || n<2 ) break; + if( n<3 || n>10 ) break; if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--; computeJD(p); assert( rc==1 ); rRounder = r<0 ? -0.5 : +0.5; + p->nFloor = 0; for(i=0; i-aXformType[i].rLimit && rM += (int)r; x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12; p->Y += x; p->M -= x*12; - assert( p->M>=1 && p->M<=12 ); - if( i==5 ) targetMonth = p->M; + computeFloor(p); p->validJD = 0; r -= (int)r; break; } - case 6: - case 7: { /* Special processing to add years */ + case 5: { /* Special processing to add years */ int y = (int)r; - assert( strcmp(aXformType[6].zName,"year")==0 ); - assert( strcmp(aXformType[7].zName,"yr")==0 ); + assert( strcmp(aXformType[5].zName,"year")==0 ); computeYMD_HMS(p); assert( p->M>=1 && p->M<=12 ); - if( i==7 ) targetMonth = p->M; p->Y += y; + computeFloor(p); p->validJD = 0; r -= (int)r; break; } } computeJD(p); - if( targetMonth>0 ){ - p->validYMD = 0; - computeYMD(p); - if( p->M==targetMonth+1 ) p->iJD -= p->D*86400000; - p->validYMD = 0; - } p->iJD += (sqlite3_int64)(r*1000.0*aXformType[i].rXform + rRounder); rc = 0; break; diff --git a/test/date.test b/test/date.test index f0616f6570..2a6e93df40 100644 --- a/test/date.test +++ b/test/date.test @@ -148,15 +148,6 @@ datetest 2.51 {datetime('2003-10-22 12:24','nonsense')} NULL datetest 2.60 {datetime('2023-02-31')} {2023-03-03 00:00:00} -datetest 2.70 {date('2024-01-31','+1 month')} {2024-03-02} -datetest 2.71 {date('2024-01-31','+1 mnth')} {2024-02-29} -datetest 2.72 {date('2023-01-31','+1 month')} {2023-03-03} -datetest 2.73 {date('2023-01-31','+1 mnth')} {2023-02-28} -datetest 2.74 {date('2024-02-29','+1 year')} {2025-03-01} -datetest 2.75 {date('2024-02-29','+1 yr')} {2025-02-28} -datetest 2.76 {date('2024-02-29','-110 years')} {1914-03-01} -datetest 2.77 {date('2024-02-29','-110 yrs')} {1914-02-28} - datetest 3.1 {strftime('%d','2003-10-31 12:34:56.432')} 31 datetest 3.2.1 {strftime('pre%fpost','2003-10-31 12:34:56.432')} pre56.432post datetest 3.2.2 {strftime('%f','2003-10-31 12:34:59.9999999')} 59.999 @@ -582,4 +573,51 @@ datetest 18.2 {unixepoch('1970-01-01T00:00:00.1', 'subsec')} {0.1} datetest 18.3 {unixepoch('1970-01-01T00:00:00.2', 'subsecond')} {0.2} datetest 18.4 {julianday('-4713-11-24 13:40:48.864', 'subsec')} {0.07001} datetest 18.5 {typeof(unixepoch('now', 'subsecond'))} {real} + +# 2024-03-03 the 'ceiling' and 'floor' operators. +# +datetest 19.1 {date('2000-01-31','floor')} {2000-01-31} +datetest 19.2a {date('2000-02-31','floor')} {2000-02-29} +datetest 19.2b {date('1999-02-31','floor')} {1999-02-28} +datetest 19.2c {date('1900-02-31','floor')} {1900-02-28} +datetest 19.3 {date('2000-03-31','floor')} {2000-03-31} +datetest 19.4 {date('2000-04-31','floor')} {2000-04-30} +datetest 19.5 {date('2000-05-31','floor')} {2000-05-31} +datetest 19.6 {date('2000-06-31','floor')} {2000-06-30} +datetest 19.7 {date('2000-07-31','floor')} {2000-07-31} +datetest 19.8 {date('2000-08-31','floor')} {2000-08-31} +datetest 19.9 {date('2000-09-31','floor')} {2000-09-30} +datetest 19.10 {date('2000-10-31','floor')} {2000-10-31} +datetest 19.11 {date('2000-11-31','floor')} {2000-11-30} +datetest 19.12 {date('2000-12-31','floor')} {2000-12-31} +datetest 19.21 {date('2000-01-31','ceiling')} {2000-01-31} +datetest 19.22a {date('2000-02-31','ceiling')} {2000-03-02} +datetest 19.22b {date('1999-02-31','ceiling')} {1999-03-03} +datetest 19.22c {date('1900-02-31','ceiling')} {1900-03-03} +datetest 19.23 {date('2000-03-31','ceiling')} {2000-03-31} +datetest 19.24 {date('2000-04-31','ceiling')} {2000-05-01} +datetest 19.25 {date('2000-05-31','ceiling')} {2000-05-31} +datetest 19.26 {date('2000-06-31','ceiling')} {2000-07-01} +datetest 19.27 {date('2000-07-31','ceiling')} {2000-07-31} +datetest 19.28 {date('2000-08-31','ceiling')} {2000-08-31} +datetest 19.29 {date('2000-09-31','ceiling')} {2000-10-01} +datetest 19.30 {date('2000-10-31','ceiling')} {2000-10-31} +datetest 19.31 {date('2000-11-31','ceiling')} {2000-12-01} +datetest 19.32 {date('2000-12-31','ceiling')} {2000-12-31} +datetest 19.40 {date('2024-01-31','+1 month','ceiling')} {2024-03-02} +datetest 19.41 {date('2024-01-31','+1 month','floor')} {2024-02-29} +datetest 19.42 {date('2023-01-31','+1 month','ceiling')} {2023-03-03} +datetest 19.43 {date('2023-01-31','+1 month','floor')} {2023-02-28} +datetest 19.44 {date('2024-02-29','+1 year','ceiling')} {2025-03-01} +datetest 19.45 {date('2024-02-29','+1 year','floor')} {2025-02-28} +datetest 19.46 {date('2024-02-29','-110 years','ceiling')} {1914-03-01} +datetest 19.47 {date('2024-02-29','-110 years','floor')} {1914-02-28} +datetest 19.48 {date('2024-02-29','-0110-00-00','floor')} {1914-02-28} +datetest 19.49 {date('2024-02-29','-0110-00-00','ceiling')} {1914-03-01} +datetest 19.50 {date('2000-08-31','+0023-06-00','floor')} {2024-02-29} +datetest 19.51 {date('2000-08-31','+0022-06-00','floor')} {2023-02-28} +datetest 19.52 {date('2000-08-31','+0023-06-00','ceiling')} {2024-03-02} +datetest 19.53 {date('2000-08-31','+0022-06-00','ceiling')} {2023-03-03} + + finish_test From e6af60c14f8b11c68fca76a0d1aba1c4696b51c2 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 4 Mar 2024 06:54:41 +0000 Subject: [PATCH 0161/1030] After wasm bootstrapping has read the optional global-scope config objects, delete those objects because any further changes would not have any useful effect. Expand the docs regarding the sqlite3ApiBootstrap() config object and explain the necessary evil of a separate global-scope object for that configuration. FossilOrigin-Name: e6b14f73136aae4c1a92d6d6ab8c5d1510db5244d0b0f168eed5b4b257c99064 --- ext/wasm/api/sqlite3-api-prologue.js | 32 +++++++++++++++++++++++++++- manifest | 14 ++++++------ manifest.uuid | 2 +- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index c784b69909..d3c8e9ffba 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -37,7 +37,7 @@ This function expects a configuration object, intended to abstract away details specific to any given WASM environment, primarily so - that it can be used without any _direct_ dependency on + that it can be used without any direct dependency on Emscripten. (Note the default values for the config object!) The config object is only honored the first time this is called. Subsequent calls ignore the argument and return the same @@ -98,6 +98,27 @@ The returned object is the top-level sqlite3 namespace object. + + Client code may optionally assign sqlite3ApiBootstrap.defaultConfig + an object-type value before calling sqlite3ApiBootstrap() (without + arguments) in order to tell that call to use this object as its + default config value. The intention of this is to provide + downstream clients with a reasonably flexible approach for plugging + in an environment-suitable configuration without having to define a + new global-scope symbol. + + However, because clients who access this library via an + Emscripten-hosted module will not have an opportunity to call + sqlite3ApiBootstrap() themselves, nor to access it before it is + called, an alternative option for setting the configuration is to + define globalThis.sqlite3ApiConfig to an object. If it is set, it + is used instead of sqlite3ApiBootstrap.defaultConfig if + sqlite3ApiBootstrap() is called without arguments. + + Both sqlite3ApiBootstrap.defaultConfig and + globalThis.sqlite3ApiConfig get deleted by sqlite3ApiBootstrap() + because any changes to them made after that point would have no + useful effect. */ 'use strict'; globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( @@ -149,6 +170,15 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( config[k] = config[k](); } }); + + /** + Eliminate any confusion about whether these config objects may + be used after library initialization by eliminating the outward-facing + objects... + */ + delete globalThis.sqlite3ApiConfig; + delete sqlite3ApiBootstrap.defaultConfig; + /** The main sqlite3 binding API gets installed into this object, mimicking the C API as closely as we can. The numerous members diff --git a/manifest b/manifest index 69581e9a5b..5d8e095922 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\sthe\sprevious\schange.\s\sReplace\sit\swith\snew\sdate\smodifiers\s"ceiling"\nand\s"floor". -D 2024-03-03T20:15:36.398 +C After\swasm\sbootstrapping\shas\sread\sthe\soptional\sglobal-scope\sconfig\sobjects,\sdelete\sthose\sobjects\sbecause\sany\sfurther\schanges\swould\snot\shave\sany\suseful\seffect.\sExpand\sthe\sdocs\sregarding\sthe\ssqlite3ApiBootstrap()\sconfig\sobject\sand\sexplain\sthe\snecessary\sevil\sof\sa\sseparate\sglobal-scope\sobject\sfor\sthat\sconfiguration. +D 2024-03-04T06:54:41.070 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -607,7 +607,7 @@ F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057af F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.js 587dc6db2d69329a5f4cb9635c377f516cf4a8e30f443f33380e5044889ec71b F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0 -F ext/wasm/api/sqlite3-api-prologue.js fffcee629bf020a8ccf5c367fbe6a169f5d5d73dfce1707a75c9fbf4aa21c7da +F ext/wasm/api/sqlite3-api-prologue.js 5f09126bc807fc506f9922a88228abb553fcbfa676a5724aa6d08e148e32af5b F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5d392c16bb5658bc92f60d250ab82c45cc109e32d58a073498c9a487b8625e96 -R 9967c002ac0a5c05f7a39fb253518624 -U drh -Z 10e35251deea062b6c8093330abd75ed +P f0831cced2c919e409214d936c81473ae321a98c5bd78b5b729c1269bf71bc45 +R 4a8c0aeaafa0cb5a978f136d9342c53b +U stephan +Z 2d4a13ca44f781b5c37a0c6aad22e4d0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index deb11dc730..399be41ba6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0831cced2c919e409214d936c81473ae321a98c5bd78b5b729c1269bf71bc45 \ No newline at end of file +e6b14f73136aae4c1a92d6d6ab8c5d1510db5244d0b0f168eed5b4b257c99064 \ No newline at end of file From bae55a768505c448384985a9cf9ddcd18c8107ca Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 4 Mar 2024 09:23:52 +0000 Subject: [PATCH 0162/1030] When warning about multiple invocations of JS's sqlite3ApiBootstrap(), use the warning logger installed by the first invocation, rather than console.warn. FossilOrigin-Name: d162af2d9941cd8c53e3928efb42aaaf4e59454f7d39aebf980a30b1427ea75b --- ext/wasm/api/sqlite3-api-prologue.js | 6 ++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index d3c8e9ffba..5fe587c147 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -125,8 +125,10 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( apiConfig = (globalThis.sqlite3ApiConfig || sqlite3ApiBootstrap.defaultConfig) ){ if(sqlite3ApiBootstrap.sqlite3){ /* already initalized */ - console.warn("sqlite3ApiBootstrap() called multiple times.", - "Config and external initializers are ignored on calls after the first."); + (sqlite3ApiBootstrap.sqlite3.config || console).warn( + "sqlite3ApiBootstrap() called multiple times.", + "Config and external initializers are ignored on calls after the first." + ); return sqlite3ApiBootstrap.sqlite3; } const config = Object.assign(Object.create(null),{ diff --git a/manifest b/manifest index 5d8e095922..3c3e555b90 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C After\swasm\sbootstrapping\shas\sread\sthe\soptional\sglobal-scope\sconfig\sobjects,\sdelete\sthose\sobjects\sbecause\sany\sfurther\schanges\swould\snot\shave\sany\suseful\seffect.\sExpand\sthe\sdocs\sregarding\sthe\ssqlite3ApiBootstrap()\sconfig\sobject\sand\sexplain\sthe\snecessary\sevil\sof\sa\sseparate\sglobal-scope\sobject\sfor\sthat\sconfiguration. -D 2024-03-04T06:54:41.070 +C When\swarning\sabout\smultiple\sinvocations\sof\sJS's\ssqlite3ApiBootstrap(),\suse\sthe\swarning\slogger\sinstalled\sby\sthe\sfirst\sinvocation,\srather\sthan\sconsole.warn. +D 2024-03-04T09:23:52.944 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -607,7 +607,7 @@ F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057af F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.js 587dc6db2d69329a5f4cb9635c377f516cf4a8e30f443f33380e5044889ec71b F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0 -F ext/wasm/api/sqlite3-api-prologue.js 5f09126bc807fc506f9922a88228abb553fcbfa676a5724aa6d08e148e32af5b +F ext/wasm/api/sqlite3-api-prologue.js 5000fea107dcd2754c1d9c9080a8d534ad7e299bb6f8ad6dd97c08740fde2dca F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f0831cced2c919e409214d936c81473ae321a98c5bd78b5b729c1269bf71bc45 -R 4a8c0aeaafa0cb5a978f136d9342c53b +P e6b14f73136aae4c1a92d6d6ab8c5d1510db5244d0b0f168eed5b4b257c99064 +R 386793253f6df9a64972715ed54c745e U stephan -Z 2d4a13ca44f781b5c37a0c6aad22e4d0 +Z 0abd34f742b690ed7162270a587892b4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 399be41ba6..191350b6e0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e6b14f73136aae4c1a92d6d6ab8c5d1510db5244d0b0f168eed5b4b257c99064 \ No newline at end of file +d162af2d9941cd8c53e3928efb42aaaf4e59454f7d39aebf980a30b1427ea75b \ No newline at end of file From 2775f10ebcebc303fa18ab12bd1697ed0794fdcd Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 4 Mar 2024 09:56:47 +0000 Subject: [PATCH 0163/1030] Document why the wasm build does not use Emscripten's -sSTRICT=1 flag and account for a behaviour change in emsdk 3.1.55 regarding the HEAPxyz symbols. FossilOrigin-Name: f6e887203365b30cea6e9c145366345e48256a347388577edf2bada65e0655b7 --- ext/wasm/GNUmakefile | 9 +++++++++ ext/wasm/api/sqlite3-api-prologue.js | 12 ++++++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 75fc785182..098a4330b0 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -531,6 +531,10 @@ emcc.jsflags += -sSTRICT_JS=0 # 3.1.31. The fix for that in newer emcc's is to throw a built-time # error if STRICT_JS is used together with those options. +# emcc.jsflags += -sSTRICT=1 +# -sSTRICT=1 Causes failures about unknown symbols which the build +# tools should be installing, e.g. __syscall_geteuid32 + # -sENVIRONMENT values for the various build modes: emcc.environment.vanilla := web,worker emcc.environment.bundler-friendly := $(emcc.environment.vanilla) @@ -551,6 +555,11 @@ emcc.environment.node := node # time with 16mb+ memory and 3X time when starting with 8MB. However, # such test results are inconsistent due to browser internals which # are opaque to us. +# +# 2024-03-04: emsdk 3.1.55 replaces INITIAL_MEMORY with INITIAL_HEAP, +# but also says (in its changelog): "Note that it is currently not +# supported in all configurations (#21071)." +# https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md emcc.jsflags += -sALLOW_MEMORY_GROWTH emcc.INITIAL_MEMORY.128 := 134217728 emcc.INITIAL_MEMORY.96 := 100663296 diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index 5fe587c147..c3cc25f43a 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -137,8 +137,16 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( bigIntEnabled: (()=>{ if('undefined'!==typeof Module){ /* Emscripten module will contain HEAPU64 when built with - -sWASM_BIGINT=1, else it will not. */ - return !!Module.HEAPU64; + -sWASM_BIGINT=1, else it will not. + + As of emsdk 3.1.55, when building in strict mode, HEAPxyz + are only available if _explicitly_ included in the exports, + else they are not. We do not (as of 2024-03-04) use -sSTRICT + for the canonical builds. + */ + if( !!Module.HEAPU64 ) return true; + /* Else fall through and hope for the best. Nobody _really_ + builds this without BigInt support, do they? */ } return !!globalThis.BigInt64Array; })(), diff --git a/manifest b/manifest index 3c3e555b90..0705277b93 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\swarning\sabout\smultiple\sinvocations\sof\sJS's\ssqlite3ApiBootstrap(),\suse\sthe\swarning\slogger\sinstalled\sby\sthe\sfirst\sinvocation,\srather\sthan\sconsole.warn. -D 2024-03-04T09:23:52.944 +C Document\swhy\sthe\swasm\sbuild\sdoes\snot\suse\sEmscripten's\s-sSTRICT=1\sflag\sand\saccount\sfor\sa\sbehaviour\schange\sin\semsdk\s3.1.55\sregarding\sthe\sHEAPxyz\ssymbols. +D 2024-03-04T09:56:47.061 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -587,7 +587,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 316349101671037a30311fbb40bd0b8702d9a223b5205a6a5eae8bac7b8dc1a0 +F ext/wasm/GNUmakefile 92e929315c3f1e0ea389fc9666b87a67a61fa1ecbe37e44c5ad226bda3bc6abe F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -607,7 +607,7 @@ F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057af F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.js 587dc6db2d69329a5f4cb9635c377f516cf4a8e30f443f33380e5044889ec71b F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0 -F ext/wasm/api/sqlite3-api-prologue.js 5000fea107dcd2754c1d9c9080a8d534ad7e299bb6f8ad6dd97c08740fde2dca +F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e6b14f73136aae4c1a92d6d6ab8c5d1510db5244d0b0f168eed5b4b257c99064 -R 386793253f6df9a64972715ed54c745e +P d162af2d9941cd8c53e3928efb42aaaf4e59454f7d39aebf980a30b1427ea75b +R a1392e5e8b70ba68a9cec5956be8638d U stephan -Z 0abd34f742b690ed7162270a587892b4 +Z eecd3ea1a1eec87bef8ed5be6afc5f59 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 191350b6e0..4b98f8cca6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d162af2d9941cd8c53e3928efb42aaaf4e59454f7d39aebf980a30b1427ea75b \ No newline at end of file +f6e887203365b30cea6e9c145366345e48256a347388577edf2bada65e0655b7 \ No newline at end of file From 8d25d07d50ecfdf82b2148606fb1bdce24509bd2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 4 Mar 2024 11:12:15 +0000 Subject: [PATCH 0164/1030] Fix assert() statements in date/time computations: The month and day numbers can be zero if an error has been seen. FossilOrigin-Name: fc773f6c76ec114be8b6e25b13885acb5adcc9d052dca0d8d0ff94e2a0743d64 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/date.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 0705277b93..f23cc045a5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Document\swhy\sthe\swasm\sbuild\sdoes\snot\suse\sEmscripten's\s-sSTRICT=1\sflag\sand\saccount\sfor\sa\sbehaviour\schange\sin\semsdk\s3.1.55\sregarding\sthe\sHEAPxyz\ssymbols. -D 2024-03-04T09:56:47.061 +C Fix\sassert()\sstatements\sin\sdate/time\scomputations:\sThe\smonth\sand\sday\snumbers\ncan\sbe\szero\sif\san\serror\shas\sbeen\sseen. +D 2024-03-04T11:12:15.305 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -696,7 +696,7 @@ F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c b36a3cc75ac691bf72b4759130b04ac2926af6fd4ca98df3400ff20d34a15878 +F src/date.c 29cecfe69287242a12f753ffc883e4231afde3af501fb1b4a7b721b159fc4bb2 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d162af2d9941cd8c53e3928efb42aaaf4e59454f7d39aebf980a30b1427ea75b -R a1392e5e8b70ba68a9cec5956be8638d -U stephan -Z eecd3ea1a1eec87bef8ed5be6afc5f59 +P f6e887203365b30cea6e9c145366345e48256a347388577edf2bada65e0655b7 +R 68522a41082e7767e1ccbf426313c9cf +U drh +Z cb9173c28803c9d207f1634b7853f7aa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4b98f8cca6..9788f68f52 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f6e887203365b30cea6e9c145366345e48256a347388577edf2bada65e0655b7 \ No newline at end of file +fc773f6c76ec114be8b6e25b13885acb5adcc9d052dca0d8d0ff94e2a0743d64 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 37bf7fdb4f..239a772ca2 100644 --- a/src/date.c +++ b/src/date.c @@ -296,8 +296,8 @@ static void computeJD(DateTime *p){ */ static void computeFloor(DateTime *p){ assert( p->validYMD || p->isError ); - assert( (p->D>=1 && p->D<=31) || p->isError ); - assert( (p->M>=1 && p->M<=12) || p->isError ); + assert( p->D>=0 && p->D<=31 ); + assert( p->M>=0 && p->M<=12 ); if( p->D<=28 ){ p->nFloor = 0; }else if( (1<M) & 0x15aa ){ @@ -1047,7 +1047,7 @@ static int parseModifier( int y = (int)r; assert( strcmp(aXformType[5].zName,"year")==0 ); computeYMD_HMS(p); - assert( p->M>=1 && p->M<=12 ); + assert( p->M>=0 && p->M<=12 ); p->Y += y; computeFloor(p); p->validJD = 0; From 3f273db39b080803219d2100fc066f17638db348 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 4 Mar 2024 13:58:09 +0000 Subject: [PATCH 0165/1030] Adjust date/time functions so that they do a better job of keeping track of whether the current time is UTC or localtime, and no-op the 'utc' and 'localtime' modifiers accordingly. See [forum:/info/e7a939e074|forum post e7a939e074]. Also add the datedebug() function, available only under -DSQLITE_DEBUG, for improved visibility of the DateTime object during debugging and testing. FossilOrigin-Name: dc569683748354a6db83438904422e802d3ea780775c48da85b474fff03ca8a1 --- manifest | 16 ++++----- manifest.uuid | 2 +- src/date.c | 78 ++++++++++++++++++++++++++++++---------- test/date.test | 34 +++++++++++++++++- test/tkt-bd484a090c.test | 2 +- 5 files changed, 103 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index f23cc045a5..e7d61781cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sassert()\sstatements\sin\sdate/time\scomputations:\sThe\smonth\sand\sday\snumbers\ncan\sbe\szero\sif\san\serror\shas\sbeen\sseen. -D 2024-03-04T11:12:15.305 +C Adjust\sdate/time\sfunctions\sso\sthat\sthey\sdo\sa\sbetter\sjob\sof\skeeping\strack\nof\swhether\sthe\scurrent\stime\sis\sUTC\sor\slocaltime,\sand\sno-op\sthe\s'utc'\sand\n'localtime'\smodifiers\saccordingly.\sSee\n[forum:/info/e7a939e074|forum\spost\se7a939e074].\nAlso\sadd\sthe\sdatedebug()\sfunction,\savailable\nonly\sunder\s-DSQLITE_DEBUG,\sfor\simproved\svisibility\sof\sthe\sDateTime\sobject\nduring\sdebugging\sand\stesting. +D 2024-03-04T13:58:09.237 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -696,7 +696,7 @@ F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c 29cecfe69287242a12f753ffc883e4231afde3af501fb1b4a7b721b159fc4bb2 +F src/date.c a9e4382961fb26156a308645f7363519ab7eb20e412e78b7c1fe16bbfbb1689a F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -1042,7 +1042,7 @@ F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c47 F test/cursorhint.test 05cf0febe5c5f8a31f199401fd1c9322249e753950d55f26f9d5aca61408a270 F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8 -F test/date.test 99bfd3a77a3f9ae54eebd374a4301af960f2b2e9a581cf63e26445bae830a435 +F test/date.test c8ff835023f2107b57ce7a45c92265d51c98a23fc93231e998f12d850831aad6 F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1 F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5 F test/date4.test 75dc8401e8c0639a228cd26a6eaa4ff5ea8ccda912b9853d1c9462c476670e17 @@ -1749,7 +1749,7 @@ F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0 F test/tkt-b72787b1.test a95e8cdad0b98af1853ac7f0afd4ab27b77bf5f3 F test/tkt-b75a9ca6b0.test dc6a853c242f7d0326564ae32e9e5eb462b5e8d2bc5b01ea3b18fd24f8e5894b F test/tkt-ba7cbfaedc.test b4c0deccc12aeb55cfdb57935b16b5d67c5a9877 -F test/tkt-bd484a090c.test 60460bf946f79a79712b71f202eda501ca99b898 +F test/tkt-bd484a090c.test e6af3e3a4242cd8f1c91c736364f09075d8e33e3b86f6492a1ee36278ea71b61 F test/tkt-bdc6bbbb38.test fc38bb09bdd440e3513a1f5f98fc60a075182d7d F test/tkt-c48d99d690.test ba61977d62ab612fc515b3c488a6fbd6464a2447 F test/tkt-c694113d5.test 82c461924ada5c14866c47e85535b0b0923ba16a2e907e370061a5ca77f65d77 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f6e887203365b30cea6e9c145366345e48256a347388577edf2bada65e0655b7 -R 68522a41082e7767e1ccbf426313c9cf +P fc773f6c76ec114be8b6e25b13885acb5adcc9d052dca0d8d0ff94e2a0743d64 +R 0f693fc7ce53368753332e9082e39c9c U drh -Z cb9173c28803c9d207f1634b7853f7aa +Z b0035812b357d7d3f0f59f737bf36230 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9788f68f52..7e9ada2541 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc773f6c76ec114be8b6e25b13885acb5adcc9d052dca0d8d0ff94e2a0743d64 \ No newline at end of file +dc569683748354a6db83438904422e802d3ea780775c48da85b474fff03ca8a1 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 239a772ca2..3bb4a8c714 100644 --- a/src/date.c +++ b/src/date.c @@ -73,12 +73,12 @@ struct DateTime { char validJD; /* True (1) if iJD is valid */ char validYMD; /* True (1) if Y,M,D are valid */ char validHMS; /* True (1) if h,m,s are valid */ - char validTZ; /* True (1) if tz is valid */ char nFloor; /* Days to implement "floor" */ unsigned rawS : 1; /* Raw numeric value stored in s */ - unsigned tzSet : 1; /* Timezone was set explicitly */ unsigned isError : 1; /* An overflow has occurred */ unsigned useSubsec : 1; /* Display subsecond precision */ + unsigned isUtc : 1; /* Time is known to be UTC */ + unsigned isLocal : 1; /* Time is known to be localtime */ }; @@ -176,6 +176,8 @@ static int parseTimezone(const char *zDate, DateTime *p){ sgn = +1; }else if( c=='Z' || c=='z' ){ zDate++; + p->isLocal = 0; + p->isUtc = 1; goto zulu_time; }else{ return c!=0; @@ -188,7 +190,6 @@ static int parseTimezone(const char *zDate, DateTime *p){ p->tz = sgn*(nMn + nHr*60); zulu_time: while( sqlite3Isspace(*zDate) ){ zDate++; } - p->tzSet = 1; return *zDate!=0; } @@ -232,7 +233,6 @@ static int parseHhMmSs(const char *zDate, DateTime *p){ p->m = m; p->s = s + ms; if( parseTimezone(zDate, p) ) return 1; - p->validTZ = (p->tz!=0)?1:0; return 0; } @@ -279,11 +279,13 @@ static void computeJD(DateTime *p){ p->validJD = 1; if( p->validHMS ){ p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000 + 0.5); - if( p->validTZ ){ + if( p->tz ){ p->iJD -= p->tz*60000; p->validYMD = 0; p->validHMS = 0; - p->validTZ = 0; + p->tz = 0; + p->isUtc = 1; + p->isLocal = 0; } } } @@ -350,11 +352,14 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){ p->M = M; p->D = D; computeFloor(p); - if( p->validTZ ){ + if( p->tz ){ computeJD(p); } return 0; -} +}; + + +static void clearYMD_HMS_TZ(DateTime *p); /* Forward declaration */ /* ** Set the time to the current time reported by the VFS. @@ -365,6 +370,9 @@ static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){ p->iJD = sqlite3StmtCurrentTime(context); if( p->iJD>0 ){ p->validJD = 1; + p->isUtc = 1; + p->isLocal = 0; + clearYMD_HMS_TZ(p); return 0; }else{ return 1; @@ -503,7 +511,7 @@ static void computeYMD_HMS(DateTime *p){ static void clearYMD_HMS_TZ(DateTime *p){ p->validYMD = 0; p->validHMS = 0; - p->validTZ = 0; + p->tz = 0; } #ifndef SQLITE_OMIT_LOCALTIME @@ -635,7 +643,7 @@ static int toLocaltime( p->validHMS = 1; p->validJD = 0; p->rawS = 0; - p->validTZ = 0; + p->tz = 0; p->isError = 0; return SQLITE_OK; } @@ -793,7 +801,9 @@ static int parseModifier( ** show local time. */ if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){ - rc = toLocaltime(p, pCtx); + rc = p->isLocal ? SQLITE_OK : toLocaltime(p, pCtx); + p->isUtc = 0; + p->isLocal = 1; } break; } @@ -818,7 +828,7 @@ static int parseModifier( } #ifndef SQLITE_OMIT_LOCALTIME else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){ - if( p->tzSet==0 ){ + if( p->isUtc==0 ){ i64 iOrigJD; /* Original localtime */ i64 iGuess; /* Guess at the corresponding utc time */ int cnt = 0; /* Safety to prevent infinite loop */ @@ -841,7 +851,8 @@ static int parseModifier( memset(p, 0, sizeof(*p)); p->iJD = iGuess; p->validJD = 1; - p->tzSet = 1; + p->isUtc = 1; + p->isLocal = 0; } rc = SQLITE_OK; } @@ -861,7 +872,7 @@ static int parseModifier( && r>=0.0 && r<7.0 && (n=(int)r)==r ){ sqlite3_int64 Z; computeYMD_HMS(p); - p->validTZ = 0; + p->tz = 0; p->validJD = 0; computeJD(p); Z = ((p->iJD + 129600000)/86400000) % 7; @@ -901,7 +912,7 @@ static int parseModifier( p->h = p->m = 0; p->s = 0.0; p->rawS = 0; - p->validTZ = 0; + p->tz = 0; p->validJD = 0; if( sqlite3_stricmp(z,"month")==0 ){ p->D = 1; @@ -1674,9 +1685,7 @@ static void timediffFunc( d1.iJD = d2.iJD - d1.iJD; d1.iJD += (u64)1486995408 * (u64)100000; } - d1.validYMD = 0; - d1.validHMS = 0; - d1.validTZ = 0; + clearYMD_HMS_TZ(&d1); computeYMD_HMS(&d1); sqlite3StrAccumInit(&sRes, 0, 0, 0, 100); sqlite3_str_appendf(&sRes, "%c%04d-%02d-%02d %02d:%02d:%06.3f", @@ -1745,6 +1754,36 @@ static void currentTimeFunc( } #endif +#if !defined(SQLITE_OMIT_DATETIME_FUNCS) && defined(SQLITE_DEBUG) +/* +** datedebug(...) +** +** This routine returns JSON that describes the internal DateTime object. +** Used for debugging and testing only. Subject to change. +*/ +static void datedebugFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + DateTime x; + if( isDate(context, argc, argv, &x)==0 ){ + char *zJson; + zJson = sqlite3_mprintf( + "{iJD:%lld,Y:%d,M:%d,D:%d,h:%d,m:%d,tz:%d," + "s:%.3f,validJD:%d,validYMS:%d,validHMS:%d," + "nFloor:%d,rawS:%d,isError:%d,useSubsec:%d," + "isUtc:%d,isLocal:%d}", + x.iJD, x.Y, x.M, x.D, x.h, x.m, x.tz, + x.s, x.validJD, x.validYMD, x.validHMS, + x.nFloor, x.rawS, x.isError, x.useSubsec, + x.isUtc, x.isLocal); + sqlite3_result_text(context, zJson, -1, sqlite3_free); + } +} +#endif /* !SQLITE_OMIT_DATETIME_FUNCS && SQLITE_DEBUG */ + + /* ** This function registered all of the above C functions as SQL ** functions. This should be the only routine in this file with @@ -1760,6 +1799,9 @@ void sqlite3RegisterDateTimeFunctions(void){ PURE_DATE(datetime, -1, 0, 0, datetimeFunc ), PURE_DATE(strftime, -1, 0, 0, strftimeFunc ), PURE_DATE(timediff, 2, 0, 0, timediffFunc ), +#ifdef SQLITE_DEBUG + PURE_DATE(datedebug, -1, 0, 0, datedebugFunc ), +#endif DFUNCTION(current_time, 0, 0, 0, ctimeFunc ), DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc), DFUNCTION(current_date, 0, 0, 0, cdateFunc ), diff --git a/test/date.test b/test/date.test index 2a6e93df40..d22b652b47 100644 --- a/test/date.test +++ b/test/date.test @@ -262,7 +262,7 @@ datetest 5.15 {datetime('1994-04-16 14:00:00 +05:00 Z')} NULL # localtime->utc and utc->localtime conversions. # # Use SQLITE_TESTCTRL_LOCALTIME_FAULT=2 to set an alternative localtime_r() -# implementation that is not locale-dependent. This testing localtime_r() +# implementation that is not locale-dependent. The testing localtime_r() # operates as follows: # # (1) Localtime is 30 minutes earlier than (west of) UTC on @@ -321,6 +321,38 @@ utc_to_local 6.22 {1800-10-29 12:30:00} {1800-10-29 12:00:00} local_to_utc 6.23 {3000-10-30 12:00:00} {3000-10-30 11:30:00} utc_to_local 6.24 {3000-10-30 11:30:00} {3000-10-30 12:00:00} +# If the time is specified to be ZULU, or if it has an explicit +# timezone extension, then the time will already be UTC and subsequent +# 'utc' modifiers are no-ops. +# +do_execsql_test date-6.25 { + SELECT datetime('2000-10-29 12:00Z','utc','utc'); +} {{2000-10-29 12:00:00}} +do_execsql_test date-6.26 { + SELECT datetime('2000-10-29 12:00:00+05:00'); +} {{2000-10-29 07:00:00}} +do_execsql_test date-6.27 { + SELECT datetime('2000-10-29 12:00:00+05:00', 'utc'); +} {{2000-10-29 07:00:00}} + +# Multiple back-and-forth UTC to LOCAL to UTC... +do_execsql_test date-6.28 { + SELECT datetime('2000-10-29 12:00:00Z', 'localtime'); +} {{2000-10-29 12:30:00}} +do_execsql_test date-6.29 { + SELECT datetime('2000-10-29 12:00:00Z', 'utc', 'localtime'); +} {{2000-10-29 12:30:00}} +do_execsql_test date-6.30 { + SELECT datetime('2000-10-29 12:00:00Z', 'utc', 'localtime', 'utc'); +} {{2000-10-29 12:00:00}} +do_execsql_test date-6.31 { + SELECT datetime('2000-10-29 12:00:00Z', 'utc','localtime','utc','localtime'); +} {{2000-10-29 12:30:00}} +do_execsql_test date-6.32 { + SELECT datetime('2000-10-29 12:00:00Z', 'localtime','localtime'); +} {{2000-10-29 12:30:00}} + + # Restore the use of the OS localtime_r() before going on... sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0 diff --git a/test/tkt-bd484a090c.test b/test/tkt-bd484a090c.test index 3d2b599958..7867c8dc97 100644 --- a/test/tkt-bd484a090c.test +++ b/test/tkt-bd484a090c.test @@ -30,7 +30,7 @@ do_test 2.1 { catchsql { SELECT datetime('now', 'localtime') } } {1 {local time unavailable}} do_test 2.2 { - catchsql { SELECT datetime('now', 'utc') } + catchsql { SELECT datetime('2000-01-01', 'utc') } } {1 {local time unavailable}} sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0 From 90170503b4e1cfbab7ef600ef5957397b188f746 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 4 Mar 2024 16:18:40 +0000 Subject: [PATCH 0166/1030] Fix harmless compiler warnings in the increment integrity_check extension. FossilOrigin-Name: 596668e6625208ff5d2ffbb4e0530530ebb3a400efa0df54bad1d91953e32694 --- ext/intck/sqlite3intck.c | 5 ++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ext/intck/sqlite3intck.c b/ext/intck/sqlite3intck.c index 12d205e4d9..ed169a2664 100644 --- a/ext/intck/sqlite3intck.c +++ b/ext/intck/sqlite3intck.c @@ -422,7 +422,7 @@ static const char *intckParseCreateIndex(const char *z, int iCol, int *pnByte){ int n = intckGetToken(&z[iOff]); if( n==5 && 0==sqlite3_strnicmp(&z[iOff], "where", 5) ){ zRet = &z[iOff+5]; - nRet = strlen(zRet); + nRet = (int)strlen(zRet); } iOff += n; } @@ -785,7 +785,7 @@ int sqlite3_intck_open( sqlite3_intck *pNew = 0; int rc = SQLITE_OK; const char *zDb = zDbArg ? zDbArg : "main"; - int nDb = strlen(zDb); + int nDb = (int)strlen(zDb); pNew = (sqlite3_intck*)sqlite3_malloc(sizeof(*pNew) + nDb + 1); if( pNew==0 ){ @@ -938,4 +938,3 @@ const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){ } return p->zTestSql; } - diff --git a/manifest b/manifest index e7d61781cc..b78fb5ca46 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sdate/time\sfunctions\sso\sthat\sthey\sdo\sa\sbetter\sjob\sof\skeeping\strack\nof\swhether\sthe\scurrent\stime\sis\sUTC\sor\slocaltime,\sand\sno-op\sthe\s'utc'\sand\n'localtime'\smodifiers\saccordingly.\sSee\n[forum:/info/e7a939e074|forum\spost\se7a939e074].\nAlso\sadd\sthe\sdatedebug()\sfunction,\savailable\nonly\sunder\s-DSQLITE_DEBUG,\sfor\simproved\svisibility\sof\sthe\sDateTime\sobject\nduring\sdebugging\sand\stesting. -D 2024-03-04T13:58:09.237 +C Fix\sharmless\scompiler\swarnings\sin\sthe\sincrement\sintegrity_check\sextension. +D 2024-03-04T16:18:40.992 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -256,7 +256,7 @@ F ext/intck/intck_common.tcl 9e51458126576783f11051ac0fd25bea3f6b17f570a55884223 F ext/intck/intckbusy.test 0732fe3efbb9e0a53ffdcc240073f6ff2777ea82c3e08812b16494f650763fe1 F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 F ext/intck/intckfault.test ba0213c9c8dce08d519d5251268a3bab076a184b4d07acdea23b65e89c9ae03c -F ext/intck/sqlite3intck.c 52381a627637504a49e93400814b36e99afa0b972a9a24ef1732b8268bb27fa8 +F ext/intck/sqlite3intck.c 0d10df36e2b7b438aa80ecd3f5e584d41b747586b038258fe6b407f66b81e7c5 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 F ext/intck/test_intck.c d63f1707432802f5db125ee40b794923af77d4686869bd8d3a7eb43332344267 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fc773f6c76ec114be8b6e25b13885acb5adcc9d052dca0d8d0ff94e2a0743d64 -R 0f693fc7ce53368753332e9082e39c9c +P dc569683748354a6db83438904422e802d3ea780775c48da85b474fff03ca8a1 +R 7e46f34cc8a5ab9c09b7645f58d236c7 U drh -Z b0035812b357d7d3f0f59f737bf36230 +Z 8407adbd700d1bcd9619e8d4b35bf5f1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7e9ada2541..ebba8e337e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dc569683748354a6db83438904422e802d3ea780775c48da85b474fff03ca8a1 \ No newline at end of file +596668e6625208ff5d2ffbb4e0530530ebb3a400efa0df54bad1d91953e32694 \ No newline at end of file From 4cf953731f640c88db344dc2e6bab90db170049f Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 4 Mar 2024 16:44:37 +0000 Subject: [PATCH 0167/1030] Change test results in corruptC.test to account for the added detail in the output of "PRAGMA integrity_check" from [b736519d3d2e93c7]. FossilOrigin-Name: 0d19eeaafb296aad212ee4f55a0f6df8c7c5185b14d7f7f49c020fe4cbe370c1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/corruptC.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b78fb5ca46..9a3eabe50d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sthe\sincrement\sintegrity_check\sextension. -D 2024-03-04T16:18:40.992 +C Change\stest\sresults\sin\scorruptC.test\sto\saccount\sfor\sthe\sadded\sdetail\sin\sthe\noutput\sof\s"PRAGMA\sintegrity_check"\sfrom\s[b736519d3d2e93c7]. +D 2024-03-04T16:44:37.718 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1009,7 +1009,7 @@ F test/corrupt8.test 2399dfe40d2c0c63af86706e30f3e6302a8d0516 F test/corrupt9.test 730a3db08d4ab9aa43392ea30d9c2b4879cbff85 F test/corruptA.test 112f4b2ae0b95ebf3ea63718642fb969a93acea557ace3a307234d19c245989b F test/corruptB.test 73a8d6c0b9833697ecf16b63e3c5c05c945b5dec -F test/corruptC.test 9cf32275dae3ca33f645afe5d1d3f5ba5ac2af2b0833dfb5282f9dccb6fb81bb +F test/corruptC.test 7d6d9e907334ea3ccb7111a0656cafa30a28f8a5f2aaf1c45ad712236302856a F test/corruptD.test 614320aa519f6bf6c7dd2f581f9513ff7b6826954180cca1a606d0e25ea084a3 F test/corruptE.test 4143791f2dfb443aec5b7fabfa5821e6063eccc3b49b06f212c2f014715fd476 F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dc569683748354a6db83438904422e802d3ea780775c48da85b474fff03ca8a1 -R 7e46f34cc8a5ab9c09b7645f58d236c7 +P 596668e6625208ff5d2ffbb4e0530530ebb3a400efa0df54bad1d91953e32694 +R e247d8c69a2f1de22f60330dc6b8c1d7 U drh -Z 8407adbd700d1bcd9619e8d4b35bf5f1 +Z c67139450867debeac7f30d4414de41e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ebba8e337e..063d7c49a5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -596668e6625208ff5d2ffbb4e0530530ebb3a400efa0df54bad1d91953e32694 \ No newline at end of file +0d19eeaafb296aad212ee4f55a0f6df8c7c5185b14d7f7f49c020fe4cbe370c1 \ No newline at end of file diff --git a/test/corruptC.test b/test/corruptC.test index f5733a8186..bf324c120f 100644 --- a/test/corruptC.test +++ b/test/corruptC.test @@ -98,7 +98,7 @@ do_test corruptC-2.1 { sqlite3 db test.db catchsql {PRAGMA integrity_check} } {0 {{*** in database main *** -Tree 3 page 3: free space corruption}}} +Tree 3 page 3: free space corruption} {wrong # of entries in index t1i1}}} # test that a corrupt content offset size is handled (seed 5649) # From 18281494a27095687cb136783878fbbde8286f51 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 4 Mar 2024 18:22:18 +0000 Subject: [PATCH 0168/1030] Fix a compiler warning in date.c. Update makefiles to include all necessary dependencies for building shell.c. FossilOrigin-Name: 178b7d46f9c8e1694ed6f506d2785a9f5c49e2b428e04c8096d557cc1b5c9680 --- Makefile.in | 60 ++++++++++++++++++++++++++------------------------- Makefile.msc | 59 +++++++++++++++++++++++++++----------------------- main.mk | 60 +++++++++++++++++++++++++++------------------------ manifest | 18 ++++++++-------- manifest.uuid | 2 +- src/date.c | 2 +- 6 files changed, 106 insertions(+), 95 deletions(-) diff --git a/Makefile.in b/Makefile.in index e858e55c34..321fb75278 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1156,35 +1156,37 @@ keywordhash.h: $(TOP)/tool/mkkeywordhash.c $(BCC) -o mkkeywordhash$(BEXE) $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)/tool/mkkeywordhash.c ./mkkeywordhash$(BEXE) >keywordhash.h -# Source files that go into making shell.c -SHELL_SRC = \ - $(TOP)/src/shell.c.in \ - $(TOP)/ext/consio/console_io.c \ - $(TOP)/ext/consio/console_io.h \ - $(TOP)/ext/misc/appendvfs.c \ - $(TOP)/ext/misc/completion.c \ - $(TOP)/ext/misc/decimal.c \ - $(TOP)/ext/misc/basexx.c \ - $(TOP)/ext/misc/base64.c \ - $(TOP)/ext/misc/base85.c \ - $(TOP)/ext/misc/fileio.c \ - $(TOP)/ext/misc/ieee754.c \ - $(TOP)/ext/misc/regexp.c \ - $(TOP)/ext/misc/series.c \ - $(TOP)/ext/misc/shathree.c \ - $(TOP)/ext/misc/sqlar.c \ - $(TOP)/ext/misc/uint.c \ - $(TOP)/ext/expert/sqlite3expert.c \ - $(TOP)/ext/expert/sqlite3expert.h \ - $(TOP)/ext/misc/zipfile.c \ - $(TOP)/ext/misc/memtrace.c \ - $(TOP)/ext/misc/pcachetrace.c \ - $(TOP)/ext/recover/dbdata.c \ - $(TOP)/ext/recover/sqlite3recover.c \ - $(TOP)/ext/recover/sqlite3recover.h \ - $(TOP)/src/test_windirent.c - -shell.c: $(SHELL_SRC) $(TOP)/tool/mkshellc.tcl has_tclsh84 +# Source and header files that shell.c depends on +SHELL_DEP = \ + $(TOP)/src/shell.c.in \ + $(TOP)/ext/consio/console_io.c \ + $(TOP)/ext/consio/console_io.h \ + $(TOP)/ext/expert/sqlite3expert.c \ + $(TOP)/ext/expert/sqlite3expert.h \ + $(TOP)/ext/intck/sqlite3intck.c \ + $(TOP)/ext/intck/sqlite3intck.h \ + $(TOP)/ext/misc/appendvfs.c \ + $(TOP)/ext/misc/base64.c \ + $(TOP)/ext/misc/base85.c \ + $(TOP)/ext/misc/completion.c \ + $(TOP)/ext/misc/decimal.c \ + $(TOP)/ext/misc/fileio.c \ + $(TOP)/ext/misc/ieee754.c \ + $(TOP)/ext/misc/memtrace.c \ + $(TOP)/ext/misc/pcachetrace.c \ + $(TOP)/ext/misc/regexp.c \ + $(TOP)/ext/misc/series.c \ + $(TOP)/ext/misc/shathree.c \ + $(TOP)/ext/misc/sqlar.c \ + $(TOP)/ext/misc/uint.c \ + $(TOP)/ext/misc/zipfile.c \ + $(TOP)/ext/recover/dbdata.c \ + $(TOP)/ext/recover/sqlite3recover.c \ + $(TOP)/ext/recover/sqlite3recover.h \ + $(TOP)/src/test_windirent.c \ + $(TOP)/src/test_windirent.h + +shell.c: $(SHELL_DEP) $(TOP)/tool/mkshellc.tcl has_tclsh84 $(TCLSH_CMD) $(TOP)/tool/mkshellc.tcl >shell.c diff --git a/Makefile.msc b/Makefile.msc index d0875c92e1..2f67600c31 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2272,39 +2272,44 @@ mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c keywordhash.h: $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe .\mkkeywordhash.exe > keywordhash.h -# Source files that go into making shell.c -SHELL_SRC = \ - $(TOP)\src\shell.c.in \ - $(TOP)\ext\consio\console_io.c \ - $(TOP)\ext\consio\console_io.h \ - $(TOP)\ext\misc\appendvfs.c \ - $(TOP)\ext\misc\completion.c \ - $(TOP)\ext\misc\base64.c \ - $(TOP)\ext\misc\base85.c \ - $(TOP)\ext\misc\decimal.c \ - $(TOP)\ext\misc\fileio.c \ - $(TOP)\ext\misc\ieee754.c \ - $(TOP)\ext\misc\regexp.c \ - $(TOP)\ext\misc\series.c \ - $(TOP)\ext\misc\shathree.c \ - $(TOP)\ext\misc\uint.c \ - $(TOP)\ext\expert\sqlite3expert.c \ - $(TOP)\ext\expert\sqlite3expert.h \ - $(TOP)\ext\misc\memtrace.c \ - $(TOP)\ext\misc\pcachetrace.c \ - $(TOP)\ext\recover\dbdata.c \ - $(TOP)\ext\recover\sqlite3recover.c \ - $(TOP)\ext\recover\sqlite3recover.h \ - $(TOP)\src\test_windirent.c +# Source and header files that shell.c depends on +SHELL_DEP = \ + $(TOP)\src\shell.c.in \ + $(TOP)\ext\consio\console_io.c \ + $(TOP)\ext\consio\console_io.h \ + $(TOP)\ext\expert\sqlite3expert.c \ + $(TOP)\ext\expert\sqlite3expert.h \ + $(TOP)\ext\intck\sqlite3intck.c \ + $(TOP)\ext\intck\sqlite3intck.h \ + $(TOP)\ext\misc\appendvfs.c \ + $(TOP)\ext\misc\base64.c \ + $(TOP)\ext\misc\base85.c \ + $(TOP)\ext\misc\completion.c \ + $(TOP)\ext\misc\decimal.c \ + $(TOP)\ext\misc\fileio.c \ + $(TOP)\ext\misc\ieee754.c \ + $(TOP)\ext\misc\memtrace.c \ + $(TOP)\ext\misc\pcachetrace.c \ + $(TOP)\ext\misc\regexp.c \ + $(TOP)\ext\misc\series.c \ + $(TOP)\ext\misc\shathree.c \ + $(TOP)\ext\misc\sqlar.c \ + $(TOP)\ext\misc\uint.c \ + $(TOP)\ext\misc\zipfile.c \ + $(TOP)\ext\recover\dbdata.c \ + $(TOP)\ext\recover\sqlite3recover.c \ + $(TOP)\ext\recover\sqlite3recover.h \ + $(TOP)\src\test_windirent.c \ + $(TOP)\src\test_windirent.h # If use of zlib is enabled, add the "zipfile.c" source file. # !IF $(USE_ZLIB)!=0 -SHELL_SRC = $(SHELL_SRC) $(TOP)\ext\misc\sqlar.c -SHELL_SRC = $(SHELL_SRC) $(TOP)\ext\misc\zipfile.c +SHELL_DEP = $(SHELL_DEP) $(TOP)\ext\misc\sqlar.c +SHELL_DEP = $(SHELL_DEP) $(TOP)\ext\misc\zipfile.c !ENDIF -shell.c: $(SHELL_SRC) $(TOP)\tool\mkshellc.tcl +shell.c: $(SHELL_DEP) $(TOP)\tool\mkshellc.tcl $(TCLSH_CMD) $(TOP)\tool\mkshellc.tcl > shell.c zlib: diff --git a/main.mk b/main.mk index be485b69ed..139e182eb1 100644 --- a/main.mk +++ b/main.mk @@ -718,8 +718,7 @@ opcodes.c: opcodes.h $(TOP)/tool/mkopcodec.tcl tclsh $(TOP)/tool/mkopcodec.tcl opcodes.h >opcodes.c opcodes.h: parse.h $(TOP)/src/vdbe.c $(TOP)/tool/mkopcodeh.tcl - cat parse.h $(TOP)/src/vdbe.c | \ - tclsh $(TOP)/tool/mkopcodeh.tcl >opcodes.h + cat parse.h $(TOP)/src/vdbe.c | tclsh $(TOP)/tool/mkopcodeh.tcl >opcodes.h # Rules to build parse.c and parse.h - the outputs of lemon. # @@ -742,32 +741,37 @@ keywordhash.h: $(TOP)/tool/mkkeywordhash.c $(BCC) -o mkkeywordhash $(OPTS) $(TOP)/tool/mkkeywordhash.c ./mkkeywordhash >keywordhash.h -# Source files that go into making shell.c -SHELL_SRC = \ - $(TOP)/src/shell.c.in \ - $(TOP)/ext/misc/appendvfs.c \ - $(TOP)/ext/misc/completion.c \ - $(TOP)/ext/misc/base64.c \ - $(TOP)/ext/misc/base85.c \ - $(TOP)/ext/misc/decimal.c \ - $(TOP)/ext/misc/fileio.c \ - $(TOP)/ext/misc/ieee754.c \ - $(TOP)/ext/misc/regexp.c \ - $(TOP)/ext/misc/series.c \ - $(TOP)/ext/misc/shathree.c \ - $(TOP)/ext/misc/sqlar.c \ - $(TOP)/ext/misc/uint.c \ - $(TOP)/ext/expert/sqlite3expert.c \ - $(TOP)/ext/expert/sqlite3expert.h \ - $(TOP)/ext/misc/zipfile.c \ - $(TOP)/ext/misc/memtrace.c \ - $(TOP)/ext/misc/pcachetrace.c \ - $(TOP)/ext/recover/dbdata.c \ - $(TOP)/ext/recover/sqlite3recover.c \ - $(TOP)/ext/recover/sqlite3recover.h \ - $(TOP)/src/test_windirent.c - -shell.c: $(SHELL_SRC) $(TOP)/tool/mkshellc.tcl +# Source and header files that shell.c depends on +SHELL_DEP = \ + $(TOP)/src/shell.c.in \ + $(TOP)/ext/consio/console_io.c \ + $(TOP)/ext/consio/console_io.h \ + $(TOP)/ext/expert/sqlite3expert.c \ + $(TOP)/ext/expert/sqlite3expert.h \ + $(TOP)/ext/intck/sqlite3intck.c \ + $(TOP)/ext/intck/sqlite3intck.h \ + $(TOP)/ext/misc/appendvfs.c \ + $(TOP)/ext/misc/base64.c \ + $(TOP)/ext/misc/base85.c \ + $(TOP)/ext/misc/completion.c \ + $(TOP)/ext/misc/decimal.c \ + $(TOP)/ext/misc/fileio.c \ + $(TOP)/ext/misc/ieee754.c \ + $(TOP)/ext/misc/memtrace.c \ + $(TOP)/ext/misc/pcachetrace.c \ + $(TOP)/ext/misc/regexp.c \ + $(TOP)/ext/misc/series.c \ + $(TOP)/ext/misc/shathree.c \ + $(TOP)/ext/misc/sqlar.c \ + $(TOP)/ext/misc/uint.c \ + $(TOP)/ext/misc/zipfile.c \ + $(TOP)/ext/recover/dbdata.c \ + $(TOP)/ext/recover/sqlite3recover.c \ + $(TOP)/ext/recover/sqlite3recover.h \ + $(TOP)/src/test_windirent.c \ + $(TOP)/src/test_windirent.h + +shell.c: $(SHELL_DEP) $(TOP)/tool/mkshellc.tcl tclsh $(TOP)/tool/mkshellc.tcl >shell.c diff --git a/manifest b/manifest index 9a3eabe50d..47ed7609bb 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Change\stest\sresults\sin\scorruptC.test\sto\saccount\sfor\sthe\sadded\sdetail\sin\sthe\noutput\sof\s"PRAGMA\sintegrity_check"\sfrom\s[b736519d3d2e93c7]. -D 2024-03-04T16:44:37.718 +C Fix\sa\scompiler\swarning\sin\sdate.c.\s\sUpdate\smakefiles\sto\sinclude\sall\snecessary\ndependencies\sfor\sbuilding\sshell.c. +D 2024-03-04T18:22:18.359 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 3c4f4879b2301e5486939f68cc64f84430861d246ac11430ff1a1d7347ed5b8c +F Makefile.in ca8b906b1c3285fc32cff9978a5b827f99ae3d440077babf32c257a92a2ba11c F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 15a875f6016c4200e7093db92365fabb8b32eb09f9e40e1aadeedeecad4050d5 +F Makefile.msc 72c8436ee7528cb78f7318230548aab145ef05d15a8feed0f3cb251a26384403 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 F VERSION c84541c6a9e8426462176fbb1f9ecb5cfd7d1bb56228053ff7eeba8841673eb6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -670,7 +670,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 2c8b556ba7a4a15f5440663f7b05da221355d1921d5c75298bb50e2bb8081d79 +F main.mk e5da4b6c13f2b15bba7f1efb0a47089dfdde0973e85a024785485655d59fd758 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -696,7 +696,7 @@ F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c a9e4382961fb26156a308645f7363519ab7eb20e412e78b7c1fe16bbfbb1689a +F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 596668e6625208ff5d2ffbb4e0530530ebb3a400efa0df54bad1d91953e32694 -R e247d8c69a2f1de22f60330dc6b8c1d7 +P 0d19eeaafb296aad212ee4f55a0f6df8c7c5185b14d7f7f49c020fe4cbe370c1 +R 191956f8db663f29da20ebca61821faf U drh -Z c67139450867debeac7f30d4414de41e +Z 23a2cbc5a581c90c55252c83bc05fa14 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 063d7c49a5..4c6664f160 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0d19eeaafb296aad212ee4f55a0f6df8c7c5185b14d7f7f49c020fe4cbe370c1 \ No newline at end of file +178b7d46f9c8e1694ed6f506d2785a9f5c49e2b428e04c8096d557cc1b5c9680 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 3bb4a8c714..d74cecb1d9 100644 --- a/src/date.c +++ b/src/date.c @@ -356,7 +356,7 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){ computeJD(p); } return 0; -}; +} static void clearYMD_HMS_TZ(DateTime *p); /* Forward declaration */ From 2c3973fdff6f3ffa6f8aac63a2c5d3fa02b66a24 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 5 Mar 2024 06:31:37 +0000 Subject: [PATCH 0169/1030] /fiddle: before resetting a db, roll back any transactions (resolves problem reported in [forum:0b41a25d65|forum post 0b41a25d65]) and remove an obsolete/broken reference to a long-gone API which could cause initialization to fail prematurely. FossilOrigin-Name: ee164ca73cf4151b1a1bf351729afa9b0ec95bd5004a5d5bfce3ed46268bfbf3 --- ext/wasm/fiddle/fiddle-worker.js | 5 ++--- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/shell.c.in | 18 ++++++++++++++---- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ext/wasm/fiddle/fiddle-worker.js b/ext/wasm/fiddle/fiddle-worker.js index cf0aa1ca2c..27d915eb2c 100644 --- a/ext/wasm/fiddle/fiddle-worker.js +++ b/ext/wasm/fiddle/fiddle-worker.js @@ -166,11 +166,10 @@ stdout("SQLite version", capi.sqlite3_libversion(), capi.sqlite3_sourceid().substr(0,19)); stdout('Welcome to the "fiddle" shell.'); - if(sqlite3.opfs){ + if(capi.sqlite3_vfs_find("opfs")){ stdout("\nOPFS is available. To open a persistent db, use:\n\n", " .open file:name?vfs=opfs\n\nbut note that some", "features (e.g. upload) do not yet work with OPFS."); - sqlite3.opfs.registerVfs(); } stdout('\nEnter ".help" for usage hints.'); this.exec([ // initialization commands... @@ -317,7 +316,7 @@ }; console.warn("Unknown fiddle-worker message type:",ev); }; - + /** emscripten module for use with build mode -sMODULARIZE. */ diff --git a/manifest b/manifest index 47ed7609bb..2e23e4d0aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scompiler\swarning\sin\sdate.c.\s\sUpdate\smakefiles\sto\sinclude\sall\snecessary\ndependencies\sfor\sbuilding\sshell.c. -D 2024-03-04T18:22:18.359 +C /fiddle:\sbefore\sresetting\sa\sdb,\sroll\sback\sany\stransactions\s(resolves\sproblem\sreported\sin\s[forum:0b41a25d65|forum\spost\s0b41a25d65])\sand\sremove\san\sobsolete/broken\sreference\sto\sa\slong-gone\sAPI\swhich\scould\scause\sinitialization\sto\sfail\sprematurely. +D 2024-03-05T06:31:37.489 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -640,7 +640,7 @@ F ext/wasm/dist.make 3a851858aad72e246a5d9c5aaf6b6a144305f1bf898ac1846760ea7bab9 F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle.make fa2ba6e90457ba2a71cb745f200d409caf773076df75ae5b177cc225d7627a11 F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f -F ext/wasm/fiddle/fiddle-worker.js 9be57887756c6854dbdcb5e7d8b7a26935d565491333a2f91dc4113598c659b5 +F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js 974b995119ac443685d7d94d3b3c58c6a36540e9eb3fed7069d5653284071715 F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2 F ext/wasm/index-dist.html e91d76e4581185238fd3d42ed86ec600f7023ed3e3a944c5c356f25304bf1263 @@ -751,7 +751,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in 2ec564ed3ff0147036be313efeb47b3dbfb8753d5eb5ea0e90636427c6b3a365 +F src/shell.c.in 6e7cd81874e3cea68b4f2dc72a8731a5f545aca0b3e48f132e3c6ee6862e3c0a F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0d19eeaafb296aad212ee4f55a0f6df8c7c5185b14d7f7f49c020fe4cbe370c1 -R 191956f8db663f29da20ebca61821faf -U drh -Z 23a2cbc5a581c90c55252c83bc05fa14 +P 178b7d46f9c8e1694ed6f506d2785a9f5c49e2b428e04c8096d557cc1b5c9680 +R 64eca58e8ac762a5eb6b341ff69c8405 +U stephan +Z ff3bca729d13aff9e0b3d1adfb9ed46d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4c6664f160..c3a86e0b30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -178b7d46f9c8e1694ed6f506d2785a9f5c49e2b428e04c8096d557cc1b5c9680 \ No newline at end of file +ee164ca73cf4151b1a1bf351729afa9b0ec95bd5004a5d5bfce3ed46268bfbf3 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 05583b2f34..36bbb93ec1 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -12838,7 +12838,7 @@ sqlite3_vfs * fiddle_db_vfs(const char *zDbName){ /* Only for emcc experimentation purposes. */ sqlite3 * fiddle_db_arg(sqlite3 *arg){ - printf("fiddle_db_arg(%p)\n", (const void*)arg); + oputf("fiddle_db_arg(%p)\n", (const void*)arg); return arg; } @@ -12864,12 +12864,22 @@ const char * fiddle_db_filename(const char * zDbName){ /* ** Completely wipes out the contents of the currently-opened database -** but leaves its storage intact for reuse. +** but leaves its storage intact for reuse. If any transactions are +** active, they are forcibly rolled back. */ void fiddle_reset_db(void){ if( globalDb ){ - int rc = sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0); - if( 0==rc ) rc = sqlite3_exec(globalDb, "VACUUM", 0, 0, 0); + int rc; + while( sqlite3_txn_state(globalDb,0)>0 ){ + /* + ** Resolve problem reported in + ** https://sqlite.org/forum/forumpost/0b41a25d65 + */ + oputz("Rolling back in-progress transaction.\n"); + sqlite3_exec(globalDb,"ROLLBACK", 0, 0, 0); + } + rc = sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0); + if( 0==rc ) sqlite3_exec(globalDb, "VACUUM", 0, 0, 0); sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0); } } From d5045a92462977e7655e8ec2f842b16e3d6f7cac Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 5 Mar 2024 07:55:20 +0000 Subject: [PATCH 0170/1030] Update fiddle.make to account for Makefile changes in [178b7d46f9]. FossilOrigin-Name: 7a5d810549f2686ae923fd0ca03ad8f536c9080b6879128ee8f00e653bb7f3f1 --- ext/wasm/fiddle.make | 10 ++++++---- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index 57141d7e2b..496e518de6 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -9,16 +9,18 @@ MAKEFILE.fiddle := $(lastword $(MAKEFILE_LIST)) # shell.c and its build flags... make-np-0 := make -C $(dir.top) -n -p make-np-1 := sed -e 's/(TOP)/(dir.top)/g' +# Extract SHELL_OPT and SHELL_DEP from the top-most makefile and import +# them as vars here... $(eval $(shell $(make-np-0) | grep -e '^SHELL_OPT ' | $(make-np-1))) -$(eval $(shell $(make-np-0) | grep -e '^SHELL_SRC ' | $(make-np-1))) +$(eval $(shell $(make-np-0) | grep -e '^SHELL_DEP ' | $(make-np-1))) # ^^^ can't do that in 1 invocation b/c newlines get stripped ifeq (,$(SHELL_OPT)) $(error Could not parse SHELL_OPT from $(dir.top)/Makefile.) endif -ifeq (,$(SHELL_SRC)) -$(error Could not parse SHELL_SRC from $(dir.top)/Makefile.) +ifeq (,$(SHELL_DEP)) +$(error Could not parse SHELL_DEP from $(dir.top)/Makefile.) endif -$(dir.top)/shell.c: $(SHELL_SRC) $(dir.top)/tool/mkshellc.tcl $(sqlite3.c) +$(dir.top)/shell.c: $(SHELL_DEP) $(dir.top)/tool/mkshellc.tcl $(sqlite3.c) $(MAKE) -C $(dir.top) shell.c # /shell.c ######################################################################## diff --git a/manifest b/manifest index 2e23e4d0aa..5d51d24787 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C /fiddle:\sbefore\sresetting\sa\sdb,\sroll\sback\sany\stransactions\s(resolves\sproblem\sreported\sin\s[forum:0b41a25d65|forum\spost\s0b41a25d65])\sand\sremove\san\sobsolete/broken\sreference\sto\sa\slong-gone\sAPI\swhich\scould\scause\sinitialization\sto\sfail\sprematurely. -D 2024-03-05T06:31:37.489 +C Update\sfiddle.make\sto\saccount\sfor\sMakefile\schanges\sin\s[178b7d46f9]. +D 2024-03-05T07:55:20.122 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -638,7 +638,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 3a851858aad72e246a5d9c5aaf6b6a144305f1bf898ac1846760ea7bab95c9a3 F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make fa2ba6e90457ba2a71cb745f200d409caf773076df75ae5b177cc225d7627a11 +F ext/wasm/fiddle.make 3c2eace29255d6ddd219f5d8cc2728cb28b9fe717ea80b6062c2a6178947a16b F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js 974b995119ac443685d7d94d3b3c58c6a36540e9eb3fed7069d5653284071715 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 178b7d46f9c8e1694ed6f506d2785a9f5c49e2b428e04c8096d557cc1b5c9680 -R 64eca58e8ac762a5eb6b341ff69c8405 +P ee164ca73cf4151b1a1bf351729afa9b0ec95bd5004a5d5bfce3ed46268bfbf3 +R 83071ca8acab359a5924e5d4cf357b67 U stephan -Z ff3bca729d13aff9e0b3d1adfb9ed46d +Z 2b4d9c85414ada098b40af0814689ab8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c3a86e0b30..b6932ff82e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ee164ca73cf4151b1a1bf351729afa9b0ec95bd5004a5d5bfce3ed46268bfbf3 \ No newline at end of file +7a5d810549f2686ae923fd0ca03ad8f536c9080b6879128ee8f00e653bb7f3f1 \ No newline at end of file From 7eb0ddf68b11a333c3056818cac31d6b8ad44455 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 5 Mar 2024 08:48:40 +0000 Subject: [PATCH 0171/1030] /fiddle 'Mandlebrot' typo fix reported in the forum. FossilOrigin-Name: ceefe6ba380c18279c2ae88443649e00e5e8110b529d447131ea9726de61f5d0 --- ext/wasm/fiddle/fiddle.js | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/wasm/fiddle/fiddle.js b/ext/wasm/fiddle/fiddle.js index 2a3d1746f3..73c55af9c5 100644 --- a/ext/wasm/fiddle/fiddle.js +++ b/ext/wasm/fiddle/fiddle.js @@ -742,7 +742,7 @@ {name: "Table list", sql: ".tables"}, {name: "Box Mode", sql: ".mode box"}, {name: "JSON Mode", sql: ".mode json"}, - {name: "Mandlebrot", sql:[ + {name: "Mandelbrot", sql:[ "WITH RECURSIVE", " xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2),\n", " yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0),\n", diff --git a/manifest b/manifest index 5d51d24787..14997b656f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sfiddle.make\sto\saccount\sfor\sMakefile\schanges\sin\s[178b7d46f9]. -D 2024-03-05T07:55:20.122 +C /fiddle\s'Mandlebrot'\stypo\sfix\sreported\sin\sthe\sforum. +D 2024-03-05T08:48:40.508 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -641,7 +641,7 @@ F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c F ext/wasm/fiddle.make 3c2eace29255d6ddd219f5d8cc2728cb28b9fe717ea80b6062c2a6178947a16b F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce -F ext/wasm/fiddle/fiddle.js 974b995119ac443685d7d94d3b3c58c6a36540e9eb3fed7069d5653284071715 +F ext/wasm/fiddle/fiddle.js 3d5cbee561bfd317f1fc83c429a0f29e7d36b9494bb983b58bed25b5b49295d7 F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2 F ext/wasm/index-dist.html e91d76e4581185238fd3d42ed86ec600f7023ed3e3a944c5c356f25304bf1263 F ext/wasm/index.html b31ce41c0da476d5ffcef23069b9d3415b419d65af5779096ebcfbcbade453a9 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ee164ca73cf4151b1a1bf351729afa9b0ec95bd5004a5d5bfce3ed46268bfbf3 -R 83071ca8acab359a5924e5d4cf357b67 +P 7a5d810549f2686ae923fd0ca03ad8f536c9080b6879128ee8f00e653bb7f3f1 +R dedcee47046ad2c820affc54bbfebf0e U stephan -Z 2b4d9c85414ada098b40af0814689ab8 +Z b6cbff2ce0125252a8326bff1a4d2a0d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b6932ff82e..134a211ac4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a5d810549f2686ae923fd0ca03ad8f536c9080b6879128ee8f00e653bb7f3f1 \ No newline at end of file +ceefe6ba380c18279c2ae88443649e00e5e8110b529d447131ea9726de61f5d0 \ No newline at end of file From 891aa0545071329a1898815e8304d67299dee758 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 5 Mar 2024 12:48:26 +0000 Subject: [PATCH 0172/1030] /fiddle: reorder/replace example entries to make them more coherent when tried in order and clear the example selection list when the input area is cleared, both based on forum feedback. FossilOrigin-Name: b4ce270b3f19499385d0923f0f28f702c8f664476def3994fdba5d418e3c5edb --- ext/wasm/fiddle/fiddle.js | 7 ++++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ext/wasm/fiddle/fiddle.js b/ext/wasm/fiddle/fiddle.js index 73c55af9c5..f409d92112 100644 --- a/ext/wasm/fiddle/fiddle.js +++ b/ext/wasm/fiddle/fiddle.js @@ -403,8 +403,10 @@ E('#btn-reset').addEventListener('click',()=>SF.resetDb()); const taInput = E('#input'); const btnClearIn = E('#btn-clear'); + const selectExamples = E('#select-examples'); btnClearIn.addEventListener('click',function(){ taInput.value = ''; + selectExamples.selectedIndex = 0; },false); // Ctrl-enter and shift-enter both run the current SQL. taInput.addEventListener('keydown',function(ev){ @@ -733,15 +735,14 @@ ]}, //{name: "Timer on", sql: ".timer on"}, // ^^^ re-enable if emscripten re-enables getrusage() + {name: "Box Mode", sql: ".mode box"}, {name: "Setup table T", sql:[ ".nullvalue NULL\n", "CREATE TABLE t(a,b);\n", "INSERT INTO t(a,b) VALUES('abc',123),('def',456),(NULL,789),('ghi',012);\n", "SELECT * FROM t;\n" ]}, - {name: "Table list", sql: ".tables"}, - {name: "Box Mode", sql: ".mode box"}, - {name: "JSON Mode", sql: ".mode json"}, + {name: "sqlite_schema", sql: "select * from sqlite_schema"}, {name: "Mandelbrot", sql:[ "WITH RECURSIVE", " xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2),\n", diff --git a/manifest b/manifest index 14997b656f..888463b04b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C /fiddle\s'Mandlebrot'\stypo\sfix\sreported\sin\sthe\sforum. -D 2024-03-05T08:48:40.508 +C /fiddle:\sreorder/replace\sexample\sentries\sto\smake\sthem\smore\scoherent\swhen\stried\sin\sorder\sand\sclear\sthe\sexample\sselection\slist\swhen\sthe\sinput\sarea\sis\scleared,\sboth\sbased\son\sforum\sfeedback. +D 2024-03-05T12:48:26.029 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -641,7 +641,7 @@ F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c F ext/wasm/fiddle.make 3c2eace29255d6ddd219f5d8cc2728cb28b9fe717ea80b6062c2a6178947a16b F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce -F ext/wasm/fiddle/fiddle.js 3d5cbee561bfd317f1fc83c429a0f29e7d36b9494bb983b58bed25b5b49295d7 +F ext/wasm/fiddle/fiddle.js 04a638e3ed8fc9ca7c05cbe73ac4196e4529ec564639a76fbcecaffdf62bd983 F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2 F ext/wasm/index-dist.html e91d76e4581185238fd3d42ed86ec600f7023ed3e3a944c5c356f25304bf1263 F ext/wasm/index.html b31ce41c0da476d5ffcef23069b9d3415b419d65af5779096ebcfbcbade453a9 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7a5d810549f2686ae923fd0ca03ad8f536c9080b6879128ee8f00e653bb7f3f1 -R dedcee47046ad2c820affc54bbfebf0e +P ceefe6ba380c18279c2ae88443649e00e5e8110b529d447131ea9726de61f5d0 +R 3f0174e7da224959eee01bc457acd8b1 U stephan -Z b6cbff2ce0125252a8326bff1a4d2a0d +Z 597983e79d7a5c5d218f87484b9eb1bc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 134a211ac4..8dabc0f49f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ceefe6ba380c18279c2ae88443649e00e5e8110b529d447131ea9726de61f5d0 \ No newline at end of file +b4ce270b3f19499385d0923f0f28f702c8f664476def3994fdba5d418e3c5edb \ No newline at end of file From 28001204f4afcd2bba65ba7a5704d2e60b405ba6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 5 Mar 2024 16:47:48 +0000 Subject: [PATCH 0173/1030] The value returned by the json_each.json field needs to survive longer than the json_each virtual table itself, in the event that the value is used in an aggregate expression. dbsqlfuzz 5120bd0b3bb0b73eebbcb79ac37c6b0663fccad6 FossilOrigin-Name: 952ed71b9b61e79fe807ac3134bdfa7c94a415e02f13f94440a34d6d548d171e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/json.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 888463b04b..7fb6fd304c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C /fiddle:\sreorder/replace\sexample\sentries\sto\smake\sthem\smore\scoherent\swhen\stried\sin\sorder\sand\sclear\sthe\sexample\sselection\slist\swhen\sthe\sinput\sarea\sis\scleared,\sboth\sbased\son\sforum\sfeedback. -D 2024-03-05T12:48:26.029 +C The\svalue\sreturned\sby\sthe\sjson_each.json\sfield\sneeds\sto\ssurvive\slonger\sthan\nthe\sjson_each\svirtual\stable\sitself,\sin\sthe\sevent\sthat\sthe\svalue\sis\sused\sin\nan\saggregate\sexpression.\s\sdbsqlfuzz\s5120bd0b3bb0b73eebbcb79ac37c6b0663fccad6 +D 2024-03-05T16:47:48.118 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -710,7 +710,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 3b4e2778d95d923d6d77e8a5efd51a6265017b466782d597303f5f094fcd68af +F src/json.c 9337dac9d9d4c77461db55fd3e06e4d006f4283cb1da2b3a9b1f8d750701583e F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ceefe6ba380c18279c2ae88443649e00e5e8110b529d447131ea9726de61f5d0 -R 3f0174e7da224959eee01bc457acd8b1 -U stephan -Z 597983e79d7a5c5d218f87484b9eb1bc +P b4ce270b3f19499385d0923f0f28f702c8f664476def3994fdba5d418e3c5edb +R c608a41202eeb1dd993e7f11e029f933 +U drh +Z 7dedc29c56fa74e9a5dfd76b2357e847 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8dabc0f49f..14670d7436 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b4ce270b3f19499385d0923f0f28f702c8f664476def3994fdba5d418e3c5edb \ No newline at end of file +952ed71b9b61e79fe807ac3134bdfa7c94a415e02f13f94440a34d6d548d171e \ No newline at end of file diff --git a/src/json.c b/src/json.c index 1227ada78e..fe7f938883 100644 --- a/src/json.c +++ b/src/json.c @@ -4993,9 +4993,9 @@ static int jsonEachColumn( case JEACH_JSON: { if( p->sParse.zJson==0 ){ sqlite3_result_blob(ctx, p->sParse.aBlob, p->sParse.nBlob, - SQLITE_STATIC); + SQLITE_TRANSIENT); }else{ - sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC); + sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_TRANSIENT); } break; } From 75aed691585281de2d75032e24d20d77d674ddac Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 5 Mar 2024 17:33:04 +0000 Subject: [PATCH 0174/1030] Reformulate [34439fe3aeea7cbb] slightly to resolve a false-positive OOM reported in [forum:2eadfe94e3|forum post 2eadfe94e3]. FossilOrigin-Name: 8290646792bc5411112b0c01dc5ac0837743056a7679725ee2edefef2e10d146 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7fb6fd304c..b875311c58 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\svalue\sreturned\sby\sthe\sjson_each.json\sfield\sneeds\sto\ssurvive\slonger\sthan\nthe\sjson_each\svirtual\stable\sitself,\sin\sthe\sevent\sthat\sthe\svalue\sis\sused\sin\nan\saggregate\sexpression.\s\sdbsqlfuzz\s5120bd0b3bb0b73eebbcb79ac37c6b0663fccad6 -D 2024-03-05T16:47:48.118 +C Reformulate\s[34439fe3aeea7cbb]\sslightly\sto\sresolve\sa\sfalse-positive\sOOM\sreported\sin\s[forum:2eadfe94e3|forum\spost\s2eadfe94e3]. +D 2024-03-05T17:33:04.627 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -751,7 +751,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in 6e7cd81874e3cea68b4f2dc72a8731a5f545aca0b3e48f132e3c6ee6862e3c0a +F src/shell.c.in 78bbd861cd0128aed67c0136561572ebcf11649be6cea86bee8491576d5958d0 F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b4ce270b3f19499385d0923f0f28f702c8f664476def3994fdba5d418e3c5edb -R c608a41202eeb1dd993e7f11e029f933 -U drh -Z 7dedc29c56fa74e9a5dfd76b2357e847 +P 952ed71b9b61e79fe807ac3134bdfa7c94a415e02f13f94440a34d6d548d171e +R 7a7e70231da662a6d891be7e73e90380 +U stephan +Z b9dbf98318196caf6d04789a6da016ae # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 14670d7436..59d20d5266 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -952ed71b9b61e79fe807ac3134bdfa7c94a415e02f13f94440a34d6d548d171e \ No newline at end of file +8290646792bc5411112b0c01dc5ac0837743056a7679725ee2edefef2e10d146 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 36bbb93ec1..1d7f8df450 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3776,6 +3776,7 @@ static void exec_prepared_stmt_columnar( rc = sqlite3_step(pStmt); if( rc!=SQLITE_ROW ) return; nColumn = sqlite3_column_count(pStmt); + if( nColumn==0 ) goto columnar_end; nAlloc = nColumn*4; if( nAlloc<=0 ) nAlloc = 1; azData = sqlite3_malloc64( nAlloc*sizeof(char*) ); @@ -3861,7 +3862,6 @@ static void exec_prepared_stmt_columnar( if( n>p->actualWidth[j] ) p->actualWidth[j] = n; } if( seenInterrupt ) goto columnar_end; - if( nColumn==0 ) goto columnar_end; switch( p->cMode ){ case MODE_Column: { colSep = " "; From 7ab40cda7be4ba05f45ecf30053f2cdf41248eff Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 5 Mar 2024 18:41:03 +0000 Subject: [PATCH 0175/1030] Remove code that added a P4 parameter to the OP_Variable opcode. This is no longer required. FossilOrigin-Name: dd5977c9a8a418be3fbd646d74933996381099a9263a02eb4a990f0084463dc1 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 6 ------ src/vdbe.c | 8 ++------ 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index b875311c58..1364d73542 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reformulate\s[34439fe3aeea7cbb]\sslightly\sto\sresolve\sa\sfalse-positive\sOOM\sreported\sin\s[forum:2eadfe94e3|forum\spost\s2eadfe94e3]. -D 2024-03-05T17:33:04.627 +C Remove\scode\sthat\sadded\sa\sP4\sparameter\sto\sthe\sOP_Variable\sopcode.\sThis\sis\sno\slonger\srequired. +D 2024-03-05T18:41:03.600 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 2803f5e7e3458ced24c0de48ec3640cd7a68ec61350d99c9f30b1bcd6640bd61 +F src/expr.c 05516e8b7d7d22f98160a0360fde69edce3304a430600567ed33e66d588ca59b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -820,7 +820,7 @@ F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 0765014847e2a06c952dd64aef0bea5144cd5b335a161eb0768ebe4f63dfe216 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 523a88b3df328810fbcbb407738c352dd9d5163b7af4c953e6e9887a4b582859 +F src/vdbe.c 7a33c5bb37e12ce35ac2d1d56a6429288b0b56c940ba660265c1428c67883729 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 952ed71b9b61e79fe807ac3134bdfa7c94a415e02f13f94440a34d6d548d171e -R 7a7e70231da662a6d891be7e73e90380 -U stephan -Z b9dbf98318196caf6d04789a6da016ae +P 8290646792bc5411112b0c01dc5ac0837743056a7679725ee2edefef2e10d146 +R 1ae68caeb21ed926e0c7d42963259d28 +U dan +Z 4bf196184c1c27ebc7d6a427ff362e10 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 59d20d5266..663d96d614 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8290646792bc5411112b0c01dc5ac0837743056a7679725ee2edefef2e10d146 \ No newline at end of file +dd5977c9a8a418be3fbd646d74933996381099a9263a02eb4a990f0084463dc1 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index e2cc15cfd6..6640d1907d 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4617,12 +4617,6 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ assert( pExpr->u.zToken!=0 ); assert( pExpr->u.zToken[0]!=0 ); sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target); - if( pExpr->u.zToken[1]!=0 ){ - const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn); - assert( pExpr->u.zToken[0]=='?' || (z && !strcmp(pExpr->u.zToken, z)) ); - pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */ - sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC); - } return target; } case TK_REGISTER: { diff --git a/src/vdbe.c b/src/vdbe.c index 489c4825f4..709ebd9fb8 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1512,19 +1512,15 @@ case OP_Blob: { /* out2 */ break; } -/* Opcode: Variable P1 P2 * P4 * -** Synopsis: r[P2]=parameter(P1,P4) +/* Opcode: Variable P1 P2 * * * +** Synopsis: r[P2]=parameter(P1) ** ** Transfer the values of bound parameter P1 into register P2 -** -** If the parameter is named, then its name appears in P4. -** The P4 value is used by sqlite3_bind_parameter_name(). */ case OP_Variable: { /* out2 */ Mem *pVar; /* Value being transferred */ assert( pOp->p1>0 && pOp->p1<=p->nVar ); - assert( pOp->p4.z==0 || pOp->p4.z==sqlite3VListNumToName(p->pVList,pOp->p1) ); pVar = &p->aVar[pOp->p1 - 1]; if( sqlite3VdbeMemTooBig(pVar) ){ goto too_big; From 53ca213e7345167e23e79740476ec5b65fc0adb2 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Mar 2024 11:35:36 +0000 Subject: [PATCH 0176/1030] =?UTF-8?q?Fix=20handling=20of=20"id=3D=3F"=20co?= =?UTF-8?q?rner=20cases=20in=20rtree=20when=20the=20value=20on=20the=20RHS?= =?UTF-8?q?=20is=20a=20real=20value.?= FossilOrigin-Name: 027e5336acc26f57f21df4980928731026c30cf88688fa0b66f13ffa0b5da3a0 --- ext/rtree/rtree.c | 2 +- ext/rtree/rtree1.test | 12 ++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 11996d110c..f2585bc25f 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1870,7 +1870,7 @@ static int rtreeFilter( i64 iNode = 0; int eType = sqlite3_value_numeric_type(argv[0]); if( eType==SQLITE_INTEGER - || (eType==SQLITE_FLOAT && sqlite3_value_double(argv[0])==iRowid) + || (eType==SQLITE_FLOAT && (i64)(sqlite3_value_double(argv[0]))==iRowid) ){ rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode); }else{ diff --git a/ext/rtree/rtree1.test b/ext/rtree/rtree1.test index 61664e1529..467a523fe5 100644 --- a/ext/rtree/rtree1.test +++ b/ext/rtree/rtree1.test @@ -797,4 +797,16 @@ do_test 23.0 { db eval {PRAGMA integrity_check;} } {ok} +reset_db +do_execsql_test 24.0 { + CREATE VIRTUAL TABLE rt1 USING rtree_i32(rid, c1, c2); + INSERT INTO rt1(rid, c1, c2) VALUES (9223372036854775807, 10, 18); +} + +do_execsql_test 1.1 { + SELECT (rid = (CAST (9223372036854775807 AS REAL))) + FROM rt1 WHERE + (rid = (CAST (9223372036854775807 AS REAL))); +} + finish_test diff --git a/manifest b/manifest index 1364d73542..8808c702a3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\scode\sthat\sadded\sa\sP4\sparameter\sto\sthe\sOP_Variable\sopcode.\sThis\sis\sno\slonger\srequired. -D 2024-03-05T18:41:03.600 +C Fix\shandling\sof\s"id=?"\scorner\scases\sin\srtree\swhen\sthe\svalue\son\sthe\sRHS\sis\sa\sreal\svalue. +D 2024-03-06T11:35:36.090 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -506,9 +506,9 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 0dd4775e896cee6067979d67aff7c998e75c2c9d9cd8d62a1a790c09cde7adca -F ext/rtree/rtree.c 1baf9f6aa7251ddecdb019d914df4db46eb227720c00f89c485c66dbfdc7863d +F ext/rtree/rtree.c 57e5269d7d3c502626dfb3dcb3866cb49f0e965b5b3457c8e8e4c092d9d54d34 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 -F ext/rtree/rtree1.test 2b5b8c719c6a4abe377f57766f428a49af36a93061cb146cccfdc3b30000c0a4 +F ext/rtree/rtree1.test aa738f9956be79de80688ebe515d5b96de75ddd5a8cf3b18819b29f5853ddbdb F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d F ext/rtree/rtree3.test 272594f88c344e973864008bbe4c71fd3a41a264c097d568593ee7886d83d409 F ext/rtree/rtree4.test 304de65d484540111b896827e4261815e5dca4ce28eeecd58be648cd73452c4b @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8290646792bc5411112b0c01dc5ac0837743056a7679725ee2edefef2e10d146 -R 1ae68caeb21ed926e0c7d42963259d28 +P dd5977c9a8a418be3fbd646d74933996381099a9263a02eb4a990f0084463dc1 +R 0d34808880ac8ee78310466df4068ad3 U dan -Z 4bf196184c1c27ebc7d6a427ff362e10 +Z f219ac544948fab5884c3a1cf576bfbe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 663d96d614..ac34f60cfe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dd5977c9a8a418be3fbd646d74933996381099a9263a02eb4a990f0084463dc1 \ No newline at end of file +027e5336acc26f57f21df4980928731026c30cf88688fa0b66f13ffa0b5da3a0 \ No newline at end of file From a64342ee9cca331cddda4c2c241d593c7516c999 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 6 Mar 2024 12:28:55 +0000 Subject: [PATCH 0177/1030] Correction to the previous check-in. FossilOrigin-Name: 483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 --- ext/rtree/rtree.c | 4 +++- ext/rtree/rtree1.test | 8 +++++++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index f2585bc25f..a24304a8ac 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1870,7 +1870,9 @@ static int rtreeFilter( i64 iNode = 0; int eType = sqlite3_value_numeric_type(argv[0]); if( eType==SQLITE_INTEGER - || (eType==SQLITE_FLOAT && (i64)(sqlite3_value_double(argv[0]))==iRowid) + || (eType==SQLITE_FLOAT + && (i64)(sqlite3_value_double(argv[0]))==iRowid + && (double)iRowid==sqlite3_value_double(argv[0])) ){ rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode); }else{ diff --git a/ext/rtree/rtree1.test b/ext/rtree/rtree1.test index 467a523fe5..e596df71d5 100644 --- a/ext/rtree/rtree1.test +++ b/ext/rtree/rtree1.test @@ -803,10 +803,16 @@ do_execsql_test 24.0 { INSERT INTO rt1(rid, c1, c2) VALUES (9223372036854775807, 10, 18); } -do_execsql_test 1.1 { +do_execsql_test 24.1 { SELECT (rid = (CAST (9223372036854775807 AS REAL))) FROM rt1 WHERE (rid = (CAST (9223372036854775807 AS REAL))); } +do_execsql_test 24.2 { + DELETE FROM rt1; + INSERT INTO rt1(rid, c1, c2) VALUES(1,2,3); + SELECT * FROM rt1 WHERE rid=1.005; +} {} + finish_test diff --git a/manifest b/manifest index 8808c702a3..da94066647 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\shandling\sof\s"id=?"\scorner\scases\sin\srtree\swhen\sthe\svalue\son\sthe\sRHS\sis\sa\sreal\svalue. -D 2024-03-06T11:35:36.090 +C Correction\sto\sthe\sprevious\scheck-in. +D 2024-03-06T12:28:55.128 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -506,9 +506,9 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 0dd4775e896cee6067979d67aff7c998e75c2c9d9cd8d62a1a790c09cde7adca -F ext/rtree/rtree.c 57e5269d7d3c502626dfb3dcb3866cb49f0e965b5b3457c8e8e4c092d9d54d34 +F ext/rtree/rtree.c d87dfef2dd8ee2360898857187b9f763e90dcee9cf98f3f487ec473b6ae30db3 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 -F ext/rtree/rtree1.test aa738f9956be79de80688ebe515d5b96de75ddd5a8cf3b18819b29f5853ddbdb +F ext/rtree/rtree1.test e0608db762b2aadca0ecb6f97396cf66244490adc3ba88f2a292b27be3e1da3e F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d F ext/rtree/rtree3.test 272594f88c344e973864008bbe4c71fd3a41a264c097d568593ee7886d83d409 F ext/rtree/rtree4.test 304de65d484540111b896827e4261815e5dca4ce28eeecd58be648cd73452c4b @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dd5977c9a8a418be3fbd646d74933996381099a9263a02eb4a990f0084463dc1 -R 0d34808880ac8ee78310466df4068ad3 -U dan -Z f219ac544948fab5884c3a1cf576bfbe +P 027e5336acc26f57f21df4980928731026c30cf88688fa0b66f13ffa0b5da3a0 +R ee785ecad1867a820bb9e665fd92d3e8 +U drh +Z 74daf43f110405d8b8bf503998b8174f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ac34f60cfe..dba854ccd3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -027e5336acc26f57f21df4980928731026c30cf88688fa0b66f13ffa0b5da3a0 \ No newline at end of file +483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 \ No newline at end of file From b4e7d59f4fa9653fad5bd1c833c3472dfe1aaf71 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 6 Mar 2024 14:30:42 +0000 Subject: [PATCH 0178/1030] Add the json_pretty(J) function for pretty-printing of JSON. An optional 2nd argument is text used for indentation, with a default value being four spaces. FossilOrigin-Name: 39552bd36c06fe9ee346cb71e0659baceccde031b67c0974f2dd14eb11ebc055 --- manifest | 15 +++--- manifest.uuid | 2 +- src/json.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 152 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index da94066647..682a374dee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correction\sto\sthe\sprevious\scheck-in. -D 2024-03-06T12:28:55.128 +C Add\sthe\sjson_pretty(J)\sfunction\sfor\spretty-printing\sof\sJSON.\s\sAn\soptional\n2nd\sargument\sis\stext\sused\sfor\sindentation,\swith\sa\sdefault\svalue\sbeing\sfour\nspaces. +D 2024-03-06T14:30:42.046 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -710,7 +710,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c 9337dac9d9d4c77461db55fd3e06e4d006f4283cb1da2b3a9b1f8d750701583e +F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b @@ -2176,8 +2176,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 027e5336acc26f57f21df4980928731026c30cf88688fa0b66f13ffa0b5da3a0 -R ee785ecad1867a820bb9e665fd92d3e8 +P 483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 +R cdcb4f4f681bccfe01ba6f525ed68e3e +T *branch * json-pretty +T *sym-json-pretty * +T -sym-trunk * U drh -Z 74daf43f110405d8b8bf503998b8174f +Z 040cd116c25b3e34e2b8acda05bc14c7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dba854ccd3..0340f39ad2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 \ No newline at end of file +39552bd36c06fe9ee346cb71e0659baceccde031b67c0974f2dd14eb11ebc055 \ No newline at end of file diff --git a/src/json.c b/src/json.c index fe7f938883..44ae846461 100644 --- a/src/json.c +++ b/src/json.c @@ -563,7 +563,6 @@ static void jsonAppendRawNZ(JsonString *p, const char *zIn, u32 N){ } } - /* Append formatted text (not to exceed N bytes) to the JsonString. */ static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){ @@ -2336,6 +2335,112 @@ static u32 jsonTranslateBlobToText( return i+n+sz; } +/* Context for recursion of json_pretty() +*/ +typedef struct JsonPretty JsonPretty; +struct JsonPretty { + JsonParse *pParse; /* The BLOB being rendered */ + JsonString *pOut; /* Generate pretty output into this string */ + const char *zIndent; /* Use this text for indentation */ + u32 szIndent; /* Bytes in zIndent[] */ + u32 nIndent; /* Current level of indentation */ +}; + +/* Append indentation to the pretty JSON under construction */ +static void jsonPrettyIndent(JsonPretty *pPretty){ + u32 jj; + for(jj=0; jjnIndent; jj++){ + jsonAppendRaw(pPretty->pOut, pPretty->zIndent, pPretty->szIndent); + } +} + +/* +** Translate the binary JSONB representation of JSON beginning at +** pParse->aBlob[i] into a JSON text string. Append the JSON +** text onto the end of pOut. Return the index in pParse->aBlob[] +** of the first byte past the end of the element that is translated. +** +** This is a variant of jsonTranslateBlobToText() that "pretty-prints" +** the output. Extra whitespace is inserted to make the JSON easier +** for humans to read. +** +** If an error is detected in the BLOB input, the pOut->eErr flag +** might get set to JSTRING_MALFORMED. But not all BLOB input errors +** are detected. So a malformed JSONB input might either result +** in an error, or in incorrect JSON. +** +** The pOut->eErr JSTRING_OOM flag is set on a OOM. +*/ +static u32 jsonTranslateBlobToPrettyText( + JsonPretty *pPretty, /* Pretty-printing context */ + u32 i /* Start rendering at this index */ +){ + u32 sz, n, j, iEnd; + const JsonParse *pParse = pPretty->pParse; + JsonString *pOut = pPretty->pOut; + n = jsonbPayloadSize(pParse, i, &sz); + if( n==0 ){ + pOut->eErr |= JSTRING_MALFORMED; + return pParse->nBlob+1; + } + switch( pParse->aBlob[i] & 0x0f ){ + case JSONB_ARRAY: { + j = i+n; + iEnd = j+sz; + jsonAppendChar(pOut, '['); + if( jnIndent++; + while( pOut->eErr==0 ){ + jsonPrettyIndent(pPretty); + j = jsonTranslateBlobToPrettyText(pPretty, j); + if( j>=iEnd ) break; + jsonAppendRawNZ(pOut, ",\n", 2); + } + jsonAppendChar(pOut, '\n'); + pPretty->nIndent--; + jsonPrettyIndent(pPretty); + } + jsonAppendChar(pOut, ']'); + i = iEnd; + break; + } + case JSONB_OBJECT: { + j = i+n; + iEnd = j+sz; + jsonAppendChar(pOut, '{'); + if( jnIndent++; + while( pOut->eErr==0 ){ + jsonPrettyIndent(pPretty); + j = jsonTranslateBlobToText(pParse, j, pOut); + if( j>iEnd ){ + pOut->eErr |= JSTRING_MALFORMED; + break; + } + jsonAppendRawNZ(pOut, ": ", 2); + j = jsonTranslateBlobToPrettyText(pPretty, j); + if( j>=iEnd ) break; + jsonAppendRawNZ(pOut, ",\n", 2); + } + jsonAppendChar(pOut, '\n'); + pPretty->nIndent--; + jsonPrettyIndent(pPretty); + } + jsonAppendChar(pOut, '}'); + i = iEnd; + break; + } + default: { + i = jsonTranslateBlobToText(pParse, i, pOut); + break; + } + } + return i; +} + + /* Return true if the input pJson ** ** For performance reasons, this routine does not do a detailed check of the @@ -4255,6 +4360,40 @@ static void jsonTypeFunc( jsonParseFree(p); } +/* +** json_pretty(JSON) +** json_pretty(JSON, INDENT) +** +** Return text that is a pretty-printed rendering of the input JSON. +** If the argument is not valid JSON, return NULL. +** +** The INDENT argument is text that is used for indentation. If omitted, +** it defaults to four spaces (the same as PostgreSQL). +*/ +static void jsonPrettyFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + JsonString s; /* The output string */ + JsonPretty x; /* Pretty printing context */ + + memset(&x, 0, sizeof(x)); + x.pParse = jsonParseFuncArg(ctx, argv[0], 0); + if( x.pParse==0 ) return; + x.pOut = &s; + jsonStringInit(&s, ctx); + if( argc==1 || (x.zIndent = (const char*)sqlite3_value_text(argv[1]))==0 ){ + x.zIndent = " "; + x.szIndent = 4; + }else{ + x.szIndent = (u32)strlen(x.zIndent); + } + jsonTranslateBlobToPrettyText(&x, 0); + jsonReturnString(&s, 0, 0); + jsonParseFree(x.pParse); +} + /* ** json_valid(JSON) ** json_valid(JSON, FLAGS) @@ -5269,6 +5408,8 @@ void sqlite3RegisterJsonFunctions(void){ JFUNCTION(jsonb_object, -1,0,1, 1,1,0, jsonObjectFunc), JFUNCTION(json_patch, 2,1,1, 0,0,0, jsonPatchFunc), JFUNCTION(jsonb_patch, 2,1,0, 0,1,0, jsonPatchFunc), + JFUNCTION(json_pretty, 1,1,0, 0,0,0, jsonPrettyFunc), + JFUNCTION(json_pretty, 2,1,0, 0,0,0, jsonPrettyFunc), JFUNCTION(json_quote, 1,0,1, 1,0,0, jsonQuoteFunc), JFUNCTION(json_remove, -1,1,1, 0,0,0, jsonRemoveFunc), JFUNCTION(jsonb_remove, -1,1,0, 0,1,0, jsonRemoveFunc), From 31c3ac9049a3e6c418ad3a1d7ce97c980968b9b9 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 6 Mar 2024 14:42:06 +0000 Subject: [PATCH 0179/1030] Add a couple of json_pretty() examples to /fiddle. FossilOrigin-Name: d5e1687b1d49cec5daa8793ea138fdf3bd29436c1e67071707ec0594bd1c66c6 --- ext/wasm/fiddle/fiddle.js | 8 +++++++- manifest | 17 +++++++---------- manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ext/wasm/fiddle/fiddle.js b/ext/wasm/fiddle/fiddle.js index f409d92112..d28589835c 100644 --- a/ext/wasm/fiddle/fiddle.js +++ b/ext/wasm/fiddle/fiddle.js @@ -761,7 +761,13 @@ " FROM m2 GROUP BY cy\n", " )\n", "SELECT group_concat(rtrim(t),x'0a') as Mandelbrot FROM a;\n", - ]} + ]}, + {name: "JSON pretty-print", + sql: "select json_pretty(json_object('ex',json('[52,3.14159]')))" + }, + {name: "JSON pretty-print (with tabs)", + sql: "select json_pretty(json_object('ex',json('[52,3.14159]')),char(0x09))" + } ]; const newOpt = function(lbl,val){ const o = document.createElement('option'); diff --git a/manifest b/manifest index 682a374dee..3636941e49 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sjson_pretty(J)\sfunction\sfor\spretty-printing\sof\sJSON.\s\sAn\soptional\n2nd\sargument\sis\stext\sused\sfor\sindentation,\swith\sa\sdefault\svalue\sbeing\sfour\nspaces. -D 2024-03-06T14:30:42.046 +C Add\sa\scouple\sof\sjson_pretty()\sexamples\sto\s/fiddle. +D 2024-03-06T14:42:06.357 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -641,7 +641,7 @@ F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c F ext/wasm/fiddle.make 3c2eace29255d6ddd219f5d8cc2728cb28b9fe717ea80b6062c2a6178947a16b F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce -F ext/wasm/fiddle/fiddle.js 04a638e3ed8fc9ca7c05cbe73ac4196e4529ec564639a76fbcecaffdf62bd983 +F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2 F ext/wasm/index-dist.html e91d76e4581185238fd3d42ed86ec600f7023ed3e3a944c5c356f25304bf1263 F ext/wasm/index.html b31ce41c0da476d5ffcef23069b9d3415b419d65af5779096ebcfbcbade453a9 @@ -2176,11 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 -R cdcb4f4f681bccfe01ba6f525ed68e3e -T *branch * json-pretty -T *sym-json-pretty * -T -sym-trunk * -U drh -Z 040cd116c25b3e34e2b8acda05bc14c7 +P 39552bd36c06fe9ee346cb71e0659baceccde031b67c0974f2dd14eb11ebc055 +R f12e2eeb9bae468bef7713e1648b6a8a +U stephan +Z 3bec70ffdc2a1f410c64a91b9d3ada78 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0340f39ad2..ea3e1e8458 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39552bd36c06fe9ee346cb71e0659baceccde031b67c0974f2dd14eb11ebc055 \ No newline at end of file +d5e1687b1d49cec5daa8793ea138fdf3bd29436c1e67071707ec0594bd1c66c6 \ No newline at end of file From 1bd583e201fbc1f81fc5cf0ba938c048742215f7 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 6 Mar 2024 20:24:02 +0000 Subject: [PATCH 0180/1030] Work around obscure floating point issue seen with older versions of MSVC. FossilOrigin-Name: 42d39f9140cc315df04b048f3811311fa50b51e1831d6cdf982fbce029778e43 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/util.c | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index da94066647..cccb344c9c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correction\sto\sthe\sprevious\scheck-in. -D 2024-03-06T12:28:55.128 +C Work\saround\sobscure\sfloating\spoint\sissue\sseen\swith\solder\sversions\sof\sMSVC. +D 2024-03-06T20:24:02.178 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -818,7 +818,7 @@ F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c 0765014847e2a06c952dd64aef0bea5144cd5b335a161eb0768ebe4f63dfe216 +F src/util.c f27a17e6e43fa362abea4db507a1c409f0adc8048ecf4c6479e8d162158ed529 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c 7a33c5bb37e12ce35ac2d1d56a6429288b0b56c940ba660265c1428c67883729 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f @@ -2176,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 027e5336acc26f57f21df4980928731026c30cf88688fa0b66f13ffa0b5da3a0 -R ee785ecad1867a820bb9e665fd92d3e8 -U drh -Z 74daf43f110405d8b8bf503998b8174f +P 483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 +R e5a2f85d4c7fe1bb0d133ab32d8d2d60 +U mistachkin +Z 8ca80acfec7b6e2b98a8f7ce94a903f4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dba854ccd3..9cbb89be52 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 \ No newline at end of file +42d39f9140cc315df04b048f3811311fa50b51e1831d6cdf982fbce029778e43 \ No newline at end of file diff --git a/src/util.c b/src/util.c index 311b7385a6..8c9e980cd1 100644 --- a/src/util.c +++ b/src/util.c @@ -665,6 +665,9 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ u64 s2; rr[0] = (double)s; s2 = (u64)rr[0]; +#if defined(_MSC_VER) && _MSC_VER<1700 + if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); } +#endif rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s); if( e>0 ){ while( e>=100 ){ From 1b977e3ae83db9fdfe70e650ca3bc3d22703ead9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 6 Mar 2024 20:38:52 +0000 Subject: [PATCH 0181/1030] Add test cases for json_pretty(). FossilOrigin-Name: 6448b90708eeedef03e82dcb10d2879e1bc859d422b450c5fc403ffbe0343bed --- manifest | 15 ++++++++------- manifest.uuid | 2 +- test/json106.test | 6 ++++++ test/json108.test | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 test/json108.test diff --git a/manifest b/manifest index 3636941e49..91c87d0a12 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\scouple\sof\sjson_pretty()\sexamples\sto\s/fiddle. -D 2024-03-06T14:42:06.357 +C Add\stest\scases\sfor\sjson_pretty(). +D 2024-03-06T20:38:52.875 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1353,8 +1353,9 @@ F test/json102.test 557a46e16df1aa9bdbc4076a71a45814ea0e7503d6621d87d42a8c04cbc2 F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba0114348c1 F test/json105.test 043838b56e68f3252a0dcf5be1689016f6f3f05056f8dcfcdc9d074f4d932988 -F test/json106.test 1d46a9294e2ced35c7f87cebbcb9626d01abab04f1969d7ded7b6f6a1d9be0f2 +F test/json106.test 4aed3afd16549045d198a8d9cea00deea96e1f2ecf55864dce96cac558b8abef F test/json107.test 59054e815c8f6b67d634d44ace421cf975828fb5651c4460aa66015c8e19d562 +F test/json108.test 0a5f1e2d4b35a1bc33052563d2a5ede03052e2099e58cb424547656c898e0f49 F test/json501.test b95e2d14988b682a5cadf079dd6162f0f85fb74cd59c6b1f1624110104a974eb F test/json502.test 84634d3dbb521d2814e43624025b760c6198456c8197bbec6c977c0236648f5b F test/jsonb01.test f4cdfb4cf5a0c940091b17675ed9583f45add0c938f07d65b0de0e19d3a9a101 @@ -2176,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 39552bd36c06fe9ee346cb71e0659baceccde031b67c0974f2dd14eb11ebc055 -R f12e2eeb9bae468bef7713e1648b6a8a -U stephan -Z 3bec70ffdc2a1f410c64a91b9d3ada78 +P d5e1687b1d49cec5daa8793ea138fdf3bd29436c1e67071707ec0594bd1c66c6 +R b5d425c8e8367f72e383ae1d2d9e4ea0 +U drh +Z ce296be00f3b33d5cde8abdb22061e01 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ea3e1e8458..342c0db21d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d5e1687b1d49cec5daa8793ea138fdf3bd29436c1e67071707ec0594bd1c66c6 \ No newline at end of file +6448b90708eeedef03e82dcb10d2879e1bc859d422b450c5fc403ffbe0343bed \ No newline at end of file diff --git a/test/json106.test b/test/json106.test index 23fa028431..06859a10b4 100644 --- a/test/json106.test +++ b/test/json106.test @@ -67,6 +67,12 @@ for {set ii 1} {$ii<=5000} {incr ii} { FROM t1, kv WHERE p->>key IS NOT val } 0 + do_execsql_test $ii.8 { + SELECT j0 FROM t1 WHERE json(j0)!=json(json_pretty(j0)); + } {} + do_execsql_test $ii.9 { + SELECT j5 FROM t1 WHERE json(j5)!=json(json_pretty(j5)); + } {} } diff --git a/test/json108.test b/test/json108.test new file mode 100644 index 0000000000..71f3814dce --- /dev/null +++ b/test/json108.test @@ -0,0 +1,45 @@ +# 2024-03-06 +# +# 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. +# +#*********************************************************************** +# Invariant tests for JSON built around the randomjson extension +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix json108 + +# These tests require virtual table "json_tree" to run. +ifcapable !vtab { finish_test ; return } + +load_static_extension db randomjson +db eval { + CREATE TEMP TABLE t1(j0,j5); + WITH RECURSIVE c(n) AS (VALUES(0) UNION ALL SELECT n+1 FROM c WHERE n<9) + INSERT INTO t1 SELECT random_json(n), random_json5(n) FROM c; +} + +do_execsql_test 1.1 { + SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL)); +} 10 +do_execsql_test 1.2 { + SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL)); +} 10 +do_execsql_test 1.3 { + SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,'')); +} 10 +do_execsql_test 1.4 { + SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,char(9))); +} 10 +do_execsql_test 1.5 { + SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,'/*hello*/')); +} 10 + + +finish_test From 5fb718aaab631e6a7f750e5049aa6f1eb33fb4a8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 7 Mar 2024 12:34:26 +0000 Subject: [PATCH 0182/1030] Do not allow the query planner to be tricked into thinking that an index on a constant expression might be useful for something. Problem reported on [forum:/forumpost/ecdfc02339|forum post ecdfc02339]. This is a follow-up to the fixes at [44200596aa943963] and [2d2b91cc0f6fed8c]. FossilOrigin-Name: 720ce06d93a9e4cc25c34c873c82165d8801f208c22701e51538f3210de84f65 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/whereexpr.c | 2 +- test/whereL.test | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index b220f92a5e..9809f4437d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sjson_pretty()\sSQL\sfunction. -D 2024-03-06T20:49:05.359 +C Do\snot\sallow\sthe\squery\splanner\sto\sbe\stricked\sinto\sthinking\sthat\san\sindex\son\sa\nconstant\sexpression\smight\sbe\suseful\sfor\ssomething.\s\sProblem\sreported\son\n[forum:/forumpost/ecdfc02339|forum\spost\secdfc02339].\s\sThis\sis\sa\sfollow-up\nto\sthe\sfixes\sat\s[44200596aa943963]\sand\s[2d2b91cc0f6fed8c]. +D 2024-03-07T12:34:26.192 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -838,7 +838,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 33eaaeef3aef10c2b9e82096e70a174d6636e35cb0b180321b8ddf804590e5cd F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 -F src/whereexpr.c dc5096eca5ed503999be3bdee8a90c51361289a678d396a220912e9cb73b3c00 +F src/whereexpr.c 6ebd90b553f4bb5c7df5a4b2f39b6a7c81a67484353827cdd2048f2514ec6f30 F src/window.c 5b1387d59df30d481ed14cceef5f4d1dab1f8752aa106ba72c8b62777bd139d2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2009,7 +2009,7 @@ F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2 F test/whereI.test c4bb7e2ca56d49bd8ab5c7bd085b8b83e353922b46904d68aefb3c7468643581 F test/whereJ.test fc05e374cc9f2dc204148d6c06822c380ad388895fe97a6d335b94a26a08aecf F test/whereK.test 0270ab7f04ba5436fb9156d31d642a1c82727f4c4bfe5ba90d435c78cf44684a -F test/whereL.test 9d7c8a9f4e5e82d6859e61cf8758c3856c7e0a7fd8be11c92cac8c3ec39228fd +F test/whereL.test f0e9585623af522ee9f382f8f945ad4b7eb7d806d18746f33f00c374acf6ab65 F test/whereM.test 0dbc9998783458ddcf3cc078ca7c2951d8b2677d472ecf0028f449ed327c0250 F test/wherefault.test 6cf2a9c5712952d463d3f45ebee7f6caf400984df51a195d884cfb7eb0e837a7 F test/wherelfault.test 9012e4ef5259058b771606616bd007af5d154e64cc25fa9fd4170f6411db44e3 @@ -2177,9 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 42d39f9140cc315df04b048f3811311fa50b51e1831d6cdf982fbce029778e43 6448b90708eeedef03e82dcb10d2879e1bc859d422b450c5fc403ffbe0343bed -R 88bdf8f2cb7f2d0936a740d66ef2bdb9 -T +closed 6448b90708eeedef03e82dcb10d2879e1bc859d422b450c5fc403ffbe0343bed +P ceb51c1cc36dfb78db8f2be042a0d74ab9a877d14a53dadf876d09e1a0616d6a +R 897d3888369143acaff743303856f10f U drh -Z 6f02a8d0c883d9be78c99bd4533f623f +Z ee9fb6bc0a9a21d42249dd521593d5a5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e46cc0fc12..a75e256014 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ceb51c1cc36dfb78db8f2be042a0d74ab9a877d14a53dadf876d09e1a0616d6a \ No newline at end of file +720ce06d93a9e4cc25c34c873c82165d8801f208c22701e51538f3210de84f65 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index daf3d5d950..25db8f396f 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -989,7 +989,7 @@ static SQLITE_NOINLINE int exprMightBeIndexed2( if( pIdx->aiColumn[i]!=XN_EXPR ) continue; assert( pIdx->bHasExpr ); if( sqlite3ExprCompareSkip(pExpr,pIdx->aColExpr->a[i].pExpr,iCur)==0 - && pExpr->op!=TK_STRING + && !sqlite3ExprIsConstant(pIdx->aColExpr->a[i].pExpr) ){ aiCurCol[0] = iCur; aiCurCol[1] = XN_EXPR; diff --git a/test/whereL.test b/test/whereL.test index c3bdcb8f34..068ee05cd4 100644 --- a/test/whereL.test +++ b/test/whereL.test @@ -209,4 +209,22 @@ do_eqp_test 710 { `--SEARCH t1 USING INDEX idx (=?) } +# 2024-03-07 https://sqlite.org/forum/forumpost/ecdfc02339 +# A refinement is needed to the enhancements tested by the prior test case +# to avoid another problem with indexes on constant expressions. +# +reset_db +db null NULL +do_execsql_test 800 { + CREATE TABLE t0(c0, c1); + CREATE TABLE t1(c2); + CREATE INDEX i0 ON t1(NULL); + INSERT INTO t1(c2) VALUES (0.2); + CREATE VIEW v0(c3) AS SELECT DISTINCT c2 FROM t1; + SELECT * FROM v0 LEFT JOIN t0 ON c3 Date: Thu, 7 Mar 2024 15:58:06 +0000 Subject: [PATCH 0183/1030] Fix harmless compiler warnings in test code for the intck extension. FossilOrigin-Name: 7fbdc1a849af3440579459bbb8797ebc7f9cce7b34d95675b8baa82db194ea9c --- ext/intck/test_intck.c | 6 +++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c index 72f72d8c13..84008fb07f 100644 --- a/ext/intck/test_intck.c +++ b/ext/intck/test_intck.c @@ -79,7 +79,7 @@ static int testIntckCmd( } case 1: assert( 0==strcmp("step", aCmd[iIdx].zName) ); { - int rc = sqlite3_intck_step(p->intck); + rc = sqlite3_intck_step(p->intck); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); break; } @@ -92,7 +92,7 @@ static int testIntckCmd( case 3: assert( 0==strcmp("error", aCmd[iIdx].zName) ); { const char *zErr = 0; - int rc = sqlite3_intck_error(p->intck, 0); + rc = sqlite3_intck_error(p->intck, 0); Tcl_Obj *pRes = Tcl_NewObj(); Tcl_ListObjAppendElement( interp, pRes, Tcl_NewStringObj(sqlite3ErrName(rc), -1) @@ -106,7 +106,7 @@ static int testIntckCmd( } case 4: assert( 0==strcmp("unlock", aCmd[iIdx].zName) ); { - int rc = sqlite3_intck_unlock(p->intck); + rc = sqlite3_intck_unlock(p->intck); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); break; } diff --git a/manifest b/manifest index 9809f4437d..cf220e9f26 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sallow\sthe\squery\splanner\sto\sbe\stricked\sinto\sthinking\sthat\san\sindex\son\sa\nconstant\sexpression\smight\sbe\suseful\sfor\ssomething.\s\sProblem\sreported\son\n[forum:/forumpost/ecdfc02339|forum\spost\secdfc02339].\s\sThis\sis\sa\sfollow-up\nto\sthe\sfixes\sat\s[44200596aa943963]\sand\s[2d2b91cc0f6fed8c]. -D 2024-03-07T12:34:26.192 +C Fix\sharmless\scompiler\swarnings\sin\stest\scode\sfor\sthe\sintck\sextension. +D 2024-03-07T15:58:06.345 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -258,7 +258,7 @@ F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f84 F ext/intck/intckfault.test ba0213c9c8dce08d519d5251268a3bab076a184b4d07acdea23b65e89c9ae03c F ext/intck/sqlite3intck.c 0d10df36e2b7b438aa80ecd3f5e584d41b747586b038258fe6b407f66b81e7c5 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 -F ext/intck/test_intck.c d63f1707432802f5db125ee40b794923af77d4686869bd8d3a7eb43332344267 +F ext/intck/test_intck.c 34243458378a12d1356c79219a03f244800533b3ab65b4a02861f0403364df12 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ceb51c1cc36dfb78db8f2be042a0d74ab9a877d14a53dadf876d09e1a0616d6a -R 897d3888369143acaff743303856f10f +P 720ce06d93a9e4cc25c34c873c82165d8801f208c22701e51538f3210de84f65 +R 78475c96717bed229515f020acd7cf0b U drh -Z ee9fb6bc0a9a21d42249dd521593d5a5 +Z b05395e7bb390bd5a3c76ba7c1373e1f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a75e256014..510215797c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -720ce06d93a9e4cc25c34c873c82165d8801f208c22701e51538f3210de84f65 \ No newline at end of file +7fbdc1a849af3440579459bbb8797ebc7f9cce7b34d95675b8baa82db194ea9c \ No newline at end of file From 61405c463d16d6fa40257c012df5c5a5d3af3af4 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 7 Mar 2024 16:04:43 +0000 Subject: [PATCH 0184/1030] Initial work at getting sqlite3Worker1Promiser.v2() to return a Promise instead of using an onready() callback, and also creating an ESM build for promiser1 per user request. It seems to work but requires more testing. FossilOrigin-Name: 0e272123ace55ed63fe86632671cca48e8965a28fc3625324984028729fc203f --- ext/wasm/GNUmakefile | 18 ++++--- ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | 48 +++++++++++++++++-- ext/wasm/demo-worker1-promiser.js | 24 +++++----- manifest | 21 ++++---- manifest.uuid | 2 +- 5 files changed, 82 insertions(+), 31 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 098a4330b0..ff11ab6552 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -307,8 +307,9 @@ DISTCLEAN_FILES += $(bin.stripccomments) ######################################################################## -# C-PP.FILTER: a $(call)able to transform $(1) to $(2) via ./c-pp -f -# $(1) ... +# C-PP.FILTER: a $(call)able to transform $(1) to $(2) via: +# +# ./c-pp -f $(1) -o $(2) $(3) # # Historical notes: # @@ -825,13 +826,13 @@ pre-post-jses.deps.common := $(extern-pre-js.js) $(sqlite3-license-version.js) # $4 = resulting sqlite-api JS/MJS file # $5 = resulting JS/MJS file # $6 = -D... flags for $(bin.c-pp) -# $7 = emcc -sXYZ flags (CURRENTLY UNUSED - was factored out) +# $7 = optional extra flags for emcc # # Maintenance reminder: be careful not to introduce spaces around args # ($1, $2), otherwise string concatenation will malfunction. # -# emcc.environment.$(2) must be set to a value for emcc's -# -sENVIRONMENT flag. +# Before calling this, emcc.environment.$(2) must be set to a value +# for emcc's -sENVIRONMENT flag. # # $(cflags.$(1)) and $(cflags.$(1).$(2)) may be defined to append # CFLAGS to a given build mode. @@ -938,6 +939,7 @@ sqlite3-worker1.js.in := $(dir.api)/sqlite3-worker1.c-pp.js sqlite3-worker1-promiser.js.in := $(dir.api)/sqlite3-worker1-promiser.c-pp.js sqlite3-worker1.js := $(dir.dout)/sqlite3-worker1.js sqlite3-worker1-promiser.js := $(dir.dout)/sqlite3-worker1-promiser.js +sqlite3-worker1-promiser.mjs := $(dir.dout)/sqlite3-worker1-promiser.mjs sqlite3-worker1-bundler-friendly.js := $(dir.dout)/sqlite3-worker1-bundler-friendly.mjs sqlite3-worker1-promiser-bundler-friendly.js := $(dir.dout)/sqlite3-worker1-promiser-bundler-friendly.js $(eval $(call C-PP.FILTER,$(sqlite3-worker1.js.in),$(sqlite3-worker1.js))) @@ -947,10 +949,12 @@ $(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-pr $(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),\ $(sqlite3-worker1-promiser-bundler-friendly.js),\ $(c-pp.D.sqlite3-bundler-friendly))) +$(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-promiser.mjs),\ + -Dtarget=es6-module -Dtarget=es6-bundler-friendly)) $(sqlite3-bundler-friendly.mjs): $(sqlite3-worker1-bundler-friendly.js) \ $(sqlite3-worker1-promiser-bundler-friendly.js) -$(sqlite3.js) $(sqlite3.mjs): $(sqlite3-worker1.js) $(sqlite3-worker1-promiser.js) - +$(sqlite3.js) $(sqlite3.mjs): $(sqlite3-worker1.js) \ + $(sqlite3-worker1-promiser.js) $(sqlite3-worker1-promiser.mjs) ######################################################################## # batch-runner.js is part of one of the test apps which reads in SQL # dumps generated by $(speedtest1) and executes them. diff --git a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js index 68846209e5..5e399cd344 100644 --- a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js +++ b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js @@ -42,9 +42,13 @@ - `onready` (optional, but...): this callback is called with no arguments when the worker fires its initial 'sqlite3-api'/'worker1-ready' message, which it does when - sqlite3.initWorker1API() completes its initialization. This is - the simplest way to tell the worker to kick off work at the - earliest opportunity. + sqlite3.initWorker1API() completes its initialization. This is the + simplest way to tell the worker to kick off work at the earliest + opportunity, and the only way to know when the worker module has + completed loading. The irony of using a callback for this, instead + of returning a promise from sqlite3Worker1Promiser() is not lost on + the developers, but initial attempts to return a promise resulted + in a much clumsier interface. - `onunhandled` (optional): a callback which gets passed the message event object for any worker.onmessage() events which @@ -277,7 +281,45 @@ globalThis.sqlite3Worker1Promiser.defaultConfig = { //#endif , onerror: (...args)=>console.error('worker1 promiser error',...args) +}/*defaultConfig*/; + +/** + sqlite3Worker1Promiser.v2() works identically to + sqlite3Worker1Promiser() except that it returns a promise instead + of relying an an onready callback in the config object. +*/ +sqlite3Worker1Promiser.v2 = function(config){ + const x = Object.create(null); + let oldFunc; + if( 'function' == typeof config ){ + oldFunc = config; + config = {}; + }else if('function'===typeof config?.onready){ + oldFunc = config.onready; + delete config.onready; + } + config = Object.assign((config || Object.create(null)),{ + onready: function(func){ + try { + if( oldFunc ){ + oldFunc(func); + } + x.resolve(func); + } + catch(e){x.reject(e)} + } + }); + const p = new Promise(function(resolve,reject){ + x.resolve = resolve; + x.reject = reject; + }); + sqlite3Worker1Promiser(config); + return p; }; + +//#if target=es6-module +export default sqlite3Worker1Promiser.v2; +//#endif /* target=es6-module */ //#else /* Built with the omit-oo1 flag. */ //#endif ifnot omit-oo1 diff --git a/ext/wasm/demo-worker1-promiser.js b/ext/wasm/demo-worker1-promiser.js index 4327f7487d..19a7af1143 100644 --- a/ext/wasm/demo-worker1-promiser.js +++ b/ext/wasm/demo-worker1-promiser.js @@ -14,8 +14,8 @@ proxy for for the sqlite3 Worker #1 API. */ 'use strict'; -(function(){ - const T = self.SqliteTestUtil; +(async function(){ + const T = globalThis.SqliteTestUtil; const eOutput = document.querySelector('#test-output'); const warn = console.warn.bind(console); const error = console.error.bind(console); @@ -48,18 +48,20 @@ onunhandled: function(ev){ error("Unhandled worker message:",ev.data); }, - onready: function(){ - T.affirm(arguments[0] === workerPromise - /* as of version 3.46. Prior to that this callback had no arguments */); - self.sqlite3TestModule.setStatus(null)/*hide the HTML-side is-loading spinner*/; - runTests(); - }, onerror: function(ev){ error("worker1 error:",ev); + }, + onready: function(f){ + warn("This is the v2 interface - don't pass an onready() function."); } }; - const workerPromise = self.sqlite3Worker1Promiser(promiserConfig); - delete self.sqlite3Worker1Promiser; + const workerPromise = await globalThis.sqlite3Worker1Promiser.v2(promiserConfig) + .then((func)=>{ + log("Init complete. Starting tests momentarily."); + globalThis.sqlite3TestModule.setStatus(null)/*hide the HTML-side is-loading spinner*/; + return func; + }); + delete globalThis.sqlite3Worker1Promiser; const wtest = async function(msgType, msgArgs, callback){ if(2===arguments.length && 'function'===typeof msgArgs){ @@ -273,5 +275,5 @@ }).finally(()=>logHtml('',"That's all, folks!")); }/*runTests2()*/; - log("Init complete, but async init bits may still be running."); + runTests(); })(); diff --git a/manifest b/manifest index da94066647..9d045f3c98 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correction\sto\sthe\sprevious\scheck-in. -D 2024-03-06T12:28:55.128 +C Initial\swork\sat\sgetting\ssqlite3Worker1Promiser.v2()\sto\sreturn\sa\sPromise\sinstead\sof\susing\san\sonready()\scallback,\sand\salso\screating\san\sESM\sbuild\sfor\spromiser1\sper\suser\srequest.\sIt\sseems\sto\swork\sbut\srequires\smore\stesting. +D 2024-03-07T16:04:43.823 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -587,7 +587,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 92e929315c3f1e0ea389fc9666b87a67a61fa1ecbe37e44c5ad226bda3bc6abe +F ext/wasm/GNUmakefile e04f36fec0ab949424622a906020902651bd8d17f9696c56ed572eebc63e2355 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -616,7 +616,7 @@ F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aae F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js fe427645e1499618f5fa7bc670af850577d8bcc132df982078690c9bf8400baa F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 -F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js e8135b44a568badfe197e2379f6b42899f2240b5c3a77fa044331110f7ce8e50 +F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js c11220b21f748c955ca798ad43ba7fea75ca0bf8dba78f46508f09517de26c05 F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd @@ -633,7 +633,7 @@ F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32 F ext/wasm/demo-jsstorage.html 409c4be4af5f207fb2877160724b91b33ea36a3cd8c204e8da1acb828ffe588e F ext/wasm/demo-jsstorage.js 44e3ae7ec2483b6c511384c3c290beb6f305c721186bcf5398ca4e00004a06b8 F ext/wasm/demo-worker1-promiser.html 1de7c248c7c2cfd4a5783d2aa154bce62d74c6de98ab22f5786620b3354ed15f -F ext/wasm/demo-worker1-promiser.js 786ae8a3214c2a29f6fb2c80eb4f90cc401fcc5b524d95c35fdc66a454e32bad +F ext/wasm/demo-worker1-promiser.js e4cd1089269d106dd3bd20684eaddcd176c73baa31867ba0e445c8e7e29160b5 F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 3a851858aad72e246a5d9c5aaf6b6a144305f1bf898ac1846760ea7bab95c9a3 @@ -2176,8 +2176,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 027e5336acc26f57f21df4980928731026c30cf88688fa0b66f13ffa0b5da3a0 -R ee785ecad1867a820bb9e665fd92d3e8 -U drh -Z 74daf43f110405d8b8bf503998b8174f +P 483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 +R fb2d3021442c55c82ff56e48b32fdd31 +T *branch * wasm-promiser1-v2 +T *sym-wasm-promiser1-v2 * +T -sym-trunk * Cancelled\sby\sbranch. +U stephan +Z d10f630418c41733e8d0108d272da900 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dba854ccd3..145a2be6b8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 \ No newline at end of file +0e272123ace55ed63fe86632671cca48e8965a28fc3625324984028729fc203f \ No newline at end of file From ffa0fa69b6fce393641562d7b794a91adbab1618 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 7 Mar 2024 17:56:08 +0000 Subject: [PATCH 0185/1030] wasm promiser.v2 is essentially working but the demo code is double-loading the module for as-yet-undetermined reasons. FossilOrigin-Name: aa877ce0c3b3aa1accd6e5fcd722d1bfaa79bea28c04c6badd8a547cea4bbc63 --- ext/wasm/GNUmakefile | 24 +- ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | 49 ++- ext/wasm/demo-worker1-promiser-esm.html | 311 ++++++++++++++++++ ext/wasm/dist.make | 11 +- ext/wasm/index-dist.html | 2 + ext/wasm/index.html | 2 + manifest | 24 +- manifest.uuid | 2 +- 8 files changed, 385 insertions(+), 40 deletions(-) create mode 100644 ext/wasm/demo-worker1-promiser-esm.html diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index ff11ab6552..922f341857 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -453,13 +453,14 @@ sqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js # the first OPFS VFS and necessarily an external file. SOAP.js := $(dir.api)/sqlite3-opfs-async-proxy.js SOAP.js.bld := $(dir.dout)/$(notdir $(SOAP.js)) -sqlite3-api.ext.jses += $(SOAP.js.bld) +# +# $(sqlite3-api.ext.jses) = API-related files which are standalone files, +# not part of the amalgamation. +# +sqlite3-api.ext.jses := $(SOAP.js.bld) $(SOAP.js.bld): $(SOAP.js) cp $< $@ -all quick: $(sqlite3-api.ext.jses) -q: quick - ######################################################################## # $(sqlite3-api*.*js) contain the core library code but not the # Emscripten-related glue which deals with loading sqlite3.wasm. In @@ -940,10 +941,10 @@ sqlite3-worker1-promiser.js.in := $(dir.api)/sqlite3-worker1-promiser.c-pp.js sqlite3-worker1.js := $(dir.dout)/sqlite3-worker1.js sqlite3-worker1-promiser.js := $(dir.dout)/sqlite3-worker1-promiser.js sqlite3-worker1-promiser.mjs := $(dir.dout)/sqlite3-worker1-promiser.mjs -sqlite3-worker1-bundler-friendly.js := $(dir.dout)/sqlite3-worker1-bundler-friendly.mjs +sqlite3-worker1-bundler-friendly.mjs := $(dir.dout)/sqlite3-worker1-bundler-friendly.mjs sqlite3-worker1-promiser-bundler-friendly.js := $(dir.dout)/sqlite3-worker1-promiser-bundler-friendly.js $(eval $(call C-PP.FILTER,$(sqlite3-worker1.js.in),$(sqlite3-worker1.js))) -$(eval $(call C-PP.FILTER,$(sqlite3-worker1.js.in),$(sqlite3-worker1-bundler-friendly.js),\ +$(eval $(call C-PP.FILTER,$(sqlite3-worker1.js.in),$(sqlite3-worker1-bundler-friendly.mjs),\ $(c-pp.D.sqlite3-bundler-friendly))) $(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-promiser.js))) $(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),\ @@ -951,10 +952,17 @@ $(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),\ $(c-pp.D.sqlite3-bundler-friendly))) $(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-promiser.mjs),\ -Dtarget=es6-module -Dtarget=es6-bundler-friendly)) -$(sqlite3-bundler-friendly.mjs): $(sqlite3-worker1-bundler-friendly.js) \ +$(sqlite3-bundler-friendly.mjs): $(sqlite3-worker1-bundler-friendly.mjs) \ $(sqlite3-worker1-promiser-bundler-friendly.js) -$(sqlite3.js) $(sqlite3.mjs): $(sqlite3-worker1.js) \ +all: $(sqlite3-worker1.js) \ $(sqlite3-worker1-promiser.js) $(sqlite3-worker1-promiser.mjs) + +sqlite3-api.ext.jses += \ + $(sqlite3-worker1-promiser.mjs) \ + $(sqlite3-worker1.js) +all quick: $(sqlite3-api.ext.jses) +q: quick + ######################################################################## # batch-runner.js is part of one of the test apps which reads in SQL # dumps generated by $(speedtest1) and executes them. diff --git a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js index 5e399cd344..06eb0781c8 100644 --- a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js +++ b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js @@ -47,8 +47,8 @@ opportunity, and the only way to know when the worker module has completed loading. The irony of using a callback for this, instead of returning a promise from sqlite3Worker1Promiser() is not lost on - the developers, but initial attempts to return a promise resulted - in a much clumsier interface. + the developers: see sqlite3Worker1Promiser.v2() which uses a + Promise instead. - `onunhandled` (optional): a callback which gets passed the message event object for any worker.onmessage() events which @@ -251,9 +251,10 @@ globalThis.sqlite3Worker1Promiser = function callee(config = callee.defaultConfi return p; }; }/*sqlite3Worker1Promiser()*/; + globalThis.sqlite3Worker1Promiser.defaultConfig = { worker: function(){ -//#if target=es6-bundler-friendly +//#if target=es6-module return new Worker(new URL("sqlite3-worker1-bundler-friendly.mjs", import.meta.url),{ type: 'module' }); @@ -274,7 +275,7 @@ globalThis.sqlite3Worker1Promiser.defaultConfig = { return new Worker(theJs + globalThis.location.search); //#endif } -//#ifnot target=es6-bundler-friendly +//#ifnot target=es6-module .bind({ currentScript: globalThis?.document?.currentScript }) @@ -285,11 +286,17 @@ globalThis.sqlite3Worker1Promiser.defaultConfig = { /** sqlite3Worker1Promiser.v2() works identically to - sqlite3Worker1Promiser() except that it returns a promise instead - of relying an an onready callback in the config object. + sqlite3Worker1Promiser() except that it returns a Promise instead + of relying an an onready callback in the config object. The Promise + resolves to the same factory function which + sqlite3Worker1Promiser() returns. + + If config is-a function or is an object which contains an onready + function, that function is replaced by a proxy which will resolve + after calling the original function and will reject if that + function throws. */ sqlite3Worker1Promiser.v2 = function(config){ - const x = Object.create(null); let oldFunc; if( 'function' == typeof config ){ oldFunc = config; @@ -298,26 +305,36 @@ sqlite3Worker1Promiser.v2 = function(config){ oldFunc = config.onready; delete config.onready; } + const promiseProxy = Object.create(null); config = Object.assign((config || Object.create(null)),{ - onready: function(func){ + onready: async function(func){ try { - if( oldFunc ){ - oldFunc(func); - } - x.resolve(func); + if( oldFunc ) await oldFunc(func); + promiseProxy.resolve(func); } - catch(e){x.reject(e)} + catch(e){promiseProxy.reject(e)} } }); const p = new Promise(function(resolve,reject){ - x.resolve = resolve; - x.reject = reject; + promiseProxy.resolve = resolve; + promiseProxy.reject = reject; }); - sqlite3Worker1Promiser(config); + try{ + sqlite3Worker1Promiser(config); + }catch(e){ + promiseProxy.reject(e); + } return p; }; //#if target=es6-module +/** + When built as a module, we export sqlite3Worker1Promiser.v2() + instead of sqlite3Worker1Promise() because (A) its interface is more + conventional for ESM usage and (B) the ESM option export option for + this API did not exist until v2 was created, so there's no backwards + incompatibility. +*/ export default sqlite3Worker1Promiser.v2; //#endif /* target=es6-module */ //#else diff --git a/ext/wasm/demo-worker1-promiser-esm.html b/ext/wasm/demo-worker1-promiser-esm.html new file mode 100644 index 0000000000..3995950938 --- /dev/null +++ b/ext/wasm/demo-worker1-promiser-esm.html @@ -0,0 +1,311 @@ + + + + + + + + + worker-promise (via ESM) tests + + +

    worker-promise (via ESM) tests
    + +
    +
    +
    Initializing app...
    +
    + On a slow internet connection this may take a moment. If this + message displays for "a long time", intialization may have + failed and the JavaScript console may contain clues as to why. +
    +
    +
    Downloading...
    +
    + +
    +
    Most stuff on this page happens in the dev console.
    +
    +
    + + + + + diff --git a/ext/wasm/dist.make b/ext/wasm/dist.make index 5d610e37b1..5165a7ec4b 100644 --- a/ext/wasm/dist.make +++ b/ext/wasm/dist.make @@ -49,12 +49,17 @@ dist.top.extras := \ tester1.js tester1.mjs \ demo-jsstorage.html demo-jsstorage.js \ demo-worker1.html demo-worker1.js \ - demo-worker1-promiser.html demo-worker1-promiser.js + demo-worker1-promiser.html demo-worker1-promiser.js \ + demo-worker1-promiser-esm.html dist.jswasm.extras := $(sqlite3-api.ext.jses) $(sqlite3.wasm) dist.common.extras := \ $(wildcard $(dir.common)/*.css) \ $(dir.common)/SqliteTestUtil.js +#$(info sqlite3-worker1-promiser.mjs = $(sqlite3-worker1-promiser.mjs)) +#$(info sqlite3-worker1.js = $(sqlite3-worker1.js)) +#$(info sqlite3-api.ext.jses = $(sqlite3-api.ext.jses)) +#$(info dist.jswasm.extras = $(dist.jswasm.extras)) .PHONY: dist snapshot # DIST_STRIP_COMMENTS $(call)able to be used in stripping C-style # from the dist copies of certain files. @@ -67,7 +72,8 @@ endef # STRIP_K1.js = list of JS files which need to be passed through # $(bin.stripcomments) with a single -k flag. STRIP_K1.js := $(sqlite3-worker1.js) $(sqlite3-worker1-promiser.js) \ - $(sqlite3-worker1-bundler-friendly.js) $(sqlite3-worker1-promiser-bundler-friendly.js) + $(sqlite3-worker1-bundler-friendly.js) \ + $(sqlite3-api.ext.jses) # STRIP_K2.js = list of JS files which need to be passed through # $(bin.stripcomments) with two -k flags. STRIP_K2.js := $(sqlite3.js) $(sqlite3.mjs) \ @@ -88,6 +94,7 @@ STRIP_K2.js := $(sqlite3.js) $(sqlite3.mjs) \ dist: \ $(bin.stripccomments) $(bin.version-info) \ $(dist.build) $(STRIP_K1.js) $(STRIP_K2.js) \ + $(dist.jswasm.extras) $(dist.common.extras) \ $(MAKEFILE) $(MAKEFILE.dist) @echo "Making end-user deliverables..." @rm -fr $(dist-dir.top) diff --git a/ext/wasm/index-dist.html b/ext/wasm/index-dist.html index f5bcdc1cb2..7b778b0205 100644 --- a/ext/wasm/index-dist.html +++ b/ext/wasm/index-dist.html @@ -97,6 +97,8 @@ wrapper is significantly easier to use, however.
  • demo-worker1-promiser: a demo of the Promise-based wrapper of the Worker1 API.
  • +
  • demo-worker1-promiser-esm: + same as the previous demo except loads the promiser from an ESM module.
  • diff --git a/ext/wasm/index.html b/ext/wasm/index.html index ebbfd6763d..d12a3aa03f 100644 --- a/ext/wasm/index.html +++ b/ext/wasm/index.html @@ -84,6 +84,8 @@ wrapper is significantly easier to use, however.
  • demo-worker1-promiser: a demo of the Promise-based wrapper of the Worker1 API.
  • +
  • demo-worker1-promiser-esm: + same as the previous demo except loads the promiser from an ESM module.
  • speedtest1 ports (sqlite3's primary benchmarking tool)... diff --git a/manifest b/manifest index 9d045f3c98..199d0f3b07 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initial\swork\sat\sgetting\ssqlite3Worker1Promiser.v2()\sto\sreturn\sa\sPromise\sinstead\sof\susing\san\sonready()\scallback,\sand\salso\screating\san\sESM\sbuild\sfor\spromiser1\sper\suser\srequest.\sIt\sseems\sto\swork\sbut\srequires\smore\stesting. -D 2024-03-07T16:04:43.823 +C wasm\spromiser.v2\sis\sessentially\sworking\sbut\sthe\sdemo\scode\sis\sdouble-loading\sthe\smodule\sfor\sas-yet-undetermined\sreasons. +D 2024-03-07T17:56:08.872 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -587,7 +587,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile e04f36fec0ab949424622a906020902651bd8d17f9696c56ed572eebc63e2355 +F ext/wasm/GNUmakefile fc361b472fdbf1256931769339d6d6e866048f6fcdbbe4bc1a60bfe70034895f F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -616,7 +616,7 @@ F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aae F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js fe427645e1499618f5fa7bc670af850577d8bcc132df982078690c9bf8400baa F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 -F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js c11220b21f748c955ca798ad43ba7fea75ca0bf8dba78f46508f09517de26c05 +F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js aff58bf96c253451af02194bf883e1c4851ef4ddbbff0cdd6cfca8f04231ec5d F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd @@ -632,19 +632,20 @@ F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b823 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf F ext/wasm/demo-jsstorage.html 409c4be4af5f207fb2877160724b91b33ea36a3cd8c204e8da1acb828ffe588e F ext/wasm/demo-jsstorage.js 44e3ae7ec2483b6c511384c3c290beb6f305c721186bcf5398ca4e00004a06b8 +F ext/wasm/demo-worker1-promiser-esm.html 181039b54e1d88181626d7e157f0f8832a532cf5c0ff6a62607cdbcc746649f3 F ext/wasm/demo-worker1-promiser.html 1de7c248c7c2cfd4a5783d2aa154bce62d74c6de98ab22f5786620b3354ed15f F ext/wasm/demo-worker1-promiser.js e4cd1089269d106dd3bd20684eaddcd176c73baa31867ba0e445c8e7e29160b5 F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef -F ext/wasm/dist.make 3a851858aad72e246a5d9c5aaf6b6a144305f1bf898ac1846760ea7bab95c9a3 +F ext/wasm/dist.make 8a6e829868e88a67a82670c6bb5d7ffda5dc46aa3f227ba3563c346d246f96d5 F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle.make 3c2eace29255d6ddd219f5d8cc2728cb28b9fe717ea80b6062c2a6178947a16b F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js 04a638e3ed8fc9ca7c05cbe73ac4196e4529ec564639a76fbcecaffdf62bd983 F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2 -F ext/wasm/index-dist.html e91d76e4581185238fd3d42ed86ec600f7023ed3e3a944c5c356f25304bf1263 -F ext/wasm/index.html b31ce41c0da476d5ffcef23069b9d3415b419d65af5779096ebcfbcbade453a9 +F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29aeff8507511f +F ext/wasm/index.html 4337f495416756802669f69f9f9f3df9f87ee4c1918e6718719b4b5718e4713a F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 @@ -2176,11 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 483fa2969e1e10cd8e8d2f9e3027871c65b1360b6c23897efe3ce63a3a55ae13 -R fb2d3021442c55c82ff56e48b32fdd31 -T *branch * wasm-promiser1-v2 -T *sym-wasm-promiser1-v2 * -T -sym-trunk * Cancelled\sby\sbranch. +P 0e272123ace55ed63fe86632671cca48e8965a28fc3625324984028729fc203f +R c8505d5644abe3c20f07eb87db82c9ac U stephan -Z d10f630418c41733e8d0108d272da900 +Z 20c543fa694914574de31b908812d405 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 145a2be6b8..1bcbadbb82 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e272123ace55ed63fe86632671cca48e8965a28fc3625324984028729fc203f \ No newline at end of file +aa877ce0c3b3aa1accd6e5fcd722d1bfaa79bea28c04c6badd8a547cea4bbc63 \ No newline at end of file From 84016759dd86626aa8c92270cb4939b0733c7dba Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 7 Mar 2024 18:53:27 +0000 Subject: [PATCH 0186/1030] Resolve duplicate loading of promiser v2 demo code (a side effect of having done precisely what it was told to do). Consolidate demo-worker1-promiser(-esm).html/(m)js variants into central copies processed with c-pp. FossilOrigin-Name: 9347d9b9a69277e40ea2f3ec6e1ff37ea19d24b4af80c6230b10624173f2f17c --- ext/wasm/GNUmakefile | 11 + ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | 8 +- ext/wasm/demo-worker1-promiser-esm.html | 311 ------------------ ...r.html => demo-worker1-promiser.c-pp.html} | 10 +- ...miser.js => demo-worker1-promiser.c-pp.js} | 38 ++- ext/wasm/dist.make | 5 +- manifest | 21 +- manifest.uuid | 2 +- 8 files changed, 62 insertions(+), 344 deletions(-) delete mode 100644 ext/wasm/demo-worker1-promiser-esm.html rename ext/wasm/{demo-worker1-promiser.html => demo-worker1-promiser.c-pp.html} (86%) rename ext/wasm/{demo-worker1-promiser.js => demo-worker1-promiser.c-pp.js} (89%) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 922f341857..6e7b49875f 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -954,11 +954,22 @@ $(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-pr -Dtarget=es6-module -Dtarget=es6-bundler-friendly)) $(sqlite3-bundler-friendly.mjs): $(sqlite3-worker1-bundler-friendly.mjs) \ $(sqlite3-worker1-promiser-bundler-friendly.js) +$(eval $(call C-PP.FILTER,demo-worker1-promiser.c-pp.js,demo-worker1-promiser.js)) +$(eval $(call C-PP.FILTER,demo-worker1-promiser.c-pp.js,demo-worker1-promiser.mjs,\ + -Dtarget=es6-module)) +$(eval $(call C-PP.FILTER,demo-worker1-promiser.c-pp.html,demo-worker1-promiser.html)) +$(eval $(call C-PP.FILTER,demo-worker1-promiser.c-pp.html,demo-worker1-promiser-esm.html,\ + -Dtarget=es6-module)) all: $(sqlite3-worker1.js) \ $(sqlite3-worker1-promiser.js) $(sqlite3-worker1-promiser.mjs) +demo-worker1-promiser.html: $(sqlite3-worker1-promiser.js) demo-worker1-promiser.js +demo-worker1-promiser-esm.html: $(sqlite3-worker1-promiser.mjs) demo-worker1-promiser.mjs +all: demo-worker1-promiser.html demo-worker1-promiser-esm.html + sqlite3-api.ext.jses += \ $(sqlite3-worker1-promiser.mjs) \ + $(sqlite3-worker1-bundler-friendly.mjs) \ $(sqlite3-worker1.js) all quick: $(sqlite3-api.ext.jses) q: quick diff --git a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js index 06eb0781c8..878147acd6 100644 --- a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js +++ b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js @@ -320,12 +320,16 @@ sqlite3Worker1Promiser.v2 = function(config){ promiseProxy.reject = reject; }); try{ - sqlite3Worker1Promiser(config); + this.original(config); }catch(e){ promiseProxy.reject(e); } return p; -}; +}.bind({ + /* We do this because clients are + recommended to delete globalThis.sqlite3Worker1Promiser. */ + original: sqlite3Worker1Promiser +}); //#if target=es6-module /** diff --git a/ext/wasm/demo-worker1-promiser-esm.html b/ext/wasm/demo-worker1-promiser-esm.html deleted file mode 100644 index 3995950938..0000000000 --- a/ext/wasm/demo-worker1-promiser-esm.html +++ /dev/null @@ -1,311 +0,0 @@ - - - - - - - - - worker-promise (via ESM) tests - - -
    worker-promise (via ESM) tests
    - -
    -
    -
    Initializing app...
    -
    - On a slow internet connection this may take a moment. If this - message displays for "a long time", intialization may have - failed and the JavaScript console may contain clues as to why. -
    -
    -
    Downloading...
    -
    - -
    -
    Most stuff on this page happens in the dev console.
    -
    -
    - - - - - diff --git a/ext/wasm/demo-worker1-promiser.html b/ext/wasm/demo-worker1-promiser.c-pp.html similarity index 86% rename from ext/wasm/demo-worker1-promiser.html rename to ext/wasm/demo-worker1-promiser.c-pp.html index e99131e6c9..e0b487bdf3 100644 --- a/ext/wasm/demo-worker1-promiser.html +++ b/ext/wasm/demo-worker1-promiser.c-pp.html @@ -6,7 +6,11 @@ +//#if target=es6-module + worker-promise (via ESM) tests +//#else worker-promise tests +//#endif
    worker-promise tests
    @@ -22,13 +26,17 @@
    Downloading...
    - +
    Most stuff on this page happens in the dev console.

    +//#if target=es6-module + +//#else +//#endif diff --git a/ext/wasm/demo-worker1-promiser.js b/ext/wasm/demo-worker1-promiser.c-pp.js similarity index 89% rename from ext/wasm/demo-worker1-promiser.js rename to ext/wasm/demo-worker1-promiser.c-pp.js index 19a7af1143..f6fc9568ae 100644 --- a/ext/wasm/demo-worker1-promiser.js +++ b/ext/wasm/demo-worker1-promiser.c-pp.js @@ -13,7 +13,13 @@ Demonstration of the sqlite3 Worker API #1 Promiser: a Promise-based proxy for for the sqlite3 Worker #1 API. */ -'use strict'; +//#if target=es6-module +import {default as promiserFactory} from "./jswasm/sqlite3-worker1-promiser.mjs"; +//#else +"use strict"; +const promiserFactory = globalThis.sqlite3Worker1Promiser.v2; +delete globalThis.sqlite3Worker1Promiser; +//#endif (async function(){ const T = globalThis.SqliteTestUtil; const eOutput = document.querySelector('#test-output'); @@ -33,35 +39,35 @@ logHtml("","Total test count:",T.counter+". Total time =",(performance.now() - startTime),"ms"); }; - //why is this triggered even when we catch() a Promise? - //window.addEventListener('unhandledrejection', function(event) { - // warn('unhandledrejection',event); - //}); - const promiserConfig = { - worker: ()=>{ - const w = new Worker("jswasm/sqlite3-worker1.js"); - w.onerror = (event)=>error("worker.onerror",event); - return w; +//#ifnot target=es6-module + /** + The v1 interfaces uses an onready function. The v2 interface optionally + accepts one but does not require it. If provided, it is called _before_ + the promise is resolved, and the promise is rejected if onready() throws. + */ + onready: function(f){ + /* f === the function returned by promiserFactory(). + Ostensibly (f === workerPromise) but this function is + called before the promiserFactory() Promise resolves, so + before workerPromise is set. */ + console.warn("This is the v2 interface - you don't need an onready() function."); }, +//#endif debug: 1 ? undefined : (...args)=>console.debug('worker debug',...args), onunhandled: function(ev){ error("Unhandled worker message:",ev.data); }, onerror: function(ev){ error("worker1 error:",ev); - }, - onready: function(f){ - warn("This is the v2 interface - don't pass an onready() function."); } }; - const workerPromise = await globalThis.sqlite3Worker1Promiser.v2(promiserConfig) + const workerPromise = await promiserFactory(promiserConfig) .then((func)=>{ - log("Init complete. Starting tests momentarily."); + console.log("Init complete. Starting tests momentarily."); globalThis.sqlite3TestModule.setStatus(null)/*hide the HTML-side is-loading spinner*/; return func; }); - delete globalThis.sqlite3Worker1Promiser; const wtest = async function(msgType, msgArgs, callback){ if(2===arguments.length && 'function'===typeof msgArgs){ diff --git a/ext/wasm/dist.make b/ext/wasm/dist.make index 5165a7ec4b..0ea53063b4 100644 --- a/ext/wasm/dist.make +++ b/ext/wasm/dist.make @@ -50,8 +50,9 @@ dist.top.extras := \ demo-jsstorage.html demo-jsstorage.js \ demo-worker1.html demo-worker1.js \ demo-worker1-promiser.html demo-worker1-promiser.js \ - demo-worker1-promiser-esm.html -dist.jswasm.extras := $(sqlite3-api.ext.jses) $(sqlite3.wasm) + demo-worker1-promiser-esm.html demo-worker1-promiser.mjs +dist.jswasm.extras := $(sqlite3.wasm) \ + $(sqlite3-api.ext.jses) dist.common.extras := \ $(wildcard $(dir.common)/*.css) \ $(dir.common)/SqliteTestUtil.js diff --git a/manifest b/manifest index 199d0f3b07..7d1e1e777f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C wasm\spromiser.v2\sis\sessentially\sworking\sbut\sthe\sdemo\scode\sis\sdouble-loading\sthe\smodule\sfor\sas-yet-undetermined\sreasons. -D 2024-03-07T17:56:08.872 +C Resolve\sduplicate\sloading\sof\spromiser\sv2\sdemo\scode\s(a\sside\seffect\sof\shaving\sdone\sprecisely\swhat\sit\swas\stold\sto\sdo).\sConsolidate\sdemo-worker1-promiser(-esm).html/(m)js\svariants\sinto\scentral\scopies\sprocessed\swith\sc-pp. +D 2024-03-07T18:53:27.916 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -587,7 +587,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile fc361b472fdbf1256931769339d6d6e866048f6fcdbbe4bc1a60bfe70034895f +F ext/wasm/GNUmakefile 4bb4cf70a8153dd5b5fee17d724075c54174da630b424bbcf48c744633396f62 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -616,7 +616,7 @@ F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aae F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js fe427645e1499618f5fa7bc670af850577d8bcc132df982078690c9bf8400baa F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 -F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js aff58bf96c253451af02194bf883e1c4851ef4ddbbff0cdd6cfca8f04231ec5d +F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bd89edfe42a4d7122a6d6d405c5423cf00aabba1f76f6ea8e2dba9c628ddd91a F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd @@ -632,12 +632,11 @@ F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b823 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf F ext/wasm/demo-jsstorage.html 409c4be4af5f207fb2877160724b91b33ea36a3cd8c204e8da1acb828ffe588e F ext/wasm/demo-jsstorage.js 44e3ae7ec2483b6c511384c3c290beb6f305c721186bcf5398ca4e00004a06b8 -F ext/wasm/demo-worker1-promiser-esm.html 181039b54e1d88181626d7e157f0f8832a532cf5c0ff6a62607cdbcc746649f3 -F ext/wasm/demo-worker1-promiser.html 1de7c248c7c2cfd4a5783d2aa154bce62d74c6de98ab22f5786620b3354ed15f -F ext/wasm/demo-worker1-promiser.js e4cd1089269d106dd3bd20684eaddcd176c73baa31867ba0e445c8e7e29160b5 +F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a9ef7c42ff04d7a125ddca7e5db8 w ext/wasm/demo-worker1-promiser.html +F ext/wasm/demo-worker1-promiser.c-pp.js fcc628cb42fcfaf07d250477801de1e6deb1e319d003976612a0db8d76b9fccc w ext/wasm/demo-worker1-promiser.js F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef -F ext/wasm/dist.make 8a6e829868e88a67a82670c6bb5d7ffda5dc46aa3f227ba3563c346d246f96d5 +F ext/wasm/dist.make f2ce42305268fe33d4b50f6e4bb3daf4a60302a90736eee382f1b8af9ff32ec1 F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle.make 3c2eace29255d6ddd219f5d8cc2728cb28b9fe717ea80b6062c2a6178947a16b F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f @@ -2177,8 +2176,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0e272123ace55ed63fe86632671cca48e8965a28fc3625324984028729fc203f -R c8505d5644abe3c20f07eb87db82c9ac +P aa877ce0c3b3aa1accd6e5fcd722d1bfaa79bea28c04c6badd8a547cea4bbc63 +R defcc9933f81850986aa7430cee8afd6 U stephan -Z 20c543fa694914574de31b908812d405 +Z bec63fded5235320bd7ff6ae8e1104cd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1bcbadbb82..828254e7bc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aa877ce0c3b3aa1accd6e5fcd722d1bfaa79bea28c04c6badd8a547cea4bbc63 \ No newline at end of file +9347d9b9a69277e40ea2f3ec6e1ff37ea19d24b4af80c6230b10624173f2f17c \ No newline at end of file From f10de5360ad8941a1bd35c84e7dc461da1a21454 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 8 Mar 2024 03:24:09 +0000 Subject: [PATCH 0187/1030] Must use sqlite3IntFloatCompare() for accurate comparisons between very large integer and floating point values in RTREE. Otherwise the comparison does not work on all platforms. Further fix to [027e5336acc26f57]. FossilOrigin-Name: 820f106acff5f2cd01da0e95a0e6f2bcc087705bf8c08b730b1fdb08db5679c8 --- ext/rtree/rtree.c | 5 +++-- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index a24304a8ac..299b5b54b9 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1841,6 +1841,8 @@ static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){ return SQLITE_OK; } +int sqlite3IntFloatCompare(i64,double); + /* ** Rtree virtual table module xFilter method. */ @@ -1871,8 +1873,7 @@ static int rtreeFilter( int eType = sqlite3_value_numeric_type(argv[0]); if( eType==SQLITE_INTEGER || (eType==SQLITE_FLOAT - && (i64)(sqlite3_value_double(argv[0]))==iRowid - && (double)iRowid==sqlite3_value_double(argv[0])) + && 0==sqlite3IntFloatCompare(iRowid,sqlite3_value_double(argv[0]))) ){ rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode); }else{ diff --git a/manifest b/manifest index a1d3e6d18a..1c8020e2d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Introducing\sJS\sworker1\spromiser\sv2,\swhich\sinitializes\svia\sPromise\s(instead\sof\sa\scallback\sfunction)\sand\scan\sbe\sloaded\sas\san\sESM\smodule. -D 2024-03-07T19:29:53.171 +C Must\suse\ssqlite3IntFloatCompare()\sfor\saccurate\scomparisons\sbetween\svery\slarge\ninteger\sand\sfloating\spoint\svalues\sin\sRTREE.\s\sOtherwise\sthe\scomparison\sdoes\nnot\swork\son\sall\splatforms.\s\sFurther\sfix\sto\s[027e5336acc26f57]. +D 2024-03-08T03:24:09.798 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -506,7 +506,7 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 0dd4775e896cee6067979d67aff7c998e75c2c9d9cd8d62a1a790c09cde7adca -F ext/rtree/rtree.c d87dfef2dd8ee2360898857187b9f763e90dcee9cf98f3f487ec473b6ae30db3 +F ext/rtree/rtree.c b6133dba5ae331fa6c1fc34df6aa623eba951b05ac35116f954a0bf7ab550436 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test e0608db762b2aadca0ecb6f97396cf66244490adc3ba88f2a292b27be3e1da3e F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d @@ -632,8 +632,8 @@ F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b823 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf F ext/wasm/demo-jsstorage.html 409c4be4af5f207fb2877160724b91b33ea36a3cd8c204e8da1acb828ffe588e F ext/wasm/demo-jsstorage.js 44e3ae7ec2483b6c511384c3c290beb6f305c721186bcf5398ca4e00004a06b8 -F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a9ef7c42ff04d7a125ddca7e5db8 w ext/wasm/demo-worker1-promiser.html -F ext/wasm/demo-worker1-promiser.c-pp.js fcc628cb42fcfaf07d250477801de1e6deb1e319d003976612a0db8d76b9fccc w ext/wasm/demo-worker1-promiser.js +F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a9ef7c42ff04d7a125ddca7e5db8 +F ext/wasm/demo-worker1-promiser.c-pp.js fcc628cb42fcfaf07d250477801de1e6deb1e319d003976612a0db8d76b9fccc F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make f2ce42305268fe33d4b50f6e4bb3daf4a60302a90736eee382f1b8af9ff32ec1 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7fbdc1a849af3440579459bbb8797ebc7f9cce7b34d95675b8baa82db194ea9c 9347d9b9a69277e40ea2f3ec6e1ff37ea19d24b4af80c6230b10624173f2f17c -R 45d7a69c537ca325c17486c899557483 -U stephan -Z 1167a057df3ec3b4a36537840625ce5c +P 2fbaf2f51d37f70ee26d45f0c62f32c15a9e03f68b6d2e2892115e7dc028b929 +R 9853c9517d878f0be47f300b894b10da +U drh +Z 35bc8555140472f74b11b6aaf0808349 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 73fafb821c..922f1dae60 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2fbaf2f51d37f70ee26d45f0c62f32c15a9e03f68b6d2e2892115e7dc028b929 \ No newline at end of file +820f106acff5f2cd01da0e95a0e6f2bcc087705bf8c08b730b1fdb08db5679c8 \ No newline at end of file From a219fb5bb92371aa66fa7e21cb659b97163c2ab5 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Mar 2024 11:08:53 +0000 Subject: [PATCH 0188/1030] Do not run tests for the intck extension in OMIT_VIRTUAL_TABLE or OMIT_PRAGMA builds. FossilOrigin-Name: de8130c020821a1615cceeb730423a2d6e01578caaaddeb11950363c4f8ea412 --- ext/intck/intck1.test | 1 + ext/intck/intck2.test | 1 + ext/intck/intck_common.tcl | 10 ++++++++++ ext/intck/intckfault.test | 5 +---- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/ext/intck/intck1.test b/ext/intck/intck1.test index 1708406304..187132f766 100644 --- a/ext/intck/intck1.test +++ b/ext/intck/intck1.test @@ -15,6 +15,7 @@ source [file join [file dirname [info script]] intck_common.tcl] set testprefix intck1 +return_if_no_intck foreach {tn sql} { 1 "CREATE TABLE t1(a PRIMARY KEY, b)" diff --git a/ext/intck/intck2.test b/ext/intck/intck2.test index c8503042c9..23b241b5a9 100644 --- a/ext/intck/intck2.test +++ b/ext/intck/intck2.test @@ -15,6 +15,7 @@ source [file join [file dirname [info script]] intck_common.tcl] set testprefix intck2 +return_if_no_intck do_execsql_test 1.0 { diff --git a/ext/intck/intck_common.tcl b/ext/intck/intck_common.tcl index 7d6579ae03..1e216b59f3 100644 --- a/ext/intck/intck_common.tcl +++ b/ext/intck/intck_common.tcl @@ -15,6 +15,16 @@ if {![info exists testdir]} { } source $testdir/tester.tcl +ifcapable !vtab||!pragma { + proc return_if_no_intck {} { + finish_test + return -code return + } + return +} else { + proc return_if_no_intck {} {} +} + proc do_intck {db {bSuspend 0}} { set ic [sqlite3_intck $db main] diff --git a/ext/intck/intckfault.test b/ext/intck/intckfault.test index 5c383681ac..0bc06e584a 100644 --- a/ext/intck/intckfault.test +++ b/ext/intck/intckfault.test @@ -12,8 +12,7 @@ source [file join [file dirname [info script]] intck_common.tcl] set testprefix intckfault - - +return_if_no_intck do_execsql_test 1.0 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); @@ -36,8 +35,6 @@ do_faultsim_test 1 -faults oom-t* -prep { set res } -test { catch { $::ic close } -puts $testresult -puts $testnfail faultsim_test_result {0 {SQLITE_OK {}}} {0 {SQLITE_NOMEM {}}} {0 {SQLITE_NOMEM {out of memory}}} } diff --git a/manifest b/manifest index 1c8020e2d0..4a3f018db0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Must\suse\ssqlite3IntFloatCompare()\sfor\saccurate\scomparisons\sbetween\svery\slarge\ninteger\sand\sfloating\spoint\svalues\sin\sRTREE.\s\sOtherwise\sthe\scomparison\sdoes\nnot\swork\son\sall\splatforms.\s\sFurther\sfix\sto\s[027e5336acc26f57]. -D 2024-03-08T03:24:09.798 +C Do\snot\srun\stests\sfor\sthe\sintck\sextension\sin\sOMIT_VIRTUAL_TABLE\sor\sOMIT_PRAGMA\sbuilds. +D 2024-03-08T11:08:53.935 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -250,12 +250,12 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/intck/intck1.test 8a879640c90fdff5e91e6c2c41d509485ee634e8077fe0ca9f76be4cbd441fa3 -F ext/intck/intck2.test 47afb44681d13d11072cd8906e6aa877c967e65be788b01f6139922fd91474ef -F ext/intck/intck_common.tcl 9e51458126576783f11051ac0fd25bea3f6b17f570a55884223737f3200b214b +F ext/intck/intck1.test f3a3cba14b6aeff145ffa5515546dd22f7510dad91512e519f43b92b56514012 +F ext/intck/intck2.test d2457c7e5e5b688046d15ebe08a1e1427cc5e7a6dc8d6af215f42e8bcaf67304 +F ext/intck/intck_common.tcl a61fd2697ae55b0a3d89847ca0b590c6e0d8ff64bebb70920d93724799894159 F ext/intck/intckbusy.test 0732fe3efbb9e0a53ffdcc240073f6ff2777ea82c3e08812b16494f650763fe1 F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 -F ext/intck/intckfault.test ba0213c9c8dce08d519d5251268a3bab076a184b4d07acdea23b65e89c9ae03c +F ext/intck/intckfault.test cff3f75dff74abb3edfcb13f6aa53f6436746ab64b09fe5e2028f051e985efab F ext/intck/sqlite3intck.c 0d10df36e2b7b438aa80ecd3f5e584d41b747586b038258fe6b407f66b81e7c5 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 F ext/intck/test_intck.c 34243458378a12d1356c79219a03f244800533b3ab65b4a02861f0403364df12 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2fbaf2f51d37f70ee26d45f0c62f32c15a9e03f68b6d2e2892115e7dc028b929 -R 9853c9517d878f0be47f300b894b10da -U drh -Z 35bc8555140472f74b11b6aaf0808349 +P 820f106acff5f2cd01da0e95a0e6f2bcc087705bf8c08b730b1fdb08db5679c8 +R e79b9941107e8b2e4d5643573f5112b9 +U dan +Z 20f09b597a6402ea271e837d23b82103 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 922f1dae60..8a852f1cf2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -820f106acff5f2cd01da0e95a0e6f2bcc087705bf8c08b730b1fdb08db5679c8 \ No newline at end of file +de8130c020821a1615cceeb730423a2d6e01578caaaddeb11950363c4f8ea412 \ No newline at end of file From 3041642b1a7bfe853302e58d1986eb6792cfe55a Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Mar 2024 11:13:20 +0000 Subject: [PATCH 0189/1030] Fix pragma6.test so that it works with ENABLE_OVERSIZE_CELL_CHECK builds. FossilOrigin-Name: a02551de4c2d7085569ee76f88bfef5da429e40137cc1d1349b4637f88259ad1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/pragma6.test | 23 +++++++++++++---------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 4a3f018db0..e42792ac4a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srun\stests\sfor\sthe\sintck\sextension\sin\sOMIT_VIRTUAL_TABLE\sor\sOMIT_PRAGMA\sbuilds. -D 2024-03-08T11:08:53.935 +C Fix\spragma6.test\sso\sthat\sit\sworks\swith\sENABLE_OVERSIZE_CELL_CHECK\sbuilds. +D 2024-03-08T11:13:20.081 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1501,7 +1501,7 @@ F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 F test/pragma4.test 9559cf5173864bf47c0431873d158fbeb72f920a59905b1f46069d8543eccdab F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d9102 -F test/pragma6.test fc3b670ab8ed985b2e5faa870f0f81aba1bfd5c3877ef3214e2df88592ccd3e5 +F test/pragma6.test c5ec577ba087954b4dfa619a3cbe97b155b60a0af487527abe89b10fc17e6512 F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8 F test/prefixes.test b524a1c44bffec225b9aec98bd728480352aa8532ac4c15771fb85e8beef65d9 F test/printf.test 685fec5a0c5af2490ab0632775a301554361d674211d690f5bee0a97b05333de @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 820f106acff5f2cd01da0e95a0e6f2bcc087705bf8c08b730b1fdb08db5679c8 -R e79b9941107e8b2e4d5643573f5112b9 +P de8130c020821a1615cceeb730423a2d6e01578caaaddeb11950363c4f8ea412 +R 7c7022496908a493f9a8f2b8a0b5ac5e U dan -Z 20f09b597a6402ea271e837d23b82103 +Z 4eebf82ab948ebc787bc88c49fe0f5a5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8a852f1cf2..3d95c47ad5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de8130c020821a1615cceeb730423a2d6e01578caaaddeb11950363c4f8ea412 \ No newline at end of file +a02551de4c2d7085569ee76f88bfef5da429e40137cc1d1349b4637f88259ad1 \ No newline at end of file diff --git a/test/pragma6.test b/test/pragma6.test index 8e4233a536..fc5566af10 100644 --- a/test/pragma6.test +++ b/test/pragma6.test @@ -51,16 +51,19 @@ do_test 1.0 { }] } {} -do_execsql_test 1.1 { - CREATE TEMP TABLE t2( - a t1 PRIMARY KEY default 27, - b default(current_timestamp), - d TEXT UNIQUE DEFAULT 'ch`arlie', - c TEXT UNIQUE DEFAULT 084, - UNIQUE(c,b,b,a,b) - ) WITHOUT ROWID; - INSERT INTO t1(a) VALUES(zeroblob(40000)); -} +do_test 1.1 { + execsql { + CREATE TEMP TABLE t2( + a t1 PRIMARY KEY default 27, + b default(current_timestamp), + d TEXT UNIQUE DEFAULT 'ch`arlie', + c TEXT UNIQUE DEFAULT 084, + UNIQUE(c,b,b,a,b) + ) WITHOUT ROWID; + } + catchsql { INSERT INTO t1(a) VALUES(zeroblob(40000)) } + set {} {} +} {} do_test 1.2 { execsql { PRAGMA integrity_check; } From b89aa10cd0d980563df54b5ad0fb2214f06c7c80 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Mar 2024 13:49:43 +0000 Subject: [PATCH 0190/1030] Omit some extra tests for the intck extension in OMIT_VIRTUAL_TABLE or OMIT_PRAGMA builds. FossilOrigin-Name: 29d9eb7d55755604781e507f6ca36c50d62fa8d8589ab932d7cefca94ba24f3e --- ext/intck/intckbusy.test | 1 + ext/intck/intckcorrupt.test | 1 + manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/intck/intckbusy.test b/ext/intck/intckbusy.test index edfedf5ae8..7c65b686bb 100644 --- a/ext/intck/intckbusy.test +++ b/ext/intck/intckbusy.test @@ -12,6 +12,7 @@ source [file join [file dirname [info script]] intck_common.tcl] set testprefix intckbusy +return_if_no_intck diff --git a/ext/intck/intckcorrupt.test b/ext/intck/intckcorrupt.test index 40f009f9c2..eee63b32f0 100644 --- a/ext/intck/intckcorrupt.test +++ b/ext/intck/intckcorrupt.test @@ -15,6 +15,7 @@ source [file join [file dirname [info script]] intck_common.tcl] set testprefix intckcorrupt +return_if_no_intck #------------------------------------------------------------------------- reset_db diff --git a/manifest b/manifest index e42792ac4a..91661718cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\spragma6.test\sso\sthat\sit\sworks\swith\sENABLE_OVERSIZE_CELL_CHECK\sbuilds. -D 2024-03-08T11:13:20.081 +C Omit\ssome\sextra\stests\sfor\sthe\sintck\sextension\sin\sOMIT_VIRTUAL_TABLE\sor\sOMIT_PRAGMA\sbuilds. +D 2024-03-08T13:49:43.243 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -253,8 +253,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/intck/intck1.test f3a3cba14b6aeff145ffa5515546dd22f7510dad91512e519f43b92b56514012 F ext/intck/intck2.test d2457c7e5e5b688046d15ebe08a1e1427cc5e7a6dc8d6af215f42e8bcaf67304 F ext/intck/intck_common.tcl a61fd2697ae55b0a3d89847ca0b590c6e0d8ff64bebb70920d93724799894159 -F ext/intck/intckbusy.test 0732fe3efbb9e0a53ffdcc240073f6ff2777ea82c3e08812b16494f650763fe1 -F ext/intck/intckcorrupt.test 3211ef68ac53e83951b6c8f6a8d2396506d123fe5898f97f848a25837744ec56 +F ext/intck/intckbusy.test d5ed4ef85a4b1dc1dee2484bd14a4bb68529659cca743327df0c775f005fa387 +F ext/intck/intckcorrupt.test f6c302792326fb3db9dcfc70b554c55369bc4b52882eaaf039cfe0b74c821029 F ext/intck/intckfault.test cff3f75dff74abb3edfcb13f6aa53f6436746ab64b09fe5e2028f051e985efab F ext/intck/sqlite3intck.c 0d10df36e2b7b438aa80ecd3f5e584d41b747586b038258fe6b407f66b81e7c5 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P de8130c020821a1615cceeb730423a2d6e01578caaaddeb11950363c4f8ea412 -R 7c7022496908a493f9a8f2b8a0b5ac5e +P a02551de4c2d7085569ee76f88bfef5da429e40137cc1d1349b4637f88259ad1 +R af066a0422542da1cc5e88fc5055710e U dan -Z 4eebf82ab948ebc787bc88c49fe0f5a5 +Z b2bec38f4a2e9b652e878f166176c721 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3d95c47ad5..d5fb64437e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a02551de4c2d7085569ee76f88bfef5da429e40137cc1d1349b4637f88259ad1 \ No newline at end of file +29d9eb7d55755604781e507f6ca36c50d62fa8d8589ab932d7cefca94ba24f3e \ No newline at end of file From 926fb60b05be799ff6e9f0013d2a0f393cfd380c Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 8 Mar 2024 14:01:48 +0000 Subject: [PATCH 0191/1030] Silently ignore redundant ON CONFLICT clauses in an UPSERT. Only the first ON CONFLICT for each index is active. Do not issue an error, since that might break legacy queries. But ignore the redundant ON CONFLICT clauses to prevent problems such as described in [forum:/forumpost/919c6579c8|forum post 919c6579c8]. FossilOrigin-Name: d0ea6b6ba64dba9d68c2b391ccf1171ea96fcdd7409dafdb2b697accb00246b8 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/insert.c | 2 +- src/sqliteInt.h | 3 ++- src/upsert.c | 21 +++++++++++++++++---- test/upsert5.test | 42 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 91661718cc..e75a8d5b89 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\ssome\sextra\stests\sfor\sthe\sintck\sextension\sin\sOMIT_VIRTUAL_TABLE\sor\sOMIT_PRAGMA\sbuilds. -D 2024-03-08T13:49:43.243 +C Silently\signore\sredundant\sON\sCONFLICT\sclauses\sin\san\sUPSERT.\s\sOnly\sthe\sfirst\nON\sCONFLICT\sfor\seach\sindex\sis\sactive.\s\sDo\snot\sissue\san\serror,\ssince\sthat\smight\nbreak\slegacy\squeries.\s\sBut\signore\sthe\sredundant\sON\sCONFLICT\sclauses\sto\sprevent\nproblems\ssuch\sas\sdescribed\sin\s[forum:/forumpost/919c6579c8|forum\spost\s919c6579c8]. +D 2024-03-08T14:01:48.797 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 +F src/insert.c eb33ea46dcab93e90f112fced343aaf41f59cbd2e951d5066f1f9302be1c2f34 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -755,7 +755,7 @@ F src/shell.c.in 78bbd861cd0128aed67c0136561572ebcf11649be6cea86bee8491576d5958d F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 58b7295a748ca5ed9e211510205b4a66a24c68f864225b81e19d4cf6038b40a1 +F src/sqliteInt.h 06d757ee6cd22f59593e51a7066327a0690a6cb66dad4f0077ee3297228f5401 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -816,7 +816,7 @@ F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd6 F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 -F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242 +F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c f27a17e6e43fa362abea4db507a1c409f0adc8048ecf4c6479e8d162158ed529 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 @@ -1907,7 +1907,7 @@ F test/upsert1.test a512e2f884d3a36159fce2e45108c236f78ae38e35bda55f4050db580ceb F test/upsert2.test 720e94d09f7362a282bc69b3c6b83d51daeaaf0440eb4920a08b86518b8c7496 F test/upsert3.test 88d7d590a1948a9cb6eac1b54b0642f67a9f35a1fc0f19b200e97d5d39e3179c F test/upsert4.test 25d2a1da92f149331ae0c51ca6e3eee78189577585eab92de149900d62994fa5 -F test/upsert5.test fff0dcfce73c649204543088d8e5bde01172676063ec9b8f8fc7f195abc386fe +F test/upsert5.test 9953b180d02d1369cdbb6c73c900834e5fef8cb78e98e07511c8762ec21cc176 F test/upsertfault.test f21ca47740841fdb4d61acfa7b17646d773e67724fe8c185b71c018db8a94b35 F test/uri.test c1abaaaa28e9422d61e5f3f9cbc8ef993ec49fe802f581520731708561d49384 F test/uri2.test 9d3ba7a53ee167572d53a298ee4a5d38ec4a8fb7 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a02551de4c2d7085569ee76f88bfef5da429e40137cc1d1349b4637f88259ad1 -R af066a0422542da1cc5e88fc5055710e -U dan -Z b2bec38f4a2e9b652e878f166176c721 +P 29d9eb7d55755604781e507f6ca36c50d62fa8d8589ab932d7cefca94ba24f3e +R 854945d64d6a5cfe38a3cc1c6a5b5bd3 +U drh +Z 3c2e932dfbe4dcd203c5f3b4ed97d851 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d5fb64437e..492aebc3bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -29d9eb7d55755604781e507f6ca36c50d62fa8d8589ab932d7cefca94ba24f3e \ No newline at end of file +d0ea6b6ba64dba9d68c2b391ccf1171ea96fcdd7409dafdb2b697accb00246b8 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 1c31ca2338..095298b90c 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1086,7 +1086,7 @@ void sqlite3Insert( pNx->iDataCur = iDataCur; pNx->iIdxCur = iIdxCur; if( pNx->pUpsertTarget ){ - if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx) ){ + if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx, pUpsert) ){ goto insert_cleanup; } } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f5920748ba..91cf173040 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3476,6 +3476,7 @@ struct Upsert { Expr *pUpsertWhere; /* WHERE clause for the ON CONFLICT UPDATE */ Upsert *pNextUpsert; /* Next ON CONFLICT clause in the list */ u8 isDoUpdate; /* True for DO UPDATE. False for DO NOTHING */ + u8 isDup; /* True if 2nd or later with same pUpsertIdx */ /* Above this point is the parse tree for the ON CONFLICT clauses. ** The next group of fields stores intermediate data. */ void *pToFree; /* Free memory when deleting the Upsert object */ @@ -5552,7 +5553,7 @@ const char *sqlite3JournalModename(int); Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*); void sqlite3UpsertDelete(sqlite3*,Upsert*); Upsert *sqlite3UpsertDup(sqlite3*,Upsert*); - int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*); + int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*,Upsert*); void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int); Upsert *sqlite3UpsertOfIndex(Upsert*,Index*); int sqlite3UpsertNextIsIPK(Upsert*); diff --git a/src/upsert.c b/src/upsert.c index be0d0550df..f74d4fabf5 100644 --- a/src/upsert.c +++ b/src/upsert.c @@ -90,7 +90,8 @@ Upsert *sqlite3UpsertNew( int sqlite3UpsertAnalyzeTarget( Parse *pParse, /* The parsing context */ SrcList *pTabList, /* Table into which we are inserting */ - Upsert *pUpsert /* The ON CONFLICT clauses */ + Upsert *pUpsert, /* The ON CONFLICT clauses */ + Upsert *pAll /* Complete list of all ON CONFLICT clauses */ ){ Table *pTab; /* That table into which we are inserting */ int rc; /* Result code */ @@ -193,6 +194,14 @@ int sqlite3UpsertAnalyzeTarget( continue; } pUpsert->pUpsertIdx = pIdx; + if( sqlite3UpsertOfIndex(pAll,pIdx)!=pUpsert ){ + /* Really this should be an error. The isDup ON CONFLICT clause will + ** never fire. But this problem was not discovered until three years + ** after multi-CONFLICT upsert was added, and so we silently ignore + ** the problem to prevent breaking applications that might actually + ** have redundant ON CONFLICT clauses. */ + pUpsert->isDup = 1; + } break; } if( pUpsert->pUpsertIdx==0 ){ @@ -219,9 +228,13 @@ int sqlite3UpsertNextIsIPK(Upsert *pUpsert){ Upsert *pNext; if( NEVER(pUpsert==0) ) return 0; pNext = pUpsert->pNextUpsert; - if( pNext==0 ) return 1; - if( pNext->pUpsertTarget==0 ) return 1; - if( pNext->pUpsertIdx==0 ) return 1; + while( 1 /*exit-by-return*/ ){ + if( pNext==0 ) return 1; + if( pNext->pUpsertTarget==0 ) return 1; + if( pNext->pUpsertIdx==0 ) return 1; + if( !pNext->isDup ) return 0; + pNext = pNext->pNextUpsert; + } return 0; } diff --git a/test/upsert5.test b/test/upsert5.test index 3161abf15e..e56e71d4b9 100644 --- a/test/upsert5.test +++ b/test/upsert5.test @@ -408,4 +408,46 @@ do_catchsql_test 2.1 { } {1 {no such table: nosuchtable}} +# 2024-03-08 https://sqlite.org/forum/forumpost/919c6579c8 +# A redundant ON CONFLICT clause in an upsert can lead to +# index corruption. +# +reset_db +do_execsql_test 3.0 { + CREATE TABLE t1(aa INTEGER PRIMARY KEY, bb INT); + INSERT INTO t1 VALUES(11,22); + CREATE UNIQUE INDEX t1bb ON t1(bb); + REPLACE INTO t1 VALUES(11,33) + ON CONFLICT(bb) DO UPDATE SET aa = 44 + ON CONFLICT(bb) DO UPDATE SET aa = 44; + PRAGMA integrity_check; +} {ok} +do_execsql_test 3.1 { + SELECT * FROM t1 NOT INDEXED; +} {11 33} +do_execsql_test 3.2 { + SELECT * FROM t1 INDEXED BY t1bb; +} {11 33} +do_execsql_test 3.3 { + DROP TABLE t1; + CREATE TABLE t1(aa INTEGER PRIMARY KEY, bb INT, cc INT); + INSERT INTO t1 VALUES(10,21,32),(11,22,33),(12,23,34); + CREATE UNIQUE INDEX t1bb ON t1(bb); + CREATE UNIQUE INDEX t1cc ON t1(cc); + REPLACE INTO t1 VALUES(11,44,55) + ON CONFLICT(bb) DO UPDATE SET aa = 99 + ON CONFLICT(cc) DO UPDATE SET aa = 99 + ON CONFLICT(bb) DO UPDATE SET aa = 99; + PRAGMA integrity_check; +} {ok} +do_execsql_test 3.4 { + SELECT * FROM t1 NOT INDEXED ORDER BY +aa; +} {10 21 32 11 44 55 12 23 34} +do_execsql_test 3.5 { + SELECT * FROM t1 INDEXED BY t1bb ORDER BY +aa; +} {10 21 32 11 44 55 12 23 34} +do_execsql_test 3.6 { + SELECT * FROM t1 INDEXED BY t1cc ORDER BY +aa; +} {10 21 32 11 44 55 12 23 34} + finish_test From 744e5672bff25eb4c83a568566c7168ff60d731e Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 8 Mar 2024 15:39:59 +0000 Subject: [PATCH 0192/1030] Add new assert() statements, which if they had existed three years ago, would have detected the code generator problem fixed by the previous check-in. FossilOrigin-Name: 166d1e5d26ef88e995f44182144891f60bd51c1aa585b4a148f01a920b2a8eea --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/vdbe.c | 28 +++++++++++++++------------- src/vdbeaux.c | 8 ++++++++ tool/mkopcodeh.tcl | 9 ++++++++- 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index e75a8d5b89..240d8fc2aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Silently\signore\sredundant\sON\sCONFLICT\sclauses\sin\san\sUPSERT.\s\sOnly\sthe\sfirst\nON\sCONFLICT\sfor\seach\sindex\sis\sactive.\s\sDo\snot\sissue\san\serror,\ssince\sthat\smight\nbreak\slegacy\squeries.\s\sBut\signore\sthe\sredundant\sON\sCONFLICT\sclauses\sto\sprevent\nproblems\ssuch\sas\sdescribed\sin\s[forum:/forumpost/919c6579c8|forum\spost\s919c6579c8]. -D 2024-03-08T14:01:48.797 +C Add\snew\sassert()\sstatements,\swhich\sif\sthey\shad\sexisted\sthree\syears\sago,\nwould\shave\sdetected\sthe\scode\sgenerator\sproblem\sfixed\sby\sthe\sprevious\scheck-in. +D 2024-03-08T15:39:59.999 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -820,11 +820,11 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c f27a17e6e43fa362abea4db507a1c409f0adc8048ecf4c6479e8d162158ed529 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 7a33c5bb37e12ce35ac2d1d56a6429288b0b56c940ba660265c1428c67883729 +F src/vdbe.c da8407be6055f5751bf85681542d130a320b4fd1f4d8719bf83a464743d9aae4 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b -F src/vdbeaux.c 66161ba75c4a2d86aab124fe3cbcc2a752d8e4b1fc8c1fc6e00625db4798168c +F src/vdbeaux.c e52815bc11fccedcc7acb14ae98c607a1c5b6c773ff4d584cd192432540502c9 F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 213bf303826c0ef702e3a2a69dab2309d84b8381b822c6787885859fd7cd4c4e F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 @@ -2101,7 +2101,7 @@ F tool/mkctimec.tcl a16682eae5f01f85e5861b2aa215ca0d46b4230658ee25977e02b4508566 F tool/mkkeywordhash.c b9faa0ae7e14e4dbbcd951cddd786bf46b8a65bb07b129ba8c0cfade723aaffd F tool/mkmsvcmin.tcl 8897d515ef7f94772322db95a3b6fce6c614d84fe0bdd06ba5a1c786351d5a1d F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef -F tool/mkopcodeh.tcl 769d9e6a8b462323150dc13a8539d6064664b72974f7894befe2491cc73e05cd +F tool/mkopcodeh.tcl 2b4e6967a670ef21bf53a164964c35c6163277d002a4c6f56fa231d68c88d023 F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa F tool/mkpragmatab.tcl 32e359ccb21011958a821955254bd7a5fa7915d01a8c16fed91ffc8b40cb4adf F tool/mkshellc.tcl b7adf08b82de60811d2cb6af05ff59fc17e5cd6f3e98743c14eaaa3f8971fed0 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 29d9eb7d55755604781e507f6ca36c50d62fa8d8589ab932d7cefca94ba24f3e -R 854945d64d6a5cfe38a3cc1c6a5b5bd3 +P d0ea6b6ba64dba9d68c2b391ccf1171ea96fcdd7409dafdb2b697accb00246b8 +R e2ddfd9aa39901e567d105504257c018 U drh -Z 3c2e932dfbe4dcd203c5f3b4ed97d851 +Z 9df6c164111bd68c49bf51ae68acbbe9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 492aebc3bd..249f75b766 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0ea6b6ba64dba9d68c2b391ccf1171ea96fcdd7409dafdb2b697accb00246b8 \ No newline at end of file +166d1e5d26ef88e995f44182144891f60bd51c1aa585b4a148f01a920b2a8eea \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 709ebd9fb8..faa12aaf8d 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1129,7 +1129,7 @@ case OP_Return: { /* in1 */ ** ** See also: EndCoroutine */ -case OP_InitCoroutine: { /* jump */ +case OP_InitCoroutine: { /* jump0 */ assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) ); assert( pOp->p2>=0 && pOp->p2nOp ); assert( pOp->p3>=0 && pOp->p3nOp ); @@ -1182,7 +1182,7 @@ case OP_EndCoroutine: { /* in1 */ ** ** See also: InitCoroutine */ -case OP_Yield: { /* in1, jump */ +case OP_Yield: { /* in1, jump0 */ int pcDest; pIn1 = &aMem[pOp->p1]; assert( VdbeMemDynamic(pIn1)==0 ); @@ -2041,7 +2041,7 @@ case OP_AddImm: { /* in1 */ ** without data loss, then jump immediately to P2, or if P2==0 ** raise an SQLITE_MISMATCH exception. */ -case OP_MustBeInt: { /* jump, in1 */ +case OP_MustBeInt: { /* jump0, in1 */ pIn1 = &aMem[pOp->p1]; if( (pIn1->flags & MEM_Int)==0 ){ applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding); @@ -4725,10 +4725,10 @@ case OP_ColumnsUsed: { ** ** See also: Found, NotFound, SeekGt, SeekGe, SeekLt */ -case OP_SeekLT: /* jump, in3, group, ncycle */ -case OP_SeekLE: /* jump, in3, group, ncycle */ -case OP_SeekGE: /* jump, in3, group, ncycle */ -case OP_SeekGT: { /* jump, in3, group, ncycle */ +case OP_SeekLT: /* jump0, in3, group, ncycle */ +case OP_SeekLE: /* jump0, in3, group, ncycle */ +case OP_SeekGE: /* jump0, in3, group, ncycle */ +case OP_SeekGT: { /* jump0, in3, group, ncycle */ int res; /* Comparison result */ int oc; /* Opcode */ VdbeCursor *pC; /* The cursor to seek */ @@ -5395,7 +5395,7 @@ case OP_Found: { /* jump, in3, ncycle */ ** ** See also: Found, NotFound, NoConflict, SeekRowid */ -case OP_SeekRowid: { /* jump, in3, ncycle */ +case OP_SeekRowid: { /* jump0, in3, ncycle */ VdbeCursor *pC; BtCursor *pCrsr; int res; @@ -6154,7 +6154,7 @@ case OP_NullRow: { ** configured to use Prev, not Next. */ case OP_SeekEnd: /* ncycle */ -case OP_Last: { /* jump, ncycle */ +case OP_Last: { /* jump0, ncycle */ VdbeCursor *pC; BtCursor *pCrsr; int res; @@ -6271,7 +6271,7 @@ case OP_Sort: { /* jump ncycle */ ** from the beginning toward the end. In other words, the cursor is ** configured to use Next, not Prev. */ -case OP_Rewind: { /* jump, ncycle */ +case OP_Rewind: { /* jump0, ncycle */ VdbeCursor *pC; BtCursor *pCrsr; int res; @@ -7279,7 +7279,9 @@ case OP_RowSetTest: { /* jump, in1, in3 */ ** P1 contains the address of the memory cell that contains the first memory ** cell in an array of values used as arguments to the sub-program. P2 ** contains the address to jump to if the sub-program throws an IGNORE -** exception using the RAISE() function. Register P3 contains the address +** exception using the RAISE() function. P2 might be zero, if there is +** no possibility that an IGNORE exception will be raised. +** Register P3 contains the address ** of a memory cell in this (the parent) VM that is used to allocate the ** memory required by the sub-vdbe at runtime. ** @@ -7287,7 +7289,7 @@ case OP_RowSetTest: { /* jump, in1, in3 */ ** ** If P5 is non-zero, then recursive program invocation is enabled. */ -case OP_Program: { /* jump */ +case OP_Program: { /* jump0 */ int nMem; /* Number of memory registers for sub-program */ int nByte; /* Bytes of runtime space required for sub-program */ Mem *pRt; /* Register to allocate runtime space */ @@ -8836,7 +8838,7 @@ case OP_Filter: { /* jump */ ** error is encountered. */ case OP_Trace: -case OP_Init: { /* jump */ +case OP_Init: { /* jump0 */ int i; #ifndef SQLITE_OMIT_TRACE char *zTrace; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 209d02a049..6519bc9651 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -939,6 +939,14 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ assert( aLabel!=0 ); /* True because of tag-20230419-1 */ pOp->p2 = aLabel[ADDR(pOp->p2)]; } + + /* OPFLG_JUMP opcodes never have P2==0, though OPFLG_JUMP0 opcodes + ** might */ + assert( pOp->p2>0 + || (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP0)!=0 ); + + /* Jumps never go off the end of the bytecode array */ + assert( pOp->p2nOp ); break; } } diff --git a/tool/mkopcodeh.tcl b/tool/mkopcodeh.tcl index 6fb3b75940..18fe1a2658 100644 --- a/tool/mkopcodeh.tcl +++ b/tool/mkopcodeh.tcl @@ -81,6 +81,7 @@ while {![eof $in]} { set op($name) -1 set group($name) 0 set jump($name) 0 + set jump0($name) 0 set in1($name) 0 set in2($name) 0 set in3($name) 0 @@ -109,6 +110,7 @@ while {![eof $in]} { out2 {set out2($name) 1} out3 {set out3($name) 1} ncycle {set ncycle($name) 1} + jump0 {set jump($name) 1; set jump0($name) 1;} } } if {$group($name)} { @@ -137,6 +139,7 @@ puts "/* Automatically generated. Do not edit */" puts "/* See the tool/mkopcodeh.tcl script for details */" foreach name {OP_Noop OP_Explain OP_Abortable} { set jump($name) 0 + set jump0($name) 0 set in1($name) 0 set in2($name) 0 set in3($name) 0 @@ -256,7 +259,9 @@ for {set i 0} {$i<=$max} {incr i} { set name $def($i) puts -nonewline [format {#define %-16s %3d} $name $i] set com {} - if {[info exists jump($name)] && $jump($name)} { + if {[info exists jump0($name)] && $jump0($name)} { + lappend com "jump0" + } elseif {[info exists jump($name)] && $jump($name)} { lappend com "jump" } if {[info exists sameas($i)]} { @@ -289,6 +294,7 @@ for {set i 0} {$i<=$max} {incr i} { if {$out2($name)} {incr x 16} if {$out3($name)} {incr x 32} if {$ncycle($name)} {incr x 64} + if {$jump0($name)} {incr x 128} } set bv($i) $x } @@ -304,6 +310,7 @@ puts "#define OPFLG_IN3 0x08 /* in3: P3 is an input */" puts "#define OPFLG_OUT2 0x10 /* out2: P2 is an output */" puts "#define OPFLG_OUT3 0x20 /* out3: P3 is an output */" puts "#define OPFLG_NCYCLE 0x40 /* ncycle:Cycles count against P1 */" +puts "#define OPFLG_JUMP0 0x80 /* jump0: P2 might be zero */" puts "#define OPFLG_INITIALIZER \173\\" for {set i 0} {$i<=$max} {incr i} { if {$i%8==0} { From 96f5ae6bd74a43f0ada92bdc40d3b23257116291 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 8 Mar 2024 19:03:30 +0000 Subject: [PATCH 0193/1030] One of the assert()s added by the previous check-in was not quite correct. This commit fixes it. FossilOrigin-Name: d401358329f5a70f9a0b9b033609a4db2af89b83c6b40242be0c76f3d6474def --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 240d8fc2aa..fcee6b38c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sassert()\sstatements,\swhich\sif\sthey\shad\sexisted\sthree\syears\sago,\nwould\shave\sdetected\sthe\scode\sgenerator\sproblem\sfixed\sby\sthe\sprevious\scheck-in. -D 2024-03-08T15:39:59.999 +C One\sof\sthe\sassert()s\sadded\sby\sthe\sprevious\scheck-in\swas\snot\squite\scorrect.\nThis\scommit\sfixes\sit. +D 2024-03-08T19:03:30.426 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -824,7 +824,7 @@ F src/vdbe.c da8407be6055f5751bf85681542d130a320b4fd1f4d8719bf83a464743d9aae4 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b -F src/vdbeaux.c e52815bc11fccedcc7acb14ae98c607a1c5b6c773ff4d584cd192432540502c9 +F src/vdbeaux.c 6385727adf51a649e4993098870a62c3945fe21dbc0e0fd9013772aff930b8fb F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 213bf303826c0ef702e3a2a69dab2309d84b8381b822c6787885859fd7cd4c4e F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d0ea6b6ba64dba9d68c2b391ccf1171ea96fcdd7409dafdb2b697accb00246b8 -R e2ddfd9aa39901e567d105504257c018 +P 166d1e5d26ef88e995f44182144891f60bd51c1aa585b4a148f01a920b2a8eea +R a10b9cfdedf65df80cd98f59556bbeca U drh -Z 9df6c164111bd68c49bf51ae68acbbe9 +Z 203e497a1090dbea6a05556e060a1144 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 249f75b766..a61603c541 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -166d1e5d26ef88e995f44182144891f60bd51c1aa585b4a148f01a920b2a8eea \ No newline at end of file +d401358329f5a70f9a0b9b033609a4db2af89b83c6b40242be0c76f3d6474def \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 6519bc9651..e5c8303435 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -946,7 +946,8 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ || (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP0)!=0 ); /* Jumps never go off the end of the bytecode array */ - assert( pOp->p2nOp ); + assert( pOp->p2nOp + || (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)==0 ); break; } } From 61b77a6fe14d271c89b0c392898b83dc05c658e5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 8 Mar 2024 21:37:18 +0000 Subject: [PATCH 0194/1030] The NOT NULL strength reduction optimization from [de9c86c9e4cdb34f] should be applied to the WHERE clause only. Otherwise, the operand of the IS NULL or IS NOT NULL operator might be a reference to a bare column of an aggregate table, and we can't tell if it is NULL or not based only on its NOT NULL attribute. [forum:/forumpost/440f2a2f17|Forum post 440f2a2f17]. FossilOrigin-Name: 51704feae224eff601db5607f8651da11b3c2ed8a58ffe5b6ee8260cab50695b --- manifest | 16 +++++++------- manifest.uuid | 2 +- src/resolve.c | 52 +++++++++++++++++++++++++++++++++++++--------- src/sqliteInt.h | 2 ++ test/notnull2.test | 16 ++++++++++---- 5 files changed, 65 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index fcee6b38c4..c35db0c838 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C One\sof\sthe\sassert()s\sadded\sby\sthe\sprevious\scheck-in\swas\snot\squite\scorrect.\nThis\scommit\sfixes\sit. -D 2024-03-08T19:03:30.426 +C The\sNOT\sNULL\sstrength\sreduction\soptimization\sfrom\s[de9c86c9e4cdb34f]\sshould\nbe\sapplied\sto\sthe\sWHERE\sclause\sonly.\s\sOtherwise,\sthe\soperand\sof\sthe\sIS\sNULL\nor\sIS\sNOT\sNULL\soperator\smight\sbe\sa\sreference\sto\sa\sbare\scolumn\sof\san\naggregate\stable,\sand\swe\scan't\stell\sif\sit\sis\sNULL\sor\snot\sbased\sonly\son\sits\nNOT\sNULL\sattribute.\s\s[forum:/forumpost/440f2a2f17|Forum\spost\s440f2a2f17]. +D 2024-03-08T21:37:18.921 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -748,14 +748,14 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d +F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 F src/shell.c.in 78bbd861cd0128aed67c0136561572ebcf11649be6cea86bee8491576d5958d0 F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 06d757ee6cd22f59593e51a7066327a0690a6cb66dad4f0077ee3297228f5401 +F src/sqliteInt.h 6123ce6ca6a1ef351c3b87189e92c92042728f16c088de56b9b5bc2552d0ae33 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -1455,7 +1455,7 @@ F test/notify1.test 669b2b743618efdc18ca4b02f45423d5d2304abf F test/notify2.test 2ecabaa1305083856b7c39cf32816b612740c161 F test/notify3.test 796c7b7157f55c93b4e672b724e9c923a6fc6aa72ac419379a623e2350472e22 F test/notnull.test a37b663d5bb728d66fc182016613fb8e4a0a4bbf3d75b8876a7527f7d4ed3f18 -F test/notnull2.test 1ee4acbd614d3cf5f1c4a52f5af7fc771b82352f1a51a86afeaa02c9df1d82ef +F test/notnull2.test 2ac7b4e04917148c7a1a9ed36df20150175ce942f07f5714375b29acbaca7106 F test/notnullfault.test fc4bb7845582a2b3db376001ef49118393b1b11abe0d24adb03db057ee2b73d5 F test/null.test b7ff206a1c60fe01aa2abd33ef9ea83c93727d993ca8a613de86e925c9f2bc6f F test/nulls1.test 7a5e4346ee4285034100b4cd20e6784f16a9d6c927e44ecdf10034086bbee9c9 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 166d1e5d26ef88e995f44182144891f60bd51c1aa585b4a148f01a920b2a8eea -R a10b9cfdedf65df80cd98f59556bbeca +P d401358329f5a70f9a0b9b033609a4db2af89b83c6b40242be0c76f3d6474def +R 05ce52a0a931825416b225aa397af1ac U drh -Z 203e497a1090dbea6a05556e060a1144 +Z ce9603354c09773b286e10e1291765af # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a61603c541..8202619d3e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d401358329f5a70f9a0b9b033609a4db2af89b83c6b40242be0c76f3d6474def \ No newline at end of file +51704feae224eff601db5607f8651da11b3c2ed8a58ffe5b6ee8260cab50695b \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 5d0801e82e..c2957a870a 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -971,6 +971,19 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ ** resolved. This prevents "column" from being counted as having been ** referenced, which might prevent a SELECT from being erroneously ** marked as correlated. + ** + ** 2024-03-28: Beware of aggregates. A bare column of aggregated table + ** can still evaluate to NULL even though it is marked as NOT NULL. + ** Example: + ** + ** CREATE TABLE t1(a INT NOT NULL); + ** SELECT a, a IS NULL, a IS NOT NULL, count(*) FROM t1; + ** + ** The "a IS NULL" and "a IS NOT NULL" expressions cannot be optimized + ** here because at the time this case is hit, we do not yet know whether + ** or not t1 is being aggregated. We have to assume the worst and omit + ** the optimization. The only time it is safe to apply this optimization + ** is within the WHERE clause. */ case TK_NOTNULL: case TK_ISNULL: { @@ -981,19 +994,36 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ anRef[i] = p->nRef; } sqlite3WalkExpr(pWalker, pExpr->pLeft); - if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){ - testcase( ExprHasProperty(pExpr, EP_OuterON) ); - assert( !ExprHasProperty(pExpr, EP_IntValue) ); - pExpr->u.iValue = (pExpr->op==TK_NOTNULL); - pExpr->flags |= EP_IntValue; - pExpr->op = TK_INTEGER; + if( IN_RENAME_OBJECT ) return WRC_Prune; + if( sqlite3ExprCanBeNull(pExpr->pLeft) ){ + /* The expression can be NULL. So the optimization does not apply */ + return WRC_Prune; + } - for(i=0, p=pNC; p && ipNext, i++){ - p->nRef = anRef[i]; + for(i=0, p=pNC; p; p=p->pNext, i++){ + if( (p->ncFlags & NC_Where)==0 ){ + return WRC_Prune; /* Not in a WHERE clause. Unsafe to optimize. */ } - sqlite3ExprDelete(pParse->db, pExpr->pLeft); - pExpr->pLeft = 0; } + testcase( ExprHasProperty(pExpr, EP_OuterON) ); + assert( !ExprHasProperty(pExpr, EP_IntValue) ); +#if TREETRACE_ENABLED + if( sqlite3TreeTrace & 0x80000 ){ + sqlite3DebugPrintf( + "NOT NULL strength reduction converts the following to %d:\n", + pExpr->op==TK_NOTNULL + ); + sqlite3ShowExpr(pExpr); + } +#endif /* TREETRACE_ENABLED */ + pExpr->u.iValue = (pExpr->op==TK_NOTNULL); + pExpr->flags |= EP_IntValue; + pExpr->op = TK_INTEGER; + for(i=0, p=pNC; p && ipNext, i++){ + p->nRef = anRef[i]; + } + sqlite3ExprDelete(pParse->db, pExpr->pLeft); + pExpr->pLeft = 0; return WRC_Prune; } @@ -1891,7 +1921,9 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ } if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; } + sNC.ncFlags |= NC_Where; if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; + sNC.ncFlags &= ~NC_Where; /* Resolve names in table-valued-function arguments */ for(i=0; ipSrc->nSrc; i++){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 91cf173040..e11b5b3a4e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1125,6 +1125,7 @@ extern u32 sqlite3TreeTrace; ** 0x00010000 Beginning of DELETE/INSERT/UPDATE processing ** 0x00020000 Transform DISTINCT into GROUP BY ** 0x00040000 SELECT tree dump after all code has been generated +** 0x00080000 NOT NULL strength reduction */ /* @@ -3453,6 +3454,7 @@ struct NameContext { #define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */ #define NC_FromDDL 0x040000 /* SQL text comes from sqlite_schema */ #define NC_NoSelect 0x080000 /* Do not descend into sub-selects */ +#define NC_Where 0x100000 /* Processing WHERE clause of a SELECT */ #define NC_OrderAgg 0x8000000 /* Has an aggregate other than count/min/max */ /* diff --git a/test/notnull2.test b/test/notnull2.test index 7f68086810..09161efbdb 100644 --- a/test/notnull2.test +++ b/test/notnull2.test @@ -59,14 +59,14 @@ do_vmstep_test 1.4.2 { do_vmstep_test 1.5.1 { SELECT count(*) FROM t2 WHERE EXISTS( - SELECT t2.d IS NULL FROM t1 WHERE t1.a=450 + SELECT 1 FROM t1 WHERE t1.a=450 AND t2.d IS NULL ) -} 10000 {1000} +} 7000 {0} do_vmstep_test 1.5.2 { SELECT count(*) FROM t2 WHERE EXISTS( - SELECT t2.c IS NULL FROM t1 WHERE t1.a=450 + SELECT 1 FROM t1 WHERE t1.a=450 AND t2.c IS NULL ) -} +100000 {1000} +} +8000 {0} #------------------------------------------------------------------------- reset_db @@ -111,4 +111,12 @@ do_execsql_test 4.1 { SELECT * FROM (SELECT 3 AS c FROM t1) AS t3 LEFT JOIN t2 ON c IS NULL; } {3 {}} +# 2024-03-08 https://sqlite.org/forum/forumpost/440f2a2f17 +# +reset_db +do_execsql_test 5.0 { + CREATE TABLE t1(a INT NOT NULL); + SELECT a IS NULL, a IS NOT NULL, count(*) FROM t1; +} {1 0 0} + finish_test From aa13f4c132ced1fda8d0d436b72c9c0b58ab16e2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 9 Mar 2024 13:31:10 +0000 Subject: [PATCH 0195/1030] Fuzzcheck is run automatically by testrunner.tcl, so there is no need to include fuzzcheck as a separate dependency for the releasetest target in the MSVC makefile. FossilOrigin-Name: 76629b2bff01df3d42eef2e93d626c291a2f129bd923498941465e5bca74e9f1 --- Makefile.msc | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 2f67600c31..31a9c57ebc 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2553,7 +2553,7 @@ mdevtest: # Testing for a release # -releasetest: testfixture.exe fuzztest +releasetest: testfixture.exe testfixture.exe $(TOP)\test\testrunner.tcl release diff --git a/manifest b/manifest index c35db0c838..17eafff732 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C The\sNOT\sNULL\sstrength\sreduction\soptimization\sfrom\s[de9c86c9e4cdb34f]\sshould\nbe\sapplied\sto\sthe\sWHERE\sclause\sonly.\s\sOtherwise,\sthe\soperand\sof\sthe\sIS\sNULL\nor\sIS\sNOT\sNULL\soperator\smight\sbe\sa\sreference\sto\sa\sbare\scolumn\sof\san\naggregate\stable,\sand\swe\scan't\stell\sif\sit\sis\sNULL\sor\snot\sbased\sonly\son\sits\nNOT\sNULL\sattribute.\s\s[forum:/forumpost/440f2a2f17|Forum\spost\s440f2a2f17]. -D 2024-03-08T21:37:18.921 +C Fuzzcheck\sis\srun\sautomatically\sby\stestrunner.tcl,\sso\sthere\sis\sno\sneed\sto\ninclude\sfuzzcheck\sas\sa\sseparate\sdependency\sfor\sthe\sreleasetest\starget\sin\nthe\sMSVC\smakefile. +D 2024-03-09T13:31:10.052 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in ca8b906b1c3285fc32cff9978a5b827f99ae3d440077babf32c257a92a2ba11c F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 72c8436ee7528cb78f7318230548aab145ef05d15a8feed0f3cb251a26384403 +F Makefile.msc 7d88d6a654d86e6a1bede090f67d633d0a57c73e591d772fce8e15bfb07147f8 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 F VERSION c84541c6a9e8426462176fbb1f9ecb5cfd7d1bb56228053ff7eeba8841673eb6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d401358329f5a70f9a0b9b033609a4db2af89b83c6b40242be0c76f3d6474def -R 05ce52a0a931825416b225aa397af1ac +P 51704feae224eff601db5607f8651da11b3c2ed8a58ffe5b6ee8260cab50695b +R 66041f681c588cd6eeb93d190f070a45 U drh -Z ce9603354c09773b286e10e1291765af +Z a7ed925f686a031dca2d1e814c8b92d8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8202619d3e..0f2473c5c0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -51704feae224eff601db5607f8651da11b3c2ed8a58ffe5b6ee8260cab50695b \ No newline at end of file +76629b2bff01df3d42eef2e93d626c291a2f129bd923498941465e5bca74e9f1 \ No newline at end of file From 5007833f5f82d33c95f44c65fc46221de1c5950f Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 9 Mar 2024 18:41:40 +0000 Subject: [PATCH 0196/1030] Fix the .expert command in the shell so that it does not leak memory if not followed by SQL and so that it works with reverse_unordered_selects. FossilOrigin-Name: 7ead022edaf7a0cd6a8976a1261246084975c9a5be5c893f6c751bb5f963ac0f --- ext/expert/sqlite3expert.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 5 +++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ext/expert/sqlite3expert.c b/ext/expert/sqlite3expert.c index 33d62226f0..276c2cc9fe 100644 --- a/ext/expert/sqlite3expert.c +++ b/ext/expert/sqlite3expert.c @@ -1948,7 +1948,7 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){ sqlite3_stmt *pSql = 0; rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'" - " AND sql NOT LIKE 'CREATE VIRTUAL %%'" + " AND sql NOT LIKE 'CREATE VIRTUAL %%' ORDER BY rowid" ); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ const char *zSql = (const char*)sqlite3_column_text(pSql, 0); diff --git a/manifest b/manifest index 17eafff732..8e74d529af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fuzzcheck\sis\srun\sautomatically\sby\stestrunner.tcl,\sso\sthere\sis\sno\sneed\sto\ninclude\sfuzzcheck\sas\sa\sseparate\sdependency\sfor\sthe\sreleasetest\starget\sin\nthe\sMSVC\smakefile. -D 2024-03-09T13:31:10.052 +C Fix\sthe\s.expert\scommand\sin\sthe\sshell\sso\sthat\sit\sdoes\snot\sleak\smemory\sif\snot\nfollowed\sby\sSQL\sand\sso\sthat\sit\sworks\swith\sreverse_unordered_selects. +D 2024-03-09T18:41:40.779 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -58,7 +58,7 @@ F ext/consio/console_io.h 0548b83d7c4b7270ad544a67f2bb90cebc519637fa39b1838df474 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 F ext/expert/expert1.test 0dd5cb096d66bed593e33053a3b364f6ef52ed72064bf5cf298364636dbf3cd6 -F ext/expert/sqlite3expert.c 90446bb1183429308c68ceb23e00cb8252f43b8886cf5efa3fc7e833b5fa24c8 +F ext/expert/sqlite3expert.c c8cea5ff15fbe792cccc4992a9b40b706411c41d32611f617897fecac6ff06a4 F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c7cc3bf59ee @@ -751,7 +751,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in 78bbd861cd0128aed67c0136561572ebcf11649be6cea86bee8491576d5958d0 +F src/shell.c.in 74a51fcae1bd945bcc818b6273a901f204410f4e8d2648221352a486ba2fe5ea F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 51704feae224eff601db5607f8651da11b3c2ed8a58ffe5b6ee8260cab50695b -R 66041f681c588cd6eeb93d190f070a45 +P 76629b2bff01df3d42eef2e93d626c291a2f129bd923498941465e5bca74e9f1 +R d4c5b88cb6e2dcca46b9c5560f050fe6 U drh -Z a7ed925f686a031dca2d1e814c8b92d8 +Z b901e762e961c86b4b7445204eab052b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0f2473c5c0..bb9cddfbd6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76629b2bff01df3d42eef2e93d626c291a2f129bd923498941465e5bca74e9f1 \ No newline at end of file +7ead022edaf7a0cd6a8976a1261246084975c9a5be5c893f6c751bb5f963ac0f \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 1d7f8df450..73161cf646 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -12772,6 +12772,11 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ #ifndef SQLITE_SHELL_FIDDLE /* In WASM mode we have to leave the db state in place so that ** client code can "push" SQL into it after this call returns. */ +#ifndef SQLITE_OMIT_VIRTUALTABLE + if( data.expert.pExpert ){ + expertFinish(&data, 1, 0); + } +#endif free(azCmd); set_table_name(&data, 0); if( data.db ){ From bf030d53b14bc38fbdc745636ef8dffdd57a1fa0 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 11 Mar 2024 09:32:38 +0000 Subject: [PATCH 0197/1030] Add delete-before-open=1 URI flag to the 'opfs' VFS to tell it to xDelete the db file before opening it, primarily to enable users to work around a corrupt db without having to reach into OPFS-specific APIs to remove the db file. FossilOrigin-Name: e83f9788636f7f9bcca7d2a09620c13ab4eb83436d5b2946a827e48addf0267d --- ext/wasm/api/sqlite3-opfs-async-proxy.js | 11 ++++++++ ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 18 ++++++++++-- ext/wasm/tester1.c-pp.js | 36 ++++++++++++++---------- manifest | 21 ++++++++------ manifest.uuid | 2 +- 5 files changed, 60 insertions(+), 28 deletions(-) diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index cafd296c61..58b8bcb233 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -562,6 +562,17 @@ const installAsyncProxy = function(self){ wTimeEnd(); return; } + if( state.opfsFlags.OPFS_UNLINK_BEFORE_OPEN & opfsFlags ){ + //log("async proxy opfsFlags =",opfsFlags); + try{ + await hDir.removeEntry(filenamePart); + //log("Unlinked",filename,hDir,filenamePart); + } + catch(e){ + /* ignoring */ + //warn("Ignoring failed Unlink of",filename,":",e); + } + } const hFile = await hDir.getFileHandle(filenamePart, {create}); wTimeEnd(); const fh = Object.assign(Object.create(null),{ diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index f7fd951a40..65e39e5b5e 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -423,10 +423,18 @@ const installOpfsVfs = function callee(options){ }); state.opfsFlags = Object.assign(Object.create(null),{ /** - Flag for use with xOpen(). "opfs-unlock-asap=1" enables - this. See defaultUnlockAsap, below. + Flag for use with xOpen(). URI flag "opfs-unlock-asap=1" + enables this. See defaultUnlockAsap, below. */ OPFS_UNLOCK_ASAP: 0x01, + /** + Flag for use with xOpen(). URI flag "delete-before-open=1" + tells the VFS to delete the db file before attempting to open + it. This can be used, e.g., to replace a db which has been + corrupted (without forcing us to expose a delete/unlink() + function in the public API). + */ + OPFS_UNLINK_BEFORE_OPEN: 0x02, /** If true, any async routine which implicitly acquires a sync access handle (i.e. an OPFS lock) will release that locks at @@ -875,13 +883,17 @@ const installOpfsVfs = function callee(options){ let opfsFlags = 0; if(0===zName){ zName = randomFilename(); - }else if('number'===typeof zName){ + }else if(wasm.isPtr(zName)){ if(capi.sqlite3_uri_boolean(zName, "opfs-unlock-asap", 0)){ /* -----------------------^^^^^ MUST pass the untranslated C-string here. */ opfsFlags |= state.opfsFlags.OPFS_UNLOCK_ASAP; } + if(capi.sqlite3_uri_boolean(zName, "delete-before-open", 0)){ + opfsFlags |= state.opfsFlags.OPFS_UNLINK_BEFORE_OPEN; + } zName = wasm.cstrToJs(zName); + //warn("xOpen zName =",zName, "opfsFlags =",opfsFlags); } const fh = Object.create(null); fh.fid = pFile; diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index f8a0225234..fdde986355 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2888,18 +2888,17 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .t({ name: 'OPFS db sanity checks', test: async function(sqlite3){ + T.assert(capi.sqlite3_vfs_find('opfs')); + const opfs = sqlite3.opfs; const filename = this.opfsDbFile = '/dir/sqlite3-tester1.db'; - const pVfs = this.opfsVfs = capi.sqlite3_vfs_find('opfs'); - T.assert(pVfs); - const unlink = this.opfsUnlink = - (fn=filename)=>{sqlite3.util.sqlite3__wasm_vfs_unlink(pVfs,fn)}; - unlink(); - let db = new sqlite3.oo1.OpfsDb(filename); + const fileUri = 'file://'+filename+'?delete-before-open=1'; + const initSql = [ + 'create table p(a);', + 'insert into p(a) values(1),(2),(3)' + ]; + let db = new sqlite3.oo1.OpfsDb(fileUri); try { - db.exec([ - 'create table p(a);', - 'insert into p(a) values(1),(2),(3)' - ]); + db.exec(initSql); T.assert(3 === db.selectValue('select count(*) from p')); db.close(); db = new sqlite3.oo1.OpfsDb(filename); @@ -2911,7 +2910,14 @@ globalThis.sqlite3InitModule = sqlite3InitModule; && 0===this.opfsDbExport.byteLength % 512); }finally{ db.close(); - unlink(); + } + T.assert(await opfs.entryExists(filename)); + try { + db = new sqlite3.oo1.OpfsDb(fileUri); + db.exec(initSql) /* will throw if delete-before-open did not work */; + T.assert(3 === db.selectValue('select count(*) from p')); + }finally{ + if(db) db.close(); } } }/*OPFS db sanity checks*/) @@ -2919,15 +2925,17 @@ globalThis.sqlite3InitModule = sqlite3InitModule; name: 'OPFS import', test: async function(sqlite3){ let db; + const filename = this.opfsDbFile; try { const exp = this.opfsDbExport; - const filename = this.opfsDbFile; delete this.opfsDbExport; this.opfsImportSize = await sqlite3.oo1.OpfsDb.importDb(filename, exp); db = new sqlite3.oo1.OpfsDb(this.opfsDbFile); T.assert(6 === db.selectValue('select count(*) from p')). assert( this.opfsImportSize == exp.byteLength ); db.close(); + const unlink = this.opfsUnlink = + (fn=filename)=>sqlite3.util.sqlite3__wasm_vfs_unlink("opfs",fn); this.opfsUnlink(filename); T.assert(!(await sqlite3.opfs.entryExists(filename))); // Try again with a function as an input source: @@ -2954,11 +2962,9 @@ globalThis.sqlite3InitModule = sqlite3InitModule; name: '(Internal-use) OPFS utility APIs', test: async function(sqlite3){ const filename = this.opfsDbFile; - const pVfs = this.opfsVfs; const unlink = this.opfsUnlink; - T.assert(filename && pVfs && !!unlink); + T.assert(filename && !!unlink); delete this.opfsDbFile; - delete this.opfsVfs; delete this.opfsUnlink; /************************************************************** ATTENTION CLIENT-SIDE USERS: sqlite3.opfs is NOT intended diff --git a/manifest b/manifest index 8e74d529af..a08f5bc55d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s.expert\scommand\sin\sthe\sshell\sso\sthat\sit\sdoes\snot\sleak\smemory\sif\snot\nfollowed\sby\sSQL\sand\sso\sthat\sit\sworks\swith\sreverse_unordered_selects. -D 2024-03-09T18:41:40.779 +C Add\sdelete-before-open=1\sURI\sflag\sto\sthe\s'opfs'\sVFS\sto\stell\sit\sto\sxDelete\sthe\sdb\sfile\sbefore\sopening\sit,\sprimarily\sto\senable\susers\sto\swork\saround\sa\scorrupt\sdb\swithout\shaving\sto\sreach\sinto\sOPFS-specific\sAPIs\sto\sremove\sthe\sdb\sfile. +D 2024-03-11T09:32:38.668 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -610,10 +610,10 @@ F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 -F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 +F ext/wasm/api/sqlite3-opfs-async-proxy.js b4c7ce9d7f7957f243d0fbd5b6e28bac80cd3c1b738374cd0c96d89df8f2f316 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aaedc1bb45489b8365bff7e955a83a8d42a -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js fe427645e1499618f5fa7bc670af850577d8bcc132df982078690c9bf8400baa +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js fb12aa55667109cfd76b5f645c4a4aec1a8ed9af59d62e05604b39e6390f54aa F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bd89edfe42a4d7122a6d6d405c5423cf00aabba1f76f6ea8e2dba9c628ddd91a @@ -662,7 +662,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 7c51d19f3644904156a154ddedd7024539ffba1a4e2df5e1efe10333e5b91b8f +F ext/wasm/tester1.c-pp.js 18331ec28d7e63c8e262a9872a8da3964d37b7ac22eabe0016af93f3c6f74cc4 F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2177,8 +2177,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 76629b2bff01df3d42eef2e93d626c291a2f129bd923498941465e5bca74e9f1 -R d4c5b88cb6e2dcca46b9c5560f050fe6 -U drh -Z b901e762e961c86b4b7445204eab052b +P 7ead022edaf7a0cd6a8976a1261246084975c9a5be5c893f6c751bb5f963ac0f +R 9e249fa0727bf1c60716395bdc490ae1 +T *branch * opfs-delete-before-open +T *sym-opfs-delete-before-open * +T -sym-trunk * Cancelled\sby\sbranch. +U stephan +Z f66cad865afa3b804834b14eccf1a085 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bb9cddfbd6..82d8c76fd0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7ead022edaf7a0cd6a8976a1261246084975c9a5be5c893f6c751bb5f963ac0f \ No newline at end of file +e83f9788636f7f9bcca7d2a09620c13ab4eb83436d5b2946a827e48addf0267d \ No newline at end of file From 289507d78bd98f08ce2fae592ff9fb1d234753f3 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 11 Mar 2024 09:39:52 +0000 Subject: [PATCH 0198/1030] Add more docs for the OPFS delete-before-open feature. FossilOrigin-Name: cb8d9c269c01f78f09069a2361e15087d9aeac63e9f1fd63fbd96b951384e9aa --- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 7 +++++++ manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index 65e39e5b5e..4c654c3351 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -433,6 +433,13 @@ const installOpfsVfs = function callee(options){ it. This can be used, e.g., to replace a db which has been corrupted (without forcing us to expose a delete/unlink() function in the public API). + + Failure to unlink the file is ignored but may lead to + downstream errors. An unlink can fail if, e.g., another tab + has the handle open. + + It goes without saying that deleting a file out from under another + instance results in Undefined Behavior. */ OPFS_UNLINK_BEFORE_OPEN: 0x02, /** diff --git a/manifest b/manifest index b49a60d948..b43b4c140b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sdelete-before-open=1\sURI\sflag\sto\sthe\s'opfs'\sVFS\sto\stell\sit\sto\sxDelete\sthe\sdb\sfile\sbefore\sopening\sit,\sprimarily\sto\senable\susers\sto\swork\saround\sa\scorrupt\sdb\swithout\shaving\sto\sreach\sinto\sOPFS-specific\sAPIs\sto\sremove\sthe\sdb\sfile. -D 2024-03-11T09:34:38.171 +C Add\smore\sdocs\sfor\sthe\sOPFS\sdelete-before-open\sfeature. +D 2024-03-11T09:39:52.643 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -613,7 +613,7 @@ F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d299 F ext/wasm/api/sqlite3-opfs-async-proxy.js b4c7ce9d7f7957f243d0fbd5b6e28bac80cd3c1b738374cd0c96d89df8f2f316 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aaedc1bb45489b8365bff7e955a83a8d42a -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js fb12aa55667109cfd76b5f645c4a4aec1a8ed9af59d62e05604b39e6390f54aa +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bd89edfe42a4d7122a6d6d405c5423cf00aabba1f76f6ea8e2dba9c628ddd91a @@ -2177,9 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7ead022edaf7a0cd6a8976a1261246084975c9a5be5c893f6c751bb5f963ac0f e83f9788636f7f9bcca7d2a09620c13ab4eb83436d5b2946a827e48addf0267d -R 9e249fa0727bf1c60716395bdc490ae1 -T +closed e83f9788636f7f9bcca7d2a09620c13ab4eb83436d5b2946a827e48addf0267d Closed\sby\sintegrate-merge. +P e87cf0d7700d33a439c91725460fbfe3a1765b48f71b4d73c38cadf6c166e0bd +R 86fc5680f4ee4960f4c1dcde68c7d5ad U stephan -Z e48b52f183c07790d9437c2d350f2700 +Z ee95146c516bc7ecdb021be98ac7e603 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 091241ce53..5f9e9ae6f3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e87cf0d7700d33a439c91725460fbfe3a1765b48f71b4d73c38cadf6c166e0bd \ No newline at end of file +cb8d9c269c01f78f09069a2361e15087d9aeac63e9f1fd63fbd96b951384e9aa \ No newline at end of file From 5dfff386e53a0ec1acd9854f676f9c2dda0cf25e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 11 Mar 2024 11:24:59 +0000 Subject: [PATCH 0199/1030] Fix the ".import" command in the CLI so that it works correctly with tables that contain computed columns. [forum:/forumpost/ca014d7358|forum post ca014d7358]. FossilOrigin-Name: 95a9c88b258f18ac671a4c712603931167cc8bd0b86e41481b200c08043338b5 --- manifest | 16 +++++----- manifest.uuid | 2 +- src/shell.c.in | 78 ++++++++++++++++++++++++++++-------------------- test/shell5.test | 14 +++++++++ 4 files changed, 68 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index b43b4c140b..49e6d916e1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smore\sdocs\sfor\sthe\sOPFS\sdelete-before-open\sfeature. -D 2024-03-11T09:39:52.643 +C Fix\sthe\s".import"\scommand\sin\sthe\sCLI\sso\sthat\sit\sworks\scorrectly\swith\stables\nthat\scontain\scomputed\scolumns.\n[forum:/forumpost/ca014d7358|forum\spost\sca014d7358]. +D 2024-03-11T11:24:59.268 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -751,7 +751,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 -F src/shell.c.in 74a51fcae1bd945bcc818b6273a901f204410f4e8d2648221352a486ba2fe5ea +F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8a F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -1604,7 +1604,7 @@ F test/shell1.test c7127a5e780ffc9e14c476773127fdf292c6db226529c44c1676f37b37931 F test/shell2.test 35226c070a8c7f64fd016dfac2a0db2a40f709b3131f61daacd9dad61536c9cb F test/shell3.test 91febeac0412812bf6370abb8ed72700e32bf8f9878849414518f662dfd55e8a F test/shell4.test 947029e5a9efae9054d424b309fc0311439c0c3a0866ebfa3b8a771120708220 -F test/shell5.test c8b6c54f26ec537f8558273d7ed293ca3725ef42e6b12b8f151718628bd1473b +F test/shell5.test 263bfd6a49049295277e3f5bdc221390dc5e72f39954b23d43204ed81993304f F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f F test/shell8.test 3fd093d481aaa94dc77fb73f1044c1f19c7efe3477a395cc4f7450133bc54915 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e87cf0d7700d33a439c91725460fbfe3a1765b48f71b4d73c38cadf6c166e0bd -R 86fc5680f4ee4960f4c1dcde68c7d5ad -U stephan -Z ee95146c516bc7ecdb021be98ac7e603 +P cb8d9c269c01f78f09069a2361e15087d9aeac63e9f1fd63fbd96b951384e9aa +R 9bba8f8b4bc3bf41627766fe1aa44b9c +U drh +Z 1d2e3bf230fd6cd6fbc6ff6c84cfd8fb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5f9e9ae6f3..c57a5b98bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cb8d9c269c01f78f09069a2361e15087d9aeac63e9f1fd63fbd96b951384e9aa \ No newline at end of file +95a9c88b258f18ac671a4c712603931167cc8bd0b86e41481b200c08043338b5 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 73161cf646..9fdf909523 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8778,16 +8778,15 @@ static int do_meta_command(char *zLine, ShellState *p){ #ifndef SQLITE_SHELL_FIDDLE if( c=='i' && cli_strncmp(azArg[0], "import", n)==0 ){ char *zTable = 0; /* Insert data into this table */ - char *zSchema = 0; /* within this schema (may default to "main") */ + char *zSchema = 0; /* Schema of zTable */ char *zFile = 0; /* Name of file to extra content from */ sqlite3_stmt *pStmt = NULL; /* A statement */ int nCol; /* Number of columns in the table */ - int nByte; /* Number of bytes in an SQL string */ + i64 nByte; /* Number of bytes in an SQL string */ int i, j; /* Loop counters */ int needCommit; /* True to COMMIT or ROLLBACK at end */ int nSep; /* Number of bytes in p->colSeparator[] */ - char *zSql; /* An SQL statement */ - char *zFullTabName; /* Table name with schema if applicable */ + char *zSql = 0; /* An SQL statement */ ImportCtx sCtx; /* Reader context */ char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */ int eVerbose = 0; /* Larger for more console output */ @@ -8921,24 +8920,14 @@ static int do_meta_command(char *zLine, ShellState *p){ while( (nSkip--)>0 ){ while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){} } - if( zSchema!=0 ){ - zFullTabName = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable); - }else{ - zFullTabName = sqlite3_mprintf("\"%w\"", zTable); - } - zSql = sqlite3_mprintf("SELECT * FROM %s", zFullTabName); - if( zSql==0 || zFullTabName==0 ){ - import_cleanup(&sCtx); - shell_out_of_memory(); - } - nByte = strlen30(zSql); - rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */ - if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){ + if( sqlite3_table_column_metadata(p->db, zSchema, zTable,0,0,0,0,0,0) ){ + /* Table does not exist. Create it. */ sqlite3 *dbCols = 0; char *zRenames = 0; char *zColDefs; - zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName); + zCreate = sqlite3_mprintf("CREATE TABLE \"%w\".\"%w\"", + zSchema ? zSchema : "main", zTable); while( xRead(&sCtx) ){ zAutoColumn(sCtx.z, &dbCols, 0); if( sCtx.cTerm!=sCtx.cColSep ) break; @@ -8953,34 +8942,50 @@ static int do_meta_command(char *zLine, ShellState *p){ assert(dbCols==0); if( zColDefs==0 ){ eputf("%s: empty file\n", sCtx.zFile); - import_fail: - sqlite3_free(zCreate); - sqlite3_free(zSql); - sqlite3_free(zFullTabName); import_cleanup(&sCtx); rc = 1; goto meta_command_exit; } zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs); + if( zCreate==0 ){ + import_cleanup(&sCtx); + shell_out_of_memory(); + } if( eVerbose>=1 ){ oputf("%s\n", zCreate); } rc = sqlite3_exec(p->db, zCreate, 0, 0, 0); + sqlite3_free(zCreate); + zCreate = 0; if( rc ){ eputf("%s failed:\n%s\n", zCreate, sqlite3_errmsg(p->db)); - goto import_fail; + import_cleanup(&sCtx); + rc = 1; + goto meta_command_exit; } - sqlite3_free(zCreate); - zCreate = 0; - rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); } + zSql = sqlite3_mprintf("SELECT count(*) FROM pragma_table_info(%Q,%Q);", + zTable, zSchema); + if( zSql==0 ){ + import_cleanup(&sCtx); + shell_out_of_memory(); + } + nByte = strlen(zSql); + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + zSql = 0; if( rc ){ if (pStmt) sqlite3_finalize(pStmt); eputf("Error: %s\n", sqlite3_errmsg(p->db)); - goto import_fail; + import_cleanup(&sCtx); + rc = 1; + goto meta_command_exit; + } + if( sqlite3_step(pStmt)==SQLITE_ROW ){ + nCol = sqlite3_column_int(pStmt, 0); + }else{ + nCol = 0; } - sqlite3_free(zSql); - nCol = sqlite3_column_count(pStmt); sqlite3_finalize(pStmt); pStmt = 0; if( nCol==0 ) return 0; /* no columns, no error */ @@ -8989,7 +8994,12 @@ static int do_meta_command(char *zLine, ShellState *p){ import_cleanup(&sCtx); shell_out_of_memory(); } - sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zFullTabName); + if( zSchema ){ + sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\".\"%w\" VALUES(?", + zSchema, zTable); + }else{ + sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable); + } j = strlen30(zSql); for(i=1; idb, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + zSql = 0; if( rc ){ eputf("Error: %s\n", sqlite3_errmsg(p->db)); if (pStmt) sqlite3_finalize(pStmt); - goto import_fail; + import_cleanup(&sCtx); + rc = 1; + goto meta_command_exit; } - sqlite3_free(zSql); - sqlite3_free(zFullTabName); needCommit = sqlite3_get_autocommit(p->db); if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0); do{ diff --git a/test/shell5.test b/test/shell5.test index 39018a0ce9..20f2ba219d 100644 --- a/test/shell5.test +++ b/test/shell5.test @@ -570,4 +570,18 @@ SELECT * FROM t1;} } {0 { 1 = あい 2 = うえお}} +# 2024-03-11 https://sqlite.org/forum/forumpost/ca014d7358 +# Import into a table that contains computed columns. +# +do_test shell5-7.1 { + set out [open shell5.csv w] + fconfigure $out -translation lf + puts $out {aaa|bbb} + close $out + forcedelete test.db + catchcmd :memory: {CREATE TABLE t1(a TEXT, b TEXT, c AS (a||b)); +.import shell5.csv t1 +SELECT * FROM t1;} +} {0 aaa|bbb|aaabbb} + finish_test From 815e055bff42d57f49cf46cc70771cdcf5930d83 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Mar 2024 17:27:19 +0000 Subject: [PATCH 0200/1030] Attempt to reduce the memory used by VALUES clauses in as many statements as possible, not just INSERT. This branch still has problems. FossilOrigin-Name: 17d1f7cfabc7593d0725051b0c7c9619a23a482265f30f15ab9493fef5caeeb0 --- manifest | 29 +++-- manifest.uuid | 2 +- src/expr.c | 1 + src/insert.c | 137 +++++++++++++++++++--- src/parse.y | 27 ++--- src/select.c | 2 +- src/sqliteInt.h | 4 + src/where.c | 1 + test/values.test | 256 ++++++++++++++++++++++++++++++++++++++++++ test/valuesfault.test | 37 ++++++ 10 files changed, 451 insertions(+), 45 deletions(-) create mode 100644 test/values.test create mode 100644 test/valuesfault.test diff --git a/manifest b/manifest index 49e6d916e1..afde134bd1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s".import"\scommand\sin\sthe\sCLI\sso\sthat\sit\sworks\scorrectly\swith\stables\nthat\scontain\scomputed\scolumns.\n[forum:/forumpost/ca014d7358|forum\spost\sca014d7358]. -D 2024-03-11T11:24:59.268 +C Attempt\sto\sreduce\sthe\smemory\sused\sby\sVALUES\sclauses\sin\sas\smany\sstatements\sas\spossible,\snot\sjust\sINSERT.\sThis\sbranch\sstill\shas\sproblems. +D 2024-03-11T17:27:19.668 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 05516e8b7d7d22f98160a0360fde69edce3304a430600567ed33e66d588ca59b +F src/expr.c 7d0280860f8683fa1e81202304a5107f493fe9bd52be6590d0d0d6c3564c7a07 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c eb33ea46dcab93e90f112fced343aaf41f59cbd2e951d5066f1f9302be1c2f34 +F src/insert.c 2c34cf51e9d8c00498ba68b7f130e448038bb31f624c9c1ca80fa8e3237b51fb F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -739,7 +739,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 6209f01e8e7495379571454744fa82a5cfc2e7eeb89e46dee3f410d73ea6252d +F src/parse.y 3d022ba4c68bf8c7c4c40b3e364d7a8226c4089fc9ff7a3a95f969f8f1bec959 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -750,12 +750,12 @@ F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1 +F src/select.c 2a12c6ed8131db7c49b6f8141c3420cab825cfc6bd222d347fa1382f36b174b7 F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8a F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 6123ce6ca6a1ef351c3b87189e92c92042728f16c088de56b9b5bc2552d0ae33 +F src/sqliteInt.h b3ac44ca090011813d5a07f63be59785a4558e74052eb94b686f52eef1af684b F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 33eaaeef3aef10c2b9e82096e70a174d6636e35cb0b180321b8ddf804590e5cd +F src/where.c 8bb70b3caadcf35073f8857ecd83d33d97bf6aa03de3342287037bae43c6f364 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 6ebd90b553f4bb5c7df5a4b2f39b6a7c81a67484353827cdd2048f2514ec6f30 @@ -1921,6 +1921,8 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb +F test/values.test 8438dea6826738291ff2019993d62e1eae7a3efb66ea8312fa9ac9bfaf0f95cb +F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test d4c4281e1679245829db35597817282f60dc513fc39cc5439078f009bd118487 @@ -2177,8 +2179,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cb8d9c269c01f78f09069a2361e15087d9aeac63e9f1fd63fbd96b951384e9aa -R 9bba8f8b4bc3bf41627766fe1aa44b9c -U drh -Z 1d2e3bf230fd6cd6fbc6ff6c84cfd8fb +P 95a9c88b258f18ac671a4c712603931167cc8bd0b86e41481b200c08043338b5 +R 62b6db11e5c879766b23978dd0871f55 +T *branch * exp-values-clause2 +T *sym-exp-values-clause2 * +T -sym-trunk * +U dan +Z 521a450017e9a427470d7f09cc068c5e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c57a5b98bf..633c59c43c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95a9c88b258f18ac671a4c712603931167cc8bd0b86e41481b200c08043338b5 \ No newline at end of file +17d1f7cfabc7593d0725051b0c7c9619a23a482265f30f15ab9493fef5caeeb0 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 6640d1907d..e4bfa995d7 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1869,6 +1869,7 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int flags){ pNewItem->iCursor = pOldItem->iCursor; pNewItem->addrFillSub = pOldItem->addrFillSub; pNewItem->regReturn = pOldItem->regReturn; + pNewItem->regResult = pOldItem->regResult; if( pNewItem->fg.isIndexedBy ){ pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy); } diff --git a/src/insert.c b/src/insert.c index 095298b90c..7b253e9262 100644 --- a/src/insert.c +++ b/src/insert.c @@ -577,6 +577,104 @@ void sqlite3AutoincrementEnd(Parse *pParse){ # define autoIncStep(A,B,C) #endif /* SQLITE_OMIT_AUTOINCREMENT */ +void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ + if( pVal->pSrc->nSrc>0 ){ + SrcItem *pItem = &pVal->pSrc->a[0]; + sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->regReturn); + sqlite3VdbeJumpHere(pParse->pVdbe, pItem->addrFillSub - 1); + } +} + +static int multiValueIsConstant(ExprList *pRow){ + int ii; + for(ii=0; iinExpr; ii++){ + if( 0==sqlite3ExprIsConstant(pRow->a[ii].pExpr) ) return 0; + } + return 1; +} + +Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ + SrcItem *p; + SelectDest dest; + Select *pSelect = 0; + + if( pParse->db->init.busy + || pParse->pNewTrigger + || pParse->bHasWith + || multiValueIsConstant(pRow)==0 + || pLeft->pPrior + ){ + int f = SF_Values | SF_MultiValue; + if( pLeft->pPrior || pLeft->pSrc->nSrc ){ + sqlite3MultiValuesEnd(pParse, pLeft); + f = SF_Values; + } + /* This VALUES clause is part of a VIEW or some other schema item. In + ** this case the co-routine cannot be coded immediately. */ + pSelect = sqlite3SelectNew(pParse,pRow,0,0,0,0,0,f,0); + pLeft->selFlags &= ~SF_MultiValue; + if( pSelect ){ + pSelect->op = TK_ALL; + pSelect->pPrior = pLeft; + pLeft = pSelect; + } + }else{ + + if( pLeft->pSrc->nSrc==0 ){ + /* Co-routine has not yet been started. */ + Vdbe *v = sqlite3GetVdbe(pParse); + Select *pRet; + + if( v==0 ) return pLeft; + pRet = sqlite3SelectNew(pParse, 0, 0, 0, 0, 0, 0, 0, 0); + if( pRet==0 ) return pLeft; + p = &pRet->pSrc->a[0]; + pRet->pSrc->nSrc = 1; + + p->pSelect = pLeft; + p->fg.viaCoroutine = 1; + p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; + p->regReturn = ++pParse->nMem; + + sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub); + sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); + sqlite3Select(pParse, pLeft, &dest); + p->regResult = dest.iSdst; + assert( pParse->nErr || dest.iSdst>0 ); + + pLeft = pRet; + }else{ + p = &pLeft->pSrc->a[0]; + } + + if( pParse->nErr==0 ){ + pSelect = sqlite3SelectNew(pParse, pRow, 0, 0, 0, 0, 0, SF_Values, 0); + if( pSelect ){ + if( p->pSelect->pEList->nExpr!=pSelect->pEList->nExpr ){ + sqlite3SelectWrongNumTermsError(pParse, pSelect); + }else{ + sqlite3SelectPrep(pParse, pSelect, 0); +#ifndef SQLITE_OMIT_WINDOWFUNC + if( pSelect->pWin ){ + sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); + dest.iSdst = p->regResult; + dest.nSdst = pRow->nExpr; + dest.iSDParm = p->regReturn; + sqlite3Select(pParse, pSelect, &dest); + }else +#endif + { + sqlite3ExprCodeExprList(pParse, pSelect->pEList,p->regResult,0,0); + sqlite3VdbeAddOp1(pParse->pVdbe, OP_Yield, p->regReturn); + } + } + sqlite3SelectDelete(pParse->db, pSelect); + } + } + } + + return pLeft; +} /* Forward declaration */ static int xferOptimization( @@ -914,24 +1012,31 @@ void sqlite3Insert( /* Data is coming from a SELECT or from a multi-row VALUES clause. ** Generate a co-routine to run the SELECT. */ int regYield; /* Register holding co-routine entry-point */ - int addrTop; /* Top of the co-routine */ int rc; /* Result code */ - regYield = ++pParse->nMem; - addrTop = sqlite3VdbeCurrentAddr(v) + 1; - sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop); - sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield); - dest.iSdst = bIdListInOrder ? regData : 0; - dest.nSdst = pTab->nCol; - rc = sqlite3Select(pParse, pSelect, &dest); - regFromSelect = dest.iSdst; - assert( db->pParse==pParse ); - if( rc || pParse->nErr ) goto insert_cleanup; - assert( db->mallocFailed==0 ); - sqlite3VdbeEndCoroutine(v, regYield); - sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */ - assert( pSelect->pEList ); - nColumn = pSelect->pEList->nExpr; + if( pSelect->pSrc->nSrc==1 && pSelect->pSrc->a[0].fg.viaCoroutine ){ + SrcItem *pItem = &pSelect->pSrc->a[0]; + dest.iSDParm = regYield = pItem->regReturn; + regFromSelect = pItem->regResult; + nColumn = pItem->pSelect->pEList->nExpr; + }else{ + int addrTop; /* Top of the co-routine */ + regYield = ++pParse->nMem; + addrTop = sqlite3VdbeCurrentAddr(v) + 1; + sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop); + sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield); + dest.iSdst = bIdListInOrder ? regData : 0; + dest.nSdst = pTab->nCol; + rc = sqlite3Select(pParse, pSelect, &dest); + regFromSelect = dest.iSdst; + assert( db->pParse==pParse ); + if( rc || pParse->nErr ) goto insert_cleanup; + assert( db->mallocFailed==0 ); + sqlite3VdbeEndCoroutine(v, regYield); + sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */ + assert( pSelect->pEList ); + nColumn = pSelect->pEList->nExpr; + } /* Set useTempTable to TRUE if the result of the SELECT statement ** should be written into a temporary table (template 4). Set to diff --git a/src/parse.y b/src/parse.y index 37c9fa8bc9..515d512f2c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -562,9 +562,13 @@ cmd ::= select(X). { } %ifndef SQLITE_OMIT_CTE -select(A) ::= WITH wqlist(W) selectnowith(X). {A = attachWithToSelect(pParse,X,W);} -select(A) ::= WITH RECURSIVE wqlist(W) selectnowith(X). +select(A) ::= withkw wqlist(W) selectnowith(X). {A = attachWithToSelect(pParse,X,W);} +select(A) ::= withkw RECURSIVE wqlist(W) selectnowith(X). {A = attachWithToSelect(pParse,X,W);} + +withkw ::= WITH. { + pParse->bHasWith = 1; +} %endif /* SQLITE_OMIT_CTE */ select(A) ::= selectnowith(A). { Select *p = A; @@ -622,7 +626,9 @@ oneselect(A) ::= SELECT distinct(D) selcollist(W) from(X) where_opt(Y) %endif -oneselect(A) ::= values(A). +oneselect(A) ::= values(A). { + sqlite3MultiValuesEnd(pParse, A); +} %type values {Select*} %destructor values {sqlite3SelectDelete(pParse->db, $$);} @@ -630,16 +636,7 @@ values(A) ::= VALUES LP nexprlist(X) RP. { A = sqlite3SelectNew(pParse,X,0,0,0,0,0,SF_Values,0); } values(A) ::= values(A) COMMA LP nexprlist(Y) RP. { - Select *pRight, *pLeft = A; - pRight = sqlite3SelectNew(pParse,Y,0,0,0,0,0,SF_Values|SF_MultiValue,0); - if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; - if( pRight ){ - pRight->op = TK_ALL; - pRight->pPrior = pLeft; - A = pRight; - }else{ - A = pLeft; - } + A = sqlite3MultiValues(pParse, A, Y); } // The "distinct" nonterminal is true (1) if the DISTINCT keyword is @@ -1754,8 +1751,8 @@ anylist ::= anylist ANY. with ::= . %ifndef SQLITE_OMIT_CTE -with ::= WITH wqlist(W). { sqlite3WithPush(pParse, W, 1); } -with ::= WITH RECURSIVE wqlist(W). { sqlite3WithPush(pParse, W, 1); } +with ::= withkw wqlist(W). { sqlite3WithPush(pParse, W, 1); } +with ::= withkw RECURSIVE wqlist(W). { sqlite3WithPush(pParse, W, 1); } %type wqas {u8} wqas(A) ::= AS. {A = M10d_Any;} diff --git a/src/select.c b/src/select.c index 81e802d6e4..4158dd2fdc 100644 --- a/src/select.c +++ b/src/select.c @@ -7636,7 +7636,7 @@ int sqlite3Select( /* Generate code for all sub-queries in the FROM clause */ pSub = pItem->pSelect; - if( pSub==0 ) continue; + if( pSub==0 || pItem->addrFillSub!=0 ) continue; /* The code for a subquery should only be generated once. */ assert( pItem->addrFillSub==0 ); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index e11b5b3a4e..3913392712 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3812,6 +3812,7 @@ struct Parse { u8 disableLookaside; /* Number of times lookaside has been disabled */ u8 prepFlags; /* SQLITE_PREPARE_* flags */ u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */ + u8 bHasWith; /* True if statement contains WITH */ #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */ #endif @@ -4486,6 +4487,9 @@ struct Window { ** due to the SQLITE_SUBTYPE flag */ }; +Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow); +void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal); + #ifndef SQLITE_OMIT_WINDOWFUNC void sqlite3WindowDelete(sqlite3*, Window*); void sqlite3WindowUnlinkFromSelect(Window*); diff --git a/src/where.c b/src/where.c index 9850d22cc3..9abc8e30f6 100644 --- a/src/where.c +++ b/src/where.c @@ -6896,6 +6896,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ */ if( pTabItem->fg.viaCoroutine ){ testcase( pParse->db->mallocFailed ); + assert( pTabItem->regResult>=0 ); translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur, pTabItem->regResult, 0); continue; diff --git a/test/values.test b/test/values.test new file mode 100644 index 0000000000..66e29ef6f0 --- /dev/null +++ b/test/values.test @@ -0,0 +1,256 @@ +# 2024 March 3 +# +# 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. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix values + + +do_execsql_test 1.0 { + CREATE TABLE x1(a, b, c); +} + + +explain_i { + INSERT INTO x1(a, b, c) VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4); +} +do_execsql_test 1.1.1 { + INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4); +} +do_execsql_test 1.1.2 { + SELECT * FROM x1; +} { + 1 1 1 + 2 2 2 + 3 3 3 + 4 4 4 +} + +do_execsql_test 1.2.0 { + DELETE FROM x1 +} +do_execsql_test 1.2.1 { + INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3) UNION ALL SELECT 4, 4, 4; + SELECT * FROM x1; +} {1 1 1 2 2 2 3 3 3 4 4 4} + +sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 4 + +do_execsql_test 1.2.2 { + DELETE FROM x1; + INSERT INTO x1 + VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5) + UNION ALL SELECT 6, 6, 6; + SELECT * FROM x1; +} {1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6} + +do_execsql_test 1.2.3 { + DELETE FROM x1; + INSERT INTO x1 + VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4) + UNION ALL SELECT 6, 6, 6; + SELECT * FROM x1; +} {1 1 1 2 2 2 3 3 3 4 4 4 6 6 6} + +do_execsql_test 1.2.4 { + DELETE FROM x1; + INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3) UNION ALL SELECT 6, 6, 6; + SELECT * FROM x1; +} { + 1 1 1 + 2 2 2 + 3 3 3 + 6 6 6 +} + +set a 4 +set b 5 +set c 6 +do_execsql_test 1.2.5 { + DELETE FROM x1; + INSERT INTO x1 + VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), + (4, 4, $a), (5, 5, $b), (6, 6, $c) +} + +do_execsql_test 1.2.6 { + SELECT * FROM x1; +} { + 1 1 1 + 2 2 2 + 3 3 3 + 4 4 4 + 5 5 5 + 6 6 6 +} + +#------------------------------------------------------------------------- +# SQLITE_LIMIT_COMPOUND_SELECT set to 0. +# +reset_db + +do_execsql_test 2.0 { + CREATE TABLE x1(a, b, c); +} + +sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 3 + +do_catchsql_test 2.1.1 { + INSERT INTO x1 VALUES + (1, 1, 1), + (2, 2, 2), + (3, 3, 3), + (4, 4, 4), + (5, 5, 5), + (6, 6, 6), + (7, 7, 7), + (8, 8, 8), + (9, 9, 9), + (10, 10, 10, 10) +} {1 {all VALUES must have the same number of terms}} + +do_catchsql_test 2.1.2 { + INSERT INTO x1 VALUES + (1, 1, 1), + (2, 2, 2, 2), + (3, 3, 3), + (4, 4, 4), + (5, 5, 5), + (6, 6, 6), + (7, 7, 7), + (8, 8, 8), + (9, 9, 9), + (10, 10, 10) +} {1 {all VALUES must have the same number of terms}} + +sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 0 + +do_execsql_test 2.2 { + INSERT INTO x1 VALUES + (1, 1, 1), + (2, 2, 2), + (3, 3, 3), + (4, 4, 4), + (5, 5, 5), + (6, 6, 6), + (7, 7, 7), + (8, 8, 8), + (9, 9, 9), + (10, 10, 10) +} {} +do_execsql_test 2.3 { + INSERT INTO x1 VALUES + (1, 1, 1), + (2, 2, 2), + (3, 3, 3), + (4, 4, 4), + (5, 5, 5), + (6, 6, 6), + (7, 7, 7), + (8, 8, 8), + (9, 9, 9), + (10, 10, 10) + UNION ALL + SELECT 5, 12, 12 + ORDER BY 1 +} {} + +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 3.0 { + CREATE TABLE y1(x, y); +} + +do_execsql_test 3.1.1 { + DELETE FROM y1; + INSERT INTO y1 VALUES(1, 2), (3, 4), (row_number() OVER (), 5); +} +do_execsql_test 3.1.2 { + SELECT * FROM y1; +} {1 2 3 4 1 5} +do_execsql_test 3.2.1 { + DELETE FROM y1; + INSERT INTO y1 VALUES(1, 2), (3, 4), (row_number() OVER (), 6) + , (row_number() OVER (), 7) +} +do_execsql_test 3.1.2 { + SELECT * FROM y1; +} {1 2 3 4 1 6 1 7} + +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 4.0 { + CREATE TABLE x1(a PRIMARY KEY, b) WITHOUT ROWID; +} + +foreach {tn iLimit} {1 0 2 3} { + sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT $iLimit + + do_execsql_test 4.1.1 { + DELETE FROM x1; + INSERT INTO x1 VALUES + (1, 1), + (2, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d')) )) + } + do_execsql_test 4.1.2 { + SELECT * FROM x1 + } {1 1 2 a} + + do_execsql_test 4.2.1 { + DELETE FROM x1; + INSERT INTO x1 VALUES + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d')) )) + } + do_execsql_test 4.2.2 { + SELECT * FROM x1 + } {1 1 2 2 3 3 4 4 5 a} + + do_execsql_test 4.3.1 { + DELETE FROM x1; + INSERT INTO x1 VALUES + (1, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d'), ('e')) )) + } + do_execsql_test 4.3.2 { + SELECT * FROM x1 + } {1 a} +} + +#------------------------------------------------------------------------ +reset_db + +do_execsql_test 5.0 { + CREATE VIEW v1 AS VALUES(1, 2, 3), (4, 5, 6), (7, 8, 9); +} +do_execsql_test 5.1 { + SELECT * FROM v1 +} {1 2 3 4 5 6 7 8 9} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 6.0 { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(1), (2); +} + +do_execsql_test 6.1 { + SELECT ( VALUES( x ), ( x ) ) FROM t1; +} {1 2} + + +finish_test diff --git a/test/valuesfault.test b/test/valuesfault.test new file mode 100644 index 0000000000..bc5dddfb0e --- /dev/null +++ b/test/valuesfault.test @@ -0,0 +1,37 @@ +# 2024 March 3 +# +# 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. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix valuesfault +source $testdir/malloc_common.tcl + + +do_execsql_test 1.0 { + CREATE TABLE x1(a, b, c); +} +faultsim_save_and_close + +do_faultsim_test 1 -prep { + faultsim_restore_and_reopen + sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 2 +} -body { + execsql { + INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4); + } +} -test { + faultsim_test_result {0 {}} +} + + +finish_test From c6481e0289f18598985bba974e901a24e528fc2c Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 11 Mar 2024 18:21:02 +0000 Subject: [PATCH 0201/1030] Run shell*.test modules with "make mdevtest". FossilOrigin-Name: 76c471061809307c1922a9460f1ea37291ff5f4dc11a71af594351e875fdc8e3 --- Makefile.in | 4 ++-- Makefile.msc | 4 ++-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/testrunner.tcl | 11 ++++++++++- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Makefile.in b/Makefile.in index 321fb75278..e16fa94345 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1314,9 +1314,9 @@ testfixture$(TEXE): has_tclsh85 $(TESTFIXTURE_SRC) $(LTLINK) -DSQLITE_NO_SYNC=1 $(TEMP_STORE) $(TESTFIXTURE_FLAGS) \ -o $@ $(TESTFIXTURE_SRC) $(LIBTCL) $(TLIBS) -coretestprogs: $(TESTPROGS) +coretestprogs: testfixture$(BEXE) sqlite3$(BEXE) -testprogs: coretestprogs srcck1$(BEXE) fuzzcheck$(TEXE) sessionfuzz$(TEXE) +testprogs: $(TESTPROGS) srcck1$(BEXE) fuzzcheck$(TEXE) sessionfuzz$(TEXE) # A very detailed test running most or all test cases fulltest: alltest fuzztest diff --git a/Makefile.msc b/Makefile.msc index 31a9c57ebc..5257cee981 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2496,9 +2496,9 @@ extensiontest: testfixture.exe testloadext.dll tool-zip: testfixture.exe sqlite3.exe sqldiff.exe sqlite3_analyzer.exe $(TOP)\tool\mktoolzip.tcl .\testfixture.exe $(TOP)\tool\mktoolzip.tcl -coretestprogs: $(TESTPROGS) +coretestprogs: testfixture.exe sqlite3.exe -testprogs: coretestprogs srcck1.exe fuzzcheck.exe sessionfuzz.exe +testprogs: $(TESTPROGS) srcck1.exe fuzzcheck.exe sessionfuzz.exe fulltest: alltest fuzztest diff --git a/manifest b/manifest index 49e6d916e1..d8e6bebb99 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Fix\sthe\s".import"\scommand\sin\sthe\sCLI\sso\sthat\sit\sworks\scorrectly\swith\stables\nthat\scontain\scomputed\scolumns.\n[forum:/forumpost/ca014d7358|forum\spost\sca014d7358]. -D 2024-03-11T11:24:59.268 +C Run\sshell*.test\smodules\swith\s"make\smdevtest". +D 2024-03-11T18:21:02.927 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in ca8b906b1c3285fc32cff9978a5b827f99ae3d440077babf32c257a92a2ba11c +F Makefile.in 5f2389d2a3c44b56621bb5156a9cb6e2bef01f7ec14a19335b1559cf0474bdde F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 7d88d6a654d86e6a1bede090f67d633d0a57c73e591d772fce8e15bfb07147f8 +F Makefile.msc e64a52619310d3067f6c38f56eedd15918a82dade70954197d6da486ad99d7f4 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 F VERSION c84541c6a9e8426462176fbb1f9ecb5cfd7d1bb56228053ff7eeba8841673eb6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 8e2a5c7550b78d3283eee6103104ae2bcf56aa1df892dbd1608f27b93ebf4de8 +F test/testrunner.tcl 277bf6ed811b1f07796eedf8b5740ef521fc7fa99bd50faad9760a1fa53653b3 F test/testrunner_data.tcl 7ffd951527bbc614e723fd8d123b6834321878530696adecfdf6035100bac64e F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cb8d9c269c01f78f09069a2361e15087d9aeac63e9f1fd63fbd96b951384e9aa -R 9bba8f8b4bc3bf41627766fe1aa44b9c +P 95a9c88b258f18ac671a4c712603931167cc8bd0b86e41481b200c08043338b5 +R 29b12e6b8f2a6bc2a8ea9a08c15b926a U drh -Z 1d2e3bf230fd6cd6fbc6ff6c84cfd8fb +Z a3f33edbc2a09bf20230f9f2220bf336 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c57a5b98bf..d3cdb542bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95a9c88b258f18ac671a4c712603931167cc8bd0b86e41481b200c08043338b5 \ No newline at end of file +76c471061809307c1922a9460f1ea37291ff5f4dc11a71af594351e875fdc8e3 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 0c704daf21..b5bd54e2b1 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -681,13 +681,22 @@ proc add_build_job {buildname target} { set dirname "[string tolower [string map {- _} $buildname]]_$target" set dirname "testrunner_bld_$dirname" + switch $target { + testfixture - + testfixture.exe { + set mktarget coretestprogs + } + default { + set mktarget $target + } + } set id [add_job \ -displaytype bld \ -displayname "Build $buildname ($target)" \ -dirname $dirname \ -build $buildname \ - -cmd "$TRG(makecmd) $target" \ + -cmd "$TRG(makecmd) $mktarget" \ -priority 3 ] From 2dbf276e93ecbeb3c067806c8c823cc4da87c2fc Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Mar 2024 19:33:55 +0000 Subject: [PATCH 0202/1030] Update mdevtest and sdevtest to do shell builds in parallel. And only if one or more of the tcl scripts run requires it. FossilOrigin-Name: 6eae4547d4d50c798d1f05eaa1da02f4682d261dbd64e94748179923839024e6 --- ext/expert/expert1.test | 1 + manifest | 38 ++++++++++++------------ manifest.uuid | 2 +- test/avfs.test | 1 + test/recover.test | 1 + test/shell1.test | 1 + test/shell2.test | 1 + test/shell3.test | 1 + test/shell4.test | 1 + test/shell5.test | 1 + test/shell6.test | 1 + test/shell7.test | 1 + test/shell8.test | 1 + test/shell9.test | 1 + test/testrunner.tcl | 65 ++++++++++++++++++++++++++++++++--------- 15 files changed, 83 insertions(+), 34 deletions(-) diff --git a/ext/expert/expert1.test b/ext/expert/expert1.test index 453334234d..c456c30c52 100644 --- a/ext/expert/expert1.test +++ b/ext/expert/expert1.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # The focus of this file is testing the CLI shell tool. Specifically, # the ".recommend" command. diff --git a/manifest b/manifest index d8e6bebb99..ccb451459a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Run\sshell*.test\smodules\swith\s"make\smdevtest". -D 2024-03-11T18:21:02.927 +C Update\smdevtest\sand\ssdevtest\sto\sdo\sshell\sbuilds\sin\sparallel.\sAnd\sonly\sif\sone\sor\smore\sof\sthe\stcl\sscripts\srun\srequires\sit. +D 2024-03-11T19:33:55.704 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -57,7 +57,7 @@ F ext/consio/console_io.c f32b757c9ee7fdf68e7586bee306f8368759e7cd12febb2a683919 F ext/consio/console_io.h 0548b83d7c4b7270ad544a67f2bb90cebc519637fa39b1838df4744cf0d87646 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 -F ext/expert/expert1.test 0dd5cb096d66bed593e33053a3b364f6ef52ed72064bf5cf298364636dbf3cd6 +F ext/expert/expert1.test 53a749de08939e3bc14f804e97410927d46fa772cbce0247d7e8fa6fc2523b0c F ext/expert/sqlite3expert.c c8cea5ff15fbe792cccc4992a9b40b706411c41d32611f617897fecac6ff06a4 F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 @@ -911,7 +911,7 @@ F test/autoindex5.test 2ee94f033b87ca0160e08d81034c507aff8e230df2627f0304fa309b2 F test/autovacuum.test 00671369bbf96c6a49989a9425f5b78b94075d6a4b031e5e00000c2c32f365df F test/autovacuum2.test 76f7eb4fe6a6bf6d33a196a7141dba98886d2fb53a268d7feca285d5da4759d7 F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 -F test/avfs.test 0c3a38e03cccb0fc3127838462dc05dc3f4c1480d770c084b388304c25de3652 +F test/avfs.test 76f59743dc1f5fa533840d1818b420fe1ee45e21c0fd6bbac7942ba677903128 F test/avtrans.test b7dc25459ecbd86c6fa9c606ee3068f59d81e225118617dcf2bbb6ded2ade89e F test/backcompat.test 3e64cedda754c778ef6bbe417b6e7a295e662a4d F test/backup.test 3b08fd4af69f0fa786931103a31f4542b184aba16e239e5f22b18c3c2476697f @@ -1520,7 +1520,7 @@ F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 -F test/recover.test fd5199f928757cb308661b5fdca1abc19398a798ff7f24b57c3071e9f8e0471e +F test/recover.test 6463509a7404e0c35431dd9b4a1c3b4a29d7a6af8a08462b31670c8a5a616d3a F test/regexp1.test 8f2a8bc1569666e29a4cee6c1a666cd224eb6d50e2470d1dc1df995170f3e0f1 F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed1368b5 F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d @@ -1600,15 +1600,15 @@ F test/sharedA.test 64bdd21216dda2c6a3bd3475348ccdc108160f34682c97f2f51c19fc0e21 F test/sharedB.test 1a84863d7a2204e0d42f2e1606577c5e92e4473fa37ea0f5bdf829e4bf8ee707 F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test c7127a5e780ffc9e14c476773127fdf292c6db226529c44c1676f37b3793123f -F test/shell2.test 35226c070a8c7f64fd016dfac2a0db2a40f709b3131f61daacd9dad61536c9cb -F test/shell3.test 91febeac0412812bf6370abb8ed72700e32bf8f9878849414518f662dfd55e8a -F test/shell4.test 947029e5a9efae9054d424b309fc0311439c0c3a0866ebfa3b8a771120708220 -F test/shell5.test 263bfd6a49049295277e3f5bdc221390dc5e72f39954b23d43204ed81993304f -F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 -F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test 3fd093d481aaa94dc77fb73f1044c1f19c7efe3477a395cc4f7450133bc54915 -F test/shell9.test f457a96c088344908e0518dbabffd02eda8ac2a8733f278679e5f47c103efbab +F test/shell1.test 17a5ca9c6f24f807b2f505b4b38fcbce143d96cd8664c06c34bbbe0672bf7c30 +F test/shell2.test 56da24128304c9ab67da2964cc80beff7b35761c446ec6e6e98bff2775b15026 +F test/shell3.test 5ad4b2813717956414f2c0c8a2027895cd98ccf7dd54dbacbde4d4f5591ce5a1 +F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f807 +F test/shell5.test 5b2ab1c0540217773f939927c24163a56257446da3f564d4724042620bfea762 +F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bdbb8 +F test/shell7.test 753c6ece5361df50025a50cadf378ea36db9cc05fb23d7a96cff7fa130626ef9 +F test/shell8.test 9b71d56a6f6fc62edd9163534ac21eaa328ad95f1b9026e7bd08d5b4621eacf6 +F test/shell9.test 8742a5b390cdcef6369f5aa223e415aa4255a4129ef249b177887dc635a87209 F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 277bf6ed811b1f07796eedf8b5740ef521fc7fa99bd50faad9760a1fa53653b3 +F test/testrunner.tcl 742a86037556cc6a9e51b5598955fcfc7a610a187ca257791c320b13ce2d5232 F test/testrunner_data.tcl 7ffd951527bbc614e723fd8d123b6834321878530696adecfdf6035100bac64e F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 95a9c88b258f18ac671a4c712603931167cc8bd0b86e41481b200c08043338b5 -R 29b12e6b8f2a6bc2a8ea9a08c15b926a -U drh -Z a3f33edbc2a09bf20230f9f2220bf336 +P 76c471061809307c1922a9460f1ea37291ff5f4dc11a71af594351e875fdc8e3 +R 3a2de83b3312aef9322c95d69c88f610 +U dan +Z ad568019dcaf7d3ff511c52e874411fe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d3cdb542bf..b517c05b4d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76c471061809307c1922a9460f1ea37291ff5f4dc11a71af594351e875fdc8e3 \ No newline at end of file +6eae4547d4d50c798d1f05eaa1da02f4682d261dbd64e94748179923839024e6 \ No newline at end of file diff --git a/test/avfs.test b/test/avfs.test index 2ebd608baa..ffd6b309fc 100644 --- a/test/avfs.test +++ b/test/avfs.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # This file implements tests for the appendvfs extension. # diff --git a/test/recover.test b/test/recover.test index 8d9ad013c0..5495b7a006 100644 --- a/test/recover.test +++ b/test/recover.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # Test the shell tool ".ar" command. # diff --git a/test/shell1.test b/test/shell1.test index 5d4243f47a..206fb0a4fd 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -11,6 +11,7 @@ # # The focus of this file is testing the CLI shell tool. # +# TESTRUNNER: shell # # Test plan: diff --git a/test/shell2.test b/test/shell2.test index 16ed33c442..c6c27d2165 100644 --- a/test/shell2.test +++ b/test/shell2.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # The focus of this file is testing the CLI shell tool. # diff --git a/test/shell3.test b/test/shell3.test index f8d69946e7..c1ea9f6a75 100644 --- a/test/shell3.test +++ b/test/shell3.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # The focus of this file is testing the CLI shell tool. # diff --git a/test/shell4.test b/test/shell4.test index eee59b02b8..4b7e9b8eec 100644 --- a/test/shell4.test +++ b/test/shell4.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # The focus of this file is testing the CLI shell tool. # These tests are specific to the .stats command. diff --git a/test/shell5.test b/test/shell5.test index 20f2ba219d..877676d726 100644 --- a/test/shell5.test +++ b/test/shell5.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # The focus of this file is testing the CLI shell tool. # These tests are specific to the .import command. diff --git a/test/shell6.test b/test/shell6.test index 49b4cc3344..4841d6c01a 100644 --- a/test/shell6.test +++ b/test/shell6.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # Test the shell tool ".lint fkey-indexes" command. # diff --git a/test/shell7.test b/test/shell7.test index 898018d775..dfd9e47c2d 100644 --- a/test/shell7.test +++ b/test/shell7.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # Test the readfile() function built into the shell tool. Specifically, # that it does not truncate the blob read at the first embedded 0x00 diff --git a/test/shell8.test b/test/shell8.test index bee6039232..944173a2a1 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # Test the shell tool ".ar" command. # diff --git a/test/shell9.test b/test/shell9.test index 34c9d8c5d6..869cb075da 100644 --- a/test/shell9.test +++ b/test/shell9.test @@ -8,6 +8,7 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# TESTRUNNER: shell # # The focus of this file is testing the CLI shell tool. Specifically, # testing that it is possible to run a ".dump" script that creates diff --git a/test/testrunner.tcl b/test/testrunner.tcl index b5bd54e2b1..dd909ea186 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -159,6 +159,7 @@ switch -nocase -glob -- $tcl_platform(os) { set TRG(make) make.sh set TRG(makecmd) "bash make.sh" set TRG(testfixture) testfixture + set TRG(shell) sqlite3 set TRG(run) run.sh set TRG(runcmd) "bash run.sh" } @@ -167,6 +168,7 @@ switch -nocase -glob -- $tcl_platform(os) { set TRG(make) make.sh set TRG(makecmd) "bash make.sh" set TRG(testfixture) testfixture + set TRG(shell) sqlite3 set TRG(run) run.sh set TRG(runcmd) "bash run.sh" } @@ -175,6 +177,7 @@ switch -nocase -glob -- $tcl_platform(os) { set TRG(make) make.bat set TRG(makecmd) make.bat set TRG(testfixture) testfixture.exe + set TRG(shell) sqlite3.exe set TRG(run) run.bat set TRG(runcmd) "run.bat" } @@ -617,7 +620,16 @@ proc add_job {args} { trdb last_insert_rowid } -proc add_tcl_jobs {build config patternlist} { +# Argument $build is either an empty string, or else a list of length 3 +# describing the job to build testfixture. In the usual form: +# +# {ID DIRNAME DISPLAYNAME} +# +# e.g +# +# {1 /home/user/sqlite/test/testrunner_bld_xyz All-Debug} +# +proc add_tcl_jobs {build config patternlist {shelldepid ""}} { global TRG set topdir [file dirname $::testdir] @@ -666,29 +678,28 @@ proc add_tcl_jobs {build config patternlist} { if {[lsearch $lProp slow]>=0} { set priority 2 } if {[lsearch $lProp superslow]>=0} { set priority 4 } + set depid [lindex $build 0] + if {$shelldepid!="" && [lsearch $lProp shell]>=0} { set depid $shelldepid } + add_job \ -displaytype tcl \ -displayname $displayname \ -cmd $cmd \ - -depid [lindex $build 0] \ + -depid $depid \ -priority $priority - } } -proc add_build_job {buildname target} { +proc add_build_job {buildname target {postcmd ""} {depid ""}} { global TRG set dirname "[string tolower [string map {- _} $buildname]]_$target" set dirname "testrunner_bld_$dirname" - switch $target { - testfixture - - testfixture.exe { - set mktarget coretestprogs - } - default { - set mktarget $target - } + + set cmd "$TRG(makecmd) $target" + if {$postcmd!=""} { + append cmd "\n" + append cmd $postcmd } set id [add_job \ @@ -696,13 +707,30 @@ proc add_build_job {buildname target} { -displayname "Build $buildname ($target)" \ -dirname $dirname \ -build $buildname \ - -cmd "$TRG(makecmd) $mktarget" \ + -cmd $cmd \ + -depid $depid \ -priority 3 ] list $id [file normalize $dirname] $buildname } +proc add_shell_build_job {buildname dirname depid} { + global TRG + + if {$TRG(platform)=="win"} { + set path [string map {/ \\} "$dirname/" + set copycmd "xcopy /S $TRG(shell) $path" + } else { + set copycmd "cp $TRG(shell) $dirname/" + } + + return [ + add_build_job $buildname $TRG(shell) $copycmd $depid + ] +} + + proc add_make_job {bld target} { global TRG @@ -776,10 +804,19 @@ proc add_devtest_jobs {lBld patternlist} { foreach b $lBld { set bld [add_build_job $b $TRG(testfixture)] - add_tcl_jobs $bld veryquick $patternlist + add_tcl_jobs $bld veryquick $patternlist SHELL if {$patternlist==""} { add_fuzztest_jobs $b } + + if {[trdb one "SELECT EXISTS (SELECT 1 FROM jobs WHERE depid='SHELL')"]} { + set sbld [add_shell_build_job $b [lindex $bld 1] [lindex $bld 0]] + set sbldid [lindex $sbld 0] + trdb eval { + UPDATE jobs SET depid=$sbldid WHERE depid='SHELL' + } + } + } } From f4783d4d7fab71d05b76a0e88448f7042a50086c Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Mar 2024 19:43:43 +0000 Subject: [PATCH 0203/1030] Fix a missing brace problem in testrunner.tcl introduced by the previous commit. FossilOrigin-Name: 1f5e334d98d98cd90a2fb53502015a883d96fed05c04c1c3e1e78c302bede50f --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ccb451459a..ac3fa0c2bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\smdevtest\sand\ssdevtest\sto\sdo\sshell\sbuilds\sin\sparallel.\sAnd\sonly\sif\sone\sor\smore\sof\sthe\stcl\sscripts\srun\srequires\sit. -D 2024-03-11T19:33:55.704 +C Fix\sa\smissing\sbrace\sproblem\sin\stestrunner.tcl\sintroduced\sby\sthe\sprevious\scommit. +D 2024-03-11T19:43:43.289 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 742a86037556cc6a9e51b5598955fcfc7a610a187ca257791c320b13ce2d5232 +F test/testrunner.tcl dc2e0d1256292f098f247a0ac33f1ad1be70e3d474bdd064c99b06637b116d3f F test/testrunner_data.tcl 7ffd951527bbc614e723fd8d123b6834321878530696adecfdf6035100bac64e F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 76c471061809307c1922a9460f1ea37291ff5f4dc11a71af594351e875fdc8e3 -R 3a2de83b3312aef9322c95d69c88f610 +P 6eae4547d4d50c798d1f05eaa1da02f4682d261dbd64e94748179923839024e6 +R ffb80cc7c28af1ee50c0fc7e45c14ced U dan -Z ad568019dcaf7d3ff511c52e874411fe +Z da9cdae477120048435de0332185ec30 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b517c05b4d..01d0a91a04 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6eae4547d4d50c798d1f05eaa1da02f4682d261dbd64e94748179923839024e6 \ No newline at end of file +1f5e334d98d98cd90a2fb53502015a883d96fed05c04c1c3e1e78c302bede50f \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index dd909ea186..170e0457cc 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -719,7 +719,7 @@ proc add_shell_build_job {buildname dirname depid} { global TRG if {$TRG(platform)=="win"} { - set path [string map {/ \\} "$dirname/" + set path [string map {/ \\} "$dirname/"] set copycmd "xcopy /S $TRG(shell) $path" } else { set copycmd "cp $TRG(shell) $dirname/" From 38152d9d04c4db92e871ef24bed43be2232c134b Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Mar 2024 20:34:02 +0000 Subject: [PATCH 0204/1030] Fix another testrunner.tcl problem on windows. FossilOrigin-Name: 7805844bc4433ae088dae6d54eb972e082c5a3df06e844cfc8b69e7d97aeb432 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ac3fa0c2bd..5731f2374e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smissing\sbrace\sproblem\sin\stestrunner.tcl\sintroduced\sby\sthe\sprevious\scommit. -D 2024-03-11T19:43:43.289 +C Fix\sanother\stestrunner.tcl\sproblem\son\swindows. +D 2024-03-11T20:34:02.340 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl dc2e0d1256292f098f247a0ac33f1ad1be70e3d474bdd064c99b06637b116d3f +F test/testrunner.tcl 283be0c85bd132136ed564a99227b946194c31a0658df43c22a5e86956b70b43 F test/testrunner_data.tcl 7ffd951527bbc614e723fd8d123b6834321878530696adecfdf6035100bac64e F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6eae4547d4d50c798d1f05eaa1da02f4682d261dbd64e94748179923839024e6 -R ffb80cc7c28af1ee50c0fc7e45c14ced +P 1f5e334d98d98cd90a2fb53502015a883d96fed05c04c1c3e1e78c302bede50f +R 3329f7728eccdd894e074db61e3ec3e5 U dan -Z da9cdae477120048435de0332185ec30 +Z 4fb36ca27e18f07178be9aab3a444f9c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 01d0a91a04..cf0788db21 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f5e334d98d98cd90a2fb53502015a883d96fed05c04c1c3e1e78c302bede50f \ No newline at end of file +7805844bc4433ae088dae6d54eb972e082c5a3df06e844cfc8b69e7d97aeb432 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 170e0457cc..daf7457170 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -175,7 +175,7 @@ switch -nocase -glob -- $tcl_platform(os) { *win* { set TRG(platform) win set TRG(make) make.bat - set TRG(makecmd) make.bat + set TRG(makecmd) "call make.bat" set TRG(testfixture) testfixture.exe set TRG(shell) sqlite3.exe set TRG(run) run.bat @@ -720,7 +720,7 @@ proc add_shell_build_job {buildname dirname depid} { if {$TRG(platform)=="win"} { set path [string map {/ \\} "$dirname/"] - set copycmd "xcopy /S $TRG(shell) $path" + set copycmd "xcopy $TRG(shell) $path" } else { set copycmd "cp $TRG(shell) $dirname/" } From 3ac5c0818073382eaaec5acca38925dcd8e4d52f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Mar 2024 18:04:40 +0000 Subject: [PATCH 0205/1030] Have testrunner.tcl have each test store its temp files in its working directory. To avoid unlikely, but possible, collisions. FossilOrigin-Name: 775a10d10b9bf2227071e778718ba4054d4b2b4238751eb147338d687b4e0d58 --- manifest | 15 +++++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 7 ++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5731f2374e..e4db435c3e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\stestrunner.tcl\sproblem\son\swindows. -D 2024-03-11T20:34:02.340 +C Have\stestrunner.tcl\shave\seach\stest\sstore\sits\stemp\sfiles\sin\sits\sworking\sdirectory.\sTo\savoid\sunlikely,\sbut\spossible,\scollisions. +D 2024-03-12T18:04:40.495 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 283be0c85bd132136ed564a99227b946194c31a0658df43c22a5e86956b70b43 +F test/testrunner.tcl 9fb1341f4a3fcc169b0cffa2f319abde197a738d98131d178a81509a0638f2df F test/testrunner_data.tcl 7ffd951527bbc614e723fd8d123b6834321878530696adecfdf6035100bac64e F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1f5e334d98d98cd90a2fb53502015a883d96fed05c04c1c3e1e78c302bede50f -R 3329f7728eccdd894e074db61e3ec3e5 +P 7805844bc4433ae088dae6d54eb972e082c5a3df06e844cfc8b69e7d97aeb432 +R 9fe0d14be342ac1becb45016c9700f68 +T *branch * testrunner-tmpdir-fix +T *sym-testrunner-tmpdir-fix * +T -sym-trunk * U dan -Z 4fb36ca27e18f07178be9aab3a444f9c +Z 7a40c29cf47919cba49700f99392c55a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cf0788db21..1af80e0611 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7805844bc4433ae088dae6d54eb972e082c5a3df06e844cfc8b69e7d97aeb432 \ No newline at end of file +775a10d10b9bf2227071e778718ba4054d4b2b4238751eb147338d687b4e0d58 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index daf7457170..7dbfc251de 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -994,6 +994,11 @@ proc launch_another_job {iJob} { close $fd } + set job_cmd $job(cmd) + if {$TRG(platform)!="win"} { + set job_cmd "export SQLITE_TMPDIR=\"[file normalize $dir]\"\n$job_cmd" + } + if { $TRG(dryrun) } { mark_job_as_finished $job(jobid) "" done 0 @@ -1008,7 +1013,7 @@ proc launch_another_job {iJob} { set pwd [pwd] cd $dir set fd [open $TRG(run) w] - puts $fd $job(cmd) + puts $fd $job_cmd close $fd set fd [open "|$TRG(runcmd) 2>@1" r] cd $pwd From 5badd048d2e63b900683eefd01a3427a3d82b277 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Mar 2024 20:10:46 +0000 Subject: [PATCH 0206/1030] Correctly initialize the SrcItem.iCursor field to -1 when creating a co-routine from a multi-values VALUES clause. FossilOrigin-Name: c32953ff6d72910815eaff29ab1b790c412e1a741d02c03c5911dda0c08e5130 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/insert.c | 1 + test/values.test | 11 +++++++++++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index afde134bd1..ae283f24ef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Attempt\sto\sreduce\sthe\smemory\sused\sby\sVALUES\sclauses\sin\sas\smany\sstatements\sas\spossible,\snot\sjust\sINSERT.\sThis\sbranch\sstill\shas\sproblems. -D 2024-03-11T17:27:19.668 +C Correctly\sinitialize\sthe\sSrcItem.iCursor\sfield\sto\s-1\swhen\screating\sa\sco-routine\sfrom\sa\smulti-values\sVALUES\sclause. +D 2024-03-12T20:10:46.651 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 2c34cf51e9d8c00498ba68b7f130e448038bb31f624c9c1ca80fa8e3237b51fb +F src/insert.c 9d48439a0fff35d3c4850bc9ab3657f9d45b2800af52ef3b083e7068e32d8aa2 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 8438dea6826738291ff2019993d62e1eae7a3efb66ea8312fa9ac9bfaf0f95cb +F test/values.test 042f30d897d3b2bfa54dc89a48ef6c8f6ba3ffdfd4fc35c2cc877d28a1095ce3 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,11 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 95a9c88b258f18ac671a4c712603931167cc8bd0b86e41481b200c08043338b5 -R 62b6db11e5c879766b23978dd0871f55 -T *branch * exp-values-clause2 -T *sym-exp-values-clause2 * -T -sym-trunk * +P 17d1f7cfabc7593d0725051b0c7c9619a23a482265f30f15ab9493fef5caeeb0 +R bc124d03e15c7cb41c52570d66be2e47 U dan -Z 521a450017e9a427470d7f09cc068c5e +Z 476dd3f62c65ec97a150406261356d2a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 633c59c43c..bc849bef9a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -17d1f7cfabc7593d0725051b0c7c9619a23a482265f30f15ab9493fef5caeeb0 \ No newline at end of file +c32953ff6d72910815eaff29ab1b790c412e1a741d02c03c5911dda0c08e5130 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 7b253e9262..071d9aeff9 100644 --- a/src/insert.c +++ b/src/insert.c @@ -635,6 +635,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ p->fg.viaCoroutine = 1; p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; p->regReturn = ++pParse->nMem; + p->iCursor = -1; sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub); sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); diff --git a/test/values.test b/test/values.test index 66e29ef6f0..8df0e6138f 100644 --- a/test/values.test +++ b/test/values.test @@ -252,5 +252,16 @@ do_execsql_test 6.1 { SELECT ( VALUES( x ), ( x ) ) FROM t1; } {1 2} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 6.0 { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES('x'), ('y'); +} + +do_execsql_test 6.1 { + SELECT * FROM t1, (VALUES(1), (2)) +} {x 1 x 2 y 1 y 2} finish_test + From eea6bdce8453c07567f24b96e6ea3e1ea994940d Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 13 Mar 2024 00:37:37 +0000 Subject: [PATCH 0207/1030] On testrunner.tcl: (1) Add the "help" command. (2) Add the "script" command to the help message. (3) Improve the error message generated by "script" when an incorrect CONFIG option is provided. FossilOrigin-Name: 1b7f0be44036fb90d763eabae84b95734e766f8010b39122f8787189308a7fc1 --- manifest | 17 ++++++++--------- manifest.uuid | 2 +- test/testrunner.tcl | 14 ++++++++++++++ test/testrunner_data.tcl | 8 ++++++-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 5da9367f47..ed93666844 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\stestrunner.tcl\shave\seach\stest\sstore\sits\stemp\sfiles\sin\sits\sworking\sdirectory.\sTo\savoid\sunlikely,\sbut\spossible,\scollisions. -D 2024-03-12T18:33:57.893 +C On\stestrunner.tcl:\s(1)\sAdd\sthe\s"help"\scommand.\s\s(2)\sAdd\sthe\s"script"\scommand\nto\sthe\shelp\smessage.\s\s(3)\sImprove\sthe\serror\smessage\sgenerated\sby\s"script"\swhen\nan\sincorrect\sCONFIG\soption\sis\sprovided. +D 2024-03-13T00:37:37.096 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,8 +1687,8 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 9fb1341f4a3fcc169b0cffa2f319abde197a738d98131d178a81509a0638f2df -F test/testrunner_data.tcl 7ffd951527bbc614e723fd8d123b6834321878530696adecfdf6035100bac64e +F test/testrunner.tcl 7cd31694a52affd636284b3e74ec10213c60e247ec71f56e9061cf669f897105 +F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2177,9 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7805844bc4433ae088dae6d54eb972e082c5a3df06e844cfc8b69e7d97aeb432 775a10d10b9bf2227071e778718ba4054d4b2b4238751eb147338d687b4e0d58 -R 9fe0d14be342ac1becb45016c9700f68 -T +closed 775a10d10b9bf2227071e778718ba4054d4b2b4238751eb147338d687b4e0d58 -U dan -Z d2698b4f4cd69108bc3174c8dffaf5d3 +P 18842d0d72048561312c2c83035c01253150e1fe1ff37160f266d24d41a01df3 +R a8f09c1fdaad1d594fe806932cdf9a66 +U drh +Z 2fb114f4336505cce7dafa69e9c32517 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2770d1d0c4..dffe028c56 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -18842d0d72048561312c2c83035c01253150e1fe1ff37160f266d24d41a01df3 \ No newline at end of file +1b7f0be44036fb90d763eabae84b95734e766f8010b39122f8787189308a7fc1 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 7dbfc251de..163ddc01e0 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -54,7 +54,9 @@ proc usage {} { Usage: $a0 ?SWITCHES? ?PERMUTATION? ?PATTERNS? $a0 PERMUTATION FILE + $a0 help $a0 njob ?NJOB? + $a0 script ?-msvc? CONFIG $a0 status where SWITCHES are: @@ -89,6 +91,10 @@ directory as a running testrunner.tcl script that is running tests. The "status" command prints a report describing the current state and progress of the tests. The "njob" command may be used to query or modify the number of sub-processes the test script uses to run tests. + +The "script" command outputs the script used to build a configuration. +Add the "-msvc" option for a Windows-compatible script. For a list of +available configurations enter "$a0 script help". }]] exit 1 @@ -329,6 +335,14 @@ if {([llength $argv]==2 || [llength $argv]==1) } #-------------------------------------------------------------------------- +#-------------------------------------------------------------------------- +# Check if this is the "help" command: +# +if {[string compare -nocase help [lindex $argv 0]]==0} { + usage +} +#-------------------------------------------------------------------------- + #-------------------------------------------------------------------------- # Check if this is the "script" command: # diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index 984c6d8272..f38abad589 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -598,7 +598,12 @@ proc trd_buildscript {config srcdir bMsvc} { # Ensure that the named configuration exists. if {![info exists build($config)]} { - error "No such build config: $config" + if {$config!="help"} { + puts "No such build config: $config" + } + puts "Available configurations: [lsort [array names build]]" + flush stdout + exit 1 } # Generate and return the script. @@ -637,4 +642,3 @@ proc trd_test_script_properties {path} { set trd_test_script_properties_cache($path) } - From 3de08a6ee0eb5eeb3d5b0008946ea606dcd8eee3 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Mar 2024 10:47:54 +0000 Subject: [PATCH 0208/1030] Have testrunner.tcl set SQLITE_TMPDIR on windows as well. FossilOrigin-Name: 64f4dad1f928716b8688c650d043f18afcc72ec78d990145c580e2b98905b919 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/testrunner.tcl | 14 ++++++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index ed93666844..2735ee46af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\stestrunner.tcl:\s(1)\sAdd\sthe\s"help"\scommand.\s\s(2)\sAdd\sthe\s"script"\scommand\nto\sthe\shelp\smessage.\s\s(3)\sImprove\sthe\serror\smessage\sgenerated\sby\s"script"\swhen\nan\sincorrect\sCONFIG\soption\sis\sprovided. -D 2024-03-13T00:37:37.096 +C Have\stestrunner.tcl\sset\sSQLITE_TMPDIR\son\swindows\sas\swell. +D 2024-03-13T10:47:54.860 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 7cd31694a52affd636284b3e74ec10213c60e247ec71f56e9061cf669f897105 +F test/testrunner.tcl 29b60469f0bd1aa717507e2ec7660128894914def0f058bb6752c9bdfe61bbaa F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 18842d0d72048561312c2c83035c01253150e1fe1ff37160f266d24d41a01df3 -R a8f09c1fdaad1d594fe806932cdf9a66 -U drh -Z 2fb114f4336505cce7dafa69e9c32517 +P 1b7f0be44036fb90d763eabae84b95734e766f8010b39122f8787189308a7fc1 +R 3f6a714f6a93dd220bd97ec3c31ac4b4 +U dan +Z 4ab7e95a7dcf535e4920c95d1b703486 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dffe028c56..ee62c57213 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b7f0be44036fb90d763eabae84b95734e766f8010b39122f8787189308a7fc1 \ No newline at end of file +64f4dad1f928716b8688c650d043f18afcc72ec78d990145c580e2b98905b919 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 163ddc01e0..f05b399e3a 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -1008,9 +1008,14 @@ proc launch_another_job {iJob} { close $fd } - set job_cmd $job(cmd) - if {$TRG(platform)!="win"} { - set job_cmd "export SQLITE_TMPDIR=\"[file normalize $dir]\"\n$job_cmd" + # Add a batch/shell file command to set the directory used for temp + # files to the test's working directory. Otherwise, tests that use + # large numbers of temp files (e.g. zipvfs), might generate temp + # filename collisions. + if {$TRG(platform)=="win"} { + set set_tmp_dir "SET SQLITE_TMPDIR=[file normalize $dir]" + } else { + set set_tmp_dir "export SQLITE_TMPDIR=\"[file normalize $dir]\"" } if { $TRG(dryrun) } { @@ -1027,7 +1032,8 @@ proc launch_another_job {iJob} { set pwd [pwd] cd $dir set fd [open $TRG(run) w] - puts $fd $job_cmd + puts $fd $set_tmp_dir + puts $fd $job(cmd) close $fd set fd [open "|$TRG(runcmd) 2>@1" r] cd $pwd From 1769640c8be768f42b9a25d175f7d2760a6534bc Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Mar 2024 10:54:04 +0000 Subject: [PATCH 0209/1030] Add pointer to documentation to testrunner.tcl help message. FossilOrigin-Name: eff855102f9c0b4e9d876d1cff9d06c07de427b4880c2fa326d4d6e3e1dd13c8 --- doc/testrunner.md | 1 - manifest | 14 +++++++------- manifest.uuid | 2 +- test/testrunner.tcl | 2 ++ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/testrunner.md b/doc/testrunner.md index d420076c4f..f7fd296718 100644 --- a/doc/testrunner.md +++ b/doc/testrunner.md @@ -17,7 +17,6 @@
  • 3.3. Investigating Source Code Test Failures
  • 4. Extra testrunner.tcl Options -# 4. Extra testrunner.tcl Options
  • 5. Controlling CPU Core Utilization diff --git a/manifest b/manifest index 2735ee46af..38fcd0cd0c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\stestrunner.tcl\sset\sSQLITE_TMPDIR\son\swindows\sas\swell. -D 2024-03-13T10:47:54.860 +C Add\spointer\sto\sdocumentation\sto\stestrunner.tcl\shelp\smessage. +D 2024-03-13T10:54:04.498 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -44,7 +44,7 @@ F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347b F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 -F doc/testrunner.md 8d36ec692cf4994bb66d84a4645b9afa1ce9d47dc12cbf8d437c5a5fb6ddeedb +F doc/testrunner.md 7d16aa94aec424d5316be7f336f84f2961ab4e5e0acbc54bc610a80c4cbd87de F doc/trusted-schema.md 33625008620e879c7bcfbbfa079587612c434fa094d338b08242288d358c3e8a F doc/vdbesort-memory.md 4da2639c14cd24a31e0af694b1a8dd37eaf277aff3867e9a8cc14046bc49df56 F doc/vfs-shm.txt e101f27ea02a8387ce46a05be2b1a902a021d37a @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 29b60469f0bd1aa717507e2ec7660128894914def0f058bb6752c9bdfe61bbaa +F test/testrunner.tcl cc3e416435f9bef832fb5e9f2b09e9d365faec77544573a9d9dc7b0f95b1120d F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1b7f0be44036fb90d763eabae84b95734e766f8010b39122f8787189308a7fc1 -R 3f6a714f6a93dd220bd97ec3c31ac4b4 +P 64f4dad1f928716b8688c650d043f18afcc72ec78d990145c580e2b98905b919 +R 1134b8266271a887377fc4f455ed517a U dan -Z 4ab7e95a7dcf535e4920c95d1b703486 +Z 833508436e05f778ed8b702f9da8c8a7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ee62c57213..b4442bcf4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -64f4dad1f928716b8688c650d043f18afcc72ec78d990145c580e2b98905b919 \ No newline at end of file +eff855102f9c0b4e9d876d1cff9d06c07de427b4880c2fa326d4d6e3e1dd13c8 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index f05b399e3a..439ccb0886 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -95,6 +95,8 @@ of sub-processes the test script uses to run tests. The "script" command outputs the script used to build a configuration. Add the "-msvc" option for a Windows-compatible script. For a list of available configurations enter "$a0 script help". + +Full documentation here: https://sqlite.org/src/doc/trunk/doc/testrunner.md }]] exit 1 From 484193fe7f7dccc1371757e339569f7c5c3e8bea Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 13 Mar 2024 10:55:47 +0000 Subject: [PATCH 0210/1030] Improvements to the "help" message generated by testrunner.tcl. Add the special "list" permutation that does nothing but list all allowed values for the PERMUTATION argument to testrunner.tcl. FossilOrigin-Name: 1f5bfc6a9030f9905d258c5b665b9ff27efc7da71556c912ab3dce0f8f5aa8da --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/testrunner.tcl | 34 ++++++++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 38fcd0cd0c..6f92138cec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\spointer\sto\sdocumentation\sto\stestrunner.tcl\shelp\smessage. -D 2024-03-13T10:54:04.498 +C Improvements\sto\sthe\s"help"\smessage\sgenerated\sby\stestrunner.tcl.\s\sAdd\sthe\nspecial\s"list"\spermutation\sthat\sdoes\snothing\sbut\slist\sall\sallowed\nvalues\sfor\sthe\sPERMUTATION\sargument\sto\stestrunner.tcl. +D 2024-03-13T10:55:47.181 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl cc3e416435f9bef832fb5e9f2b09e9d365faec77544573a9d9dc7b0f95b1120d +F test/testrunner.tcl acc25035b127471961ff8f77b829dc51a9615b1016bb874a339733b4c0881f30 F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 64f4dad1f928716b8688c650d043f18afcc72ec78d990145c580e2b98905b919 -R 1134b8266271a887377fc4f455ed517a -U dan -Z 833508436e05f778ed8b702f9da8c8a7 +P eff855102f9c0b4e9d876d1cff9d06c07de427b4880c2fa326d4d6e3e1dd13c8 +R 932e56d0dea34c025007477ebbf78453 +U drh +Z 0cfae733ff130354c2d77ebd401ddd94 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b4442bcf4f..2f15429b49 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eff855102f9c0b4e9d876d1cff9d06c07de427b4880c2fa326d4d6e3e1dd13c8 \ No newline at end of file +1f5bfc6a9030f9905d258c5b665b9ff27efc7da71556c912ab3dce0f8f5aa8da \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 439ccb0886..ba3d9b5533 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -65,13 +65,19 @@ Usage: --jobs NUMBER-OF-JOBS --zipvfs ZIPVFS-SOURCE-DIR -Interesting values for PERMUTATION are: +Special values for PERMUTATION that work with plain tclsh: + + list - show all allowed PERMUTATION arguments. + mdevtest - tests recommended prior to normal development check-ins. + release - full release test with various builds. + sdevtest - like mdevtest but using ASAN and UBSAN. + +Other PERMUTATION arguments must be run using testfixture, not tclsh: - veryquick - a fast subset of the tcl test scripts. This is the default. - full - all tcl test scripts. all - all tcl test scripts, plus a subset of test scripts rerun with various permutations. - release - full release test with various builds. + full - all tcl test scripts. + veryquick - a fast subset of the tcl test scripts. This is the default. If no PATTERN arguments are present, all tests specified by the PERMUTATION are run. Otherwise, each pattern is interpreted as a glob pattern. Only @@ -836,6 +842,17 @@ proc add_devtest_jobs {lBld patternlist} { } } +# Check to ensure that the interpreter is a full-blown "testfixture" +# build and not just a "tclsh". If this is not the case, issue an +# error message and exit. +# +proc must_be_testfixture {} { + if {[lsearch [info commands] sqlite3_soft_heap_limit]<0} { + puts "Use ./testfixture, not tclsh, for these arguments" + exit 1 + } +} + proc add_jobs_from_cmdline {patternlist} { global TRG @@ -851,6 +868,7 @@ proc add_jobs_from_cmdline {patternlist} { set first [lindex $patternlist 0] switch -- $first { all { + must_be_testfixture set patternlist [lrange $patternlist 1 end] set clist [trd_all_configs] foreach c $clist { @@ -886,7 +904,15 @@ proc add_jobs_from_cmdline {patternlist} { } } + list { + set allperm [array names ::testspec] + lappend allperm all mdevtest sdevtest release list + puts "Allowed values for the PERMUTATION argument: [lsort $allperm]" + exit 0 + } + default { + must_be_testfixture if {[info exists ::testspec($first)]} { add_tcl_jobs "" $first [lrange $patternlist 1 end] } else { From c2764dbb3310922cf3127c057c508804353230c7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 13 Mar 2024 11:29:04 +0000 Subject: [PATCH 0211/1030] Minor tweaks to the testrunner documentation. FossilOrigin-Name: 3128b98d2656c7f23f6071c173f96329c7bdc49cd641050fbb7b105b810ba7c7 --- doc/testrunner.md | 27 +++++++++++++++------------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/doc/testrunner.md b/doc/testrunner.md index f7fd296718..470c770f1d 100644 --- a/doc/testrunner.md +++ b/doc/testrunner.md @@ -28,12 +28,18 @@ multiple jobs. It supports the following types of tests: * Tcl test scripts. - * Tests run with [make] commands. Specifically, at time of writing, - [make fuzztest], [make mptest], [make sourcetest] and [make threadtest]. + * Tests run with `make` commands. Examples: + - `make mdevtest` + - `make releasetest` + - `make sdevtest` + - `make testrunner` testrunner.tcl pipes the output of all tests and builds run into log file -**testrunner.log**, created in the cwd directory. Searching this file for -"failed" is a good way to find the output of a failed test. +**testrunner.log**, created in the current working directory. Search this +file to find details of errors. Suggested search commands: + + * `grep "^!" testrunner.log` + * `grep failed testrunner.log` testrunner.tcl also populates SQLite database **testrunner.db**. This database contains details of all tests run, running and to be run. A useful query @@ -59,7 +65,7 @@ Running: in another terminal is a good way to keep an eye on a long running test. -Sometimes testrunner.tcl uses the [testfixture] binary that it is run with +Sometimes testrunner.tcl uses the `testfixture` binary that it is run with to run tests (see "Binary Tests" below). Sometimes it builds testfixture and other binaries in specific configurations to test (see "Source Tests"). @@ -67,9 +73,9 @@ other binaries in specific configurations to test (see "Source Tests"). # 2. Binary Tests The commands described in this section all run various combinations of the Tcl -test scripts using the [testfixture] binary used to run the testrunner.tcl +test scripts using the `testfixture` binary used to run the testrunner.tcl script (i.e. they do not invoke the compiler to build new binaries, or the -[make] command to run tests that are not Tcl scripts). The procedure to run +`make` command to run tests that are not Tcl scripts). The procedure to run these tests is therefore: 1. Build the "testfixture" (or "testfixture.exe" for windows) binary using @@ -192,7 +198,7 @@ TODO: ./configure + Makefile.msc build systems. ## 3.1. Commands to Run SQLite Tests The **mdevtest** command is equivalent to running the veryquick tests and -the [make fuzztest] target once for each of two --enable-all builds - one +the `make fuzztest` target once for each of two --enable-all builds - one with debugging enabled and one without: ``` @@ -282,7 +288,7 @@ a dos \*.bat file on windows. For example: ``` The generated bash or \*.bat file script accepts a single argument - a makefile -target to build. This may be used either to run a [make] command test directly, +target to build. This may be used either to run a `make` command test directly, or else to build a testfixture (or testfixture.exe) binary with which to run a Tcl test script, as described above. @@ -338,6 +344,3 @@ testrunner.log and testrunner.db files: ``` $ ./testfixture $TESTDIR/testrunner.tcl njob $NEW_NUMBER_OF_JOBS ``` - - - diff --git a/manifest b/manifest index 6f92138cec..ea1d4a7d34 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\s"help"\smessage\sgenerated\sby\stestrunner.tcl.\s\sAdd\sthe\nspecial\s"list"\spermutation\sthat\sdoes\snothing\sbut\slist\sall\sallowed\nvalues\sfor\sthe\sPERMUTATION\sargument\sto\stestrunner.tcl. -D 2024-03-13T10:55:47.181 +C Minor\stweaks\sto\sthe\stestrunner\sdocumentation. +D 2024-03-13T11:29:04.049 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -44,7 +44,7 @@ F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347b F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 -F doc/testrunner.md 7d16aa94aec424d5316be7f336f84f2961ab4e5e0acbc54bc610a80c4cbd87de +F doc/testrunner.md 50570a63efb68fd1472cbe7eeccf78c7b7d66ac1f966ab18d29f824f7cdba2b3 F doc/trusted-schema.md 33625008620e879c7bcfbbfa079587612c434fa094d338b08242288d358c3e8a F doc/vdbesort-memory.md 4da2639c14cd24a31e0af694b1a8dd37eaf277aff3867e9a8cc14046bc49df56 F doc/vfs-shm.txt e101f27ea02a8387ce46a05be2b1a902a021d37a @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eff855102f9c0b4e9d876d1cff9d06c07de427b4880c2fa326d4d6e3e1dd13c8 -R 932e56d0dea34c025007477ebbf78453 +P 1f5bfc6a9030f9905d258c5b665b9ff27efc7da71556c912ab3dce0f8f5aa8da +R f1d87f081beab0bb7e2677dcc20d7af9 U drh -Z 0cfae733ff130354c2d77ebd401ddd94 +Z 7d008234f4102bc09ae556028dcb2b0f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2f15429b49..f66ed3c2e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f5bfc6a9030f9905d258c5b665b9ff27efc7da71556c912ab3dce0f8f5aa8da \ No newline at end of file +3128b98d2656c7f23f6071c173f96329c7bdc49cd641050fbb7b105b810ba7c7 \ No newline at end of file From 9b6e535609a114846a4570d263533845b6cf0f77 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 13 Mar 2024 11:46:23 +0000 Subject: [PATCH 0212/1030] Improve one of the error messages from testrunner.tcl. FossilOrigin-Name: 233155c174575fa99b34030c1936bc2b04489417f4d5223f18cdb3c8fc274a56 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ea1d4a7d34..a67db52106 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\stweaks\sto\sthe\stestrunner\sdocumentation. -D 2024-03-13T11:29:04.049 +C Improve\sone\sof\sthe\serror\smessages\sfrom\stestrunner.tcl. +D 2024-03-13T11:46:23.016 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl acc25035b127471961ff8f77b829dc51a9615b1016bb874a339733b4c0881f30 +F test/testrunner.tcl cdbfe4b24952a411fcc2cb48331d10ece650b6a3108bd05ae890304cfed93fed F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1f5bfc6a9030f9905d258c5b665b9ff27efc7da71556c912ab3dce0f8f5aa8da -R f1d87f081beab0bb7e2677dcc20d7af9 +P 3128b98d2656c7f23f6071c173f96329c7bdc49cd641050fbb7b105b810ba7c7 +R b30ace34515f0911b2a0db585efbc51d U drh -Z 7d008234f4102bc09ae556028dcb2b0f +Z 4fb6ed0f5ce1c12c4ccfa1c6192fc974 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f66ed3c2e4..7d5581e36c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3128b98d2656c7f23f6071c173f96329c7bdc49cd641050fbb7b105b810ba7c7 \ No newline at end of file +233155c174575fa99b34030c1936bc2b04489417f4d5223f18cdb3c8fc274a56 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index ba3d9b5533..76a73a6ba7 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -848,7 +848,7 @@ proc add_devtest_jobs {lBld patternlist} { # proc must_be_testfixture {} { if {[lsearch [info commands] sqlite3_soft_heap_limit]<0} { - puts "Use ./testfixture, not tclsh, for these arguments" + puts "Use testfixture, not tclsh, for these arguments." exit 1 } } From 4659ec34c1c5ffceb64ce486502acb92f14688eb Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 13 Mar 2024 13:09:58 +0000 Subject: [PATCH 0213/1030] Add the --explain option to testrunner.tcl. FossilOrigin-Name: f0c9eb0326f189fe5ebbee83532ac2c413e91c6a8e9d5b93aa6170cba66fdd22 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 45 ++++++++++++++++++++++++++++++++++++++------- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index a67db52106..683882b1c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sone\sof\sthe\serror\smessages\sfrom\stestrunner.tcl. -D 2024-03-13T11:46:23.016 +C Add\sthe\s--explain\soption\sto\stestrunner.tcl. +D 2024-03-13T13:09:58.491 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl cdbfe4b24952a411fcc2cb48331d10ece650b6a3108bd05ae890304cfed93fed +F test/testrunner.tcl f172c5141b890acfc223884071f90176031e3a059218280952f536eb2c851ee8 F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3128b98d2656c7f23f6071c173f96329c7bdc49cd641050fbb7b105b810ba7c7 -R b30ace34515f0911b2a0db585efbc51d +P 233155c174575fa99b34030c1936bc2b04489417f4d5223f18cdb3c8fc274a56 +R 73b7b3b0e43269248a0a7f9b5744d286 U drh -Z 4fb6ed0f5ce1c12c4ccfa1c6192fc974 +Z bad41bec7a1c5ea3149d7911ab3a6c38 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7d5581e36c..6ccc32a8fd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -233155c174575fa99b34030c1936bc2b04489417f4d5223f18cdb3c8fc274a56 \ No newline at end of file +f0c9eb0326f189fe5ebbee83532ac2c413e91c6a8e9d5b93aa6170cba66fdd22 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 76a73a6ba7..96494dc3a5 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -62,6 +62,7 @@ Usage: where SWITCHES are: --buildonly --dryrun + --explain --jobs NUMBER-OF-JOBS --zipvfs ZIPVFS-SOURCE-DIR @@ -166,6 +167,7 @@ set TRG(fuzztest) 0 ;# is the fuzztest option present. set TRG(zipvfs) "" ;# -zipvfs option, if any set TRG(buildonly) 0 ;# True if --buildonly option set TRG(dryrun) 0 ;# True if --dryrun option +set TRG(explain) 0 ;# True for the --explain option switch -nocase -glob -- $tcl_platform(os) { *darwin* { @@ -460,6 +462,8 @@ for {set ii 0} {$ii < [llength $argv]} {incr ii} { set TRG(buildonly) 1 } elseif {($n>2 && [string match "$a*" --dryrun]) || $a=="-d"} { set TRG(dryrun) 1 + } elseif {($n>2 && [string match "$a*" --explain]) || $a=="-e"} { + set TRG(explain) 1 } else { usage } @@ -1177,15 +1181,42 @@ proc handle_buildonly {} { } } +# Handle the --explain option. Provide a human-readable +# explanation of all the tests that are in the trdb database jobs +# table. +# +proc explain_layer {indent depid} { + global TRG + if {$TRG(buildonly)} { + set showtests 0 + } else { + set showtests 1 + } + trdb eval {SELECT jobid, displayname, displaytype, dirname + FROM jobs WHERE depid=$depid ORDER BY displayname} { + if {$displaytype=="bld"} { + puts "${indent}$displayname in $dirname" + explain_layer "${indent} " $jobid + } elseif {$showtests} { + puts "${indent}[lindex $displayname end]" + } + } +} +proc explain_tests {} { + explain_layer "" "" +} + sqlite3 trdb $TRG(dbname) trdb timeout $TRG(timeout) set tm [lindex [time { make_new_testset }] 0] -if {$TRG(nJob)>1} { - puts "splitting work across $TRG(nJob) jobs" +if {$TRG(explain)} { + explain_tests +} else { + if {$TRG(nJob)>1} { + puts "splitting work across $TRG(nJob) jobs" + } + puts "built testset in [expr $tm/1000]ms.." + handle_buildonly + run_testset } -puts "built testset in [expr $tm/1000]ms.." - -handle_buildonly -run_testset trdb close -#puts [pwd] From 4565c8417b1ff0f188fe7272f7049f2c33ced134 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 13 Mar 2024 13:27:16 +0000 Subject: [PATCH 0214/1030] Document the testrunner.tcl --explain option in doc/testrunner.md. FossilOrigin-Name: 5a7b5fc99a9d5c7693a5707c2050a8c59a8f97732e4763a56982579f8d5959ec --- doc/testrunner.md | 10 ++++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/doc/testrunner.md b/doc/testrunner.md index 470c770f1d..d0248573ee 100644 --- a/doc/testrunner.md +++ b/doc/testrunner.md @@ -315,6 +315,16 @@ would normally execute into the testrunner.log file. Example: tclsh $TESTDIR/testrunner.tcl --dryrun mdevtest" ``` +The **--explain** option is similar to --dryrun in that it prevents testrunner.tcl +from building any binaries or running any tests. The difference is that --explain +prints on standard output a human-readable summary of all the builds and tests that +would have been run. + +``` + # Show what builds and tests would have been run + tclsh $TESTDIR/testrunner.tcl --explain mdevtest +``` + # 5. Controlling CPU Core Utilization diff --git a/manifest b/manifest index 683882b1c4..a5d47b0edb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--explain\soption\sto\stestrunner.tcl. -D 2024-03-13T13:09:58.491 +C Document\sthe\stestrunner.tcl\s--explain\soption\sin\sdoc/testrunner.md. +D 2024-03-13T13:27:16.812 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -44,7 +44,7 @@ F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347b F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 -F doc/testrunner.md 50570a63efb68fd1472cbe7eeccf78c7b7d66ac1f966ab18d29f824f7cdba2b3 +F doc/testrunner.md 15583cf8c7d8a1c3378fd5d4319ca769a14c4d950a5df9b015d01d5be290dc69 F doc/trusted-schema.md 33625008620e879c7bcfbbfa079587612c434fa094d338b08242288d358c3e8a F doc/vdbesort-memory.md 4da2639c14cd24a31e0af694b1a8dd37eaf277aff3867e9a8cc14046bc49df56 F doc/vfs-shm.txt e101f27ea02a8387ce46a05be2b1a902a021d37a @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 233155c174575fa99b34030c1936bc2b04489417f4d5223f18cdb3c8fc274a56 -R 73b7b3b0e43269248a0a7f9b5744d286 +P f0c9eb0326f189fe5ebbee83532ac2c413e91c6a8e9d5b93aa6170cba66fdd22 +R 4e0be3056348c8f1e7d2864a45b77c77 U drh -Z bad41bec7a1c5ea3149d7911ab3a6c38 +Z 5cfab6cb98d5a454aa1c2e14d97de81e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6ccc32a8fd..b5e8f2c31e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0c9eb0326f189fe5ebbee83532ac2c413e91c6a8e9d5b93aa6170cba66fdd22 \ No newline at end of file +5a7b5fc99a9d5c7693a5707c2050a8c59a8f97732e4763a56982579f8d5959ec \ No newline at end of file From 6bb6a9c94162ec7faf5489bca4fbebbe90901604 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 13 Mar 2024 13:43:21 +0000 Subject: [PATCH 0215/1030] If the NJOB environment variable is a positive integer, it causes testrunner.tcl to run that many jobs. FossilOrigin-Name: 924281b94d8e6ba674d6fe2f7f01da890351355a854e9e6fe623fad1180f7392 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index a5d47b0edb..f47cb0a280 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Document\sthe\stestrunner.tcl\s--explain\soption\sin\sdoc/testrunner.md. -D 2024-03-13T13:27:16.812 +C If\sthe\sNJOB\senvironment\svariable\sis\sa\spositive\sinteger,\sit\scauses\ntestrunner.tcl\sto\srun\sthat\smany\sjobs. +D 2024-03-13T13:43:21.042 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl f172c5141b890acfc223884071f90176031e3a059218280952f536eb2c851ee8 +F test/testrunner.tcl 48e33d99f0bad37a03b8a4064a44184de4c4ed8cd2e3174fef8d7c5f4e28ecc3 F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f0c9eb0326f189fe5ebbee83532ac2c413e91c6a8e9d5b93aa6170cba66fdd22 -R 4e0be3056348c8f1e7d2864a45b77c77 +P 5a7b5fc99a9d5c7693a5707c2050a8c59a8f97732e4763a56982579f8d5959ec +R 407830b5c90e1eed2d3fe5c7fa3b86c4 U drh -Z 5cfab6cb98d5a454aa1c2e14d97de81e +Z 7cb4f1a4becd0bff0730a94c93a2e20f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b5e8f2c31e..a1fceec15d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a7b5fc99a9d5c7693a5707c2050a8c59a8f97732e4763a56982579f8d5959ec \ No newline at end of file +924281b94d8e6ba674d6fe2f7f01da890351355a854e9e6fe623fad1180f7392 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 96494dc3a5..b201a263d1 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -141,6 +141,10 @@ proc guess_number_of_cores {} { } proc default_njob {} { + global env + if {[info exists env(NJOB)] && $env(NJOB)>=1} { + return $env(NJOB) + } set nCore [guess_number_of_cores] if {$nCore<=2} { set nHelper 1 From 609aba00d930c4909a1dfa313645847de5804b68 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Mar 2024 15:34:44 +0000 Subject: [PATCH 0216/1030] Avoid creating a co-routine incrementally for a VALUES clause that has affinities other than NONE. FossilOrigin-Name: 4229b12b327b05561dcf49b8585a66467d17d4e998b14eff65eb886f2434b53c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/insert.c | 12 ++++++++++++ test/values.test | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ae283f24ef..1eef7fdddb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correctly\sinitialize\sthe\sSrcItem.iCursor\sfield\sto\s-1\swhen\screating\sa\sco-routine\sfrom\sa\smulti-values\sVALUES\sclause. -D 2024-03-12T20:10:46.651 +C Avoid\screating\sa\sco-routine\sincrementally\sfor\sa\sVALUES\sclause\sthat\shas\saffinities\sother\sthan\sNONE. +D 2024-03-13T15:34:44.818 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 9d48439a0fff35d3c4850bc9ab3657f9d45b2800af52ef3b083e7068e32d8aa2 +F src/insert.c aef8d3dfc86116e0226a90549b5fbe8c63cda51eaca01d22f4d16e7b4e554a1b F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 042f30d897d3b2bfa54dc89a48ef6c8f6ba3ffdfd4fc35c2cc877d28a1095ce3 +F test/values.test 3f0fe0e8859306e9a5cfc800e327278762510c8d5b075d8ddce40f2d13d1405a F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 17d1f7cfabc7593d0725051b0c7c9619a23a482265f30f15ab9493fef5caeeb0 -R bc124d03e15c7cb41c52570d66be2e47 +P c32953ff6d72910815eaff29ab1b790c412e1a741d02c03c5911dda0c08e5130 +R 919d468c68cfa043ffb3132b71e307d6 U dan -Z 476dd3f62c65ec97a150406261356d2a +Z 074e750da48e105e4f7bff52672dad88 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bc849bef9a..e4e6f66f77 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c32953ff6d72910815eaff29ab1b790c412e1a741d02c03c5911dda0c08e5130 \ No newline at end of file +4229b12b327b05561dcf49b8585a66467d17d4e998b14eff65eb886f2434b53c \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 071d9aeff9..10eafaa413 100644 --- a/src/insert.c +++ b/src/insert.c @@ -593,6 +593,17 @@ static int multiValueIsConstant(ExprList *pRow){ return 1; } +static int multiValueIsConstantNoAff(ExprList *pRow){ + int ii; + if( multiValueIsConstant(pRow)==0 ) return 0; + for(ii=0; iinExpr; ii++){ + assert( pRow->a[ii].pExpr->affExpr==0 ); + if( 0!=sqlite3ExprAffinity(pRow->a[ii].pExpr) ) return 0; + } + return 1; + +} + Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ SrcItem *p; SelectDest dest; @@ -603,6 +614,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ || pParse->bHasWith || multiValueIsConstant(pRow)==0 || pLeft->pPrior + || (pLeft->pSrc->nSrc==0 && multiValueIsConstantNoAff(pLeft->pEList)==0) ){ int f = SF_Values | SF_MultiValue; if( pLeft->pPrior || pLeft->pSrc->nSrc ){ diff --git a/test/values.test b/test/values.test index 8df0e6138f..627987b43b 100644 --- a/test/values.test +++ b/test/values.test @@ -263,5 +263,9 @@ do_execsql_test 6.1 { SELECT * FROM t1, (VALUES(1), (2)) } {x 1 x 2 y 1 y 2} +do_execsql_test 6.2 { + VALUES(CAST(44 AS REAL)),(55); +} {44.0 55} + finish_test From e116fa153f752192ce96e285f7a3685549e0e2a4 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Mar 2024 15:44:31 +0000 Subject: [PATCH 0217/1030] Ensure that if a multi-row VALUES cannot be coded while being parsed, the SF_MultiValue flag is correctly set. FossilOrigin-Name: 94791824a6f04782aac6bc16c182685e2d6ebf5c688dc9f8d59e479c6fd5a40e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 9 ++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1eef7fdddb..fc5a54bd05 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\screating\sa\sco-routine\sincrementally\sfor\sa\sVALUES\sclause\sthat\shas\saffinities\sother\sthan\sNONE. -D 2024-03-13T15:34:44.818 +C Ensure\sthat\sif\sa\smulti-row\sVALUES\scannot\sbe\scoded\swhile\sbeing\sparsed,\sthe\sSF_MultiValue\sflag\sis\scorrectly\sset. +D 2024-03-13T15:44:31.439 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c aef8d3dfc86116e0226a90549b5fbe8c63cda51eaca01d22f4d16e7b4e554a1b +F src/insert.c 88f3c98b0ebbee295bb5085753bdb64ef1546ee5f0f0100b8be4f756b8a1acc6 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c32953ff6d72910815eaff29ab1b790c412e1a741d02c03c5911dda0c08e5130 -R 919d468c68cfa043ffb3132b71e307d6 +P 4229b12b327b05561dcf49b8585a66467d17d4e998b14eff65eb886f2434b53c +R 759c4fdaf4045c9f2dff7c53c191816c U dan -Z 074e750da48e105e4f7bff52672dad88 +Z 9143cafae67b08f919f57c93acfe5550 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e4e6f66f77..bd6f8334d3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4229b12b327b05561dcf49b8585a66467d17d4e998b14eff65eb886f2434b53c \ No newline at end of file +94791824a6f04782aac6bc16c182685e2d6ebf5c688dc9f8d59e479c6fd5a40e \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 10eafaa413..7303e1950a 100644 --- a/src/insert.c +++ b/src/insert.c @@ -616,13 +616,16 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ || pLeft->pPrior || (pLeft->pSrc->nSrc==0 && multiValueIsConstantNoAff(pLeft->pEList)==0) ){ + /* This row of the VALUES clause cannot be coded immediately. */ int f = SF_Values | SF_MultiValue; - if( pLeft->pPrior || pLeft->pSrc->nSrc ){ + if( pLeft->pSrc->nSrc ){ sqlite3MultiValuesEnd(pParse, pLeft); f = SF_Values; + }else if( pLeft->pPrior ){ + /* In this case set the SF_MultiValue flag only if it was set on + ** the previous Select structure. */ + f = (f & pLeft->selFlags); } - /* This VALUES clause is part of a VIEW or some other schema item. In - ** this case the co-routine cannot be coded immediately. */ pSelect = sqlite3SelectNew(pParse,pRow,0,0,0,0,0,f,0); pLeft->selFlags &= ~SF_MultiValue; if( pSelect ){ From 81a244c514a5273b8b293bcc68cf2467c9b8c771 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 13 Mar 2024 16:32:05 +0000 Subject: [PATCH 0218/1030] Minor change to the "mdevtest" and "sdevtest" in testrunner.tcl, to make it easier to add configurations in branches. FossilOrigin-Name: 9349d94e05dcf266b02afcd89f1e433cdc45f23e8536b2f3f9aa242d5d89c307 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 12 ++++++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f47cb0a280..d831726a46 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sthe\sNJOB\senvironment\svariable\sis\sa\spositive\sinteger,\sit\scauses\ntestrunner.tcl\sto\srun\sthat\smany\sjobs. -D 2024-03-13T13:43:21.042 +C Minor\schange\sto\sthe\s"mdevtest"\sand\s"sdevtest"\sin\stestrunner.tcl,\sto\smake\sit\neasier\sto\sadd\sconfigurations\sin\sbranches. +D 2024-03-13T16:32:05.539 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 48e33d99f0bad37a03b8a4064a44184de4c4ed8cd2e3174fef8d7c5f4e28ecc3 +F test/testrunner.tcl 9f198e41c0d8899d547a5beb4af0c0d512021d18da136918dd96be6a242dbab5 F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5a7b5fc99a9d5c7693a5707c2050a8c59a8f97732e4763a56982579f8d5959ec -R 407830b5c90e1eed2d3fe5c7fa3b86c4 +P 924281b94d8e6ba674d6fe2f7f01da890351355a854e9e6fe623fad1180f7392 +R 92509b8a5762b034ecb1ec5b7039a632 U drh -Z 7cb4f1a4becd0bff0730a94c93a2e20f +Z 644a950afdac6e39b6751ae1898b20f1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a1fceec15d..cd3ae2f7ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -924281b94d8e6ba674d6fe2f7f01da890351355a854e9e6fe623fad1180f7392 \ No newline at end of file +9349d94e05dcf266b02afcd89f1e433cdc45f23e8536b2f3f9aa242d5d89c307 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index b201a263d1..e8d0f76864 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -885,11 +885,19 @@ proc add_jobs_from_cmdline {patternlist} { } mdevtest { - add_devtest_jobs {All-O0 All-Debug} [lrange $patternlist 1 end] + set config_set { + All-O0 + All-Debug + } + add_devtest_jobs $config_set [lrange $patternlist 1 end] } sdevtest { - add_devtest_jobs {All-Sanitize All-Debug} [lrange $patternlist 1 end] + set config_set { + All-Sanitize + All-Debug + } + add_devtest_jobs $config_set [lrange $patternlist 1 end] } release { From 35057fb4bc78c5080fc41e81ab3f6c4f4d2a797c Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Mar 2024 17:33:45 +0000 Subject: [PATCH 0219/1030] Fix some OOM handling problems on this branch. FossilOrigin-Name: 2085c7f12a3916ec883c31795e29f2e2b6641c30ecf748cce9bff7b13b061d1f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 39 ++++++++++++++++++++------------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 80413c4c4e..a91c89a359 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\sinto\sthis\sbranch. -D 2024-03-13T15:47:52.750 +C Fix\ssome\sOOM\shandling\sproblems\son\sthis\sbranch. +D 2024-03-13T17:33:45.566 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 88f3c98b0ebbee295bb5085753bdb64ef1546ee5f0f0100b8be4f756b8a1acc6 +F src/insert.c 7d4e27871c23ad98d062dcf21509573229b41307e125d4569a89e4a489383134 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 94791824a6f04782aac6bc16c182685e2d6ebf5c688dc9f8d59e479c6fd5a40e 924281b94d8e6ba674d6fe2f7f01da890351355a854e9e6fe623fad1180f7392 -R af81f2952048774d882db6d201804b0c +P 38635651f08d42110c01d6b24f6e362e340511846294f8696af4afc795dae80d +R 3557bbe553b856781f68b1001ce502f1 U dan -Z a427b7a910e44c4f56ce4ce6ef8524f2 +Z cbe8c4c577b21b3ca1560ccfb96c64e5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4f0c6af8d4..f60296676d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38635651f08d42110c01d6b24f6e362e340511846294f8696af4afc795dae80d \ No newline at end of file +2085c7f12a3916ec883c31795e29f2e2b6641c30ecf748cce9bff7b13b061d1f \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 7303e1950a..627a4892ec 100644 --- a/src/insert.c +++ b/src/insert.c @@ -578,7 +578,7 @@ void sqlite3AutoincrementEnd(Parse *pParse){ #endif /* SQLITE_OMIT_AUTOINCREMENT */ void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ - if( pVal->pSrc->nSrc>0 ){ + if( pVal && pVal->pSrc->nSrc>0 ){ SrcItem *pItem = &pVal->pSrc->a[0]; sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->regReturn); sqlite3VdbeJumpHere(pParse->pVdbe, pItem->addrFillSub - 1); @@ -640,25 +640,24 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ Vdbe *v = sqlite3GetVdbe(pParse); Select *pRet; - if( v==0 ) return pLeft; pRet = sqlite3SelectNew(pParse, 0, 0, 0, 0, 0, 0, 0, 0); - if( pRet==0 ) return pLeft; - p = &pRet->pSrc->a[0]; - pRet->pSrc->nSrc = 1; - - p->pSelect = pLeft; - p->fg.viaCoroutine = 1; - p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; - p->regReturn = ++pParse->nMem; - p->iCursor = -1; - - sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub); - sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); - sqlite3Select(pParse, pLeft, &dest); - p->regResult = dest.iSdst; - assert( pParse->nErr || dest.iSdst>0 ); - - pLeft = pRet; + if( pRet ){ + p = &pRet->pSrc->a[0]; + pRet->pSrc->nSrc = 1; + + p->pSelect = pLeft; + p->fg.viaCoroutine = 1; + p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; + p->regReturn = ++pParse->nMem; + p->iCursor = -1; + + sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub); + sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); + sqlite3Select(pParse, pLeft, &dest); + p->regResult = dest.iSdst; + assert( pParse->nErr || dest.iSdst>0 ); + pLeft = pRet; + } }else{ p = &pLeft->pSrc->a[0]; } @@ -686,6 +685,8 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ } sqlite3SelectDelete(pParse->db, pSelect); } + }else{ + sqlite3ExprListDelete(pParse->db, pRow); } } From aa2e244e146de01c51be139cc95cec92aa7fe104 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Mar 2024 18:41:05 +0000 Subject: [PATCH 0220/1030] Remove unreachable code from this branch. FossilOrigin-Name: 657c7b4f9df53e041a33cfad00ee2f507ac09c97a2ae61164bd189d660d167da --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 53 +++++++++++++++++---------------------------------- 3 files changed, 25 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index a91c89a359..1f5591b8ed 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sOOM\shandling\sproblems\son\sthis\sbranch. -D 2024-03-13T17:33:45.566 +C Remove\sunreachable\scode\sfrom\sthis\sbranch. +D 2024-03-13T18:41:05.450 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 7d4e27871c23ad98d062dcf21509573229b41307e125d4569a89e4a489383134 +F src/insert.c 05dd5ea1b8da8a81e1132140fd4dd6d4d9e777ee282799c53cce4f3e9d7dd0ca F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38635651f08d42110c01d6b24f6e362e340511846294f8696af4afc795dae80d -R 3557bbe553b856781f68b1001ce502f1 +P 2085c7f12a3916ec883c31795e29f2e2b6641c30ecf748cce9bff7b13b061d1f +R 77c42a89dcd308559626c377320e4df2 U dan -Z cbe8c4c577b21b3ca1560ccfb96c64e5 +Z 54b19091c4c166a485c83de0a7190e37 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f60296676d..0dc187c408 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2085c7f12a3916ec883c31795e29f2e2b6641c30ecf748cce9bff7b13b061d1f \ No newline at end of file +657c7b4f9df53e041a33cfad00ee2f507ac09c97a2ae61164bd189d660d167da \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 627a4892ec..49ec5e0dc9 100644 --- a/src/insert.c +++ b/src/insert.c @@ -604,29 +604,29 @@ static int multiValueIsConstantNoAff(ExprList *pRow){ } +/* +** This function is called by the parser for the second and subsequent +** rows of a multi-row VALUES clause. +*/ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ - SrcItem *p; - SelectDest dest; - Select *pSelect = 0; - if( pParse->db->init.busy - || pParse->pNewTrigger + if( pLeft->pPrior || pParse->bHasWith + || pParse->db->init.busy || multiValueIsConstant(pRow)==0 - || pLeft->pPrior || (pLeft->pSrc->nSrc==0 && multiValueIsConstantNoAff(pLeft->pEList)==0) ){ /* This row of the VALUES clause cannot be coded immediately. */ + Select *pSelect = 0; int f = SF_Values | SF_MultiValue; if( pLeft->pSrc->nSrc ){ sqlite3MultiValuesEnd(pParse, pLeft); f = SF_Values; }else if( pLeft->pPrior ){ - /* In this case set the SF_MultiValue flag only if it was set on - ** the previous Select structure. */ + /* In this case set the SF_MultiValue flag only if it was set on pLeft */ f = (f & pLeft->selFlags); } - pSelect = sqlite3SelectNew(pParse,pRow,0,0,0,0,0,f,0); + pSelect = sqlite3SelectNew(pParse, pRow, 0, 0, 0, 0, 0, f, 0); pLeft->selFlags &= ~SF_MultiValue; if( pSelect ){ pSelect->op = TK_ALL; @@ -634,6 +634,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ pLeft = pSelect; } }else{ + SrcItem *p = 0; if( pLeft->pSrc->nSrc==0 ){ /* Co-routine has not yet been started. */ @@ -642,15 +643,14 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ pRet = sqlite3SelectNew(pParse, 0, 0, 0, 0, 0, 0, 0, 0); if( pRet ){ - p = &pRet->pSrc->a[0]; + SelectDest dest; pRet->pSrc->nSrc = 1; - + p = &pRet->pSrc->a[0]; p->pSelect = pLeft; p->fg.viaCoroutine = 1; p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; p->regReturn = ++pParse->nMem; p->iCursor = -1; - sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub); sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); sqlite3Select(pParse, pLeft, &dest); @@ -663,31 +663,14 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ } if( pParse->nErr==0 ){ - pSelect = sqlite3SelectNew(pParse, pRow, 0, 0, 0, 0, 0, SF_Values, 0); - if( pSelect ){ - if( p->pSelect->pEList->nExpr!=pSelect->pEList->nExpr ){ - sqlite3SelectWrongNumTermsError(pParse, pSelect); - }else{ - sqlite3SelectPrep(pParse, pSelect, 0); -#ifndef SQLITE_OMIT_WINDOWFUNC - if( pSelect->pWin ){ - sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); - dest.iSdst = p->regResult; - dest.nSdst = pRow->nExpr; - dest.iSDParm = p->regReturn; - sqlite3Select(pParse, pSelect, &dest); - }else -#endif - { - sqlite3ExprCodeExprList(pParse, pSelect->pEList,p->regResult,0,0); - sqlite3VdbeAddOp1(pParse->pVdbe, OP_Yield, p->regReturn); - } - } - sqlite3SelectDelete(pParse->db, pSelect); + if( p->pSelect->pEList->nExpr!=pRow->nExpr ){ + sqlite3SelectWrongNumTermsError(pParse, p->pSelect); + }else{ + sqlite3ExprCodeExprList(pParse, pRow, p->regResult, 0, 0); + sqlite3VdbeAddOp1(pParse->pVdbe, OP_Yield, p->regReturn); } - }else{ - sqlite3ExprListDelete(pParse->db, pRow); } + sqlite3ExprListDelete(pParse->db, pRow); } return pLeft; From 56be6f6c084070026fe720668f644f82fd628f8a Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Mar 2024 20:04:11 +0000 Subject: [PATCH 0221/1030] Change the way parse.y handles multi-row VALUES clauses to save a few cycles. FossilOrigin-Name: 88d5bc91a52675d2a83748b79ad50de0e9732b2afd23107627bdc604f744d275 --- manifest | 16 ++++----- manifest.uuid | 2 +- src/insert.c | 90 ++++++++++++++++++++++++++++++++++++++++-------- src/parse.y | 34 +++++++++++------- test/values.test | 13 +++++++ 5 files changed, 118 insertions(+), 37 deletions(-) diff --git a/manifest b/manifest index 1f5591b8ed..86fcabaf5e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunreachable\scode\sfrom\sthis\sbranch. -D 2024-03-13T18:41:05.450 +C Change\sthe\sway\sparse.y\shandles\smulti-row\sVALUES\sclauses\sto\ssave\sa\sfew\scycles. +D 2024-03-13T20:04:11.997 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 05dd5ea1b8da8a81e1132140fd4dd6d4d9e777ee282799c53cce4f3e9d7dd0ca +F src/insert.c 6323a2da33b5af954f914f33e06af30cce354bbd2553261a4b64e578339e498f F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -739,7 +739,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 3d022ba4c68bf8c7c4c40b3e364d7a8226c4089fc9ff7a3a95f969f8f1bec959 +F src/parse.y 2ff84e5e346974100b7ed37f01abfd148012e1ce65a6b5a72d5025258077121e F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 3f0fe0e8859306e9a5cfc800e327278762510c8d5b075d8ddce40f2d13d1405a +F test/values.test 1f0a7f8468d7f087bc4add7a95545afb15e22d5e629a18fbea73b9d76f3ef8bd F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2085c7f12a3916ec883c31795e29f2e2b6641c30ecf748cce9bff7b13b061d1f -R 77c42a89dcd308559626c377320e4df2 +P 657c7b4f9df53e041a33cfad00ee2f507ac09c97a2ae61164bd189d660d167da +R c74bcaf2a43ef6c41ceff5cdf5beeb0e U dan -Z 54b19091c4c166a485c83de0a7190e37 +Z dc10b4e059ebbb23528a1aebd608a6c4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0dc187c408..e561c09c27 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -657c7b4f9df53e041a33cfad00ee2f507ac09c97a2ae61164bd189d660d167da \ No newline at end of file +88d5bc91a52675d2a83748b79ad50de0e9732b2afd23107627bdc604f744d275 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 49ec5e0dc9..9302c10417 100644 --- a/src/insert.c +++ b/src/insert.c @@ -577,6 +577,11 @@ void sqlite3AutoincrementEnd(Parse *pParse){ # define autoIncStep(A,B,C) #endif /* SQLITE_OMIT_AUTOINCREMENT */ +/* +** If argument pVal is a Select object returned by an sqlite3MultiValues() +** that was able to use the co-routine optimization, finish coding the +** co-routine. +*/ void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ if( pVal && pVal->pSrc->nSrc>0 ){ SrcItem *pItem = &pVal->pSrc->a[0]; @@ -585,7 +590,11 @@ void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ } } -static int multiValueIsConstant(ExprList *pRow){ +/* +** Return true if all expressions in the expression-list passed as the +** only argument are constant. +*/ +static int exprListIsConstant(ExprList *pRow){ int ii; for(ii=0; iinExpr; ii++){ if( 0==sqlite3ExprIsConstant(pRow->a[ii].pExpr) ) return 0; @@ -593,9 +602,13 @@ static int multiValueIsConstant(ExprList *pRow){ return 1; } -static int multiValueIsConstantNoAff(ExprList *pRow){ +/* +** Return true if all expressions in the expression-list passed as the +** only argument are both constant and have no affinity. +*/ +static int exprListIsNoAffinity(ExprList *pRow){ int ii; - if( multiValueIsConstant(pRow)==0 ) return 0; + if( exprListIsConstant(pRow)==0 ) return 0; for(ii=0; iinExpr; ii++){ assert( pRow->a[ii].pExpr->affExpr==0 ); if( 0!=sqlite3ExprAffinity(pRow->a[ii].pExpr) ) return 0; @@ -606,17 +619,64 @@ static int multiValueIsConstantNoAff(ExprList *pRow){ /* ** This function is called by the parser for the second and subsequent -** rows of a multi-row VALUES clause. +** rows of a multi-row VALUES clause. Argument pLeft is the part of +** the VALUES clause already parsed, argument pRow is the vector of values +** for the new row. The Select object returned represents the complete +** VALUES clause, including the new row. +** +** There are two ways in which this may be achieved - by incremental +** coding of a co-routine (the "co-routine" method) or by returning a +** Select object equivalent to the following (the "UNION ALL" method): +** +** "pLeft UNION ALL SELECT pRow" +** +** If the VALUES clause contains a lot of rows, this compound Select +** object may consume a lot of memory. +** +** When the co-routine method is used, each row that will be returned +** by the VALUES clause is coded into part of a co-routine as it is +** passed to this function. The returned Select object is equivalent to: +** +** SELECT * FROM ( +** Select object to read co-routine +** ) +** +** The co-routine method is used in most cases. Exceptions are: +** +** a) If the current statement has a WITH clause. This is to avoid +** statements like: +** +** WITH cte AS ( VALUES('x'), ('y') ... ) +** SELECT * FROM cte AS a, cte AS b; +** +** This will not work, as the co-routine uses a hard-coded register +** for its OP_Yield instructions, and so it is not possible for two +** cursors to iterate through it concurrently. +** +** b) The schema is currently being parsed (i.e. the VALUES clause is part +** of a schema item like a VIEW or TRIGGER). In this case there is no VM +** being generated when parsing is taking place, and so generating +** a co-routine is not possible. +** +** c) There are non-constant expressions in the VALUES clause (e.g. +** the VALUES clause is part of a correlated sub-query). +** +** d) One or more of the values in the first row of the VALUES clause +** has an affinity (i.e. is a CAST expression). This causes problems +** because the complex rules SQLite uses (see function +** sqlite3SubqueryColumnTypes() in select.c) to determine the effective +** affinity of such a column for all rows require access to all values in +** the column simultaneously. */ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ - if( pLeft->pPrior - || pParse->bHasWith - || pParse->db->init.busy - || multiValueIsConstant(pRow)==0 - || (pLeft->pSrc->nSrc==0 && multiValueIsConstantNoAff(pLeft->pEList)==0) + if( pLeft->pPrior /* co-routine precluded by prior row */ + || pParse->bHasWith /* condition (a) above */ + || pParse->db->init.busy /* condition (b) above */ + || exprListIsConstant(pRow)==0 /* condition (c) above */ + || (pLeft->pSrc->nSrc==0 && exprListIsNoAffinity(pLeft->pEList)==0) /* (d) */ ){ - /* This row of the VALUES clause cannot be coded immediately. */ + /* The co-routine method cannot be used. Fall back to UNION ALL. */ Select *pSelect = 0; int f = SF_Values | SF_MultiValue; if( pLeft->pSrc->nSrc ){ @@ -634,14 +694,14 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ pLeft = pSelect; } }else{ - SrcItem *p = 0; + SrcItem *p = 0; /* SrcItem that reads from co-routine */ if( pLeft->pSrc->nSrc==0 ){ - /* Co-routine has not yet been started. */ + /* Co-routine has not yet been started and the special Select object + ** that accesses the co-routine has not yet been created. This block + ** does both those things. */ Vdbe *v = sqlite3GetVdbe(pParse); - Select *pRet; - - pRet = sqlite3SelectNew(pParse, 0, 0, 0, 0, 0, 0, 0, 0); + Select *pRet = sqlite3SelectNew(pParse, 0, 0, 0, 0, 0, 0, 0, 0); if( pRet ){ SelectDest dest; pRet->pSrc->nSrc = 1; diff --git a/src/parse.y b/src/parse.y index 515d512f2c..36566d28aa 100644 --- a/src/parse.y +++ b/src/parse.y @@ -562,13 +562,10 @@ cmd ::= select(X). { } %ifndef SQLITE_OMIT_CTE -select(A) ::= withkw wqlist(W) selectnowith(X). {A = attachWithToSelect(pParse,X,W);} -select(A) ::= withkw RECURSIVE wqlist(W) selectnowith(X). +select(A) ::= WITH wqlist(W) selectnowith(X). {A = attachWithToSelect(pParse,X,W);} +select(A) ::= WITH RECURSIVE wqlist(W) selectnowith(X). {A = attachWithToSelect(pParse,X,W);} -withkw ::= WITH. { - pParse->bHasWith = 1; -} %endif /* SQLITE_OMIT_CTE */ select(A) ::= selectnowith(A). { Select *p = A; @@ -626,16 +623,26 @@ oneselect(A) ::= SELECT distinct(D) selcollist(W) from(X) where_opt(Y) %endif -oneselect(A) ::= values(A). { - sqlite3MultiValuesEnd(pParse, A); -} - +// Single row VALUES clause. +// %type values {Select*} +oneselect(A) ::= values(A). %destructor values {sqlite3SelectDelete(pParse->db, $$);} values(A) ::= VALUES LP nexprlist(X) RP. { A = sqlite3SelectNew(pParse,X,0,0,0,0,0,SF_Values,0); } -values(A) ::= values(A) COMMA LP nexprlist(Y) RP. { + +// Multiple row VALUES clause. +// +%type mvalues {Select*} +oneselect(A) ::= mvalues(A). { + sqlite3MultiValuesEnd(pParse, A); +} +%destructor mvalues {sqlite3SelectDelete(pParse->db, $$);} +mvalues(A) ::= values(A) COMMA LP nexprlist(Y) RP. { + A = sqlite3MultiValues(pParse, A, Y); +} +mvalues(A) ::= mvalues(A) COMMA LP nexprlist(Y) RP. { A = sqlite3MultiValues(pParse, A, Y); } @@ -1751,16 +1758,17 @@ anylist ::= anylist ANY. with ::= . %ifndef SQLITE_OMIT_CTE -with ::= withkw wqlist(W). { sqlite3WithPush(pParse, W, 1); } -with ::= withkw RECURSIVE wqlist(W). { sqlite3WithPush(pParse, W, 1); } +with ::= WITH wqlist(W). { sqlite3WithPush(pParse, W, 1); } +with ::= WITH RECURSIVE wqlist(W). { sqlite3WithPush(pParse, W, 1); } %type wqas {u8} wqas(A) ::= AS. {A = M10d_Any;} wqas(A) ::= AS MATERIALIZED. {A = M10d_Yes;} wqas(A) ::= AS NOT MATERIALIZED. {A = M10d_No;} -wqitem(A) ::= nm(X) eidlist_opt(Y) wqas(M) LP select(Z) RP. { +wqitem(A) ::= withnm(X) eidlist_opt(Y) wqas(M) LP select(Z) RP. { A = sqlite3CteNew(pParse, &X, Y, Z, M); /*A-overwrites-X*/ } +withnm(A) ::= nm(A). {pParse->bHasWith = 1;} wqlist(A) ::= wqitem(X). { A = sqlite3WithAdd(pParse, 0, X); /*A-overwrites-X*/ } diff --git a/test/values.test b/test/values.test index 627987b43b..7c260260d0 100644 --- a/test/values.test +++ b/test/values.test @@ -267,5 +267,18 @@ do_execsql_test 6.2 { VALUES(CAST(44 AS REAL)),(55); } {44.0 55} +#------------------------------------------------------------------------ +do_execsql_test 7.1 { + WITH x1(a, b) AS ( + VALUES(1, 2), ('a', 'b') + ) + SELECT * FROM x1 one, x1 two +} { + 1 2 1 2 + 1 2 a b + a b 1 2 + a b a b +} + finish_test From a06c046e29d5024efafb1cc5a90fead8731bc96b Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Mar 2024 11:45:39 +0000 Subject: [PATCH 0222/1030] Add further tests for VALUES clauses in various contexts. FossilOrigin-Name: 973d197d9676c066a95cea77a27e36d2d7f5778283919d8cac4424d2ec952f47 --- manifest | 12 +++---- manifest.uuid | 2 +- test/values.test | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 86fcabaf5e..92b88f4681 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sway\sparse.y\shandles\smulti-row\sVALUES\sclauses\sto\ssave\sa\sfew\scycles. -D 2024-03-13T20:04:11.997 +C Add\sfurther\stests\sfor\sVALUES\sclauses\sin\svarious\scontexts. +D 2024-03-14T11:45:39.711 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 1f0a7f8468d7f087bc4add7a95545afb15e22d5e629a18fbea73b9d76f3ef8bd +F test/values.test 97a12553a3bb5bae5bdd924e1bdc53540e59d255f5072fe1f744412497ffb8e9 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 657c7b4f9df53e041a33cfad00ee2f507ac09c97a2ae61164bd189d660d167da -R c74bcaf2a43ef6c41ceff5cdf5beeb0e +P 88d5bc91a52675d2a83748b79ad50de0e9732b2afd23107627bdc604f744d275 +R ff7025814ffdce6724f42ac930401faa U dan -Z dc10b4e059ebbb23528a1aebd608a6c4 +Z a6579ddbeb44182b511c7d09df6cac16 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e561c09c27..21731dcc23 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -88d5bc91a52675d2a83748b79ad50de0e9732b2afd23107627bdc604f744d275 \ No newline at end of file +973d197d9676c066a95cea77a27e36d2d7f5778283919d8cac4424d2ec952f47 \ No newline at end of file diff --git a/test/values.test b/test/values.test index 7c260260d0..08f8193f95 100644 --- a/test/values.test +++ b/test/values.test @@ -280,5 +280,96 @@ do_execsql_test 7.1 { a b a b } +#------------------------------------------------------------------------- +reset_db + +set VVV { + ( VALUES('a', 'b'), ('c', 'd'), (123, NULL) ) +} +set VVV2 { + ( + SELECT 'a' AS column1, 'b' AS column2 + UNION ALL SELECT 'c', 'd' UNION ALL SELECT 123, NULL + ) +} + +do_execsql_test 8.0 { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES('d'), (NULL), (123) +} +foreach {tn q res} { + 1 "SELECT * FROM t1 LEFT JOIN VVV" { + d a b d c d d 123 {} + {} a b {} c d {} 123 {} + 123 a b 123 c d 123 123 {} + } + + 2 "SELECT * FROM t1 LEFT JOIN VVV ON (column1=x)" { + d {} {} + {} {} {} + 123 123 {} + } + + 3 "SELECT * FROM t1 RIGHT JOIN VVV" { + d a b d c d d 123 {} + {} a b {} c d {} 123 {} + 123 a b 123 c d 123 123 {} + } + + 4 "SELECT * FROM t1 RIGHT JOIN VVV ON (column1=x)" { + 123 123 {} + {} a b + {} c d + } + + 5 "SELECT * FROM t1 FULL OUTER JOIN VVV ON (column1=x)" { + d {} {} + {} {} {} + 123 123 {} + {} a b + {} c d + } + + 6 "SELECT count(*) FROM VVV" { 3 } + + 7 "SELECT (SELECT column1 FROM VVV)" { a } + + 8 "SELECT * FROM VVV UNION ALL SELECT * FROM VVV" { + a b c d 123 {} + a b c d 123 {} + } + + 9 "SELECT * FROM VVV INTERSECT SELECT * FROM VVV" { + 123 {} a b c d + } + + 10 "SELECT * FROM VVV eXCEPT SELECT * FROM VVV" { } + + 11 "SELECT * FROM VVV eXCEPT SELECT 'a', 'b'" { 123 {} c d } + +} { + set q1 [string map [list VVV $VVV] $q] + set q2 [string map [list VVV $VVV2] $q] + set q3 "WITH VVV AS $VVV $q" + + do_execsql_test 8.1.$tn.1 $q1 $res + do_execsql_test 8.1.$tn.2 $q2 $res + do_execsql_test 8.1.$tn.3 $q3 $res +} + +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 9.1 { + VALUES(456), (123), (NULL) UNION ALL SELECT 122 ORDER BY 1 +} { {} 122 123 456 } + +do_execsql_test 9.2 { + VALUES (1, 2), (3, 4), ( + ( SELECT column1 FROM ( VALUES (5, 6), (7, 8) ) ), + ( SELECT max(column2) FROM ( VALUES (5, 1), (7, 6) ) ) + ) +} { 1 2 3 4 5 6 } + finish_test From 5a0fd81fcec15afd0ecdcbb565b6014ad21b2c96 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 14 Mar 2024 13:18:19 +0000 Subject: [PATCH 0223/1030] JS: remove an unused function argument and some debug-related comments. No functional changes. FossilOrigin-Name: f15709430d4ba2fcf5729bc30a45dacb77102927b82cda12de0b67935b526cc0 --- ext/wasm/api/sqlite3-opfs-async-proxy.js | 9 +++------ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index 58b8bcb233..e671094f04 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -51,7 +51,7 @@ */ "use strict"; const wPost = (type,...args)=>postMessage({type, payload:args}); -const installAsyncProxy = function(self){ +const installAsyncProxy = function(){ const toss = function(...args){throw new Error(args.join(' '))}; if(globalThis.window === globalThis){ toss("This code cannot run from the main thread.", @@ -563,12 +563,9 @@ const installAsyncProxy = function(self){ return; } if( state.opfsFlags.OPFS_UNLINK_BEFORE_OPEN & opfsFlags ){ - //log("async proxy opfsFlags =",opfsFlags); try{ await hDir.removeEntry(filenamePart); - //log("Unlinked",filename,hDir,filenamePart); - } - catch(e){ + }catch(e){ /* ignoring */ //warn("Ignoring failed Unlink of",filename,":",e); } @@ -922,5 +919,5 @@ if(!globalThis.SharedArrayBuffer){ !navigator?.storage?.getDirectory){ wPost('opfs-unavailable',"Missing required OPFS APIs."); }else{ - installAsyncProxy(self); + installAsyncProxy(); } diff --git a/manifest b/manifest index d831726a46..d9e3176a98 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\schange\sto\sthe\s"mdevtest"\sand\s"sdevtest"\sin\stestrunner.tcl,\sto\smake\sit\neasier\sto\sadd\sconfigurations\sin\sbranches. -D 2024-03-13T16:32:05.539 +C JS:\sremove\san\sunused\sfunction\sargument\sand\ssome\sdebug-related\scomments.\sNo\sfunctional\schanges. +D 2024-03-14T13:18:19.313 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -610,7 +610,7 @@ F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 -F ext/wasm/api/sqlite3-opfs-async-proxy.js b4c7ce9d7f7957f243d0fbd5b6e28bac80cd3c1b738374cd0c96d89df8f2f316 +F ext/wasm/api/sqlite3-opfs-async-proxy.js 196ad83d36ca794e564044788c9d21b964679d63cad865f604da37c4afc9a285 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aaedc1bb45489b8365bff7e955a83a8d42a F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 924281b94d8e6ba674d6fe2f7f01da890351355a854e9e6fe623fad1180f7392 -R 92509b8a5762b034ecb1ec5b7039a632 -U drh -Z 644a950afdac6e39b6751ae1898b20f1 +P 9349d94e05dcf266b02afcd89f1e433cdc45f23e8536b2f3f9aa242d5d89c307 +R e2c267441183e97923991728d71c55b9 +U stephan +Z f0980170118e0dee3925f721da1aaab7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cd3ae2f7ad..19a52c5ee0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9349d94e05dcf266b02afcd89f1e433cdc45f23e8536b2f3f9aa242d5d89c307 \ No newline at end of file +f15709430d4ba2fcf5729bc30a45dacb77102927b82cda12de0b67935b526cc0 \ No newline at end of file From f0f43238248e3e6491686acf1104217face58b00 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Mar 2024 17:04:18 +0000 Subject: [PATCH 0224/1030] Avoid some OP_SCopy instructions in "INSERT INTO .. VALUES" statements that insert more than one row in cases where the VALUES clause contains a value for all columns of the table. FossilOrigin-Name: 988f0ea70cd21b3194011e0cd1ddd4990a07669e0fd9c37afa48f69698ab7212 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/insert.c | 15 +++++++++++++++ test/values.test | 17 +++++++++++++++++ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 92b88f4681..4b2722dbe6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfurther\stests\sfor\sVALUES\sclauses\sin\svarious\scontexts. -D 2024-03-14T11:45:39.711 +C Avoid\ssome\sOP_SCopy\sinstructions\sin\s"INSERT\sINTO\s..\sVALUES"\sstatements\sthat\sinsert\smore\sthan\sone\srow\sin\scases\swhere\sthe\sVALUES\sclause\scontains\sa\svalue\sfor\sall\scolumns\sof\sthe\stable. +D 2024-03-14T17:04:18.708 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 6323a2da33b5af954f914f33e06af30cce354bbd2553261a4b64e578339e498f +F src/insert.c 49b1f253248a7492595ee5b602f8b9f8f5bd25037148ca4429b24bd11d9033ed F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 97a12553a3bb5bae5bdd924e1bdc53540e59d255f5072fe1f744412497ffb8e9 +F test/values.test 9ec708b15ef0c6a63ece21b2cffcf1bc11cdc96b7fc778e62995de51609afcad F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 88d5bc91a52675d2a83748b79ad50de0e9732b2afd23107627bdc604f744d275 -R ff7025814ffdce6724f42ac930401faa +P 973d197d9676c066a95cea77a27e36d2d7f5778283919d8cac4424d2ec952f47 +R 35577c4549391d6fa401c7e1873df695 U dan -Z a6579ddbeb44182b511c7d09df6cac16 +Z 98186a481119713b14ebbdd018027220 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 21731dcc23..591f868806 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -973d197d9676c066a95cea77a27e36d2d7f5778283919d8cac4424d2ec952f47 \ No newline at end of file +988f0ea70cd21b3194011e0cd1ddd4990a07669e0fd9c37afa48f69698ab7212 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 9302c10417..3fc5f6ccdb 100644 --- a/src/insert.c +++ b/src/insert.c @@ -713,6 +713,16 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ p->iCursor = -1; sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub); sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); + + /* Allocate registers for the output of the co-routine. Do so so + ** that there are two unused registers immediately before those + ** used by the co-routine. This allows the code in sqlite3Insert() + ** to use these registers directly, instead of copying the output + ** of the co-routine to a separate array for processing. */ + dest.iSdst = pParse->nMem + 3; + dest.nSdst = pLeft->pEList->nExpr; + pParse->nMem += 2 + dest.nSdst; + sqlite3Select(pParse, pLeft, &dest); p->regResult = dest.iSdst; assert( pParse->nErr || dest.iSdst>0 ); @@ -1079,6 +1089,11 @@ void sqlite3Insert( dest.iSDParm = regYield = pItem->regReturn; regFromSelect = pItem->regResult; nColumn = pItem->pSelect->pEList->nExpr; + if( bIdListInOrder && nColumn==pTab->nCol ){ + regData = regFromSelect; + regRowid = regData - 1; + regIns = regRowid - (IsVirtual(pTab) ? 1 : 0); + } }else{ int addrTop; /* Top of the co-routine */ regYield = ++pParse->nMem; diff --git a/test/values.test b/test/values.test index 08f8193f95..51fb818a3a 100644 --- a/test/values.test +++ b/test/values.test @@ -371,5 +371,22 @@ do_execsql_test 9.2 { ) } { 1 2 3 4 5 6 } +do_execsql_test 10.1 { + CREATE TABLE a2(a, b, c DEFAULT 'xyz'); +} +do_execsql_test 10.2 { + INSERT INTO a2(a) VALUES(3),(4); +} + +#------------------------------------------------------------------------- +reset_db +ifcapable fts5 { + do_execsql_test 11.0 { + CREATE VIRTUAL TABLE ft USING fts3(x); + } + do_execsql_test 11.1 { + INSERT INTO ft VALUES('one'), ('two'); + } +} finish_test From 400992b1c4e48b10bbfb29301f5582f74e3188a3 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Mar 2024 19:01:17 +0000 Subject: [PATCH 0225/1030] Fix a problem handling "INSERT INTO ... SELECT ... UNION VALUES(...), (...)" and similar statements. FossilOrigin-Name: e8a2a8198a97046ff376bc5d38e4bc0a24fcac79f5a0dadb9d29d953a862a012 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/insert.c | 5 ++++- test/values.test | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4b2722dbe6..70d506eb4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\ssome\sOP_SCopy\sinstructions\sin\s"INSERT\sINTO\s..\sVALUES"\sstatements\sthat\sinsert\smore\sthan\sone\srow\sin\scases\swhere\sthe\sVALUES\sclause\scontains\sa\svalue\sfor\sall\scolumns\sof\sthe\stable. -D 2024-03-14T17:04:18.708 +C Fix\sa\sproblem\shandling\s"INSERT\sINTO\s...\sSELECT\s...\sUNION\sVALUES(...),\s(...)"\sand\ssimilar\sstatements. +D 2024-03-14T19:01:17.847 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 49b1f253248a7492595ee5b602f8b9f8f5bd25037148ca4429b24bd11d9033ed +F src/insert.c 609b1862f7047c13f5bf531210b6918367e3f594fddd6deb0f9a3bc90aebc1a5 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 9ec708b15ef0c6a63ece21b2cffcf1bc11cdc96b7fc778e62995de51609afcad +F test/values.test f888bc7e833cc84258497f2c1b016f04515db00f9ee2e37ea12164eb9c8f47cf F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 973d197d9676c066a95cea77a27e36d2d7f5778283919d8cac4424d2ec952f47 -R 35577c4549391d6fa401c7e1873df695 +P 988f0ea70cd21b3194011e0cd1ddd4990a07669e0fd9c37afa48f69698ab7212 +R 15823514808bcf5b8985bdd8c17c3034 U dan -Z 98186a481119713b14ebbdd018027220 +Z 3a0769f650aec425942250a7ea141fa5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 591f868806..9344f0ae07 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -988f0ea70cd21b3194011e0cd1ddd4990a07669e0fd9c37afa48f69698ab7212 \ No newline at end of file +e8a2a8198a97046ff376bc5d38e4bc0a24fcac79f5a0dadb9d29d953a862a012 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 3fc5f6ccdb..428d5c1940 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1084,7 +1084,10 @@ void sqlite3Insert( int regYield; /* Register holding co-routine entry-point */ int rc; /* Result code */ - if( pSelect->pSrc->nSrc==1 && pSelect->pSrc->a[0].fg.viaCoroutine ){ + if( pSelect->pSrc->nSrc==1 + && pSelect->pSrc->a[0].fg.viaCoroutine + && pSelect->pPrior==0 + ){ SrcItem *pItem = &pSelect->pSrc->a[0]; dest.iSDParm = regYield = pItem->regReturn; regFromSelect = pItem->regResult; diff --git a/test/values.test b/test/values.test index 51fb818a3a..3dba3dda94 100644 --- a/test/values.test +++ b/test/values.test @@ -388,5 +388,19 @@ ifcapable fts5 { INSERT INTO ft VALUES('one'), ('two'); } } + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 12.0 { + CREATE TABLE t1(a, b); +} +do_execsql_test 12.1 { + INSERT INTO t1 SELECT 1, 2 UNION ALL VALUES(3, 4), (5, 6); +} +do_execsql_test 12.2 { + SELECT * FROM t1 +} {1 2 3 4 5 6} + + finish_test From 26a3ef7557c6118a717f6555aefc7e424ffe1ca9 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Mar 2024 19:31:06 +0000 Subject: [PATCH 0226/1030] Fix a problem with ALTER TABLE and correlated multi-row VALUES clauses. FossilOrigin-Name: d543c829ef74dbd64105bd757ca660e4f02e9ce562be4f1688a701fa535351c4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/insert.c | 1 + test/altertab3.test | 27 +++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 70d506eb4c..fb7853d8f0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\shandling\s"INSERT\sINTO\s...\sSELECT\s...\sUNION\sVALUES(...),\s(...)"\sand\ssimilar\sstatements. -D 2024-03-14T19:01:17.847 +C Fix\sa\sproblem\swith\sALTER\sTABLE\sand\scorrelated\smulti-row\sVALUES\sclauses. +D 2024-03-14T19:31:06.929 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 609b1862f7047c13f5bf531210b6918367e3f594fddd6deb0f9a3bc90aebc1a5 +F src/insert.c b03721dfe0679445c635c33f137fde594e73abdd5bc042ca3c15990b339151d0 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -867,7 +867,7 @@ F test/altermalloc3.test 8040e486368403f2fdd6fc3998258b499bd4cc2f3ddbb5f8f874cd4 F test/alterqf.test 8ec03d776de9c391daa0078ea8f838903bdcfb11dfae4ba3576b48436834ccba F test/altertab.test 8a2712f9076da5012a002d0b5cc0a421398a5bf61c25bab41b77c427586a7a27 F test/altertab2.test 62597b6fd08feaba1b6bfe7d31dac6117c67e06dc9ce9c478a3abe75b5926de0 -F test/altertab3.test 6c432fbb9963e0bd6549bf1422f6861d744ee5a80cb3298564e81e556481df16 +F test/altertab3.test e167ce3b8e243b52306c1e40b13eb868f402a969513c063998593862cc643b44 F test/altertrig.test aacc980b657354fe2d3d4d3a004f07d04ccc1a93e5ef82d68a79088c274ddc6b F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 2fb21d7d64748636384e6cb8998dbf83968caf644c07fcb4f76c18f2e7ede94b @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 988f0ea70cd21b3194011e0cd1ddd4990a07669e0fd9c37afa48f69698ab7212 -R 15823514808bcf5b8985bdd8c17c3034 +P e8a2a8198a97046ff376bc5d38e4bc0a24fcac79f5a0dadb9d29d953a862a012 +R 52836dd49dafb492a11e027744e0ffa5 U dan -Z 3a0769f650aec425942250a7ea141fa5 +Z 97470bd397212d168f5c1df2d58f75c8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9344f0ae07..8c9e08af96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e8a2a8198a97046ff376bc5d38e4bc0a24fcac79f5a0dadb9d29d953a862a012 \ No newline at end of file +d543c829ef74dbd64105bd757ca660e4f02e9ce562be4f1688a701fa535351c4 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 428d5c1940..2bd846e834 100644 --- a/src/insert.c +++ b/src/insert.c @@ -675,6 +675,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ || pParse->db->init.busy /* condition (b) above */ || exprListIsConstant(pRow)==0 /* condition (c) above */ || (pLeft->pSrc->nSrc==0 && exprListIsNoAffinity(pLeft->pEList)==0) /* (d) */ + || IN_SPECIAL_PARSE ){ /* The co-routine method cannot be used. Fall back to UNION ALL. */ Select *pSelect = 0; diff --git a/test/altertab3.test b/test/altertab3.test index 5fd17f3a2f..cb6f00de48 100644 --- a/test/altertab3.test +++ b/test/altertab3.test @@ -736,4 +736,31 @@ do_execsql_test 29.7 { END} } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 30.0 { + CREATE TABLE t1(a, b); + CREATE VIEW v1 AS + SELECT ( VALUES(a), (b) ) FROM ( + SELECT a, b FROM t1 + ) + ; +} + +do_execsql_test 30.1 { + SELECT * FROM v1 +} + +do_execsql_test 30.1 { + ALTER TABLE t1 RENAME TO t2; +} +do_execsql_test 30.2 { + SELECT sql FROM sqlite_schema WHERE type='view' +} { + {CREATE VIEW v1 AS + SELECT ( VALUES(a), (b) ) FROM ( + SELECT a, b FROM "t2" + )} +} + finish_test From 932b5f457509f5141f75f5cce7a6050124d1cc8c Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 14 Mar 2024 20:39:03 +0000 Subject: [PATCH 0227/1030] Fix testcase to account for new behaviors with this branch. FossilOrigin-Name: 823e579362c05bb8accf6c3b158c5162a16eb23cf81d6021c9e3246e32583d1c --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/sqllimits1.test | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index fb7853d8f0..e6296bc3ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sALTER\sTABLE\sand\scorrelated\smulti-row\sVALUES\sclauses. -D 2024-03-14T19:31:06.929 +C Fix\stestcase\sto\saccount\sfor\snew\sbehaviors\swith\sthis\sbranch. +D 2024-03-14T20:39:03.615 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1648,7 +1648,7 @@ F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 F test/spellfix4.test 51c7c26514ade169855c66bcf130bd5acfb4d7fd090cc624645ab275ae6a41fb F test/sqldiff1.test 1b7ab4f312442c5cc6b3a5f299fa8ca051416d1dd173cb1126fd51bf64f2c3fb -F test/sqllimits1.test 5880a2f107185744ba4d93637f44c78d17706a9899a38b694d50f209735c81cc +F test/sqllimits1.test dee96a51b83ef866d06ec3c687d4c951d97b02549facc5be88c9dfcb215b98bf F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a F test/startup.c 1beb5ca66fcc0fce95c3444db9d1674f90fc605499a574ae2434dcfc10d22805 F test/stat.test 123212a20ceb496893d5254a5f6c76442ce549fdc08d1702d8288a2bbaac8408 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e8a2a8198a97046ff376bc5d38e4bc0a24fcac79f5a0dadb9d29d953a862a012 -R 52836dd49dafb492a11e027744e0ffa5 -U dan -Z 97470bd397212d168f5c1df2d58f75c8 +P d543c829ef74dbd64105bd757ca660e4f02e9ce562be4f1688a701fa535351c4 +R 9a3605a04234115bfc68cd6fc0f2125f +U drh +Z eb4b6e81254ae60e2fa77bddac123f09 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8c9e08af96..ad17c6052c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d543c829ef74dbd64105bd757ca660e4f02e9ce562be4f1688a701fa535351c4 \ No newline at end of file +823e579362c05bb8accf6c3b158c5162a16eb23cf81d6021c9e3246e32583d1c \ No newline at end of file diff --git a/test/sqllimits1.test b/test/sqllimits1.test index e9e20f40cc..14d39e6911 100644 --- a/test/sqllimits1.test +++ b/test/sqllimits1.test @@ -922,7 +922,7 @@ do_catchsql_test sqllimits1-18.1 { do_catchsql_test sqllimits1-18.2 { INSERT INTO b1 VALUES(1), (2), (3), (4), (5), (6), (7), (8), (9), (10) UNION VALUES(11); -} {1 {too many terms in compound SELECT}} +} {0 {}} #------------------------------------------------------------------------- # From 0ebd1c382cfbe4cd5fd09a9929add6b203d93d0a Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 15 Mar 2024 13:16:13 +0000 Subject: [PATCH 0228/1030] Tweaks to the func4.test test module (which tests the rarely used totype.c extension) so that it works on i586 compiled using gcc-13 with -O0. Details at [forum:/forumpost/0a7553b0f734c033|forum post 0a7553b0f734c033]. FossilOrigin-Name: d0fbe779bc2460e120da4f39063a9f4121c700f0b86d85f4311715b1366c3515 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/func4.test | 35 +++++++++++++++++++++++++++++------ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index d9e3176a98..dcb0f53470 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C JS:\sremove\san\sunused\sfunction\sargument\sand\ssome\sdebug-related\scomments.\sNo\sfunctional\schanges. -D 2024-03-14T13:18:19.313 +C Tweaks\sto\sthe\sfunc4.test\stest\smodule\s(which\stests\sthe\srarely\sused\stotype.c\nextension)\sso\sthat\sit\sworks\son\si586\scompiled\susing\sgcc-13\swith\s-O0.\s\sDetails\nat\s[forum:/forumpost/0a7553b0f734c033|forum\spost\s0a7553b0f734c033]. +D 2024-03-15T13:16:13.460 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1231,7 +1231,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test 504d202650c7940b5aa98364dd68f242df87f39f829e51074a55d79fc7bc7414 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a -F test/func4.test e8ef9b2bd6a192a213cbd5cf31a3b35e25cd6ff2fdaeea0b58d63be31b03d220 +F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5 F test/func5.test 863e6d1bd0013d09c17236f8a13ea34008dd857d87d85a13a673960e4c25d82a F test/func6.test 9cc9b1f43b435af34fe1416eb1e318c8920448ea7a6962f2121972f5215cb9b0 F test/func7.test adbfc910385a6ffd15dc47be3c619ef070c542fcb7488964badb17b2d9a4d080 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9349d94e05dcf266b02afcd89f1e433cdc45f23e8536b2f3f9aa242d5d89c307 -R e2c267441183e97923991728d71c55b9 -U stephan -Z f0980170118e0dee3925f721da1aaab7 +P f15709430d4ba2fcf5729bc30a45dacb77102927b82cda12de0b67935b526cc0 +R 5b57f46c94d279354a994dbd1c18ea0b +U drh +Z ac2ce8f2de4e984fc417325734d61778 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 19a52c5ee0..e7275106fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f15709430d4ba2fcf5729bc30a45dacb77102927b82cda12de0b67935b526cc0 \ No newline at end of file +d0fbe779bc2460e120da4f39063a9f4121c700f0b86d85f4311715b1366c3515 \ No newline at end of file diff --git a/test/func4.test b/test/func4.test index 64c7a11edc..56cc9063a1 100644 --- a/test/func4.test +++ b/test/func4.test @@ -1,4 +1,4 @@ -# 2013 March 10 +# 2023-03-10 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: @@ -9,7 +9,10 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of -# this file is testing the tointeger() and toreal() functions. +# this file is testing the tointeger() and toreal() functions that are +# part of the "totype.c" extension. This file does not test the core +# SQLite library. Failures of tests in this file are related to the +# ext/misc/totype.c extension. # # Several of the toreal() tests are disabled on platforms where floating # point precision is not high enough to represent their constant integer @@ -23,6 +26,20 @@ load_static_extension db totype set highPrecision(1) [expr \ {[db eval {SELECT tointeger(9223372036854775807 + 1);}] eq {{}}}] +set highPrecision(2) [expr \ + {[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}] + +# highPrecision(3) is only known to be false on i586 with gcc-13 and -O2. +# It is true on the exact same platform with -O0. Both results seem +# reasonable, so we'll just very the expectation accordingly. +# +set highPrecision(3) [expr \ + {[db eval {SELECT toreal(9007199254740992 + 1);}] eq {{}}}] + +if {!$highPrecision(1) || !$highPrecision(2) || !$highPrecision(3)} { + puts "NOTICE: use_long_double: [use_long_double] \ + highPrecision: $highPrecision(1) $highPrecision(2) $highPrecision(3)" +} do_execsql_test func4-1.1 { SELECT tointeger(NULL); @@ -195,8 +212,6 @@ do_execsql_test func4-1.55 { } {{}} ifcapable floatingpoint { - set highPrecision(2) [expr \ - {[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}] do_execsql_test func4-2.1 { SELECT toreal(NULL); @@ -341,10 +356,14 @@ ifcapable floatingpoint { do_execsql_test func4-2.45 { SELECT toreal(9007199254740992); } {9007199254740992.0} - if {$highPrecision(2)} { + if {$highPrecision(3)} { do_execsql_test func4-2.46 { SELECT toreal(9007199254740992 + 1); } {{}} + } else { + do_execsql_test func4-2.46 { + SELECT toreal(9007199254740992 + 1); + } {9007199254740992.0} } do_execsql_test func4-2.47 { SELECT toreal(9007199254740992 + 2); @@ -626,10 +645,14 @@ ifcapable floatingpoint { do_execsql_test func4-5.22 { SELECT tointeger(toreal(9007199254740992)); } {9007199254740992} - if {$highPrecision(2)} { + if {$highPrecision(3)} { do_execsql_test func4-5.23 { SELECT tointeger(toreal(9007199254740992 + 1)); } {{}} + } else { + do_execsql_test func4-5.23 { + SELECT tointeger(toreal(9007199254740992 + 1)); + } {9007199254740992} } do_execsql_test func4-5.24 { SELECT tointeger(toreal(9007199254740992 + 2)); From 825596481fad09348607da0b161216fa7d2ef4ae Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 15 Mar 2024 17:04:55 +0000 Subject: [PATCH 0229/1030] Fix (totally harmless) memory leaks in Lemon to avoid warnings during ASAN builds. FossilOrigin-Name: ce009205a8edc02b7d45ac01bd0e692c3d2c3ffeadb68e4f1bad20c39075e692 --- manifest | 12 +-- manifest.uuid | 2 +- tool/lemon.c | 219 +++++++++++++++++++++++++++++++++----------------- 3 files changed, 153 insertions(+), 80 deletions(-) diff --git a/manifest b/manifest index dcb0f53470..f747e5569e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tweaks\sto\sthe\sfunc4.test\stest\smodule\s(which\stests\sthe\srarely\sused\stotype.c\nextension)\sso\sthat\sit\sworks\son\si586\scompiled\susing\sgcc-13\swith\s-O0.\s\sDetails\nat\s[forum:/forumpost/0a7553b0f734c033|forum\spost\s0a7553b0f734c033]. -D 2024-03-15T13:16:13.460 +C Fix\s(totally\sharmless)\smemory\sleaks\sin\sLemon\sto\savoid\swarnings\sduring\sASAN\nbuilds. +D 2024-03-15T17:04:55.912 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2088,7 +2088,7 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c 7f264d5d06450f929a20fa63a1b7e8f2df47dfaa6d7f80e4afef3639157497a4 +F tool/lemon.c 2eaee61479f9b97056950741c8f671a13281c819b94246698264a322360319a9 F tool/lempar.c e6b649778e5c027c8365ff01d7ef39297cd7285fa1f881cce31792689541e79f F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f15709430d4ba2fcf5729bc30a45dacb77102927b82cda12de0b67935b526cc0 -R 5b57f46c94d279354a994dbd1c18ea0b +P d0fbe779bc2460e120da4f39063a9f4121c700f0b86d85f4311715b1366c3515 +R 23ce63f7e666b66fe29613cc12e69c85 U drh -Z ac2ce8f2de4e984fc417325734d61778 +Z 6317df74aefa1b57098e3d6e2401e93c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e7275106fa..d62b446349 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0fbe779bc2460e120da4f39063a9f4121c700f0b86d85f4311715b1366c3515 \ No newline at end of file +ce009205a8edc02b7d45ac01bd0e692c3d2c3ffeadb68e4f1bad20c39075e692 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 0239b2d86f..06b9109a1d 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -59,6 +59,82 @@ static char *msort(char*,char**,int(*)(const char*,const char*)); */ #define lemonStrlen(X) ((int)strlen(X)) +/* +** Header on the linked list of memory allocations. +*/ +typedef struct MemChunk MemChunk; +struct MemChunk { + MemChunk *pNext; + size_t sz; + /* Actually memory follows */ +}; + +/* +** Global linked list of all memory allocations. +*/ +static MemChunk *memChunkList = 0; + +/* +** Wrappers around malloc(), calloc(), realloc() and free(). +** +** All memory allocations are kept on a doubly-linked list. The +** lemon_free_all() function can be called prior to exit to clean +** up any memory leaks. +** +** This is not necessary. But compilers and getting increasingly +** fussy about memory leaks, even in command-line programs like Lemon +** where they do not matter. So this code is provided to hush the +** warnings. +*/ +static void *lemon_malloc(size_t nByte){ + MemChunk *p; + if( nByte<0 ) return 0; + p = malloc( nByte + sizeof(MemChunk) ); + if( p==0 ){ + fprintf(stderr, "Out of memory. Failed to allocate %lld bytes.\n", + (long long int)nByte); + exit(1); + } + p->pNext = memChunkList; + p->sz = nByte; + memChunkList = p; + return (void*)&p[1]; +} +static void *lemon_calloc(size_t nElem, size_t sz){ + void *p = lemon_malloc(nElem*sz); + memset(p, 0, nElem*sz); + return p; +} +static void lemon_free(void *pOld){ + if( pOld ){ + MemChunk *p = (MemChunk*)pOld; + p--; + memset(pOld, 0, p->sz); + } +} +static void *lemon_realloc(void *pOld, size_t nNew){ + void *pNew; + MemChunk *p; + if( pOld==0 ) return lemon_malloc(nNew); + p = (MemChunk*)pOld; + p--; + if( p->sz>=nNew ) return pOld; + pNew = lemon_malloc( nNew ); + memcpy(pNew, pOld, p->sz); + return pNew; +} + +/* Free all outstanding memory allocations. +** Do this right before exiting. +*/ +static void lemon_free_all(void){ + while( memChunkList ){ + MemChunk *pNext = memChunkList->pNext; + free( memChunkList ); + memChunkList = pNext; + } +} + /* ** Compilers are starting to complain about the use of sprintf() and strcpy(), ** saying they are unsafe. So we define our own versions of those routines too. @@ -497,7 +573,7 @@ static struct action *Action_new(void){ if( actionfreelist==0 ){ int i; int amt = 100; - actionfreelist = (struct action *)calloc(amt, sizeof(struct action)); + actionfreelist = (struct action *)lemon_calloc(amt, sizeof(struct action)); if( actionfreelist==0 ){ fprintf(stderr,"Unable to allocate memory for a new parser action."); exit(1); @@ -616,14 +692,14 @@ struct acttab { /* Free all memory associated with the given acttab */ void acttab_free(acttab *p){ - free( p->aAction ); - free( p->aLookahead ); - free( p ); + lemon_free( p->aAction ); + lemon_free( p->aLookahead ); + lemon_free( p ); } /* Allocate a new acttab structure */ acttab *acttab_alloc(int nsymbol, int nterminal){ - acttab *p = (acttab *) calloc( 1, sizeof(*p) ); + acttab *p = (acttab *) lemon_calloc( 1, sizeof(*p) ); if( p==0 ){ fprintf(stderr,"Unable to allocate memory for a new acttab."); exit(1); @@ -642,7 +718,7 @@ acttab *acttab_alloc(int nsymbol, int nterminal){ void acttab_action(acttab *p, int lookahead, int action){ if( p->nLookahead>=p->nLookaheadAlloc ){ p->nLookaheadAlloc += 25; - p->aLookahead = (struct lookahead_action *) realloc( p->aLookahead, + p->aLookahead = (struct lookahead_action *) lemon_realloc( p->aLookahead, sizeof(p->aLookahead[0])*p->nLookaheadAlloc ); if( p->aLookahead==0 ){ fprintf(stderr,"malloc failed\n"); @@ -692,7 +768,7 @@ int acttab_insert(acttab *p, int makeItSafe){ if( p->nAction + n >= p->nActionAlloc ){ int oldAlloc = p->nActionAlloc; p->nActionAlloc = p->nAction + n + p->nActionAlloc + 20; - p->aAction = (struct lookahead_action *) realloc( p->aAction, + p->aAction = (struct lookahead_action *) lemon_realloc( p->aAction, sizeof(p->aAction[0])*p->nActionAlloc); if( p->aAction==0 ){ fprintf(stderr,"malloc failed\n"); @@ -1314,7 +1390,7 @@ static struct config **basisend = 0; /* End of list of basis configs */ /* Return a pointer to a new configuration */ PRIVATE struct config *newconfig(void){ - return (struct config*)calloc(1, sizeof(struct config)); + return (struct config*)lemon_calloc(1, sizeof(struct config)); } /* The configuration "old" is no longer used */ @@ -1530,19 +1606,19 @@ static char *bDefineUsed = 0; /* True for every -D macro actually used */ static void handle_D_option(char *z){ char **paz; nDefine++; - azDefine = (char **) realloc(azDefine, sizeof(azDefine[0])*nDefine); + azDefine = (char **) lemon_realloc(azDefine, sizeof(azDefine[0])*nDefine); if( azDefine==0 ){ fprintf(stderr,"out of memory\n"); exit(1); } - bDefineUsed = (char*)realloc(bDefineUsed, nDefine); + bDefineUsed = (char*)lemon_realloc(bDefineUsed, nDefine); if( bDefineUsed==0 ){ fprintf(stderr,"out of memory\n"); exit(1); } bDefineUsed[nDefine-1] = 0; paz = &azDefine[nDefine-1]; - *paz = (char *) malloc( lemonStrlen(z)+1 ); + *paz = (char *) lemon_malloc( lemonStrlen(z)+1 ); if( *paz==0 ){ fprintf(stderr,"out of memory\n"); exit(1); @@ -1556,7 +1632,7 @@ static void handle_D_option(char *z){ */ static char *outputDir = NULL; static void handle_d_option(char *z){ - outputDir = (char *) malloc( lemonStrlen(z)+1 ); + outputDir = (char *) lemon_malloc( lemonStrlen(z)+1 ); if( outputDir==0 ){ fprintf(stderr,"out of memory\n"); exit(1); @@ -1566,7 +1642,7 @@ static void handle_d_option(char *z){ static char *user_templatename = NULL; static void handle_T_option(char *z){ - user_templatename = (char *) malloc( lemonStrlen(z)+1 ); + user_templatename = (char *) lemon_malloc( lemonStrlen(z)+1 ); if( user_templatename==0 ){ memory_error(); } @@ -1803,6 +1879,7 @@ int main(int argc, char **argv){ /* return 0 on success, 1 on failure. */ exitcode = ((lem.errorcnt > 0) || (lem.nconflict > 0)) ? 1 : 0; + lemon_free_all(); exit(exitcode); return (exitcode); } @@ -2391,7 +2468,7 @@ static void parseonetoken(struct pstate *psp) case IN_RHS: if( x[0]=='.' ){ struct rule *rp; - rp = (struct rule *)calloc( sizeof(struct rule) + + rp = (struct rule *)lemon_calloc( sizeof(struct rule) + sizeof(struct symbol*)*psp->nrhs + sizeof(char*)*psp->nrhs, 1); if( rp==0 ){ ErrorMsg(psp->filename,psp->tokenlineno, @@ -2443,17 +2520,17 @@ static void parseonetoken(struct pstate *psp) struct symbol *msp = psp->rhs[psp->nrhs-1]; if( msp->type!=MULTITERMINAL ){ struct symbol *origsp = msp; - msp = (struct symbol *) calloc(1,sizeof(*msp)); + msp = (struct symbol *) lemon_calloc(1,sizeof(*msp)); memset(msp, 0, sizeof(*msp)); msp->type = MULTITERMINAL; msp->nsubsym = 1; - msp->subsym = (struct symbol **) calloc(1,sizeof(struct symbol*)); + msp->subsym = (struct symbol**)lemon_calloc(1,sizeof(struct symbol*)); msp->subsym[0] = origsp; msp->name = origsp->name; psp->rhs[psp->nrhs-1] = msp; } msp->nsubsym++; - msp->subsym = (struct symbol **) realloc(msp->subsym, + msp->subsym = (struct symbol **) lemon_realloc(msp->subsym, sizeof(struct symbol*)*msp->nsubsym); msp->subsym[msp->nsubsym-1] = Symbol_new(&x[1]); if( ISLOWER(x[1]) || ISLOWER(msp->subsym[0]->name[0]) ){ @@ -2669,7 +2746,7 @@ static void parseonetoken(struct pstate *psp) nLine = lemonStrlen(zLine); n += nLine + lemonStrlen(psp->filename) + nBack; } - *psp->declargslot = (char *) realloc(*psp->declargslot, n); + *psp->declargslot = (char *) lemon_realloc(*psp->declargslot, n); zBuf = *psp->declargslot + nOld; if( addLineMacro ){ if( nOld && zBuf[-1]!='\n' ){ @@ -2783,7 +2860,7 @@ static void parseonetoken(struct pstate *psp) }else if( ISUPPER(x[0]) || ((x[0]=='|' || x[0]=='/') && ISUPPER(x[1])) ){ struct symbol *msp = psp->tkclass; msp->nsubsym++; - msp->subsym = (struct symbol **) realloc(msp->subsym, + msp->subsym = (struct symbol **) lemon_realloc(msp->subsym, sizeof(struct symbol*)*msp->nsubsym); if( !ISUPPER(x[0]) ) x++; msp->subsym[msp->nsubsym-1] = Symbol_new(x); @@ -2998,10 +3075,10 @@ void Parse(struct lemon *gp) fseek(fp,0,2); filesize = ftell(fp); rewind(fp); - filebuf = (char *)malloc( filesize+1 ); + filebuf = (char *)lemon_malloc( filesize+1 ); if( filesize>100000000 || filebuf==0 ){ ErrorMsg(ps.filename,0,"Input file too large."); - free(filebuf); + lemon_free(filebuf); gp->errorcnt++; fclose(fp); return; @@ -3009,7 +3086,7 @@ void Parse(struct lemon *gp) if( fread(filebuf,1,filesize,fp)!=filesize ){ ErrorMsg(ps.filename,0,"Can't read in all %d bytes of this file.", filesize); - free(filebuf); + lemon_free(filebuf); gp->errorcnt++; fclose(fp); return; @@ -3121,7 +3198,7 @@ void Parse(struct lemon *gp) *cp = (char)c; /* Restore the buffer */ cp = nextcp; } - free(filebuf); /* Release the buffer after parsing */ + lemon_free(filebuf); /* Release the buffer after parsing */ gp->rule = ps.firstrule; gp->errorcnt = ps.errorcnt; } @@ -3139,7 +3216,7 @@ struct plink *Plink_new(void){ if( plink_freelist==0 ){ int i; int amt = 100; - plink_freelist = (struct plink *)calloc( amt, sizeof(struct plink) ); + plink_freelist = (struct plink *)lemon_calloc( amt, sizeof(struct plink) ); if( plink_freelist==0 ){ fprintf(stderr, "Unable to allocate memory for a new follow-set propagation link.\n"); @@ -3192,9 +3269,7 @@ void Plink_delete(struct plink *plp) ** Procedures for generating reports and tables in the LEMON parser generator. */ -/* Generate a filename with the given suffix. Space to hold the -** name comes from malloc() and must be freed by the calling -** function. +/* Generate a filename with the given suffix. */ PRIVATE char *file_makename(struct lemon *lemp, const char *suffix) { @@ -3211,7 +3286,7 @@ PRIVATE char *file_makename(struct lemon *lemp, const char *suffix) sz += lemonStrlen(suffix); if( outputDir ) sz += lemonStrlen(outputDir) + 1; sz += 5; - name = (char*)malloc( sz ); + name = (char*)lemon_malloc( sz ); if( name==0 ){ fprintf(stderr,"Can't allocate space for a filename.\n"); exit(1); @@ -3238,7 +3313,7 @@ PRIVATE FILE *file_open( ){ FILE *fp; - if( lemp->outname ) free(lemp->outname); + if( lemp->outname ) lemon_free(lemp->outname); lemp->outname = file_makename(lemp, suffix); fp = fopen(lemp->outname,mode); if( fp==0 && *mode=='w' ){ @@ -3554,14 +3629,14 @@ PRIVATE char *pathsearch(char *argv0, char *name, int modemask) if( cp ){ c = *cp; *cp = 0; - path = (char *)malloc( lemonStrlen(argv0) + lemonStrlen(name) + 2 ); + path = (char *)lemon_malloc( lemonStrlen(argv0) + lemonStrlen(name) + 2 ); if( path ) lemon_sprintf(path,"%s/%s",argv0,name); *cp = c; }else{ pathlist = getenv("PATH"); if( pathlist==0 ) pathlist = ".:/bin:/usr/bin"; - pathbuf = (char *) malloc( lemonStrlen(pathlist) + 1 ); - path = (char *)malloc( lemonStrlen(pathlist)+lemonStrlen(name)+2 ); + pathbuf = (char *) lemon_malloc( lemonStrlen(pathlist) + 1 ); + path = (char *)lemon_malloc( lemonStrlen(pathlist)+lemonStrlen(name)+2 ); if( (pathbuf != 0) && (path!=0) ){ pathbufptr = pathbuf; lemon_strcpy(pathbuf, pathlist); @@ -3577,7 +3652,7 @@ PRIVATE char *pathsearch(char *argv0, char *name, int modemask) if( access(path,modemask)==0 ) break; } } - free(pathbufptr); + lemon_free(pathbufptr); } return path; } @@ -3708,7 +3783,7 @@ PRIVATE FILE *tplt_open(struct lemon *lemp) fprintf(stderr,"Can't open the template file \"%s\".\n",tpltname); lemp->errorcnt++; } - free(toFree); + lemon_free(toFree); return in; } @@ -3837,7 +3912,7 @@ PRIVATE char *append_str(const char *zText, int n, int p1, int p2){ } if( (int) (n+sizeof(zInt)*2+used) >= alloced ){ alloced = n + sizeof(zInt)*2 + used + 200; - z = (char *) realloc(z, alloced); + z = (char *) lemon_realloc(z, alloced); } if( z==0 ) return empty; while( n-- > 0 ){ @@ -4127,7 +4202,7 @@ void print_stack_union( /* Allocate and initialize types[] and allocate stddt[] */ arraysize = lemp->nsymbol * 2; - types = (char**)calloc( arraysize, sizeof(char*) ); + types = (char**)lemon_calloc( arraysize, sizeof(char*) ); if( types==0 ){ fprintf(stderr,"Out of memory.\n"); exit(1); @@ -4144,7 +4219,7 @@ void print_stack_union( len = lemonStrlen(sp->datatype); if( len>maxdtlength ) maxdtlength = len; } - stddt = (char*)malloc( maxdtlength*2 + 1 ); + stddt = (char*)lemon_malloc( maxdtlength*2 + 1 ); if( stddt==0 ){ fprintf(stderr,"Out of memory.\n"); exit(1); @@ -4193,7 +4268,7 @@ void print_stack_union( } if( types[hash]==0 ){ sp->dtnum = hash + 1; - types[hash] = (char*)malloc( lemonStrlen(stddt)+1 ); + types[hash] = (char*)lemon_malloc( lemonStrlen(stddt)+1 ); if( types[hash]==0 ){ fprintf(stderr,"Out of memory.\n"); exit(1); @@ -4215,13 +4290,13 @@ void print_stack_union( for(i=0; ierrsym && lemp->errsym->useCnt ){ fprintf(out," int yy%d;\n",lemp->errsym->dtnum); lineno++; } - free(stddt); - free(types); + lemon_free(stddt); + lemon_free(types); fprintf(out,"} YYMINORTYPE;\n"); lineno++; *plineno = lineno; } @@ -4450,7 +4525,7 @@ void ReportTable( if( mhflag ){ char *incName = file_makename(lemp, ".h"); fprintf(out,"#include \"%s\"\n", incName); lineno++; - free(incName); + lemon_free(incName); } tplt_xfer(lemp->name,in,out,&lineno); @@ -4557,7 +4632,7 @@ void ReportTable( ** table must be computed before generating the YYNSTATE macro because ** we need to know how many states can be eliminated. */ - ax = (struct axset *) calloc(lemp->nxstate*2, sizeof(ax[0])); + ax = (struct axset *) lemon_calloc(lemp->nxstate*2, sizeof(ax[0])); if( ax==0 ){ fprintf(stderr,"malloc failed\n"); exit(1); @@ -4615,7 +4690,7 @@ void ReportTable( } #endif } - free(ax); + lemon_free(ax); /* Mark rules that are actually used for reduce actions after all ** optimizations have been applied @@ -5241,7 +5316,7 @@ void SetSize(int n) /* Allocate a new set */ char *SetNew(void){ char *s; - s = (char*)calloc( size, 1); + s = (char*)lemon_calloc( size, 1); if( s==0 ){ memory_error(); } @@ -5251,7 +5326,7 @@ char *SetNew(void){ /* Deallocate a set */ void SetFree(char *s) { - free(s); + lemon_free(s); } /* Add a new element to the set. Return TRUE if the element was added @@ -5310,7 +5385,7 @@ const char *Strsafe(const char *y) if( y==0 ) return 0; z = Strsafe_find(y); - if( z==0 && (cpy=(char *)malloc( lemonStrlen(y)+1 ))!=0 ){ + if( z==0 && (cpy=(char *)lemon_malloc( lemonStrlen(y)+1 ))!=0 ){ lemon_strcpy(cpy,y); z = cpy; Strsafe_insert(z); @@ -5346,13 +5421,13 @@ static struct s_x1 *x1a; /* Allocate a new associative array */ void Strsafe_init(void){ if( x1a ) return; - x1a = (struct s_x1*)malloc( sizeof(struct s_x1) ); + x1a = (struct s_x1*)lemon_malloc( sizeof(struct s_x1) ); if( x1a ){ x1a->size = 1024; x1a->count = 0; - x1a->tbl = (x1node*)calloc(1024, sizeof(x1node) + sizeof(x1node*)); + x1a->tbl = (x1node*)lemon_calloc(1024, sizeof(x1node) + sizeof(x1node*)); if( x1a->tbl==0 ){ - free(x1a); + lemon_free(x1a); x1a = 0; }else{ int i; @@ -5387,7 +5462,7 @@ int Strsafe_insert(const char *data) struct s_x1 array; array.size = arrSize = x1a->size*2; array.count = x1a->count; - array.tbl = (x1node*)calloc(arrSize, sizeof(x1node) + sizeof(x1node*)); + array.tbl = (x1node*)lemon_calloc(arrSize, sizeof(x1node)+sizeof(x1node*)); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ array.ht = (x1node**)&(array.tbl[arrSize]); for(i=0; ifrom = &(array.ht[h]); array.ht[h] = newnp; } - /* free(x1a->tbl); // This program was originally for 16-bit machines. + /* lemon_free(x1a->tbl); // This program was originally for 16-bit machines. ** Don't worry about freeing memory on modern platforms. */ *x1a = array; } @@ -5443,7 +5518,7 @@ struct symbol *Symbol_new(const char *x) sp = Symbol_find(x); if( sp==0 ){ - sp = (struct symbol *)calloc(1, sizeof(struct symbol) ); + sp = (struct symbol *)lemon_calloc(1, sizeof(struct symbol) ); MemoryCheck(sp); sp->name = Strsafe(x); sp->type = ISUPPER(*x) ? TERMINAL : NONTERMINAL; @@ -5514,13 +5589,13 @@ static struct s_x2 *x2a; /* Allocate a new associative array */ void Symbol_init(void){ if( x2a ) return; - x2a = (struct s_x2*)malloc( sizeof(struct s_x2) ); + x2a = (struct s_x2*)lemon_malloc( sizeof(struct s_x2) ); if( x2a ){ x2a->size = 128; x2a->count = 0; - x2a->tbl = (x2node*)calloc(128, sizeof(x2node) + sizeof(x2node*)); + x2a->tbl = (x2node*)lemon_calloc(128, sizeof(x2node) + sizeof(x2node*)); if( x2a->tbl==0 ){ - free(x2a); + lemon_free(x2a); x2a = 0; }else{ int i; @@ -5555,7 +5630,7 @@ int Symbol_insert(struct symbol *data, const char *key) struct s_x2 array; array.size = arrSize = x2a->size*2; array.count = x2a->count; - array.tbl = (x2node*)calloc(arrSize, sizeof(x2node) + sizeof(x2node*)); + array.tbl = (x2node*)lemon_calloc(arrSize, sizeof(x2node)+sizeof(x2node*)); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ array.ht = (x2node**)&(array.tbl[arrSize]); for(i=0; ifrom = &(array.ht[h]); array.ht[h] = newnp; } - /* free(x2a->tbl); // This program was originally written for 16-bit + /* lemon_free(x2a->tbl); // This program was originally written for 16-bit ** machines. Don't worry about freeing this trivial amount of memory ** on modern platforms. Just leak it. */ *x2a = array; @@ -5632,7 +5707,7 @@ struct symbol **Symbol_arrayof() int i,arrSize; if( x2a==0 ) return 0; arrSize = x2a->count; - array = (struct symbol **)calloc(arrSize, sizeof(struct symbol *)); + array = (struct symbol **)lemon_calloc(arrSize, sizeof(struct symbol *)); if( array ){ for(i=0; itbl[i].data; } @@ -5680,7 +5755,7 @@ PRIVATE unsigned statehash(struct config *a) struct state *State_new() { struct state *newstate; - newstate = (struct state *)calloc(1, sizeof(struct state) ); + newstate = (struct state *)lemon_calloc(1, sizeof(struct state) ); MemoryCheck(newstate); return newstate; } @@ -5713,13 +5788,13 @@ static struct s_x3 *x3a; /* Allocate a new associative array */ void State_init(void){ if( x3a ) return; - x3a = (struct s_x3*)malloc( sizeof(struct s_x3) ); + x3a = (struct s_x3*)lemon_malloc( sizeof(struct s_x3) ); if( x3a ){ x3a->size = 128; x3a->count = 0; - x3a->tbl = (x3node*)calloc(128, sizeof(x3node) + sizeof(x3node*)); + x3a->tbl = (x3node*)lemon_calloc(128, sizeof(x3node) + sizeof(x3node*)); if( x3a->tbl==0 ){ - free(x3a); + lemon_free(x3a); x3a = 0; }else{ int i; @@ -5754,7 +5829,7 @@ int State_insert(struct state *data, struct config *key) struct s_x3 array; array.size = arrSize = x3a->size*2; array.count = x3a->count; - array.tbl = (x3node*)calloc(arrSize, sizeof(x3node) + sizeof(x3node*)); + array.tbl = (x3node*)lemon_calloc(arrSize, sizeof(x3node)+sizeof(x3node*)); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ array.ht = (x3node**)&(array.tbl[arrSize]); for(i=0; ifrom = &(array.ht[h]); array.ht[h] = newnp; } - free(x3a->tbl); + lemon_free(x3a->tbl); *x3a = array; } /* Insert the new data */ @@ -5811,7 +5886,7 @@ struct state **State_arrayof(void) int i,arrSize; if( x3a==0 ) return 0; arrSize = x3a->count; - array = (struct state **)calloc(arrSize, sizeof(struct state *)); + array = (struct state **)lemon_calloc(arrSize, sizeof(struct state *)); if( array ){ for(i=0; itbl[i].data; } @@ -5853,13 +5928,13 @@ static struct s_x4 *x4a; /* Allocate a new associative array */ void Configtable_init(void){ if( x4a ) return; - x4a = (struct s_x4*)malloc( sizeof(struct s_x4) ); + x4a = (struct s_x4*)lemon_malloc( sizeof(struct s_x4) ); if( x4a ){ x4a->size = 64; x4a->count = 0; - x4a->tbl = (x4node*)calloc(64, sizeof(x4node) + sizeof(x4node*)); + x4a->tbl = (x4node*)lemon_calloc(64, sizeof(x4node) + sizeof(x4node*)); if( x4a->tbl==0 ){ - free(x4a); + lemon_free(x4a); x4a = 0; }else{ int i; @@ -5894,7 +5969,8 @@ int Configtable_insert(struct config *data) struct s_x4 array; array.size = arrSize = x4a->size*2; array.count = x4a->count; - array.tbl = (x4node*)calloc(arrSize, sizeof(x4node) + sizeof(x4node*)); + array.tbl = (x4node*)lemon_calloc(arrSize, + sizeof(x4node) + sizeof(x4node*)); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ array.ht = (x4node**)&(array.tbl[arrSize]); for(i=0; ifrom = &(array.ht[h]); array.ht[h] = newnp; } - /* free(x4a->tbl); // This code was originall written for 16-bit machines. - ** on modern machines, don't worry about freeing this trival amount of - ** memory. */ *x4a = array; } /* Insert the new data */ From d31fc6e9cfd4d25d2fdea2f5aa41fee0a1d5e80c Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 15 Mar 2024 17:57:58 +0000 Subject: [PATCH 0230/1030] New options for testrunner.tcl: --stop-on-error and --stop-on-coredump. FossilOrigin-Name: 82035b9cfd28ef6b0ecc6f469f03d2b001189aa4925147cdb784b6b1964eb3b2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index f747e5569e..345be73124 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\s(totally\sharmless)\smemory\sleaks\sin\sLemon\sto\savoid\swarnings\sduring\sASAN\nbuilds. -D 2024-03-15T17:04:55.912 +C New\soptions\sfor\stestrunner.tcl:\s\s--stop-on-error\sand\s--stop-on-coredump. +D 2024-03-15T17:57:58.502 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1687,7 +1687,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 9f198e41c0d8899d547a5beb4af0c0d512021d18da136918dd96be6a242dbab5 +F test/testrunner.tcl 01bc3b5bc900dc73b076180727eb2869dc61426b1ab95ac2f42def5d1f3d407e F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2177,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d0fbe779bc2460e120da4f39063a9f4121c700f0b86d85f4311715b1366c3515 -R 23ce63f7e666b66fe29613cc12e69c85 +P ce009205a8edc02b7d45ac01bd0e692c3d2c3ffeadb68e4f1bad20c39075e692 +R 6f65d3d8f9136f71ba32b06be27a8871 U drh -Z 6317df74aefa1b57098e3d6e2401e93c +Z 3ec0c84d38eb2a8a3a9b0c26445e8068 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d62b446349..39c5e3d4e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ce009205a8edc02b7d45ac01bd0e692c3d2c3ffeadb68e4f1bad20c39075e692 \ No newline at end of file +82035b9cfd28ef6b0ecc6f469f03d2b001189aa4925147cdb784b6b1964eb3b2 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index e8d0f76864..e8570ddf19 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -64,6 +64,8 @@ Usage: --dryrun --explain --jobs NUMBER-OF-JOBS + --stop-on-coredump + --stop-on-error --zipvfs ZIPVFS-SOURCE-DIR Special values for PERMUTATION that work with plain tclsh: @@ -172,6 +174,8 @@ set TRG(zipvfs) "" ;# -zipvfs option, if any set TRG(buildonly) 0 ;# True if --buildonly option set TRG(dryrun) 0 ;# True if --dryrun option set TRG(explain) 0 ;# True for the --explain option +set TRG(stopOnError) 0 ;# Stop running at first failure +set TRG(stopOnCore) 0 ;# Stop on a core-dump switch -nocase -glob -- $tcl_platform(os) { *darwin* { @@ -468,6 +472,10 @@ for {set ii 0} {$ii < [llength $argv]} {incr ii} { set TRG(dryrun) 1 } elseif {($n>2 && [string match "$a*" --explain]) || $a=="-e"} { set TRG(explain) 1 + } elseif {[string match "$a*" --stop-on-error]} { + set TRG(stopOnError) 1 + } elseif {[string match "$a*" --stop-on-coredump]} { + set TRG(stopOnCore) 1 } else { usage } @@ -992,6 +1000,14 @@ proc script_input_ready {fd iJob jobid} { } puts "FAILED: $job(displayname) ($iJob)" set state "failed" + if {$TRG(stopOnError)} { + puts "OUTPUT: $O($iJob)" + exit 1 + } + if {$TRG(stopOnCore) && [string first {core dumped} $O($iJob)]>0} { + puts "OUTPUT: $O($iJob)" + exit 1 + } } set tm [clock_milliseconds] From f696591dd45bea11c24d9f219e6f17161a329934 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 16 Mar 2024 13:18:48 +0000 Subject: [PATCH 0231/1030] Enhance the sqlite3ExprIsConstant() function so that it recognizes constant functions. So far the enhancement only applies to the multi-row VALUES clause, but it could possibly be applied in many other places. FossilOrigin-Name: c9e0488c6c0135932b6e76b0f3f3acd69ef65327e0a54daa59777f35da1aef26 --- manifest | 29 ++++++++++--------- manifest.uuid | 2 +- src/expr.c | 74 +++++++++++++++++++++++++++++++++++++++++++++---- src/insert.c | 19 +++++++------ src/parse.y | 2 +- src/select.c | 6 ++-- src/sqliteInt.h | 2 +- src/where.c | 10 +++---- src/whereexpr.c | 2 +- src/window.c | 2 +- 10 files changed, 108 insertions(+), 40 deletions(-) diff --git a/manifest b/manifest index e6296bc3ee..5926610ec1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stestcase\sto\saccount\sfor\snew\sbehaviors\swith\sthis\sbranch. -D 2024-03-14T20:39:03.615 +C Enhance\sthe\ssqlite3ExprIsConstant()\sfunction\sso\sthat\sit\srecognizes\nconstant\sfunctions.\s\sSo\sfar\sthe\senhancement\sonly\sapplies\sto\sthe\smulti-row\nVALUES\sclause,\sbut\sit\scould\spossibly\sbe\sapplied\sin\smany\sother\splaces. +D 2024-03-16T13:18:48.351 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 7d0280860f8683fa1e81202304a5107f493fe9bd52be6590d0d0d6c3564c7a07 +F src/expr.c 023e84202023d58bc10cb1f7a4dcc7fe1342e11daa054ea1024e8b78144bd589 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c b03721dfe0679445c635c33f137fde594e73abdd5bc042ca3c15990b339151d0 +F src/insert.c e28426630ebbac5763d5802099164ad24fbf46fea79d48a8313117a64b950871 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -739,7 +739,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 2ff84e5e346974100b7ed37f01abfd148012e1ce65a6b5a72d5025258077121e +F src/parse.y 004faaa6b6d6a88d9ec5e535281d7a203e1a03e83617ef8249f40e18bda23dc4 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -750,12 +750,12 @@ F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 2a12c6ed8131db7c49b6f8141c3420cab825cfc6bd222d347fa1382f36b174b7 +F src/select.c 4a3abb346d184a5b1f4f10f10da22465ff18db170099c2d2e0b0cb6ea5f2720e F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8a F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h b3ac44ca090011813d5a07f63be59785a4558e74052eb94b686f52eef1af684b +F src/sqliteInt.h 92d3323ba58a1a745f0f6a300d619ea12a6b142f0e8d8d49ce24d84ed85092f1 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -835,11 +835,11 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 8bb70b3caadcf35073f8857ecd83d33d97bf6aa03de3342287037bae43c6f364 +F src/where.c 3efa165f9205602eef711af071db3862531fcda2b1ad875cda5e2c5effa56fee F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 -F src/whereexpr.c 6ebd90b553f4bb5c7df5a4b2f39b6a7c81a67484353827cdd2048f2514ec6f30 -F src/window.c 5b1387d59df30d481ed14cceef5f4d1dab1f8752aa106ba72c8b62777bd139d2 +F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 +F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 F test/affinity3.test f094773025eddf31135c7ad4cde722b7696f8eb07b97511f98585addf2a510a9 @@ -2179,8 +2179,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d543c829ef74dbd64105bd757ca660e4f02e9ce562be4f1688a701fa535351c4 -R 9a3605a04234115bfc68cd6fc0f2125f +P 823e579362c05bb8accf6c3b158c5162a16eb23cf81d6021c9e3246e32583d1c +R 2ac63c110cf6a72c96a474d2b73e892b +T *branch * enhanced-expr-is-const +T *sym-enhanced-expr-is-const * +T -sym-exp-values-clause2 * U drh -Z eb4b6e81254ae60e2fa77bddac123f09 +Z 0a7dc94654580f17d6264250f37030ea # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ad17c6052c..38b8366e49 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -823e579362c05bb8accf6c3b158c5162a16eb23cf81d6021c9e3246e32583d1c \ No newline at end of file +c9e0488c6c0135932b6e76b0f3f3acd69ef65327e0a54daa59777f35da1aef26 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index e4bfa995d7..6050058e43 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2346,6 +2346,52 @@ Expr *sqlite3ExprSimplifiedAndOr(Expr *pExpr){ return pExpr; } +/* +** pExpr is a TK_FUNCTION node. Try to determine whether or not the +** function is a constant function. A function is constant if all of +** the following are true: +** +** (1) It is a scalar function (not an aggregate or window function) +** (2) It has either the SQLITE_FUNC_CONSTANT or SQLITE_FUNC_SLOCHNG +** property. +** (3) All of its arguments are constants +** +** This routine sets pWalker->eCode to 0 if pExpr is not a constant. +** It makes no changes to pWalker->eCode if pExpr is constant. In +** every case, it returns WRC_Abort. +** +** Called as a service subroutine from exprNodeIsConstant(). +*/ +static SQLITE_NOINLINE int exprNodeIsConstantFunction( + Walker *pWalker, + Expr *pExpr +){ + int n; /* Number of arguments */ + ExprList *pList; /* List of arguments */ + FuncDef *pDef; /* The function */ + sqlite3 *db; /* The database */ + + assert( pExpr->op==TK_FUNCTION ); + if( pWalker->eCode==0 ) return WRC_Abort; + pList = pExpr->x.pList; + if( pList==0 ){ + n = 0; + }else{ + n = pList->nExpr; + sqlite3WalkExprList(pWalker, pList); + if( pWalker->eCode==0 ) return WRC_Abort; + } + db = pWalker->pParse->db; + pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); + if( pDef==0 + || pDef->xFinalize!=0 + || (pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 + ){ + pWalker->eCode = 0; + } + return WRC_Abort; +} + /* ** These routines are Walker callbacks used to check expressions to @@ -2393,6 +2439,8 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ ){ if( pWalker->eCode==5 ) ExprSetProperty(pExpr, EP_FromDDL); return WRC_Continue; + }else if( pWalker->pParse ){ + return exprNodeIsConstantFunction(pWalker, pExpr); }else{ pWalker->eCode = 0; return WRC_Abort; @@ -2448,6 +2496,7 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ static int exprIsConst(Expr *p, int initFlag, int iCur){ Walker w; w.eCode = initFlag; + w.pParse = 0; w.xExprCallback = exprNodeIsConstant; w.xSelectCallback = sqlite3SelectWalkFail; #ifdef SQLITE_DEBUG @@ -2465,9 +2514,24 @@ static int exprIsConst(Expr *p, int initFlag, int iCur){ ** For the purposes of this function, a double-quoted string (ex: "abc") ** is considered a variable but a single-quoted string (ex: 'abc') is ** a constant. +** +** The pParse parameter may be NULL. But if it is NULL, there is no way +** to determine if function calls are constant or not, and hence all +** function calls will be considered to be non-constant. If pParse is +** not NULL, then a function call might be constant, depending on the +** function and on its parameters. */ -int sqlite3ExprIsConstant(Expr *p){ - return exprIsConst(p, 1, 0); +int sqlite3ExprIsConstant(Parse *pParse, Expr *p){ + Walker w; + w.eCode = 1; + w.pParse = pParse; + w.xExprCallback = exprNodeIsConstant; + w.xSelectCallback = sqlite3SelectWalkFail; +#ifdef SQLITE_DEBUG + w.xSelectCallback2 = sqlite3SelectWalkAssert2; +#endif + sqlite3WalkExpr(&w, p); + return w.eCode; } /* @@ -2902,7 +2966,7 @@ static int sqlite3InRhsIsConstant(Expr *pIn){ assert( !ExprHasProperty(pIn, EP_xIsSelect) ); pLHS = pIn->pLeft; pIn->pLeft = 0; - res = sqlite3ExprIsConstant(pIn); + res = sqlite3ExprIsConstant(0, pIn); pIn->pLeft = pLHS; return res; } @@ -3454,7 +3518,7 @@ void sqlite3CodeRhsOfIN( ** this code only executes once. Because for a non-constant ** expression we need to rerun this code each time. */ - if( addrOnce && !sqlite3ExprIsConstant(pE2) ){ + if( addrOnce && !sqlite3ExprIsConstant(0, pE2) ){ sqlite3VdbeChangeToNoop(v, addrOnce-1); sqlite3VdbeChangeToNoop(v, addrOnce); ExprClearProperty(pExpr, EP_Subrtn); @@ -4822,7 +4886,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ } for(i=0; ia[i].pExpr) ){ + if( i<32 && sqlite3ExprIsConstant(0, pFarg->a[i].pExpr) ){ testcase( i==31 ); constMask |= MASKBIT32(i); } diff --git a/src/insert.c b/src/insert.c index 2bd846e834..915f368fbd 100644 --- a/src/insert.c +++ b/src/insert.c @@ -594,10 +594,10 @@ void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ ** Return true if all expressions in the expression-list passed as the ** only argument are constant. */ -static int exprListIsConstant(ExprList *pRow){ +static int exprListIsConstant(Parse *pParse, ExprList *pRow){ int ii; for(ii=0; iinExpr; ii++){ - if( 0==sqlite3ExprIsConstant(pRow->a[ii].pExpr) ) return 0; + if( 0==sqlite3ExprIsConstant(pParse, pRow->a[ii].pExpr) ) return 0; } return 1; } @@ -606,9 +606,9 @@ static int exprListIsConstant(ExprList *pRow){ ** Return true if all expressions in the expression-list passed as the ** only argument are both constant and have no affinity. */ -static int exprListIsNoAffinity(ExprList *pRow){ +static int exprListIsNoAffinity(Parse *pParse, ExprList *pRow){ int ii; - if( exprListIsConstant(pRow)==0 ) return 0; + if( exprListIsConstant(pParse,pRow)==0 ) return 0; for(ii=0; iinExpr; ii++){ assert( pRow->a[ii].pExpr->affExpr==0 ); if( 0!=sqlite3ExprAffinity(pRow->a[ii].pExpr) ) return 0; @@ -670,11 +670,12 @@ static int exprListIsNoAffinity(ExprList *pRow){ */ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ - if( pLeft->pPrior /* co-routine precluded by prior row */ - || pParse->bHasWith /* condition (a) above */ - || pParse->db->init.busy /* condition (b) above */ - || exprListIsConstant(pRow)==0 /* condition (c) above */ - || (pLeft->pSrc->nSrc==0 && exprListIsNoAffinity(pLeft->pEList)==0) /* (d) */ + if( pLeft->pPrior /* co-routine precluded by prior row */ + || pParse->bHasWith /* condition (a) above */ + || pParse->db->init.busy /* condition (b) above */ + || exprListIsConstant(pParse,pRow)==0 /* condition (c) above */ + || (pLeft->pSrc->nSrc==0 && + exprListIsNoAffinity(pParse,pLeft->pEList)==0) /* condition (d) above */ || IN_SPECIAL_PARSE ){ /* The co-routine method cannot be used. Fall back to UNION ALL. */ diff --git a/src/parse.y b/src/parse.y index 36566d28aa..78404ce673 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1325,7 +1325,7 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] { if( A ) sqlite3ExprIdToTrueFalse(A); }else{ Expr *pRHS = Y->a[0].pExpr; - if( Y->nExpr==1 && sqlite3ExprIsConstant(pRHS) && A->op!=TK_VECTOR ){ + if( Y->nExpr==1 && sqlite3ExprIsConstant(0,pRHS) && A->op!=TK_VECTOR ){ Y->a[0].pExpr = 0; sqlite3ExprListDelete(pParse->db, Y); pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); diff --git a/src/select.c b/src/select.c index 4158dd2fdc..bffbaa9800 100644 --- a/src/select.c +++ b/src/select.c @@ -4776,7 +4776,7 @@ static void constInsert( ){ int i; assert( pColumn->op==TK_COLUMN ); - assert( sqlite3ExprIsConstant(pValue) ); + assert( sqlite3ExprIsConstant(0, pValue) ); if( ExprHasProperty(pColumn, EP_FixedCol) ) return; if( sqlite3ExprAffinity(pValue)!=0 ) return; @@ -4834,10 +4834,10 @@ static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ pLeft = pExpr->pLeft; assert( pRight!=0 ); assert( pLeft!=0 ); - if( pRight->op==TK_COLUMN && sqlite3ExprIsConstant(pLeft) ){ + if( pRight->op==TK_COLUMN && sqlite3ExprIsConstant(0, pLeft) ){ constInsert(pConst,pRight,pLeft,pExpr); } - if( pLeft->op==TK_COLUMN && sqlite3ExprIsConstant(pRight) ){ + if( pLeft->op==TK_COLUMN && sqlite3ExprIsConstant(0, pRight) ){ constInsert(pConst,pLeft,pRight,pExpr); } } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 3913392712..205cb6afe0 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -5058,7 +5058,7 @@ void sqlite3LeaveMutexAndCloseZombie(sqlite3*); u32 sqlite3IsTrueOrFalse(const char*); int sqlite3ExprIdToTrueFalse(Expr*); int sqlite3ExprTruthValue(const Expr*); -int sqlite3ExprIsConstant(Expr*); +int sqlite3ExprIsConstant(Parse*,Expr*); int sqlite3ExprIsConstantNotJoin(Expr*); int sqlite3ExprIsConstantOrFunction(Expr*, u8); int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); diff --git a/src/where.c b/src/where.c index 9abc8e30f6..2a99c73980 100644 --- a/src/where.c +++ b/src/where.c @@ -1329,7 +1329,7 @@ static sqlite3_index_info *allocateIndexInfo( Expr *pE2; /* Skip over constant terms in the ORDER BY clause */ - if( sqlite3ExprIsConstant(pExpr) ){ + if( sqlite3ExprIsConstant(0, pExpr) ){ continue; } @@ -1441,7 +1441,7 @@ static sqlite3_index_info *allocateIndexInfo( pIdxInfo->nConstraint = j; for(i=j=0; ia[i].pExpr; - if( sqlite3ExprIsConstant(pExpr) ) continue; + if( sqlite3ExprIsConstant(0, pExpr) ) continue; assert( pExpr->op==TK_COLUMN || (pExpr->op==TK_COLLATE && pExpr->pLeft->op==TK_COLUMN && pExpr->iColumn==pExpr->pLeft->iColumn) ); @@ -3623,7 +3623,7 @@ static void wherePartIdxExpr( u8 aff; if( pLeft->op!=TK_COLUMN ) return; - if( !sqlite3ExprIsConstant(pRight) ) return; + if( !sqlite3ExprIsConstant(0, pRight) ) return; if( !sqlite3IsBinary(sqlite3ExprCompareCollSeq(pParse, pPart)) ) return; if( pLeft->iColumn<0 ) return; aff = pIdx->pTable->aCol[pLeft->iColumn].affinity; @@ -4997,7 +4997,7 @@ static i8 wherePathSatisfiesOrderBy( if( MASKBIT(i) & obSat ) continue; p = pOrderBy->a[i].pExpr; mTerm = sqlite3WhereExprUsage(&pWInfo->sMaskSet,p); - if( mTerm==0 && !sqlite3ExprIsConstant(p) ) continue; + if( mTerm==0 && !sqlite3ExprIsConstant(0,p) ) continue; if( (mTerm&~orderDistinctMask)==0 ){ obSat |= MASKBIT(i); } @@ -5866,7 +5866,7 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( }else{ continue; } - if( sqlite3ExprIsConstant(pExpr) ) continue; + if( sqlite3ExprIsConstant(0,pExpr) ) continue; if( pExpr->op==TK_FUNCTION ){ /* Functions that might set a subtype should not be replaced by the ** value taken from an expression index since the index omits the diff --git a/src/whereexpr.c b/src/whereexpr.c index 25db8f396f..9d1f947a09 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -989,7 +989,7 @@ static SQLITE_NOINLINE int exprMightBeIndexed2( if( pIdx->aiColumn[i]!=XN_EXPR ) continue; assert( pIdx->bHasExpr ); if( sqlite3ExprCompareSkip(pExpr,pIdx->aColExpr->a[i].pExpr,iCur)==0 - && !sqlite3ExprIsConstant(pIdx->aColExpr->a[i].pExpr) + && !sqlite3ExprIsConstant(0,pIdx->aColExpr->a[i].pExpr) ){ aiCurCol[0] = iCur; aiCurCol[1] = XN_EXPR; diff --git a/src/window.c b/src/window.c index 62df349fb3..bcee65d924 100644 --- a/src/window.c +++ b/src/window.c @@ -1164,7 +1164,7 @@ void sqlite3WindowListDelete(sqlite3 *db, Window *p){ ** variable values in the expression tree. */ static Expr *sqlite3WindowOffsetExpr(Parse *pParse, Expr *pExpr){ - if( 0==sqlite3ExprIsConstant(pExpr) ){ + if( 0==sqlite3ExprIsConstant(0,pExpr) ){ if( IN_RENAME_OBJECT ) sqlite3RenameExprUnmap(pParse, pExpr); sqlite3ExprDelete(pParse->db, pExpr); pExpr = sqlite3ExprAlloc(pParse->db, TK_NULL, 0, 0); From 40514dd1f661ad05b679cda3df90ed4efd0133fc Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 16 Mar 2024 14:27:10 +0000 Subject: [PATCH 0232/1030] Fix exprNodeIsConstantFunction() so that it returns WRC_Continue, not WRC_Abort, if the function really is constant. FossilOrigin-Name: d85dd4de2d0989127e0ae6a2eec9d83a577777f8d5ba40700084a0b498016634 --- manifest | 19 ++++++++----------- manifest.uuid | 2 +- src/expr.c | 3 ++- test/values.test | 13 +++++++++++++ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 5926610ec1..521628dfe1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\ssqlite3ExprIsConstant()\sfunction\sso\sthat\sit\srecognizes\nconstant\sfunctions.\s\sSo\sfar\sthe\senhancement\sonly\sapplies\sto\sthe\smulti-row\nVALUES\sclause,\sbut\sit\scould\spossibly\sbe\sapplied\sin\smany\sother\splaces. -D 2024-03-16T13:18:48.351 +C Fix\sexprNodeIsConstantFunction()\sso\sthat\sit\sreturns\sWRC_Continue,\snot\sWRC_Abort,\sif\sthe\sfunction\sreally\sis\sconstant. +D 2024-03-16T14:27:10.517 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 023e84202023d58bc10cb1f7a4dcc7fe1342e11daa054ea1024e8b78144bd589 +F src/expr.c b3914ec5ac4f1c43d0743123fabab27c089f16dcfdcfd47973e2eebe0834f94b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test f888bc7e833cc84258497f2c1b016f04515db00f9ee2e37ea12164eb9c8f47cf +F test/values.test 60723a55f68e8e42027d49a159a1be8b92cb0f538a65cb363ff65637e8a41703 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,11 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 823e579362c05bb8accf6c3b158c5162a16eb23cf81d6021c9e3246e32583d1c -R 2ac63c110cf6a72c96a474d2b73e892b -T *branch * enhanced-expr-is-const -T *sym-enhanced-expr-is-const * -T -sym-exp-values-clause2 * -U drh -Z 0a7dc94654580f17d6264250f37030ea +P c9e0488c6c0135932b6e76b0f3f3acd69ef65327e0a54daa59777f35da1aef26 +R 073539ebd1c8b85d1f5a19f0731cb417 +U dan +Z afcb8a3f36080c6ea414186a5d7c11c8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 38b8366e49..35e0b4aa0d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c9e0488c6c0135932b6e76b0f3f3acd69ef65327e0a54daa59777f35da1aef26 \ No newline at end of file +d85dd4de2d0989127e0ae6a2eec9d83a577777f8d5ba40700084a0b498016634 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 6050058e43..95567de799 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2388,8 +2388,9 @@ static SQLITE_NOINLINE int exprNodeIsConstantFunction( || (pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 ){ pWalker->eCode = 0; + return WRC_Abort; } - return WRC_Abort; + return WRC_Continue; } diff --git a/test/values.test b/test/values.test index 3dba3dda94..b96c9e5d23 100644 --- a/test/values.test +++ b/test/values.test @@ -401,6 +401,19 @@ do_execsql_test 12.2 { SELECT * FROM t1 } {1 2 3 4 5 6} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 13.0 { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES('xyz'); + + SELECT ( + VALUES( (max(substr('abc', 1, 1), x)) ), + (123), + (456) + ) + FROM t1; +} {xyz} finish_test From bf4105d76851ba3fb4ad56190284f9ebc6decfd8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 16 Mar 2024 17:04:08 +0000 Subject: [PATCH 0233/1030] Extend the scope expr-is-constant for function to cover the IN-to-EQ optimization. FossilOrigin-Name: dae669245c86021bcd28716aff6e316257cc8075d02081745d4b7de17f8ad553 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/parse.y | 2 +- src/test1.c | 21 +++++++++++++++++++++ test/in4.test | 5 +++-- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 521628dfe1..bbfca938b7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sexprNodeIsConstantFunction()\sso\sthat\sit\sreturns\sWRC_Continue,\snot\sWRC_Abort,\sif\sthe\sfunction\sreally\sis\sconstant. -D 2024-03-16T14:27:10.517 +C Extend\sthe\sscope\sexpr-is-constant\sfor\sfunction\sto\scover\sthe\sIN-to-EQ\noptimization. +D 2024-03-16T17:04:08.435 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -739,7 +739,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 004faaa6b6d6a88d9ec5e535281d7a203e1a03e83617ef8249f40e18bda23dc4 +F src/parse.y 5bcef16094213efcc365a9d4dc4e3131f09251dc8838dce4a9e5f9764bff5b82 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -760,7 +760,7 @@ F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c ecbc3c99c0d0c3ed122a913f143026c26d38d57f33e06bb71185dd5c1efe37cd -F src/test1.c 310f43eb17a9252a7790726ca652e4ea3197da17c19eec93b8578863a49dc7b4 +F src/test1.c 5a67577fa7d93a19a72aa165b7013606a35e53f62d0de11587940aed5797d92d F src/test2.c 54520d0565ef2b9bf0f8f1dcac43dc4d06baf4ffe13d10905f8d8c3ad3e4b9ab F src/test3.c e5178558c41ff53236ae0271e9acb3d6885a94981d2eb939536ee6474598840e F src/test4.c 4533b76419e7feb41b40582554663ed3cd77aaa54e135cf76b3205098cd6e664 @@ -1271,7 +1271,7 @@ F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 F test/in.test d1cad4ededd425568b2e39fb0c31fa9a3772311dd595801ff13ba3912b69bba6 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 -F test/in4.test fdd1d8134da8376985c2edba6035a2de1f6c731524d2ffa651419e8fe2cd1c5a +F test/in4.test 176719161ba96c9386027891602700738aadac3419964f72b628f59d2071d53d F test/in5.test b32ce7f4a93f44c5dee94af16886d922cc16ebe33c8e1765c73d4049d0f4b40f F test/in6.test f5f40d6816a8bb7c784424b58a10ac38efb76ab29127a2c17399e0cbeeda0e4b F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c9e0488c6c0135932b6e76b0f3f3acd69ef65327e0a54daa59777f35da1aef26 -R 073539ebd1c8b85d1f5a19f0731cb417 -U dan -Z afcb8a3f36080c6ea414186a5d7c11c8 +P d85dd4de2d0989127e0ae6a2eec9d83a577777f8d5ba40700084a0b498016634 +R ca429b76372fd82d8194dbd47566db28 +U drh +Z 9b82b5806afe1db311bd1eb3f3eb021c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 35e0b4aa0d..23dbdeae40 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d85dd4de2d0989127e0ae6a2eec9d83a577777f8d5ba40700084a0b498016634 \ No newline at end of file +dae669245c86021bcd28716aff6e316257cc8075d02081745d4b7de17f8ad553 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 78404ce673..d22c8e6fc2 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1325,7 +1325,7 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] { if( A ) sqlite3ExprIdToTrueFalse(A); }else{ Expr *pRHS = Y->a[0].pExpr; - if( Y->nExpr==1 && sqlite3ExprIsConstant(0,pRHS) && A->op!=TK_VECTOR ){ + if( Y->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && A->op!=TK_VECTOR ){ Y->a[0].pExpr = 0; sqlite3ExprListDelete(pParse->db, Y); pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); diff --git a/src/test1.c b/src/test1.c index 8faf5a397b..a552c3f509 100644 --- a/src/test1.c +++ b/src/test1.c @@ -1024,6 +1024,23 @@ static void addRealTypeFunction( sqlite3_result_value(context, argv[0]); } +/* +** Implementation of the noop(X) SQL function. +** +** The result is just a copy of its argument. However, this function +** does not have the SQLITE_FUNC_CONSTANT flag, so it is consider +** non-constant by sqlite3ExprIsConstant(). +*/ +static void noopFunction( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + (void)argc; + sqlite3_result_value(context, argv[0]); +} + + /* ** SQL function: strtod(X) ** @@ -1151,6 +1168,10 @@ static int SQLITE_TCLAPI test_create_function( rc = sqlite3_create_function(db, "add_real_type", 1, SQLITE_UTF8, 0, addRealTypeFunction, 0, 0); } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "noop", 1, SQLITE_UTF8, + 0, noopFunction, 0, 0); + } /* Functions strtod() and dtostr() work as in the shell. These routines ** use the standard C library to convert between floating point and diff --git a/test/in4.test b/test/in4.test index a3fe22e787..81f2b2840d 100644 --- a/test/in4.test +++ b/test/in4.test @@ -455,17 +455,18 @@ do_execsql_test 11.0 { INSERT INTO sqlite_stat1 VALUES('t1','t1abc','10000 5 00 2003 10'); ANALYZE sqlite_schema; } {} +sqlite3_create_function db do_execsql_test 11.1 { SELECT * FROM t1 WHERE b IN (345, (SELECT 1 FROM t1 - WHERE b IN (345 NOT GLOB 510) + WHERE b IN (noop(1)) AND c GLOB 'abc*xyz')) AND c BETWEEN 'abc' AND 'xyz'; } {xyz 1 abcdefxyz 99} do_execsql_test 11.2 { EXPLAIN SELECT * FROM t1 WHERE b IN (345, (SELECT 1 FROM t1 - WHERE b IN (345 NOT GLOB 510) + WHERE b IN (noop(1)) AND c GLOB 'abc*xyz')) AND c BETWEEN 'abc' AND 'xyz'; } {/ SeekScan /} From b918a0f8215b43d62e2824dbe439261cafaf48c2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 16 Mar 2024 19:36:18 +0000 Subject: [PATCH 0234/1030] Activate the enhanced constant-expression for the [constant propagation optimization](/info/f4229707ac08d66c). FossilOrigin-Name: 92afea38881a1a4f266c79ddc6e1027cf17c288dcc8f7e7d50466899ac0054c4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 6 +++--- test/whereL.test | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index bbfca938b7..8f71171d11 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Extend\sthe\sscope\sexpr-is-constant\sfor\sfunction\sto\scover\sthe\sIN-to-EQ\noptimization. -D 2024-03-16T17:04:08.435 +C Activate\sthe\senhanced\sconstant-expression\sfor\sthe\n[constant\spropagation\soptimization](/info/f4229707ac08d66c). +D 2024-03-16T19:36:18.764 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -750,7 +750,7 @@ F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 4a3abb346d184a5b1f4f10f10da22465ff18db170099c2d2e0b0cb6ea5f2720e +F src/select.c df2bf515fc36e02e97959a70e82da8a4967d6c85590646a7fda2926a734c81ce F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8a F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2011,7 +2011,7 @@ F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2 F test/whereI.test c4bb7e2ca56d49bd8ab5c7bd085b8b83e353922b46904d68aefb3c7468643581 F test/whereJ.test fc05e374cc9f2dc204148d6c06822c380ad388895fe97a6d335b94a26a08aecf F test/whereK.test 0270ab7f04ba5436fb9156d31d642a1c82727f4c4bfe5ba90d435c78cf44684a -F test/whereL.test f0e9585623af522ee9f382f8f945ad4b7eb7d806d18746f33f00c374acf6ab65 +F test/whereL.test bf41203fda5e19e4c554a296b4ad2ff3eb27207549b94a819a2bc37275b4529d F test/whereM.test 0dbc9998783458ddcf3cc078ca7c2951d8b2677d472ecf0028f449ed327c0250 F test/wherefault.test 6cf2a9c5712952d463d3f45ebee7f6caf400984df51a195d884cfb7eb0e837a7 F test/wherelfault.test 9012e4ef5259058b771606616bd007af5d154e64cc25fa9fd4170f6411db44e3 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d85dd4de2d0989127e0ae6a2eec9d83a577777f8d5ba40700084a0b498016634 -R ca429b76372fd82d8194dbd47566db28 +P dae669245c86021bcd28716aff6e316257cc8075d02081745d4b7de17f8ad553 +R 02d7863e0170a404854cbdb7daab35da U drh -Z 9b82b5806afe1db311bd1eb3f3eb021c +Z 4782493dacf06603b1147674a9e69d60 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 23dbdeae40..7aaeff4fab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dae669245c86021bcd28716aff6e316257cc8075d02081745d4b7de17f8ad553 \ No newline at end of file +92afea38881a1a4f266c79ddc6e1027cf17c288dcc8f7e7d50466899ac0054c4 \ No newline at end of file diff --git a/src/select.c b/src/select.c index bffbaa9800..1085b99436 100644 --- a/src/select.c +++ b/src/select.c @@ -4776,7 +4776,7 @@ static void constInsert( ){ int i; assert( pColumn->op==TK_COLUMN ); - assert( sqlite3ExprIsConstant(0, pValue) ); + assert( sqlite3ExprIsConstant(pConst->pParse, pValue) ); if( ExprHasProperty(pColumn, EP_FixedCol) ) return; if( sqlite3ExprAffinity(pValue)!=0 ) return; @@ -4834,10 +4834,10 @@ static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ pLeft = pExpr->pLeft; assert( pRight!=0 ); assert( pLeft!=0 ); - if( pRight->op==TK_COLUMN && sqlite3ExprIsConstant(0, pLeft) ){ + if( pRight->op==TK_COLUMN && sqlite3ExprIsConstant(pConst->pParse, pLeft) ){ constInsert(pConst,pRight,pLeft,pExpr); } - if( pLeft->op==TK_COLUMN && sqlite3ExprIsConstant(0, pRight) ){ + if( pLeft->op==TK_COLUMN && sqlite3ExprIsConstant(pConst->pParse, pRight) ){ constInsert(pConst,pLeft,pRight,pExpr); } } diff --git a/test/whereL.test b/test/whereL.test index 068ee05cd4..9d1054964c 100644 --- a/test/whereL.test +++ b/test/whereL.test @@ -49,6 +49,32 @@ do_eqp_test 120 { |--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?) `--SCAN t3 } +do_eqp_test 121 { + SELECT * FROM t1, t2, t3 + WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=abs(5) + ORDER BY t1.a; +} { + QUERY PLAN + |--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?) + |--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?) + `--SCAN t3 +} + +# The sqlite3ExprIsConstant() routine does not believe that noop(3) +# is constant. So the optimization does not apply in this case. +# +sqlite3_create_function db +do_eqp_test 122 { + SELECT * FROM t1, t2, t3 + WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=noop(5) + ORDER BY t1.a; +} { + QUERY PLAN + |--SCAN t3 + |--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?) + |--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?) + `--USE TEMP B-TREE FOR ORDER BY +} # Constant propagation in the face of collating sequences: # From 4713b2d73ca0053671c7b6e8502647e1a2c0a411 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 16 Mar 2024 19:48:51 +0000 Subject: [PATCH 0235/1030] Assert that the eCode is always non-zero upon entry into exprNodeIsConstant(). FossilOrigin-Name: f71b28f6713126745bca53e098dfe3444d4235d6a2b87ced5b333a7f0ee79be8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8f71171d11..fb57f31af9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Activate\sthe\senhanced\sconstant-expression\sfor\sthe\n[constant\spropagation\soptimization](/info/f4229707ac08d66c). -D 2024-03-16T19:36:18.764 +C Assert\sthat\sthe\seCode\sis\salways\snon-zero\supon\sentry\sinto\sexprNodeIsConstant(). +D 2024-03-16T19:48:51.062 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c b3914ec5ac4f1c43d0743123fabab27c089f16dcfdcfd47973e2eebe0834f94b +F src/expr.c a6cc77ccca00905f5ba0739dd8112fcb0411231d9228239553829a85bf35b0dd F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dae669245c86021bcd28716aff6e316257cc8075d02081745d4b7de17f8ad553 -R 02d7863e0170a404854cbdb7daab35da +P 92afea38881a1a4f266c79ddc6e1027cf17c288dcc8f7e7d50466899ac0054c4 +R 03a747756d1c2eaa7bed49327f66bff5 U drh -Z 4782493dacf06603b1147674a9e69d60 +Z 34a5fcb15810c923d4200d4da137f642 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7aaeff4fab..5218da70b2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -92afea38881a1a4f266c79ddc6e1027cf17c288dcc8f7e7d50466899ac0054c4 \ No newline at end of file +f71b28f6713126745bca53e098dfe3444d4235d6a2b87ced5b333a7f0ee79be8 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 95567de799..66070db5b9 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2372,7 +2372,6 @@ static SQLITE_NOINLINE int exprNodeIsConstantFunction( sqlite3 *db; /* The database */ assert( pExpr->op==TK_FUNCTION ); - if( pWalker->eCode==0 ) return WRC_Abort; pList = pExpr->x.pList; if( pList==0 ){ n = 0; @@ -2421,6 +2420,7 @@ static SQLITE_NOINLINE int exprNodeIsConstantFunction( ** malformed schema error. */ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ + assert( pWalker->eCode>0 ); /* If pWalker->eCode is 2 then any term of the expression that comes from ** the ON or USING clauses of an outer join disqualifies the expression From 7dc3e923c4066eeb3c8a16f9de736c755b621b00 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 16 Mar 2024 20:15:34 +0000 Subject: [PATCH 0236/1030] Further expand the scope of usage for the enhacement to expr-is-constant. FossilOrigin-Name: d7eadcf7dd089f0f4aa963c58f0df32edd951368c9906375fd62b0a61cd393b8 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 48 +++++++++++++++++++++--------------------------- src/sqliteInt.h | 1 - 4 files changed, 29 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index fb57f31af9..bbd7c592eb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Assert\sthat\sthe\seCode\sis\salways\snon-zero\supon\sentry\sinto\sexprNodeIsConstant(). -D 2024-03-16T19:48:51.062 +C Further\sexpand\sthe\sscope\sof\susage\sfor\sthe\senhacement\sto\sexpr-is-constant. +D 2024-03-16T20:15:34.449 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c a6cc77ccca00905f5ba0739dd8112fcb0411231d9228239553829a85bf35b0dd +F src/expr.c 8968e7bef87f595a3e7a5a31b1ee849dd26b600cae9caae17d0bd151f7771eb3 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -755,7 +755,7 @@ F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8 F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 92d3323ba58a1a745f0f6a300d619ea12a6b142f0e8d8d49ce24d84ed85092f1 +F src/sqliteInt.h 4bf7dcc1d2015a6cdd0a2cba5ef33f8f4f7bc14ebc7205321e2488c14eead77d F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 92afea38881a1a4f266c79ddc6e1027cf17c288dcc8f7e7d50466899ac0054c4 -R 03a747756d1c2eaa7bed49327f66bff5 +P f71b28f6713126745bca53e098dfe3444d4235d6a2b87ced5b333a7f0ee79be8 +R d3bfccf80dd34f5216cfa96d96bbce32 U drh -Z 34a5fcb15810c923d4200d4da137f642 +Z d29542cf1f94495f6b9d8836a34942e6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5218da70b2..ce44e01dd6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f71b28f6713126745bca53e098dfe3444d4235d6a2b87ced5b333a7f0ee79be8 \ No newline at end of file +d7eadcf7dd089f0f4aa963c58f0df32edd951368c9906375fd62b0a61cd393b8 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 66070db5b9..4b312873f7 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2372,8 +2372,9 @@ static SQLITE_NOINLINE int exprNodeIsConstantFunction( sqlite3 *db; /* The database */ assert( pExpr->op==TK_FUNCTION ); - pList = pExpr->x.pList; - if( pList==0 ){ + if( ExprHasProperty(pExpr, EP_TokenOnly) + || (pList = pExpr->x.pList)==0 + ){; n = 0; }else{ n = pList->nExpr; @@ -2494,10 +2495,10 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ return WRC_Continue; } } -static int exprIsConst(Expr *p, int initFlag, int iCur){ +static int exprIsConst(Parse *pParse, Expr *p, int initFlag, int iCur){ Walker w; w.eCode = initFlag; - w.pParse = 0; + w.pParse = pParse; w.xExprCallback = exprNodeIsConstant; w.xSelectCallback = sqlite3SelectWalkFail; #ifdef SQLITE_DEBUG @@ -2523,16 +2524,7 @@ static int exprIsConst(Expr *p, int initFlag, int iCur){ ** function and on its parameters. */ int sqlite3ExprIsConstant(Parse *pParse, Expr *p){ - Walker w; - w.eCode = 1; - w.pParse = pParse; - w.xExprCallback = exprNodeIsConstant; - w.xSelectCallback = sqlite3SelectWalkFail; -#ifdef SQLITE_DEBUG - w.xSelectCallback2 = sqlite3SelectWalkAssert2; -#endif - sqlite3WalkExpr(&w, p); - return w.eCode; + return exprIsConst(pParse, p, 1, 0); } /* @@ -2548,8 +2540,8 @@ int sqlite3ExprIsConstant(Parse *pParse, Expr *p){ ** can be added to the pParse->pConstExpr list and evaluated once when ** the prepared statement starts up. See sqlite3ExprCodeRunJustOnce(). */ -int sqlite3ExprIsConstantNotJoin(Expr *p){ - return exprIsConst(p, 2, 0); +static int sqlite3ExprIsConstantNotJoin(Parse *pParse, Expr *p){ + return exprIsConst(pParse, p, 2, 0); } /* @@ -2559,7 +2551,7 @@ int sqlite3ExprIsConstantNotJoin(Expr *p){ ** table other than iCur. */ int sqlite3ExprIsTableConstant(Expr *p, int iCur){ - return exprIsConst(p, 3, iCur); + return exprIsConst(0, p, 3, iCur); } /* @@ -2716,7 +2708,7 @@ int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){ */ int sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){ assert( isInit==0 || isInit==1 ); - return exprIsConst(p, 4+isInit, 0); + return exprIsConst(0, p, 4+isInit, 0); } #ifdef SQLITE_ENABLE_CURSOR_HINTS @@ -2961,13 +2953,13 @@ static void sqlite3SetHasNullFlag(Vdbe *v, int iCur, int regHasNull){ ** The argument is an IN operator with a list (not a subquery) on the ** right-hand side. Return TRUE if that list is constant. */ -static int sqlite3InRhsIsConstant(Expr *pIn){ +static int sqlite3InRhsIsConstant(Parse *pParse, Expr *pIn){ Expr *pLHS; int res; assert( !ExprHasProperty(pIn, EP_xIsSelect) ); pLHS = pIn->pLeft; pIn->pLeft = 0; - res = sqlite3ExprIsConstant(0, pIn); + res = sqlite3ExprIsConstant(pParse, pIn); pIn->pLeft = pLHS; return res; } @@ -3236,7 +3228,7 @@ int sqlite3FindInIndex( if( eType==0 && (inFlags & IN_INDEX_NOOP_OK) && ExprUseXList(pX) - && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2) + && (!sqlite3InRhsIsConstant(pParse,pX) || pX->x.pList->nExpr<=2) ){ pParse->nTab--; /* Back out the allocation of the unused cursor */ iTab = -1; /* Cursor is not allocated */ @@ -3519,7 +3511,7 @@ void sqlite3CodeRhsOfIN( ** this code only executes once. Because for a non-constant ** expression we need to rerun this code each time. */ - if( addrOnce && !sqlite3ExprIsConstant(0, pE2) ){ + if( addrOnce && !sqlite3ExprIsConstant(pParse, pE2) ){ sqlite3VdbeChangeToNoop(v, addrOnce-1); sqlite3VdbeChangeToNoop(v, addrOnce); ExprClearProperty(pExpr, EP_Subrtn); @@ -4856,7 +4848,9 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ } #endif - if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){ + if( ConstFactorOk(pParse) + && sqlite3ExprIsConstantNotJoin(pParse,pExpr) + ){ /* SQL functions can be expensive. So try to avoid running them ** multiple times if we know they always give the same result */ return sqlite3ExprCodeRunJustOnce(pParse, pExpr, -1); @@ -4887,7 +4881,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ } for(i=0; ia[i].pExpr) ){ + if( i<32 && sqlite3ExprIsConstant(pParse, pFarg->a[i].pExpr) ){ testcase( i==31 ); constMask |= MASKBIT32(i); } @@ -5354,7 +5348,7 @@ int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){ if( ConstFactorOk(pParse) && ALWAYS(pExpr!=0) && pExpr->op!=TK_REGISTER - && sqlite3ExprIsConstantNotJoin(pExpr) + && sqlite3ExprIsConstantNotJoin(pParse, pExpr) ){ *pReg = 0; r2 = sqlite3ExprCodeRunJustOnce(pParse, pExpr, -1); @@ -5418,7 +5412,7 @@ void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){ ** might choose to code the expression at initialization time. */ void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){ - if( pParse->okConstFactor && sqlite3ExprIsConstantNotJoin(pExpr) ){ + if( pParse->okConstFactor && sqlite3ExprIsConstantNotJoin(pParse,pExpr) ){ sqlite3ExprCodeRunJustOnce(pParse, pExpr, target); }else{ sqlite3ExprCodeCopy(pParse, pExpr, target); @@ -5477,7 +5471,7 @@ int sqlite3ExprCodeExprList( sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i); } }else if( (flags & SQLITE_ECEL_FACTOR)!=0 - && sqlite3ExprIsConstantNotJoin(pExpr) + && sqlite3ExprIsConstantNotJoin(pParse,pExpr) ){ sqlite3ExprCodeRunJustOnce(pParse, pExpr, target+i); }else{ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 205cb6afe0..54fe9458fc 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -5059,7 +5059,6 @@ u32 sqlite3IsTrueOrFalse(const char*); int sqlite3ExprIdToTrueFalse(Expr*); int sqlite3ExprTruthValue(const Expr*); int sqlite3ExprIsConstant(Parse*,Expr*); -int sqlite3ExprIsConstantNotJoin(Expr*); int sqlite3ExprIsConstantOrFunction(Expr*, u8); int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); int sqlite3ExprIsTableConstant(Expr*,int); From ec00a4d11148e4127a30bb1b1d26bf09409204e6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 16 Mar 2024 21:04:32 +0000 Subject: [PATCH 0237/1030] A formerly impossible case has now become possible because of the new ExprIsConstant enhancements. So deal with that. FossilOrigin-Name: 9ba3cff9d48fe8fc8a0a51291169599209d464465e44bdfd60058fd1e314a2b1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index bbd7c592eb..5a88394c42 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\sexpand\sthe\sscope\sof\susage\sfor\sthe\senhacement\sto\sexpr-is-constant. -D 2024-03-16T20:15:34.449 +C A\sformerly\simpossible\scase\shas\snow\sbecome\spossible\sbecause\sof\sthe\snew\nExprIsConstant\senhancements.\s\sSo\sdeal\swith\sthat. +D 2024-03-16T21:04:32.468 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 8968e7bef87f595a3e7a5a31b1ee849dd26b600cae9caae17d0bd151f7771eb3 +F src/expr.c eef4b58b1c5f488c7bd099af3a571ff32509d00a1c990f17c0bc5e752ed33462 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f71b28f6713126745bca53e098dfe3444d4235d6a2b87ced5b333a7f0ee79be8 -R d3bfccf80dd34f5216cfa96d96bbce32 +P d7eadcf7dd089f0f4aa963c58f0df32edd951368c9906375fd62b0a61cd393b8 +R 8cf165d7d4e6171fbfcc63e324d78f15 U drh -Z d29542cf1f94495f6b9d8836a34942e6 +Z 950e1346eed1b73efa50ee1189a08fc5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ce44e01dd6..3675f57590 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d7eadcf7dd089f0f4aa963c58f0df32edd951368c9906375fd62b0a61cd393b8 \ No newline at end of file +9ba3cff9d48fe8fc8a0a51291169599209d464465e44bdfd60058fd1e314a2b1 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 4b312873f7..3ba07fb2dc 100644 --- a/src/expr.c +++ b/src/expr.c @@ -218,9 +218,10 @@ Expr *sqlite3ExprSkipCollateAndLikely(Expr *pExpr){ assert( pExpr->x.pList->nExpr>0 ); assert( pExpr->op==TK_FUNCTION ); pExpr = pExpr->x.pList->a[0].pExpr; - }else{ - assert( pExpr->op==TK_COLLATE ); + }else if( pExpr->op==TK_COLLATE ){ pExpr = pExpr->pLeft; + }else{ + break; } } return pExpr; From e4a1b4da4f8e76293209071b7bc3588d6c05f736 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 17 Mar 2024 00:13:12 +0000 Subject: [PATCH 0238/1030] Add an ALWAYS on an unreachable branch. FossilOrigin-Name: 0dce6211690210e802545cbca9b3375e07075e117fad3f8c921879da7671d981 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/insert.c | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ee5a613c1a..d667045fa5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Recognize\swhen\san\sSQL\sfunction\sis\sconstant\sand\scan\soccur\sinside\san\noptimized\sVALUES\sclause. -D 2024-03-16T21:12:51.251 +C Add\san\sALWAYS\son\san\sunreachable\sbranch. +D 2024-03-17T00:13:12.278 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c e28426630ebbac5763d5802099164ad24fbf46fea79d48a8313117a64b950871 +F src/insert.c f0755de645ee8e632445b731951c75b7484ccadb890ade4cbc8db269327ff4b8 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -2179,9 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 823e579362c05bb8accf6c3b158c5162a16eb23cf81d6021c9e3246e32583d1c 9ba3cff9d48fe8fc8a0a51291169599209d464465e44bdfd60058fd1e314a2b1 -R 8cf165d7d4e6171fbfcc63e324d78f15 -T +closed 9ba3cff9d48fe8fc8a0a51291169599209d464465e44bdfd60058fd1e314a2b1 +P c0e5ceb87d3cf28f22d381f863b8f91043804fd7901f23f3afb02fe698e6a12a +R c0fd5d4c2ab2c847266cf4b9416ae243 U drh -Z 1c2f2833c22bf92aec87aab6cf84bca7 +Z 061bbac91348ec107ed9e1ccfd2e024e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ca62261369..9a374d564f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c0e5ceb87d3cf28f22d381f863b8f91043804fd7901f23f3afb02fe698e6a12a \ No newline at end of file +0dce6211690210e802545cbca9b3375e07075e117fad3f8c921879da7671d981 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 915f368fbd..2c6a76b78d 100644 --- a/src/insert.c +++ b/src/insert.c @@ -583,7 +583,7 @@ void sqlite3AutoincrementEnd(Parse *pParse){ ** co-routine. */ void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ - if( pVal && pVal->pSrc->nSrc>0 ){ + if( ALWAYS(pVal) && pVal->pSrc->nSrc>0 ){ SrcItem *pItem = &pVal->pSrc->a[0]; sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->regReturn); sqlite3VdbeJumpHere(pParse->pVdbe, pItem->addrFillSub - 1); From 54bf109e807cc2c12cd81883affd008d718d0748 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 17 Mar 2024 16:01:23 +0000 Subject: [PATCH 0239/1030] Omit the "noop(X)" test SQL function. Accomplish the same thing using the idiom: "coalesce(X,random())". FossilOrigin-Name: 0eb2fbb8910e7a372c50db3ae44238d7b161f0e45858b74061b5228aec5fcc7e --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test1.c | 21 --------------------- test/in4.test | 5 ++--- test/whereL.test | 7 ++++--- 5 files changed, 15 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index d667045fa5..7f30177097 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sALWAYS\son\san\sunreachable\sbranch. -D 2024-03-17T00:13:12.278 +C Omit\sthe\s"noop(X)"\stest\sSQL\sfunction.\s\sAccomplish\sthe\ssame\sthing\susing\nthe\sidiom:\s\s"coalesce(X,random())". +D 2024-03-17T16:01:23.923 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c ecbc3c99c0d0c3ed122a913f143026c26d38d57f33e06bb71185dd5c1efe37cd -F src/test1.c 5a67577fa7d93a19a72aa165b7013606a35e53f62d0de11587940aed5797d92d +F src/test1.c 310f43eb17a9252a7790726ca652e4ea3197da17c19eec93b8578863a49dc7b4 F src/test2.c 54520d0565ef2b9bf0f8f1dcac43dc4d06baf4ffe13d10905f8d8c3ad3e4b9ab F src/test3.c e5178558c41ff53236ae0271e9acb3d6885a94981d2eb939536ee6474598840e F src/test4.c 4533b76419e7feb41b40582554663ed3cd77aaa54e135cf76b3205098cd6e664 @@ -1271,7 +1271,7 @@ F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 F test/in.test d1cad4ededd425568b2e39fb0c31fa9a3772311dd595801ff13ba3912b69bba6 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 -F test/in4.test 176719161ba96c9386027891602700738aadac3419964f72b628f59d2071d53d +F test/in4.test bb767ec1cfd1730256f0a83219f0acda36bc251b63f8b8bb7d8c7cff17875a4f F test/in5.test b32ce7f4a93f44c5dee94af16886d922cc16ebe33c8e1765c73d4049d0f4b40f F test/in6.test f5f40d6816a8bb7c784424b58a10ac38efb76ab29127a2c17399e0cbeeda0e4b F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822 @@ -2011,7 +2011,7 @@ F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2 F test/whereI.test c4bb7e2ca56d49bd8ab5c7bd085b8b83e353922b46904d68aefb3c7468643581 F test/whereJ.test fc05e374cc9f2dc204148d6c06822c380ad388895fe97a6d335b94a26a08aecf F test/whereK.test 0270ab7f04ba5436fb9156d31d642a1c82727f4c4bfe5ba90d435c78cf44684a -F test/whereL.test bf41203fda5e19e4c554a296b4ad2ff3eb27207549b94a819a2bc37275b4529d +F test/whereL.test 438a397fa883b77bb6361c08a8befa41b52e9cfbe15a2a43715d122f8cfa8649 F test/whereM.test 0dbc9998783458ddcf3cc078ca7c2951d8b2677d472ecf0028f449ed327c0250 F test/wherefault.test 6cf2a9c5712952d463d3f45ebee7f6caf400984df51a195d884cfb7eb0e837a7 F test/wherelfault.test 9012e4ef5259058b771606616bd007af5d154e64cc25fa9fd4170f6411db44e3 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c0e5ceb87d3cf28f22d381f863b8f91043804fd7901f23f3afb02fe698e6a12a -R c0fd5d4c2ab2c847266cf4b9416ae243 +P 0dce6211690210e802545cbca9b3375e07075e117fad3f8c921879da7671d981 +R 04c934383a09ffd06af013a1dd47675b U drh -Z 061bbac91348ec107ed9e1ccfd2e024e +Z ca3e70db7b33adfad0eeda8b7a11174b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9a374d564f..186e057cef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0dce6211690210e802545cbca9b3375e07075e117fad3f8c921879da7671d981 \ No newline at end of file +0eb2fbb8910e7a372c50db3ae44238d7b161f0e45858b74061b5228aec5fcc7e \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index a552c3f509..8faf5a397b 100644 --- a/src/test1.c +++ b/src/test1.c @@ -1024,23 +1024,6 @@ static void addRealTypeFunction( sqlite3_result_value(context, argv[0]); } -/* -** Implementation of the noop(X) SQL function. -** -** The result is just a copy of its argument. However, this function -** does not have the SQLITE_FUNC_CONSTANT flag, so it is consider -** non-constant by sqlite3ExprIsConstant(). -*/ -static void noopFunction( - sqlite3_context *context, - int argc, - sqlite3_value **argv -){ - (void)argc; - sqlite3_result_value(context, argv[0]); -} - - /* ** SQL function: strtod(X) ** @@ -1168,10 +1151,6 @@ static int SQLITE_TCLAPI test_create_function( rc = sqlite3_create_function(db, "add_real_type", 1, SQLITE_UTF8, 0, addRealTypeFunction, 0, 0); } - if( rc==SQLITE_OK ){ - rc = sqlite3_create_function(db, "noop", 1, SQLITE_UTF8, - 0, noopFunction, 0, 0); - } /* Functions strtod() and dtostr() work as in the shell. These routines ** use the standard C library to convert between floating point and diff --git a/test/in4.test b/test/in4.test index 81f2b2840d..71993e7003 100644 --- a/test/in4.test +++ b/test/in4.test @@ -455,18 +455,17 @@ do_execsql_test 11.0 { INSERT INTO sqlite_stat1 VALUES('t1','t1abc','10000 5 00 2003 10'); ANALYZE sqlite_schema; } {} -sqlite3_create_function db do_execsql_test 11.1 { SELECT * FROM t1 WHERE b IN (345, (SELECT 1 FROM t1 - WHERE b IN (noop(1)) + WHERE b IN (coalesce(1,random())) AND c GLOB 'abc*xyz')) AND c BETWEEN 'abc' AND 'xyz'; } {xyz 1 abcdefxyz 99} do_execsql_test 11.2 { EXPLAIN SELECT * FROM t1 WHERE b IN (345, (SELECT 1 FROM t1 - WHERE b IN (noop(1)) + WHERE b IN (coalesce(1,random())) AND c GLOB 'abc*xyz')) AND c BETWEEN 'abc' AND 'xyz'; } {/ SeekScan /} diff --git a/test/whereL.test b/test/whereL.test index 9d1054964c..2e9ae219e1 100644 --- a/test/whereL.test +++ b/test/whereL.test @@ -60,13 +60,14 @@ do_eqp_test 121 { `--SCAN t3 } -# The sqlite3ExprIsConstant() routine does not believe that noop(3) -# is constant. So the optimization does not apply in this case. +# The sqlite3ExprIsConstant() routine does not believe that +# the expression "coalesce(5,random())" is constant. So the +# optimization does not apply in this case. # sqlite3_create_function db do_eqp_test 122 { SELECT * FROM t1, t2, t3 - WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=noop(5) + WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=coalesce(5,random()) ORDER BY t1.a; } { QUERY PLAN From 2f4a8cc2d8f1ce29814a97887d9e8e96e9ed7725 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Mar 2024 10:54:48 +0000 Subject: [PATCH 0240/1030] Fix a problem caused by a non-aggregate function with an OVER clause in a multi-row VALUES clause. FossilOrigin-Name: 10ee6fcba08ab1281235197602148fe062560e1d5034a477b8e7b574dd3e2907 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 1 + test/values.test | 5 +++++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7f30177097..f72f4d1d80 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sthe\s"noop(X)"\stest\sSQL\sfunction.\s\sAccomplish\sthe\ssame\sthing\susing\nthe\sidiom:\s\s"coalesce(X,random())". -D 2024-03-17T16:01:23.923 +C Fix\sa\sproblem\scaused\sby\sa\snon-aggregate\sfunction\swith\san\sOVER\sclause\sin\sa\smulti-row\sVALUES\sclause. +D 2024-03-18T10:54:48.739 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c eef4b58b1c5f488c7bd099af3a571ff32509d00a1c990f17c0bc5e752ed33462 +F src/expr.c 27fdcdc65bca88934dfc4af0efe7a3eae095267bf7592b562abb6a11292c2b82 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 60723a55f68e8e42027d49a159a1be8b92cb0f538a65cb363ff65637e8a41703 +F test/values.test 336ce9404c15cc9ff70f74a374e6da474724c94e69ea658aeab279d94623142f F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0dce6211690210e802545cbca9b3375e07075e117fad3f8c921879da7671d981 -R 04c934383a09ffd06af013a1dd47675b -U drh -Z ca3e70db7b33adfad0eeda8b7a11174b +P 0eb2fbb8910e7a372c50db3ae44238d7b161f0e45858b74061b5228aec5fcc7e +R 0c271dec25d4e7ba3707539d1d6d785b +U dan +Z 92342f3e47401a6da453743f142fe632 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 186e057cef..18c1998557 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0eb2fbb8910e7a372c50db3ae44238d7b161f0e45858b74061b5228aec5fcc7e \ No newline at end of file +10ee6fcba08ab1281235197602148fe062560e1d5034a477b8e7b574dd3e2907 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 3ba07fb2dc..be8339c305 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2387,6 +2387,7 @@ static SQLITE_NOINLINE int exprNodeIsConstantFunction( if( pDef==0 || pDef->xFinalize!=0 || (pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 + || pExpr->y.pWin ){ pWalker->eCode = 0; return WRC_Abort; diff --git a/test/values.test b/test/values.test index b96c9e5d23..caa33058bf 100644 --- a/test/values.test +++ b/test/values.test @@ -415,5 +415,10 @@ do_execsql_test 13.0 { FROM t1; } {xyz} +do_catchsql_test 13.1 { + VALUES(300), (zeroblob(300) OVER win); +} {1 {zeroblob() may not be used as a window function}} + + finish_test From 75924d3ae22587cac6c68caad9212a7621e47135 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Mar 2024 11:12:22 +0000 Subject: [PATCH 0241/1030] Ensure the database schema has been loaded and the database encoding gleaned before beginning to code a multi-row VALUES clause. FossilOrigin-Name: 2ff476eb3d1f4a2146f4a48b57895a00a3ff5beb29afa679ae53ea58cac07c76 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/insert.c | 8 ++++++++ test/values.test | 16 ++++++++++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f72f4d1d80..b3ff72f880 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scaused\sby\sa\snon-aggregate\sfunction\swith\san\sOVER\sclause\sin\sa\smulti-row\sVALUES\sclause. -D 2024-03-18T10:54:48.739 +C Ensure\sthe\sdatabase\sschema\shas\sbeen\sloaded\sand\sthe\sdatabase\sencoding\sgleaned\sbefore\sbeginning\sto\scode\sa\smulti-row\sVALUES\sclause. +D 2024-03-18T11:12:22.121 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c f0755de645ee8e632445b731951c75b7484ccadb890ade4cbc8db269327ff4b8 +F src/insert.c 507113439413cdda2705b98089068be2b84273984bd2fbefe5e6a63efd2654a4 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 336ce9404c15cc9ff70f74a374e6da474724c94e69ea658aeab279d94623142f +F test/values.test 301f9dcf37e654e9fb7f210ebeded878b620f17965f3b6b0d273323183538e82 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0eb2fbb8910e7a372c50db3ae44238d7b161f0e45858b74061b5228aec5fcc7e -R 0c271dec25d4e7ba3707539d1d6d785b +P 10ee6fcba08ab1281235197602148fe062560e1d5034a477b8e7b574dd3e2907 +R 22155fb84ed7e9f97f13e6f0600beffd U dan -Z 92342f3e47401a6da453743f142fe632 +Z 0dcb69e533979c58b8fa8014884ff3fb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 18c1998557..f196850839 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -10ee6fcba08ab1281235197602148fe062560e1d5034a477b8e7b574dd3e2907 \ No newline at end of file +2ff476eb3d1f4a2146f4a48b57895a00a3ff5beb29afa679ae53ea58cac07c76 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 2c6a76b78d..7d386f5d2b 100644 --- a/src/insert.c +++ b/src/insert.c @@ -698,12 +698,20 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ }else{ SrcItem *p = 0; /* SrcItem that reads from co-routine */ + if( pLeft->pSrc->nSrc==0 ){ /* Co-routine has not yet been started and the special Select object ** that accesses the co-routine has not yet been created. This block ** does both those things. */ Vdbe *v = sqlite3GetVdbe(pParse); Select *pRet = sqlite3SelectNew(pParse, 0, 0, 0, 0, 0, 0, 0, 0); + + /* Ensure the database schema has been read. This is to ensure we have + ** the correct text encoding. */ + if( (pParse->db->mDbFlags & DBFLAG_SchemaKnownOk)==0 ){ + sqlite3ReadSchema(pParse); + } + if( pRet ){ SelectDest dest; pRet->pSrc->nSrc = 1; diff --git a/test/values.test b/test/values.test index caa33058bf..d6eb0684e1 100644 --- a/test/values.test +++ b/test/values.test @@ -419,6 +419,22 @@ do_catchsql_test 13.1 { VALUES(300), (zeroblob(300) OVER win); } {1 {zeroblob() may not be used as a window function}} +#-------------------------------------------------------------------------- +reset_db +do_execsql_test 14.1 { + PRAGMA encoding = utf16; + CREATE TABLE t1(a, b); +} {} + +db close +sqlite3 db test.db + +do_execsql_test 14.2 { + INSERT INTO t1 VALUES + (17, 'craft'), + (16, 'urtlek' IN(1,2,3)); +} + finish_test From 27a5ee855d6428246ea7fc9511a2a10a85c3199c Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 18 Mar 2024 12:49:30 +0000 Subject: [PATCH 0242/1030] Improvements to EXPLAIN QUERY PLAN output for multi-row VALUES claues. FossilOrigin-Name: ac6f095e13e43d66c06552c8b01f6bec3407c9d41a34c4cdb0be57b0b828ad0d --- manifest | 22 ++++++++++---------- manifest.uuid | 2 +- src/insert.c | 4 ++++ src/printf.c | 3 +++ src/sqliteInt.h | 1 + src/where.c | 6 +++++- test/values.test | 52 +++++++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 76 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index b3ff72f880..93cb0216d1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthe\sdatabase\sschema\shas\sbeen\sloaded\sand\sthe\sdatabase\sencoding\sgleaned\sbefore\sbeginning\sto\scode\sa\smulti-row\sVALUES\sclause. -D 2024-03-18T11:12:22.121 +C Improvements\sto\sEXPLAIN\sQUERY\sPLAN\soutput\sfor\smulti-row\sVALUES\sclaues. +D 2024-03-18T12:49:30.989 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 507113439413cdda2705b98089068be2b84273984bd2fbefe5e6a63efd2654a4 +F src/insert.c 3b3661886b198d9c5e26c189a802782d35e6b415d0edf57af8c273225c2ae8f2 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -746,7 +746,7 @@ F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 F src/pragma.c e8221d6310c9923c80f6fa6d09b7ea7c5263a671f53db8d0894df23efcdb617b F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c -F src/printf.c 10e8bad30042f8bd6114a013b4afc229ec8ad255ab27518d7d9f52e8cbc5cd0a +F src/printf.c aec4a5d743796be82d61c5d127d0f4615efbe61620a7a16968c5e2c9378ab37b F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 @@ -755,7 +755,7 @@ F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8 F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 4bf7dcc1d2015a6cdd0a2cba5ef33f8f4f7bc14ebc7205321e2488c14eead77d +F src/sqliteInt.h f0014674d40b401795b4ff026fc4804aed3887f50d206fb221ddf4f2004bc3ef F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 3efa165f9205602eef711af071db3862531fcda2b1ad875cda5e2c5effa56fee +F src/where.c 5e9a5d642cceb666152c59091a3dbb645a9dda209b4e65a2f9215ee9298d26cf F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 301f9dcf37e654e9fb7f210ebeded878b620f17965f3b6b0d273323183538e82 +F test/values.test 77f72e80ad7b9e362e309bccb391307f41d0a41d1cd159cbdadb2de043505184 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 10ee6fcba08ab1281235197602148fe062560e1d5034a477b8e7b574dd3e2907 -R 22155fb84ed7e9f97f13e6f0600beffd -U dan -Z 0dcb69e533979c58b8fa8014884ff3fb +P 2ff476eb3d1f4a2146f4a48b57895a00a3ff5beb29afa679ae53ea58cac07c76 +R dd6d36e36b292e54015829bdd4a764a6 +U drh +Z 67655d85fa3f7ad082be72ee3ee927a1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f196850839..21dcd3d6f2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2ff476eb3d1f4a2146f4a48b57895a00a3ff5beb29afa679ae53ea58cac07c76 \ No newline at end of file +ac6f095e13e43d66c06552c8b01f6bec3407c9d41a34c4cdb0be57b0b828ad0d \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 7d386f5d2b..7256281fd2 100644 --- a/src/insert.c +++ b/src/insert.c @@ -721,6 +721,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; p->regReturn = ++pParse->nMem; p->iCursor = -1; + p->u1.nRow = 2; sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub); sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); @@ -733,6 +734,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ dest.nSdst = pLeft->pEList->nExpr; pParse->nMem += 2 + dest.nSdst; + pLeft->selFlags |= SF_MultiValue; sqlite3Select(pParse, pLeft, &dest); p->regResult = dest.iSdst; assert( pParse->nErr || dest.iSdst>0 ); @@ -740,6 +742,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ } }else{ p = &pLeft->pSrc->a[0]; + p->u1.nRow++; } if( pParse->nErr==0 ){ @@ -1102,6 +1105,7 @@ void sqlite3Insert( dest.iSDParm = regYield = pItem->regReturn; regFromSelect = pItem->regResult; nColumn = pItem->pSelect->pEList->nExpr; + ExplainQueryPlan((pParse, 0, "SCAN %S", pItem)); if( bIdListInOrder && nColumn==pTab->nCol ){ regData = regFromSelect; regRowid = regData - 1; diff --git a/src/printf.c b/src/printf.c index 186e95bb85..0aea74e890 100644 --- a/src/printf.c +++ b/src/printf.c @@ -860,6 +860,9 @@ void sqlite3_str_vappendf( assert( pSel!=0 ); if( pSel->selFlags & SF_NestedFrom ){ sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId); + }else if( pSel->selFlags & SF_MultiValue ){ + sqlite3_str_appendf(pAccum, "%u-ROW VALUES CLAUSE", + pItem->u1.nRow); }else{ sqlite3_str_appendf(pAccum, "(subquery-%u)", pSel->selId); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 54fe9458fc..01a5126499 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3311,6 +3311,7 @@ struct SrcItem { union { char *zIndexedBy; /* Identifier from "INDEXED BY " clause */ ExprList *pFuncArg; /* Arguments to table-valued-function */ + u32 nRow; /* Number of rows in a VALUES clause */ } u1; union { Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */ diff --git a/src/where.c b/src/where.c index 2a99c73980..2463e823c8 100644 --- a/src/where.c +++ b/src/where.c @@ -6144,7 +6144,11 @@ WhereInfo *sqlite3WhereBegin( ){ pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE; } - ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW")); + if( ALWAYS(pWInfo->pSelect) + && (pWInfo->pSelect->selFlags & SF_MultiValue)==0 + ){ + ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW")); + } }else{ /* Assign a bit from the bitmask to every term in the FROM clause. ** diff --git a/test/values.test b/test/values.test index d6eb0684e1..8365584b4a 100644 --- a/test/values.test +++ b/test/values.test @@ -435,6 +435,56 @@ do_execsql_test 14.2 { (16, 'urtlek' IN(1,2,3)); } +#-------------------------------------------------------------------------- +# +reset_db +do_eqp_test 15.1 { + VALUES(1),(2),(3),(4),(5); +} { + QUERY PLAN + `--SCAN 5-ROW VALUES CLAUSE +} +do_execsql_test 15.2 { + CREATE TABLE t1(a,b); +} +do_eqp_test 15.3 { + INSERT INTO t1 VALUES + (1,2),(3,4),(7,8); +} { + QUERY PLAN + `--SCAN 3-ROW VALUES CLAUSE +} +do_eqp_test 15.4 { + INSERT INTO t1 VALUES + (1,2),(3,4),(7,8), + (5,coalesce(6,random())); +} { + QUERY PLAN + `--COMPOUND QUERY + |--LEFT-MOST SUBQUERY + | `--SCAN 3-ROW VALUES CLAUSE + `--UNION ALL + `--SCAN CONSTANT ROW +} +do_eqp_test 15.5 { + SELECT * FROM (VALUES(1),(2),(3),(4),(5),(6)), (VALUES('a'),('b'),('c')); +} { + QUERY PLAN + |--SCAN 6-ROW VALUES CLAUSE + `--SCAN 3-ROW VALUES CLAUSE +} +do_execsql_test 15.6 { + CREATE TABLE t2(x,y); +} +do_eqp_test 15.7 { + SELECT * FROM t2 UNION ALL VALUES(1,2),(3,4),(5,6),(7,8); +} { + QUERY PLAN + `--COMPOUND QUERY + |--LEFT-MOST SUBQUERY + | `--SCAN t2 + `--UNION ALL + `--SCAN 4-ROW VALUES CLAUSE +} finish_test - From 871786b7927bc101e25e38d1c446cecd55939ed4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 18 Mar 2024 13:10:54 +0000 Subject: [PATCH 0243/1030] Fix the patch at [10ee6fcba08ab128] so that it works on reduced-size Expr nodes. FossilOrigin-Name: 260bd764c3f2d6d067adb9cd0045b7c24d5e00b02ab2735b1cba455a6143ff4c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 93cb0216d1..5876e426d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sEXPLAIN\sQUERY\sPLAN\soutput\sfor\smulti-row\sVALUES\sclaues. -D 2024-03-18T12:49:30.989 +C Fix\sthe\spatch\sat\s[10ee6fcba08ab128]\sso\sthat\sit\sworks\son\sreduced-size\sExpr\nnodes. +D 2024-03-18T13:10:54.954 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 27fdcdc65bca88934dfc4af0efe7a3eae095267bf7592b562abb6a11292c2b82 +F src/expr.c d7cfe9b9fe7ab47b254706589467d2e65fec3536b936d6f4eb28b84da6726ecc F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2ff476eb3d1f4a2146f4a48b57895a00a3ff5beb29afa679ae53ea58cac07c76 -R dd6d36e36b292e54015829bdd4a764a6 +P ac6f095e13e43d66c06552c8b01f6bec3407c9d41a34c4cdb0be57b0b828ad0d +R 5e57ddae8e8fa784e790916f6a9e17d3 U drh -Z 67655d85fa3f7ad082be72ee3ee927a1 +Z 9ad56bfa46f009d741e8a52554c68de1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 21dcd3d6f2..2ca2f7c4e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac6f095e13e43d66c06552c8b01f6bec3407c9d41a34c4cdb0be57b0b828ad0d \ No newline at end of file +260bd764c3f2d6d067adb9cd0045b7c24d5e00b02ab2735b1cba455a6143ff4c \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index be8339c305..3a7065b21f 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2387,7 +2387,7 @@ static SQLITE_NOINLINE int exprNodeIsConstantFunction( if( pDef==0 || pDef->xFinalize!=0 || (pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 - || pExpr->y.pWin + || ExprHasProperty(pExpr, EP_WinFunc) ){ pWalker->eCode = 0; return WRC_Abort; From ac7c6f58540e07a1db2cda5ed58b5fe06fc23dd2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 18 Mar 2024 13:31:24 +0000 Subject: [PATCH 0244/1030] Add assert() statements to validate access to the SrcItem.u1.nRow union member. FossilOrigin-Name: 21f616d9b948efca441f8d45d0a95f4c052ce8b6daec7fa582ad9a00b82ca570 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/insert.c | 2 +- src/printf.c | 1 + src/sqliteInt.h | 10 ++++++---- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 5876e426d7..96cee0f9f8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\spatch\sat\s[10ee6fcba08ab128]\sso\sthat\sit\sworks\son\sreduced-size\sExpr\nnodes. -D 2024-03-18T13:10:54.954 +C Add\sassert()\sstatements\sto\svalidate\saccess\sto\sthe\sSrcItem.u1.nRow\sunion\smember. +D 2024-03-18T13:31:24.110 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 3b3661886b198d9c5e26c189a802782d35e6b415d0edf57af8c273225c2ae8f2 +F src/insert.c 59ae6959ccd23ea084159b4268d3fb5e6daffcc26b7cf1ad37201d823eecad82 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -746,7 +746,7 @@ F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 F src/pragma.c e8221d6310c9923c80f6fa6d09b7ea7c5263a671f53db8d0894df23efcdb617b F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c -F src/printf.c aec4a5d743796be82d61c5d127d0f4615efbe61620a7a16968c5e2c9378ab37b +F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 @@ -755,7 +755,7 @@ F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8 F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h f0014674d40b401795b4ff026fc4804aed3887f50d206fb221ddf4f2004bc3ef +F src/sqliteInt.h a58b4a33a9807667503a053721a4cd736cda8b60daae896a1b04f120a64c9fd2 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ac6f095e13e43d66c06552c8b01f6bec3407c9d41a34c4cdb0be57b0b828ad0d -R 5e57ddae8e8fa784e790916f6a9e17d3 +P 260bd764c3f2d6d067adb9cd0045b7c24d5e00b02ab2735b1cba455a6143ff4c +R 75dcb9b9acd93ebd15b87898d6bfec55 U drh -Z 9ad56bfa46f009d741e8a52554c68de1 +Z 5ddd66d0b5fd1a33a6a204e07bcebf08 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2ca2f7c4e3..242c703a39 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -260bd764c3f2d6d067adb9cd0045b7c24d5e00b02ab2735b1cba455a6143ff4c \ No newline at end of file +21f616d9b948efca441f8d45d0a95f4c052ce8b6daec7fa582ad9a00b82ca570 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 7256281fd2..be558be78d 100644 --- a/src/insert.c +++ b/src/insert.c @@ -698,7 +698,6 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ }else{ SrcItem *p = 0; /* SrcItem that reads from co-routine */ - if( pLeft->pSrc->nSrc==0 ){ /* Co-routine has not yet been started and the special Select object ** that accesses the co-routine has not yet been created. This block @@ -742,6 +741,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ } }else{ p = &pLeft->pSrc->a[0]; + assert( !p->fg.isTabFunc && !p->fg.isIndexedBy ); p->u1.nRow++; } diff --git a/src/printf.c b/src/printf.c index 0aea74e890..eb22ee320d 100644 --- a/src/printf.c +++ b/src/printf.c @@ -861,6 +861,7 @@ void sqlite3_str_vappendf( if( pSel->selFlags & SF_NestedFrom ){ sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId); }else if( pSel->selFlags & SF_MultiValue ){ + assert( !pItem->fg.isTabFunc && !pItem->fg.isIndexedBy ); sqlite3_str_appendf(pAccum, "%u-ROW VALUES CLAUSE", pItem->u1.nRow); }else{ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 01a5126499..8d18bfdfbb 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3270,10 +3270,12 @@ struct IdList { ** ** Union member validity: ** -** u1.zIndexedBy fg.isIndexedBy && !fg.isTabFunc -** u1.pFuncArg fg.isTabFunc && !fg.isIndexedBy -** u2.pIBIndex fg.isIndexedBy && !fg.isCte -** u2.pCteUse fg.isCte && !fg.isIndexedBy +** u1.zIndexedBy fg.isIndexedBy && !fg.isTabFunc +** u1.pFuncArg fg.isTabFunc && !fg.isIndexedBy +** u1.nRow !fg.isTabFunc && !fg.isIndexedBy +** +** u2.pIBIndex fg.isIndexedBy && !fg.isCte +** u2.pCteUse fg.isCte && !fg.isIndexedBy */ struct SrcItem { Schema *pSchema; /* Schema to which this item is fixed */ From b03805b70b1312dc92b6a394ac0d09be132e6a68 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 18 Mar 2024 15:10:00 +0000 Subject: [PATCH 0245/1030] Change a test case to use a window function rather than random() to disable the VALUES clause optimization. FossilOrigin-Name: c589149a138fa0a6be3153986fc0f315e052e13ebc0e7006b6529ca02bae413b --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/values.test | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 96cee0f9f8..1e6486f30b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sassert()\sstatements\sto\svalidate\saccess\sto\sthe\sSrcItem.u1.nRow\sunion\smember. -D 2024-03-18T13:31:24.110 +C Change\sa\stest\scase\sto\suse\sa\swindow\sfunction\srather\sthan\srandom()\sto\sdisable\nthe\sVALUES\sclause\soptimization. +D 2024-03-18T15:10:00.843 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 77f72e80ad7b9e362e309bccb391307f41d0a41d1cd159cbdadb2de043505184 +F test/values.test 28aae97e976968c8540df0294c3f1cee80780c0df87101ca8969f184789f3029 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 260bd764c3f2d6d067adb9cd0045b7c24d5e00b02ab2735b1cba455a6143ff4c -R 75dcb9b9acd93ebd15b87898d6bfec55 +P 21f616d9b948efca441f8d45d0a95f4c052ce8b6daec7fa582ad9a00b82ca570 +R 8397e730ec47ff60644573ff69916492 U drh -Z 5ddd66d0b5fd1a33a6a204e07bcebf08 +Z 4aa38dc309434c1f95f0da72b0b4ecc4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 242c703a39..168fa1695d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -21f616d9b948efca441f8d45d0a95f4c052ce8b6daec7fa582ad9a00b82ca570 \ No newline at end of file +c589149a138fa0a6be3153986fc0f315e052e13ebc0e7006b6529ca02bae413b \ No newline at end of file diff --git a/test/values.test b/test/values.test index 8365584b4a..14b242c9ec 100644 --- a/test/values.test +++ b/test/values.test @@ -457,14 +457,16 @@ do_eqp_test 15.3 { do_eqp_test 15.4 { INSERT INTO t1 VALUES (1,2),(3,4),(7,8), - (5,coalesce(6,random())); + (5,row_number()OVER()); } { QUERY PLAN `--COMPOUND QUERY |--LEFT-MOST SUBQUERY | `--SCAN 3-ROW VALUES CLAUSE `--UNION ALL - `--SCAN CONSTANT ROW + |--CO-ROUTINE (subquery-xxxxxx) + | `--SCAN CONSTANT ROW + `--SCAN (subquery-xxxxxx) } do_eqp_test 15.5 { SELECT * FROM (VALUES(1),(2),(3),(4),(5),(6)), (VALUES('a'),('b'),('c')); From c195e2374b63d29190e00a74482238eaf426d73f Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 18 Mar 2024 16:30:00 +0000 Subject: [PATCH 0246/1030] Allow the VALUES-as-coroutine optimization to be applied to later rows of a VALUES clause even if earlier rows do not qualify. FossilOrigin-Name: 9a47ea7f0f675f7bf4710901487ce34c7689e618cd1d8b9f94f0ff7ebc3f2841 --- manifest | 14 ++++---- manifest.uuid | 2 +- src/insert.c | 9 +++-- test/values.test | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1e6486f30b..e3e832688e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sa\stest\scase\sto\suse\sa\swindow\sfunction\srather\sthan\srandom()\sto\sdisable\nthe\sVALUES\sclause\soptimization. -D 2024-03-18T15:10:00.843 +C Allow\sthe\sVALUES-as-coroutine\soptimization\sto\sbe\sapplied\sto\slater\srows\sof\na\sVALUES\sclause\seven\sif\searlier\srows\sdo\snot\squalify. +D 2024-03-18T16:30:00.996 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 59ae6959ccd23ea084159b4268d3fb5e6daffcc26b7cf1ad37201d823eecad82 +F src/insert.c a71901268468aff9bc5d4034209026b45a0163c7a21422337de21940c8ab5310 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -1921,7 +1921,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 28aae97e976968c8540df0294c3f1cee80780c0df87101ca8969f184789f3029 +F test/values.test e7c156f92d32ed645908fbad0a1144f0f31650376cdcb212fde701978c89d3b1 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 21f616d9b948efca441f8d45d0a95f4c052ce8b6daec7fa582ad9a00b82ca570 -R 8397e730ec47ff60644573ff69916492 +P c589149a138fa0a6be3153986fc0f315e052e13ebc0e7006b6529ca02bae413b +R 940f14de84991bdaec1e3874c3d6141e U drh -Z 4aa38dc309434c1f95f0da72b0b4ecc4 +Z d0598787dc817aed0c423e65e0b46555 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 168fa1695d..c08cd51c0e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c589149a138fa0a6be3153986fc0f315e052e13ebc0e7006b6529ca02bae413b \ No newline at end of file +9a47ea7f0f675f7bf4710901487ce34c7689e618cd1d8b9f94f0ff7ebc3f2841 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index be558be78d..a87d714a0c 100644 --- a/src/insert.c +++ b/src/insert.c @@ -670,8 +670,7 @@ static int exprListIsNoAffinity(Parse *pParse, ExprList *pRow){ */ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ - if( pLeft->pPrior /* co-routine precluded by prior row */ - || pParse->bHasWith /* condition (a) above */ + if( pParse->bHasWith /* condition (a) above */ || pParse->db->init.busy /* condition (b) above */ || exprListIsConstant(pParse,pRow)==0 /* condition (c) above */ || (pLeft->pSrc->nSrc==0 && @@ -714,6 +713,12 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ if( pRet ){ SelectDest dest; pRet->pSrc->nSrc = 1; + pRet->pPrior = pLeft->pPrior; + pRet->op = pLeft->op; + pLeft->pPrior = 0; + pLeft->op = TK_SELECT; + assert( pLeft->pNext==0 ); + assert( pRet->pNext==0 ); p = &pRet->pSrc->a[0]; p->pSelect = pLeft; p->fg.viaCoroutine = 1; diff --git a/test/values.test b/test/values.test index 14b242c9ec..43f8e0e6fe 100644 --- a/test/values.test +++ b/test/values.test @@ -489,4 +489,95 @@ do_eqp_test 15.7 { `--SCAN 4-ROW VALUES CLAUSE } +#-------------------------------------------------------------------------- +# The VALUES-as-coroutine optimization can be applied to later rows of +# a VALUES clause even if earlier rows do not qualify. +# +reset_db +do_execsql_test 16.1 { + CREATE TABLE t1(a,b); +} +do_execsql_test 16.2 { + BEGIN; + INSERT INTO t1 VALUES(1,2),(3,4),(5,6), + (7,row_number()OVER()), + (9,10), (11,12), (13,14), (15,16); + SELECT * FROM t1 ORDER BY a, b; + ROLLBACK; +} {1 2 3 4 5 6 7 1 9 10 11 12 13 14 15 16} +do_eqp_test 16.3 { + INSERT INTO t1 VALUES(1,2),(3,4),(5,6), + (7,row_number()OVER()), + (9,10), (11,12), (13,14), (15,16); +} { + QUERY PLAN + `--COMPOUND QUERY + |--LEFT-MOST SUBQUERY + | `--SCAN 3-ROW VALUES CLAUSE + |--UNION ALL + | |--CO-ROUTINE (subquery-xxxxxx) + | | `--SCAN CONSTANT ROW + | `--SCAN (subquery-xxxxxx) + `--UNION ALL + `--SCAN 4-ROW VALUES CLAUSE +} +do_execsql_test 16.4 { + BEGIN; + INSERT INTO t1 VALUES + (1,row_number()OVER()), + (2,3), (4,5), (6,7); + SELECT * FROM t1 ORDER BY a, b; + ROLLBACK; +} {1 1 2 3 4 5 6 7} +do_eqp_test 16.5 { + INSERT INTO t1 VALUES + (1,row_number()OVER()), + (2,3), (4,5), (6,7); +} { + QUERY PLAN + `--COMPOUND QUERY + |--LEFT-MOST SUBQUERY + | |--CO-ROUTINE (subquery-xxxxxx) + | | `--SCAN CONSTANT ROW + | `--SCAN (subquery-xxxxxx) + `--UNION ALL + `--SCAN 3-ROW VALUES CLAUSE +} +do_execsql_test 16.6 { + BEGIN; + INSERT INTO t1 VALUES + (1,2),(3,4), + (5,row_number()OVER()), + (7,8),(9,10),(11,12), + (13,row_number()OVER()), + (15,16),(17,18),(19,20),(21,22); + SELECT * FROM t1 ORDER BY a, b; + ROLLBACK; +} { 1 2 3 4 5 1 7 8 9 10 11 12 13 1 15 16 17 18 19 20 21 22} +do_eqp_test 16.7 { + INSERT INTO t1 VALUES + (1,2),(3,4), + (5,row_number()OVER()), + (7,8),(9,10),(11,12), + (13,row_number()OVER()), + (15,16),(17,18),(19,20),(21,22); +} { + QUERY PLAN + `--COMPOUND QUERY + |--LEFT-MOST SUBQUERY + | `--SCAN 2-ROW VALUES CLAUSE + |--UNION ALL + | |--CO-ROUTINE (subquery-xxxxxx) + | | `--SCAN CONSTANT ROW + | `--SCAN (subquery-xxxxxx) + |--UNION ALL + | `--SCAN 3-ROW VALUES CLAUSE + |--UNION ALL + | |--CO-ROUTINE (subquery-xxxxxx) + | | `--SCAN CONSTANT ROW + | `--SCAN (subquery-xxxxxx) + `--UNION ALL + `--SCAN 4-ROW VALUES CLAUSE +} + finish_test From 2ad2584581992f59543bc00c3be313d29448aeb0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 18 Mar 2024 17:13:52 +0000 Subject: [PATCH 0247/1030] Fix harmless compiler (scan-build) warnings. FossilOrigin-Name: c86f9f2a15ffc726b7f0d9bba5a8c4dfdaeea6a297e0b591c554fff3d1fe6e1c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e3e832688e..1e94c6c964 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sthe\sVALUES-as-coroutine\soptimization\sto\sbe\sapplied\sto\slater\srows\sof\na\sVALUES\sclause\seven\sif\searlier\srows\sdo\snot\squalify. -D 2024-03-18T16:30:00.996 +C Fix\sharmless\scompiler\s(scan-build)\swarnings. +D 2024-03-18T17:13:52.924 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c a71901268468aff9bc5d4034209026b45a0163c7a21422337de21940c8ab5310 +F src/insert.c 06ce505713e86172612f9e01febefd2d3331d1f70461b4ada0eae5a76bb6349f F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -2179,8 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c589149a138fa0a6be3153986fc0f315e052e13ebc0e7006b6529ca02bae413b -R 940f14de84991bdaec1e3874c3d6141e +P 9a47ea7f0f675f7bf4710901487ce34c7689e618cd1d8b9f94f0ff7ebc3f2841 +R 99b0c172599c8a90caf2454e462eb6ef U drh -Z d0598787dc817aed0c423e65e0b46555 +Z e6f67e954fdd4f797f1644f6604d7595 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c08cd51c0e..7f56713a39 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a47ea7f0f675f7bf4710901487ce34c7689e618cd1d8b9f94f0ff7ebc3f2841 \ No newline at end of file +c86f9f2a15ffc726b7f0d9bba5a8c4dfdaeea6a297e0b591c554fff3d1fe6e1c \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index a87d714a0c..fe7ba05dc1 100644 --- a/src/insert.c +++ b/src/insert.c @@ -751,6 +751,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ } if( pParse->nErr==0 ){ + assert( p!=0 ); if( p->pSelect->pEList->nExpr!=pRow->nExpr ){ sqlite3SelectWrongNumTermsError(pParse, p->pSelect); }else{ @@ -1099,7 +1100,6 @@ void sqlite3Insert( if( pSelect ){ /* Data is coming from a SELECT or from a multi-row VALUES clause. ** Generate a co-routine to run the SELECT. */ - int regYield; /* Register holding co-routine entry-point */ int rc; /* Result code */ if( pSelect->pSrc->nSrc==1 @@ -1107,7 +1107,7 @@ void sqlite3Insert( && pSelect->pPrior==0 ){ SrcItem *pItem = &pSelect->pSrc->a[0]; - dest.iSDParm = regYield = pItem->regReturn; + dest.iSDParm = pItem->regReturn; regFromSelect = pItem->regResult; nColumn = pItem->pSelect->pEList->nExpr; ExplainQueryPlan((pParse, 0, "SCAN %S", pItem)); @@ -1118,7 +1118,7 @@ void sqlite3Insert( } }else{ int addrTop; /* Top of the co-routine */ - regYield = ++pParse->nMem; + int regYield = ++pParse->nMem; addrTop = sqlite3VdbeCurrentAddr(v) + 1; sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop); sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield); From fc2d862318876ff36910b57f8ecafdda8d36fa59 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 18 Mar 2024 18:03:17 +0000 Subject: [PATCH 0248/1030] Remove unnecessary blank lines from build commands in the default Makefile.in. FossilOrigin-Name: 76fb3a908f45230b956cb659c754e47603e80aa72a2aad50d479437a9c013f61 --- Makefile.in | 6 ++---- manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index e16fa94345..c16e1c127d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -817,8 +817,7 @@ has_tclsh85: touch .target_source sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl src-verify has_tclsh84 - $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(AMALGAMATION_LINE_MACROS) \ - $(EXTRA_SRC) + $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(AMALGAMATION_LINE_MACROS) $(EXTRA_SRC) cp tsrc/sqlite3ext.h . cp $(TOP)/ext/session/sqlite3session.h . @@ -829,8 +828,7 @@ sqlite3r.c: sqlite3.c sqlite3r.h has_tclsh84 cp $(TOP)/ext/recover/sqlite3recover.c tsrc/ cp $(TOP)/ext/recover/sqlite3recover.h tsrc/ cp $(TOP)/ext/recover/dbdata.c tsrc/ - $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl --enable-recover \ - $(AMALGAMATION_LINE_MACROS) $(EXTRA_SRC) + $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl --enable-recover $(AMALGAMATION_LINE_MACROS) $(EXTRA_SRC) sqlite3ext.h: .target_source cp tsrc/sqlite3ext.h . diff --git a/manifest b/manifest index 55bb6354bf..68196a51d6 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\sthe\s"VALUES-as-coroutine"\soptimization.\s\sLarge\sVALUES\sclauses\son\san\nINSERT,\sfor\sexample,\sprepare\sand\srun\sin\sabout\shalf\sthe\stime\sand\swith\shalf\nthe\smemory.\s\sThis\scheck-in\salso\sincludes\senhancements\sto\sthe\sinternal\nsqlite3ExprIsConstant()\sroutine\sto\srecognize\spure\sSQL\sfunctions\sas\sconstant\nif\sthey\shave\sconstant\sarguments. -D 2024-03-18T18:00:17.106 +C Remove\sunnecessary\sblank\slines\sfrom\sbuild\scommands\sin\sthe\sdefault\sMakefile.in. +D 2024-03-18T18:03:17.115 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 5f2389d2a3c44b56621bb5156a9cb6e2bef01f7ec14a19335b1559cf0474bdde +F Makefile.in 993a7874e3d3721df61846f03dda4a9ef7490da11953ae36ba1bb0c0346eaf4a F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc e64a52619310d3067f6c38f56eedd15918a82dade70954197d6da486ad99d7f4 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -2179,9 +2179,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 82035b9cfd28ef6b0ecc6f469f03d2b001189aa4925147cdb784b6b1964eb3b2 c86f9f2a15ffc726b7f0d9bba5a8c4dfdaeea6a297e0b591c554fff3d1fe6e1c -R d086636689a6bb7c4b198edffb3a7c63 -T +closed c86f9f2a15ffc726b7f0d9bba5a8c4dfdaeea6a297e0b591c554fff3d1fe6e1c +P a120c9235f125e05be494038c16a9dd326fd79837698bef17e7879cd0cd75831 +R 8ff4324227d383f5da29d0bfe203141e U drh -Z 48e8dd6fe42c5583ed5ba3f909ede536 +Z 25814839eb089de12c64c949b849b19e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 82d6efaeee..73c10f1cd5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a120c9235f125e05be494038c16a9dd326fd79837698bef17e7879cd0cd75831 \ No newline at end of file +76fb3a908f45230b956cb659c754e47603e80aa72a2aad50d479437a9c013f61 \ No newline at end of file From 365b6e9769681b2bab3300c53ec7131d3df08064 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Mar 2024 20:52:45 +0000 Subject: [PATCH 0249/1030] Avoid spurious SQLITE_IOERR_DATA errors when reading partial pages from a cksumvfs database using a SQLITE_DIRECT_OVERFLOW_READ build. FossilOrigin-Name: 0f485dbece9146eabe5a5c0998a9e35c685a170c3fe6d4509e92aa8dae18a2c0 --- ext/misc/cksumvfs.c | 6 +++--- manifest | 15 ++++++++------- manifest.uuid | 2 +- test/cksumvfs.test | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 test/cksumvfs.test diff --git a/ext/misc/cksumvfs.c b/ext/misc/cksumvfs.c index e7c2c9d5c0..2d7f6584ea 100644 --- a/ext/misc/cksumvfs.c +++ b/ext/misc/cksumvfs.c @@ -446,9 +446,9 @@ static int cksmRead( ** (2) checksum verification is enabled ** (3) we are not in the middle of checkpoint */ - if( iAmt>=512 /* (1) */ - && p->verifyCksm /* (2) */ - && !p->inCkpt /* (3) */ + if( iAmt>=512 && (iAmt & (iAmt-1))==0 /* (1) */ + && p->verifyCksm /* (2) */ + && !p->inCkpt /* (3) */ ){ u8 cksum[8]; cksmCompute((u8*)zBuf, iAmt-8, cksum); diff --git a/manifest b/manifest index 68196a51d6..e0127ab6bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunnecessary\sblank\slines\sfrom\sbuild\scommands\sin\sthe\sdefault\sMakefile.in. -D 2024-03-18T18:03:17.115 +C Avoid\sspurious\sSQLITE_IOERR_DATA\serrors\swhen\sreading\spartial\spages\sfrom\sa\scksumvfs\sdatabase\susing\sa\sSQLITE_DIRECT_OVERFLOW_READ\sbuild. +D 2024-03-18T20:52:45.827 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -382,7 +382,7 @@ F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0e F ext/misc/btreeinfo.c cb952620eedf5c0b7625b678f0f08e54d2ec0011d4e50efda5ebdc97f3df7d04 F ext/misc/carray.c 34fac63770971611c5285de0a9f0ac67d504eaf66be891f637add9290f1c76a5 F ext/misc/carray.h 503209952ccf2431c7fd899ebb92bf46bf7635b38aace42ec8aa1b8d7b6e98a5 -F ext/misc/cksumvfs.c 9224e33cc0cb6aa61ff1d7d7b8fd6fe56beca9f9c47954fa4ae0a69bef608f69 +F ext/misc/cksumvfs.c 3a7931dd30667be6348af919f3f9e6188dfd7646b42af8e399a499b327f5bd63 F ext/misc/closure.c 0e04f52d93e678dd6f950f195f365992edf3c380df246f3d80425cba4c13891e F ext/misc/completion.c ef78835483b43ac18c96be312b90b615d8368189909be03513ab7a9338131298 F ext/misc/compress.c 3354c77a7c8e86e07d849916000cdac451ed96500bfb5bd83b20eb61eee012c9 @@ -977,6 +977,7 @@ F test/changes2.test 07949edcc732af28cb54276bfb7d99723bccc1e905a423648bf57ac5cb0 F test/check.test 56e4ed457e9f8683b9fc56f5b964f461f6e8a8dd5a13f3d495408215d66419ed F test/checkfault.test da6cb3d50247169efcb20bdf57863a3ccfa1d27d9e55cd324f0680096970f014 F test/chunksize.test 427d87791743486cbf0c3b8c625002f3255cb3a89c6eba655a98923b1387b760 +F test/cksumvfs.test 6f05dc95847c06a3dc10eee6b5ab1351d78314a52d0db15717c9388f4cb96646 F test/close.test eccbad8ecd611d974cbf47278c3d4e5874faf02d811338d5d348af42d56d647c F test/closure01.test 9905883f1b171a4638f98fc764879f154e214a306d3d8daf412a15e7f3a9b1e0 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 @@ -2179,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a120c9235f125e05be494038c16a9dd326fd79837698bef17e7879cd0cd75831 -R 8ff4324227d383f5da29d0bfe203141e -U drh -Z 25814839eb089de12c64c949b849b19e +P 76fb3a908f45230b956cb659c754e47603e80aa72a2aad50d479437a9c013f61 +R 3ba9b9e82b0006578500d53bc7e1cee3 +U dan +Z 687b3a53beb157acf8ccda89bb48f5f1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 73c10f1cd5..e141632691 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76fb3a908f45230b956cb659c754e47603e80aa72a2aad50d479437a9c013f61 \ No newline at end of file +0f485dbece9146eabe5a5c0998a9e35c685a170c3fe6d4509e92aa8dae18a2c0 \ No newline at end of file diff --git a/test/cksumvfs.test b/test/cksumvfs.test new file mode 100644 index 0000000000..8c7bcf5511 --- /dev/null +++ b/test/cksumvfs.test @@ -0,0 +1,33 @@ +# 2024 March 19 +# +# 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 +set testprefix cksumvfs + +sqlite3_register_cksumvfs +db close +sqlite3 db test.db +file_control_reservebytes db 8 + +set text [db one "SELECT hex(randomblob(5000))"] + +do_execsql_test 1.0 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + INSERT INTO t1 VALUES(1, $text); +} + +do_execsql_test 1.1 { + SELECT * FROM t1; +} [list 1 $text] + +finish_test From 28cd72ac520883a94cbb8444c38ff42aab485c52 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Mar 2024 21:08:33 +0000 Subject: [PATCH 0250/1030] Fix asan problems in sqlite3rbu.c. Enable RBU for sanitizer release tests. FossilOrigin-Name: ad2ae7717e7a10cf42aeabd3c544e7884fa082295c2babf0fdb19a684d2aba1e --- ext/rbu/sqlite3rbu.c | 4 +++- manifest | 14 +++++++------- manifest.uuid | 2 +- test/testrunner_data.tcl | 1 + 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ext/rbu/sqlite3rbu.c b/ext/rbu/sqlite3rbu.c index 15b05cede1..feb7695d66 100644 --- a/ext/rbu/sqlite3rbu.c +++ b/ext/rbu/sqlite3rbu.c @@ -199,6 +199,7 @@ typedef unsigned int u32; typedef unsigned short u16; typedef unsigned char u8; typedef sqlite3_int64 i64; +typedef sqlite3_uint64 u64; #endif /* @@ -885,6 +886,7 @@ static int rbuObjIterNext(sqlite3rbu *p, RbuObjIter *pIter){ if( rc!=SQLITE_ROW ){ rc = resetAndCollectError(pIter->pTblIter, &p->zErrmsg); pIter->zTbl = 0; + pIter->zDataTbl = 0; }else{ pIter->zTbl = (const char*)sqlite3_column_text(pIter->pTblIter, 0); pIter->zDataTbl = (const char*)sqlite3_column_text(pIter->pTblIter,1); @@ -2979,7 +2981,7 @@ static i64 rbuShmChecksum(sqlite3rbu *p){ u32 volatile *ptr; p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, (void volatile**)&ptr); if( p->rc==SQLITE_OK ){ - iRet = ((i64)ptr[10] << 32) + ptr[11]; + iRet = (i64)(((u64)ptr[10] << 32) + ptr[11]); } } return iRet; diff --git a/manifest b/manifest index e0127ab6bd..a13b01a2c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sspurious\sSQLITE_IOERR_DATA\serrors\swhen\sreading\spartial\spages\sfrom\sa\scksumvfs\sdatabase\susing\sa\sSQLITE_DIRECT_OVERFLOW_READ\sbuild. -D 2024-03-18T20:52:45.827 +C Fix\sasan\sproblems\sin\ssqlite3rbu.c.\sEnable\sRBU\sfor\ssanitizer\srelease\stests. +D 2024-03-18T21:08:33.041 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -475,7 +475,7 @@ F ext/rbu/rbuvacuum.test 542561741ff2b262e3694bc6012b44694ee62c545845319a06f3237 F ext/rbu/rbuvacuum2.test ae097d04feb041446a74fac94b24bffeb3fdd60e32b848c5611e507ab702b81b F ext/rbu/rbuvacuum3.test 3ce42695fdf21aaa3499e857d7d4253bc499ad759bcd6c9362042c13cd37d8de F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69eefaebb205 -F ext/rbu/sqlite3rbu.c d4ddf8f0e93772556e452a6c2814063cf47efb760a0834391a9d0cd9859fa4b9 +F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055 F ext/recover/dbdata.c b7746c2ec801b453840831311be4b31f8c8f9dd97791060a69bbf12392c78949 @@ -1689,7 +1689,7 @@ F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf F test/testrunner.tcl 01bc3b5bc900dc73b076180727eb2869dc61426b1ab95ac2f42def5d1f3d407e -F test/testrunner_data.tcl 2f94974e5e3a56af880be72f7a7fd239aa9d4ecf978625435fcc698319c927fa +F test/testrunner_data.tcl 7032a64e4757db0bf83c6874cab2ccbb14a8708b4d68c1ddc8b359e204139cb7 F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 76fb3a908f45230b956cb659c754e47603e80aa72a2aad50d479437a9c013f61 -R 3ba9b9e82b0006578500d53bc7e1cee3 +P 0f485dbece9146eabe5a5c0998a9e35c685a170c3fe6d4509e92aa8dae18a2c0 +R 59c6c1819c5f6280d4b2fc1e8ab12326 U dan -Z 687b3a53beb157acf8ccda89bb48f5f1 +Z 8b503392df6e7d7e46ebd7af33bbcc16 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e141632691..7dfd6e9373 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f485dbece9146eabe5a5c0998a9e35c685a170c3fe6d4509e92aa8dae18a2c0 \ No newline at end of file +ad2ae7717e7a10cf42aeabd3c544e7884fa082295c2babf0fdb19a684d2aba1e \ No newline at end of file diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index f38abad589..73b5472a99 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -108,6 +108,7 @@ namespace eval trd { -DSQLITE_ENABLE_STAT4 -DSQLITE_OMIT_LOOKASIDE=1 -DCONFIG_SLOWDOWN_FACTOR=5.0 + -DSQLITE_ENABLE_RBU --enable-debug --enable-all } From 108dd6a52d3679cc3a772600ac22de792f92c897 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 02:30:24 +0000 Subject: [PATCH 0251/1030] First steps toward getting -DSQLITE_ALLOW_ROWID_IN_VIEW to work again. That compile-time option is untested, undocumented, and unsupported. But it was mentioned in the release notes for version 3.36.0, so I think that means we need to support it forever. FossilOrigin-Name: 7c46ff640247584f1ea260c062de29a0e49f649d1894a526574c1a479006a1fc --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/select.c | 7 ++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index a13b01a2c2..a8b9d2e2ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sasan\sproblems\sin\ssqlite3rbu.c.\sEnable\sRBU\sfor\ssanitizer\srelease\stests. -D 2024-03-18T21:08:33.041 +C First\ssteps\stoward\sgetting\s-DSQLITE_ALLOW_ROWID_IN_VIEW\sto\swork\sagain.\s\sThat\ncompile-time\soption\sis\suntested,\sundocumented,\sand\sunsupported.\s\sBut\sit\swas\nmentioned\sin\sthe\srelease\snotes\sfor\sversion\s3.36.0,\sso\sI\sthink\sthat\smeans\swe\nneed\sto\ssupport\sit\sforever. +D 2024-03-19T02:30:24.246 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -750,7 +750,7 @@ F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c df2bf515fc36e02e97959a70e82da8a4967d6c85590646a7fda2926a734c81ce +F src/select.c 934eb6e543133cb373ab76f791ded2b2b5c13ac50684453494c4b6c4ea4fba24 F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8a F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2180,8 +2180,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0f485dbece9146eabe5a5c0998a9e35c685a170c3fe6d4509e92aa8dae18a2c0 -R 59c6c1819c5f6280d4b2fc1e8ab12326 -U dan -Z 8b503392df6e7d7e46ebd7af33bbcc16 +P ad2ae7717e7a10cf42aeabd3c544e7884fa082295c2babf0fdb19a684d2aba1e +R cc156187f695f7801f18b2af21acf477 +T *branch * rowid-in-view +T *sym-rowid-in-view * +T -sym-trunk * +U drh +Z d1168aa5ebee2530ad432f8f9a6ecbd1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7dfd6e9373..3c83ab3dfc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad2ae7717e7a10cf42aeabd3c544e7884fa082295c2babf0fdb19a684d2aba1e \ No newline at end of file +7c46ff640247584f1ea260c062de29a0e49f649d1894a526574c1a479006a1fc \ No newline at end of file diff --git a/src/select.c b/src/select.c index 1085b99436..5dfabb140d 100644 --- a/src/select.c +++ b/src/select.c @@ -6142,7 +6142,9 @@ static int selectExpander(Walker *pWalker, Select *p){ pNestedFrom = pFrom->pSelect->pEList; assert( pNestedFrom!=0 ); assert( pNestedFrom->nExpr==pTab->nCol ); +#ifndef SQLITE_ALLOW_ROWID_IN_VIEW assert( VisibleRowid(pTab)==0 ); +#endif }else{ if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ continue; @@ -6174,7 +6176,10 @@ static int selectExpander(Walker *pWalker, Select *p){ pUsing = 0; } - nAdd = pTab->nCol + (VisibleRowid(pTab) && (selFlags&SF_NestedFrom)); + nAdd = pTab->nCol; +#ifndef SQLITE_ALLOW_ROWID_IN_VIEW + if( VisibleRowid(pTab) && (selFlags & SF_NestedFrom)!=0 ) nAdd++; +#endif for(j=0; j Date: Tue, 19 Mar 2024 10:16:17 +0000 Subject: [PATCH 0252/1030] Fix another problem from [c63e26e705f5e967] involving infinities and the Kahan-Babushka-Neumaier summation algorithm. Problem reported by [forum:/forumpost/23b8688ef4|forum post 23b8688ef4]. FossilOrigin-Name: 45d272ef38d5ee6189f81369aefb8e3ac35868a67687012d93c84f2bbc42520a --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/func.c | 6 +++--- src/sqliteInt.h | 7 +++++-- src/util.c | 13 +++++++++++++ test/func.test | 21 +++++++++++++++++++++ 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index a13b01a2c2..d421c59182 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sasan\sproblems\sin\ssqlite3rbu.c.\sEnable\sRBU\sfor\ssanitizer\srelease\stests. -D 2024-03-18T21:08:33.041 +C Fix\sanother\sproblem\sfrom\s[c63e26e705f5e967]\sinvolving\sinfinities\sand\sthe\nKahan-Babushka-Neumaier\ssummation\salgorithm.\s\sProblem\sreported\sby\n[forum:/forumpost/23b8688ef4|forum\spost\s23b8688ef4]. +D 2024-03-19T10:16:17.413 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -703,7 +703,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c d7cfe9b9fe7ab47b254706589467d2e65fec3536b936d6f4eb28b84da6726ecc F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 -F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb +F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f F src/global.c 765a0656d6cbf043cb272ff0ae38f39cc46713539ffe6793258ed3eb4b188b52 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -755,7 +755,7 @@ F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8 F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h a58b4a33a9807667503a053721a4cd736cda8b60daae896a1b04f120a64c9fd2 +F src/sqliteInt.h 9ffcf672d8a55d5bd5b5c8988c14ea575350c4920b7e43393608ac65aee332fe F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -818,7 +818,7 @@ F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c f27a17e6e43fa362abea4db507a1c409f0adc8048ecf4c6479e8d162158ed529 +F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c da8407be6055f5751bf85681542d130a320b4fd1f4d8719bf83a464743d9aae4 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f @@ -1229,7 +1229,7 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75 F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9 F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test 504d202650c7940b5aa98364dd68f242df87f39f829e51074a55d79fc7bc7414 +F test/func.test 648ca90b9c36e9eefd8005d64cd8ad2d2dba73891df0fbe157b866d1cc95bdc8 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0f485dbece9146eabe5a5c0998a9e35c685a170c3fe6d4509e92aa8dae18a2c0 -R 59c6c1819c5f6280d4b2fc1e8ab12326 -U dan -Z 8b503392df6e7d7e46ebd7af33bbcc16 +P ad2ae7717e7a10cf42aeabd3c544e7884fa082295c2babf0fdb19a684d2aba1e +R 6728c90829563f9564b3fe7ee7e264f2 +U drh +Z 8f46ba2909e90f1ebfbdf6c7d1fcfdc3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7dfd6e9373..aafcf89491 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad2ae7717e7a10cf42aeabd3c544e7884fa082295c2babf0fdb19a684d2aba1e \ No newline at end of file +45d272ef38d5ee6189f81369aefb8e3ac35868a67687012d93c84f2bbc42520a \ No newline at end of file diff --git a/src/func.c b/src/func.c index 9fbd1e9e1c..18004984d9 100644 --- a/src/func.c +++ b/src/func.c @@ -1892,7 +1892,7 @@ static void sumFinalize(sqlite3_context *context){ if( p->approx ){ if( p->ovrfl ){ sqlite3_result_error(context,"integer overflow",-1); - }else if( !sqlite3IsNaN(p->rErr) ){ + }else if( !sqlite3IsOverflow(p->rErr) ){ sqlite3_result_double(context, p->rSum+p->rErr); }else{ sqlite3_result_double(context, p->rSum); @@ -1909,7 +1909,7 @@ static void avgFinalize(sqlite3_context *context){ double r; if( p->approx ){ r = p->rSum; - if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; + if( !sqlite3IsOverflow(p->rErr) ) r += p->rErr; }else{ r = (double)(p->iSum); } @@ -1923,7 +1923,7 @@ static void totalFinalize(sqlite3_context *context){ if( p ){ if( p->approx ){ r = p->rSum; - if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; + if( !sqlite3IsOverflow(p->rErr) ) r += p->rErr; }else{ r = (double)(p->iSum); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8d18bfdfbb..db1ede8e6d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4712,10 +4712,13 @@ void sqlite3MutexWarnOnContention(sqlite3_mutex*); # define EXP754 (((u64)0x7ff)<<52) # define MAN754 ((((u64)1)<<52)-1) # define IsNaN(X) (((X)&EXP754)==EXP754 && ((X)&MAN754)!=0) +# define IsOvfl(X) (((X)&EXP754)==EXP754) int sqlite3IsNaN(double); + int sqlite3IsOverflow(double); #else -# define IsNaN(X) 0 -# define sqlite3IsNaN(X) 0 +# define IsNaN(X) 0 +# define sqlite3IsNaN(X) 0 +# define sqlite3IsOVerflow(X) 0 #endif /* diff --git a/src/util.c b/src/util.c index 8c9e980cd1..3b10ba60ad 100644 --- a/src/util.c +++ b/src/util.c @@ -68,6 +68,19 @@ int sqlite3IsNaN(double x){ } #endif /* SQLITE_OMIT_FLOATING_POINT */ +#ifndef SQLITE_OMIT_FLOATING_POINT +/* +** Return true if the floating point value is NaN or +Inf or -Inf. +*/ +int sqlite3IsOverflow(double x){ + int rc; /* The value return */ + u64 y; + memcpy(&y,&x,sizeof(y)); + rc = IsOvfl(y); + return rc; +} +#endif /* SQLITE_OMIT_FLOATING_POINT */ + /* ** Compute a string length that is limited to what can be stored in ** lower 30 bits of a 32-bit signed integer. diff --git a/test/func.test b/test/func.test index c7b8f72352..fa7be84242 100644 --- a/test/func.test +++ b/test/func.test @@ -1561,4 +1561,25 @@ do_execsql_test func-38.100 { WITH t1(x) AS (VALUES(-9e+999)) SELECT sum(x), avg(x), total(x) FROM t1; } {Inf Inf Inf -Inf -Inf -Inf} +# 2024-03-21 https://sqlite.org/forum/forumpost/23b8688ef4 +# Another problem with Kahan-Babushka-Neumaier summation and +# infinities. +# +do_execsql_test func-39.101 { + WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<1) + SELECT quote(sum(1.7976931348623157e308)), + quote(avg(1.7976931348623157e308)), + quote(total(1.7976931348623157e308)) + FROM c; +} {1.797693134862315708e+308 1.797693134862315708e+308 1.797693134862315708e+308} +for {set i 2} {$i<10} {incr i} { + do_execsql_test func-39.[expr {10*$i+100}] { + WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<$i) + SELECT quote(sum(1.7976931348623157e308)), + quote(avg(1.7976931348623157e308)), + quote(total(1.7976931348623157e308)) + FROM c; + } {9.0e+999 9.0e+999 9.0e+999} +} + finish_test From 1fe31dcfabf886517e41cbab3b8435e0e828b44f Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 10:41:18 +0000 Subject: [PATCH 0253/1030] Adjustments to the test cases for the previous check-in to make them cross-platform Linux/Mac/Windows. Test chance only. No change to core code. FossilOrigin-Name: 0dddadbd5b217a48bb5c1b0568a03fbafb89dba98c577727bf4f79ff7e0ca849 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/func.test | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index d421c59182..26d692be1b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\sproblem\sfrom\s[c63e26e705f5e967]\sinvolving\sinfinities\sand\sthe\nKahan-Babushka-Neumaier\ssummation\salgorithm.\s\sProblem\sreported\sby\n[forum:/forumpost/23b8688ef4|forum\spost\s23b8688ef4]. -D 2024-03-19T10:16:17.413 +C Adjustments\sto\sthe\stest\scases\sfor\sthe\sprevious\scheck-in\sto\smake\sthem\ncross-platform\sLinux/Mac/Windows.\s\sTest\schance\sonly.\s\sNo\schange\sto\score\scode. +D 2024-03-19T10:41:18.138 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1229,7 +1229,7 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75 F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9 F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test 648ca90b9c36e9eefd8005d64cd8ad2d2dba73891df0fbe157b866d1cc95bdc8 +F test/func.test b56905748ce0567c01d60005f3e6ad1af19453d224ba4730ee687d048fd09ef9 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ad2ae7717e7a10cf42aeabd3c544e7884fa082295c2babf0fdb19a684d2aba1e -R 6728c90829563f9564b3fe7ee7e264f2 +P 45d272ef38d5ee6189f81369aefb8e3ac35868a67687012d93c84f2bbc42520a +R 06f52063180a10fd2f7e8878024a8e93 U drh -Z 8f46ba2909e90f1ebfbdf6c7d1fcfdc3 +Z be89e098a4549a3844da98de72222ae6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aafcf89491..46aef1d450 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -45d272ef38d5ee6189f81369aefb8e3ac35868a67687012d93c84f2bbc42520a \ No newline at end of file +0dddadbd5b217a48bb5c1b0568a03fbafb89dba98c577727bf4f79ff7e0ca849 \ No newline at end of file diff --git a/test/func.test b/test/func.test index fa7be84242..a3ecd4e30b 100644 --- a/test/func.test +++ b/test/func.test @@ -1567,19 +1567,19 @@ do_execsql_test func-38.100 { # do_execsql_test func-39.101 { WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<1) - SELECT quote(sum(1.7976931348623157e308)), - quote(avg(1.7976931348623157e308)), - quote(total(1.7976931348623157e308)) + SELECT sum(1.7976931348623157e308), + avg(1.7976931348623157e308), + total(1.7976931348623157e308) FROM c; -} {1.797693134862315708e+308 1.797693134862315708e+308 1.797693134862315708e+308} +} {1.79769313486232e+308 1.79769313486232e+308 1.79769313486232e+308} for {set i 2} {$i<10} {incr i} { do_execsql_test func-39.[expr {10*$i+100}] { WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<$i) - SELECT quote(sum(1.7976931348623157e308)), - quote(avg(1.7976931348623157e308)), - quote(total(1.7976931348623157e308)) + SELECT sum(1.7976931348623157e308), + avg(1.7976931348623157e308), + total(1.7976931348623157e308) FROM c; - } {9.0e+999 9.0e+999 9.0e+999} + } {Inf Inf Inf} } finish_test From 4b42b5259f151aad0ece49b7132a6bc2e40b262f Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 13:31:54 +0000 Subject: [PATCH 0254/1030] When compiled with SQLITE_ALLOW_ROWID_IN_VIEW, rowid-in-view is on by default but can now be turned off using SQLITE_TESTCTRL_ROWID_IN_VIEW. Without the compile-time option, rowid-in-view is always off. FossilOrigin-Name: 8a6196ab29052071be753c5c77ac945c2d62ecc8019c6160f954eafe34ab05a8 --- manifest | 27 ++++++++++++--------------- manifest.uuid | 2 +- src/build.c | 9 ++++++--- src/global.c | 3 +++ src/main.c | 33 +++++++++++++++++++++++++++++++++ src/select.c | 22 ++++++++++------------ src/shell.c.in | 15 +++++++++++++++ src/sqlite.h.in | 1 + src/sqliteInt.h | 14 ++++++++++++++ 9 files changed, 95 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index a8b9d2e2ff..051742cb39 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C First\ssteps\stoward\sgetting\s-DSQLITE_ALLOW_ROWID_IN_VIEW\sto\swork\sagain.\s\sThat\ncompile-time\soption\sis\suntested,\sundocumented,\sand\sunsupported.\s\sBut\sit\swas\nmentioned\sin\sthe\srelease\snotes\sfor\sversion\s3.36.0,\sso\sI\sthink\sthat\smeans\swe\nneed\sto\ssupport\sit\sforever. -D 2024-03-19T02:30:24.246 +C When\scompiled\swith\sSQLITE_ALLOW_ROWID_IN_VIEW,\srowid-in-view\sis\son\sby\sdefault\nbut\scan\snow\sbe\sturned\soff\susing\sSQLITE_TESTCTRL_ROWID_IN_VIEW.\s\sWithout\sthe\ncompile-time\soption,\srowid-in-view\sis\salways\soff. +D 2024-03-19T13:31:54.376 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -692,7 +692,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 285b493d843e7ba8ef78b6ae7d31238e904901dbc0c484f7904de4cf18fd8802 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f +F src/build.c 18b4caf7f4eabf4c46727f476b669505aa67cfd3c3587b0fb82f5b8b69acc0e0 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b @@ -704,7 +704,7 @@ F src/expr.c d7cfe9b9fe7ab47b254706589467d2e65fec3536b936d6f4eb28b84da6726ecc F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 4204c56196847faefef57fa14e43b8e4d65eb8d7e65318abe463472e3fd148cb -F src/global.c 765a0656d6cbf043cb272ff0ae38f39cc46713539ffe6793258ed3eb4b188b52 +F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 @@ -713,7 +713,7 @@ F src/insert.c 06ce505713e86172612f9e01febefd2d3331d1f70461b4ada0eae5a76bb6349f F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b +F src/main.c e7e6e9356ba86713051199968e22ac2c64b1078f266518ca5791dab5fc1af237 F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -750,12 +750,12 @@ F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 934eb6e543133cb373ab76f791ded2b2b5c13ac50684453494c4b6c4ea4fba24 -F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8a -F src/sqlite.h.in 19a2db3995a699bd7f6dfb423856242bfceb7ec849a93c91d241d19fc28d9f0f +F src/select.c 6d6301429c1de03d14ccdad371c36464747e4b0245e4a3a48c8e264ccc5f69df +F src/shell.c.in 21d998d82e169acd7905263674afdf4eff690125fcc8bf7766bcc9f463cd1b13 +F src/sqlite.h.in 09d55c3707ee5e3e041301fc558de6fc124bd4af6135ea1288d9c30dc43a7fd9 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h a58b4a33a9807667503a053721a4cd736cda8b60daae896a1b04f120a64c9fd2 +F src/sqliteInt.h b97455359ea9410d2568d54d752e8e67d1d47fc8968b3d0c8c34ef7cc70d88b7 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2180,11 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ad2ae7717e7a10cf42aeabd3c544e7884fa082295c2babf0fdb19a684d2aba1e -R cc156187f695f7801f18b2af21acf477 -T *branch * rowid-in-view -T *sym-rowid-in-view * -T -sym-trunk * +P 7c46ff640247584f1ea260c062de29a0e49f649d1894a526574c1a479006a1fc +R e5e0882c9142c10ac12b6ecaf695934e U drh -Z d1168aa5ebee2530ad432f8f9a6ecbd1 +Z 8e31fdf538ff0513b533fb4971fc8443 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3c83ab3dfc..24809892dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c46ff640247584f1ea260c062de29a0e49f649d1894a526574c1a479006a1fc \ No newline at end of file +8a6196ab29052071be753c5c77ac945c2d62ecc8019c6160f954eafe34ab05a8 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 15f8fe1d24..1bc6008ecd 100644 --- a/src/build.c +++ b/src/build.c @@ -3006,9 +3006,12 @@ void sqlite3CreateView( ** on a view, even though views do not have rowids. The following flag ** setting fixes this problem. But the fix can be disabled by compiling ** with -DSQLITE_ALLOW_ROWID_IN_VIEW in case there are legacy apps that - ** depend upon the old buggy behavior. */ -#ifndef SQLITE_ALLOW_ROWID_IN_VIEW - p->tabFlags |= TF_NoVisibleRowid; + ** depend upon the old buggy behavior. The ability can also be toggled + ** using SQLITE_TESTCTRL_ROWID_IN_VIEW */ +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + p->tabFlags |= sqlite3Config.mNoVisibleRowid; /* Optional. Allow by default */ +#else + p->tabFlags |= TF_NoVisibleRowid; /* Never allow rowid in view */ #endif sqlite3TwoPartName(pParse, pName1, pName2, &pName); diff --git a/src/global.c b/src/global.c index 7f27d91d15..121b3f6d6b 100644 --- a/src/global.c +++ b/src/global.c @@ -288,6 +288,9 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = { #endif #ifndef SQLITE_UNTESTABLE 0, /* xTestCallback */ +#endif +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + 0, /* mNoVisibleRowid. 0 == allow rowid-in-view */ #endif 0, /* bLocaltimeFault */ 0, /* xAltLocaltime */ diff --git a/src/main.c b/src/main.c index 03429983d6..67191fb0fe 100644 --- a/src/main.c +++ b/src/main.c @@ -4405,6 +4405,39 @@ int sqlite3_test_control(int op, ...){ break; } + /* sqlite3_test_control(SQLITE_TESTCTRL_ROWID_IN_VIEW, int *pVal); + ** + ** Query or set the sqlite3Config.mNoVisibleRowid flag. Cases: + ** + ** *pVal==1 Allow ROWID in VIEWs + ** *pVal==0 Disallow ROWID in VIEWs + ** *pVal<0 No change + ** + ** In every case *pVal is written with 1 if ROWID is allowd in VIEWs and + ** 0 if not. Changes to the setting only occur if SQLite is compiled + ** with -DSQLITE_ALLOW_ROWID_IN_VIEW (hereafter: "SARIV"). With the + ** "SARIV" compile-time option the default value for this setting is 1. + ** Otherwise this setting defaults to 0. This setting may only be changed + ** if SQLite is compiled with "SARIV". Hence, in the normal case when + ** SQLite is compiled without "SARIV", this test-control is a no-op + ** that always leaves *pVal set to 0. + ** + ** IMPORTANT: If you change this setting while a database connection + ** is option, it is very important to run "PRAGMA writable_schema=RESET" + ** afterwards in order to reparse all VIEW definitions in the schema. + */ + case SQLITE_TESTCTRL_ROWID_IN_VIEW: { + int *pVal = va_arg(ap, int*); +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + if( *pVal==0 ) sqlite3Config.mNoVisibleRowid = TF_NoVisibleRowid; + if( *pVal==1 ) sqlite3Config.mNoVisibleRowid = 0; + *pVal = (sqlite3Config.mNoVisibleRowid==0); +#else + *pVal = 0; +#endif + break; + } + /* sqlite3_test_control(SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, sqlite3*); ** ** Toggle the ability to use internal functions on or off for diff --git a/src/select.c b/src/select.c index 5dfabb140d..7f8a0f892e 100644 --- a/src/select.c +++ b/src/select.c @@ -1953,11 +1953,7 @@ static const char *columnTypeImpl( ** data for the result-set column of the sub-select. */ if( iColpEList->nExpr -#ifdef SQLITE_ALLOW_ROWID_IN_VIEW - && iCol>=0 -#else - && ALWAYS(iCol>=0) -#endif + && (!ViewCanHaveRowid || iCol>=0) ){ /* If iCol is less than zero, then the expression requests the ** rowid of the sub-select or view. This expression is legal (see @@ -5874,7 +5870,8 @@ int sqlite3ExpandSubquery(Parse *pParse, SrcItem *pFrom){ /* The usual case - do not allow ROWID on a subquery */ pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; #else - pTab->tabFlags |= TF_Ephemeral; /* Legacy compatibility mode */ + /* Legacy compatibility mode */ + pTab->tabFlags |= TF_Ephemeral | sqlite3Config.mNoVisibleRowid; #endif return pParse->nErr ? SQLITE_ERROR : SQLITE_OK; } @@ -6142,9 +6139,7 @@ static int selectExpander(Walker *pWalker, Select *p){ pNestedFrom = pFrom->pSelect->pEList; assert( pNestedFrom!=0 ); assert( pNestedFrom->nExpr==pTab->nCol ); -#ifndef SQLITE_ALLOW_ROWID_IN_VIEW - assert( VisibleRowid(pTab)==0 ); -#endif + assert( VisibleRowid(pTab)==0 || ViewCanHaveRowid ); }else{ if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ continue; @@ -6177,9 +6172,12 @@ static int selectExpander(Walker *pWalker, Select *p){ } nAdd = pTab->nCol; -#ifndef SQLITE_ALLOW_ROWID_IN_VIEW - if( VisibleRowid(pTab) && (selFlags & SF_NestedFrom)!=0 ) nAdd++; -#endif + if( VisibleRowid(pTab) + && !ViewCanHaveRowid + && (selFlags & SF_NestedFrom)!=0 + ){ + nAdd++; + } for(j=0; j=3 ){ + if( !ShellHasFlag(p,SHFLG_TestingMode) ){ + eputz("The --unsafe-testing option is required to change " + "this setting\n"); + }else{ + rc2 = booleanValue(azArg[2]); + } + } + sqlite3_test_control(testctrl, &rc2); + isOk = 1; + break; + } #ifdef SQLITE_DEBUG case SQLITE_TESTCTRL_TUNE: { if( nArg==4 ){ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e05d7b231a..17a231860a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -8307,6 +8307,7 @@ int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_JSON_SELFCHECK 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ +#define SQLITE_TESTCTRL_ROWID_IN_VIEW 16 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ #define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8d18bfdfbb..9fdc721e40 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2535,6 +2535,15 @@ struct Table { #define HasRowid(X) (((X)->tabFlags & TF_WithoutRowid)==0) #define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0) +/* Macro is true if the SQLITE_ALLOW_ROWID_IN_VIEW (mis-)feature is +** available. By default, this macro is false +*/ +#ifndef SQLITE_ALLOW_ROWID_IN_VIEW +# define ViewCanHaveRowid 0 +#else +# define ViewCanHaveRowid (sqlite3Config.mNoVisibleRowid==0) +#endif + /* ** Each foreign key constraint is an instance of the following structure. ** @@ -4253,6 +4262,11 @@ struct Sqlite3Config { #endif #ifndef SQLITE_UNTESTABLE int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */ +#endif +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + u32 mNoVisibleRowid; /* TF_NoVisibleRowid if the ROWID_IN_VIEW + ** feature is disabled. 0 if rowids can + ** occur in views. */ #endif int bLocaltimeFault; /* True to fail localtime() calls */ int (*xAltLocaltime)(const void*,void*); /* Alternative localtime() routine */ From 261c6dfe7b32b8a66b91026ac134afb91aada452 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 13:55:10 +0000 Subject: [PATCH 0255/1030] On second thought, change SQLITE_TESTCTRL_ROWID_IN_VIEW into a start-time option SQLITE_CONFIG_NO_ROWID_IN_VIEW. FossilOrigin-Name: b8e045c9e1d098d116f8745704b10ed76569d4b063c0b81cce16bc136930755d --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/build.c | 2 +- src/main.c | 40 +++++++--------------------------------- src/shell.c.in | 19 ++++--------------- src/sqlite.h.in | 12 +++++++++++- 6 files changed, 33 insertions(+), 60 deletions(-) diff --git a/manifest b/manifest index 051742cb39..eec7c4d0c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scompiled\swith\sSQLITE_ALLOW_ROWID_IN_VIEW,\srowid-in-view\sis\son\sby\sdefault\nbut\scan\snow\sbe\sturned\soff\susing\sSQLITE_TESTCTRL_ROWID_IN_VIEW.\s\sWithout\sthe\ncompile-time\soption,\srowid-in-view\sis\salways\soff. -D 2024-03-19T13:31:54.376 +C On\ssecond\sthought,\schange\sSQLITE_TESTCTRL_ROWID_IN_VIEW\sinto\sa\sstart-time\noption\sSQLITE_CONFIG_NO_ROWID_IN_VIEW. +D 2024-03-19T13:55:10.156 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -692,7 +692,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 285b493d843e7ba8ef78b6ae7d31238e904901dbc0c484f7904de4cf18fd8802 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 18b4caf7f4eabf4c46727f476b669505aa67cfd3c3587b0fb82f5b8b69acc0e0 +F src/build.c 71445e2d1e2c78b120a20a46d80a29a9ea42370df430efda5bb6ef377e8016c8 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b @@ -713,7 +713,7 @@ F src/insert.c 06ce505713e86172612f9e01febefd2d3331d1f70461b4ada0eae5a76bb6349f F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c e7e6e9356ba86713051199968e22ac2c64b1078f266518ca5791dab5fc1af237 +F src/main.c 3db8bc4c8e0515b9e23bed3167de8b626a55e9eb1f65fe42b878d820cfa90628 F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -751,8 +751,8 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6d6301429c1de03d14ccdad371c36464747e4b0245e4a3a48c8e264ccc5f69df -F src/shell.c.in 21d998d82e169acd7905263674afdf4eff690125fcc8bf7766bcc9f463cd1b13 -F src/sqlite.h.in 09d55c3707ee5e3e041301fc558de6fc124bd4af6135ea1288d9c30dc43a7fd9 +F src/shell.c.in a2ccceb9a250613f8156b098736bd94424c422972a1c1ddda35604531ae1762e +F src/sqlite.h.in e9d785f9d17f2caa366641d6616748310c8092cc0746f064c8cf5bcc767bcab0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h b97455359ea9410d2568d54d752e8e67d1d47fc8968b3d0c8c34ef7cc70d88b7 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7c46ff640247584f1ea260c062de29a0e49f649d1894a526574c1a479006a1fc -R e5e0882c9142c10ac12b6ecaf695934e +P 8a6196ab29052071be753c5c77ac945c2d62ecc8019c6160f954eafe34ab05a8 +R d89345c69403f3ed5d805ef59957407f U drh -Z 8e31fdf538ff0513b533fb4971fc8443 +Z a176e962a21e6476d0fc3787bbf8685d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 24809892dc..578f79ca78 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8a6196ab29052071be753c5c77ac945c2d62ecc8019c6160f954eafe34ab05a8 \ No newline at end of file +b8e045c9e1d098d116f8745704b10ed76569d4b063c0b81cce16bc136930755d \ No newline at end of file diff --git a/src/build.c b/src/build.c index 1bc6008ecd..e7c23c173a 100644 --- a/src/build.c +++ b/src/build.c @@ -3007,7 +3007,7 @@ void sqlite3CreateView( ** setting fixes this problem. But the fix can be disabled by compiling ** with -DSQLITE_ALLOW_ROWID_IN_VIEW in case there are legacy apps that ** depend upon the old buggy behavior. The ability can also be toggled - ** using SQLITE_TESTCTRL_ROWID_IN_VIEW */ + ** using SQLITE_CONFIG_NO_ROWID_IN_VIEW */ #ifdef SQLITE_ALLOW_ROWID_IN_VIEW p->tabFlags |= sqlite3Config.mNoVisibleRowid; /* Optional. Allow by default */ #else diff --git a/src/main.c b/src/main.c index 67191fb0fe..6c8ae5b281 100644 --- a/src/main.c +++ b/src/main.c @@ -765,6 +765,13 @@ int sqlite3_config(int op, ...){ } #endif /* SQLITE_OMIT_DESERIALIZE */ + case SQLITE_CONFIG_NO_ROWID_IN_VIEW: { +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + sqlite3GlobalConfig.mNoVisibleRowid = TF_NoVisibleRowid; +#endif + break; + } + default: { rc = SQLITE_ERROR; break; @@ -4405,39 +4412,6 @@ int sqlite3_test_control(int op, ...){ break; } - /* sqlite3_test_control(SQLITE_TESTCTRL_ROWID_IN_VIEW, int *pVal); - ** - ** Query or set the sqlite3Config.mNoVisibleRowid flag. Cases: - ** - ** *pVal==1 Allow ROWID in VIEWs - ** *pVal==0 Disallow ROWID in VIEWs - ** *pVal<0 No change - ** - ** In every case *pVal is written with 1 if ROWID is allowd in VIEWs and - ** 0 if not. Changes to the setting only occur if SQLite is compiled - ** with -DSQLITE_ALLOW_ROWID_IN_VIEW (hereafter: "SARIV"). With the - ** "SARIV" compile-time option the default value for this setting is 1. - ** Otherwise this setting defaults to 0. This setting may only be changed - ** if SQLite is compiled with "SARIV". Hence, in the normal case when - ** SQLite is compiled without "SARIV", this test-control is a no-op - ** that always leaves *pVal set to 0. - ** - ** IMPORTANT: If you change this setting while a database connection - ** is option, it is very important to run "PRAGMA writable_schema=RESET" - ** afterwards in order to reparse all VIEW definitions in the schema. - */ - case SQLITE_TESTCTRL_ROWID_IN_VIEW: { - int *pVal = va_arg(ap, int*); -#ifdef SQLITE_ALLOW_ROWID_IN_VIEW - if( *pVal==0 ) sqlite3Config.mNoVisibleRowid = TF_NoVisibleRowid; - if( *pVal==1 ) sqlite3Config.mNoVisibleRowid = 0; - *pVal = (sqlite3Config.mNoVisibleRowid==0); -#else - *pVal = 0; -#endif - break; - } - /* sqlite3_test_control(SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, sqlite3*); ** ** Toggle the ability to use internal functions on or off for diff --git a/src/shell.c.in b/src/shell.c.in index fbec5a8c9a..51769a67d7 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -10893,7 +10893,6 @@ static int do_meta_command(char *zLine, ShellState *p){ {"prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE,0, "" }, {"prng_save", SQLITE_TESTCTRL_PRNG_SAVE, 0, "" }, {"prng_seed", SQLITE_TESTCTRL_PRNG_SEED, 0, "SEED ?db?" }, - {"rowid_in_view", SQLITE_TESTCTRL_ROWID_IN_VIEW,0,"?BOOLEAN?" }, {"seek_count", SQLITE_TESTCTRL_SEEK_COUNT, 0, "" }, {"sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP, 0, "NMAX" }, {"tune", SQLITE_TESTCTRL_TUNE, 1, "ID VALUE" }, @@ -11068,20 +11067,6 @@ static int do_meta_command(char *zLine, ShellState *p){ break; } #endif - case SQLITE_TESTCTRL_ROWID_IN_VIEW: { - rc2 = -1; - if( nArg>=3 ){ - if( !ShellHasFlag(p,SHFLG_TestingMode) ){ - eputz("The --unsafe-testing option is required to change " - "this setting\n"); - }else{ - rc2 = booleanValue(azArg[2]); - } - } - sqlite3_test_control(testctrl, &rc2); - isOk = 1; - break; - } #ifdef SQLITE_DEBUG case SQLITE_TESTCTRL_TUNE: { if( nArg==4 ){ @@ -12363,6 +12348,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ stdin_is_interactive = 0; }else if( cli_strcmp(z,"-utf8")==0 ){ }else if( cli_strcmp(z,"-no-utf8")==0 ){ + }else if( cli_strcmp(z,"-no-rowid-in-view")==0 ){ + sqlite3_config(SQLITE_CONFIG_NO_ROWID_IN_VIEW); }else if( cli_strcmp(z,"-heap")==0 ){ #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) const char *zSize; @@ -12638,6 +12625,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ /* already handled */ }else if( cli_strcmp(z,"-no-utf8")==0 ){ /* already handled */ + }else if( cli_strcmp(z,"-no-rowid-in-view")==0 ){ + /* already handled */ }else if( cli_strcmp(z,"-heap")==0 ){ i++; }else if( cli_strcmp(z,"-pagecache")==0 ){ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 17a231860a..9c9a78c453 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2143,6 +2143,16 @@ struct sqlite3_mem_methods { ** configuration setting is never used, then the default maximum is determined ** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that ** compile-time option is not set, then the default maximum is 1073741824. +** +** [[SQLITE_CONFIG_NO_ROWID_IN_VIEW]] +**
    SQLITE_CONFIG_NO_ROWID_IN_VIEW +**
    The SQLITE_CONFIG_NO_ROWID_IN_VIEW option prohibits VIEWs from having +** a ROWID. This is the default behavior and so test sqlite_config() option +** is normally a no-op. However, if SQLite is compiled with the +** -DSQLITE_ALLOW_ROWID_IN_VIEW option (not recommended!) then this configuration +** option will disable that capability and make SQLite operate as it normally +** would given default the default compile-time options. Once ROWIDs in VIEWs +** have been disabled using this option, they cannot be reenabled. ** */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ @@ -2174,6 +2184,7 @@ struct sqlite3_mem_methods { #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ #define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */ +#define SQLITE_CONFIG_NO_ROWID_IN_VIEW 30 /* nil */ /* ** CAPI3REF: Database Connection Configuration Options @@ -8307,7 +8318,6 @@ int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_JSON_SELFCHECK 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ -#define SQLITE_TESTCTRL_ROWID_IN_VIEW 16 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ #define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 From d75bdf51c7623d70bba6e3e330e59d59a4f7b6dd Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 14:21:26 +0000 Subject: [PATCH 0256/1030] Improvements to the first check-in on this branch, causing less collateral damage. FossilOrigin-Name: 7bc882897b6910f93695ad372445df7791b096412089ccbcd4fde365c62fa074 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 9 ++------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index eec7c4d0c1..e338d56c6e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\ssecond\sthought,\schange\sSQLITE_TESTCTRL_ROWID_IN_VIEW\sinto\sa\sstart-time\noption\sSQLITE_CONFIG_NO_ROWID_IN_VIEW. -D 2024-03-19T13:55:10.156 +C Improvements\sto\sthe\sfirst\scheck-in\son\sthis\sbranch,\scausing\sless\scollateral\ndamage. +D 2024-03-19T14:21:26.201 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -750,7 +750,7 @@ F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 6d6301429c1de03d14ccdad371c36464747e4b0245e4a3a48c8e264ccc5f69df +F src/select.c ac3689a3f54f81e8b710ce772c5c49c13a152e4ac484c2429ad5264243e7de66 F src/shell.c.in a2ccceb9a250613f8156b098736bd94424c422972a1c1ddda35604531ae1762e F src/sqlite.h.in e9d785f9d17f2caa366641d6616748310c8092cc0746f064c8cf5bcc767bcab0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8a6196ab29052071be753c5c77ac945c2d62ecc8019c6160f954eafe34ab05a8 -R d89345c69403f3ed5d805ef59957407f +P b8e045c9e1d098d116f8745704b10ed76569d4b063c0b81cce16bc136930755d +R 9d63476358fa70a434b2b00bc72db1e7 U drh -Z a176e962a21e6476d0fc3787bbf8685d +Z f699d32733c11fd3a8c679549f29c036 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 578f79ca78..add372b711 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8e045c9e1d098d116f8745704b10ed76569d4b063c0b81cce16bc136930755d \ No newline at end of file +7bc882897b6910f93695ad372445df7791b096412089ccbcd4fde365c62fa074 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 7f8a0f892e..f71b715517 100644 --- a/src/select.c +++ b/src/select.c @@ -6172,12 +6172,7 @@ static int selectExpander(Walker *pWalker, Select *p){ } nAdd = pTab->nCol; - if( VisibleRowid(pTab) - && !ViewCanHaveRowid - && (selFlags & SF_NestedFrom)!=0 - ){ - nAdd++; - } + if( VisibleRowid(pTab) && (selFlags & SF_NestedFrom)!=0 ) nAdd++; for(j=0; ja[pNew->nExpr-1]; assert( pX->zEName==0 ); if( (selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){ - if( pNestedFrom ){ + if( pNestedFrom && jnExpr ){ pX->zEName = sqlite3DbStrDup(db, pNestedFrom->a[j].zEName); testcase( pX->zEName==0 ); }else{ From 967c3032124b1365c65946371809660404376169 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 14:38:39 +0000 Subject: [PATCH 0257/1030] Fix the fuzzinvariants.c test module so that it does not generate invariants that depend on rowid when SQLITE_ALLOW_ROWID_IN_VIEW is used, since rowid values can be unreliable in that context. FossilOrigin-Name: 0d711aaaa14472a82f8893e1b07d845073f3d018bd5b8093ec0b00ffbbc8cd5a --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/fuzzinvariants.c | 8 ++++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index e338d56c6e..1bd5d0bc66 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sfirst\scheck-in\son\sthis\sbranch,\scausing\sless\scollateral\ndamage. -D 2024-03-19T14:21:26.201 +C Fix\sthe\sfuzzinvariants.c\stest\smodule\sso\sthat\sit\sdoes\snot\sgenerate\ninvariants\sthat\sdepend\son\srowid\swhen\sSQLITE_ALLOW_ROWID_IN_VIEW\sis\sused,\nsince\srowid\svalues\scan\sbe\sunreliable\sin\sthat\scontext. +D 2024-03-19T14:38:39.687 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1257,7 +1257,7 @@ F test/fuzzdata8.db 4a53b6d077c6a5c23b609d8d3ac66996fa55ba3f8d02f9b6efdd0214a767 F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc -F test/fuzzinvariants.c b34530e8431f2cf3591eff588fc7684d6fdef466916fb46141c8c5374a3d8099 +F test/fuzzinvariants.c 4355043e98cd8555c62462fcbba91c17c6492b0b017bbbe68656d5f2208f6444 F test/gcfault.test 4ea410ac161e685f17b19e1f606f58514a2850e806c65b846d05f60d436c5b0d F test/gencol1.test e169bdfa11c7ed5e9f322a98a7db3afe9e66235750b68c923efee8e1876b46ec F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b8e045c9e1d098d116f8745704b10ed76569d4b063c0b81cce16bc136930755d -R 9d63476358fa70a434b2b00bc72db1e7 +P 7bc882897b6910f93695ad372445df7791b096412089ccbcd4fde365c62fa074 +R 1d0ab0a71fdecadee0025e4c9e79a52a U drh -Z f699d32733c11fd3a8c679549f29c036 +Z ef38e4f5190d6a950df6cf2eac0e14a7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index add372b711..6d341e4ed1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7bc882897b6910f93695ad372445df7791b096412089ccbcd4fde365c62fa074 \ No newline at end of file +0d711aaaa14472a82f8893e1b07d845073f3d018bd5b8093ec0b00ffbbc8cd5a \ No newline at end of file diff --git a/test/fuzzinvariants.c b/test/fuzzinvariants.c index 5d473f19f3..00b2c11742 100644 --- a/test/fuzzinvariants.c +++ b/test/fuzzinvariants.c @@ -296,6 +296,14 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ ** WHERE clause. */ continue; } +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + if( sqlite3_strlike("%rowid%",zColName,0)==0 + || sqlite3_strlike("%oid%",zColName,0)==0 + ){ + /* ROWID values are unreliable if SQLITE_ALLOW_ROWID_IN_VIEW is used */ + continue; + } +#endif for(j=0; j Date: Tue, 19 Mar 2024 14:55:49 +0000 Subject: [PATCH 0258/1030] Return the error "ambiguous column name: rowid", instead of "no such column: rowid", when a "rowid" reference is ambiguous. FossilOrigin-Name: 021f34fcfed41b607be8169bbda59aef93f130108d944f4741b46e8e345b2bbb --- manifest | 23 +++++++++++++---------- manifest.uuid | 2 +- src/resolve.c | 4 ++-- test/joinH.test | 6 +++--- test/rowid.test | 5 +++-- test/unionall.test | 2 +- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 26d692be1b..bf79ca82f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjustments\sto\sthe\stest\scases\sfor\sthe\sprevious\scheck-in\sto\smake\sthem\ncross-platform\sLinux/Mac/Windows.\s\sTest\schance\sonly.\s\sNo\schange\sto\score\scode. -D 2024-03-19T10:41:18.138 +C Return\sthe\serror\s"ambiguous\scolumn\sname:\srowid",\sinstead\sof\s"no\ssuch\scolumn:\srowid",\swhen\sa\s"rowid"\sreference\sis\sambiguous. +D 2024-03-19T14:55:49.846 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -748,7 +748,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 +F src/resolve.c c3d6f422645c1fab9b6c493a39624d0b20af5b62f085484293c47d38114edd4f F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c df2bf515fc36e02e97959a70e82da8a4967d6c85590646a7fda2926a734c81ce F src/shell.c.in cf80c636bccb0ff9db46995e39d69ca21fde2a8a331d1691e4d62a69d7841c8a @@ -1337,7 +1337,7 @@ F test/joinC.test 1f1a602c2127f55f136e2cbd3bf2d26546614bf8cffe5902ec1ac9c07f87f2 F test/joinD.test 2ce62e7353a0702ca5e70008faf319c1d4686aa19fba34275c6d1da0e960be28 F test/joinE.test d5d182f3812771e2c0d97c9dcf5dbe4c41c8e21c82560e59358731c4a3981d6b F test/joinF.test 53dd66158806823ea680dd7543b5406af151b5aafa5cd06a7f3231cd94938127 -F test/joinH.test f69e5b53b7d887914e854b6a131efbed4ea9f5ca52bdab81788bfc3e79299f43 +F test/joinH.test d5054173442fdf98260eeb6bb9751daa733b0ae6842fe50dcbd5469945b86985 F test/journal1.test c7b768041b7f494471531e17abc2f4f5ebf9e5096984f43ed17c4eb80ba34497 F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4 F test/journal3.test 7c3cf23ffc77db06601c1fcfc9743de8441cb77db9d1aa931863d94f5ffa140e @@ -1535,7 +1535,7 @@ F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/round1.test 29c3c9039936ed024d672f003c4d35ee11c14c0acb75c5f7d6188ff16190cfd4 F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 -F test/rowid.test e29025be95baf6b32f0d5edef59a7633028325896a98f1caa8019559ca910350 +F test/rowid.test 9910c999e58d211d182599bc0023bdfa849d02c712163476afd384780936b404 F test/rowvalue.test baf4fa3ec1a8c1c920c3faa5fd25959cb454bbd99ac8960397c34549d9fc4abe F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b F test/rowvalue3.test 1347e25ca11c547c5a6ff0cc5626f95aa9740e9275bfaec096029f57cb2130ce @@ -1887,7 +1887,7 @@ F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff F test/types2.test 1aeb81976841a91eef292723649b5c4fe3bc3cac F test/types3.test c9db8f9e80309edfa4252585cf16bcab7ed31f39eeb904d21e831199a3613fb0 F test/unhex.test b7f1b806207cb77fa31c3e434fe92fba524464e3e9356809bfcc28f15af1a8b7 -F test/unionall.test 5b1c4186a661e4bf762875caf4c61d8fda3dd04a6fa9005187f6ba8900c2913f +F test/unionall.test 04d30726c5056f84f92b3a12bf8d8a1dbbe807d1ddc8af95def09e6ef2dd91e3 F test/unionall2.test 71e8fa08d5699d50dc9f9dc0c9799c2e7a6bb7931a330d369307a4df7f157fa1 F test/unionallfault.test 652bfbb630e6c43135965dc1e8f0a9a791da83aec885d626a632fe1909c56f73 F test/unionvtab.test e1704ab1b4c1bb3ffc9da4681f8e85a0b909fd80b937984fc94b27415ac8e5a4 @@ -2180,8 +2180,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 45d272ef38d5ee6189f81369aefb8e3ac35868a67687012d93c84f2bbc42520a -R 06f52063180a10fd2f7e8878024a8e93 -U drh -Z be89e098a4549a3844da98de72222ae6 +P 0dddadbd5b217a48bb5c1b0568a03fbafb89dba98c577727bf4f79ff7e0ca849 +R 9d3e521ec7779aa5763735bc3fc68d12 +T *branch * ambiguous-rowid-error +T *sym-ambiguous-rowid-error * +T -sym-trunk * +U dan +Z 8273ce08b357f09baf92785ce3364245 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 46aef1d450..5279cb0694 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0dddadbd5b217a48bb5c1b0568a03fbafb89dba98c577727bf4f79ff7e0ca849 \ No newline at end of file +021f34fcfed41b607be8169bbda59aef93f130108d944f4741b46e8e345b2bbb \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index c2957a870a..2a128199db 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -596,13 +596,13 @@ static int lookupName( ** Perhaps the name is a reference to the ROWID */ if( cnt==0 - && cntTab==1 + && cntTab>=1 && pMatch && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 && sqlite3IsRowid(zCol) && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom) ){ - cnt = 1; + cnt = cntTab; if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1; pExpr->affExpr = SQLITE_AFF_INTEGER; } diff --git a/test/joinH.test b/test/joinH.test index 3702266804..e3f979409a 100644 --- a/test/joinH.test +++ b/test/joinH.test @@ -201,13 +201,13 @@ do_execsql_test 9.0 { do_catchsql_test 9.1 { SELECT rowid FROM wo1, x1, x2; -} {1 {no such column: rowid}} +} {1 {ambiguous column name: rowid}} do_catchsql_test 9.2 { SELECT rowid FROM wo1, (x1, x2); -} {1 {no such column: rowid}} +} {1 {ambiguous column name: rowid}} do_catchsql_test 9.3 { SELECT rowid FROM wo1 JOIN (x1 JOIN x2); -} {1 {no such column: rowid}} +} {1 {ambiguous column name: rowid}} do_catchsql_test 9.4 { SELECT a FROM wo1, x1, x2; } {1 {ambiguous column name: a}} diff --git a/test/rowid.test b/test/rowid.test index 4327004d31..8b76762b7b 100644 --- a/test/rowid.test +++ b/test/rowid.test @@ -813,8 +813,9 @@ do_execsql_test 16.6 { SELECT rowid FROM v1, t1; } {1} do_execsql_test 16.7 { SELECT rowid FROM v1, t3; } {3} do_execsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } {3} -do_catchsql_test 16.5 { SELECT rowid FROM t1, t3; } {1 {no such column: rowid}} - +do_catchsql_test 16.9 { + SELECT rowid FROM t1, t3; +} {1 {ambiguous column name: rowid}} finish_test diff --git a/test/unionall.test b/test/unionall.test index 99cb48a259..9057199070 100644 --- a/test/unionall.test +++ b/test/unionall.test @@ -351,7 +351,7 @@ do_catchsql_test 5.30 { SELECT * FROM (t1 NATURAL JOIN pragma_table_xinfo('t1_a') NATURAL JOIN t3) t1 NATURAL JOIN t2 NATURAL JOIN t3 WHERE rowid ISNULL>0 AND 0%y; -} {1 {no such column: rowid}} +} {1 {ambiguous column name: rowid}} } reset_db From f891ef8d6111c8c8aa7de74bcd36aaf2f4569c47 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 19 Mar 2024 15:27:15 +0000 Subject: [PATCH 0259/1030] Update tests to work with SQLITE_ALLOW_ROWID_IN_VIEW. FossilOrigin-Name: 495b8c7b08b998ddfe2ad055703f058c768e7e94014952e5cd8a81c7c1515cb1 --- manifest | 28 ++++++++++++++-------------- manifest.uuid | 2 +- src/ctime.c | 3 +++ src/test_config.c | 8 ++++++++ test/join5.test | 13 +++++++++++-- test/join8.test | 7 ++++++- test/misc2.test | 29 ++++++++++++++++++++++------- test/returning1.test | 43 ++++++++++++++++++++++++++++++++----------- test/rowid.test | 33 +++++++++++++++++++++++---------- test/trigger9.test | 27 +++++++++++++++++++++------ 10 files changed, 141 insertions(+), 52 deletions(-) diff --git a/manifest b/manifest index 1bd5d0bc66..c5b4e813c0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sfuzzinvariants.c\stest\smodule\sso\sthat\sit\sdoes\snot\sgenerate\ninvariants\sthat\sdepend\son\srowid\swhen\sSQLITE_ALLOW_ROWID_IN_VIEW\sis\sused,\nsince\srowid\svalues\scan\sbe\sunreliable\sin\sthat\scontext. -D 2024-03-19T14:38:39.687 +C Update\stests\sto\swork\swith\sSQLITE_ALLOW_ROWID_IN_VIEW. +D 2024-03-19T15:27:15.880 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -695,7 +695,7 @@ F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b F src/build.c 71445e2d1e2c78b120a20a46d80a29a9ea42370df430efda5bb6ef377e8016c8 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b +F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 @@ -774,7 +774,7 @@ F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 F src/test_bestindex.c f6af1e41cb7901edafb065a8198e4a0192dd42432b642d038965be5e628dec12 F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 -F src/test_config.c f0cc1f517deaa96dd384822ae2bb91534fa56aa458528b439830d709941d3932 +F src/test_config.c 5fa77ee6064ba546e144c4fea870c5ede2c54314616f81485c6a9c4192100c75 F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f F src/test_demovfs.c 38a459d1c78fd9afa770445b224c485e079018d6ac07332ff9bd07b54d2b8ce9 F src/test_devsym.c 649434ed34d0b03fbd5a6b42df80f0f9a7e53f94dd1710aad5dd8831e91c4e86 @@ -1326,10 +1326,10 @@ F test/join.test f7abfef3faeaf2800308872e33a57e5b6e4a2b44fb8c6b90c6068412e71a6cf F test/join2.test 8561fe82ce434ac96de91544072e578dc2cadddf2d9bc9cd802f866a9b92502e F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0 F test/join4.test 1a352e4e267114444c29266ce79e941af5885916 -F test/join5.test 7cc3f3595bb41e60f3f96d5cb6dd8cfcbc31212f0136bba6fc081c082994a94a +F test/join5.test f939b2c7f45a8d36f6b690b797cfa2d7bb828a5ff6e43d9cca88bd91e08fb464 F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c F test/join7.test 2268dcbb54b724391dda3748ea95c60d960607ffeed67885675998e7117697f6 -F test/join8.test d384d63985e3991c404afccadaf3efd1cdf9cd72680167f80e3cb80b95c18c68 +F test/join8.test 02da1534b2b47599a078e513f597c205934d115a5a6bc31af8a5615a7488a81f F test/join9.test 9056ddd3b0c0f4f9d658f4521038d9a37dc23ead8ca9a505d0b0db2b6a471e05 F test/joinA.test 6ac4efdbb1eb9ca398162c5bc5623a757803b04bb4d76453c8563a0bdc2f73bd F test/joinB.test 1b2ba3fc8568b49411787fccbf540570c148e9b6a53a30f80691cb6268098ded @@ -1426,7 +1426,7 @@ F test/minmax2.test cf9311babb6f0518d04e42fd6a42c619531c4309a9dd790a2c4e9b3bc595 F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 272ca395257f05937dc96441c9dde4bc9fbf116a8d4fa02baeb0d13d50e36c87 F test/misc1.test e3e36262aff1bd9b8b9bf1eeb3af04adb3fc1e23f0a92dbff708bba9e939ace1 -F test/misc2.test 71e746af479119386ac2ed7ab7d81d99970e75b49ffd3e8efffee100b4b5f350 +F test/misc2.test a1a3573cc02662becd967766021d6f16c54684d56df5f227481c7ef0d9df0bd0 F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e F test/misc5.test 027cf0ac10314ea534173f335a33bb4059907ddabbac2c16786766d6f26c8923 @@ -1527,7 +1527,7 @@ F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed13 F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d F test/resetdb.test 54c06f18bc832ac6d6319e5ab23d5c8dd49fdbeec7c696d791682a8006bd5fc3 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb -F test/returning1.test db532cde29d6aebbc48c6ddc3149b30476f8e69ca7a2c4b53986c7635e6fd8ec +F test/returning1.test 3ead782eddf51f573cdd43bcbb10d1b485ac095a19a76d16c43fd159ea9b7466 F test/returningfault.test ae4c4b5e8745813287a359d9ccdb9d5c883c2e68afb18fb0767937d5de5692a4 F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa F test/rollback2.test 3f3a4e20401825017df7e7671e9f31b6de5fae5620c2b9b49917f52f8c160a8f @@ -1535,7 +1535,7 @@ F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/round1.test 29c3c9039936ed024d672f003c4d35ee11c14c0acb75c5f7d6188ff16190cfd4 F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 -F test/rowid.test e29025be95baf6b32f0d5edef59a7633028325896a98f1caa8019559ca910350 +F test/rowid.test 17e2a82e0567eec4b265fd063c44b96d5fd7b25ad6bd976d9c5fd892f0c2e258 F test/rowvalue.test baf4fa3ec1a8c1c920c3faa5fd25959cb454bbd99ac8960397c34549d9fc4abe F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b F test/rowvalue3.test 1347e25ca11c547c5a6ff0cc5626f95aa9740e9275bfaec096029f57cb2130ce @@ -1867,7 +1867,7 @@ F test/trigger5.test 619391a3e9fc194081d22cefd830d811e7badf83 F test/trigger6.test 0e411654f122552da6590f0b4e6f781048a4a9b9 F test/trigger7.test e7ce54bfda67a88d778aea42544e151c465547a7e617127b6914c2221a6d53c1 F test/trigger8.test 30cb0530bd7c4728055420e3f739aa00412eafa4 -F test/trigger9.test fd49aff8b724ae1a6238989ecf84320d88c0e8f8d9142a891b93f826dfe37b59 +F test/trigger9.test 1724b595661da3dd3c8d79f0ebae818132a39e65c241bad2049f66952b1dc29d F test/triggerA.test 837be862d8721f903dba3f3ceff05b32e0bee5214cf6ea3da5fadf12d3650e9d F test/triggerB.test 56780c031b454abac2340dbb3b71ac5c56c3d7fe F test/triggerC.test 29f5a28d0fe39e6e2c01f6e1f53f08c0955170ae10a63ad023e33cb0a1682a51 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7bc882897b6910f93695ad372445df7791b096412089ccbcd4fde365c62fa074 -R 1d0ab0a71fdecadee0025e4c9e79a52a -U drh -Z ef38e4f5190d6a950df6cf2eac0e14a7 +P 0d711aaaa14472a82f8893e1b07d845073f3d018bd5b8093ec0b00ffbbc8cd5a +R 9a00ab01baff88b608a562a16a741256 +U dan +Z 3b22054791de9eb30bbf5d96e1597df1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6d341e4ed1..2d1f2cba94 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0d711aaaa14472a82f8893e1b07d845073f3d018bd5b8093ec0b00ffbbc8cd5a \ No newline at end of file +495b8c7b08b998ddfe2ad055703f058c768e7e94014952e5cd8a81c7c1515cb1 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index cf761299fe..0ffe2a5bdf 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -65,6 +65,9 @@ static const char * const sqlite3azCompileOpt[] = { "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN), # endif #endif +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + "ALLOW_ROWID_IN_VIEW", +#endif #ifdef SQLITE_ALLOW_URI_AUTHORITY "ALLOW_URI_AUTHORITY", #endif diff --git a/src/test_config.c b/src/test_config.c index ee766a26d8..76904e5bf2 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -59,6 +59,14 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "rowid32", "0", TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + Tcl_SetVar2( + interp, "sqlite_options", "allow_rowid_in_view", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2( + interp, "sqlite_options", "allow_rowid_in_view", "0", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_CASE_SENSITIVE_LIKE Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","1",TCL_GLOBAL_ONLY); #else diff --git a/test/join5.test b/test/join5.test index 44c8b71a8d..7f8c2f6e65 100644 --- a/test/join5.test +++ b/test/join5.test @@ -370,8 +370,17 @@ do_execsql_test 9.1 { ANALYZE sqlite_schema; INSERT INTO sqlite_stat1 VALUES('t1','t1x1','648 324 81 81 81 81 81 81 81081 81 81 81'); ANALYZE sqlite_schema; - SELECT a FROM (SELECT a FROM t1 NATURAL LEFT JOIN t1) NATURAL LEFT JOIN t1 WHERE (rowid,1)<=(5,0); -} {1} +} +ifcapable allow_rowid_in_view { + set res {1 {no such column: rowid}} +} else { + set res {0 1} +} +do_catchsql_test 9.2 { + SELECT a FROM + (SELECT a FROM t1 NATURAL LEFT JOIN t1) NATURAL LEFT JOIN t1 + WHERE (rowid,1)<=(5,0); +} $res # 2022-03-02 https://sqlite.org/forum/info/50a1bbe08ce4c29c # Bloom-filter pulldown is incompatible with skip-scan. diff --git a/test/join8.test b/test/join8.test index fc50df32ff..269d251fcc 100644 --- a/test/join8.test +++ b/test/join8.test @@ -41,6 +41,11 @@ do_execsql_test join8-1000 { CREATE INDEX t1x2 ON t1(b); INSERT INTO t1 DEFAULT VALUES; } {} +ifcapable allow_rowid_in_view { + set res {1 {no such column: rowid}} +} else { + set res {0 1} +} do_catchsql_test join8-1010 { SELECT a FROM ( @@ -61,7 +66,7 @@ do_catchsql_test join8-1010 { NATURAL LEFT FULL JOIN t1 WHERE ( rowid , 1 )<=(CASE 5 WHEN 619 THEN 841 ELSE 3374391096 END,0) ORDER BY a ASC; -} {0 1} +} $res # Pending issue #2: (now resolved) # Jump to addrHalt inside the RIGHT JOIN body subroutine bypasses the diff --git a/test/misc2.test b/test/misc2.test index 4796d5d374..607799ea21 100644 --- a/test/misc2.test +++ b/test/misc2.test @@ -54,19 +54,34 @@ do_test misc2-2.1 { } } {} ifcapable subquery { - do_catchsql_test misc2-2.2 { - SELECT rowid, * FROM (SELECT * FROM t1, t2); - } {1 {no such column: rowid}} + ifcapable allow_rowid_in_view { + do_catchsql_test misc2-2.2 { + SELECT rowid, * FROM (SELECT * FROM t1, t2); + } {0 {{} 1 2 3 7 8 9}} + } else { + do_catchsql_test misc2-2.2 { + SELECT rowid, * FROM (SELECT * FROM t1, t2); + } {1 {no such column: rowid}} + } do_catchsql_test misc2-2.2b { SELECT 'rowid', * FROM (SELECT * FROM t1, t2); } {0 {rowid 1 2 3 7 8 9}} } ifcapable view { - do_catchsql_test misc2-2.3 { - CREATE VIEW v1 AS SELECT * FROM t1, t2; - SELECT rowid, * FROM v1; - } {1 {no such column: rowid}} + ifcapable allow_rowid_in_view { + do_catchsql_test misc2-2.3 { + CREATE VIEW v1 AS SELECT * FROM t1, t2; + SELECT rowid, * FROM v1; + } {0 {{} 1 2 3 7 8 9}} + } else { + do_catchsql_test misc2-2.3 { + CREATE VIEW v1 AS SELECT * FROM t1, t2; + SELECT rowid, * FROM v1; + } {1 {no such column: rowid}} + } + + do_catchsql_test misc2-2.3b { SELECT 'rowid', * FROM v1; } {0 {rowid 1 2 3 7 8 9}} diff --git a/test/returning1.test b/test/returning1.test index 6c098dc256..24032496ce 100644 --- a/test/returning1.test +++ b/test/returning1.test @@ -212,17 +212,38 @@ do_execsql_test 10.2 { END; } -do_catchsql_test 10.3a { - INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid; -} {1 {no such column: new.rowid}} - -do_catchsql_test 10.3b { - UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid; -} {1 {no such column: new.rowid}} - -do_execsql_test 10.4 { - SELECT * FROM log; -} {} +ifcapable !allow_rowid_in_view { + do_catchsql_test 10.3a { + INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid; + } {1 {no such column: new.rowid}} + + do_catchsql_test 10.3b { + UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid; + } {1 {no such column: new.rowid}} + + do_execsql_test 10.4 { + SELECT * FROM log; + } {} +} else { + # Note: The values returned by the RETURNING clauses of the following + # two statements are the rowid columns of views. These values are not + # well defined, so the INSERT returns -1, and the UPDATE returns 1, 2 + # and 3. These match the values used for new.rowid expressions, but + # not much else. + do_catchsql_test 10.3a { + INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid; + } {0 -1} + + do_catchsql_test 10.3b { + UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid; + } {0 {1 2 3}} + + do_execsql_test 10.4 { + SELECT * FROM log; + } { + insert -1 1234 5678 update 1 z y update 2 z y update 3 z y + } +} # 2021-04-27 dbsqlfuzz 78b9400770ef8cc7d9427dfba26f4fcf46ea7dc2 # Returning clauses on TEMP tables with triggers. diff --git a/test/rowid.test b/test/rowid.test index 4327004d31..450ae35cce 100644 --- a/test/rowid.test +++ b/test/rowid.test @@ -803,17 +803,30 @@ do_execsql_test 16.0 { INSERT INTO t3(rowid, z) VALUES(3, 3); } -do_execsql_test 16.1 { SELECT rowid FROM t1, t2; } {1} -do_execsql_test 16.2 { SELECT rowid FROM t1, v1; } {1} -do_execsql_test 16.3 { SELECT rowid FROM t3, v1; } {3} -do_execsql_test 16.4 { SELECT rowid FROM t3, (SELECT 123); } {3} - -do_execsql_test 16.5 { SELECT rowid FROM t2, t1; } {1} -do_execsql_test 16.6 { SELECT rowid FROM v1, t1; } {1} -do_execsql_test 16.7 { SELECT rowid FROM v1, t3; } {3} -do_execsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } {3} +ifcapable allow_rowid_in_view { + set nosuch "1 {no such column: rowid}" + do_execsql_test 16.1 { SELECT rowid FROM t1, t2; } {1} + do_catchsql_test 16.2 { SELECT rowid FROM t1, v1; } $nosuch + do_catchsql_test 16.3 { SELECT rowid FROM t3, v1; } $nosuch + do_catchsql_test 16.4 { SELECT rowid FROM t3, (SELECT 123); } $nosuch + + do_execsql_test 16.5 { SELECT rowid FROM t2, t1; } {1} + do_catchsql_test 16.6 { SELECT rowid FROM v1, t1; } $nosuch + do_catchsql_test 16.7 { SELECT rowid FROM v1, t3; } $nosuch + do_catchsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } $nosuch +} else { + do_execsql_test 16.1 { SELECT rowid FROM t1, t2; } {1} + do_execsql_test 16.2 { SELECT rowid FROM t1, v1; } {1} + do_execsql_test 16.3 { SELECT rowid FROM t3, v1; } {3} + do_execsql_test 16.4 { SELECT rowid FROM t3, (SELECT 123); } {3} + + do_execsql_test 16.5 { SELECT rowid FROM t2, t1; } {1} + do_execsql_test 16.6 { SELECT rowid FROM v1, t1; } {1} + do_execsql_test 16.7 { SELECT rowid FROM v1, t3; } {3} + do_execsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } {3} +} -do_catchsql_test 16.5 { SELECT rowid FROM t1, t3; } {1 {no such column: rowid}} +do_catchsql_test 16.9 { SELECT rowid FROM t1, t3; } {1 {no such column: rowid}} diff --git a/test/trigger9.test b/test/trigger9.test index 6e31d1af97..47940de577 100644 --- a/test/trigger9.test +++ b/test/trigger9.test @@ -242,12 +242,27 @@ do_execsql_test 4.1 { END; } -do_catchsql_test 4.2 { - DELETE FROM v1 WHERE rowid=1; -} {1 {no such column: rowid}} +ifcapable !allow_rowid_in_view { + do_catchsql_test 4.2 { + DELETE FROM v1 WHERE rowid=1; + } {1 {no such column: rowid}} -do_catchsql_test 4.3 { - UPDATE v1 SET a=b WHERE rowid=2; -} {1 {no such column: rowid}} + do_catchsql_test 4.3 { + UPDATE v1 SET a=b WHERE rowid=2; + } {1 {no such column: rowid}} +} else { + do_execsql_test 4.2a { + DELETE FROM log; + } + do_catchsql_test 4.2 { + DELETE FROM v1 WHERE rowid=1; + } {0 {}} + do_catchsql_test 4.3 { + UPDATE v1 SET a=b WHERE rowid=2; + } {0 {}} + do_execsql_test 4.3b { + SELECT * FROM log; + } +} finish_test From e9feb0acfc4bd4fc86fbc7eaa160361bef3e4198 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 16:34:32 +0000 Subject: [PATCH 0260/1030] In the name resolver when SQLITE_ALLOW_ROWID_IN_INDEX is enabled, if there are multiple views that might resolve to the "rowid" but only one real table, then use that one real table and ignore the views. FossilOrigin-Name: 8fcea4cdfc89dd78eca5e7f62aa31aff0e296f41e79349d3af1cc3a2bc4d77c6 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/ctime.c | 3 --- src/resolve.c | 29 +++++++++++++++++++++++++++++ test/unionall.test | 2 +- 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index c5b4e813c0..98c9af5c57 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\stests\sto\swork\swith\sSQLITE_ALLOW_ROWID_IN_VIEW. -D 2024-03-19T15:27:15.880 +C In\sthe\sname\sresolver\swhen\sSQLITE_ALLOW_ROWID_IN_INDEX\sis\senabled,\sif\sthere\nare\smultiple\sviews\sthat\smight\sresolve\sto\sthe\s"rowid"\sbut\sonly\sone\sreal\stable,\nthen\suse\sthat\sone\sreal\stable\sand\signore\sthe\sviews. +D 2024-03-19T16:34:32.133 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -695,7 +695,7 @@ F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b F src/build.c 71445e2d1e2c78b120a20a46d80a29a9ea42370df430efda5bb6ef377e8016c8 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 +F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 @@ -748,7 +748,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432 +F src/resolve.c f851f7cce8cca274f82242b09e2fab67a42fa52de21c8a25cbdb490b057004ac F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ac3689a3f54f81e8b710ce772c5c49c13a152e4ac484c2429ad5264243e7de66 F src/shell.c.in a2ccceb9a250613f8156b098736bd94424c422972a1c1ddda35604531ae1762e @@ -1887,7 +1887,7 @@ F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff F test/types2.test 1aeb81976841a91eef292723649b5c4fe3bc3cac F test/types3.test c9db8f9e80309edfa4252585cf16bcab7ed31f39eeb904d21e831199a3613fb0 F test/unhex.test b7f1b806207cb77fa31c3e434fe92fba524464e3e9356809bfcc28f15af1a8b7 -F test/unionall.test 5b1c4186a661e4bf762875caf4c61d8fda3dd04a6fa9005187f6ba8900c2913f +F test/unionall.test cdae0b1b47128991d0c26075e552cbb1c1fa0b62c4fa7ffa5575e65a5e9fe834 F test/unionall2.test 71e8fa08d5699d50dc9f9dc0c9799c2e7a6bb7931a330d369307a4df7f157fa1 F test/unionallfault.test 652bfbb630e6c43135965dc1e8f0a9a791da83aec885d626a632fe1909c56f73 F test/unionvtab.test e1704ab1b4c1bb3ffc9da4681f8e85a0b909fd80b937984fc94b27415ac8e5a4 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0d711aaaa14472a82f8893e1b07d845073f3d018bd5b8093ec0b00ffbbc8cd5a -R 9a00ab01baff88b608a562a16a741256 -U dan -Z 3b22054791de9eb30bbf5d96e1597df1 +P 495b8c7b08b998ddfe2ad055703f058c768e7e94014952e5cd8a81c7c1515cb1 +R 8eb7d29f7ff85a3768eaeec1cf36e8a2 +U drh +Z 689a4a1a83e57ca389a38b62f6fe8edf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2d1f2cba94..0ad3f9c566 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -495b8c7b08b998ddfe2ad055703f058c768e7e94014952e5cd8a81c7c1515cb1 \ No newline at end of file +8fcea4cdfc89dd78eca5e7f62aa31aff0e296f41e79349d3af1cc3a2bc4d77c6 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 0ffe2a5bdf..cf761299fe 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -65,9 +65,6 @@ static const char * const sqlite3azCompileOpt[] = { "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN), # endif #endif -#ifdef SQLITE_ALLOW_ROWID_IN_VIEW - "ALLOW_ROWID_IN_VIEW", -#endif #ifdef SQLITE_ALLOW_URI_AUTHORITY "ALLOW_URI_AUTHORITY", #endif diff --git a/src/resolve.c b/src/resolve.c index c2957a870a..2971936105 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -469,8 +469,37 @@ static int lookupName( } } if( 0==cnt && VisibleRowid(pTab) ){ + /* pTab is a potential ROWID match. Keep track of it and match + ** the ROWID later if that seems appropriate. (Search for "cntTab" + ** to find related code.) Only allow a ROWID match if there is + ** a single ROWID match candidate. + */ +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + /* In SQLITE_ALLOW_ROWID_IN_VIEW mode, allow a ROWID match + ** if there is a single VIEW candidate or if there is a single + ** non-VIEW candidate plus multiple VIEW candidates. In other + ** words non-VIEW candidate terms take precedence over VIEWs. + */ + if( cntTab==0 + || (cntTab==1 + && ALWAYS(pMatch!=0) + && ALWAYS(pMatch->pTab!=0) + && (pMatch->pTab->tabFlags & TF_Ephemeral)!=0 + && (pTab->tabFlags & TF_Ephemeral)==0) + ){ + cntTab = 1; + pMatch = pItem; + }else{ + cntTab++; + } +#else + /* The (much more common) non-SQLITE_ALLOW_ROWID_IN_VIEW case is + ** simpler since we require exactly one candidate, which will + ** always be a non-VIEW + */ cntTab++; pMatch = pItem; +#endif } } if( pMatch ){ diff --git a/test/unionall.test b/test/unionall.test index 99cb48a259..ae1a271bfc 100644 --- a/test/unionall.test +++ b/test/unionall.test @@ -351,7 +351,7 @@ do_catchsql_test 5.30 { SELECT * FROM (t1 NATURAL JOIN pragma_table_xinfo('t1_a') NATURAL JOIN t3) t1 NATURAL JOIN t2 NATURAL JOIN t3 WHERE rowid ISNULL>0 AND 0%y; -} {1 {no such column: rowid}} +} {/1 {no such column: [a-z]+}/} } reset_db From ffbe4925532ed82f61dd93af40c288a593a5b5d3 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 19 Mar 2024 16:51:18 +0000 Subject: [PATCH 0261/1030] Update test scripts to account for [8fcea4cd]. FossilOrigin-Name: 0c543c51a8c5c8916f649a5e7fd3fedc9c05f2df36064b1699ea6f5e08eaa9e0 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- test/join5.test | 7 +------ test/join8.test | 7 +------ test/rowid.test | 2 +- 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 98c9af5c57..c2d38c6cc9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sname\sresolver\swhen\sSQLITE_ALLOW_ROWID_IN_INDEX\sis\senabled,\sif\sthere\nare\smultiple\sviews\sthat\smight\sresolve\sto\sthe\s"rowid"\sbut\sonly\sone\sreal\stable,\nthen\suse\sthat\sone\sreal\stable\sand\signore\sthe\sviews. -D 2024-03-19T16:34:32.133 +C Update\stest\sscripts\sto\saccount\sfor\s[8fcea4cd]. +D 2024-03-19T16:51:18.484 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1326,10 +1326,10 @@ F test/join.test f7abfef3faeaf2800308872e33a57e5b6e4a2b44fb8c6b90c6068412e71a6cf F test/join2.test 8561fe82ce434ac96de91544072e578dc2cadddf2d9bc9cd802f866a9b92502e F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0 F test/join4.test 1a352e4e267114444c29266ce79e941af5885916 -F test/join5.test f939b2c7f45a8d36f6b690b797cfa2d7bb828a5ff6e43d9cca88bd91e08fb464 +F test/join5.test 380d12a9350f99f0cc681a4f1fea999886f18b3fe0d71a9b3065bcaead1e007f F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c F test/join7.test 2268dcbb54b724391dda3748ea95c60d960607ffeed67885675998e7117697f6 -F test/join8.test 02da1534b2b47599a078e513f597c205934d115a5a6bc31af8a5615a7488a81f +F test/join8.test d384d63985e3991c404afccadaf3efd1cdf9cd72680167f80e3cb80b95c18c68 F test/join9.test 9056ddd3b0c0f4f9d658f4521038d9a37dc23ead8ca9a505d0b0db2b6a471e05 F test/joinA.test 6ac4efdbb1eb9ca398162c5bc5623a757803b04bb4d76453c8563a0bdc2f73bd F test/joinB.test 1b2ba3fc8568b49411787fccbf540570c148e9b6a53a30f80691cb6268098ded @@ -1535,7 +1535,7 @@ F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/round1.test 29c3c9039936ed024d672f003c4d35ee11c14c0acb75c5f7d6188ff16190cfd4 F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 -F test/rowid.test 17e2a82e0567eec4b265fd063c44b96d5fd7b25ad6bd976d9c5fd892f0c2e258 +F test/rowid.test f1e15169727f50a77854280b6cb9100f0bb1cff286f2a8157eecc2e1b5e01bbd F test/rowvalue.test baf4fa3ec1a8c1c920c3faa5fd25959cb454bbd99ac8960397c34549d9fc4abe F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b F test/rowvalue3.test 1347e25ca11c547c5a6ff0cc5626f95aa9740e9275bfaec096029f57cb2130ce @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 495b8c7b08b998ddfe2ad055703f058c768e7e94014952e5cd8a81c7c1515cb1 -R 8eb7d29f7ff85a3768eaeec1cf36e8a2 -U drh -Z 689a4a1a83e57ca389a38b62f6fe8edf +P 8fcea4cdfc89dd78eca5e7f62aa31aff0e296f41e79349d3af1cc3a2bc4d77c6 +R 83391bbbe1b5a044197ab1ad94f98ae7 +U dan +Z 5ca20466e8061812ee63f9a3dfe46ebc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0ad3f9c566..f4ba89c174 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8fcea4cdfc89dd78eca5e7f62aa31aff0e296f41e79349d3af1cc3a2bc4d77c6 \ No newline at end of file +0c543c51a8c5c8916f649a5e7fd3fedc9c05f2df36064b1699ea6f5e08eaa9e0 \ No newline at end of file diff --git a/test/join5.test b/test/join5.test index 7f8c2f6e65..703c256f86 100644 --- a/test/join5.test +++ b/test/join5.test @@ -371,16 +371,11 @@ do_execsql_test 9.1 { INSERT INTO sqlite_stat1 VALUES('t1','t1x1','648 324 81 81 81 81 81 81 81081 81 81 81'); ANALYZE sqlite_schema; } -ifcapable allow_rowid_in_view { - set res {1 {no such column: rowid}} -} else { - set res {0 1} -} do_catchsql_test 9.2 { SELECT a FROM (SELECT a FROM t1 NATURAL LEFT JOIN t1) NATURAL LEFT JOIN t1 WHERE (rowid,1)<=(5,0); -} $res +} {0 1} # 2022-03-02 https://sqlite.org/forum/info/50a1bbe08ce4c29c # Bloom-filter pulldown is incompatible with skip-scan. diff --git a/test/join8.test b/test/join8.test index 269d251fcc..fc50df32ff 100644 --- a/test/join8.test +++ b/test/join8.test @@ -41,11 +41,6 @@ do_execsql_test join8-1000 { CREATE INDEX t1x2 ON t1(b); INSERT INTO t1 DEFAULT VALUES; } {} -ifcapable allow_rowid_in_view { - set res {1 {no such column: rowid}} -} else { - set res {0 1} -} do_catchsql_test join8-1010 { SELECT a FROM ( @@ -66,7 +61,7 @@ do_catchsql_test join8-1010 { NATURAL LEFT FULL JOIN t1 WHERE ( rowid , 1 )<=(CASE 5 WHEN 619 THEN 841 ELSE 3374391096 END,0) ORDER BY a ASC; -} $res +} {0 1} # Pending issue #2: (now resolved) # Jump to addrHalt inside the RIGHT JOIN body subroutine bypasses the diff --git a/test/rowid.test b/test/rowid.test index 450ae35cce..75215d5dfc 100644 --- a/test/rowid.test +++ b/test/rowid.test @@ -813,7 +813,7 @@ ifcapable allow_rowid_in_view { do_execsql_test 16.5 { SELECT rowid FROM t2, t1; } {1} do_catchsql_test 16.6 { SELECT rowid FROM v1, t1; } $nosuch do_catchsql_test 16.7 { SELECT rowid FROM v1, t3; } $nosuch - do_catchsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } $nosuch + do_execsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } {3} } else { do_execsql_test 16.1 { SELECT rowid FROM t1, t2; } {1} do_execsql_test 16.2 { SELECT rowid FROM t1, v1; } {1} From 27ea83f66ec0a95ab07e93945e7be1ed76d6499c Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 19:42:56 +0000 Subject: [PATCH 0262/1030] Make sure the new u1.nRow value is copied when making a copy of a SrcItem object. This fixes a problem in [ac6f095e13e43d66] from yesterady. FossilOrigin-Name: 262f8f9d80d37160e4126634b99aa48fce2073e61f6365e8bdbe1cc4fa560a96 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 9 +++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 26d692be1b..3e08c7de52 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjustments\sto\sthe\stest\scases\sfor\sthe\sprevious\scheck-in\sto\smake\sthem\ncross-platform\sLinux/Mac/Windows.\s\sTest\schance\sonly.\s\sNo\schange\sto\score\scode. -D 2024-03-19T10:41:18.138 +C Make\ssure\sthe\snew\su1.nRow\svalue\sis\scopied\swhen\smaking\sa\scopy\sof\sa\sSrcItem\nobject.\s\sThis\sfixes\sa\sproblem\sin\s[ac6f095e13e43d66]\sfrom\syesterady. +D 2024-03-19T19:42:56.248 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c d7cfe9b9fe7ab47b254706589467d2e65fec3536b936d6f4eb28b84da6726ecc +F src/expr.c 94f48513fbec07725501298dee3f16d95b1762bb4a12296455f544b2d7f2d74a F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 45d272ef38d5ee6189f81369aefb8e3ac35868a67687012d93c84f2bbc42520a -R 06f52063180a10fd2f7e8878024a8e93 +P 0dddadbd5b217a48bb5c1b0568a03fbafb89dba98c577727bf4f79ff7e0ca849 +R e14b4caec27431611935484cb358ede2 U drh -Z be89e098a4549a3844da98de72222ae6 +Z bd83640688abf542746530f70fd640a9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 46aef1d450..a3e0e0577d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0dddadbd5b217a48bb5c1b0568a03fbafb89dba98c577727bf4f79ff7e0ca849 \ No newline at end of file +262f8f9d80d37160e4126634b99aa48fce2073e61f6365e8bdbe1cc4fa560a96 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 3a7065b21f..7e3f38279d 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1873,15 +1873,16 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int flags){ pNewItem->regResult = pOldItem->regResult; if( pNewItem->fg.isIndexedBy ){ pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy); + }else if( pNewItem->fg.isTabFunc ){ + pNewItem->u1.pFuncArg = + sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags); + }else{ + pNewItem->u1.nRow = pOldItem->u1.nRow; } pNewItem->u2 = pOldItem->u2; if( pNewItem->fg.isCte ){ pNewItem->u2.pCteUse->nUse++; } - if( pNewItem->fg.isTabFunc ){ - pNewItem->u1.pFuncArg = - sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags); - } pTab = pNewItem->pTab = pOldItem->pTab; if( pTab ){ pTab->nTabRef++; From 4aa21492d134e4713e7d0b9a2fa0df69af0595f3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 19:48:50 +0000 Subject: [PATCH 0263/1030] Add the --no-rowid-in-view option to the --help output of the CLI. FossilOrigin-Name: 134da9c348a5e3b5cef97b79f37d48257afd4fa958a84f6930ac9874284a14cd --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c2d38c6cc9..54c1de2dbc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\stest\sscripts\sto\saccount\sfor\s[8fcea4cd]. -D 2024-03-19T16:51:18.484 +C Add\sthe\s--no-rowid-in-view\soption\sto\sthe\s--help\soutput\sof\sthe\sCLI. +D 2024-03-19T19:48:50.520 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -751,7 +751,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c f851f7cce8cca274f82242b09e2fab67a42fa52de21c8a25cbdb490b057004ac F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ac3689a3f54f81e8b710ce772c5c49c13a152e4ac484c2429ad5264243e7de66 -F src/shell.c.in a2ccceb9a250613f8156b098736bd94424c422972a1c1ddda35604531ae1762e +F src/shell.c.in 31c3845fae8382e5c9c46a8985b51a444387edf77404ac4db6716493efe2c72f F src/sqlite.h.in e9d785f9d17f2caa366641d6616748310c8092cc0746f064c8cf5bcc767bcab0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8fcea4cdfc89dd78eca5e7f62aa31aff0e296f41e79349d3af1cc3a2bc4d77c6 -R 83391bbbe1b5a044197ab1ad94f98ae7 -U dan -Z 5ca20466e8061812ee63f9a3dfe46ebc +P 0c543c51a8c5c8916f649a5e7fd3fedc9c05f2df36064b1699ea6f5e08eaa9e0 +R d8ca3828d85dd4e8623c1490de65b057 +U drh +Z c0e8acb3c82219f215133f9caa378b5b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f4ba89c174..408e38f5d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c543c51a8c5c8916f649a5e7fd3fedc9c05f2df36064b1699ea6f5e08eaa9e0 \ No newline at end of file +134da9c348a5e3b5cef97b79f37d48257afd4fa958a84f6930ac9874284a14cd \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 51769a67d7..9a86a06659 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -12058,6 +12058,7 @@ static const char zOptions[] = " -newline SEP set output row separator. Default: '\\n'\n" " -nofollow refuse to open symbolic links to database files\n" " -nonce STRING set the safe-mode escape nonce\n" + " -no-rowid-in-view Disable rowid-in-view using sqlite3_config()\n" " -nullvalue TEXT set text string for NULL values. Default ''\n" " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n" " -pcachetrace trace all page cache operations\n" From 254729edb7b7e704b95af059e91bc4b3e11e9e4e Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 19 Mar 2024 23:01:56 +0000 Subject: [PATCH 0264/1030] Change the SQLITE_CONFIG_NO_ROWID_IN_VIEW configuration option to be just SQLITE_CONFIG_ROWID_IN_VIEW (without the "_NO_" in the middle) and give it the ability to turn the option on and off. Otherwise, it is difficult to test. FossilOrigin-Name: 5d412edc2e378999ad798d1d7d73c7f7a17ee4e3c751a0dd00b9d5ce32759550 --- manifest | 19 +++++++++---------- manifest.uuid | 2 +- src/main.c | 9 +++++++-- src/select.c | 3 ++- src/shell.c.in | 4 +++- src/sqlite.h.in | 25 +++++++++++++++---------- 6 files changed, 37 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 3a9d289865..a4d4966bbc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Return\sthe\serror\s"ambiguous\scolumn\sname:\srowid",\sinstead\sof\s"no\ssuch\scolumn:\srowid",\swhen\sa\s"rowid"\sreference\sis\sambiguous. -D 2024-03-19T19:56:39.777 +C Change\sthe\sSQLITE_CONFIG_NO_ROWID_IN_VIEW\sconfiguration\soption\sto\sbe\njust\sSQLITE_CONFIG_ROWID_IN_VIEW\s(without\sthe\s"_NO_"\sin\sthe\smiddle)\sand\sgive\nit\sthe\sability\sto\sturn\sthe\soption\son\sand\soff.\s\sOtherwise,\sit\sis\sdifficult\nto\stest. +D 2024-03-19T23:01:56.437 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -713,7 +713,7 @@ F src/insert.c 06ce505713e86172612f9e01febefd2d3331d1f70461b4ada0eae5a76bb6349f F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c 3db8bc4c8e0515b9e23bed3167de8b626a55e9eb1f65fe42b878d820cfa90628 +F src/main.c 8a59d297ec77e6b78550433bfccb95a1b26f2fb69aaaf233206e21579a1cfcc1 F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -750,9 +750,9 @@ F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c ac3689a3f54f81e8b710ce772c5c49c13a152e4ac484c2429ad5264243e7de66 -F src/shell.c.in 31c3845fae8382e5c9c46a8985b51a444387edf77404ac4db6716493efe2c72f -F src/sqlite.h.in e9d785f9d17f2caa366641d6616748310c8092cc0746f064c8cf5bcc767bcab0 +F src/select.c a83532bae45185f271b59babf715a31a831ac17e2b4bc061f52ee53825c688f1 +F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 +F src/sqlite.h.in f099b625b073ba250ff9f0feb4d7d0fb570ac1b9584584009ff4951f729e147c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h f8928f0397d797046396dd9d360a6af8ce6dcb48bd72ea290165b07c8c518744 @@ -2180,9 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 134da9c348a5e3b5cef97b79f37d48257afd4fa958a84f6930ac9874284a14cd 021f34fcfed41b607be8169bbda59aef93f130108d944f4741b46e8e345b2bbb -R be08dcf8f811c87330d104f5ec4dbed8 -T +closed 021f34fcfed41b607be8169bbda59aef93f130108d944f4741b46e8e345b2bbb +P 0615bdae2dfc70c7e0416a28e89ffde31fa44ed4b3dac46e5ef20eed0d89e58c +R 0da4f5b6bfe3d8c8b355040cbb4a265d U drh -Z e6cd68fc074ecbc59d0059bf2fbd13d3 +Z c8d34cb65d7a95190f13ea53bc6d7b05 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 15c3871d50..59f541b818 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0615bdae2dfc70c7e0416a28e89ffde31fa44ed4b3dac46e5ef20eed0d89e58c \ No newline at end of file +5d412edc2e378999ad798d1d7d73c7f7a17ee4e3c751a0dd00b9d5ce32759550 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 6c8ae5b281..bff801a87d 100644 --- a/src/main.c +++ b/src/main.c @@ -765,9 +765,14 @@ int sqlite3_config(int op, ...){ } #endif /* SQLITE_OMIT_DESERIALIZE */ - case SQLITE_CONFIG_NO_ROWID_IN_VIEW: { + case SQLITE_CONFIG_ROWID_IN_VIEW: { + int *pVal = va_arg(ap,int*); #ifdef SQLITE_ALLOW_ROWID_IN_VIEW - sqlite3GlobalConfig.mNoVisibleRowid = TF_NoVisibleRowid; + if( 0==*pVal ) sqlite3GlobalConfig.mNoVisibleRowid = TF_NoVisibleRowid; + if( 1==*pVal ) sqlite3GlobalConfig.mNoVisibleRowid = 0; + *pVal = (sqlite3GlobalConfig.mNoVisibleRowid==0); +#else + *pVal = 0; #endif break; } diff --git a/src/select.c b/src/select.c index f71b715517..8d3c69ebb9 100644 --- a/src/select.c +++ b/src/select.c @@ -6254,7 +6254,8 @@ static int selectExpander(Walker *pWalker, Select *p){ pX = &pNew->a[pNew->nExpr-1]; assert( pX->zEName==0 ); if( (selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){ - if( pNestedFrom && jnExpr ){ + if( pNestedFrom && (!ViewCanHaveRowid || jnExpr) ){ + assert( jnExpr ); pX->zEName = sqlite3DbStrDup(db, pNestedFrom->a[j].zEName); testcase( pX->zEName==0 ); }else{ diff --git a/src/shell.c.in b/src/shell.c.in index 9a86a06659..2f91ac8ba1 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -12350,7 +12350,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ }else if( cli_strcmp(z,"-utf8")==0 ){ }else if( cli_strcmp(z,"-no-utf8")==0 ){ }else if( cli_strcmp(z,"-no-rowid-in-view")==0 ){ - sqlite3_config(SQLITE_CONFIG_NO_ROWID_IN_VIEW); + int val = 0; + sqlite3_config(SQLITE_CONFIG_ROWID_IN_VIEW, &val); + assert( val==0 ); }else if( cli_strcmp(z,"-heap")==0 ){ #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) const char *zSize; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9c9a78c453..811ea3c5ef 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2144,15 +2144,20 @@ struct sqlite3_mem_methods { ** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that ** compile-time option is not set, then the default maximum is 1073741824. ** -** [[SQLITE_CONFIG_NO_ROWID_IN_VIEW]] -**
    SQLITE_CONFIG_NO_ROWID_IN_VIEW -**
    The SQLITE_CONFIG_NO_ROWID_IN_VIEW option prohibits VIEWs from having -** a ROWID. This is the default behavior and so test sqlite_config() option -** is normally a no-op. However, if SQLite is compiled with the -** -DSQLITE_ALLOW_ROWID_IN_VIEW option (not recommended!) then this configuration -** option will disable that capability and make SQLite operate as it normally -** would given default the default compile-time options. Once ROWIDs in VIEWs -** have been disabled using this option, they cannot be reenabled. +** [[SQLITE_CONFIG_ROWID_IN_VIEW]] +**
    SQLITE_CONFIG_ROWID_IN_VIEW +**
    The SQLITE_CONFIG_ROWID_IN_VIEW option enables are disables the ability +** for VIEWs to have a ROWID. The capability can only be abled if SQLite is +** compiled with -DSQLITE_ALLOW_ROWID_IN_VIEW, in which case it the capability +** defaults to on. This configuration option queries the current setting or +** changes the setting to off or on. The argument is a pointer to an integer. +** If that integer initially holds a value of 1, then the ability for VIEWs to +** have ROWIDs is activated. If the integer initially holds zero, then the +** ability is deactivated. After any changes, the integer is written with +** a 1 or 0, if the ability for VIEWs to have ROWIDs is on or off. If SQLite +** is compiled without -DSQLITE_ALLOW_ROWID_IN_VIEW (which is the usual and +** recommended case) then the integer is always filled with zero, regardless +** if its initial value. ** */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ @@ -2184,7 +2189,7 @@ struct sqlite3_mem_methods { #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ #define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */ -#define SQLITE_CONFIG_NO_ROWID_IN_VIEW 30 /* nil */ +#define SQLITE_CONFIG_ROWID_IN_VIEW 30 /* int* */ /* ** CAPI3REF: Database Connection Configuration Options From 697e122a11bdf15e9f503b1eb222c70b90874e03 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 20 Mar 2024 09:45:44 +0000 Subject: [PATCH 0265/1030] Fix typos in the SQLITE_CONFIG_ROWID_IN_VIEW documentation. FossilOrigin-Name: 1ad1ca498296493c8e89cda911cc153baa51c90ae6c19961841e6b4e37302a23 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 9 +++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index a4d4966bbc..2d322553b1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sSQLITE_CONFIG_NO_ROWID_IN_VIEW\sconfiguration\soption\sto\sbe\njust\sSQLITE_CONFIG_ROWID_IN_VIEW\s(without\sthe\s"_NO_"\sin\sthe\smiddle)\sand\sgive\nit\sthe\sability\sto\sturn\sthe\soption\son\sand\soff.\s\sOtherwise,\sit\sis\sdifficult\nto\stest. -D 2024-03-19T23:01:56.437 +C Fix\stypos\sin\sthe\sSQLITE_CONFIG_ROWID_IN_VIEW\sdocumentation. +D 2024-03-20T09:45:44.382 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -752,7 +752,7 @@ F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c a83532bae45185f271b59babf715a31a831ac17e2b4bc061f52ee53825c688f1 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 -F src/sqlite.h.in f099b625b073ba250ff9f0feb4d7d0fb570ac1b9584584009ff4951f729e147c +F src/sqlite.h.in 41c5febd217b1e475aae022895c60f57fbe39ff6136450110662cfad67002d43 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h f8928f0397d797046396dd9d360a6af8ce6dcb48bd72ea290165b07c8c518744 @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0615bdae2dfc70c7e0416a28e89ffde31fa44ed4b3dac46e5ef20eed0d89e58c -R 0da4f5b6bfe3d8c8b355040cbb4a265d +P 5d412edc2e378999ad798d1d7d73c7f7a17ee4e3c751a0dd00b9d5ce32759550 +R d82f649ee8e5d633f69feebd0d7bf101 U drh -Z c8d34cb65d7a95190f13ea53bc6d7b05 +Z ae521986bd186966a5bde1a9ef372fcb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 59f541b818..83e1223c29 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d412edc2e378999ad798d1d7d73c7f7a17ee4e3c751a0dd00b9d5ce32759550 \ No newline at end of file +1ad1ca498296493c8e89cda911cc153baa51c90ae6c19961841e6b4e37302a23 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 811ea3c5ef..06fcd3f89e 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2146,14 +2146,15 @@ struct sqlite3_mem_methods { ** ** [[SQLITE_CONFIG_ROWID_IN_VIEW]] **
    SQLITE_CONFIG_ROWID_IN_VIEW -**
    The SQLITE_CONFIG_ROWID_IN_VIEW option enables are disables the ability -** for VIEWs to have a ROWID. The capability can only be abled if SQLite is -** compiled with -DSQLITE_ALLOW_ROWID_IN_VIEW, in which case it the capability +**
    The SQLITE_CONFIG_ROWID_IN_VIEW option enables or disables the ability +** for VIEWs to have a ROWID. The capability can only be enabled if SQLite is +** compiled with -DSQLITE_ALLOW_ROWID_IN_VIEW, in which case the capability ** defaults to on. This configuration option queries the current setting or ** changes the setting to off or on. The argument is a pointer to an integer. ** If that integer initially holds a value of 1, then the ability for VIEWs to ** have ROWIDs is activated. If the integer initially holds zero, then the -** ability is deactivated. After any changes, the integer is written with +** ability is deactivated. Any other initial value for the integer leaves the +** setting unchanged. After changes, if any, the integer is written with ** a 1 or 0, if the ability for VIEWs to have ROWIDs is on or off. If SQLite ** is compiled without -DSQLITE_ALLOW_ROWID_IN_VIEW (which is the usual and ** recommended case) then the integer is always filled with zero, regardless From 7128c789bd98dd06bd261107fb78803236af45b2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 20 Mar 2024 10:40:25 +0000 Subject: [PATCH 0266/1030] Fix a typo in a comment. FossilOrigin-Name: 54680d0fbec1f0575ac4be6dca866971795dab2c42b02a492d5cd485f46d153f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/build.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 2d322553b1..970e874f41 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sin\sthe\sSQLITE_CONFIG_ROWID_IN_VIEW\sdocumentation. -D 2024-03-20T09:45:44.382 +C Fix\sa\stypo\sin\sa\scomment. +D 2024-03-20T10:40:25.308 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -692,7 +692,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 285b493d843e7ba8ef78b6ae7d31238e904901dbc0c484f7904de4cf18fd8802 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 71445e2d1e2c78b120a20a46d80a29a9ea42370df430efda5bb6ef377e8016c8 +F src/build.c fff536730a6d83120ae38d960f812b548394e8af6907249effb1764d69178106 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b @@ -2180,8 +2180,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5d412edc2e378999ad798d1d7d73c7f7a17ee4e3c751a0dd00b9d5ce32759550 -R d82f649ee8e5d633f69feebd0d7bf101 +P 1ad1ca498296493c8e89cda911cc153baa51c90ae6c19961841e6b4e37302a23 +R 881bc9317ed9df88acd3db1968866969 U drh -Z ae521986bd186966a5bde1a9ef372fcb +Z 3ac48e6dcd121003681750f4a6450153 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 83e1223c29..753c2ed9a5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1ad1ca498296493c8e89cda911cc153baa51c90ae6c19961841e6b4e37302a23 \ No newline at end of file +54680d0fbec1f0575ac4be6dca866971795dab2c42b02a492d5cd485f46d153f \ No newline at end of file diff --git a/src/build.c b/src/build.c index e7c23c173a..3ea35b331c 100644 --- a/src/build.c +++ b/src/build.c @@ -3007,7 +3007,7 @@ void sqlite3CreateView( ** setting fixes this problem. But the fix can be disabled by compiling ** with -DSQLITE_ALLOW_ROWID_IN_VIEW in case there are legacy apps that ** depend upon the old buggy behavior. The ability can also be toggled - ** using SQLITE_CONFIG_NO_ROWID_IN_VIEW */ + ** using sqlite3_config(SQLITE_CONFIG_ROWID_IN_VIEW,...) */ #ifdef SQLITE_ALLOW_ROWID_IN_VIEW p->tabFlags |= sqlite3Config.mNoVisibleRowid; /* Optional. Allow by default */ #else From e555bd4f0263b31e180e2bcc65703beed24011f9 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 20 Mar 2024 16:27:08 +0000 Subject: [PATCH 0267/1030] Change EXPLAIN QUERY PLAN output to say "USE TEMP B-TREE FOR LAST TERM OF ORDER BY", or "LAST N TERMS OF ORDER BY", instead of "RIGHT PART OF ORDER BY". FossilOrigin-Name: cd547c500442f3f58c05d6da8a67c3238560c5204ea62ec14afa844cc8fb94f0 --- manifest | 27 +++++++++++++------------ manifest.uuid | 2 +- src/select.c | 14 +++++++++---- test/cost.test | 2 +- test/eqp.test | 6 +++--- test/eqp2.test | 49 ++++++++++++++++++++++++++++++++++++++++++++++ test/orderby1.test | 2 +- test/selectA.test | 4 ++-- 8 files changed, 82 insertions(+), 24 deletions(-) create mode 100644 test/eqp2.test diff --git a/manifest b/manifest index 5cf6262c5f..8c06159035 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sSQLITE_ALLOW_ROWID_IN_VIEW\sbug-compatibility\soption\sso\sthat\sit\sworks\nagain.\s\sAdd\sthe\sSQLITE_CONFIG_ROWID_IN_VIEW\ssqlite3_config()\svalue\nto\soptionally\sdisable\sthe\sbug-compatibility\smode\sat\sstart-time.\s\sEnable\ntesting\sof\sSQLITE_ALLOW_ROWID_IN_VIEW. -D 2024-03-20T10:45:13.735 +C Change\sEXPLAIN\sQUERY\sPLAN\soutput\sto\ssay\s"USE\sTEMP\sB-TREE\sFOR\sLAST\sTERM\sOF\sORDER\sBY",\sor\s"LAST\sN\sTERMS\sOF\sORDER\sBY",\sinstead\sof\s"RIGHT\sPART\sOF\sORDER\sBY". +D 2024-03-20T16:27:08.690 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -750,7 +750,7 @@ F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c a83532bae45185f271b59babf715a31a831ac17e2b4bc061f52ee53825c688f1 +F src/select.c ced6678ead94c08d58cdb65cdda00a4871a3048e7834146f2a58ce71171808f8 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 41c5febd217b1e475aae022895c60f57fbe39ff6136450110662cfad67002d43 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1022,7 +1022,7 @@ F test/corruptK.test 5b4212fe346699831c5ad559a62c54e11c0611bdde1ea8423a091f9c01a F test/corruptL.test 504d90502d9993440226edc355d2275524b89064ea3df5ee5c27f7028ec59d07 F test/corruptM.test 7d574320e08c1b36caa3e47262061f186367d593a7e305d35f15289cc2c3e067 F test/corruptN.test 7c099d153a554001b4fb829c799b01f2ea6276cbc32479131e0db0da4efd9cc4 -F test/cost.test b11cdbf9f11ffe8ef99c9881bf390e61fe92baf2182bad1dbe6de59a7295c576 +F test/cost.test cc434a026b1e9d0d98137a147e24e5daf1b1ad09e9ff7da63b34c83ddd136d92 F test/count.test cd4bd531066e8d77ef8fe1e3fc8253d042072e117ccab214b290cf83f1602249 F test/countofview.test 4088e461a10ee33e69803c177a69aa1d7bba81a9ffc2df66d76465a22ca7fdfc F test/coveridxscan.test f35c7208dedc4f98e471c569df64c0f95a49f6e072d8dc7c8f99bdee2697de1b @@ -1100,7 +1100,8 @@ F test/enc.test 9a7be5479da985381d740b15f432800f65e2c87029ee57a318f42cb2eb43763a F test/enc2.test 848bf05f15b011719f478dddb7b5e9aea35e39e457493cba4c4eef75d849a5ec F test/enc3.test 55ef64416d72975c66167310a51dc9fc544ba3ae4858b8d5ab22f4cb6500b087 F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020 -F test/eqp.test f3f7548d2f3df03e2f23ecaf35c7c2cc7b89848bd7c3606d94a010521b7ea4f6 +F test/eqp.test 3302598f611220a6c61e29d9b7bb62fd4a43504509b978dbabdb0b3e56ae3bc0 +F test/eqp2.test 6e8996148de88f0e7670491e92e712a2920a369b4406f21a27c3c9b6a46b68dd F test/errmsg.test eae9f091eb39ce7e20305de45d8e5d115b68fa856fba4ea6757b6ca3705ff7f9 F test/eval.test 73969a2d43a511bf44080c44485a8c4d796b6a4f038d19e491867081155692c0 F test/exclusive.test 7ff63be7503990921838d5c9f77f6e33e68e48ed1a9d48cd28745bf650bf0747 @@ -1467,7 +1468,7 @@ F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/optfuzz-db01.c 9f2fa80b8f84ebbf1f2e8b13421a4e0477fe300f6686fbd76cac1d2db66e0fdc F test/optfuzz-db01.txt 21f6bdeadc701cf11528276e2a55c70bfcb846ba42df327f979bd9e7b6ce7041 F test/optfuzz.c 690430a0bf0ad047d5a168bf52b05b2ee97aedaad8c14337e9eb5050faa64994 -F test/orderby1.test 02cfd870127a7342170b829175c5c53e9e7405744451ac1aeb2f7e2b0c18ca76 +F test/orderby1.test 7d0e4ee692a3e808c1026b3c483594ad1e468b68b50dcefa0d678a8c05274ceb F test/orderby2.test bc11009f7cd99d96b1b11e57b199b00633eb5b04 F test/orderby3.test 8619d06a3debdcd80a27c0fdea5c40b468854b99 F test/orderby4.test 4d39bfbaaa3ae64d026ca2ff166353d2edca4ba4 @@ -1578,7 +1579,7 @@ F test/select6.test 9b2fb4ffedf52e1b5703cfcae1212e7a4a063f014c0458d78d29aca3db76 F test/select7.test f659f231489349e8c5734e610803d7654207318f F test/select8.test 8c8f5ae43894c891efc5755ed905467d1d67ad5d F test/select9.test f7586b207ce2304ab80dc93d3146469a28fd4403621dd3a82d06644563d3c812 -F test/selectA.test 6aef8b2136a4ac7a3e2e4161d2b8ca7bc6ebe2779de084f9bb66ca9e2323a937 +F test/selectA.test 1da8ce3884c326e11d2855baffb76436b0d7e044404af8a2a70d1399a4ff7e29 F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25 F test/selectC.test 38c530b0cc5728b793c3c11f52b52c70290d39822224acd39011c89c1853bd31 F test/selectD.test 6d1909b49970bf92f45ce657505befcef5fc7cbc13544e18103a316d32189bfb @@ -2180,9 +2181,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 262f8f9d80d37160e4126634b99aa48fce2073e61f6365e8bdbe1cc4fa560a96 54680d0fbec1f0575ac4be6dca866971795dab2c42b02a492d5cd485f46d153f -R 1676f1a7037df308a062e51e2c63ab1f -T +closed 54680d0fbec1f0575ac4be6dca866971795dab2c42b02a492d5cd485f46d153f -U drh -Z 8bdaec16fb58072604ac6ea406b7bf1a +P b6802565df0f63286a7ef26c92d3ed817895f244920a24909cd855090fdfa08c +R 8123b01b9bcdf105a2e2ddc317d657f0 +T *branch * eqp-orderby +T *sym-eqp-orderby * +T -sym-trunk * +U dan +Z b979ee1c2ca7e0d90b1c38ab5826e1ad # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b48a5a89de..310df97d77 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b6802565df0f63286a7ef26c92d3ed817895f244920a24909cd855090fdfa08c \ No newline at end of file +cd547c500442f3f58c05d6da8a67c3238560c5204ea62ec14afa844cc8fb94f0 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 8d3c69ebb9..b539288e9d 100644 --- a/src/select.c +++ b/src/select.c @@ -1673,9 +1673,16 @@ static void generateSortTail( int addrExplain; /* Address of OP_Explain instruction */ #endif - ExplainQueryPlan2(addrExplain, (pParse, 0, - "USE TEMP B-TREE FOR %sORDER BY", pSort->nOBSat>0?"RIGHT PART OF ":"") - ); + nKey = pOrderBy->nExpr - pSort->nOBSat; + if( pSort->nOBSat==0 || nKey==1 ){ + ExplainQueryPlan2(addrExplain, (pParse, 0, + "USE TEMP B-TREE FOR %sORDER BY", pSort->nOBSat?"LAST TERM OF ":"" + )); + }else{ + ExplainQueryPlan2(addrExplain, (pParse, 0, + "USE TEMP B-TREE FOR LAST %d TERMS OF ORDER BY", nKey + )); + } sqlite3VdbeScanStatusRange(v, addrExplain,pSort->addrPush,pSort->addrPushEnd); sqlite3VdbeScanStatusCounters(v, addrExplain, addrExplain, pSort->addrPush); @@ -1713,7 +1720,6 @@ static void generateSortTail( regRow = sqlite3GetTempRange(pParse, nColumn); } } - nKey = pOrderBy->nExpr - pSort->nOBSat; if( pSort->sortFlags & SORTFLAG_UseSorter ){ int regSortOut = ++pParse->nMem; iSortTab = pParse->nTab++; diff --git a/test/cost.test b/test/cost.test index 5684177a13..6106caba8c 100644 --- a/test/cost.test +++ b/test/cost.test @@ -103,7 +103,7 @@ do_eqp_test 5.2 { } { QUERY PLAN |--SCAN t2 USING INDEX t2i1 - `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY + `--USE TEMP B-TREE FOR LAST TERM OF ORDER BY } do_eqp_test 5.3 { diff --git a/test/eqp.test b/test/eqp.test index 61fd617d89..cd441c271d 100644 --- a/test/eqp.test +++ b/test/eqp.test @@ -413,7 +413,7 @@ do_eqp_test 4.2.3 { | `--USE TEMP B-TREE FOR ORDER BY `--RIGHT |--SCAN t2 USING INDEX t2i1 - `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY + `--USE TEMP B-TREE FOR LAST 2 TERMS OF ORDER BY } do_eqp_test 4.2.4 { SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 1 @@ -425,7 +425,7 @@ do_eqp_test 4.2.4 { | `--USE TEMP B-TREE FOR ORDER BY `--RIGHT |--SCAN t2 USING INDEX t2i1 - `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY + `--USE TEMP B-TREE FOR LAST 2 TERMS OF ORDER BY } do_eqp_test 4.2.5 { SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 1 @@ -437,7 +437,7 @@ do_eqp_test 4.2.5 { | `--USE TEMP B-TREE FOR ORDER BY `--RIGHT |--SCAN t2 USING INDEX t2i1 - `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY + `--USE TEMP B-TREE FOR LAST 2 TERMS OF ORDER BY } do_eqp_test 4.3.1 { diff --git a/test/eqp2.test b/test/eqp2.test new file mode 100644 index 0000000000..3c634fc28a --- /dev/null +++ b/test/eqp2.test @@ -0,0 +1,49 @@ +# 2024 March 20 +# +# 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 + +set testprefix eqp2 + +do_execsql_test 1.0 { + CREATE TABLE t1(a, b, c, d); + CREATE INDEX i1 ON t1(a, b, c); +} + +do_eqp_test 1.1 { + SELECT * FROM t1 ORDER BY a, b, c +} { + QUERY PLAN + `--SCAN t1 USING INDEX i1 +} + + +do_eqp_test 1.2 { + SELECT * FROM t1 ORDER BY a, b, +c +} { + QUERY PLAN + |--SCAN t1 USING INDEX i1 + `--USE TEMP B-TREE FOR LAST TERM OF ORDER BY +} + +do_eqp_test 1.3 { + SELECT * FROM t1 ORDER BY a, +b, +c +} { + QUERY PLAN + |--SCAN t1 USING INDEX i1 + `--USE TEMP B-TREE FOR LAST 2 TERMS OF ORDER BY +} + +finish_test + + diff --git a/test/orderby1.test b/test/orderby1.test index 7432b5473d..41444a44c3 100644 --- a/test/orderby1.test +++ b/test/orderby1.test @@ -520,7 +520,7 @@ do_eqp_test 8.1 { } { QUERY PLAN |--SCAN t1 USING INDEX i1 - `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY + `--USE TEMP B-TREE FOR LAST TERM OF ORDER BY } do_execsql_test 8.2 { diff --git a/test/selectA.test b/test/selectA.test index 7d72bb3fa5..91b1548488 100644 --- a/test/selectA.test +++ b/test/selectA.test @@ -1340,10 +1340,10 @@ do_eqp_test 4.1.2 { `--MERGE (UNION ALL) |--LEFT | |--SCAN t5 USING INDEX i2 - | `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY + | `--USE TEMP B-TREE FOR LAST TERM OF ORDER BY `--RIGHT |--SCAN t4 USING INDEX i1 - `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY + `--USE TEMP B-TREE FOR LAST TERM OF ORDER BY } do_execsql_test 4.1.3 { From 296ae1e4673151e59593105b653e87eceae25163 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 21 Mar 2024 10:35:33 +0000 Subject: [PATCH 0268/1030] Fix all test cases so that they work with SQLITE_ALLOW_ROWID_IN_VIEW. FossilOrigin-Name: 66c69e2f20f7692e0f34743ae97b09c4d8d11b874cdc5381795f2d1e0410f724 --- manifest | 21 ++++++++++----------- manifest.uuid | 2 +- src/ctime.c | 3 +++ test/misc8.test | 7 ++++++- test/rowid.test | 2 +- tool/mkctimec.tcl | 1 + 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 64843591f9..0e4698a26a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sEXPLAIN\sQUERY\sPLAN\soutput\sto\ssay\s"USE\sTEMP\sB-TREE\sFOR\sLAST\sTERM\sOF\sORDER\sBY",\sor\s"LAST\sN\sTERMS\sOF\sORDER\sBY",\sinstead\sof\s"RIGHT\sPART\sOF\sORDER\sBY". -D 2024-03-20T16:56:12.477 +C Fix\sall\stest\scases\sso\sthat\sthey\swork\swith\sSQLITE_ALLOW_ROWID_IN_VIEW. +D 2024-03-21T10:35:33.254 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -695,7 +695,7 @@ F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b F src/build.c fff536730a6d83120ae38d960f812b548394e8af6907249effb1764d69178106 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b +F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 @@ -1433,7 +1433,7 @@ F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db F test/misc5.test 027cf0ac10314ea534173f335a33bb4059907ddabbac2c16786766d6f26c8923 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test d912f3d45c2989191b797504a220ca225d6be80b21acad22ba0d35f4a9ee4579 -F test/misc8.test 4db9f8be59834cea08c87e9658014080efa02678ef54a088f84fa5647e81fee0 +F test/misc8.test 08d2380bc435486b12161521f225043ac2be26f02471c2c1ea4cac0b1548edbd F test/misuse.test 9e7f78402005e833af71dcab32d048003869eca5abcaccc985d4f8dc1d86bcc7 F test/mjournal.test 28a08d5cb5fb5b5702a46e19176e45e964e0800d1f894677169e79f34030e152 F test/mmap1.test 18de3fd7b70a777af6004ca2feecfcdd3d0be17fa04058e808baf530c94b1a1d @@ -1536,7 +1536,7 @@ F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/round1.test 29c3c9039936ed024d672f003c4d35ee11c14c0acb75c5f7d6188ff16190cfd4 F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 -F test/rowid.test aaa2572271edf58f8f88ac4d39f69e57ee5ae7a858332cdce9106e7cff8b7963 +F test/rowid.test d27191b5ce794c05bf61081e8b2c546a1844c1641321dcaf7fb785234256cc8e F test/rowvalue.test baf4fa3ec1a8c1c920c3faa5fd25959cb454bbd99ac8960397c34549d9fc4abe F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b F test/rowvalue3.test 1347e25ca11c547c5a6ff0cc5626f95aa9740e9275bfaec096029f57cb2130ce @@ -2101,7 +2101,7 @@ F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176 F tool/mkautoconfamal.sh cbdcf993fa83dccbef7fb77b39cdeb31ef9f77d9d88c9e343b58d35ca3898a6a F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x -F tool/mkctimec.tcl a16682eae5f01f85e5861b2aa215ca0d46b4230658ee25977e02b4508566fb75 x +F tool/mkctimec.tcl 060e9785e9503bf51f8b1b11b542bdeef90fd0ceb0738154f6762acec0c61e5f x F tool/mkkeywordhash.c b9faa0ae7e14e4dbbcd951cddd786bf46b8a65bb07b129ba8c0cfade723aaffd F tool/mkmsvcmin.tcl 8897d515ef7f94772322db95a3b6fce6c614d84fe0bdd06ba5a1c786351d5a1d F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef @@ -2181,9 +2181,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b6802565df0f63286a7ef26c92d3ed817895f244920a24909cd855090fdfa08c cd547c500442f3f58c05d6da8a67c3238560c5204ea62ec14afa844cc8fb94f0 -R 8123b01b9bcdf105a2e2ddc317d657f0 -T +closed cd547c500442f3f58c05d6da8a67c3238560c5204ea62ec14afa844cc8fb94f0 -U dan -Z cfb92556c121157a43b1e3903f143f16 +P 7e13a2c7583dbcb660adde6b0465da037365971c56726b8f18a541d8803ffeed +R 2027b60f20ab6be3fc26d73a48e5361c +U drh +Z 4767141a590293471cedda2bdaf01e5d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 800ecf82c9..423f236b45 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7e13a2c7583dbcb660adde6b0465da037365971c56726b8f18a541d8803ffeed \ No newline at end of file +66c69e2f20f7692e0f34743ae97b09c4d8d11b874cdc5381795f2d1e0410f724 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index cf761299fe..0ffe2a5bdf 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -65,6 +65,9 @@ static const char * const sqlite3azCompileOpt[] = { "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN), # endif #endif +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + "ALLOW_ROWID_IN_VIEW", +#endif #ifdef SQLITE_ALLOW_URI_AUTHORITY "ALLOW_URI_AUTHORITY", #endif diff --git a/test/misc8.test b/test/misc8.test index 32b3a597dc..60b44fe1c7 100644 --- a/test/misc8.test +++ b/test/misc8.test @@ -100,6 +100,11 @@ do_execsql_test misc8-2.1 { # 2016-02-26: An assertion fault found by the libFuzzer project # +ifcapable allow_rowid_in_view { + set nosuch "1 {ambiguous column name: rowid}" +} else { + set nosuch "1 {no such column: rowid}" +} do_catchsql_test misc8-3.0 { SELECT * FROM @@ -110,7 +115,7 @@ do_catchsql_test misc8-3.0 { (SELECT 6 AS j UNION ALL SELECT 7) AS x4 WHERE i Date: Thu, 21 Mar 2024 11:37:36 +0000 Subject: [PATCH 0269/1030] Have os_unix.c reuse cached file-descriptors in the case when a read-write fd is requested on a read-only file and a read-only fd returned. FossilOrigin-Name: a678e85402af08c1e387bf30ff2205f84dd7da749755da565d70f831c007a3d9 --- manifest | 15 +++++++------ manifest.uuid | 2 +- src/os_unix.c | 9 +++++++- test/readonly.test | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 test/readonly.test diff --git a/manifest b/manifest index 0e4698a26a..d352d9cc2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sall\stest\scases\sso\sthat\sthey\swork\swith\sSQLITE_ALLOW_ROWID_IN_VIEW. -D 2024-03-21T10:35:33.254 +C Have\sos_unix.c\sreuse\scached\sfile-descriptors\sin\sthe\scase\swhen\sa\sread-write\sfd\sis\srequested\son\sa\sread-only\sfile\sand\sa\sread-only\sfd\sreturned. +D 2024-03-21T11:37:36.346 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -734,7 +734,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c 8d7533b3b4d0d2d6ddd34d1ebc92f50a91f04e722a3a9295a000bc3c25128e2f +F src/os_unix.c 6227cbc4ac93046f121436886cf3712da6f4e2082af6314f976eeae1d86b794a F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd @@ -1522,6 +1522,7 @@ F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 +F test/readonly.test bdf5a451f415bc3153764122d034f553797c27194ffbd1e9763ecd9500af41d2 F test/recover.test 6463509a7404e0c35431dd9b4a1c3b4a29d7a6af8a08462b31670c8a5a616d3a F test/regexp1.test 8f2a8bc1569666e29a4cee6c1a666cd224eb6d50e2470d1dc1df995170f3e0f1 F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed1368b5 @@ -2181,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7e13a2c7583dbcb660adde6b0465da037365971c56726b8f18a541d8803ffeed -R 2027b60f20ab6be3fc26d73a48e5361c -U drh -Z 4767141a590293471cedda2bdaf01e5d +P 66c69e2f20f7692e0f34743ae97b09c4d8d11b874cdc5381795f2d1e0410f724 +R 41345a246cf3c264839b8ebe82b82196 +U dan +Z d2317639297bfb820720d835feec7e58 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 423f236b45..ac95fcbf05 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -66c69e2f20f7692e0f34743ae97b09c4d8d11b874cdc5381795f2d1e0410f724 \ No newline at end of file +a678e85402af08c1e387bf30ff2205f84dd7da749755da565d70f831c007a3d9 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 4663c22d94..9e7ba05d68 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -6398,12 +6398,19 @@ static int unixOpen( rc = SQLITE_READONLY_DIRECTORY; }else if( errno!=EISDIR && isReadWrite ){ /* Failed to open the file for read/write access. Try read-only. */ + UnixUnusedFd *pReadonly = 0; flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE); openFlags &= ~(O_RDWR|O_CREAT); flags |= SQLITE_OPEN_READONLY; openFlags |= O_RDONLY; isReadonly = 1; - fd = robust_open(zName, openFlags, openMode); + pReadonly = findReusableFd(zName, flags); + if( pReadonly ){ + fd = pReadonly->fd; + sqlite3_free(pReadonly); + }else{ + fd = robust_open(zName, openFlags, openMode); + } } } if( fd<0 ){ diff --git a/test/readonly.test b/test/readonly.test new file mode 100644 index 0000000000..811d54f3b5 --- /dev/null +++ b/test/readonly.test @@ -0,0 +1,54 @@ +# 2024 March 21 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# This file contains tests for using databases in read-only mode on +# unix. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/lock_common.tcl +source $testdir/wal_common.tcl +set ::testprefix readonly + +do_execsql_test 1.0 { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2), (3, 4), (5, 6); +} + +db close +file attributes test.db -permissions r--r--r-- + +sqlite3 db test.db + +do_catchsql_test 1.1 { + INSERT INTO t1 VALUES(7, 8); +} {1 {attempt to write a readonly database}} + +do_execsql_test 1.2 { + BEGIN; + SELECT * FROM t1; +} {1 2 3 4 5 6} + +# The following attempts to open a read/write fd on the database 20,000 +# times. And each time instead opens a read-only fd. At one point this +# was failing to reuse cached fds, causing a "too many open file-descriptors" +# error. +do_test 1.3 { + for {set ii 0} {$ii < 20000} {incr ii} { + sqlite3 db2 test.db + db2 close + } + set {} {} +} {} + + +finish_test From 529ed1a3a3b1a32fa1343e0466f627870cffbfb6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 21 Mar 2024 11:46:52 +0000 Subject: [PATCH 0270/1030] Enhancements to testrunner.tcl: (1) Add the "--config CONFIGS" option, to that only configuration named on the comma-separated list CONFIGS are run. (2) Add the "--omit CONFIGS" to omit configuration on the CONFIGS list (3) Add the Android configuration to "release" FossilOrigin-Name: 4ccb372967fab779b29be8f01c879a99ef247981466f81f55e18e3961fbd7d5a --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- test/sessionfuzz.c | 1 + test/testrunner.tcl | 28 +++++++++++++++++++--------- test/testrunner_data.tcl | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index d352d9cc2b..3f732c3abd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sos_unix.c\sreuse\scached\sfile-descriptors\sin\sthe\scase\swhen\sa\sread-write\sfd\sis\srequested\son\sa\sread-only\sfile\sand\sa\sread-only\sfd\sreturned. -D 2024-03-21T11:37:36.346 +C Enhancements\sto\stestrunner.tcl:\n(1)\sAdd\sthe\s"--config\sCONFIGS"\soption,\sto\sthat\sonly\sconfiguration\snamed\non\sthe\scomma-separated\slist\sCONFIGS\sare\srun.\n(2)\sAdd\sthe\s"--omit\sCONFIGS"\sto\somit\sconfiguration\son\sthe\sCONFIGS\slist\n(3)\sAdd\sthe\sAndroid\sconfiguration\sto\s"release" +D 2024-03-21T11:46:52.796 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1590,7 +1590,7 @@ F test/selectG.test 089f7d3d7e6db91566f00b036cb353107a2cca6220eb1cb264085a836dae F test/selectH.test 0b54599f1917d99568c9b929df22ec6261ed7b6d2f02a46b5945ef81b7871aac F test/session.test 78fa2365e93d3663a6e933f86e7afc395adf18be F test/sessionfuzz-data1.db 1f8d5def831f19b1c74571037f0d53a588ea49a6c4ca2a028fc0c27ef896dbcb -F test/sessionfuzz.c 666b47e177c7b25f01ba645d41fb9131d2d54ae673f0d81c08f5af2b3e6ecbda +F test/sessionfuzz.c f693b8827034a3bed7616d89c65fb4fe8b7ff3c0f000c6ea6beda69b7f1aced3 F test/shared.test f022874d9d299fe913529dc10f52ad5a386e4e7ff709270b9b1111b3a0f3420a F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879 F test/shared3.test f8cd07c1a2b7cdb315c01671a0b2f8e3830b11ef31da6baa9a9cd8da88965403 @@ -1690,8 +1690,8 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl 01bc3b5bc900dc73b076180727eb2869dc61426b1ab95ac2f42def5d1f3d407e -F test/testrunner_data.tcl 7032a64e4757db0bf83c6874cab2ccbb14a8708b4d68c1ddc8b359e204139cb7 +F test/testrunner.tcl b48a8fc17e3b200244f53d60348afa7fe9482400d164e95709890743af9536d0 +F test/testrunner_data.tcl 3d36660cfd55ea5e20e661e8f94c0520feebcb437848f9b98b33c483cc479c0c F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 66c69e2f20f7692e0f34743ae97b09c4d8d11b874cdc5381795f2d1e0410f724 -R 41345a246cf3c264839b8ebe82b82196 -U dan -Z d2317639297bfb820720d835feec7e58 +P a678e85402af08c1e387bf30ff2205f84dd7da749755da565d70f831c007a3d9 +R 2c6a53e503eb513e49b4f3899bff37cd +U drh +Z 89d0196ee33d74016c89e304cba255b3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ac95fcbf05..09d6bad378 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a678e85402af08c1e387bf30ff2205f84dd7da749755da565d70f831c007a3d9 \ No newline at end of file +4ccb372967fab779b29be8f01c879a99ef247981466f81f55e18e3961fbd7d5a \ No newline at end of file diff --git a/test/sessionfuzz.c b/test/sessionfuzz.c index 093c2b043d..c389a5e996 100644 --- a/test/sessionfuzz.c +++ b/test/sessionfuzz.c @@ -60,6 +60,7 @@ #define SQLITE_DEBUG 1 #define SQLITE_THREADSAFE 0 +#undef SQLITE_OMIT_LOAD_EXTENSION #define SQLITE_OMIT_LOAD_EXTENSION 0 #define SQLITE_ENABLE_SESSION 1 #define SQLITE_ENABLE_PREUPDATE_HOOK 1 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index e8570ddf19..05f7d4cc98 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -60,13 +60,15 @@ Usage: $a0 status where SWITCHES are: - --buildonly - --dryrun - --explain - --jobs NUMBER-OF-JOBS - --stop-on-coredump - --stop-on-error - --zipvfs ZIPVFS-SOURCE-DIR + --buildonly Build test exes but do not run tests + --config CONFIGS Only use configs on comma-separate list CONFIGS + --dryrun Write what would have happened to testrunner.log + --explain Write summary to stdout + --jobs NUM Run tests using NUM separate processes + --omit CONFIGS Omit configs on comma-separated list CONFIGS + --stop-on-coredump Stop running if any test segfaults + --stop-on-error Stop running after any reported error + --zipvfs ZIPVFSDIR ZIPVFS source directory Special values for PERMUTATION that work with plain tclsh: @@ -172,6 +174,8 @@ set TRG(reporttime) 2000 set TRG(fuzztest) 0 ;# is the fuzztest option present. set TRG(zipvfs) "" ;# -zipvfs option, if any set TRG(buildonly) 0 ;# True if --buildonly option +set TRG(config) {} ;# Only build the named configurations +set TRG(omitconfig) {} ;# Do not build these configurations set TRG(dryrun) 0 ;# True if --dryrun option set TRG(explain) 0 ;# True for the --explain option set TRG(stopOnError) 0 ;# Stop running at first failure @@ -468,10 +472,16 @@ for {set ii 0} {$ii < [llength $argv]} {incr ii} { if {$isLast} { usage } } elseif {($n>2 && [string match "$a*" --buildonly]) || $a=="-b"} { set TRG(buildonly) 1 + } elseif {($n>2 && [string match "$a*" --config]) || $a=="-c"} { + incr ii + set TRG(config) [lindex $argv $ii] } elseif {($n>2 && [string match "$a*" --dryrun]) || $a=="-d"} { set TRG(dryrun) 1 } elseif {($n>2 && [string match "$a*" --explain]) || $a=="-e"} { set TRG(explain) 1 + } elseif {($n>2 && [string match "$a*" --omit]) || $a=="-c"} { + incr ii + set TRG(omitconfig) [lindex $argv $ii] } elseif {[string match "$a*" --stop-on-error]} { set TRG(stopOnError) 1 } elseif {[string match "$a*" --stop-on-coredump]} { @@ -485,8 +495,6 @@ for {set ii 0} {$ii < [llength $argv]} {incr ii} { } set argv [list] - - # This script runs individual tests - tcl scripts or [make xyz] commands - # in directories named "testdir$N", where $N is an integer. This variable # contains a list of integers indicating the directories in use. @@ -911,6 +919,8 @@ proc add_jobs_from_cmdline {patternlist} { release { set patternlist [lrange $patternlist 1 end] foreach b [trd_builds $TRG(platform)] { + if {$TRG(config)!="" && ![regexp "\\y$b\\y" $TRG(config)]} continue + if {[regexp "\\y$b\\y" $TRG(omitconfig)]} continue set bld [add_build_job $b $TRG(testfixture)] foreach c [trd_configs $TRG(platform) $b] { add_tcl_jobs $bld $c $patternlist diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index 73b5472a99..f8f12d91a7 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -23,6 +23,7 @@ namespace eval trd { set tcltest(linux.No-lookaside) veryquick set tcltest(linux.Devkit) veryquick set tcltest(linux.Apple) veryquick + set tcltest(linux.Android) veryquick set tcltest(linux.Sanitize) veryquick set tcltest(linux.Device-One) all set tcltest(linux.Default) all_plus_autovacuum_crash @@ -53,6 +54,7 @@ namespace eval trd { set extra(linux.Device-Two) {fuzztest sourcetest threadtest} set extra(linux.No-lookaside) {fuzztest sourcetest} set extra(linux.Devkit) {fuzztest sourcetest} + set extra(linux.Android) {fuzztest sourcetest} set extra(linux.Apple) {fuzztest sourcetest} set extra(linux.Sanitize) {fuzztest sourcetest} set extra(linux.Default) {fuzztest sourcetest threadtest} @@ -246,6 +248,40 @@ namespace eval trd { -O2 -DSQLITE_ENABLE_LOCKING_STYLE=1 } + set build(Android) { + -Os + -DHAVE_USLEEP=1 + -DSQLITE_HAVE_ISNAN + -DSQLITE_POWERSAFE_OVERWRITE=1 + -DSQLITE_DEFAULT_FILE_FORMAT=4 + -DSQLITE_DEFAULT_AUTOVACUUM=1 + -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 + -DSQLITE_ENABLE_FTS3 + -DSQLITE_ENABLE_FTS3_BACKWARDS + -DSQLITE_ENABLE_FTS4 + -DSQLITE_SECURE_DELETE + -DSQLITE_ENABLE_BATCH_ATOMIC_WRITE + -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD + -DSQLITE_ALLOW_ROWID_IN_VIEW + -DSQLITE_ENABLE_BYTECODE_VTAB + -Wno-unused-parameter + -Werror + -DUSE_PREAD64 + -Dfdatasync=fdatasync + -DHAVE_MALLOC_H=1 + -DHAVE_MALLOC_USABLE_SIZE + -DSQLITE_ENABLE_DBSTAT_VTAB + } + # Compile-options used by Android but omitted from these + # tests: + # -DNDEBUG=1 + # -DSQLITE_DEFAULT_LEGACY_ALTER_TABLE + # -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 + # -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600 + # -DSQLITE_OMIT_BUILTIN_TEST + # -DSQLITE_OMIT_LOAD_EXTENSION + # -DSQLITE_OMIT_COMPILEOPTION_DIAGS + # set build(Apple) { -Os -DHAVE_GMTIME_R=1 From 006a9b51aa5fcb636325587d28b17474148bb41e Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 21 Mar 2024 15:52:52 +0000 Subject: [PATCH 0271/1030] Add comments (only, no code) to the JS sqlite3_config() bindings reminding us why SQLITE_CONFIG_ROWID_IN_VIEW is specifically not included. JNI does not need this treatment because it explicitly supports only a very small subset of config options. FossilOrigin-Name: 4fea396221e84f9532f9327226691621a23bd966a860329fc579141c69cf7f64 --- ext/wasm/api/sqlite3-api-glue.js | 4 ++++ ext/wasm/api/sqlite3-wasm.c | 4 ++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index 2cb4c800d2..b05d7a765a 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -1547,6 +1547,10 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ case capi.SQLITE_CONFIG_SQLLOG: // 21 /* xSqllog, void* */ case capi.SQLITE_CONFIG_WIN32_HEAPSIZE: // 23 /* int nByte */ default: + /* maintenance note: we specifically do not include + SQLITE_CONFIG_ROWID_IN_VIEW here, on the grounds that + it's only for legacy support and no apps written with + this API require that. */ return capi.SQLITE_NOTFOUND; } }; diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index bd0eb884c9..cc1db6723a 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -545,6 +545,10 @@ const char * sqlite3__wasm_enum_json(void){ DefInt(SQLITE_CONFIG_SMALL_MALLOC); DefInt(SQLITE_CONFIG_SORTERREF_SIZE); DefInt(SQLITE_CONFIG_MEMDB_MAXSIZE); + /* maintenance note: we specifically do not include + SQLITE_CONFIG_ROWID_IN_VIEW here, on the grounds that + it's only for legacy support and no apps written with + this API require that. */ } _DefGroup; DefGroup(dataTypes) { diff --git a/manifest b/manifest index 3f732c3abd..de98d45464 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\stestrunner.tcl:\n(1)\sAdd\sthe\s"--config\sCONFIGS"\soption,\sto\sthat\sonly\sconfiguration\snamed\non\sthe\scomma-separated\slist\sCONFIGS\sare\srun.\n(2)\sAdd\sthe\s"--omit\sCONFIGS"\sto\somit\sconfiguration\son\sthe\sCONFIGS\slist\n(3)\sAdd\sthe\sAndroid\sconfiguration\sto\s"release" -D 2024-03-21T11:46:52.796 +C Add\scomments\s(only,\sno\scode)\sto\sthe\sJS\ssqlite3_config()\sbindings\sreminding\sus\swhy\sSQLITE_CONFIG_ROWID_IN_VIEW\sis\sspecifically\snot\sincluded.\sJNI\sdoes\snot\sneed\sthis\streatment\sbecause\sit\sexplicitly\ssupports\sonly\sa\svery\ssmall\ssubset\sof\sconfig\soptions. +D 2024-03-21T15:52:52.021 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -605,7 +605,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.js 587dc6db2d69329a5f4cb9635c377f516cf4a8e30f443f33380e5044889ec71b +F ext/wasm/api/sqlite3-api-glue.js 2d35660c52dcb4bb16d00c56553d34e7caa6ad30083938b515e6f9aa0b312fbb F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0 F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf @@ -615,7 +615,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aaedc1bb45489b8365bff7e955a83a8d42a F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 -F ext/wasm/api/sqlite3-wasm.c d33a16495ca871781e78812d3a18fed78b797468fffee657b8d7199b277ff359 +F ext/wasm/api/sqlite3-wasm.c afba6827a49151b564af5cf588a6bbd0401b16ef5cbe3269c66f676fee9ca92c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bd89edfe42a4d7122a6d6d405c5423cf00aabba1f76f6ea8e2dba9c628ddd91a F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a678e85402af08c1e387bf30ff2205f84dd7da749755da565d70f831c007a3d9 -R 2c6a53e503eb513e49b4f3899bff37cd -U drh -Z 89d0196ee33d74016c89e304cba255b3 +P 4ccb372967fab779b29be8f01c879a99ef247981466f81f55e18e3961fbd7d5a +R ea9e20b51710635b69a86f29c94e13a1 +U stephan +Z 968d86b7461df92ba4077d882e3cd299 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 09d6bad378..15f1e0f519 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ccb372967fab779b29be8f01c879a99ef247981466f81f55e18e3961fbd7d5a \ No newline at end of file +4fea396221e84f9532f9327226691621a23bd966a860329fc579141c69cf7f64 \ No newline at end of file From 2faaf3830efc93db406d6a58c837ad87f49e95db Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 21 Mar 2024 22:18:24 +0000 Subject: [PATCH 0272/1030] Test case for the assert() problem fixed by [9ba3cff9d48fe8fc]. FossilOrigin-Name: 865f0de7a17ce6059b8f0708002cff5f13b9dba3ebc41896ee0fdc21ae4f3740 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/default.test | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index de98d45464..3a62236ed9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\scomments\s(only,\sno\scode)\sto\sthe\sJS\ssqlite3_config()\sbindings\sreminding\sus\swhy\sSQLITE_CONFIG_ROWID_IN_VIEW\sis\sspecifically\snot\sincluded.\sJNI\sdoes\snot\sneed\sthis\streatment\sbecause\sit\sexplicitly\ssupports\sonly\sa\svery\ssmall\ssubset\sof\sconfig\soptions. -D 2024-03-21T15:52:52.021 +C Test\scase\sfor\sthe\sassert()\sproblem\sfixed\sby\s[9ba3cff9d48fe8fc]. +D 2024-03-21T22:18:24.397 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1057,7 +1057,7 @@ F test/dbpagefault.test 35f06cfb2ef100a9b19d25754e8141b9cba9b7daabd4c60fa5af93fc F test/dbstatus.test 4a4221a883025ffd39696b3d1b3910b928fb097d77e671351acb35f3aed42759 F test/dbstatus2.test f5fe0afed3fa45e57cfa70d1147606c20d2ba23feac78e9a172f2fe8ab5b78ef F test/decimal.test ef731887b43ee32ef86e1c8fddb61a40789f988332c029c601dcf2c319277e9e -F test/default.test 9687cfb16717e4b8238c191697c98be88c0b16e568dd5368cd9284154097ef50 +F test/default.test 830fad7180cdf0e6a06e93acc0403bf73762314a639363314db5674c631b6127 F test/delete.test 2686e1c98d552ef37d79ad55b17b93fe96fad9737786917ce3839767f734c48f F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4ccb372967fab779b29be8f01c879a99ef247981466f81f55e18e3961fbd7d5a -R ea9e20b51710635b69a86f29c94e13a1 -U stephan -Z 968d86b7461df92ba4077d882e3cd299 +P 4fea396221e84f9532f9327226691621a23bd966a860329fc579141c69cf7f64 +R 1d5390331fd847f868d4cf4de5871522 +U drh +Z 2f8691d3650feb9b039ca6336d443329 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 15f1e0f519..120c9883b8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4fea396221e84f9532f9327226691621a23bd966a860329fc579141c69cf7f64 \ No newline at end of file +865f0de7a17ce6059b8f0708002cff5f13b9dba3ebc41896ee0fdc21ae4f3740 \ No newline at end of file diff --git a/test/default.test b/test/default.test index 06a180c1de..de67f643b4 100644 --- a/test/default.test +++ b/test/default.test @@ -136,5 +136,9 @@ do_catchsql_test default-5.1 { CREATE TABLE t1 (a,b DEFAULT(random() NOTNULL IN (RAISE(IGNORE),2,3))); INSERT INTO t1(a) VALUES(1); } {1 {RAISE() may only be used within a trigger-program}} +do_catchsql_test default-5.2 { + CREATE TABLE Table0 (Col0 DEFAULT (RAISE(IGNORE) ) ) ; + INSERT INTO Table0 DEFAULT VALUES ; +} {1 {RAISE() may only be used within a trigger-program}} finish_test From 378bf82e2bc09734b8c5869f9b148efe37d29527 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 22 Mar 2024 10:32:14 +0000 Subject: [PATCH 0273/1030] Fix incorrect boundary assert()s on the new OP_IfSizeBetween opcode. FossilOrigin-Name: 8eda4797c573382cbb989a4ab4b1f19d8fd538dbc9818d86a9aa6189cfa90f37 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 3a62236ed9..2210416533 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\scase\sfor\sthe\sassert()\sproblem\sfixed\sby\s[9ba3cff9d48fe8fc]. -D 2024-03-21T22:18:24.397 +C Fix\sincorrect\sboundary\sassert()s\son\sthe\snew\sOP_IfSizeBetween\sopcode. +D 2024-03-22T10:32:14.835 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -820,7 +820,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c da8407be6055f5751bf85681542d130a320b4fd1f4d8719bf83a464743d9aae4 +F src/vdbe.c 651aa0f31027d5d0a133eb7b41d11c41dc3b88ecb760b770430da0e477ae3b6c F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4fea396221e84f9532f9327226691621a23bd966a860329fc579141c69cf7f64 -R 1d5390331fd847f868d4cf4de5871522 +P 865f0de7a17ce6059b8f0708002cff5f13b9dba3ebc41896ee0fdc21ae4f3740 +R 7ab31df9ffdd4f8066f809be43b05ba6 U drh -Z 2f8691d3650feb9b039ca6336d443329 +Z 00e0c5317c8b57851c68c1832373c781 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 120c9883b8..21b3877a0f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -865f0de7a17ce6059b8f0708002cff5f13b9dba3ebc41896ee0fdc21ae4f3740 \ No newline at end of file +8eda4797c573382cbb989a4ab4b1f19d8fd538dbc9818d86a9aa6189cfa90f37 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index faa12aaf8d..ed1d277b23 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6192,7 +6192,8 @@ case OP_Last: { /* jump0, ncycle */ ** ** Let N be the approximate number of rows in the table or index ** with cursor P1 and let X be 10*log2(N) if N is positive or -1 -** if N is zero. Thus X will be within the range of -1 to 640, inclusive +** if N is zero. +** ** Jump to P2 if X is in between P3 and P4, inclusive. */ case OP_IfSizeBetween: { /* jump */ @@ -6203,8 +6204,8 @@ case OP_IfSizeBetween: { /* jump */ assert( pOp->p1>=0 && pOp->p1nCursor ); assert( pOp->p4type==P4_INT32 ); - assert( pOp->p3>=-1 && pOp->p3<=640 ); - assert( pOp->p4.i>=-1 && pOp->p4.i<=640 ); + assert( pOp->p3>=-1 && pOp->p3<=640*2 ); + assert( pOp->p4.i>=-1 && pOp->p4.i<=640*2 ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); pCrsr = pC->uc.pCursor; From d9eee787bd1ab041fef140dd29a5a8316647d3bc Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 23 Mar 2024 15:17:38 +0000 Subject: [PATCH 0274/1030] Fix an adverse interaction between CREATE TABLE AS and the new [/info/a120c9235f125e05|VALUES-as-coroutine] optimization. dbsqlfuzz c2c5e7e08b7e489d270a26d895077a03f678c33b FossilOrigin-Name: 84b6fdea0bf07c73df0ca8ef110db066164a5f34606e6c069a060476e04ef44e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 12 ++++++------ test/values.test | 12 ++++++++++++ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 2210416533..2662568857 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sincorrect\sboundary\sassert()s\son\sthe\snew\sOP_IfSizeBetween\sopcode. -D 2024-03-22T10:32:14.835 +C Fix\san\sadverse\sinteraction\sbetween\sCREATE\sTABLE\sAS\sand\sthe\snew\n[/info/a120c9235f125e05|VALUES-as-coroutine]\soptimization.\ndbsqlfuzz\sc2c5e7e08b7e489d270a26d895077a03f678c33b +D 2024-03-23T15:17:38.317 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -692,7 +692,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 285b493d843e7ba8ef78b6ae7d31238e904901dbc0c484f7904de4cf18fd8802 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c fff536730a6d83120ae38d960f812b548394e8af6907249effb1764d69178106 +F src/build.c 02f5b25ca854c83b5015cb02b8c9ab236c60b1795528675aee8a5070e58da52a F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 @@ -1924,7 +1924,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test e7c156f92d32ed645908fbad0a1144f0f31650376cdcb212fde701978c89d3b1 +F test/values.test ee77c1cb540c47868848f85c39f92bb11d787657ade32f91eedf2988727769cd F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 865f0de7a17ce6059b8f0708002cff5f13b9dba3ebc41896ee0fdc21ae4f3740 -R 7ab31df9ffdd4f8066f809be43b05ba6 +P 8eda4797c573382cbb989a4ab4b1f19d8fd538dbc9818d86a9aa6189cfa90f37 +R da9288a1e61bb5eb45cf509b5ee97ccd U drh -Z 00e0c5317c8b57851c68c1832373c781 +Z 02c1f27357ab211e7de37d670fb693ee # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 21b3877a0f..cb38d5c115 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8eda4797c573382cbb989a4ab4b1f19d8fd538dbc9818d86a9aa6189cfa90f37 \ No newline at end of file +84b6fdea0bf07c73df0ca8ef110db066164a5f34606e6c069a060476e04ef44e \ No newline at end of file diff --git a/src/build.c b/src/build.c index 3ea35b331c..8279c0a89c 100644 --- a/src/build.c +++ b/src/build.c @@ -2828,20 +2828,20 @@ void sqlite3EndTable( int regRowid; /* Rowid of the next row to insert */ int addrInsLoop; /* Top of the loop for inserting rows */ Table *pSelTab; /* A table that describes the SELECT results */ + int iCsr; /* Write cursor on the new table */ if( IN_SPECIAL_PARSE ){ pParse->rc = SQLITE_ERROR; pParse->nErr++; return; } + iCsr = pParse->nTab++; regYield = ++pParse->nMem; regRec = ++pParse->nMem; regRowid = ++pParse->nMem; - assert(pParse->nTab==1); sqlite3MayAbort(pParse); - sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb); + sqlite3VdbeAddOp3(v, OP_OpenWrite, iCsr, pParse->regRoot, iDb); sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG); - pParse->nTab = 2; addrTop = sqlite3VdbeCurrentAddr(v) + 1; sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop); if( pParse->nErr ) return; @@ -2862,11 +2862,11 @@ void sqlite3EndTable( VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec); sqlite3TableAffinity(v, p, 0); - sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid); - sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid); + sqlite3VdbeAddOp2(v, OP_NewRowid, iCsr, regRowid); + sqlite3VdbeAddOp3(v, OP_Insert, iCsr, regRec, regRowid); sqlite3VdbeGoto(v, addrInsLoop); sqlite3VdbeJumpHere(v, addrInsLoop); - sqlite3VdbeAddOp1(v, OP_Close, 1); + sqlite3VdbeAddOp1(v, OP_Close, iCsr); } /* Compute the complete text of the CREATE statement */ diff --git a/test/values.test b/test/values.test index 43f8e0e6fe..26f2812237 100644 --- a/test/values.test +++ b/test/values.test @@ -580,4 +580,16 @@ do_eqp_test 16.7 { `--SCAN 4-ROW VALUES CLAUSE } +#-------------------------------------------------------------------------- +# 2024-03-23 dbsqlfuzz crash-c2c5e7e08b7e489d270a26d895077a03f678c33b +# +do_execsql_test 17.1 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1 AS SELECT * FROM (VALUES(1,2), (3,4 IN (1,2,3))); +} + +do_execsql_test 17.2 { + SELECT * FROM t1 +} {1 2 3 0} + finish_test From a631eb378d94eb10ade6a0c2d18b2e411c1da806 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 24 Mar 2024 16:33:31 +0000 Subject: [PATCH 0275/1030] Do not automatically assume that ROWID is NOT NULL when compiled with SQLITE_ALLOW_ROWID_IN_VIEW. dbsqlfuzz 31b38eeb63a4e1562de665078f52b7b47a7543cf FossilOrigin-Name: 80c4223098c1827ff3a564f1f9a4203164a943e9a83eef99df68378fa3c4764b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 9 ++++++--- src/select.c | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 2662568857..d217a1389c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sadverse\sinteraction\sbetween\sCREATE\sTABLE\sAS\sand\sthe\snew\n[/info/a120c9235f125e05|VALUES-as-coroutine]\soptimization.\ndbsqlfuzz\sc2c5e7e08b7e489d270a26d895077a03f678c33b -D 2024-03-23T15:17:38.317 +C Do\snot\sautomatically\sassume\sthat\sROWID\sis\sNOT\sNULL\swhen\scompiled\swith\nSQLITE_ALLOW_ROWID_IN_VIEW.\ndbsqlfuzz\s31b38eeb63a4e1562de665078f52b7b47a7543cf +D 2024-03-24T16:33:31.285 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 94f48513fbec07725501298dee3f16d95b1762bb4a12296455f544b2d7f2d74a +F src/expr.c ff1bb1bdbcdc20505cfa900f332e18239ab3cf20d2b0d220a960b5b3513b7cb4 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -750,7 +750,7 @@ F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c ced6678ead94c08d58cdb65cdda00a4871a3048e7834146f2a58ce71171808f8 +F src/select.c 15a221347789e393b39e7d2d2bd102167979c95a1ce0675bb870b86a24ca6cf4 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 41c5febd217b1e475aae022895c60f57fbe39ff6136450110662cfad67002d43 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8eda4797c573382cbb989a4ab4b1f19d8fd538dbc9818d86a9aa6189cfa90f37 -R da9288a1e61bb5eb45cf509b5ee97ccd +P 84b6fdea0bf07c73df0ca8ef110db066164a5f34606e6c069a060476e04ef44e +R 1acc2c5116f8a8c5695dfb6ee536b3ee U drh -Z 02c1f27357ab211e7de37d670fb693ee +Z 664dfa62372b996e1fbf277d588e4a7b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cb38d5c115..001db1b9c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -84b6fdea0bf07c73df0ca8ef110db066164a5f34606e6c069a060476e04ef44e \ No newline at end of file +80c4223098c1827ff3a564f1f9a4203164a943e9a83eef99df68378fa3c4764b \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 7e3f38279d..d71353f174 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2801,9 +2801,12 @@ int sqlite3ExprCanBeNull(const Expr *p){ return 0; case TK_COLUMN: assert( ExprUseYTab(p) ); - return ExprHasProperty(p, EP_CanBeNull) || - NEVER(p->y.pTab==0) || /* Reference to column of index on expr */ - (p->iColumn>=0 + return ExprHasProperty(p, EP_CanBeNull) + || NEVER(p->y.pTab==0) /* Reference to column of index on expr */ +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + || (p->iColumn==XN_ROWID && IsView(p->y.pTab)) +#endif + || (p->iColumn>=0 && p->y.pTab->aCol!=0 /* Possible due to prior error */ && ALWAYS(p->iColumny.pTab->nCol) && p->y.pTab->aCol[p->iColumn].notNull==0); diff --git a/src/select.c b/src/select.c index b539288e9d..b200518518 100644 --- a/src/select.c +++ b/src/select.c @@ -5134,6 +5134,10 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){ ** ** (11) The subquery is not a VALUES clause ** +** (12) The WHERE clause is not "rowid ISNULL" or the equivalent. This +** case only comes up if SQLite is compiled using +** SQLITE_ALLOW_ROWID_IN_VIEW. +** ** Return 0 if no changes are made and non-zero if one or more WHERE clause ** terms are duplicated into the subquery. */ @@ -5244,6 +5248,18 @@ static int pushDownWhereTerms( } #endif +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + if( ViewCanHaveRowid && (pWhere->op==TK_ISNULL || pWhere->op==TK_NOTNULL) ){ + Expr *pLeft = pWhere->pLeft; + if( ALWAYS(pLeft) + && pLeft->op==TK_COLUMN + && pLeft->iColumn < 0 + ){ + return 0; /* Restriction (12) */ + } + } +#endif + if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrcList, iSrc) ){ nChng++; pSubq->selFlags |= SF_PushDown; @@ -5871,6 +5887,7 @@ int sqlite3ExpandSubquery(Parse *pParse, SrcItem *pFrom){ while( pSel->pPrior ){ pSel = pSel->pPrior; } sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol); pTab->iPKey = -1; + pTab->eTabType = TABTYP_VIEW; pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); #ifndef SQLITE_ALLOW_ROWID_IN_VIEW /* The usual case - do not allow ROWID on a subquery */ From 4a402b80c59d4d3f929544e8eea54e8e5965700a Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 24 Mar 2024 20:26:59 +0000 Subject: [PATCH 0276/1030] Improved "wheretrace" debugging output for calls to xBestIndex. No changes to release code. FossilOrigin-Name: 33966bb06ce9a8e90734de59a8d43c523f60870d20be64789638da4c84a8b81b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 20 ++++++++++++++------ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index d217a1389c..eea486cab1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sautomatically\sassume\sthat\sROWID\sis\sNOT\sNULL\swhen\scompiled\swith\nSQLITE_ALLOW_ROWID_IN_VIEW.\ndbsqlfuzz\s31b38eeb63a4e1562de665078f52b7b47a7543cf -D 2024-03-24T16:33:31.285 +C Improved\s"wheretrace"\sdebugging\soutput\sfor\scalls\sto\sxBestIndex.\s\sNo\schanges\nto\srelease\scode. +D 2024-03-24T20:26:59.325 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 5e9a5d642cceb666152c59091a3dbb645a9dda209b4e65a2f9215ee9298d26cf +F src/where.c 2e01199202dd117a27f7597e1f554a5cd55e7465e2f39ff9a78adc9cba98b971 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 84b6fdea0bf07c73df0ca8ef110db066164a5f34606e6c069a060476e04ef44e -R 1acc2c5116f8a8c5695dfb6ee536b3ee +P 80c4223098c1827ff3a564f1f9a4203164a943e9a83eef99df68378fa3c4764b +R 85708579a006a76a9ac19f57eff9986d U drh -Z 664dfa62372b996e1fbf277d588e4a7b +Z 2f119c894f4b4cc81a59e37d61239a6c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 001db1b9c8..c6fd4f1e53 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -80c4223098c1827ff3a564f1f9a4203164a943e9a83eef99df68378fa3c4764b \ No newline at end of file +33966bb06ce9a8e90734de59a8d43c523f60870d20be64789638da4c84a8b81b \ No newline at end of file diff --git a/src/where.c b/src/where.c index 2463e823c8..3fbb768af5 100644 --- a/src/where.c +++ b/src/where.c @@ -713,9 +713,13 @@ static void translateColumnToCopy( ** are no-ops. */ #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(WHERETRACE_ENABLED) -static void whereTraceIndexInfoInputs(sqlite3_index_info *p){ +static void whereTraceIndexInfoInputs( + sqlite3_index_info *p, /* The IndexInfo object */ + Table *pTab /* The TABLE that is the virtual table */ +){ int i; if( (sqlite3WhereTrace & 0x10)==0 ) return; + sqlite3DebugPrintf("sqlite3_index_info inputs for %s:\n", pTab->zName); for(i=0; inConstraint; i++){ sqlite3DebugPrintf( " constraint[%d]: col=%d termid=%d op=%d usabled=%d collseq=%s\n", @@ -733,9 +737,13 @@ static void whereTraceIndexInfoInputs(sqlite3_index_info *p){ p->aOrderBy[i].desc); } } -static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){ +static void whereTraceIndexInfoOutputs( + sqlite3_index_info *p, /* The IndexInfo object */ + Table *pTab /* The TABLE that is the virtual table */ +){ int i; if( (sqlite3WhereTrace & 0x10)==0 ) return; + sqlite3DebugPrintf("sqlite3_index_info outputs for %s:\n", pTab->zName); for(i=0; inConstraint; i++){ sqlite3DebugPrintf(" usage[%d]: argvIdx=%d omit=%d\n", i, @@ -749,8 +757,8 @@ static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){ sqlite3DebugPrintf(" estimatedRows=%lld\n", p->estimatedRows); } #else -#define whereTraceIndexInfoInputs(A) -#define whereTraceIndexInfoOutputs(A) +#define whereTraceIndexInfoInputs(A,B) +#define whereTraceIndexInfoOutputs(A,B) #endif /* @@ -1493,11 +1501,11 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){ sqlite3_vtab *pVtab = sqlite3GetVTable(pParse->db, pTab)->pVtab; int rc; - whereTraceIndexInfoInputs(p); + whereTraceIndexInfoInputs(p, pTab); pParse->db->nSchemaLock++; rc = pVtab->pModule->xBestIndex(pVtab, p); pParse->db->nSchemaLock--; - whereTraceIndexInfoOutputs(p); + whereTraceIndexInfoOutputs(p, pTab); if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){ if( rc==SQLITE_NOMEM ){ From cf84ae0189ced4937662feebfcc855d64a5232a1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 24 Mar 2024 21:10:45 +0000 Subject: [PATCH 0277/1030] Fix the xBestIndex method of the pragma virtual table so that it correctly gives a higher cost to plans where the schema hidden parameter is unconstrained. Fix for the problem reported by [forum:/forumpost/85b6a8b6705fb77a|forum post 85b6a8b6705fb77a]. FossilOrigin-Name: bc516ff5202ee6e9834266bf755fe26e30ac557dcc7975ca7a06dfe33874fcd2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pragma.c | 6 +++++- test/pragma4.test | 12 ++++++++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index eea486cab1..d0fa3fb808 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\s"wheretrace"\sdebugging\soutput\sfor\scalls\sto\sxBestIndex.\s\sNo\schanges\nto\srelease\scode. -D 2024-03-24T20:26:59.325 +C Fix\sthe\sxBestIndex\smethod\sof\sthe\spragma\svirtual\stable\sso\sthat\sit\scorrectly\ngives\sa\shigher\scost\sto\splans\swhere\sthe\sschema\shidden\sparameter\sis\nunconstrained.\s\sFix\sfor\sthe\sproblem\sreported\sby\n[forum:/forumpost/85b6a8b6705fb77a|forum\spost\s85b6a8b6705fb77a]. +D 2024-03-24T21:10:45.270 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -743,7 +743,7 @@ F src/parse.y 5bcef16094213efcc365a9d4dc4e3131f09251dc8838dce4a9e5f9764bff5b82 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c e8221d6310c9923c80f6fa6d09b7ea7c5263a671f53db8d0894df23efcdb617b +F src/pragma.c 4629926f936cdc586873d5ff24acb1af12a1db0172988a0dc2b32e46b798a640 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 @@ -1501,7 +1501,7 @@ F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b76 F test/pragma.test 8bb6d3992c1c31ff6d5553d1e0693d642f7e19015648c6ae7034cb497d26bbd4 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 -F test/pragma4.test 9559cf5173864bf47c0431873d158fbeb72f920a59905b1f46069d8543eccdab +F test/pragma4.test 1951dc5a6d87c4ccd8eab35c65f18380c80fac4a0897e828cf518e3cc8a4c292 F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d9102 F test/pragma6.test c5ec577ba087954b4dfa619a3cbe97b155b60a0af487527abe89b10fc17e6512 F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 80c4223098c1827ff3a564f1f9a4203164a943e9a83eef99df68378fa3c4764b -R 85708579a006a76a9ac19f57eff9986d +P 33966bb06ce9a8e90734de59a8d43c523f60870d20be64789638da4c84a8b81b +R 97fc378a830906e74d1623fece2781ad U drh -Z 2f119c894f4b4cc81a59e37d61239a6c +Z 0dbd1f88ff00b9d3018bd54394a97ce0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c6fd4f1e53..cc6bf08fca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -33966bb06ce9a8e90734de59a8d43c523f60870d20be64789638da4c84a8b81b \ No newline at end of file +bc516ff5202ee6e9834266bf755fe26e30ac557dcc7975ca7a06dfe33874fcd2 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index d3b0198236..d14428f75e 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2885,7 +2885,11 @@ static int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ j = seen[0]-1; pIdxInfo->aConstraintUsage[j].argvIndex = 1; pIdxInfo->aConstraintUsage[j].omit = 1; - if( seen[1]==0 ) return SQLITE_OK; + if( seen[1]==0 ){ + pIdxInfo->estimatedCost = (double)1000; + pIdxInfo->estimatedRows = 1000; + return SQLITE_OK; + } pIdxInfo->estimatedCost = (double)20; pIdxInfo->estimatedRows = 20; j = seen[1]-1; diff --git a/test/pragma4.test b/test/pragma4.test index 9d5a363d65..9b2fa9ba2a 100644 --- a/test/pragma4.test +++ b/test/pragma4.test @@ -264,5 +264,17 @@ do_execsql_test 5.0 { 0 a {} 0 'abc' 0 1 b {} 0 -1 0 2 c {} 0 +4.0 0 } +# 2024-03-24 https://sqlite.org/forum/forumpost/85b6a8b6705fb77a +# +reset_db +do_execsql_test 6.0 { + CREATE TABLE t1(a INT PRIMARY KEY, b INT); + CREATE TABLE t2(c INT PRIMARY KEY, d INT REFERENCES t1); + SELECT t.name, f."table", f."from", i.name, i.pk + FROM pragma_table_list() AS t + JOIN pragma_foreign_key_list(t.name, t.schema) AS f + JOIN pragma_table_info(f."table", t.schema) AS i + WHERE i.pk; +} {t2 t1 d a 1} finish_test From d2b3b72a2b2524cb8a9b017c08fd255d8fe842d7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 00:38:55 +0000 Subject: [PATCH 0278/1030] Improvements to the vtablog.c extension, for better logging of virtual table interactions. FossilOrigin-Name: e253bb36a5f4f601c9b08858b55a9ce198239ace8efa8dab7c0ec019028967c1 --- ext/misc/vtablog.c | 147 ++++++++++++++++++++++++++++++++++----------- manifest | 12 ++-- manifest.uuid | 2 +- 3 files changed, 119 insertions(+), 42 deletions(-) diff --git a/ext/misc/vtablog.c b/ext/misc/vtablog.c index e414e7afa7..301e82fcc1 100644 --- a/ext/misc/vtablog.c +++ b/ext/misc/vtablog.c @@ -38,8 +38,9 @@ SQLITE_EXTENSION_INIT1 typedef struct vtablog_vtab vtablog_vtab; struct vtablog_vtab { sqlite3_vtab base; /* Base class - must be first */ + char *zDb; /* Schema name. argv[1] of xConnect/xCreate */ + char *zName; /* Table name. argv[2] of xConnect/xCreate */ int nRow; /* Number of rows in the table */ - int iInst; /* Instance number for this vtablog table */ int nCursor; /* Number of cursors created */ }; @@ -167,15 +168,14 @@ static int vtablogConnectCreate( char **pzErr, int isCreate ){ - static int nInst = 0; vtablog_vtab *pNew; int i; int rc; - int iInst = ++nInst; char *zSchema = 0; char *zNRow = 0; - printf("vtablog%s(tab=%d):\n", isCreate ? "Create" : "Connect", iInst); + printf("%s.%s.%s():\n", argv[1], argv[2], + isCreate ? "xCreate" : "xConnect"); printf(" argc=%d\n", argc); for(i=0; inRow = 10; if( zNRow ) pNew->nRow = atoi(zNRow); - pNew->iInst = iInst; + pNew->zDb = sqlite3_mprintf("%s", argv[1]); + pNew->zName = sqlite3_mprintf("%s", argv[2]); } return rc; } @@ -237,7 +236,9 @@ static int vtablogConnect( */ static int vtablogDisconnect(sqlite3_vtab *pVtab){ vtablog_vtab *pTab = (vtablog_vtab*)pVtab; - printf("vtablogDisconnect(%d)\n", pTab->iInst); + printf("%s.%s.xDisconnect()\n", pTab->zDb, pTab->zName); + sqlite3_free(pTab->zDb); + sqlite3_free(pTab->zName); sqlite3_free(pVtab); return SQLITE_OK; } @@ -247,7 +248,8 @@ static int vtablogDisconnect(sqlite3_vtab *pVtab){ */ static int vtablogDestroy(sqlite3_vtab *pVtab){ vtablog_vtab *pTab = (vtablog_vtab*)pVtab; - printf("vtablogDestroy(%d)\n", pTab->iInst); + printf("%s.%s.xDestroy()\n", pTab->zDb, pTab->zName); + sqlite3_free(pTab->zName); sqlite3_free(pVtab); return SQLITE_OK; } @@ -258,7 +260,8 @@ static int vtablogDestroy(sqlite3_vtab *pVtab){ static int vtablogOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ vtablog_vtab *pTab = (vtablog_vtab*)p; vtablog_cursor *pCur; - printf("vtablogOpen(tab=%d, cursor=%d)\n", pTab->iInst, ++pTab->nCursor); + printf("%s.%s.xOpen(cursor=%d)\n", pTab->zDb, pTab->zName, + ++pTab->nCursor); pCur = sqlite3_malloc( sizeof(*pCur) ); if( pCur==0 ) return SQLITE_NOMEM; memset(pCur, 0, sizeof(*pCur)); @@ -273,7 +276,7 @@ static int vtablogOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ static int vtablogClose(sqlite3_vtab_cursor *cur){ vtablog_cursor *pCur = (vtablog_cursor*)cur; vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab; - printf("vtablogClose(tab=%d, cursor=%d)\n", pTab->iInst, pCur->iCursor); + printf("%s.%s.xClose(cursor=%d)\n", pTab->zDb, pTab->zName, pCur->iCursor); sqlite3_free(cur); return SQLITE_OK; } @@ -285,8 +288,9 @@ static int vtablogClose(sqlite3_vtab_cursor *cur){ static int vtablogNext(sqlite3_vtab_cursor *cur){ vtablog_cursor *pCur = (vtablog_cursor*)cur; vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab; - printf("vtablogNext(tab=%d, cursor=%d) rowid %d -> %d\n", - pTab->iInst, pCur->iCursor, (int)pCur->iRowid, (int)pCur->iRowid+1); + printf("%s.%s.xNext(cursor=%d) rowid %d -> %d\n", + pTab->zDb, pTab->zName, pCur->iCursor, + (int)pCur->iRowid, (int)pCur->iRowid+1); pCur->iRowid++; return SQLITE_OK; } @@ -310,8 +314,8 @@ static int vtablogColumn( }else{ sqlite3_snprintf(sizeof(zVal),zVal,"{%d}%d", i, pCur->iRowid); } - printf("vtablogColumn(tab=%d, cursor=%d, i=%d): [%s]\n", - pTab->iInst, pCur->iCursor, i, zVal); + printf("%s.%s.xColumn(cursor=%d, i=%d): [%s]\n", + pTab->zDb, pTab->zName, pCur->iCursor, i, zVal); sqlite3_result_text(ctx, zVal, -1, SQLITE_TRANSIENT); return SQLITE_OK; } @@ -323,8 +327,8 @@ static int vtablogColumn( static int vtablogRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ vtablog_cursor *pCur = (vtablog_cursor*)cur; vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab; - printf("vtablogRowid(tab=%d, cursor=%d): %d\n", - pTab->iInst, pCur->iCursor, (int)pCur->iRowid); + printf("%s.%s.xRowid(cursor=%d): %d\n", + pTab->zDb, pTab->zName, pCur->iCursor, (int)pCur->iRowid); *pRowid = pCur->iRowid; return SQLITE_OK; } @@ -337,8 +341,8 @@ static int vtablogEof(sqlite3_vtab_cursor *cur){ vtablog_cursor *pCur = (vtablog_cursor*)cur; vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab; int rc = pCur->iRowid >= pTab->nRow; - printf("vtablogEof(tab=%d, cursor=%d): %d\n", - pTab->iInst, pCur->iCursor, rc); + printf("%s.%s.xEof(cursor=%d): %d\n", + pTab->zDb, pTab->zName, pCur->iCursor, rc); return rc; } @@ -417,7 +421,7 @@ static int vtablogFilter( ){ vtablog_cursor *pCur = (vtablog_cursor *)cur; vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab; - printf("vtablogFilter(tab=%d, cursor=%d):\n", pTab->iInst, pCur->iCursor); + printf("%s.%s.xFilter(cursor=%d):\n", pTab->zDb, pTab->zName, pCur->iCursor); pCur->iRowid = 0; return SQLITE_OK; } @@ -433,7 +437,7 @@ static int vtablogBestIndex( sqlite3_index_info *pIdxInfo ){ vtablog_vtab *pTab = (vtablog_vtab*)tab; - printf("vtablogBestIndex(tab=%d):\n", pTab->iInst); + printf("%s.%s.xBestIndex():\n", pTab->zDb, pTab->zName); pIdxInfo->estimatedCost = (double)500; pIdxInfo->estimatedRows = 500; return SQLITE_OK; @@ -454,7 +458,7 @@ static int vtablogUpdate( ){ vtablog_vtab *pTab = (vtablog_vtab*)tab; int i; - printf("vtablogUpdate(tab=%d):\n", pTab->iInst); + printf("%s.%s.xUpdate():\n", pTab->zDb, pTab->zName); printf(" argc=%d\n", argc); for(i=0; izDb, pTab->zName); + return SQLITE_OK; +} +static int vtablogSync(sqlite3_vtab *tab){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xSync()\n", pTab->zDb, pTab->zName); + return SQLITE_OK; +} +static int vtablogCommit(sqlite3_vtab *tab){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xCommit()\n", pTab->zDb, pTab->zName); + return SQLITE_OK; +} +static int vtablogRollback(sqlite3_vtab *tab){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xRollback()\n", pTab->zDb, pTab->zName); + return SQLITE_OK; +} +static int vtablogSavepoint(sqlite3_vtab *tab, int N){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xSavepoint(%d)\n", pTab->zDb, pTab->zName, N); + return SQLITE_OK; +} +static int vtablogRelease(sqlite3_vtab *tab, int N){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xRelease(%d)\n", pTab->zDb, pTab->zName, N); + return SQLITE_OK; +} +static int vtablogRollbackTo(sqlite3_vtab *tab, int N){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xRollbackTo(%d)\n", pTab->zDb, pTab->zName, N); + return SQLITE_OK; +} + +static int vtablogFindMethod( + sqlite3_vtab *tab, + int nArg, + const char *zName, + void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), + void **ppArg +){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xFindMethod(nArg=%d, zName=%s)\n", + pTab->zDb, pTab->zName, nArg, zName); + return SQLITE_OK; +} +static int vtablogRename(sqlite3_vtab *tab, const char *zNew){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xRename('%s')\n", pTab->zDb, pTab->zName, zNew); + sqlite3_free(pTab->zName); + pTab->zName = sqlite3_mprintf("%s", zNew); + return SQLITE_OK; +} + +static int vtablogShadowName(const char *zName){ + printf("vtablog.xShadowName('%s')\n", zName); + return 0; +} + +static int vtablogIntegrity( + sqlite3_vtab *tab, + const char *zSchema, + const char *zTabName, + int mFlags, + char **pzErr +){ + vtablog_vtab *pTab = (vtablog_vtab*)tab; + printf("%s.%s.xIntegrity(mFlags=0x%x)\n", pTab->zDb, pTab->zName, mFlags); + return 0; +} + /* ** This following structure defines all the methods for the ** vtablog virtual table. */ static sqlite3_module vtablogModule = { - 0, /* iVersion */ + 4, /* iVersion */ vtablogCreate, /* xCreate */ vtablogConnect, /* xConnect */ vtablogBestIndex, /* xBestIndex */ @@ -483,17 +560,17 @@ static sqlite3_module vtablogModule = { vtablogColumn, /* xColumn - read data */ vtablogRowid, /* xRowid - read data */ vtablogUpdate, /* xUpdate */ - 0, /* xBegin */ - 0, /* xSync */ - 0, /* xCommit */ - 0, /* xRollback */ - 0, /* xFindMethod */ - 0, /* xRename */ - 0, /* xSavepoint */ - 0, /* xRelease */ - 0, /* xRollbackTo */ - 0, /* xShadowName */ - 0 /* xIntegrity */ + vtablogBegin, /* xBegin */ + vtablogSync, /* xSync */ + vtablogCommit, /* xCommit */ + vtablogRollback, /* xRollback */ + vtablogFindMethod, /* xFindMethod */ + vtablogRename, /* xRename */ + vtablogSavepoint, /* xSavepoint */ + vtablogRelease, /* xRelease */ + vtablogRollbackTo, /* xRollbackTo */ + vtablogShadowName, /* xShadowName */ + vtablogIntegrity /* xIntegrity */ }; #ifdef _WIN32 diff --git a/manifest b/manifest index d0fa3fb808..cfb54dfdeb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sxBestIndex\smethod\sof\sthe\spragma\svirtual\stable\sso\sthat\sit\scorrectly\ngives\sa\shigher\scost\sto\splans\swhere\sthe\sschema\shidden\sparameter\sis\nunconstrained.\s\sFix\sfor\sthe\sproblem\sreported\sby\n[forum:/forumpost/85b6a8b6705fb77a|forum\spost\s85b6a8b6705fb77a]. -D 2024-03-24T21:10:45.270 +C Improvements\sto\sthe\svtablog.c\sextension,\sfor\sbetter\slogging\sof\svirtual\ntable\sinteractions. +D 2024-03-25T00:38:55.563 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -426,7 +426,7 @@ F ext/misc/urifuncs.c f71360d14fa9e7626b563f1f781c6148109462741c5235ac63ae0f8917 F ext/misc/uuid.c 5bb2264c1b64d163efa46509544fd7500cb8769cb7c16dd52052da8d961505cf F ext/misc/vfslog.c 3932ab932eeb2601dbc4447cb14d445aaa9fbe43b863ef5f014401c3420afd20 F ext/misc/vfsstat.c a85df08654743922a19410d7b1e3111de41bb7cd07d20dd16eda4e2b808d269d -F ext/misc/vtablog.c f2c9d41afe00b51b2c8307b79f508eb0c2dcd57bae074807944e73376fcf15b7 +F ext/misc/vtablog.c 10b3b8abb57c9e6ad5b9fd7789a15359931f4ae7eea1ce4c42692b5ab458b58d F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 0fa0c082676b7868bf2fa918e911133f2b349bcdceabd1198bba5f65b4fc0668 F ext/misc/zipfile.c 64cb3d98b6316586e6056d182051aa9d28fdedfbf4b908e6b7a7d70209b1db11 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 33966bb06ce9a8e90734de59a8d43c523f60870d20be64789638da4c84a8b81b -R 97fc378a830906e74d1623fece2781ad +P bc516ff5202ee6e9834266bf755fe26e30ac557dcc7975ca7a06dfe33874fcd2 +R 73586b393bce9c1bed9e065f652632d2 U drh -Z 0dbd1f88ff00b9d3018bd54394a97ce0 +Z 2f68833aa47d50c9278d5d5a2c9b24b3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cc6bf08fca..fe309677df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc516ff5202ee6e9834266bf755fe26e30ac557dcc7975ca7a06dfe33874fcd2 \ No newline at end of file +e253bb36a5f4f601c9b08858b55a9ce198239ace8efa8dab7c0ec019028967c1 \ No newline at end of file From 55051d661c05ed2e5879fd082184687ecf71c8d8 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 25 Mar 2024 10:28:10 +0000 Subject: [PATCH 0279/1030] Flag sqlite3_trace() and sqlite3_profile() as deprecated so that the doc generator for funclist.html sees them as such, and add 'Deprecated' to their page's title for consistency with other deprecated APIs. Comment changes only. Addresses [forum:0901025836|forum post 0901025836]. FossilOrigin-Name: 87c54f93f5711739741ed0ff3c1a6fe24ffc8a025b43523bf78c1f6be8c1b4cd --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index cfb54dfdeb..d0cd7ceb0b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\svtablog.c\sextension,\sfor\sbetter\slogging\sof\svirtual\ntable\sinteractions. -D 2024-03-25T00:38:55.563 +C Flag\ssqlite3_trace()\sand\ssqlite3_profile()\sas\sdeprecated\sso\sthat\sthe\sdoc\sgenerator\sfor\sfunclist.html\ssees\sthem\sas\ssuch,\sand\sadd\s'Deprecated'\sto\stheir\spage's\stitle\sfor\sconsistency\swith\sother\sdeprecated\sAPIs.\sComment\schanges\sonly.\sAddresses\s[forum:0901025836|forum\spost\s0901025836]. +D 2024-03-25T10:28:10.796 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -752,7 +752,7 @@ F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 15a221347789e393b39e7d2d2bd102167979c95a1ce0675bb870b86a24ca6cf4 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 -F src/sqlite.h.in 41c5febd217b1e475aae022895c60f57fbe39ff6136450110662cfad67002d43 +F src/sqlite.h.in e9af5761aab316d52e5a5ac11b42d6a25eaaa49352e982c14f1080aab684b5c4 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h f8928f0397d797046396dd9d360a6af8ce6dcb48bd72ea290165b07c8c518744 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bc516ff5202ee6e9834266bf755fe26e30ac557dcc7975ca7a06dfe33874fcd2 -R 73586b393bce9c1bed9e065f652632d2 -U drh -Z 2f68833aa47d50c9278d5d5a2c9b24b3 +P e253bb36a5f4f601c9b08858b55a9ce198239ace8efa8dab7c0ec019028967c1 +R 9b310c2f5986c86858424e569b4e6f77 +U stephan +Z 6c78d97a358d85a52548c24a097975e6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fe309677df..906e916a84 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e253bb36a5f4f601c9b08858b55a9ce198239ace8efa8dab7c0ec019028967c1 \ No newline at end of file +87c54f93f5711739741ed0ff3c1a6fe24ffc8a025b43523bf78c1f6be8c1b4cd \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 06fcd3f89e..6841cf38f7 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3305,8 +3305,8 @@ int sqlite3_set_authorizer( #define SQLITE_RECURSIVE 33 /* NULL NULL */ /* -** CAPI3REF: Tracing And Profiling Functions -** METHOD: sqlite3 +** CAPI3REF: Deprecated Tracing And Profiling Functions +** DEPRECATED ** ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface ** instead of the routines described here. From 4397d2837889a5b9c8d6ac26b19281acba45ff61 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 10:55:08 +0000 Subject: [PATCH 0280/1030] Improvements to the vtablog.c extension: Eliminate memory leaks. More diagnostic output for xBestIndex. FossilOrigin-Name: 92e9a71bc4daa261d7c9a81fb66f7d7c0f0a74eb9e0c9dec8b4651acc5217bff --- ext/misc/vtablog.c | 51 +++++++++++++++++++++++++++++++++++++++------- manifest | 14 ++++++------- manifest.uuid | 2 +- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/ext/misc/vtablog.c b/ext/misc/vtablog.c index 301e82fcc1..2cc29c285f 100644 --- a/ext/misc/vtablog.c +++ b/ext/misc/vtablog.c @@ -189,15 +189,18 @@ static int vtablogConnectCreate( for(i=3; inRow = 10; if( zNRow ) pNew->nRow = atoi(zNRow); + printf(" nrow = %d\n", pNew->nRow); pNew->zDb = sqlite3_mprintf("%s", argv[1]); pNew->zName = sqlite3_mprintf("%s", argv[2]); } + +vtablog_end_connect: + sqlite3_free(zSchema); + sqlite3_free(zNRow); return rc; } static int vtablogCreate( @@ -249,6 +257,7 @@ static int vtablogDisconnect(sqlite3_vtab *pVtab){ static int vtablogDestroy(sqlite3_vtab *pVtab){ vtablog_vtab *pTab = (vtablog_vtab*)pVtab; printf("%s.%s.xDestroy()\n", pTab->zDb, pTab->zName); + sqlite3_free(pTab->zDb); sqlite3_free(pTab->zName); sqlite3_free(pVtab); return SQLITE_OK; @@ -434,12 +443,37 @@ static int vtablogFilter( */ static int vtablogBestIndex( sqlite3_vtab *tab, - sqlite3_index_info *pIdxInfo + sqlite3_index_info *p ){ vtablog_vtab *pTab = (vtablog_vtab*)tab; + int i; printf("%s.%s.xBestIndex():\n", pTab->zDb, pTab->zName); - pIdxInfo->estimatedCost = (double)500; - pIdxInfo->estimatedRows = 500; + printf(" colUsed: 0x%016llx\n", p->colUsed); + printf(" nConstraint: %d\n", p->nConstraint); + for(i=0; inConstraint; i++){ + printf( + " constraint[%d]: col=%d termid=%d op=%d usabled=%d collseq=%s\n", + i, + p->aConstraint[i].iColumn, + p->aConstraint[i].iTermOffset, + p->aConstraint[i].op, + p->aConstraint[i].usable, + sqlite3_vtab_collation(p,i)); + } + printf(" nOrderBy: %d\n", p->nOrderBy); + for(i=0; inOrderBy; i++){ + printf(" orderby[%d]: col=%d desc=%d\n", + i, + p->aOrderBy[i].iColumn, + p->aOrderBy[i].desc); + } + p->estimatedCost = (double)500; + p->estimatedRows = 500; + printf(" idxNum=%d\n", p->idxNum); + printf(" idxStr=NULL\n"); + printf(" orderByConsumed=%d\n", p->orderByConsumed); + printf(" estimatedCost=%g\n", p->estimatedCost); + printf(" estimatedRows=%lld\n", p->estimatedRows); return SQLITE_OK; } @@ -524,9 +558,12 @@ static int vtablogRename(sqlite3_vtab *tab, const char *zNew){ return SQLITE_OK; } +/* Any table name that contains the text "shadow" is seen as a +** shadow table. Nothing else is. +*/ static int vtablogShadowName(const char *zName){ printf("vtablog.xShadowName('%s')\n", zName); - return 0; + return sqlite3_strglob("*shadow*", zName)==0; } static int vtablogIntegrity( diff --git a/manifest b/manifest index d0cd7ceb0b..16315ac093 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Flag\ssqlite3_trace()\sand\ssqlite3_profile()\sas\sdeprecated\sso\sthat\sthe\sdoc\sgenerator\sfor\sfunclist.html\ssees\sthem\sas\ssuch,\sand\sadd\s'Deprecated'\sto\stheir\spage's\stitle\sfor\sconsistency\swith\sother\sdeprecated\sAPIs.\sComment\schanges\sonly.\sAddresses\s[forum:0901025836|forum\spost\s0901025836]. -D 2024-03-25T10:28:10.796 +C Improvements\sto\sthe\svtablog.c\sextension:\s\sEliminate\smemory\sleaks.\nMore\sdiagnostic\soutput\sfor\sxBestIndex. +D 2024-03-25T10:55:08.289 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -426,7 +426,7 @@ F ext/misc/urifuncs.c f71360d14fa9e7626b563f1f781c6148109462741c5235ac63ae0f8917 F ext/misc/uuid.c 5bb2264c1b64d163efa46509544fd7500cb8769cb7c16dd52052da8d961505cf F ext/misc/vfslog.c 3932ab932eeb2601dbc4447cb14d445aaa9fbe43b863ef5f014401c3420afd20 F ext/misc/vfsstat.c a85df08654743922a19410d7b1e3111de41bb7cd07d20dd16eda4e2b808d269d -F ext/misc/vtablog.c 10b3b8abb57c9e6ad5b9fd7789a15359931f4ae7eea1ce4c42692b5ab458b58d +F ext/misc/vtablog.c 1100250ce8782db37c833e3a9a5c9a3ecf1af5e15b8325572b82e6e0a138ffb5 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 0fa0c082676b7868bf2fa918e911133f2b349bcdceabd1198bba5f65b4fc0668 F ext/misc/zipfile.c 64cb3d98b6316586e6056d182051aa9d28fdedfbf4b908e6b7a7d70209b1db11 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e253bb36a5f4f601c9b08858b55a9ce198239ace8efa8dab7c0ec019028967c1 -R 9b310c2f5986c86858424e569b4e6f77 -U stephan -Z 6c78d97a358d85a52548c24a097975e6 +P 87c54f93f5711739741ed0ff3c1a6fe24ffc8a025b43523bf78c1f6be8c1b4cd +R 5d99a8b46e486ca8140c2e5b9bcd6d3d +U drh +Z 2928903171aaf3fcef9f3546955ace45 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 906e916a84..f2c8986bfb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87c54f93f5711739741ed0ff3c1a6fe24ffc8a025b43523bf78c1f6be8c1b4cd \ No newline at end of file +92e9a71bc4daa261d7c9a81fb66f7d7c0f0a74eb9e0c9dec8b4651acc5217bff \ No newline at end of file From 41c9945c746018b3bcec1e6ecc3e900f7b209ce4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 11:34:42 +0000 Subject: [PATCH 0281/1030] Use the SQLITE_CONSTRAINT return value from xBestIndex to prohibit bad query plans in the pragma virtual table. FossilOrigin-Name: b1259d4448f744861e416f42328c1450854370e5c77102d2a5abe5cf6c7f12bd --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 17 +++++++---------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 16315ac093..462d7295e3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\svtablog.c\sextension:\s\sEliminate\smemory\sleaks.\nMore\sdiagnostic\soutput\sfor\sxBestIndex. -D 2024-03-25T10:55:08.289 +C Use\sthe\sSQLITE_CONSTRAINT\sreturn\svalue\sfrom\sxBestIndex\sto\sprohibit\sbad\nquery\splans\sin\sthe\spragma\svirtual\stable. +D 2024-03-25T11:34:42.948 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -743,7 +743,7 @@ F src/parse.y 5bcef16094213efcc365a9d4dc4e3131f09251dc8838dce4a9e5f9764bff5b82 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c 4629926f936cdc586873d5ff24acb1af12a1db0172988a0dc2b32e46b798a640 +F src/pragma.c f8f1845b42df684e9d31c5a1628c989a34939686049d7878bc5394ac1ae9cac4 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87c54f93f5711739741ed0ff3c1a6fe24ffc8a025b43523bf78c1f6be8c1b4cd -R 5d99a8b46e486ca8140c2e5b9bcd6d3d +P 92e9a71bc4daa261d7c9a81fb66f7d7c0f0a74eb9e0c9dec8b4651acc5217bff +R 7a45ef8d7654e3d4a6dd224e77e73806 U drh -Z 2928903171aaf3fcef9f3546955ace45 +Z d7913bb9141ded55d9621342d895b371 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f2c8986bfb..81c9591139 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -92e9a71bc4daa261d7c9a81fb66f7d7c0f0a74eb9e0c9dec8b4651acc5217bff \ No newline at end of file +b1259d4448f744861e416f42328c1450854370e5c77102d2a5abe5cf6c7f12bd \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index d14428f75e..8af18cbf20 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2870,9 +2870,9 @@ static int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ seen[0] = 0; seen[1] = 0; for(i=0; inConstraint; i++, pConstraint++){ - if( pConstraint->usable==0 ) continue; - if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; if( pConstraint->iColumn < pTab->iHidden ) continue; + if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; + if( pConstraint->usable==0 ) return SQLITE_CONSTRAINT; j = pConstraint->iColumn - pTab->iHidden; assert( j < 2 ); seen[j] = i+1; @@ -2885,16 +2885,13 @@ static int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ j = seen[0]-1; pIdxInfo->aConstraintUsage[j].argvIndex = 1; pIdxInfo->aConstraintUsage[j].omit = 1; - if( seen[1]==0 ){ - pIdxInfo->estimatedCost = (double)1000; - pIdxInfo->estimatedRows = 1000; - return SQLITE_OK; - } pIdxInfo->estimatedCost = (double)20; pIdxInfo->estimatedRows = 20; - j = seen[1]-1; - pIdxInfo->aConstraintUsage[j].argvIndex = 2; - pIdxInfo->aConstraintUsage[j].omit = 1; + if( seen[1] ){ + j = seen[1]-1; + pIdxInfo->aConstraintUsage[j].argvIndex = 2; + pIdxInfo->aConstraintUsage[j].omit = 1; + } return SQLITE_OK; } From 99b4e6e25467f33db7e4140ce70bb052b01e2c02 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 12:28:06 +0000 Subject: [PATCH 0282/1030] Fix recent test case changes so that they also work on Windows. FossilOrigin-Name: 38578b5af2e97c420f3106bc486318604aecbaa327365bbc2e9518be84491495 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/pragma4.test | 6 +++++- test/readonly.test | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 462d7295e3..9250890ce0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sthe\sSQLITE_CONSTRAINT\sreturn\svalue\sfrom\sxBestIndex\sto\sprohibit\sbad\nquery\splans\sin\sthe\spragma\svirtual\stable. -D 2024-03-25T11:34:42.948 +C Fix\srecent\stest\scase\schanges\sso\sthat\sthey\salso\swork\son\sWindows. +D 2024-03-25T12:28:06.030 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1501,7 +1501,7 @@ F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b76 F test/pragma.test 8bb6d3992c1c31ff6d5553d1e0693d642f7e19015648c6ae7034cb497d26bbd4 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 -F test/pragma4.test 1951dc5a6d87c4ccd8eab35c65f18380c80fac4a0897e828cf518e3cc8a4c292 +F test/pragma4.test d864430507fc5628c150f1e50c1d128a444ccf8dab39b5465644f53fa4232311 F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d9102 F test/pragma6.test c5ec577ba087954b4dfa619a3cbe97b155b60a0af487527abe89b10fc17e6512 F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8 @@ -1522,7 +1522,7 @@ F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 -F test/readonly.test bdf5a451f415bc3153764122d034f553797c27194ffbd1e9763ecd9500af41d2 +F test/readonly.test c1985f0b4ab55041f2ba629dadc6578a3ff0f0e5b0ec7912e85c51f49c3e82fe F test/recover.test 6463509a7404e0c35431dd9b4a1c3b4a29d7a6af8a08462b31670c8a5a616d3a F test/regexp1.test 8f2a8bc1569666e29a4cee6c1a666cd224eb6d50e2470d1dc1df995170f3e0f1 F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed1368b5 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 92e9a71bc4daa261d7c9a81fb66f7d7c0f0a74eb9e0c9dec8b4651acc5217bff -R 7a45ef8d7654e3d4a6dd224e77e73806 +P b1259d4448f744861e416f42328c1450854370e5c77102d2a5abe5cf6c7f12bd +R 8e93d8f33bb14264477f8796f06f56d6 U drh -Z d7913bb9141ded55d9621342d895b371 +Z 14ed6a8037fd4481b1dadac4489cca1e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 81c9591139..ca79f423a7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b1259d4448f744861e416f42328c1450854370e5c77102d2a5abe5cf6c7f12bd \ No newline at end of file +38578b5af2e97c420f3106bc486318604aecbaa327365bbc2e9518be84491495 \ No newline at end of file diff --git a/test/pragma4.test b/test/pragma4.test index 9b2fa9ba2a..7c244c78b6 100644 --- a/test/pragma4.test +++ b/test/pragma4.test @@ -83,7 +83,7 @@ foreach {tn sql} { # Verify that that P4_INTARRAY argument to OP_IntegrityCk is rendered # correctly. # -db close +catch {db close} forcedelete test.db sqlite3 db test.db do_test pragma4-2.100 { @@ -266,8 +266,12 @@ do_execsql_test 5.0 { # 2024-03-24 https://sqlite.org/forum/forumpost/85b6a8b6705fb77a # +catch {db2 close} +catch {db3 close} reset_db do_execsql_test 6.0 { + DROP TABLE IF EXISTS t1; + DROP TABLE IF EXISTS t2; CREATE TABLE t1(a INT PRIMARY KEY, b INT); CREATE TABLE t2(c INT PRIMARY KEY, d INT REFERENCES t1); SELECT t.name, f."table", f."from", i.name, i.pk diff --git a/test/readonly.test b/test/readonly.test index 811d54f3b5..1ccbcee284 100644 --- a/test/readonly.test +++ b/test/readonly.test @@ -15,6 +15,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +if {$tcl_platform(platform)=="windows"} finish_test source $testdir/lock_common.tcl source $testdir/wal_common.tcl set ::testprefix readonly From bcf97e70f5ee50dac50f8604c9b62b3429912bff Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 13:18:46 +0000 Subject: [PATCH 0283/1030] Fix the pragma4.test script so that it works with SQLITE_OMIT_VIRTUALTABLE. FossilOrigin-Name: f8fe6fb69c4164d087783a0d6990112afabea78daa4d8985eb6df7df6f45ac27 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/pragma4.test | 26 ++++++++++++++------------ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 9250890ce0..4797b53cd8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\srecent\stest\scase\schanges\sso\sthat\sthey\salso\swork\son\sWindows. -D 2024-03-25T12:28:06.030 +C Fix\sthe\spragma4.test\sscript\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_VIRTUALTABLE. +D 2024-03-25T13:18:46.591 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1501,7 +1501,7 @@ F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b76 F test/pragma.test 8bb6d3992c1c31ff6d5553d1e0693d642f7e19015648c6ae7034cb497d26bbd4 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 -F test/pragma4.test d864430507fc5628c150f1e50c1d128a444ccf8dab39b5465644f53fa4232311 +F test/pragma4.test 22834a228e59b80f5c15b519b710474859d91535002670ddb7cd13ac44b54e9a F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d9102 F test/pragma6.test c5ec577ba087954b4dfa619a3cbe97b155b60a0af487527abe89b10fc17e6512 F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b1259d4448f744861e416f42328c1450854370e5c77102d2a5abe5cf6c7f12bd -R 8e93d8f33bb14264477f8796f06f56d6 +P 38578b5af2e97c420f3106bc486318604aecbaa327365bbc2e9518be84491495 +R 4aabcb0c5c9b41b63fc5196fb947c9b6 U drh -Z 14ed6a8037fd4481b1dadac4489cca1e +Z d83b8554c188328afa7b3f0d71ba5b85 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ca79f423a7..e76f63aa38 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38578b5af2e97c420f3106bc486318604aecbaa327365bbc2e9518be84491495 \ No newline at end of file +f8fe6fb69c4164d087783a0d6990112afabea78daa4d8985eb6df7df6f45ac27 \ No newline at end of file diff --git a/test/pragma4.test b/test/pragma4.test index 7c244c78b6..6d59b4fff3 100644 --- a/test/pragma4.test +++ b/test/pragma4.test @@ -268,17 +268,19 @@ do_execsql_test 5.0 { # catch {db2 close} catch {db3 close} -reset_db -do_execsql_test 6.0 { - DROP TABLE IF EXISTS t1; - DROP TABLE IF EXISTS t2; - CREATE TABLE t1(a INT PRIMARY KEY, b INT); - CREATE TABLE t2(c INT PRIMARY KEY, d INT REFERENCES t1); - SELECT t.name, f."table", f."from", i.name, i.pk - FROM pragma_table_list() AS t - JOIN pragma_foreign_key_list(t.name, t.schema) AS f - JOIN pragma_table_info(f."table", t.schema) AS i - WHERE i.pk; -} {t2 t1 d a 1} +ifcapable vtab { + reset_db + do_execsql_test 6.0 { + DROP TABLE IF EXISTS t1; + DROP TABLE IF EXISTS t2; + CREATE TABLE t1(a INT PRIMARY KEY, b INT); + CREATE TABLE t2(c INT PRIMARY KEY, d INT REFERENCES t1); + SELECT t.name, f."table", f."from", i.name, i.pk + FROM pragma_table_list() AS t + JOIN pragma_foreign_key_list(t.name, t.schema) AS f + JOIN pragma_table_info(f."table", t.schema) AS i + WHERE i.pk; + } {t2 t1 d a 1} +} finish_test From ed6c9aa6abf27b198313a1e274a7a9a22b6a8542 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 14:44:10 +0000 Subject: [PATCH 0284/1030] Fix an inaccuracy in automatic indexes that was exposed by the fix at [80c4223098c1827f]. FossilOrigin-Name: fdc9406f1c8ba4a7341c1e408f6042ddc788cf65f98e1de2ee101390bfb0abae --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4797b53cd8..a5e165b27b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\spragma4.test\sscript\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_VIRTUALTABLE. -D 2024-03-25T13:18:46.591 +C Fix\san\sinaccuracy\sin\sautomatic\sindexes\sthat\swas\sexposed\sby\sthe\sfix\nat\s[80c4223098c1827f]. +D 2024-03-25T14:44:10.198 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 2e01199202dd117a27f7597e1f554a5cd55e7465e2f39ff9a78adc9cba98b971 +F src/where.c 11a67988c3a5be2e7ee07c958998f3ad4b30dc491c0add894c2933c752415b16 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38578b5af2e97c420f3106bc486318604aecbaa327365bbc2e9518be84491495 -R 4aabcb0c5c9b41b63fc5196fb947c9b6 +P f8fe6fb69c4164d087783a0d6990112afabea78daa4d8985eb6df7df6f45ac27 +R a7eca515ed0d2c704ec351621eaadae9 U drh -Z d83b8554c188328afa7b3f0d71ba5b85 +Z 126d8b46e6dcce24a23c7b6d521c4841 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e76f63aa38..e02a458158 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f8fe6fb69c4164d087783a0d6990112afabea78daa4d8985eb6df7df6f45ac27 \ No newline at end of file +fdc9406f1c8ba4a7341c1e408f6042ddc788cf65f98e1de2ee101390bfb0abae \ No newline at end of file diff --git a/src/where.c b/src/where.c index 3fbb768af5..5767b44128 100644 --- a/src/where.c +++ b/src/where.c @@ -984,7 +984,7 @@ static SQLITE_NOINLINE void constructAutomaticIndex( ** if they go out of sync. */ if( IsView(pTable) ){ - extraCols = ALLBITS; + extraCols = ALLBITS & ~idxCols; }else{ extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1)); } From f7aab656ff0c38260c2daf01591518cadcd04359 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 17:43:11 +0000 Subject: [PATCH 0285/1030] Remove an ALWAYS() from a condition that can be true. FossilOrigin-Name: 715fcf033a6c0c64fa3076d58be8c39246aebef922c1a44a31831b40e165015e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vtab.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a5e165b27b..991d1c97d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sinaccuracy\sin\sautomatic\sindexes\sthat\swas\sexposed\sby\sthe\sfix\nat\s[80c4223098c1827f]. -D 2024-03-25T14:44:10.198 +C Remove\san\sALWAYS()\sfrom\sa\scondition\sthat\scan\sbe\strue. +D 2024-03-25T17:43:11.374 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -830,7 +830,7 @@ F src/vdbemem.c 213bf303826c0ef702e3a2a69dab2309d84b8381b822c6787885859fd7cd4c4e F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 -F src/vtab.c 38fcf63832f7e606755fa47b028c2eb6d6cd5facb40e280d66fbda4ed9a52188 +F src/vtab.c cd53fee1d4ca6c9dd6eb673aeb87ecaa1c5a067da30e3b231678bd9e3f771b60 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f8fe6fb69c4164d087783a0d6990112afabea78daa4d8985eb6df7df6f45ac27 -R a7eca515ed0d2c704ec351621eaadae9 +P fdc9406f1c8ba4a7341c1e408f6042ddc788cf65f98e1de2ee101390bfb0abae +R f76b08b792dbded66ddcd94e7cec15b2 U drh -Z 126d8b46e6dcce24a23c7b6d521c4841 +Z b7fa3cba61650ea05eb1778d7cc33597 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e02a458158..ae66038eef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fdc9406f1c8ba4a7341c1e408f6042ddc788cf65f98e1de2ee101390bfb0abae \ No newline at end of file +715fcf033a6c0c64fa3076d58be8c39246aebef922c1a44a31831b40e165015e \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index 67226c63c8..199ae32171 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -840,7 +840,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ db->init.busy = 0; sParse.nQueryLoop = 1; if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable) - && ALWAYS(sParse.pNewTable!=0) + && sParse.pNewTable!=0 && ALWAYS(!db->mallocFailed) && IsOrdinaryTable(sParse.pNewTable) ){ From 791b6f36cc8ed25766e709dfe2dc6d23782652b8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 18:24:28 +0000 Subject: [PATCH 0286/1030] Revert the previous change. Instead, do a pre-check of the CREATE TABLE statement that is the second argument to sqlite3_declare_vtab() and if the first two keywords are not "CREATE" and "TABLE", then raise an SQLITE_MISUSE error. FossilOrigin-Name: 6a2ff8351244da2336055454dfad2dd40534b7cfb51e840f7f8cf2ddacf8649e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vtab.c | 18 +++++++++++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 991d1c97d7..3e57f6173d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sALWAYS()\sfrom\sa\scondition\sthat\scan\sbe\strue. -D 2024-03-25T17:43:11.374 +C Revert\sthe\sprevious\schange.\s\sInstead,\sdo\sa\spre-check\sof\sthe\sCREATE\sTABLE\nstatement\sthat\sis\sthe\ssecond\sargument\sto\ssqlite3_declare_vtab()\sand\sif\nthe\sfirst\stwo\skeywords\sare\snot\s"CREATE"\sand\s"TABLE",\sthen\sraise\san\nSQLITE_MISUSE\serror. +D 2024-03-25T18:24:28.496 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -830,7 +830,7 @@ F src/vdbemem.c 213bf303826c0ef702e3a2a69dab2309d84b8381b822c6787885859fd7cd4c4e F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 -F src/vtab.c cd53fee1d4ca6c9dd6eb673aeb87ecaa1c5a067da30e3b231678bd9e3f771b60 +F src/vtab.c 13481f3532a3a89624d1853ebc8c980215e716e275a729444c12e3f1005b4b74 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fdc9406f1c8ba4a7341c1e408f6042ddc788cf65f98e1de2ee101390bfb0abae -R f76b08b792dbded66ddcd94e7cec15b2 +P 715fcf033a6c0c64fa3076d58be8c39246aebef922c1a44a31831b40e165015e +R 56888bcd4145065d254cef5a88e451fc U drh -Z b7fa3cba61650ea05eb1778d7cc33597 +Z d2c55463ac4c41ce779d550b765c534c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ae66038eef..8fc054c745 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -715fcf033a6c0c64fa3076d58be8c39246aebef922c1a44a31831b40e165015e \ No newline at end of file +6a2ff8351244da2336055454dfad2dd40534b7cfb51e840f7f8cf2ddacf8649e \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index 199ae32171..aad93fef8b 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -813,12 +813,27 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ Table *pTab; Parse sParse; int initBusy; + int i; + const unsigned char *z; + static const u8 aKeyword[] = { TK_CREATE, TK_TABLE, 0 }; #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){ return SQLITE_MISUSE_BKPT; } #endif + + /* Verify that the first two keywords in the CREATE TABLE statement + ** really are "CREATE" and "TABLE". If this is not the case, then + ** sqlite3_declare_vtab() is being misused. + */ + z = (const unsigned char*)zCreateTable; + for(i=0; aKeyword[i]; i++){ + int tokenType = 0; + do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE ); + if( tokenType!=aKeyword[i] ) return SQLITE_MISUSE_BKPT; + } + sqlite3_mutex_enter(db->mutex); pCtx = db->pVtabCtx; if( !pCtx || pCtx->bDeclared ){ @@ -826,6 +841,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ sqlite3_mutex_leave(db->mutex); return SQLITE_MISUSE_BKPT; } + pTab = pCtx->pTab; assert( IsVirtual(pTab) ); @@ -840,7 +856,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ db->init.busy = 0; sParse.nQueryLoop = 1; if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable) - && sParse.pNewTable!=0 + && ALWAYS(sParse.pNewTable!=0) && ALWAYS(!db->mallocFailed) && IsOrdinaryTable(sParse.pNewTable) ){ From eb5bd4db91430a44f96bf636e4aba1c5eaa69c7d Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 25 Mar 2024 18:30:15 +0000 Subject: [PATCH 0287/1030] Fix a theoretical OOB memory access in sqlite3_stmt_scanstatus_v2(). FossilOrigin-Name: 87be9580747b405c2c534beadb0f95cee0d4f34e0245f90e157a6b7ada38e092 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/vdbeapi.c | 3 ++- test/scanstatus2.test | 11 +++++++++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 3e57f6173d..2ec51c300c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revert\sthe\sprevious\schange.\s\sInstead,\sdo\sa\spre-check\sof\sthe\sCREATE\sTABLE\nstatement\sthat\sis\sthe\ssecond\sargument\sto\ssqlite3_declare_vtab()\sand\sif\nthe\sfirst\stwo\skeywords\sare\snot\s"CREATE"\sand\s"TABLE",\sthen\sraise\san\nSQLITE_MISUSE\serror. -D 2024-03-25T18:24:28.496 +C Fix\sa\stheoretical\sOOB\smemory\saccess\sin\ssqlite3_stmt_scanstatus_v2(). +D 2024-03-25T18:30:15.250 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -823,7 +823,7 @@ F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c 651aa0f31027d5d0a133eb7b41d11c41dc3b88ecb760b770430da0e477ae3b6c F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c -F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b +F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df F src/vdbeaux.c 6385727adf51a649e4993098870a62c3945fe21dbc0e0fd9013772aff930b8fb F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 213bf303826c0ef702e3a2a69dab2309d84b8381b822c6787885859fd7cd4c4e @@ -1560,7 +1560,7 @@ F test/savepoint6.test f41279c5e137139fa5c21485773332c7adb98cd7 F test/savepoint7.test cde525ea3075283eb950cdcdefe23ead4f700daa F test/savepointfault.test f044eac64b59f09746c7020ee261734de82bf9b2 F test/scanstatus.test b249328caf4d317e71058006872b8012598a5fa045b30bf24a81eeff650ab49e -F test/scanstatus2.test 317670daf7f3eef48a9598cb7800ba8eccab51949cf52bca3f7da3b83a0c1c8c +F test/scanstatus2.test 688adc0c3ab1ffadead218cbce6446b10aa892004a8ea5e3640d59257fb836f2 F test/schema.test 5dd11c96ba64744de955315d2e4f8992e447533690153b93377dffb2a5ef5431 F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5 F test/schema3.test 8ed4ae66e082cdd8b1b1f22d8549e1e7a0db4527a8e6ee8b6193053ee1e5c9ce @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 715fcf033a6c0c64fa3076d58be8c39246aebef922c1a44a31831b40e165015e -R 56888bcd4145065d254cef5a88e451fc -U drh -Z d2c55463ac4c41ce779d550b765c534c +P 6a2ff8351244da2336055454dfad2dd40534b7cfb51e840f7f8cf2ddacf8649e +R 1054addf5a80b70d64920561ede27990 +U dan +Z b1b40567e29d2af418e3b643400eabb8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8fc054c745..e0d4ad9044 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a2ff8351244da2336055454dfad2dd40534b7cfb51e840f7f8cf2ddacf8649e \ No newline at end of file +87be9580747b405c2c534beadb0f95cee0d4f34e0245f90e157a6b7ada38e092 \ No newline at end of file diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 14c6091e0c..3182e4070f 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -2404,7 +2404,6 @@ int sqlite3_stmt_scanstatus_v2( } if( flags & SQLITE_SCANSTAT_COMPLEX ){ idx = iScan; - pScan = &p->aScan[idx]; }else{ /* If the COMPLEX flag is clear, then this function must ignore any ** ScanStatus structures with ScanStatus.addrLoop set to 0. */ @@ -2417,6 +2416,8 @@ int sqlite3_stmt_scanstatus_v2( } } if( idx>=p->nScan ) return 1; + assert( pScan==0 || pScan==&p->aScan[idx] ); + pScan = &p->aScan[idx]; switch( iScanStatusOp ){ case SQLITE_SCANSTAT_NLOOP: { diff --git a/test/scanstatus2.test b/test/scanstatus2.test index e4b510d20f..7f107cd2eb 100644 --- a/test/scanstatus2.test +++ b/test/scanstatus2.test @@ -328,6 +328,17 @@ QUERY (nCycle=nnn) --SCAN xy2 (nCycle=nnn) } +#------------------------------------------------------------------------- +reset_db + +# Check that an OOB parameter (45) does not cause asan or valgrind errors. +# +do_test 7.0 { + db eval {SELECT * FROM sqlite_schema} + set stmt [db version -last-stmt-ptr] + sqlite3_stmt_scanstatus -flags complex $stmt 1000000 +} {} + #explain_i { SELECT (a % 2), group_concat(b) FROM t1 GROUP BY 1 } #puts_debug_info { SELECT (a % 2), group_concat(b) FROM t1 GROUP BY 1 } From 1872f8d8442f0c21a7ae573dc557a1784e30bbf1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 19:31:03 +0000 Subject: [PATCH 0288/1030] Simplifications to the sqlite3_declare_vtab() implementation. Changes some conditionals into assert() statements, for coverage. FossilOrigin-Name: ff7b898a6f9cb9aecb51bd6b63e253b4b7486ac9367f59c3c0491d78cfb39993 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vtab.c | 9 ++++----- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 2ec51c300c..ba1ed56e3d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stheoretical\sOOB\smemory\saccess\sin\ssqlite3_stmt_scanstatus_v2(). -D 2024-03-25T18:30:15.250 +C Simplifications\sto\sthe\ssqlite3_declare_vtab()\simplementation.\s\sChanges\nsome\sconditionals\sinto\sassert()\sstatements,\sfor\scoverage. +D 2024-03-25T19:31:03.875 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -830,7 +830,7 @@ F src/vdbemem.c 213bf303826c0ef702e3a2a69dab2309d84b8381b822c6787885859fd7cd4c4e F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 -F src/vtab.c 13481f3532a3a89624d1853ebc8c980215e716e275a729444c12e3f1005b4b74 +F src/vtab.c 4c475fb672a6fe57830561e614dbee21a9a24a6f616d1cfcbe85f356a09f14ad F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 @@ -2182,8 +2182,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a2ff8351244da2336055454dfad2dd40534b7cfb51e840f7f8cf2ddacf8649e -R 1054addf5a80b70d64920561ede27990 -U dan -Z b1b40567e29d2af418e3b643400eabb8 +P 87be9580747b405c2c534beadb0f95cee0d4f34e0245f90e157a6b7ada38e092 +R ad8aac9f3b06a2e42b637acda669767c +U drh +Z b1a7a78f1aa22406dcb910ac85bd2eff # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e0d4ad9044..f0cba94336 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87be9580747b405c2c534beadb0f95cee0d4f34e0245f90e157a6b7ada38e092 \ No newline at end of file +ff7b898a6f9cb9aecb51bd6b63e253b4b7486ac9367f59c3c0491d78cfb39993 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index aad93fef8b..61dafab711 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -855,11 +855,10 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ initBusy = db->init.busy; db->init.busy = 0; sParse.nQueryLoop = 1; - if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable) - && ALWAYS(sParse.pNewTable!=0) - && ALWAYS(!db->mallocFailed) - && IsOrdinaryTable(sParse.pNewTable) - ){ + if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable) ){ + assert( sParse.pNewTable!=0 ); + assert( !db->mallocFailed ); + assert( IsOrdinaryTable(sParse.pNewTable) ); assert( sParse.zErrMsg==0 ); if( !pTab->aCol ){ Table *pNew = sParse.pNewTable; From ca3b9096c45f308b89608155baabfff587d96616 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 25 Mar 2024 20:00:40 +0000 Subject: [PATCH 0289/1030] Add further tests for sqlite3_declare_vtab(). FossilOrigin-Name: f3c4433f6b33087494c8d38ff9dbb008a1bd30b424ca9aaa51c1956d75a86249 --- manifest | 13 ++++++------ manifest.uuid | 2 +- test/vtabL.test | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 test/vtabL.test diff --git a/manifest b/manifest index ba1ed56e3d..2f44648bcd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\ssqlite3_declare_vtab()\simplementation.\s\sChanges\nsome\sconditionals\sinto\sassert()\sstatements,\sfor\scoverage. -D 2024-03-25T19:31:03.875 +C Add\sfurther\stests\sfor\ssqlite3_declare_vtab(). +D 2024-03-25T20:00:40.445 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1951,6 +1951,7 @@ F test/vtabH.test 2efb5a24b0bb50796b21eca23032cfb77abfa4b0c03938e38ce5897abac404 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtabJ.test a6aef49d558af90fae10565b29501f82a95781cb4f797f2d13e2d19f9b6bc77b F test/vtabK.test 13293177528fada1235c0112db0d187d754af1355c5a39371abd365104e3afbf +F test/vtabL.test 040b9f782a3b41844f2a5c660e6a0bfd298492980c6b4e126d82113c9785cec3 F test/vtab_alter.test 736e66fb5ec7b4fee58229aa3ada2f27ec58bc58c00edae4836890c3784c6783 F test/vtab_err.test dcc8b7b9cb67522b3fe7a272c73856829dae4ab7fdb30399aea1b6981bda2b65 F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad @@ -2182,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87be9580747b405c2c534beadb0f95cee0d4f34e0245f90e157a6b7ada38e092 -R ad8aac9f3b06a2e42b637acda669767c -U drh -Z b1a7a78f1aa22406dcb910ac85bd2eff +P ff7b898a6f9cb9aecb51bd6b63e253b4b7486ac9367f59c3c0491d78cfb39993 +R aae449702ba5a25d8e948527e6058f06 +U dan +Z 4c63f0c0b8b71810a39e1da8a896d2df # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f0cba94336..bb07a9bef8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff7b898a6f9cb9aecb51bd6b63e253b4b7486ac9367f59c3c0491d78cfb39993 \ No newline at end of file +f3c4433f6b33087494c8d38ff9dbb008a1bd30b424ca9aaa51c1956d75a86249 \ No newline at end of file diff --git a/test/vtabL.test b/test/vtabL.test new file mode 100644 index 0000000000..a801481c84 --- /dev/null +++ b/test/vtabL.test @@ -0,0 +1,55 @@ +# 2024-03-26 +# +# 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 +set testprefix vtabL + +ifcapable !vtab { + finish_test + return +} + +register_tcl_module db + +proc vtab_command {method args} { + switch -- $method { + xConnect { + return $::create_table_sql + } + } + + return {} +} + +do_execsql_test 1.0 { + CREATE TABLE t1(a, b); +} + +foreach {tn cts} { + 1 {SELECT 123} + 2 {SELECT 123, 456} + 3 {INSERT INTO t1 VALUES(5, 6)} + 4 {CREATE INDEX i1 ON t1(a)} + 5 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END;} + 6 {DROP TABLE nosuchtable} + 7 {DROP TABLE x1} + 8 {DROP TABLE t1} +} { + set ::create_table_sql $cts + do_catchsql_test 1.$tn { + CREATE VIRTUAL TABLE x1 USING tcl(vtab_command); + } {1 {vtable constructor failed: x1}} +} + +finish_test + From a509a90958ddb234d1785ed7801880ccb18b497e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 25 Mar 2024 20:35:14 +0000 Subject: [PATCH 0290/1030] The RAISE() operator is not a constant expression and cannot participate in the VALUE-as-coroutine optimization. dbsqlfuzz 74cf7c9904360322a6c917e4934b127543d1cd51 FossilOrigin-Name: 6a06dc73847716c88d65651d1bf0e002002303881df1389beac884d0032eae08 --- manifest | 18 +++++++-------- manifest.uuid | 2 +- src/expr.c | 2 ++ src/insert.c | 6 +++-- test/values.test | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 2f44648bcd..24f7bb9fb9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfurther\stests\sfor\ssqlite3_declare_vtab(). -D 2024-03-25T20:00:40.445 +C The\sRAISE()\soperator\sis\snot\sa\sconstant\sexpression\sand\scannot\sparticipate\sin\nthe\sVALUE-as-coroutine\soptimization.\ndbsqlfuzz\s74cf7c9904360322a6c917e4934b127543d1cd51 +D 2024-03-25T20:35:14.251 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c ff1bb1bdbcdc20505cfa900f332e18239ab3cf20d2b0d220a960b5b3513b7cb4 +F src/expr.c cd46ce2ebe46a30e63087dbe8aff7d6e34ba8acc8c658e8e18fcaa35f2711391 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 06ce505713e86172612f9e01febefd2d3331d1f70461b4ada0eae5a76bb6349f +F src/insert.c bc4d172b52a6167cd28797397a464c2cca9607dc047dfa0b5cf61687962e6964 F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -1924,7 +1924,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test ee77c1cb540c47868848f85c39f92bb11d787657ade32f91eedf2988727769cd +F test/values.test 6c2426de40cd397a8ab68d375b6964ab3bce1244bbb69f5d1ed3ccd0e039c1f3 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ff7b898a6f9cb9aecb51bd6b63e253b4b7486ac9367f59c3c0491d78cfb39993 -R aae449702ba5a25d8e948527e6058f06 -U dan -Z 4c63f0c0b8b71810a39e1da8a896d2df +P f3c4433f6b33087494c8d38ff9dbb008a1bd30b424ca9aaa51c1956d75a86249 +R 11afa0c0cb35ff6b57f28ca49a3f27d4 +U drh +Z 38f01fde0dacda37a79ba00b3f8d1e29 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bb07a9bef8..04e087afeb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f3c4433f6b33087494c8d38ff9dbb008a1bd30b424ca9aaa51c1956d75a86249 \ No newline at end of file +6a06dc73847716c88d65651d1bf0e002002303881df1389beac884d0032eae08 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index d71353f174..edfea3fc92 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2474,9 +2474,11 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ case TK_IF_NULL_ROW: case TK_REGISTER: case TK_DOT: + case TK_RAISE: testcase( pExpr->op==TK_REGISTER ); testcase( pExpr->op==TK_IF_NULL_ROW ); testcase( pExpr->op==TK_DOT ); + testcase( pExpr->op==TK_RAISE ); pWalker->eCode = 0; return WRC_Abort; case TK_VARIABLE: diff --git a/src/insert.c b/src/insert.c index fe7ba05dc1..c126a83952 100644 --- a/src/insert.c +++ b/src/insert.c @@ -610,8 +610,10 @@ static int exprListIsNoAffinity(Parse *pParse, ExprList *pRow){ int ii; if( exprListIsConstant(pParse,pRow)==0 ) return 0; for(ii=0; iinExpr; ii++){ - assert( pRow->a[ii].pExpr->affExpr==0 ); - if( 0!=sqlite3ExprAffinity(pRow->a[ii].pExpr) ) return 0; + Expr *pExpr = pRow->a[ii].pExpr; + assert( pExpr->op!=TK_RAISE ); + assert( pExpr->affExpr==0 ); + if( 0!=sqlite3ExprAffinity(pExpr) ) return 0; } return 1; diff --git a/test/values.test b/test/values.test index 26f2812237..4252f2e13b 100644 --- a/test/values.test +++ b/test/values.test @@ -592,4 +592,62 @@ do_execsql_test 17.2 { SELECT * FROM t1 } {1 2 3 0} +# 2024-03-25 dbsqlfuzz crash-74cf7c9904360322a6c917e4934b127543d1cd51 +# +do_catchsql_test 18.1 { + DROP TABLE t1; + CREATE TABLE t1(x INTEGER PRIMARY KEY); + INSERT INTO t1 VALUES(RAISE(IGNORE)),(0); +} {1 {RAISE() may only be used within a trigger-program}} +do_catchsql_test 18.2 { + DROP TABLE t1; + CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z); + CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN + INSERT INTO t1(y) VALUES(RAISE(IGNORE)),(0); + END; + INSERT INTO t1 VALUES(1,2,3); + SELECT * FROM t1; +} {0 {1 2 3}} +do_catchsql_test 18.3.1 { + DROP TABLE t1; + CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z); + CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN + INSERT INTO t1(y) VALUES(RAISE(ABORT,'error 18.3')),(0); + END; + INSERT INTO t1 VALUES(1,2,3); +} {1 {error 18.3}} +do_execsql_test 18.3.2 { + SELECT * FROM t1; +} {} +do_catchsql_test 18.4.1 { + DROP TABLE t1; + CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z); + CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN + INSERT INTO t1(y) VALUES(1),(RAISE(ABORT,'error 18.4')),(0); + END; + INSERT INTO t1 VALUES(1,2,3); +} {1 {error 18.4}} +do_execsql_test 18.4.2 { + SELECT * FROM t1; +} {} +do_catchsql_test 18.5.1 { + DROP TABLE t1; + CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z); + CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN + INSERT INTO t1(y) VALUES(1), + (CASE WHEN new.z>7 THEN RAISE(ABORT,'error 18.5') ELSE 2 END); + END; + INSERT INTO t1 VALUES(1,2,3); + SELECT * FROM t1; +} {0 {1 2 3 2 1 {} 3 2 {}}} +do_catchsql_test 18.5.2 { + DELETE FROM t1; + INSERT INTO t1 VALUES(1,2,13); +} {1 {error 18.5}} +do_catchsql_test 18.5.3 { + SELECT * FROM t1; +} {0 {}} + + + finish_test From dcc121999cb458e36b5aef9808f856a734041622 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 26 Mar 2024 11:14:52 +0000 Subject: [PATCH 0291/1030] Avoid expanding integer values in columns with real affinity to the full 8-byte representation when editing records as part of a DROP COLUMN command. FossilOrigin-Name: a49296de0061931badaf3db6b965131a78b1c6c21b1eeb62815ea7adf767d0b3 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/alter.c | 5 +++++ test/altertab3.test | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 24f7bb9fb9..ea43bdf8f8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sRAISE()\soperator\sis\snot\sa\sconstant\sexpression\sand\scannot\sparticipate\sin\nthe\sVALUE-as-coroutine\soptimization.\ndbsqlfuzz\s74cf7c9904360322a6c917e4934b127543d1cd51 -D 2024-03-25T20:35:14.251 +C Avoid\sexpanding\sinteger\svalues\sin\scolumns\swith\sreal\saffinity\sto\sthe\sfull\s8-byte\srepresentation\swhen\sediting\srecords\sas\spart\sof\sa\sDROP\sCOLUMN\scommand. +D 2024-03-26T11:14:52.242 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -682,7 +682,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 -F src/alter.c 30c2333b8bb3af71e4eb9adeadee8aa20edb15917ed44b8422e5cd15f3dfcddc +F src/alter.c e1b6782b85dd758f89e5c588e4e3eb82638c2dafc0c857b79a43bb8ec1746fca F src/analyze.c a3df28274e2565ba5656577d7e3fd262169a213e6eb0bd47890e0f0729a4031c F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39 F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 @@ -867,7 +867,7 @@ F test/altermalloc3.test 8040e486368403f2fdd6fc3998258b499bd4cc2f3ddbb5f8f874cd4 F test/alterqf.test 8ec03d776de9c391daa0078ea8f838903bdcfb11dfae4ba3576b48436834ccba F test/altertab.test 8a2712f9076da5012a002d0b5cc0a421398a5bf61c25bab41b77c427586a7a27 F test/altertab2.test 62597b6fd08feaba1b6bfe7d31dac6117c67e06dc9ce9c478a3abe75b5926de0 -F test/altertab3.test e167ce3b8e243b52306c1e40b13eb868f402a969513c063998593862cc643b44 +F test/altertab3.test b331ae34e69594e19605e3297805202d6156fcc8f75379dfd972a2e51cae8721 F test/altertrig.test aacc980b657354fe2d3d4d3a004f07d04ccc1a93e5ef82d68a79088c274ddc6b F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 2fb21d7d64748636384e6cb8998dbf83968caf644c07fcb4f76c18f2e7ede94b @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f3c4433f6b33087494c8d38ff9dbb008a1bd30b424ca9aaa51c1956d75a86249 -R 11afa0c0cb35ff6b57f28ca49a3f27d4 -U drh -Z 38f01fde0dacda37a79ba00b3f8d1e29 +P 6a06dc73847716c88d65651d1bf0e002002303881df1389beac884d0032eae08 +R 9f7cc1bf5356d77f08ae122347a7b675 +U dan +Z 96694e9dd3b3c0e4acdff2534541b848 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 04e087afeb..8c514c694f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a06dc73847716c88d65651d1bf0e002002303881df1389beac884d0032eae08 \ No newline at end of file +a49296de0061931badaf3db6b965131a78b1c6c21b1eeb62815ea7adf767d0b3 \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index ec45e14331..c1e0a295a4 100644 --- a/src/alter.c +++ b/src/alter.c @@ -2262,7 +2262,12 @@ void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const Token *pName){ if( i==pTab->iPKey ){ sqlite3VdbeAddOp2(v, OP_Null, 0, regOut); }else{ + char aff = pTab->aCol[i].affinity; + if( aff==SQLITE_AFF_REAL ){ + pTab->aCol[i].affinity = SQLITE_AFF_NUMERIC; + } sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut); + pTab->aCol[i].affinity = aff; } nField++; } diff --git a/test/altertab3.test b/test/altertab3.test index cb6f00de48..5f5c11b0bb 100644 --- a/test/altertab3.test +++ b/test/altertab3.test @@ -763,4 +763,27 @@ do_execsql_test 30.2 { )} } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 31.0 { + CREATE TABLE t1(ii INTEGER PRIMARY KEY, tt INTEGER, rr REAL); + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000 + ) + INSERT INTO t1 SELECT NULL, i, 5.0 FROM s; +} + +do_test 31.1 { + set pg [db one {PRAGMA page_count}] + execsql { + ALTER TABLE t1 DROP COLUMN tt; + } + set pg2 [db one {PRAGMA page_count}] + expr $pg==$pg2 +} {1} + +do_execsql_test 31.2 { + SELECT rr FROM t1 LIMIT 1 +} {5.0} + finish_test From ed517a708284b6e00b6ae5f1e3f702bbfcbd32ed Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 26 Mar 2024 18:07:39 +0000 Subject: [PATCH 0292/1030] Add extra tests to vtabL.test. FossilOrigin-Name: fe209099f5c348f1280b9b827ffbf6a6742ebdd1a23ef189445147894b1832ba --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/vtabL.test | 21 +++++++++++++++++---- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index ea43bdf8f8..8b6dfb5fc7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sexpanding\sinteger\svalues\sin\scolumns\swith\sreal\saffinity\sto\sthe\sfull\s8-byte\srepresentation\swhen\sediting\srecords\sas\spart\sof\sa\sDROP\sCOLUMN\scommand. -D 2024-03-26T11:14:52.242 +C Add\sextra\stests\sto\svtabL.test. +D 2024-03-26T18:07:39.608 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1951,7 +1951,7 @@ F test/vtabH.test 2efb5a24b0bb50796b21eca23032cfb77abfa4b0c03938e38ce5897abac404 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtabJ.test a6aef49d558af90fae10565b29501f82a95781cb4f797f2d13e2d19f9b6bc77b F test/vtabK.test 13293177528fada1235c0112db0d187d754af1355c5a39371abd365104e3afbf -F test/vtabL.test 040b9f782a3b41844f2a5c660e6a0bfd298492980c6b4e126d82113c9785cec3 +F test/vtabL.test 49ec7342e8bfcb0d6c3d2443c619f430c609c042d5d7e6ddf52def65d6d1812f F test/vtab_alter.test 736e66fb5ec7b4fee58229aa3ada2f27ec58bc58c00edae4836890c3784c6783 F test/vtab_err.test dcc8b7b9cb67522b3fe7a272c73856829dae4ab7fdb30399aea1b6981bda2b65 F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a06dc73847716c88d65651d1bf0e002002303881df1389beac884d0032eae08 -R 9f7cc1bf5356d77f08ae122347a7b675 +P a49296de0061931badaf3db6b965131a78b1c6c21b1eeb62815ea7adf767d0b3 +R 7ff7efd995047005d6aa8ecbdebb1507 U dan -Z 96694e9dd3b3c0e4acdff2534541b848 +Z ff7145a12bdc41a2553dea79acaa6e0c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8c514c694f..46f1a1149d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a49296de0061931badaf3db6b965131a78b1c6c21b1eeb62815ea7adf767d0b3 \ No newline at end of file +fe209099f5c348f1280b9b827ffbf6a6742ebdd1a23ef189445147894b1832ba \ No newline at end of file diff --git a/test/vtabL.test b/test/vtabL.test index a801481c84..0834655ffd 100644 --- a/test/vtabL.test +++ b/test/vtabL.test @@ -31,10 +31,7 @@ proc vtab_command {method args} { return {} } -do_execsql_test 1.0 { - CREATE TABLE t1(a, b); -} - +breakpoint foreach {tn cts} { 1 {SELECT 123} 2 {SELECT 123, 456} @@ -44,6 +41,8 @@ foreach {tn cts} { 6 {DROP TABLE nosuchtable} 7 {DROP TABLE x1} 8 {DROP TABLE t1} + 9 {CREATE TABLE xyz AS SELECT * FROM sqlite_schema} + 10 {CREATE TABLE xyz AS SELECT 1 AS 'col'} } { set ::create_table_sql $cts do_catchsql_test 1.$tn { @@ -51,5 +50,19 @@ foreach {tn cts} { } {1 {vtable constructor failed: x1}} } +foreach {tn cts} { + 1 {CREATE TABLE IF NOT EXISTS t1(a, b)} + 2 {CREATE TABLE ""(a, b PRIMARY KEY) WITHOUT ROWID} +} { + set ::create_table_sql $cts + execsql { DROP TABLE IF EXISTS x1 } + do_execsql_test 2.$tn.1 { + CREATE VIRTUAL TABLE x1 USING tcl(vtab_command); + } + do_execsql_test 2.$tn.2 { + SELECT a, b FROM x1 + } +} + finish_test From 6921a2d2054dcbf26c5f455dded278fac795ea5e Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 27 Mar 2024 20:34:14 +0000 Subject: [PATCH 0293/1030] Update comments in fts5.h. FossilOrigin-Name: 862945d5c432c27377e90d93d64c4655eefcc369d086eb51edef925fb3d80b57 --- ext/fts5/fts5.h | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 250d2ee7e3..551618e718 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -55,8 +55,8 @@ struct Fts5PhraseIter { ** EXTENSION API FUNCTIONS ** ** xUserData(pFts): -** Return a copy of the context pointer the extension function was -** registered with. +** Return a copy of the pUserData pointer passed to the xCreateFunction() +** API when the extension function was registered. ** ** xColumnTotalSize(pFts, iCol, pnToken): ** If parameter iCol is less than zero, set output variable *pnToken diff --git a/manifest b/manifest index 8b6dfb5fc7..0580f02c1d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\stests\sto\svtabL.test. -D 2024-03-26T18:07:39.608 +C Update\scomments\sin\sfts5.h. +D 2024-03-27T20:34:14.698 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,7 +92,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h ecba24fed7b359b3a53016bb07e411b3b4c9cdf163aa141006536423a63b611e +F ext/fts5/fts5.h 8856e11a5f0269cd346754cea0765efe8089635b80cad3222e8bfdb08cd5348a F ext/fts5/fts5Int.h defa43c0932265138ee910ca416e6baccf8b774e0f3d610e74be1ab2880e9834 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a49296de0061931badaf3db6b965131a78b1c6c21b1eeb62815ea7adf767d0b3 -R 7ff7efd995047005d6aa8ecbdebb1507 +P fe209099f5c348f1280b9b827ffbf6a6742ebdd1a23ef189445147894b1832ba +R c56763aed4d4e5080faa164bf6334faf U dan -Z ff7145a12bdc41a2553dea79acaa6e0c +Z d4f93415501168b234b57e2165e695ab # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 46f1a1149d..1b105c4bee 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe209099f5c348f1280b9b827ffbf6a6742ebdd1a23ef189445147894b1832ba \ No newline at end of file +862945d5c432c27377e90d93d64c4655eefcc369d086eb51edef925fb3d80b57 \ No newline at end of file From cfd4507c830a73dad165ec5db2ae28549f62ae9f Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 28 Mar 2024 10:58:18 +0000 Subject: [PATCH 0294/1030] Document that the order of an update hook call is unspecied vis-a-vis the final result of the operation which triggers that hook. Doc changes only. FossilOrigin-Name: 3d4b1f0791384d3e531d6757daecf67e5b873954de61f37032474e3ae23cd22b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 6 ++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 0580f02c1d..335dcd41b5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\scomments\sin\sfts5.h. -D 2024-03-27T20:34:14.698 +C Document\sthat\sthe\sorder\sof\san\supdate\shook\scall\sis\sunspecied\svis-a-vis\sthe\sfinal\sresult\sof\sthe\soperation\swhich\striggers\sthat\shook.\sDoc\schanges\sonly. +D 2024-03-28T10:58:18.871 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -752,7 +752,7 @@ F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 15a221347789e393b39e7d2d2bd102167979c95a1ce0675bb870b86a24ca6cf4 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 -F src/sqlite.h.in e9af5761aab316d52e5a5ac11b42d6a25eaaa49352e982c14f1080aab684b5c4 +F src/sqlite.h.in b5fb41b730da29d7cec58c6020afba627baf58a3dca4e30814bd674bc2a6fc86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h f8928f0397d797046396dd9d360a6af8ce6dcb48bd72ea290165b07c8c518744 @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fe209099f5c348f1280b9b827ffbf6a6742ebdd1a23ef189445147894b1832ba -R c56763aed4d4e5080faa164bf6334faf -U dan -Z d4f93415501168b234b57e2165e695ab +P 862945d5c432c27377e90d93d64c4655eefcc369d086eb51edef925fb3d80b57 +R c8b4c3bc800aa223f9c43a96ed885105 +U stephan +Z 8903ace573828f0152a9ba1563932171 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1b105c4bee..8763970a63 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -862945d5c432c27377e90d93d64c4655eefcc369d086eb51edef925fb3d80b57 \ No newline at end of file +3d4b1f0791384d3e531d6757daecf67e5b873954de61f37032474e3ae23cd22b \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 6841cf38f7..0a020d691c 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6887,6 +6887,12 @@ int sqlite3_autovacuum_pages( ** The exceptions defined in this paragraph might change in a future ** release of SQLite. ** +** Whether the update hook is invoked before or after the +** corresponding change is currently unspecified and may differ +** depending on the type of change. Do not rely on the order of the +** hook call with regards to the final result of the operation which +** triggers the hook. +** ** The update hook implementation must not do anything that will modify ** the database connection that invoked the update hook. Any actions ** to modify the database connection must be deferred until after the From 69dbd7a4e772e5f5a59409c45f29dbb038a06adc Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 30 Mar 2024 14:11:30 +0000 Subject: [PATCH 0295/1030] Make explicit that sqlite3_keyword_name()'s index is 0-based, per forum request. Doc changes only. FossilOrigin-Name: 090943dc31e7a3af5c11c1c0953cb82ae3ca07ba000189bb85deaecc76921504 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 335dcd41b5..1e6bf524c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Document\sthat\sthe\sorder\sof\san\supdate\shook\scall\sis\sunspecied\svis-a-vis\sthe\sfinal\sresult\sof\sthe\soperation\swhich\striggers\sthat\shook.\sDoc\schanges\sonly. -D 2024-03-28T10:58:18.871 +C Make\sexplicit\sthat\ssqlite3_keyword_name()'s\sindex\sis\s0-based,\sper\sforum\srequest.\sDoc\schanges\sonly. +D 2024-03-30T14:11:30.350 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -752,7 +752,7 @@ F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 15a221347789e393b39e7d2d2bd102167979c95a1ce0675bb870b86a24ca6cf4 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 -F src/sqlite.h.in b5fb41b730da29d7cec58c6020afba627baf58a3dca4e30814bd674bc2a6fc86 +F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h f8928f0397d797046396dd9d360a6af8ce6dcb48bd72ea290165b07c8c518744 @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 862945d5c432c27377e90d93d64c4655eefcc369d086eb51edef925fb3d80b57 -R c8b4c3bc800aa223f9c43a96ed885105 +P 3d4b1f0791384d3e531d6757daecf67e5b873954de61f37032474e3ae23cd22b +R 1ec9bcb0364e01dba28a12b65d50cd52 U stephan -Z 8903ace573828f0152a9ba1563932171 +Z 8fd3b1df728a4b7485ff966dda79d536 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8763970a63..a86194fdb9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3d4b1f0791384d3e531d6757daecf67e5b873954de61f37032474e3ae23cd22b \ No newline at end of file +090943dc31e7a3af5c11c1c0953cb82ae3ca07ba000189bb85deaecc76921504 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 0a020d691c..d553abb7bf 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -8363,7 +8363,7 @@ int sqlite3_test_control(int op, ...); ** The sqlite3_keyword_count() interface returns the number of distinct ** keywords understood by SQLite. ** -** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and +** The sqlite3_keyword_name(N,Z,L) interface finds the 0-based N-th keyword and ** makes *Z point to that keyword expressed as UTF8 and writes the number ** of bytes in the keyword into *L. The string that *Z points to is not ** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns From 9352cfa30b33bc88a422a05564616b5397d54a97 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 1 Apr 2024 15:38:15 +0000 Subject: [PATCH 0296/1030] Improved comments in the query planner logic that computes the cost for a particular step in a query plan. No code changes. FossilOrigin-Name: 0b2ac2cdc767db764e3ea8bbc33898cac4e1ec27fe8c9b60ce08a1785f921e6d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 21 ++++++++++++++++----- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 1e6bf524c1..4939830a71 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sexplicit\sthat\ssqlite3_keyword_name()'s\sindex\sis\s0-based,\sper\sforum\srequest.\sDoc\schanges\sonly. -D 2024-03-30T14:11:30.350 +C Improved\scomments\sin\sthe\squery\splanner\slogic\sthat\scomputes\sthe\scost\sfor\sa\nparticular\sstep\sin\sa\squery\splan.\s\sNo\scode\schanges. +D 2024-04-01T15:38:15.301 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 11a67988c3a5be2e7ee07c958998f3ad4b30dc491c0add894c2933c752415b16 +F src/where.c a15429ae9d42c7b824b9faad7e8234b006abf0a4526166dc4dfc0cc9cd2c9e6a F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3d4b1f0791384d3e531d6757daecf67e5b873954de61f37032474e3ae23cd22b -R 1ec9bcb0364e01dba28a12b65d50cd52 -U stephan -Z 8fd3b1df728a4b7485ff966dda79d536 +P 090943dc31e7a3af5c11c1c0953cb82ae3ca07ba000189bb85deaecc76921504 +R 27a9be3de32bd888ad6632e320231186 +U drh +Z 13460dee49d687f64f99bd37193c204d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a86194fdb9..3fb4e018f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -090943dc31e7a3af5c11c1c0953cb82ae3ca07ba000189bb85deaecc76921504 \ No newline at end of file +0b2ac2cdc767db764e3ea8bbc33898cac4e1ec27fe8c9b60ce08a1785f921e6d \ No newline at end of file diff --git a/src/where.c b/src/where.c index 5767b44128..cea134d0e2 100644 --- a/src/where.c +++ b/src/where.c @@ -3252,10 +3252,13 @@ static int whereLoopAddBtreeIndex( } } - /* Set rCostIdx to the cost of visiting selected rows in index. Add - ** it to pNew->rRun, which is currently set to the cost of the index - ** seek only. Then, if this is a non-covering index, add the cost of - ** visiting the rows in the main table. */ + /* Set rCostIdx to the estimated cost of visiting selected rows in the + ** index. The estimate is the sum of two values: + ** 1. The cost of doing one search-by-key to find the first matching + ** entry + ** 2. Stepping forward in the index pNew->nOut times to find all + ** additional matching entries. + */ assert( pSrc->pTab->szTabRow>0 ); if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){ /* The pProbe->szIdxRow is low for an IPK table since the interior @@ -3266,7 +3269,15 @@ static int whereLoopAddBtreeIndex( }else{ rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow; } - pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx); + rCostIdx = sqlite3LogEstAdd(rLogSize, rCostIdx); + + /* Estimate the cost of running the loop. If all data is coming + ** from the index, then this is just the cost of doing the index + ** lookup and scan. But if some data is coming out of the main table, + ** we also have to add in the cost of doing pNew->nOut searches to + ** locate the row in the main table that corresponds to the index entry. + */ + pNew->rRun = rCostIdx; if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK|WHERE_EXPRIDX))==0 ){ pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16); } From 7f7d0b19f8d2628466d8e25bbb0f7d10bfb98baf Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 2 Apr 2024 11:44:44 +0000 Subject: [PATCH 0297/1030] Add a heuristic in between the two solver() passes of the query planner that tries to prevent a very slow query plan in cases where the output row count estimate is imprecise. FossilOrigin-Name: 8018417b0143ea11535f2457bf3e4b3755717c554a17df1076425b4251b5f2c6 --- manifest | 16 +++++--- manifest.uuid | 2 +- src/where.c | 64 ++++++++++++++++++++++++++++- test/whereN.test | 103 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 177 insertions(+), 8 deletions(-) create mode 100644 test/whereN.test diff --git a/manifest b/manifest index 4939830a71..24a90e1c43 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\scomments\sin\sthe\squery\splanner\slogic\sthat\scomputes\sthe\scost\sfor\sa\nparticular\sstep\sin\sa\squery\splan.\s\sNo\scode\schanges. -D 2024-04-01T15:38:15.301 +C Add\sa\sheuristic\sin\sbetween\sthe\stwo\ssolver()\spasses\sof\sthe\squery\splanner\sthat\ntries\sto\sprevent\sa\svery\sslow\squery\splan\sin\scases\swhere\sthe\soutput\srow\scount\nestimate\sis\simprecise. +D 2024-04-02T11:44:44.648 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c a15429ae9d42c7b824b9faad7e8234b006abf0a4526166dc4dfc0cc9cd2c9e6a +F src/where.c ba9d22fda3850b508e075f8bdc4f4d4f1ff314551597a6f14842bb03aeec0d3a F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -2017,6 +2017,7 @@ F test/whereJ.test fc05e374cc9f2dc204148d6c06822c380ad388895fe97a6d335b94a26a08a F test/whereK.test 0270ab7f04ba5436fb9156d31d642a1c82727f4c4bfe5ba90d435c78cf44684a F test/whereL.test 438a397fa883b77bb6361c08a8befa41b52e9cfbe15a2a43715d122f8cfa8649 F test/whereM.test 0dbc9998783458ddcf3cc078ca7c2951d8b2677d472ecf0028f449ed327c0250 +F test/whereN.test 63a3584b71acfb6963416de82f26c6b1644abc5ca6080c76546b9246734c8803 F test/wherefault.test 6cf2a9c5712952d463d3f45ebee7f6caf400984df51a195d884cfb7eb0e837a7 F test/wherelfault.test 9012e4ef5259058b771606616bd007af5d154e64cc25fa9fd4170f6411db44e3 F test/wherelimit.test afb46397c6d7e964e6e294ba3569864a0c570fe3807afc634236c2b752372f31 @@ -2183,8 +2184,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 090943dc31e7a3af5c11c1c0953cb82ae3ca07ba000189bb85deaecc76921504 -R 27a9be3de32bd888ad6632e320231186 +P 0b2ac2cdc767db764e3ea8bbc33898cac4e1ec27fe8c9b60ce08a1785f921e6d +R bbe24560206aebee12aa3740963fd4bf +T *branch * interstage-heuristic +T *sym-interstage-heuristic * +T -sym-trunk * U drh -Z 13460dee49d687f64f99bd37193c204d +Z f6898799f068ada043c459f74f460b9b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3fb4e018f6..4593d196ec 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b2ac2cdc767db764e3ea8bbc33898cac4e1ec27fe8c9b60ce08a1785f921e6d \ No newline at end of file +8018417b0143ea11535f2457bf3e4b3755717c554a17df1076425b4251b5f2c6 \ No newline at end of file diff --git a/src/where.c b/src/where.c index cea134d0e2..fe76f2c960 100644 --- a/src/where.c +++ b/src/where.c @@ -5530,7 +5530,6 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ } } - pWInfo->nRowOut = pFrom->nRow; /* Free temporary memory and return success */ @@ -5538,6 +5537,68 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ return SQLITE_OK; } +/* +** This routine implements a heuristic designed to improve query planning. +** This routine is called in between the first and second call to +** wherePathSolver(). Hence the name "Interstage" "Heuristic". +** +** The first call to wherePathSolver() (hereafter just "solver()") computes +** the best path without regard to the order of the outputs. The second call +** to the solver() builds upon the first call to try to find an alternative +** path that satisfies the ORDER BY clause. +** +** This routine looks at the results of the first solver() run, and for +** every FROM clause term in the resulting query plan that uses an equality +** constraint against an index, disable other WhereLoops for that same +** FROM clause term that would try to do a full-table scan. This prevents +** an index search from being converted into a full-table scan in order to +** satisfy an ORDER BY clause, since even though we might get slightly better +** performance using the full-scan without sorting if the output size +** estimates are very precise, we might also get severe performance +** degradation using the full-scan if the output size estimate is too large. +** It is better to err on the side of caution. +** +** Except, if the first solver() call generated a full-table scan in an outer +** loop then stop this analysis at the first full-scan, since the second +** solver() run might try to swap that full-scan for another in order to +** get the output into the correct order. In other words, we do *not* want +** to inhibit a rewrites like this: +** +** First Solver() Second Solver() +** |-- SCAN t1 |-- SCAN t2 +** |-- SEARCH t2 `-- SEARCH t1 +** `-- SORT USING B-TREE +** +** Rather, the purpose of this routine is to inhibit rewrites such as: +** +** First Solver() Second Solver() +** |-- SEARCH t1 |-- SCAN t2 <--- bad! +** |-- SEARCH t2 `-- SEARCH t1 +** `-- SORT USING B-TREE +** +** See test cases in test/whereN.test for the real-world query that +** originally provoked this heuristic. +*/ +static SQLITE_NOINLINE void whereInterstageHeuristic(WhereInfo *pWInfo){ + int i; + for(i=0; inLevel; i++){ + WhereLoop *p = pWInfo->a[i].pWLoop; + if( p==0 ) break; + if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 ) continue; + if( (p->wsFlags & (WHERE_COLUMN_EQ|WHERE_COLUMN_NULL|WHERE_COLUMN_IN))!=0 ){ + u8 iTab = p->iTab; + WhereLoop *pLoop; + for(pLoop=pWInfo->pLoops; pLoop; pLoop=pLoop->pNextLoop){ + if( pLoop->iTab!=iTab ) continue; + if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0 ) continue; + pLoop->prereq = ALLBITS; /* Prevent 2nd solver() from using this one */ + } + }else{ + break; + } + } +} + /* ** Most queries use only a single table (they are not joins) and have ** simple == constraints against indexed fields. This routine attempts @@ -6320,6 +6381,7 @@ WhereInfo *sqlite3WhereBegin( wherePathSolver(pWInfo, 0); if( db->mallocFailed ) goto whereBeginError; if( pWInfo->pOrderBy ){ + whereInterstageHeuristic(pWInfo); wherePathSolver(pWInfo, pWInfo->nRowOut+1); if( db->mallocFailed ) goto whereBeginError; } diff --git a/test/whereN.test b/test/whereN.test new file mode 100644 index 0000000000..b9b889fa28 --- /dev/null +++ b/test/whereN.test @@ -0,0 +1,103 @@ +# 2024-04-02 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# Tests for the whereInterstageHeuristic() routine in the query planner. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix whereN + +# The following is a simplified and "sanitized" version of the original +# real-world query that brought the problem to light. +# +# The issue is a slow query. The answer is correct, but it was taking too +# much time, because it was doing a full table scan rather than an indexed +# lookup. +# +# The problem was that the query planner was overestimating the number of +# output rows. The estimated number of output rows is accurate if the +# DSNAME parameter is "ds-one". In that case, a large fraction of the rows +# in "violation" end up being output. The query planner correctly deduces +# that it is faster to do a full table scan of the large "violation" table +# to avoid the after-query sort that implements the ORDER BY clause. However, +# if the DSNAME is "ds-two", then only a few rows (about 6) are generated, +# and it is much much faster to do an indexed lookup of "violation" followed +# by a sort operation to implement ORDER BY +# +# The problem, of course, is that the query planner has no way of knowing +# in advance how many rows will be generated. The query planner tries to +# estimate a worst case, which is a large number of output rows, and it picks +# the best plan for that case. However, the plan choosen is very inefficient +# when the number of output rows is small. +# +# The whereInterstageHeuristic() routine in the query planner attempts to +# correct this by adjusting the query plan such that it avoids the very bad +# query plan for a small number of rows, at the expense of a slightly less +# efficient plan for a large number of rows. The large number of rows case +# is perhaps 5% slower with the revised plan, but the small number of +# rows case is around 100 times faster. That seems like a good tradeoff. +# +do_execsql_test 1.0 { + CREATE TABLE datasource(dsid INT, name TEXT); + INSERT INTO datasource VALUES(1,'ds-one'),(2,'ds-two'),(3,'ds-three'); + CREATE INDEX ds1 ON datasource(name, dsid); + + CREATE TABLE rule(rid INT, team_id INT, dsid INT); + WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<9) + INSERT INTO rule(rid,team_id,dsid) SELECT n, 1, 1 FROM c; + WITH RECURSIVE c(n) AS (VALUES(10) UNION ALL SELECT n+1 FROM c WHERE n<24) + INSERT INTO rule(rid,team_id,dsid) SELECT n, 2, 2 FROM c; + CREATE INDEX rule2 ON rule(dsid, rid); + + CREATE TABLE violation(vid INT, rid INT, vx BLOB); + /*** Uncomment to insert actual data + WITH src(rid, cnt) AS (VALUES(1,3586),(2,1343),(3,6505),(5,76230), + (6,740),(7,287794),(8,457),(12,1), + (14,1),(16,1),(17,1),(18,1),(19,1)) + INSERT INTO violation(vid, rid, vx) + SELECT rid*1000000+value, rid, randomblob(15) + FROM src, generate_series(1,cnt); + ***/ + CREATE INDEX v1 ON violation(rid, vid); + CREATE INDEX v2 ON violation(vid); + ANALYZE; + DELETE FROM sqlite_stat1; + DROP TABLE IF EXISTS sqlite_stat4; + INSERT INTO sqlite_stat1 VALUES + ('violation','v2','376661 1'), + ('violation','v1','376661 28974 1'), + ('rule','rule2','24 12 1'), + ('datasource','ds1','3 1 1'); + ANALYZE sqlite_schema; +} +set DSNAME ds-two ;# Only a few rows. Change to "ds-one" for many rows. +do_eqp_test 1.1 { + SELECT count(*), length(group_concat(vx)) FROM ( + SELECT V.* + FROM datasource DS, rule R, violation V + WHERE V.rid=R.rid + AND R.dsid=DS.dsid + AND DS.name=$DSNAME + ORDER BY V.vid desc + ); +} { + QUERY PLAN + |--CO-ROUTINE (subquery-xxxxxx) + | |--SEARCH DS USING COVERING INDEX ds1 (name=?) + | |--SEARCH R USING COVERING INDEX rule2 (dsid=?) + | |--SEARCH V USING INDEX v1 (rid=?) + | `--USE TEMP B-TREE FOR ORDER BY + `--SCAN (subquery-xxxxxx) +} +# ^^^^---- We want to see three SEARCH terms. No SCAN terms. +# The ORDER BY is implemented by a separate sorter pass. + +finish_test From 8ce73ce15b8f02b8e86c8a4d567dce42f40c70ba Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 2 Apr 2024 14:12:29 +0000 Subject: [PATCH 0298/1030] Fix typos in comments. Provided ".wheretrace" debugging output for the interstage heuristic module. Do omit automatic index loops in the interstage heuristic. FossilOrigin-Name: 186dcae19e249db36de15f295999cff25063b54ee3d5d481cd2ba99b6d13148e --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- src/where.c | 23 +++++++++++++++++++---- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 24a90e1c43..790c61ed9b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sheuristic\sin\sbetween\sthe\stwo\ssolver()\spasses\sof\sthe\squery\splanner\sthat\ntries\sto\sprevent\sa\svery\sslow\squery\splan\sin\scases\swhere\sthe\soutput\srow\scount\nestimate\sis\simprecise. -D 2024-04-02T11:44:44.648 +C Fix\stypos\sin\scomments.\s\sProvided\s".wheretrace"\sdebugging\soutput\sfor\sthe\ninterstage\sheuristic\smodule.\s\sDo\somit\sautomatic\sindex\sloops\sin\sthe\ninterstage\sheuristic. +D 2024-04-02T14:12:29.323 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -755,7 +755,7 @@ F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be219 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h f8928f0397d797046396dd9d360a6af8ce6dcb48bd72ea290165b07c8c518744 +F src/sqliteInt.h 170f85c5a9d6189cf9b5dd304f4d40b73a8c9762fb927f1327e8ed2cb99c06b6 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c ba9d22fda3850b508e075f8bdc4f4d4f1ff314551597a6f14842bb03aeec0d3a +F src/where.c 08ffccb5b8df523a484af2ae8593c8f571113475fe76b13360f2dfd74e117b4e F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -2184,11 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0b2ac2cdc767db764e3ea8bbc33898cac4e1ec27fe8c9b60ce08a1785f921e6d -R bbe24560206aebee12aa3740963fd4bf -T *branch * interstage-heuristic -T *sym-interstage-heuristic * -T -sym-trunk * +P 8018417b0143ea11535f2457bf3e4b3755717c554a17df1076425b4251b5f2c6 +R 9b55b3987ec7e07bd641f4ba8c80fe98 U drh -Z f6898799f068ada043c459f74f460b9b +Z 1d7be0abb1ed0f4f893f7da5731cd389 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4593d196ec..5063c5ac66 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8018417b0143ea11535f2457bf3e4b3755717c554a17df1076425b4251b5f2c6 \ No newline at end of file +186dcae19e249db36de15f295999cff25063b54ee3d5d481cd2ba99b6d13148e \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index dba64c71bd..365ff2c7f5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1156,7 +1156,7 @@ extern u32 sqlite3WhereTrace; ** 0x00000010 Display sqlite3_index_info xBestIndex calls ** 0x00000020 Range an equality scan metrics ** 0x00000040 IN operator decisions -** 0x00000080 WhereLoop cost adjustements +** 0x00000080 WhereLoop cost adjustments ** 0x00000100 ** 0x00000200 Covering index decisions ** 0x00000400 OR optimization diff --git a/src/where.c b/src/where.c index fe76f2c960..a4506602a2 100644 --- a/src/where.c +++ b/src/where.c @@ -5561,15 +5561,15 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** Except, if the first solver() call generated a full-table scan in an outer ** loop then stop this analysis at the first full-scan, since the second ** solver() run might try to swap that full-scan for another in order to -** get the output into the correct order. In other words, we do *not* want -** to inhibit a rewrites like this: +** get the output into the correct order. In other words, we allow a +** rewrite like this: ** ** First Solver() Second Solver() ** |-- SCAN t1 |-- SCAN t2 ** |-- SEARCH t2 `-- SEARCH t1 ** `-- SORT USING B-TREE ** -** Rather, the purpose of this routine is to inhibit rewrites such as: +** The purpose of this routine is to disallow rewrites such as: ** ** First Solver() Second Solver() ** |-- SEARCH t1 |-- SCAN t2 <--- bad! @@ -5581,6 +5581,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ */ static SQLITE_NOINLINE void whereInterstageHeuristic(WhereInfo *pWInfo){ int i; +#ifdef WHERETRACE_ENABLED + int once = 0; +#endif for(i=0; inLevel; i++){ WhereLoop *p = pWInfo->a[i].pWLoop; if( p==0 ) break; @@ -5590,7 +5593,19 @@ static SQLITE_NOINLINE void whereInterstageHeuristic(WhereInfo *pWInfo){ WhereLoop *pLoop; for(pLoop=pWInfo->pLoops; pLoop; pLoop=pLoop->pNextLoop){ if( pLoop->iTab!=iTab ) continue; - if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0 ) continue; + if( (pLoop->wsFlags & (WHERE_CONSTRAINT|WHERE_AUTO_INDEX))!=0 ){ + /* Auto-index and index-constrained loops allowed to remain */ + continue; + } +#ifdef WHERETRACE_ENABLED + if( sqlite3WhereTrace & 0x80 ){ + if( once==0 ){ + sqlite3DebugPrintf("Loops disabled by interstage heuristic:\n"); + once = 1; + } + sqlite3WhereLoopPrint(pLoop, &pWInfo->sWC); + } +#endif /* WHERETRACE_ENABLED */ pLoop->prereq = ALLBITS; /* Prevent 2nd solver() from using this one */ } }else{ From 307f290b329603e70d1053282a96e5536184b252 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 2 Apr 2024 21:55:45 +0000 Subject: [PATCH 0299/1030] Add an optional 3rd argument to the icu_load_collation() function that specifies the "strength" of the comparison. FossilOrigin-Name: acddbc489d5231dacf29890d1aa562da499026690f55c256a07d04a3190faacc --- ext/icu/icu.c | 37 +++++++++++++++++++++++++++++++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- test/icu.test | 18 +++++++++++++++++- 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/ext/icu/icu.c b/ext/icu/icu.c index e745ab0253..f9d9eef905 100644 --- a/ext/icu/icu.c +++ b/ext/icu/icu.c @@ -471,7 +471,7 @@ static void icuLoadCollation( UCollator *pUCollator; /* ICU library collation object */ int rc; /* Return code from sqlite3_create_collation_x() */ - assert(nArg==2); + assert(nArg==2 || nArg==3); (void)nArg; /* Unused parameter */ zLocale = (const char *)sqlite3_value_text(apArg[0]); zName = (const char *)sqlite3_value_text(apArg[1]); @@ -486,7 +486,39 @@ static void icuLoadCollation( return; } assert(p); - + if(nArg==3){ + const char *zOption = (const char*)sqlite3_value_text(apArg[2]); + static const struct { + const char *zName; + UColAttributeValue val; + } aStrength[] = { + { "PRIMARY", UCOL_PRIMARY }, + { "SECONDARY", UCOL_SECONDARY }, + { "TERTIARY", UCOL_TERTIARY }, + { "DEFAULT", UCOL_DEFAULT_STRENGTH }, + { "QUARTERNARY", UCOL_QUATERNARY }, + { "IDENTICAL", UCOL_IDENTICAL }, + }; + int i; + for(i=0; i=sizeof(aStrength)/sizeof(aStrength[0]) ){ + sqlite3_str *pStr = sqlite3_str_new(sqlite3_context_db_handle(p)); + sqlite3_str_appendf(pStr, + "unknown collation strength \"%s\" - should be one of:", + zOption); + for(i=0; i Date: Thu, 4 Apr 2024 12:36:33 +0000 Subject: [PATCH 0300/1030] Fix exception propagation when the opfs-sahpool VFS fails to initialize to address report in [forum:be0141c639|forum post be0141c639]. FossilOrigin-Name: cdb3a90055afe371962ec6c0931f1b08797aaeaab0358ef64b1cabda0a855b33 --- ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index f3664fd4b8..3f4182dacc 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -1272,7 +1272,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return poolUtil; }).catch(async (e)=>{ await thePool.removeVfs().catch(()=>{}); - return e; + throw e; }); }).catch((err)=>{ //error("rejecting promise:",err); diff --git a/manifest b/manifest index d49c515d29..b640e1905b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\soptional\s3rd\sargument\sto\sthe\sicu_load_collation()\sfunction\sthat\nspecifies\sthe\s"strength"\sof\sthe\scomparison. -D 2024-04-02T21:55:45.687 +C Fix\sexception\spropagation\swhen\sthe\sopfs-sahpool\sVFS\sfails\sto\sinitialize\sto\saddress\sreport\sin\s[forum:be0141c639|forum\spost\sbe0141c639]. +D 2024-04-04T12:36:33.682 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -612,7 +612,7 @@ F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b59 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 196ad83d36ca794e564044788c9d21b964679d63cad865f604da37c4afc9a285 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 5a430874906ff3f4a6ca69aadf0c2aaedc1bb45489b8365bff7e955a83a8d42a +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c afba6827a49151b564af5cf588a6bbd0401b16ef5cbe3269c66f676fee9ca92c @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0b2ac2cdc767db764e3ea8bbc33898cac4e1ec27fe8c9b60ce08a1785f921e6d -R c7e032bcb5236f4db4e7b2c73488ed57 -U drh -Z bc9a8cdde88480024e55380b78b92154 +P acddbc489d5231dacf29890d1aa562da499026690f55c256a07d04a3190faacc +R f4284681fd828de592cb5ab0ae30f403 +U stephan +Z 66fed09968d914b9f5c12c3e86ad8491 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a90644ab0e..f32fa06d10 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -acddbc489d5231dacf29890d1aa562da499026690f55c256a07d04a3190faacc \ No newline at end of file +cdb3a90055afe371962ec6c0931f1b08797aaeaab0358ef64b1cabda0a855b33 \ No newline at end of file From efe9500af7051c259e9564db96c900be778ff65c Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 4 Apr 2024 13:07:43 +0000 Subject: [PATCH 0301/1030] Fix test cases due to an error message change. FossilOrigin-Name: c49ec239eddde6f07f8d528cccd6224c4c80b240dc8f5c974186e3bb08afb83b --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/default.test | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index b640e1905b..4b231f8550 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sexception\spropagation\swhen\sthe\sopfs-sahpool\sVFS\sfails\sto\sinitialize\sto\saddress\sreport\sin\s[forum:be0141c639|forum\spost\sbe0141c639]. -D 2024-04-04T12:36:33.682 +C Fix\stest\scases\sdue\sto\san\serror\smessage\schange. +D 2024-04-04T13:07:43.910 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1057,7 +1057,7 @@ F test/dbpagefault.test 35f06cfb2ef100a9b19d25754e8141b9cba9b7daabd4c60fa5af93fc F test/dbstatus.test 4a4221a883025ffd39696b3d1b3910b928fb097d77e671351acb35f3aed42759 F test/dbstatus2.test f5fe0afed3fa45e57cfa70d1147606c20d2ba23feac78e9a172f2fe8ab5b78ef F test/decimal.test ef731887b43ee32ef86e1c8fddb61a40789f988332c029c601dcf2c319277e9e -F test/default.test 830fad7180cdf0e6a06e93acc0403bf73762314a639363314db5674c631b6127 +F test/default.test c7124864cded213a3f118bc7e2e26f34b7c36dfa26cf6945cc8b7f5db1191277 F test/delete.test 2686e1c98d552ef37d79ad55b17b93fe96fad9737786917ce3839767f734c48f F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P acddbc489d5231dacf29890d1aa562da499026690f55c256a07d04a3190faacc -R f4284681fd828de592cb5ab0ae30f403 -U stephan -Z 66fed09968d914b9f5c12c3e86ad8491 +P cdb3a90055afe371962ec6c0931f1b08797aaeaab0358ef64b1cabda0a855b33 +R ccb06537668742bb198e005c80e2d348 +U drh +Z 5666fcda290346432865b5fd5e238e7f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f32fa06d10..68f73f7bce 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cdb3a90055afe371962ec6c0931f1b08797aaeaab0358ef64b1cabda0a855b33 \ No newline at end of file +c49ec239eddde6f07f8d528cccd6224c4c80b240dc8f5c974186e3bb08afb83b \ No newline at end of file diff --git a/test/default.test b/test/default.test index de67f643b4..192b3d2ff3 100644 --- a/test/default.test +++ b/test/default.test @@ -135,10 +135,10 @@ reset_db do_catchsql_test default-5.1 { CREATE TABLE t1 (a,b DEFAULT(random() NOTNULL IN (RAISE(IGNORE),2,3))); INSERT INTO t1(a) VALUES(1); -} {1 {RAISE() may only be used within a trigger-program}} +} {1 {default value of column [b] is not constant}} do_catchsql_test default-5.2 { CREATE TABLE Table0 (Col0 DEFAULT (RAISE(IGNORE) ) ) ; INSERT INTO Table0 DEFAULT VALUES ; -} {1 {RAISE() may only be used within a trigger-program}} +} {1 {default value of column [Col0] is not constant}} finish_test From 634f43468605b8f53404b7838472dff52639d249 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 4 Apr 2024 13:36:48 +0000 Subject: [PATCH 0302/1030] Fix an ASAN problem in part of the test harness. No changes to SQLite itself. FossilOrigin-Name: 797cda7ddcceb140330d58892c3e73d28df72b638df00fd48f07dfcba7706c5f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test_bestindex.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4b231f8550..9947cad665 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stest\scases\sdue\sto\san\serror\smessage\schange. -D 2024-04-04T13:07:43.910 +C Fix\san\sASAN\sproblem\sin\spart\sof\sthe\stest\sharness.\s\sNo\schanges\sto\sSQLite\sitself. +D 2024-04-04T13:36:48.714 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -771,7 +771,7 @@ F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a F src/test_autoext.c 915d245e736652a219a907909bb6710f0d587871 F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 -F src/test_bestindex.c f6af1e41cb7901edafb065a8198e4a0192dd42432b642d038965be5e628dec12 +F src/test_bestindex.c 1ee3d64b49ca06a9cb8195fab04f1a0585cafc90d25a2a817caa14e7caab22e7 F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 F src/test_config.c 5fa77ee6064ba546e144c4fea870c5ede2c54314616f81485c6a9c4192100c75 @@ -2183,8 +2183,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cdb3a90055afe371962ec6c0931f1b08797aaeaab0358ef64b1cabda0a855b33 -R ccb06537668742bb198e005c80e2d348 +P c49ec239eddde6f07f8d528cccd6224c4c80b240dc8f5c974186e3bb08afb83b +R 7af8cb79e580778082df3d4aa754bb75 U drh -Z 5666fcda290346432865b5fd5e238e7f +Z e0623a1804a9fd12482c3193ee60e8ba # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 68f73f7bce..12ab17b4c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c49ec239eddde6f07f8d528cccd6224c4c80b240dc8f5c974186e3bb08afb83b \ No newline at end of file +797cda7ddcceb140330d58892c3e73d28df72b638df00fd48f07dfcba7706c5f \ No newline at end of file diff --git a/src/test_bestindex.c b/src/test_bestindex.c index 8128530b40..6b6b413950 100644 --- a/src/test_bestindex.c +++ b/src/test_bestindex.c @@ -226,7 +226,7 @@ static int tclConnect( } sqlite3_free(zCmd); - *ppVtab = &pTab->base; + *ppVtab = pTab ? &pTab->base : 0; return rc; } From 7fd9b53308d8bea8a8851fb71e6dbe0db4a73775 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 4 Apr 2024 22:53:09 +0000 Subject: [PATCH 0303/1030] Optimize sqlite3.oo1.DB.exec() for the rowMode='object' case to avoid converting the object property keys (column names) from native code to JS for each row. This speeds up large data sets considerably and addresses the report in [forum:3632183d2470617d|forum post 3632183d2470617d]. FossilOrigin-Name: 8b41ef8690001eb299f5b7182c28f5318333bff5b505e1d59d6e6f4556b1c759 --- ext/wasm/api/sqlite3-api-oo1.js | 91 ++++++++++++++++++++------------- manifest | 15 +++--- manifest.uuid | 2 +- 3 files changed, 64 insertions(+), 44 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index 160d59db5a..425b52eeca 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -433,40 +433,56 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ out.returnVal = ()=>opt.resultRows; } if(opt.callback || opt.resultRows){ - switch((undefined===opt.rowMode) - ? 'array' : opt.rowMode) { - case 'object': out.cbArg = (stmt)=>stmt.get(Object.create(null)); break; - case 'array': out.cbArg = (stmt)=>stmt.get([]); break; - case 'stmt': - if(Array.isArray(opt.resultRows)){ - toss3("exec(): invalid rowMode for a resultRows array: must", - "be one of 'array', 'object',", - "a result column number, or column name reference."); - } - out.cbArg = (stmt)=>stmt; + switch((undefined===opt.rowMode) ? 'array' : opt.rowMode) { + case 'object': + out.cbArg = (stmt,cache)=>{ + if( !cache.columnNames ) cache.columnNames = stmt.getColumnNames([]); + /* https://sqlite.org/forum/forumpost/3632183d2470617d: + conversion of rows to objects (key/val pairs) is + somewhat expensive for large data sets because of the + native-to-JS conversion of the column names. If we + instead cache the names and build objects from that + list of strings, it can run twice as fast. The + difference is not noticeable for small data sets but + becomes human-perceivable when enough rows are + involved. */ + const row = stmt.get([]); + const rv = Object.create(null); + for( const i in cache.columnNames ) rv[cache.columnNames[i]] = row[i]; + return rv; + }; + break; + case 'array': out.cbArg = (stmt)=>stmt.get([]); break; + case 'stmt': + if(Array.isArray(opt.resultRows)){ + toss3("exec(): invalid rowMode for a resultRows array: must", + "be one of 'array', 'object',", + "a result column number, or column name reference."); + } + out.cbArg = (stmt)=>stmt; + break; + default: + if(util.isInt32(opt.rowMode)){ + out.cbArg = (stmt)=>stmt.get(opt.rowMode); break; - default: - if(util.isInt32(opt.rowMode)){ - out.cbArg = (stmt)=>stmt.get(opt.rowMode); - break; - }else if('string'===typeof opt.rowMode - && opt.rowMode.length>1 - && '$'===opt.rowMode[0]){ - /* "$X": fetch column named "X" (case-sensitive!). Prior - to 2022-12-14 ":X" and "@X" were also permitted, but - having so many options is unnecessary and likely to - cause confusion. */ - const $colName = opt.rowMode.substr(1); - out.cbArg = (stmt)=>{ - const rc = stmt.get(Object.create(null))[$colName]; - return (undefined===rc) - ? toss3(capi.SQLITE_NOTFOUND, - "exec(): unknown result column:",$colName) - : rc; - }; - break; - } - toss3("Invalid rowMode:",opt.rowMode); + }else if('string'===typeof opt.rowMode + && opt.rowMode.length>1 + && '$'===opt.rowMode[0]){ + /* "$X": fetch column named "X" (case-sensitive!). Prior + to 2022-12-14 ":X" and "@X" were also permitted, but + having so many options is unnecessary and likely to + cause confusion. */ + const $colName = opt.rowMode.substr(1); + out.cbArg = (stmt)=>{ + const rc = stmt.get(Object.create(null))[$colName]; + return (undefined===rc) + ? toss3(capi.SQLITE_NOTFOUND, + "exec(): unknown result column:",$colName) + : rc; + }; + break; + } + toss3("Invalid rowMode:",opt.rowMode); } } return out; @@ -884,10 +900,15 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ and names. */) ? 0 : 1; evalFirstResult = false; if(arg.cbArg || resultRows){ + const cbArgCache = Object.create(null) + /* 2nd arg for arg.cbArg, used by (at least) row-to-object + converter */; for(; stmt.step(); stmt._lockedByExec = false){ - if(0===gotColNames++) stmt.getColumnNames(opt.columnNames); + if(0===gotColNames++){ + stmt.getColumnNames(cbArgCache.columnNames = (opt.columnNames || [])); + } stmt._lockedByExec = true; - const row = arg.cbArg(stmt); + const row = arg.cbArg(stmt,cbArgCache); if(resultRows) resultRows.push(row); if(callback && false === callback.call(opt, row, stmt)){ break; diff --git a/manifest b/manifest index e296c36245..457e113cfd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"interstage-heuristic"\sthat\sattempts\sto\savoid\swildly\sinefficient\nqueries\sthat\suse\stable\sscans\sinstead\sof\sindex\slookups\sbecause\sthe\soutput\nrow\sestimates\sare\sinaccurate. -D 2024-04-04T14:26:42.961 +C Optimize\ssqlite3.oo1.DB.exec()\sfor\sthe\srowMode='object'\scase\sto\savoid\sconverting\sthe\sobject\sproperty\skeys\s(column\snames)\sfrom\snative\scode\sto\sJS\sfor\seach\srow.\sThis\sspeeds\sup\slarge\sdata\ssets\sconsiderably\sand\saddresses\sthe\sreport\sin\s[forum:3632183d2470617d|forum\spost\s3632183d2470617d]. +D 2024-04-04T22:53:09.385 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -606,7 +606,7 @@ F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.js 2d35660c52dcb4bb16d00c56553d34e7caa6ad30083938b515e6f9aa0b312fbb -F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0 +F ext/wasm/api/sqlite3-api-oo1.js 365b3ae01a461dc974796823652ef1ecb1a9fac5df295ee1a78002cc77afb0d8 F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 @@ -2184,9 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 797cda7ddcceb140330d58892c3e73d28df72b638df00fd48f07dfcba7706c5f 186dcae19e249db36de15f295999cff25063b54ee3d5d481cd2ba99b6d13148e -R 869b12f296c2e2b0f215f1adb6cf5942 -T +closed 186dcae19e249db36de15f295999cff25063b54ee3d5d481cd2ba99b6d13148e -U drh -Z 93e4543ac83acbe7df90dc3896cd40af +P 7bf49e2c54c9f6f336416f01c0e76aaf70f1e2f3fd612232e5a33ae5dabe0900 +R 32cab23d7481e1a388944c536dd694cd +U stephan +Z 96ae2cb4464d7637da1ca6fd97c9b197 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e59021c9b1..4ea31d83a3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7bf49e2c54c9f6f336416f01c0e76aaf70f1e2f3fd612232e5a33ae5dabe0900 \ No newline at end of file +8b41ef8690001eb299f5b7182c28f5318333bff5b505e1d59d6e6f4556b1c759 \ No newline at end of file From 65a1d7a28464a62488d4771dcbdb35cafa5a4e39 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 5 Apr 2024 11:23:51 +0000 Subject: [PATCH 0304/1030] When compiling with SQLITE_ALLOW_ROWID_IN_VIEW, if the RETURNING clause of an UPDATE of a view specifies a rowid, then return NULL for the value of that rowid. dbsqlfuzz 7863696e9e5ec10b29bcf5ab2681cd6c82a78a4a. FossilOrigin-Name: c7896e88850669e18e89d44c4169d4f4a5d4b904bea6ccb2ac64f93b6d348a42 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/update.c | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 457e113cfd..51f9fbab8a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Optimize\ssqlite3.oo1.DB.exec()\sfor\sthe\srowMode='object'\scase\sto\savoid\sconverting\sthe\sobject\sproperty\skeys\s(column\snames)\sfrom\snative\scode\sto\sJS\sfor\seach\srow.\sThis\sspeeds\sup\slarge\sdata\ssets\sconsiderably\sand\saddresses\sthe\sreport\sin\s[forum:3632183d2470617d|forum\spost\s3632183d2470617d]. -D 2024-04-04T22:53:09.385 +C When\scompiling\swith\sSQLITE_ALLOW_ROWID_IN_VIEW,\sif\sthe\sRETURNING\sclause\sof\nan\sUPDATE\sof\sa\sview\sspecifies\sa\srowid,\sthen\sreturn\sNULL\sfor\sthe\svalue\sof\nthat\srowid.\s\sdbsqlfuzz\s7863696e9e5ec10b29bcf5ab2681cd6c82a78a4a. +D 2024-04-05T11:23:51.958 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -815,7 +815,7 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 -F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 +F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7bf49e2c54c9f6f336416f01c0e76aaf70f1e2f3fd612232e5a33ae5dabe0900 -R 32cab23d7481e1a388944c536dd694cd -U stephan -Z 96ae2cb4464d7637da1ca6fd97c9b197 +P 8b41ef8690001eb299f5b7182c28f5318333bff5b505e1d59d6e6f4556b1c759 +R f56441a29ebaf6b9cc2fa5b75235bdce +U drh +Z ca20487feeb5219923a08470db600847 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4ea31d83a3..58ff11c4a9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b41ef8690001eb299f5b7182c28f5318333bff5b505e1d59d6e6f4556b1c759 \ No newline at end of file +c7896e88850669e18e89d44c4169d4f4a5d4b904bea6ccb2ac64f93b6d348a42 \ No newline at end of file diff --git a/src/update.c b/src/update.c index cd7d73f3f7..b6068caa79 100644 --- a/src/update.c +++ b/src/update.c @@ -921,6 +921,9 @@ void sqlite3Update( } } if( chngRowid==0 && pPk==0 ){ +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + if( isView ) sqlite3VdbeAddOp2(v, OP_Null, 0, regOldRowid); +#endif sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid); } } From b411c4d69e1d7df018e9c313e104e973fc79d583 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 5 Apr 2024 13:56:05 +0000 Subject: [PATCH 0305/1030] Check-in [a9657c87c53c1922] is wrong: the IndexedExpr.bMaybeNullRow flag is required for virtual columns if they are part of an outer join. Add a test case (derived from dbsqlfuzz b9e65e2f110df998f1306571fae7af6c01e4d92b) to prove it. FossilOrigin-Name: 4484ec6d26b31305e31de89bdbae26344d8083a7e7de20861430d31737d9979c --- manifest | 15 ++++++++------- manifest.uuid | 2 +- src/where.c | 8 +------- test/joinH.test | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 51f9fbab8a..8b598b2633 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scompiling\swith\sSQLITE_ALLOW_ROWID_IN_VIEW,\sif\sthe\sRETURNING\sclause\sof\nan\sUPDATE\sof\sa\sview\sspecifies\sa\srowid,\sthen\sreturn\sNULL\sfor\sthe\svalue\sof\nthat\srowid.\s\sdbsqlfuzz\s7863696e9e5ec10b29bcf5ab2681cd6c82a78a4a. -D 2024-04-05T11:23:51.958 +C Check-in\s[a9657c87c53c1922]\sis\swrong:\sthe\sIndexedExpr.bMaybeNullRow\sflag\sis\nrequired\sfor\svirtual\scolumns\sif\sthey\sare\spart\sof\san\souter\sjoin.\s\sAdd\sa\ntest\scase\s(derived\sfrom\sdbsqlfuzz\sb9e65e2f110df998f1306571fae7af6c01e4d92b)\nto\sprove\sit. +D 2024-04-05T13:56:05.021 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 08ffccb5b8df523a484af2ae8593c8f571113475fe76b13360f2dfd74e117b4e +F src/where.c 9982128f010a699560fb5be37633801c7641ac3540f49db43cec878025929a0e F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -1338,7 +1338,7 @@ F test/joinC.test 1f1a602c2127f55f136e2cbd3bf2d26546614bf8cffe5902ec1ac9c07f87f2 F test/joinD.test 2ce62e7353a0702ca5e70008faf319c1d4686aa19fba34275c6d1da0e960be28 F test/joinE.test d5d182f3812771e2c0d97c9dcf5dbe4c41c8e21c82560e59358731c4a3981d6b F test/joinF.test 53dd66158806823ea680dd7543b5406af151b5aafa5cd06a7f3231cd94938127 -F test/joinH.test d5054173442fdf98260eeb6bb9751daa733b0ae6842fe50dcbd5469945b86985 +F test/joinH.test 55f69e64da74d4eca2235237f3acb657aef181e22e45daa228e35bba865e0255 F test/journal1.test c7b768041b7f494471531e17abc2f4f5ebf9e5096984f43ed17c4eb80ba34497 F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4 F test/journal3.test 7c3cf23ffc77db06601c1fcfc9743de8441cb77db9d1aa931863d94f5ffa140e @@ -2184,8 +2184,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8b41ef8690001eb299f5b7182c28f5318333bff5b505e1d59d6e6f4556b1c759 -R f56441a29ebaf6b9cc2fa5b75235bdce +P c7896e88850669e18e89d44c4169d4f4a5d4b904bea6ccb2ac64f93b6d348a42 +Q -a9657c87c53c19228a42559c82c54b504a5ad729e407e9e2c7dabcc0c949b261 +R 00fdd25fa9a3c1e58bfe6d44fd3eb812 U drh -Z ca20487feeb5219923a08470db600847 +Z d45c3b35e63ad3a95f4d8ac3c99323f3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 58ff11c4a9..0dad7c2062 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c7896e88850669e18e89d44c4169d4f4a5d4b904bea6ccb2ac64f93b6d348a42 \ No newline at end of file +4484ec6d26b31305e31de89bdbae26344d8083a7e7de20861430d31737d9979c \ No newline at end of file diff --git a/src/where.c b/src/where.c index a4506602a2..a1837b5879 100644 --- a/src/where.c +++ b/src/where.c @@ -5948,16 +5948,10 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( for(i=0; inColumn; i++){ Expr *pExpr; int j = pIdx->aiColumn[i]; - int bMaybeNullRow; if( j==XN_EXPR ){ pExpr = pIdx->aColExpr->a[i].pExpr; - testcase( pTabItem->fg.jointype & JT_LEFT ); - testcase( pTabItem->fg.jointype & JT_RIGHT ); - testcase( pTabItem->fg.jointype & JT_LTORJ ); - bMaybeNullRow = (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0; }else if( j>=0 && (pTab->aCol[j].colFlags & COLFLAG_VIRTUAL)!=0 ){ pExpr = sqlite3ColumnExpr(pTab, &pTab->aCol[j]); - bMaybeNullRow = 0; }else{ continue; } @@ -5989,7 +5983,7 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( p->iDataCur = pTabItem->iCursor; p->iIdxCur = iIdxCur; p->iIdxCol = i; - p->bMaybeNullRow = bMaybeNullRow; + p->bMaybeNullRow = (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0; if( sqlite3IndexAffinityStr(pParse->db, pIdx) ){ p->aff = pIdx->zColAff[i]; } diff --git a/test/joinH.test b/test/joinH.test index e3f979409a..908b93dee5 100644 --- a/test/joinH.test +++ b/test/joinH.test @@ -309,4 +309,36 @@ do_execsql_test 12.3 { SELECT * FROM t1 LEFT JOIN t2 ON true RIGHT JOIN t3 ON d2=e3 WHERE c2 BETWEEN NULL AND a1; } +#------------------------------------------------------------------------- +# 2024-04-05 dbsqlfuzz b9e65e2f110df998f1306571fae7af6c01e4d92b +reset_db +do_execsql_test 13.1 { + CREATE TABLE t1(a INT AS (b), b INT); + INSERT INTO t1(b) VALUES(123); + CREATE TABLE t2(a INT, c INT); + SELECT a FROM t2 NATURAL RIGHT JOIN t1; +} {123} +do_execsql_test 13.2 { + CREATE INDEX t1a ON t1(a); + SELECT a FROM t2 NATURAL RIGHT JOIN t1; +} {123} +# Further tests of the same logic (indexes on expressions +# used by RIGHT JOIN) from check-in ffe23af73fcb324d and +# forum post https://sqlite.org/forum/forumpost/9b491e1debf0b67a. +db null NULL +do_execsql_test 13.3 { + CREATE TABLE t3(a INT, b INT); + CREATE UNIQUE INDEX t3x ON t3(a, a+b); + INSERT INTO t3(a,b) VALUES(1,2),(4,8),(16,32),(4,80),(1,-300); + CREATE TABLE t4(x INT, y INT); + INSERT INTO t4(x,y) SELECT a, b FROM t3; + INSERT INTO t4(x,y) VALUES(99,99); + SELECT a1.a, sum( a1.a+a1.b ) FROM t3 AS a1 RIGHT JOIN t4 ON a=x + GROUP BY a1.a ORDER BY 1; +} {NULL NULL 1 -592 4 192 16 48} +do_execsql_test 13.4 { + SELECT sum( a1.a+a1.b ) FROM t3 AS a1 RIGHT JOIN t3 ON true + GROUP BY a1.a ORDER BY 1; +} {-1480 240 480} + finish_test From 743ae4c68b51fe56e6a269a79532224d2e45ce12 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 5 Apr 2024 20:01:28 +0000 Subject: [PATCH 0306/1030] Experimental enhancement in which expressions of the form "expr IN table" can be pushed down into subexpressions. FossilOrigin-Name: 2cbd7838fd6ffdf210f34671cd2e3e749a076a3a6f155bbe5f910a67db31c5b1 --- manifest | 22 ++++++------ manifest.uuid | 2 +- src/expr.c | 60 ++++++++++++++++++++++++++++---- src/parse.y | 4 +++ src/sqliteInt.h | 3 +- test/pushdown.test | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 157 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 8b598b2633..8fd5496617 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Check-in\s[a9657c87c53c1922]\sis\swrong:\sthe\sIndexedExpr.bMaybeNullRow\sflag\sis\nrequired\sfor\svirtual\scolumns\sif\sthey\sare\spart\sof\san\souter\sjoin.\s\sAdd\sa\ntest\scase\s(derived\sfrom\sdbsqlfuzz\sb9e65e2f110df998f1306571fae7af6c01e4d92b)\nto\sprove\sit. -D 2024-04-05T13:56:05.021 +C Experimental\senhancement\sin\swhich\sexpressions\sof\sthe\sform\s"expr\sIN\stable"\ncan\sbe\spushed\sdown\sinto\ssubexpressions. +D 2024-04-05T20:01:28.787 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c cd46ce2ebe46a30e63087dbe8aff7d6e34ba8acc8c658e8e18fcaa35f2711391 +F src/expr.c 48e6732170b5f3c07f9ebbdbe12c478e2867ea4be4361946ed26e2c8d607f7e8 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -739,7 +739,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 5bcef16094213efcc365a9d4dc4e3131f09251dc8838dce4a9e5f9764bff5b82 +F src/parse.y 67b9965a501599d5a1a4333125fab0dd230e03e28045700c9b331f7c3269bda5 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -755,7 +755,7 @@ F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be219 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 170f85c5a9d6189cf9b5dd304f4d40b73a8c9762fb927f1327e8ed2cb99c06b6 +F src/sqliteInt.h a0d0f014baafcb61f5d0a6d206d4b190644d57bb762dff2073903595653d6319 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -1510,7 +1510,7 @@ F test/printf.test 685fec5a0c5af2490ab0632775a301554361d674211d690f5bee0a97b0533 F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224cce60 F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc -F test/pushdown.test 1495a09837a1cedfc0adf07ba42dc6b83be05a2c15de331b67c39a0e22078238 +F test/pushdown.test a8472a771ff80f9652477a688a5beed40b1f6de6546ed3a38150d3b272891173 F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quickcheck.test a4b7e878cd97e46108291c409b0bf8214f29e18fddd68a42bc5c1375ad1fb80a @@ -2184,9 +2184,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c7896e88850669e18e89d44c4169d4f4a5d4b904bea6ccb2ac64f93b6d348a42 -Q -a9657c87c53c19228a42559c82c54b504a5ad729e407e9e2c7dabcc0c949b261 -R 00fdd25fa9a3c1e58bfe6d44fd3eb812 +P 4484ec6d26b31305e31de89bdbae26344d8083a7e7de20861430d31737d9979c +R 445c665a7eec3209ded422866778f161 +T *branch * pushdown-IN-table +T *sym-pushdown-IN-table * +T -sym-trunk * U drh -Z d45c3b35e63ad3a95f4d8ac3c99323f3 +Z 5ecd3bbce21aa8f702309c384d09dab0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0dad7c2062..7d0dacd7c0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4484ec6d26b31305e31de89bdbae26344d8083a7e7de20861430d31737d9979c \ No newline at end of file +2cbd7838fd6ffdf210f34671cd2e3e749a076a3a6f155bbe5f910a67db31c5b1 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index edfea3fc92..f2b252792b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2500,7 +2500,7 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ return WRC_Continue; } } -static int exprIsConst(Parse *pParse, Expr *p, int initFlag, int iCur){ +static int exprIsConst(Parse *pParse, Expr *p, int initFlag){ Walker w; w.eCode = initFlag; w.pParse = pParse; @@ -2509,7 +2509,6 @@ static int exprIsConst(Parse *pParse, Expr *p, int initFlag, int iCur){ #ifdef SQLITE_DEBUG w.xSelectCallback2 = sqlite3SelectWalkAssert2; #endif - w.u.iCur = iCur; sqlite3WalkExpr(&w, p); return w.eCode; } @@ -2529,7 +2528,7 @@ static int exprIsConst(Parse *pParse, Expr *p, int initFlag, int iCur){ ** function and on its parameters. */ int sqlite3ExprIsConstant(Parse *pParse, Expr *p){ - return exprIsConst(pParse, p, 1, 0); + return exprIsConst(pParse, p, 1); } /* @@ -2546,7 +2545,44 @@ int sqlite3ExprIsConstant(Parse *pParse, Expr *p){ ** the prepared statement starts up. See sqlite3ExprCodeRunJustOnce(). */ static int sqlite3ExprIsConstantNotJoin(Parse *pParse, Expr *p){ - return exprIsConst(pParse, p, 2, 0); + return exprIsConst(pParse, p, 2); +} + +/* +** This routine examines sub-SELECT statements as an expression is being +** walked as part of sqlite3ExprIsTableConstant() (hereafter IsTabConst()). +** Most SELECT statements will cause IsTabConst() to return false. However, +** if: +** +** (1) The SELECT is the right-hand side of an IN operator, and +** (2) Nothing in the SELECT refers to anything other than itself +** +** Then this routine causes the sub-SELECT to be bypassed, so that if +** nothing else is amiss the IsTabConst() routine can return true. +*/ +static int exprSelectWalkTableConstant(Walker *pWalker, Select *pSelect){ + int savedCursor; + assert( pSelect!=0 ); + assert( pWalker->eCode==3 || pWalker->eCode==0 ); + if( (pSelect->selFlags & SF_RhsOfIN)==0 ){ + pWalker->eCode = 0; + return WRC_Abort; + } + assert( pSelect->pSrc!=0 ); + assert( pSelect->pSrc->nSrc==1 ); + assert( pSelect->pWhere==0 ); + assert( pSelect->pGroupBy==0 ); + assert( pSelect->pHaving==0 ); + assert( pSelect->pOrderBy==0 ); + assert( pSelect->pPrior==0 ); + assert( pSelect->pNext==0 ); + assert( pSelect->pLimit==0 ); + assert( pSelect->pWith==0 ); + savedCursor = pWalker->u.iCur; + pWalker->u.iCur = pSelect->pSrc->a[0].iCursor; + sqlite3WalkExprList(pWalker, pSelect->pEList); + pWalker->u.iCur = savedCursor; + return WRC_Prune; } /* @@ -2554,9 +2590,19 @@ static int sqlite3ExprIsConstantNotJoin(Parse *pParse, Expr *p){ ** for any single row of the table with cursor iCur. In other words, the ** expression must not refer to any non-deterministic function nor any ** table other than iCur. +** +** 2024-04-05: Operators of the form "expr IN table" are now allowed, where +** "table" is the name of a table. */ -int sqlite3ExprIsTableConstant(Expr *p, int iCur){ - return exprIsConst(0, p, 3, iCur); +static int sqlite3ExprIsTableConstant(Expr *p, int iCur){ + Walker w; + w.eCode = 3; + w.pParse = 0; + w.xExprCallback = exprNodeIsConstant; + w.xSelectCallback = exprSelectWalkTableConstant; + w.u.iCur = iCur; + sqlite3WalkExpr(&w, p); + return w.eCode; } /* @@ -2713,7 +2759,7 @@ int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){ */ int sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){ assert( isInit==0 || isInit==1 ); - return exprIsConst(0, p, 4+isInit, 0); + return exprIsConst(0, p, 4+isInit); } #ifdef SQLITE_ENABLE_CURSOR_HINTS diff --git a/src/parse.y b/src/parse.y index d22c8e6fc2..7a3d637663 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1369,6 +1369,10 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] { if( E ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, E); A = sqlite3PExpr(pParse, TK_IN, A, 0); sqlite3PExprAddSelect(pParse, A, pSelect); + if( pParse->nErr==0 ){ + assert( pSelect!=0 ); + pSelect->selFlags |= SF_RhsOfIN; + } if( N ) A = sqlite3PExpr(pParse, TK_NOT, A, 0); } expr(A) ::= EXISTS LP select(Y) RP. { diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 365ff2c7f5..29acb570de 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3585,6 +3585,7 @@ struct Select { #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ #define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */ #define SF_UpdateFrom 0x10000000 /* Query originates with UPDATE FROM */ +#define SF_RhsOfIN 0x20000000 /* Right-hand-side of an IN operator */ /* True if S exists and has SF_NestedFrom */ #define IsNestedFrom(S) ((S)!=0 && ((S)->selFlags&SF_NestedFrom)!=0) @@ -5081,7 +5082,7 @@ int sqlite3ExprTruthValue(const Expr*); int sqlite3ExprIsConstant(Parse*,Expr*); int sqlite3ExprIsConstantOrFunction(Expr*, u8); int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); -int sqlite3ExprIsTableConstant(Expr*,int); +// int sqlite3ExprIsTableConstant(Expr*,int); int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int); #ifdef SQLITE_ENABLE_CURSOR_HINTS int sqlite3ExprContainsSubquery(Expr*); diff --git a/test/pushdown.test b/test/pushdown.test index 1fbe6f34cd..036fe2e2d8 100644 --- a/test/pushdown.test +++ b/test/pushdown.test @@ -227,4 +227,89 @@ do_execsql_test 5.0 { WHERE e>0; } {- - 3 4 5} + +# 2024-04-05 +# Allow push-down of operators of the form "expr IN table". +# +reset_db +do_execsql_test 6.0 { + CREATE TABLE t01(w,x,y,z); + CREATE TABLE t02(w,x,y,z); + CREATE VIEW t0(w,x,y,z) AS + SELECT w,x,y,z FROM t01 UNION ALL SELECT w,x,y,z FROM t02; + CREATE INDEX t01x ON t01(w,x,y); + CREATE INDEX t02x ON t02(w,x,y); + CREATE VIEW v1(k) AS VALUES(77),(88),(99); + CREATE TABLE k1(k); + INSERT INTO k1 SELECT * FROM v1; +} +do_eqp_test 6.1 { + WITH k(n) AS (VALUES(77),(88),(99)) + SELECT max(z) FROM t0 WHERE w=123 AND x IN k AND y BETWEEN 44 AND 55; +} { + QUERY PLAN + |--CO-ROUTINE t0 + | `--COMPOUND QUERY + | |--LEFT-MOST SUBQUERY + | | |--SEARCH t01 USING INDEX t01x (w=? AND x=? AND y>? AND y? AND y? AND y? AND y? AND y? AND y Date: Sat, 6 Apr 2024 12:19:50 +0000 Subject: [PATCH 0307/1030] Generalize pushdown to allow any uncorrelated subquery to be pushed down. FossilOrigin-Name: 87c45fb0d5f5ca5d6d1ad27bef83f294231d17d94299e1997364a7975b423e38 --- manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/expr.c | 32 +++++--------------------------- src/parse.y | 4 ---- src/resolve.c | 2 ++ src/sqliteInt.h | 3 +-- 6 files changed, 21 insertions(+), 46 deletions(-) diff --git a/manifest b/manifest index 8fd5496617..581e5d22d1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Experimental\senhancement\sin\swhich\sexpressions\sof\sthe\sform\s"expr\sIN\stable"\ncan\sbe\spushed\sdown\sinto\ssubexpressions. -D 2024-04-05T20:01:28.787 +C Generalize\spushdown\sto\sallow\sany\suncorrelated\ssubquery\sto\sbe\spushed\sdown. +D 2024-04-06T12:19:50.927 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 48e6732170b5f3c07f9ebbdbe12c478e2867ea4be4361946ed26e2c8d607f7e8 +F src/expr.c f2f4768a25d62f645d11233930c0514f5f05fdadd8150e17d64187dd5aa41e4a F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -739,7 +739,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 67b9965a501599d5a1a4333125fab0dd230e03e28045700c9b331f7c3269bda5 +F src/parse.y 5bcef16094213efcc365a9d4dc4e3131f09251dc8838dce4a9e5f9764bff5b82 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -748,14 +748,14 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 +F src/resolve.c f242e509b2ff9e31799d26ddd87f20db1124426203aa16833a694d401b50d650 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 15a221347789e393b39e7d2d2bd102167979c95a1ce0675bb870b86a24ca6cf4 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h a0d0f014baafcb61f5d0a6d206d4b190644d57bb762dff2073903595653d6319 +F src/sqliteInt.h e9ef8bb759f6ed7c41971bd8189dca3d38cc8bc69c463a6f49aaa9401857091a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2184,11 +2184,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4484ec6d26b31305e31de89bdbae26344d8083a7e7de20861430d31737d9979c -R 445c665a7eec3209ded422866778f161 -T *branch * pushdown-IN-table -T *sym-pushdown-IN-table * -T -sym-trunk * +P 2cbd7838fd6ffdf210f34671cd2e3e749a076a3a6f155bbe5f910a67db31c5b1 +R 3f1ebbef3f30ee834eac030ff4cc2f9a +T *branch * pushdown-subquery +T *sym-pushdown-subquery * +T -sym-pushdown-IN-table * U drh -Z 5ecd3bbce21aa8f702309c384d09dab0 +Z 00cc18dd5b8247ec2ec6349e18d457dd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7d0dacd7c0..b3cce22c82 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2cbd7838fd6ffdf210f34671cd2e3e749a076a3a6f155bbe5f910a67db31c5b1 \ No newline at end of file +87c45fb0d5f5ca5d6d1ad27bef83f294231d17d94299e1997364a7975b423e38 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index f2b252792b..9513e5ffd5 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2550,38 +2550,17 @@ static int sqlite3ExprIsConstantNotJoin(Parse *pParse, Expr *p){ /* ** This routine examines sub-SELECT statements as an expression is being -** walked as part of sqlite3ExprIsTableConstant() (hereafter IsTabConst()). -** Most SELECT statements will cause IsTabConst() to return false. However, -** if: -** -** (1) The SELECT is the right-hand side of an IN operator, and -** (2) Nothing in the SELECT refers to anything other than itself -** -** Then this routine causes the sub-SELECT to be bypassed, so that if -** nothing else is amiss the IsTabConst() routine can return true. +** walked as part of sqlite3ExprIsTableConstant(). Sub-SELECTs are considered +** constant as long as they are uncorrelated - meaning that they do not +** contain any terms from outer contexts. */ static int exprSelectWalkTableConstant(Walker *pWalker, Select *pSelect){ - int savedCursor; assert( pSelect!=0 ); assert( pWalker->eCode==3 || pWalker->eCode==0 ); - if( (pSelect->selFlags & SF_RhsOfIN)==0 ){ + if( (pSelect->selFlags & SF_Correlated)!=0 ){ pWalker->eCode = 0; return WRC_Abort; } - assert( pSelect->pSrc!=0 ); - assert( pSelect->pSrc->nSrc==1 ); - assert( pSelect->pWhere==0 ); - assert( pSelect->pGroupBy==0 ); - assert( pSelect->pHaving==0 ); - assert( pSelect->pOrderBy==0 ); - assert( pSelect->pPrior==0 ); - assert( pSelect->pNext==0 ); - assert( pSelect->pLimit==0 ); - assert( pSelect->pWith==0 ); - savedCursor = pWalker->u.iCur; - pWalker->u.iCur = pSelect->pSrc->a[0].iCursor; - sqlite3WalkExprList(pWalker, pSelect->pEList); - pWalker->u.iCur = savedCursor; return WRC_Prune; } @@ -2591,8 +2570,7 @@ static int exprSelectWalkTableConstant(Walker *pWalker, Select *pSelect){ ** expression must not refer to any non-deterministic function nor any ** table other than iCur. ** -** 2024-04-05: Operators of the form "expr IN table" are now allowed, where -** "table" is the name of a table. +** Enhanced on 2024-04-06: Allow pExpr to contain uncorrelated subqueries. */ static int sqlite3ExprIsTableConstant(Expr *p, int iCur){ Walker w; diff --git a/src/parse.y b/src/parse.y index 7a3d637663..d22c8e6fc2 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1369,10 +1369,6 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] { if( E ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, E); A = sqlite3PExpr(pParse, TK_IN, A, 0); sqlite3PExprAddSelect(pParse, A, pSelect); - if( pParse->nErr==0 ){ - assert( pSelect!=0 ); - pSelect->selFlags |= SF_RhsOfIN; - } if( N ) A = sqlite3PExpr(pParse, TK_NOT, A, 0); } expr(A) ::= EXISTS LP select(Y) RP. { diff --git a/src/resolve.c b/src/resolve.c index 6e0c9906a6..7378addf5d 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1349,6 +1349,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ testcase( pNC->ncFlags & NC_PartIdx ); testcase( pNC->ncFlags & NC_IdxExpr ); testcase( pNC->ncFlags & NC_GenCol ); + assert( pExpr->x.pSelect ); if( pNC->ncFlags & NC_SelfRef ){ notValidImpl(pParse, pNC, "subqueries", pExpr, pExpr); }else{ @@ -1357,6 +1358,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ assert( pNC->nRef>=nRef ); if( nRef!=pNC->nRef ){ ExprSetProperty(pExpr, EP_VarSelect); + pExpr->x.pSelect->selFlags |= SF_Correlated; } pNC->ncFlags |= NC_Subquery; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 29acb570de..a735c445e7 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3585,7 +3585,7 @@ struct Select { #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ #define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */ #define SF_UpdateFrom 0x10000000 /* Query originates with UPDATE FROM */ -#define SF_RhsOfIN 0x20000000 /* Right-hand-side of an IN operator */ +#define SF_Correlated 0x20000000 /* True if references the outer context */ /* True if S exists and has SF_NestedFrom */ #define IsNestedFrom(S) ((S)!=0 && ((S)->selFlags&SF_NestedFrom)!=0) @@ -5082,7 +5082,6 @@ int sqlite3ExprTruthValue(const Expr*); int sqlite3ExprIsConstant(Parse*,Expr*); int sqlite3ExprIsConstantOrFunction(Expr*, u8); int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); -// int sqlite3ExprIsTableConstant(Expr*,int); int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int); #ifdef SQLITE_ENABLE_CURSOR_HINTS int sqlite3ExprContainsSubquery(Expr*); From 8181cc6c105f3a0253999563d73aa541a6f9916e Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 6 Apr 2024 17:37:30 +0000 Subject: [PATCH 0308/1030] Improvements to the accurancy of the fuzzinvariants.c testing module when SQLITE_ALLOW_ROWID_IN_VIEW is defined and the test query involves rowids. FossilOrigin-Name: c6e873d4db3ef36a0d561e64ead6feada5d1654c0757b4b6e55f671c9db66469 --- manifest | 13 ++++++------- manifest.uuid | 2 +- test/fuzzinvariants.c | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 8b598b2633..3fc2321c7a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Check-in\s[a9657c87c53c1922]\sis\swrong:\sthe\sIndexedExpr.bMaybeNullRow\sflag\sis\nrequired\sfor\svirtual\scolumns\sif\sthey\sare\spart\sof\san\souter\sjoin.\s\sAdd\sa\ntest\scase\s(derived\sfrom\sdbsqlfuzz\sb9e65e2f110df998f1306571fae7af6c01e4d92b)\nto\sprove\sit. -D 2024-04-05T13:56:05.021 +C Improvements\sto\sthe\saccurancy\sof\sthe\sfuzzinvariants.c\stesting\smodule\swhen\nSQLITE_ALLOW_ROWID_IN_VIEW\sis\sdefined\sand\sthe\stest\squery\sinvolves\srowids. +D 2024-04-06T17:37:30.138 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1258,7 +1258,7 @@ F test/fuzzdata8.db 4a53b6d077c6a5c23b609d8d3ac66996fa55ba3f8d02f9b6efdd0214a767 F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc -F test/fuzzinvariants.c 4355043e98cd8555c62462fcbba91c17c6492b0b017bbbe68656d5f2208f6444 +F test/fuzzinvariants.c 9fc6810dde21e1aee20ed7a6c8ed944ffee127cf082fc48caba398fa31c762ca F test/gcfault.test 4ea410ac161e685f17b19e1f606f58514a2850e806c65b846d05f60d436c5b0d F test/gencol1.test e169bdfa11c7ed5e9f322a98a7db3afe9e66235750b68c923efee8e1876b46ec F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -2184,9 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c7896e88850669e18e89d44c4169d4f4a5d4b904bea6ccb2ac64f93b6d348a42 -Q -a9657c87c53c19228a42559c82c54b504a5ad729e407e9e2c7dabcc0c949b261 -R 00fdd25fa9a3c1e58bfe6d44fd3eb812 +P 4484ec6d26b31305e31de89bdbae26344d8083a7e7de20861430d31737d9979c +R e668dfe755aeff2fdd8b334389296750 U drh -Z d45c3b35e63ad3a95f4d8ac3c99323f3 +Z 4d6c822e968c71422e1200a444d830a0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0dad7c2062..57aabf40aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4484ec6d26b31305e31de89bdbae26344d8083a7e7de20861430d31737d9979c \ No newline at end of file +c6e873d4db3ef36a0d561e64ead6feada5d1654c0757b4b6e55f671c9db66469 \ No newline at end of file diff --git a/test/fuzzinvariants.c b/test/fuzzinvariants.c index 00b2c11742..25b35d4f6b 100644 --- a/test/fuzzinvariants.c +++ b/test/fuzzinvariants.c @@ -223,6 +223,18 @@ int fuzz_invariant( return SQLITE_OK; } +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW +/* +** Return TRUE if the i-th column of pStmt might be a ROWID value. +*/ +static int column_might_be_rowid(sqlite3_stmt *pStmt, int i){ + const char *zColName = sqlite3_column_name(pStmt, i); + if( sqlite3_strlike("%rowid%",zColName,0)==0 ) return 1; + if( sqlite3_strlike("%oid%",zColName,0)==0 ) return 1; + return 0; +} +#endif /* SQLITE_ALLOW_ROWID_IN_VIEW */ + /* ** Generate SQL used to test a statement invariant. @@ -297,9 +309,7 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ continue; } #ifdef SQLITE_ALLOW_ROWID_IN_VIEW - if( sqlite3_strlike("%rowid%",zColName,0)==0 - || sqlite3_strlike("%oid%",zColName,0)==0 - ){ + if( column_might_be_rowid(pBase,i) ){ /* ROWID values are unreliable if SQLITE_ALLOW_ROWID_IN_VIEW is used */ continue; } @@ -332,6 +342,11 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ /* ** Return true if and only if v1 and is the same as v2. +** +** When compiled with SQLITE_ALLOW_ROWID_IN_VIEW, and if either +** v1 or v2 has a column name that indicates that it is a rowid +** then a NULL value in the rowid column will compare equal to +** an integer value in the other. */ static int sameValue( sqlite3_stmt *pS1, int i1, /* Value to text on the left */ @@ -346,6 +361,20 @@ static int sameValue( || (t1==SQLITE_FLOAT && t2==SQLITE_INTEGER) ){ /* Comparison of numerics is ok */ +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW + }else + if( t1==SQLITE_INTEGER + && t2==SQLITE_NULL + && column_might_be_rowid(pS2,i2) + ){ + return 1; + }else + if( t2==SQLITE_INTEGER + && t1==SQLITE_NULL + && column_might_be_rowid(pS1,i1) + ){ + return 1; +#endif /* SQLITE_ALLOW_ROWID_IN_VIEW */ }else{ return 0; } From 6951c4977976ddca0b9e4ce75e79fc69c44dfd77 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 6 Apr 2024 18:30:09 +0000 Subject: [PATCH 0309/1030] Do not allow changes to sqlite3ExprIsTableConstant() that support pushdown of subqueries interfere with the hash-join logic. FossilOrigin-Name: 8682931f9c6b40e1b09139c10bbe932c38330b5eb0c5c84f2432ad19a6793e37 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/expr.c | 25 +++++++++++++++++++------ src/select.c | 2 +- src/sqliteInt.h | 2 +- src/where.c | 4 ++-- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index b13e8b0b82..781df2e045 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\stesting\slogic\sfixes\son\strunk\sinto\sthe\spushdown-subquery\sbranch. -D 2024-04-06T17:42:14.598 +C Do\snot\sallow\schanges\sto\ssqlite3ExprIsTableConstant()\sthat\ssupport\spushdown\sof\nsubqueries\sinterfere\swith\sthe\shash-join\slogic. +D 2024-04-06T18:30:09.352 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c f2f4768a25d62f645d11233930c0514f5f05fdadd8150e17d64187dd5aa41e4a +F src/expr.c a475049e45329a4586ce8967963784a72023cef0f5821a2265ccacb7f68e0bc6 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -750,12 +750,12 @@ F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c f242e509b2ff9e31799d26ddd87f20db1124426203aa16833a694d401b50d650 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 15a221347789e393b39e7d2d2bd102167979c95a1ce0675bb870b86a24ca6cf4 +F src/select.c 6208d6d4acafc944b9916df28e63fc4e47b922b0335d0db057f68e334b87fc8e F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h e9ef8bb759f6ed7c41971bd8189dca3d38cc8bc69c463a6f49aaa9401857091a +F src/sqliteInt.h 257a7addbdb67b1f9f514a28904ed3f574de16bd87c21570faf30600c9c39f40 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 9982128f010a699560fb5be37633801c7641ac3540f49db43cec878025929a0e +F src/where.c 09253e913dc1a93aa6e0e1a5d25a392b8fa39096cc30d230dd302264b3be0661 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87c45fb0d5f5ca5d6d1ad27bef83f294231d17d94299e1997364a7975b423e38 c6e873d4db3ef36a0d561e64ead6feada5d1654c0757b4b6e55f671c9db66469 -R 5c918916ac2b7aa6a88b463bfdfa1fb1 +P a4e1f03dcad70e828a4b56e7a332946daf84d6eae078e3ec9a248b8157a53963 +R d7462427e22b33861c511b137742aefb U drh -Z 8a9056dc314aaed8a12c375787e3cb55 +Z cfcd3c15df77757710cc4630347f7777 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6465b19d72..545d7417cd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4e1f03dcad70e828a4b56e7a332946daf84d6eae078e3ec9a248b8157a53963 \ No newline at end of file +8682931f9c6b40e1b09139c10bbe932c38330b5eb0c5c84f2432ad19a6793e37 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 9513e5ffd5..0ccb39cc6e 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2570,14 +2570,22 @@ static int exprSelectWalkTableConstant(Walker *pWalker, Select *pSelect){ ** expression must not refer to any non-deterministic function nor any ** table other than iCur. ** -** Enhanced on 2024-04-06: Allow pExpr to contain uncorrelated subqueries. +** Consider uncorrelated subqueries to be constants if the bAllowSubq +** parameter is true. */ -static int sqlite3ExprIsTableConstant(Expr *p, int iCur){ +static int sqlite3ExprIsTableConstant(Expr *p, int iCur, int bAllowSubq){ Walker w; w.eCode = 3; w.pParse = 0; w.xExprCallback = exprNodeIsConstant; - w.xSelectCallback = exprSelectWalkTableConstant; + if( bAllowSubq ){ + w.xSelectCallback = exprSelectWalkTableConstant; + }else{ + w.xSelectCallback = sqlite3SelectWalkFail; +#ifdef SQLITE_DEBUG + w.xSelectCallback2 = sqlite3SelectWalkAssert2; +#endif + } w.u.iCur = iCur; sqlite3WalkExpr(&w, p); return w.eCode; @@ -2598,7 +2606,10 @@ static int sqlite3ExprIsTableConstant(Expr *p, int iCur){ ** ** (1) pExpr cannot refer to any table other than pSrc->iCursor. ** -** (2) pExpr cannot use subqueries or non-deterministic functions. +** (2a) pExpr cannot use subqueries unless the bAllowSubq parameter is +** true and the subquery is non-correlated +** +** (2b) pExpr cannot use non-deterministic functions. ** ** (3) pSrc cannot be part of the left operand for a RIGHT JOIN. ** (Is there some way to relax this constraint?) @@ -2627,7 +2638,8 @@ static int sqlite3ExprIsTableConstant(Expr *p, int iCur){ int sqlite3ExprIsSingleTableConstraint( Expr *pExpr, /* The constraint */ const SrcList *pSrcList, /* Complete FROM clause */ - int iSrc /* Which element of pSrcList to use */ + int iSrc, /* Which element of pSrcList to use */ + int bAllowSubq /* Allow non-correlated subqueries */ ){ const SrcItem *pSrc = &pSrcList->a[iSrc]; if( pSrc->fg.jointype & JT_LTORJ ){ @@ -2652,7 +2664,8 @@ int sqlite3ExprIsSingleTableConstraint( } } } - return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor); /* rules (1), (2) */ + /* Rules (1), (2a), and (2b) handled by the following: */ + return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor, bAllowSubq); } diff --git a/src/select.c b/src/select.c index b200518518..b13aae1f9a 100644 --- a/src/select.c +++ b/src/select.c @@ -5260,7 +5260,7 @@ static int pushDownWhereTerms( } #endif - if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrcList, iSrc) ){ + if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrcList, iSrc, 1) ){ nChng++; pSubq->selFlags |= SF_PushDown; while( pSubq ){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index a735c445e7..d80a646093 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -5082,7 +5082,7 @@ int sqlite3ExprTruthValue(const Expr*); int sqlite3ExprIsConstant(Parse*,Expr*); int sqlite3ExprIsConstantOrFunction(Expr*, u8); int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); -int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int); +int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int,int); #ifdef SQLITE_ENABLE_CURSOR_HINTS int sqlite3ExprContainsSubquery(Expr*); #endif diff --git a/src/where.c b/src/where.c index a1837b5879..65b6ae2c92 100644 --- a/src/where.c +++ b/src/where.c @@ -942,7 +942,7 @@ static SQLITE_NOINLINE void constructAutomaticIndex( ** WHERE clause (or the ON clause of a LEFT join) that constrain which ** rows of the target table (pSrc) that can be used. */ if( (pTerm->wtFlags & TERM_VIRTUAL)==0 - && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, pLevel->iFrom) + && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, pLevel->iFrom, 0) ){ pPartial = sqlite3ExprAnd(pParse, pPartial, sqlite3ExprDup(pParse->db, pExpr, 0)); @@ -1211,7 +1211,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter( for(pTerm=pWInfo->sWC.a; pTermpExpr; if( (pTerm->wtFlags & TERM_VIRTUAL)==0 - && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, iSrc) + && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, iSrc, 0) ){ sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL); } From 05c6d13027db5e2f8dd6311fd6520e1ca0e7bdb9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 7 Apr 2024 10:27:18 +0000 Subject: [PATCH 0310/1030] Add comments to note the name abiguity between the MySQL push-down optimization and the WHERE-clause push-down optimization. FossilOrigin-Name: 3d5fb1ec7a0440072d6e3b957903c85d0f32b8b07207a1ef22d1a69cf5e664d1 --- manifest | 21 +++++++++++---------- manifest.uuid | 2 +- src/expr.c | 5 +++-- src/select.c | 22 +++++++++++++++++----- src/sqliteInt.h | 4 ++-- src/wherecode.c | 6 ++++++ test/pushdown.test | 28 ++++++++++++++++++++++++---- 7 files changed, 64 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 3fc2321c7a..64b52c9b24 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\saccurancy\sof\sthe\sfuzzinvariants.c\stesting\smodule\swhen\nSQLITE_ALLOW_ROWID_IN_VIEW\sis\sdefined\sand\sthe\stest\squery\sinvolves\srowids. -D 2024-04-06T17:37:30.138 +C Add\scomments\sto\snote\sthe\sname\sabiguity\sbetween\sthe\sMySQL\spush-down\noptimization\sand\sthe\sWHERE-clause\spush-down\soptimization. +D 2024-04-07T10:27:18.165 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -700,7 +700,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c cd46ce2ebe46a30e63087dbe8aff7d6e34ba8acc8c658e8e18fcaa35f2711391 +F src/expr.c 98a1cabc44fbf64e4c87a639f4399d1afde640875c16dbc2e62a37c102cca9e8 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -750,12 +750,12 @@ F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 15a221347789e393b39e7d2d2bd102167979c95a1ce0675bb870b86a24ca6cf4 +F src/select.c 3c8e1b921edfb71904b01c1ef9fb378224cdba71543342b164c7718cc8e82a44 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 170f85c5a9d6189cf9b5dd304f4d40b73a8c9762fb927f1327e8ed2cb99c06b6 +F src/sqliteInt.h a275d95f5612f2640380532e484d1f6c46a48d84ae227e6c12e36712c22b7b8a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -837,7 +837,7 @@ F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 9982128f010a699560fb5be37633801c7641ac3540f49db43cec878025929a0e F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 -F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 +F src/wherecode.c e033875570f5d65b99fdb5189e597d91c8bc34f4196089fd50e6086d174035e7 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1510,7 +1510,7 @@ F test/printf.test 685fec5a0c5af2490ab0632775a301554361d674211d690f5bee0a97b0533 F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224cce60 F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc -F test/pushdown.test 1495a09837a1cedfc0adf07ba42dc6b83be05a2c15de331b67c39a0e22078238 +F test/pushdown.test 45c6fa615f225041bbebac398d42aaaffdb6e0cdef8e542be9a8337a43d0ad95 F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quickcheck.test a4b7e878cd97e46108291c409b0bf8214f29e18fddd68a42bc5c1375ad1fb80a @@ -2184,8 +2184,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4484ec6d26b31305e31de89bdbae26344d8083a7e7de20861430d31737d9979c -R e668dfe755aeff2fdd8b334389296750 +P c6e873d4db3ef36a0d561e64ead6feada5d1654c0757b4b6e55f671c9db66469 +Q +681dfe2dd60714daf4987d45231d877f389825ab93e9bd0749391230186d6091 +R 023f47c11f43b462b0bef8a0994a0c0a U drh -Z 4d6c822e968c71422e1200a444d830a0 +Z 5c41a9ea676fc6eeb1fc7c2dc29fd70c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 57aabf40aa..1888e324a6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c6e873d4db3ef36a0d561e64ead6feada5d1654c0757b4b6e55f671c9db66469 \ No newline at end of file +3d5fb1ec7a0440072d6e3b957903c85d0f32b8b07207a1ef22d1a69cf5e664d1 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index edfea3fc92..9ec77e823b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -5031,8 +5031,9 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ if( !ExprHasProperty(pExpr, EP_Collate) ){ /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called ** "SOFT-COLLATE" that is added to constraints that are pushed down - ** from outer queries into sub-queries by the push-down optimization. - ** Clear subtypes as subtypes may not cross a subquery boundary. + ** from outer queries into sub-queries by the WHERE-clause push-down + ** optimization. Clear subtypes as subtypes may not cross a subquery + ** boundary. */ assert( pExpr->pLeft ); sqlite3ExprCode(pParse, pExpr->pLeft, target); diff --git a/src/select.c b/src/select.c index b200518518..821f9a0c4e 100644 --- a/src/select.c +++ b/src/select.c @@ -5060,6 +5060,18 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){ ** The hope is that the terms added to the inner query will make it more ** efficient. ** +** NAME AMBIGUITY +** +** This optimization is called the "WHERE-clause push-down optimization". +** +** Do not confuse this optimization with another unrelated optimization +** with a similar name: The "MySQL push-down optimization" causes WHERE +** clause terms that can be evaluated using only the index and without +** reference to the table are run first, so that if they are false, +** unnecessary table seeks are avoided. +** +** RULES +** ** Do not attempt this optimization if: ** ** (1) (** This restriction was removed on 2017-09-29. We used to @@ -5125,10 +5137,10 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){ ** (9c) There is a RIGHT JOIN (or FULL JOIN) in between the ON/USING ** clause and the subquery. ** -** Without this restriction, the push-down optimization might move -** the ON/USING filter expression from the left side of a RIGHT JOIN -** over to the right side, which leads to incorrect answers. See -** also restriction (6) in sqlite3ExprIsSingleTableConstraint(). +** Without this restriction, the WHERE-clause push-down optimization +** might move the ON/USING filter expression from the left side of a +** RIGHT JOIN over to the right side, which leads to incorrect answers. +** See also restriction (6) in sqlite3ExprIsSingleTableConstraint(). ** ** (10) The inner query is not the right-hand table of a RIGHT JOIN. ** @@ -7689,7 +7701,7 @@ int sqlite3Select( #endif assert( pItem->pSelect && (pItem->pSelect->selFlags & SF_PushDown)!=0 ); }else{ - TREETRACE(0x4000,pParse,p,("Push-down not possible\n")); + TREETRACE(0x4000,pParse,p,("WHERE-lcause push-down not possible\n")); } /* Convert unused result columns of the subquery into simple NULL diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 365ff2c7f5..d7e339d181 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1906,7 +1906,7 @@ struct sqlite3 { #define SQLITE_CursorHints 0x00000400 /* Add OP_CursorHint opcodes */ #define SQLITE_Stat4 0x00000800 /* Use STAT4 data */ /* TH3 expects this value ^^^^^^^^^^ to be 0x0000800. Don't change it */ -#define SQLITE_PushDown 0x00001000 /* The push-down optimization */ +#define SQLITE_PushDown 0x00001000 /* WHERE-clause push-down opt */ #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */ #define SQLITE_SkipScan 0x00004000 /* Skip-scans */ #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ @@ -3580,7 +3580,7 @@ struct Select { #define SF_View 0x0200000 /* SELECT statement is a view */ #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */ #define SF_UFSrcCheck 0x0800000 /* Check pSrc as required by UPDATE...FROM */ -#define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ +#define SF_PushDown 0x1000000 /* Modified by WHERE-clause push-down opt */ #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ #define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */ diff --git a/src/wherecode.c b/src/wherecode.c index 47ce36ce38..1f9c84f008 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -2474,6 +2474,12 @@ Bitmask sqlite3WhereCodeOneLoopStart( ** iLoop==3: Code all remaining expressions. ** ** An effort is made to skip unnecessary iterations of the loop. + ** + ** This optimization of causing simple query restrictions to occur before + ** more complex one is call the "push-down" optimization in MySQL. Here + ** in SQLite, the name is "MySQL push-down", since there is also another + ** totally unrelated optimization called "WHERE-clause push-down". + ** Sometimes the qualifier is omitted, resulting in an ambiguity, so beware. */ iLoop = (pIdx ? 1 : 2); do{ diff --git a/test/pushdown.test b/test/pushdown.test index 1fbe6f34cd..ac46eee8a8 100644 --- a/test/pushdown.test +++ b/test/pushdown.test @@ -1,4 +1,4 @@ -# 2017 April 29 +# 2017-04-29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: @@ -8,6 +8,26 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# +# Test cases for the push-down optimizations. +# +# +# There are two different meanings for "push-down optimization". +# +# (1) "MySQL push-down" means that WHERE clause terms that can be +# evaluated using only the index and without reference to the +# table are run first, so that if they are false, unnecessary table +# seeks are avoided. See https://sqlite.org/src/info/d7bb79ed3a40419d +# from 2017-04-29. +# +# (2) "WHERE-clause pushdown" means to push WHERE clause terms in +# outer queries down into subqueries. See +# https://sqlite.org/src/info/6df18e949d367629 from 2015-06-02. +# +# This module started out as tests for MySQL push-down only. But because +# of naming ambiguity, it has picked up test cases for WHERE-clause push-down +# over the years. +# set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -87,8 +107,8 @@ do_test 2.2 { } {three} # 2022-11-25 dbsqlfuzz crash-3a548de406a50e896c1bf7142692d35d339d697f -# Disable the push-down optimization for compound subqueries if any -# arm of the compound has an incompatible affinity. +# Disable the WHERE-clause push-down optimization for compound subqueries +# if any arm of the compound has an incompatible affinity. # reset_db do_execsql_test 3.1 { @@ -185,7 +205,7 @@ do_eqp_test 3.8 { # SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2) # 2023-05-09 https://sqlite.org/forum/forumpost/a7d4be7fb6 -# Restriction (9) on the push-down optimization. +# Restriction (9) on the WHERE-clause push-down optimization. # reset_db db null - From 1152def76ecc8bfb95a51562b6bad949471f6863 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 7 Apr 2024 18:23:30 +0000 Subject: [PATCH 0311/1030] If SQLITE_ALLOW_ROWID_IN_VIEW is set to 2, then all rowids for views return a value of NULL. FossilOrigin-Name: 0a53dde21403aa6de11c5085c16def3f95046c5629daf2675b075e4d6683ef94 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/resolve.c | 5 +++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 64b52c9b24..b806287450 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\scomments\sto\snote\sthe\sname\sabiguity\sbetween\sthe\sMySQL\spush-down\noptimization\sand\sthe\sWHERE-clause\spush-down\soptimization. -D 2024-04-07T10:27:18.165 +C If\sSQLITE_ALLOW_ROWID_IN_VIEW\sis\sset\sto\s2,\sthen\sall\srowids\sfor\sviews\sreturn\na\svalue\sof\sNULL. +D 2024-04-07T18:23:30.116 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -748,7 +748,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c eb1860b134fb044fd819c4347105c148d5aac7c6498032be2829e5cc95619b28 +F src/resolve.c 42d5d75a6ccfaf5b17d81fca64203ebce87f59702089142feed90df28dec1203 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 3c8e1b921edfb71904b01c1ef9fb378224cdba71543342b164c7718cc8e82a44 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 @@ -2184,9 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c6e873d4db3ef36a0d561e64ead6feada5d1654c0757b4b6e55f671c9db66469 -Q +681dfe2dd60714daf4987d45231d877f389825ab93e9bd0749391230186d6091 -R 023f47c11f43b462b0bef8a0994a0c0a +P 3d5fb1ec7a0440072d6e3b957903c85d0f32b8b07207a1ef22d1a69cf5e664d1 +R 0db0e0612520e2d37c806507a6db9dae U drh -Z 5c41a9ea676fc6eeb1fc7c2dc29fd70c +Z 2bafcb904067739b9429bfd86a29a830 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1888e324a6..2f2bda0775 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3d5fb1ec7a0440072d6e3b957903c85d0f32b8b07207a1ef22d1a69cf5e664d1 \ No newline at end of file +0a53dde21403aa6de11c5085c16def3f95046c5629daf2675b075e4d6683ef94 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 6e0c9906a6..86532db154 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -632,6 +632,11 @@ static int lookupName( && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom) ){ cnt = cntTab; +#if SQLITE_ALLOW_ROWID_IN_VIEW+0==2 + if( pMatch->pTab!=0 && IsView(pMatch->pTab) ){ + eNewExprOp = TK_NULL; + } +#endif if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1; pExpr->affExpr = SQLITE_AFF_INTEGER; } From fa4c4247a573b0f8f5875fba23b1c5a19562c44e Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 7 Apr 2024 18:36:32 +0000 Subject: [PATCH 0312/1030] Omit all rowid-in-view restrictions from the fuzzinvariant.c test module as they are no longer necessary, as of the previous check-in. FossilOrigin-Name: 6431538f0bb3bb8606786f3c3e5c055c4bc387098dd3bdc8a94f6fda61c47f52 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/fuzzinvariants.c | 38 -------------------------------------- 3 files changed, 7 insertions(+), 45 deletions(-) diff --git a/manifest b/manifest index b806287450..c4e5160b20 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sSQLITE_ALLOW_ROWID_IN_VIEW\sis\sset\sto\s2,\sthen\sall\srowids\sfor\sviews\sreturn\na\svalue\sof\sNULL. -D 2024-04-07T18:23:30.116 +C Omit\sall\srowid-in-view\srestrictions\sfrom\sthe\sfuzzinvariant.c\stest\smodule\nas\sthey\sare\sno\slonger\snecessary,\sas\sof\sthe\sprevious\scheck-in. +D 2024-04-07T18:36:32.081 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1258,7 +1258,7 @@ F test/fuzzdata8.db 4a53b6d077c6a5c23b609d8d3ac66996fa55ba3f8d02f9b6efdd0214a767 F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc -F test/fuzzinvariants.c 9fc6810dde21e1aee20ed7a6c8ed944ffee127cf082fc48caba398fa31c762ca +F test/fuzzinvariants.c d89b81c3bdad7b2837f8cce645d5b563ffa965f6d819ce33f0f6d82a71c6ca9a F test/gcfault.test 4ea410ac161e685f17b19e1f606f58514a2850e806c65b846d05f60d436c5b0d F test/gencol1.test e169bdfa11c7ed5e9f322a98a7db3afe9e66235750b68c923efee8e1876b46ec F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3d5fb1ec7a0440072d6e3b957903c85d0f32b8b07207a1ef22d1a69cf5e664d1 -R 0db0e0612520e2d37c806507a6db9dae +P 0a53dde21403aa6de11c5085c16def3f95046c5629daf2675b075e4d6683ef94 +R 950039d72c57e0f5f8da3387d03515aa U drh -Z 2bafcb904067739b9429bfd86a29a830 +Z decff099e336dbab63d6324042d80ad4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2f2bda0775..e1d7770bd6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a53dde21403aa6de11c5085c16def3f95046c5629daf2675b075e4d6683ef94 \ No newline at end of file +6431538f0bb3bb8606786f3c3e5c055c4bc387098dd3bdc8a94f6fda61c47f52 \ No newline at end of file diff --git a/test/fuzzinvariants.c b/test/fuzzinvariants.c index 25b35d4f6b..66475270b0 100644 --- a/test/fuzzinvariants.c +++ b/test/fuzzinvariants.c @@ -223,19 +223,6 @@ int fuzz_invariant( return SQLITE_OK; } -#ifdef SQLITE_ALLOW_ROWID_IN_VIEW -/* -** Return TRUE if the i-th column of pStmt might be a ROWID value. -*/ -static int column_might_be_rowid(sqlite3_stmt *pStmt, int i){ - const char *zColName = sqlite3_column_name(pStmt, i); - if( sqlite3_strlike("%rowid%",zColName,0)==0 ) return 1; - if( sqlite3_strlike("%oid%",zColName,0)==0 ) return 1; - return 0; -} -#endif /* SQLITE_ALLOW_ROWID_IN_VIEW */ - - /* ** Generate SQL used to test a statement invariant. ** @@ -308,12 +295,6 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ ** WHERE clause. */ continue; } -#ifdef SQLITE_ALLOW_ROWID_IN_VIEW - if( column_might_be_rowid(pBase,i) ){ - /* ROWID values are unreliable if SQLITE_ALLOW_ROWID_IN_VIEW is used */ - continue; - } -#endif for(j=0; j Date: Mon, 8 Apr 2024 06:37:19 +0000 Subject: [PATCH 0313/1030] Enhancements to the fuzzer invariant checker to turn optimizations on and off. FossilOrigin-Name: 67594481379824823105939fea2ce1fe280667f6db91735ac78b4b6164a78dab --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fuzzcheck.c | 16 +++++++++++----- test/fuzzinvariants.c | 30 ++++++++++++++++++++++++------ 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 9489e7d05e..f59889aa63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\stesting\senhancements\sinto\sthe\spushdown-subquery\sbranch. -D 2024-04-07T18:55:57.788 +C Enhancements\sto\sthe\sfuzzer\sinvariant\schecker\sto\sturn\soptimizations\son\sand\noff. +D 2024-04-08T06:37:19.669 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1246,7 +1246,7 @@ F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2 -F test/fuzzcheck.c e6a40f53ac5624aa5b7c4f31c385f09ba088d524cecc4512fd3057caeed8f530 +F test/fuzzcheck.c dc159967609d00b0cfe619e735cbbf8482570aca85711397034b0662b6c18fc7 F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1258,7 +1258,7 @@ F test/fuzzdata8.db 4a53b6d077c6a5c23b609d8d3ac66996fa55ba3f8d02f9b6efdd0214a767 F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc -F test/fuzzinvariants.c d89b81c3bdad7b2837f8cce645d5b563ffa965f6d819ce33f0f6d82a71c6ca9a +F test/fuzzinvariants.c 0729b9d8ed77ad0f8c5c7601168a707d5803087d2da030ede9057c51c809cc6c F test/gcfault.test 4ea410ac161e685f17b19e1f606f58514a2850e806c65b846d05f60d436c5b0d F test/gencol1.test e169bdfa11c7ed5e9f322a98a7db3afe9e66235750b68c923efee8e1876b46ec F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 27865e316f8dfbf4c20290cf1be3024d7518fec46655e34f3fc435e15346c63e 6431538f0bb3bb8606786f3c3e5c055c4bc387098dd3bdc8a94f6fda61c47f52 -R a6f74894c0cda8635456b45fc1556948 +P 287ff24b26a512ff7648679767e68244f6eef95df6a49c46ed1f2594030ed523 +R f668a18b739f9caf1d0ed3baa3bf6c8f U drh -Z d0677700c03f1b93b120f5cc4adf200f +Z 70cb6868aa0f914c12631462fc26d140 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c911a505d2..30cfd87b8f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -287ff24b26a512ff7648679767e68244f6eef95df6a49c46ed1f2594030ed523 \ No newline at end of file +67594481379824823105939fea2ce1fe280667f6db91735ac78b4b6164a78dab \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index e4ad1c1137..6cae348bd6 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -979,7 +979,8 @@ extern int fuzz_invariant( int iRow, /* The row number for pStmt */ int nRow, /* Total number of output rows */ int *pbCorrupt, /* IN/OUT: Flag indicating a corrupt database file */ - int eVerbosity /* How much debugging output */ + int eVerbosity, /* How much debugging output */ + unsigned int dbOpt /* Default optimization flags */ ); /* Implementation of sqlite_dbdata and sqlite_dbptr */ @@ -1031,7 +1032,12 @@ static int recoverDatabase(sqlite3 *db){ /* ** Run the SQL text */ -static int runDbSql(sqlite3 *db, const char *zSql, unsigned int *pBtsFlags){ +static int runDbSql( + sqlite3 *db, /* Run SQL on this database connection */ + const char *zSql, /* The SQL to be run */ + unsigned int *pBtsFlags, + unsigned int dbOpt /* Default optimization flags */ +){ int rc; sqlite3_stmt *pStmt; int bCorrupt = 0; @@ -1107,7 +1113,7 @@ static int runDbSql(sqlite3 *db, const char *zSql, unsigned int *pBtsFlags){ iRow++; for(iCnt=0; iCnt<99999; iCnt++){ rc = fuzz_invariant(db, pStmt, iCnt, iRow, nRow, - &bCorrupt, eVerbosity); + &bCorrupt, eVerbosity, dbOpt); if( rc==SQLITE_DONE ) break; if( rc!=SQLITE_ERROR ) g.nInvariant++; if( eVerbosity>0 ){ @@ -1330,7 +1336,7 @@ int runCombinedDbSqlInput( char cSaved = zSql[i+1]; zSql[i+1] = 0; if( sqlite3_complete(zSql+j) ){ - rc = runDbSql(cx.db, zSql+j, &btsFlags); + rc = runDbSql(cx.db, zSql+j, &btsFlags, dbOpt); j = i+1; } zSql[i+1] = cSaved; @@ -1340,7 +1346,7 @@ int runCombinedDbSqlInput( } } if( j100 ) return SQLITE_DONE; zTest = fuzz_invariant_sql(pStmt, iCnt); if( zTest==0 ) return SQLITE_DONE; + if( noOpt ){ + sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, ~dbOpt); + } rc = sqlite3_prepare_v2(db, zTest, -1, &pTestStmt, 0); + if( noOpt ){ + sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, dbOpt); + } if( rc ){ if( eVerbosity ){ printf("invariant compile failed: %s\n%s\n", @@ -212,7 +226,7 @@ int fuzz_invariant( } sqlite3_finalize(pCk); if( rc==SQLITE_DONE ){ - reportInvariantFailed(pStmt, pTestStmt, iRow); + reportInvariantFailed(pStmt, pTestStmt, iRow, dbOpt, noOpt); return SQLITE_INTERNAL; }else if( eVerbosity>0 ){ printf("invariant-error ignored due to the use of virtual tables\n"); @@ -488,13 +502,17 @@ static void printRow(sqlite3_stmt *pStmt, int iRow){ static void reportInvariantFailed( sqlite3_stmt *pOrig, /* The original query */ sqlite3_stmt *pTest, /* The alternative test query with a missing row */ - int iRow /* Row number in pOrig */ + int iRow, /* Row number in pOrig */ + unsigned int dbOpt, /* Optimization flags on pOrig */ + int noOpt /* True if opt flags inverted for pTest */ ){ int iTestRow = 0; printf("Invariant check failed on row %d.\n", iRow); - printf("Original query --------------------------------------------------\n"); + printf("Original query (opt-flags: 0x%08x) --------------------------\n", + dbOpt); printf("%s\n", sqlite3_expanded_sql(pOrig)); - printf("Alternative query -----------------------------------------------\n"); + printf("Alternative query (opt-flags: 0x%08x) -----------------------\n", + noOpt ? ~dbOpt : dbOpt); printf("%s\n", sqlite3_expanded_sql(pTest)); printf("Result row that is missing from the alternative -----------------\n"); printRow(pOrig, iRow); From 0389d5f8d0838c4b7eb415d6ce515a07aeb958d1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 8 Apr 2024 11:45:15 +0000 Subject: [PATCH 0314/1030] Fix a harmless compiler warning in the ICU extension due to [acddbc489d5231da]. FossilOrigin-Name: 3d8750e88558f8ea6a1523a5add4ccca3262e31f348b603e56ab193d81908995 --- ext/icu/icu.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/icu/icu.c b/ext/icu/icu.c index f9d9eef905..69867bfa83 100644 --- a/ext/icu/icu.c +++ b/ext/icu/icu.c @@ -499,7 +499,7 @@ static void icuLoadCollation( { "QUARTERNARY", UCOL_QUATERNARY }, { "IDENTICAL", UCOL_IDENTICAL }, }; - int i; + unsigned int i; for(i=0; i Date: Mon, 8 Apr 2024 17:55:15 +0000 Subject: [PATCH 0315/1030] Update tests in returning1.test to account for [c7896e88]. FossilOrigin-Name: c02956cd5cbf87027ba201b5d273e0efd429836ee6cabdc2f6d5b8096c876b7b --- manifest | 15 +++++++-------- manifest.uuid | 2 +- test/returning1.test | 10 +++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 739651c910..9dfb5b4e7d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sWHERE-clause\spush-down\soptimization\sso\sthat\sit\sis\sable\sto\npush\sdown\sWHERE\sclause\sterms\sthat\scontain\suncorrelated\ssubqueries. -D 2024-04-08T11:50:07.908 +C Update\stests\sin\sreturning1.test\sto\saccount\sfor\s[c7896e88]. +D 2024-04-08T17:55:15.936 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1529,7 +1529,7 @@ F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed13 F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d F test/resetdb.test 54c06f18bc832ac6d6319e5ab23d5c8dd49fdbeec7c696d791682a8006bd5fc3 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb -F test/returning1.test 3ead782eddf51f573cdd43bcbb10d1b485ac095a19a76d16c43fd159ea9b7466 +F test/returning1.test b27646c5e25431dd47cf72f525d1b2d5ad4ae14e21d9cf3d65769f05e48f64f3 F test/returningfault.test ae4c4b5e8745813287a359d9ccdb9d5c883c2e68afb18fb0767937d5de5692a4 F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa F test/rollback2.test 3f3a4e20401825017df7e7671e9f31b6de5fae5620c2b9b49917f52f8c160a8f @@ -2184,9 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3d8750e88558f8ea6a1523a5add4ccca3262e31f348b603e56ab193d81908995 67594481379824823105939fea2ce1fe280667f6db91735ac78b4b6164a78dab -R 1ffe1af0415e1a4fed09276e65c27d2f -T +closed 67594481379824823105939fea2ce1fe280667f6db91735ac78b4b6164a78dab -U drh -Z a907cc2f6ecf59760a4baca00ef3db65 +P 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940 +R 02f4dab5c53b9393812ce64cd20da4c4 +U dan +Z d5b97b3de9d6c5aa7782c9d7a19a211c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 35e356a937..df4e321c0c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940 \ No newline at end of file +c02956cd5cbf87027ba201b5d273e0efd429836ee6cabdc2f6d5b8096c876b7b \ No newline at end of file diff --git a/test/returning1.test b/test/returning1.test index 24032496ce..02743b2bdc 100644 --- a/test/returning1.test +++ b/test/returning1.test @@ -227,21 +227,21 @@ ifcapable !allow_rowid_in_view { } else { # Note: The values returned by the RETURNING clauses of the following # two statements are the rowid columns of views. These values are not - # well defined, so the INSERT returns -1, and the UPDATE returns 1, 2 - # and 3. These match the values used for new.rowid expressions, but - # not much else. + # well defined, so the INSERT returns -1, and the UPDATE returns NULL. + # These match the values used for new.rowid expressions, but not much + # else. do_catchsql_test 10.3a { INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid; } {0 -1} do_catchsql_test 10.3b { UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid; - } {0 {1 2 3}} + } {0 {{} {} {}}} do_execsql_test 10.4 { SELECT * FROM log; } { - insert -1 1234 5678 update 1 z y update 2 z y update 3 z y + insert -1 1234 5678 update {} z y update {} z y update {} z y } } From d21d5b21db209597aeaf41d0394cf70ddd62235d Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 9 Apr 2024 13:57:27 +0000 Subject: [PATCH 0316/1030] The read-only CHECK-constraint optimization of [34ddf02d3d21151b] inhibits the xfer optimization for tables with CHECK constraints. However, the xfer optimization is required for correct operation of VACUUM INTO on tables that contain generated columns. Fix this by ignoring CHECK constraints when qualifying the xfer optimization while running VACUUM. Problem reported by [forum:/forumpost/3ec177d68fe7fa2c|forum post 3ec177d68fe7fa2c]. FossilOrigin-Name: a6e26e778812c8409fca77183e24d3b70189c4d02fce10c7e74cd4ccc8c8ea97 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/insert.c | 5 ++++- test/vacuum-into.test | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 9dfb5b4e7d..8197099293 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\stests\sin\sreturning1.test\sto\saccount\sfor\s[c7896e88]. -D 2024-04-08T17:55:15.936 +C The\sread-only\sCHECK-constraint\soptimization\sof\s[34ddf02d3d21151b]\sinhibits\sthe\nxfer\soptimization\sfor\stables\swith\sCHECK\sconstraints.\s\sHowever,\sthe\sxfer\noptimization\sis\srequired\sfor\scorrect\soperation\sof\sVACUUM\sINTO\son\stables\sthat\ncontain\sgenerated\scolumns.\sFix\sthis\sby\signoring\sCHECK\sconstraints\swhen\nqualifying\sthe\sxfer\soptimization\swhile\srunning\sVACUUM.\s\sProblem\sreported\sby\n[forum:/forumpost/3ec177d68fe7fa2c|forum\spost\s3ec177d68fe7fa2c]. +D 2024-04-09T13:57:27.143 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c bc4d172b52a6167cd28797397a464c2cca9607dc047dfa0b5cf61687962e6964 +F src/insert.c 4bd7c7e54a1062dcd0214b7a6296f7194eb10fb14d3ddca1ed20b01c2a86a18c F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -1916,7 +1916,7 @@ F test/uri.test c1abaaaa28e9422d61e5f3f9cbc8ef993ec49fe802f581520731708561d49384 F test/uri2.test 9d3ba7a53ee167572d53a298ee4a5d38ec4a8fb7 F test/userauth01.test e740a2697a7b40d7c5003a7d7edaee16acd349a9 F test/utf16align.test 9fde0bb5d3a821594aa68c6829ab9c5453a084384137ebb9f6153e2d678039da -F test/vacuum-into.test 35dc6f79b563f91c61822f61797363e97fed1bf28f1f722688b98d43f1980d76 +F test/vacuum-into.test 77845cee98770c416dae9b0da6bb3229753861f2da65c11b4f9715d081712d8a F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test 9fd45ce6ce29f5614c249e03938d3567c06a9e772d4f155949f8eafe2d8af520 F test/vacuum3.test d9d9a04ee58c485b94694fd4f68cffaba49c32234fdefe1ac1a622c5e17d4ce3 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940 -R 02f4dab5c53b9393812ce64cd20da4c4 -U dan -Z d5b97b3de9d6c5aa7782c9d7a19a211c +P c02956cd5cbf87027ba201b5d273e0efd429836ee6cabdc2f6d5b8096c876b7b +R 14ee2c4095f13f5f59e64d6dfae705ab +U drh +Z 40f988c61dc13a84e5a7ab5ecd628e6c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index df4e321c0c..3f94593291 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c02956cd5cbf87027ba201b5d273e0efd429836ee6cabdc2f6d5b8096c876b7b \ No newline at end of file +a6e26e778812c8409fca77183e24d3b70189c4d02fce10c7e74cd4ccc8c8ea97 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index c126a83952..072386e656 100644 --- a/src/insert.c +++ b/src/insert.c @@ -3182,7 +3182,10 @@ static int xferOptimization( } } #ifndef SQLITE_OMIT_CHECK - if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){ + if( pDest->pCheck + && (db->mDbFlags & DBFLAG_Vacuum)==0 + && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) + ){ return 0; /* Tables have different CHECK constraints. Ticket #2252 */ } #endif diff --git a/test/vacuum-into.test b/test/vacuum-into.test index 698d65f540..d559b7fb39 100644 --- a/test/vacuum-into.test +++ b/test/vacuum-into.test @@ -26,13 +26,36 @@ ifcapable {!vacuum} { forcedelete out.db do_execsql_test vacuum-into-100 { - CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + CREATE TABLE t1( + a INTEGER PRIMARY KEY, + b ANY, + c INT AS (b+1), --- See "2024-04-09" block + CHECK( typeof(b)!='integer' OR b>a-5 ) --- comment below + ); WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100) INSERT INTO t1(a,b) SELECT x, randomblob(600) FROM c; CREATE INDEX t1b ON t1(b); DELETE FROM t1 WHERE a%2; SELECT count(*), sum(a), sum(length(b)) FROM t1; } {50 2550 30000} + +# Update 2024-04-09 for forum post eec177d68fe7fa2c. +# +# VACUUM INTO is sensitive to tables holding both generated columns +# and CHECK constraints. +# +# CHECK constraints are ignored for read-only databases in order to save +# memory (see check-in 34ddf02d3d21151b on 2014-05-21). But the xfer +# optimization normally only works if CHECK constraints match between the +# source and destination tables. So the xfer optimization was not +# working for VACUUM INTO when the source was a read-only database and the +# table held CHECK constraints. But if the table has generated columns, +# then the xfer optimization is required or else VACUUM will raise an +# error. +# +# Fix this by ignoring CHECK constraints when determining whether or not +# the xfer optimization can run while doing VACUUM. + do_execsql_test vacuum-into-110 { VACUUM main INTO 'out.db'; } {} @@ -88,11 +111,21 @@ do_catchsql_test vacuum-into-420 { # The ability to VACUUM INTO a read-only database db close +if {$tcl_platform(platform)=="windows"} { + file attributes test.db -readonly 1 +} else { + file attributes test.db -permissions 292 ;# 292 == 0444 +} sqlite3 db test.db -readonly 1 forcedelete test.db2 do_execsql_test vacuum-into-500 { VACUUM INTO 'test.db2'; } +if {$tcl_platform(platform)=="windows"} { + file attributes test.db -readonly 0 +} else { + file attributes test.db -permissions 420 ;# 420 = 0644 +} sqlite3 db2 test.db2 do_test vacuum-into-510 { db2 eval {SELECT name FROM sqlite_master ORDER BY 1} From 73a50fa42cbc2ddd1bf9e795a1407c3c746896e9 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Apr 2024 15:09:54 +0000 Subject: [PATCH 0317/1030] Avoid some performance problems in the recover extension when recovering strategically corrupted databases. FossilOrigin-Name: e66a834bbab9d71e02b70588ad4c71eae2e13b50e299b0269d488402bc4a7fc5 --- ext/recover/dbdata.c | 24 +++++++++++++++++++----- ext/recover/recovercorrupt2.test | 28 ++++++++++++++++++++++++++++ ext/recover/sqlite3recover.c | 2 +- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/ext/recover/dbdata.c b/ext/recover/dbdata.c index b6cb26ecd3..ca6371026e 100644 --- a/ext/recover/dbdata.c +++ b/ext/recover/dbdata.c @@ -494,6 +494,15 @@ static void dbdataValue( } } +/* This macro is a copy of the MX_CELL() macro in the SQLite core. Given +** a page-size, it returns the maximum number of cells that may be present +** on the page. */ +#define DBDATA_MX_CELL(pgsz) ((pgsz-8)/6) + +/* Maximum number of fields that may appear in a single record. This is +** the "hard-limit", according to comments in sqliteLimit.h. */ +#define DBDATA_MX_FIELD 32676 + /* ** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry. */ @@ -522,6 +531,9 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ assert( iOff+3+2<=pCsr->nPage ); pCsr->iCell = pTab->bPtr ? -2 : 0; pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]); + if( pCsr->nCell>DBDATA_MX_CELL(pCsr->nPage) ){ + pCsr->nCell = DBDATA_MX_CELL(pCsr->nPage); + } } if( pTab->bPtr ){ @@ -566,19 +578,19 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ if( pCsr->iCell>=pCsr->nCell ){ bNextPage = 1; }else{ + int iCellPtr = iOff + 8 + nPointer + pCsr->iCell*2; - iOff += 8 + nPointer + pCsr->iCell*2; - if( iOff>pCsr->nPage ){ + if( iCellPtr>pCsr->nPage ){ bNextPage = 1; }else{ - iOff = get_uint16(&pCsr->aPage[iOff]); + iOff = get_uint16(&pCsr->aPage[iCellPtr]); } /* For an interior node cell, skip past the child-page number */ iOff += nPointer; /* Load the "byte of payload including overflow" field */ - if( bNextPage || iOff>pCsr->nPage ){ + if( bNextPage || iOff>pCsr->nPage || iOff<=iCellPtr ){ bNextPage = 1; }else{ iOff += dbdataGetVarintU32(&pCsr->aPage[iOff], &nPayload); @@ -661,7 +673,9 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ pCsr->iField++; if( pCsr->iField>0 ){ sqlite3_int64 iType; - if( pCsr->pHdrPtr>&pCsr->pRec[pCsr->nRec] ){ + if( pCsr->pHdrPtr>=&pCsr->pRec[pCsr->nRec] + || pCsr->iField>=DBDATA_MX_FIELD + ){ bNextPage = 1; }else{ int szField = 0; diff --git a/ext/recover/recovercorrupt2.test b/ext/recover/recovercorrupt2.test index 29acc27a35..6c216308f0 100644 --- a/ext/recover/recovercorrupt2.test +++ b/ext/recover/recovercorrupt2.test @@ -524,5 +524,33 @@ do_test 7.1 { list [catch { $R finish } msg] $msg } {1 {file is not a database}} +reset_db +breakpoint +do_test 8.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +| size 8192 pagesize 4096 filename db.sqlite +| page 1 offset 0 +| 0: ac ae b3 76 74 65 20 66 6f 72 6d 61 74 20 33 00 ...vte format 3. +| 16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 02 .....@ ........ +| 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................ +| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ +| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................ +| 96: 00 2e 76 8a 0d ff ff ff 1e 0f cb 00 0f cb 00 00 ..v............. +| 4032: 00 00 00 00 00 00 00 00 00 00 00 33 01 06 17 19 ...........3.... +| 4048: 19 01 43 74 61 62 6c 65 54 61 62 6c 65 30 54 61 ..CtableTable0Ta +| 4064: 62 6c 65 30 02 43 52 45 41 54 45 20 54 41 42 4c ble0.CREATE TABL +| 4080: 45 20 54 61 62 6c 65 30 20 28 43 6f 6c 30 20 29 E Table0 (Col0 ) +| page 2 offset 4096 +| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................ +| end db.sqlite +}]} {} + +do_test 8.1 { + set R [sqlite3_recover_init db main test.db2] + catch { $R run } + list [catch { $R finish } msg] $msg +} {0 {}} + finish_test diff --git a/ext/recover/sqlite3recover.c b/ext/recover/sqlite3recover.c index c445c51793..1d858c0ab9 100644 --- a/ext/recover/sqlite3recover.c +++ b/ext/recover/sqlite3recover.c @@ -1189,7 +1189,7 @@ static int recoverWriteSchema1(sqlite3_recover *p){ if( bTable && !bVirtual ){ if( SQLITE_ROW==sqlite3_step(pTblname) ){ const char *zTbl = (const char*)sqlite3_column_text(pTblname, 0); - recoverAddTable(p, zTbl, iRoot); + if( zTbl ) recoverAddTable(p, zTbl, iRoot); } recoverReset(p, pTblname); } diff --git a/manifest b/manifest index 8197099293..0fa7d973a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sread-only\sCHECK-constraint\soptimization\sof\s[34ddf02d3d21151b]\sinhibits\sthe\nxfer\soptimization\sfor\stables\swith\sCHECK\sconstraints.\s\sHowever,\sthe\sxfer\noptimization\sis\srequired\sfor\scorrect\soperation\sof\sVACUUM\sINTO\son\stables\sthat\ncontain\sgenerated\scolumns.\sFix\sthis\sby\signoring\sCHECK\sconstraints\swhen\nqualifying\sthe\sxfer\soptimization\swhile\srunning\sVACUUM.\s\sProblem\sreported\sby\n[forum:/forumpost/3ec177d68fe7fa2c|forum\spost\s3ec177d68fe7fa2c]. -D 2024-04-09T13:57:27.143 +C Avoid\ssome\sperformance\sproblems\sin\sthe\srecover\sextension\swhen\srecovering\sstrategically\scorrupted\sdatabases. +D 2024-04-09T15:09:54.458 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -478,13 +478,13 @@ F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69 F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055 -F ext/recover/dbdata.c b7746c2ec801b453840831311be4b31f8c8f9dd97791060a69bbf12392c78949 +F ext/recover/dbdata.c d2e00d3cac74319c9c6def2e56ab2146b4f4ba5d820ab275e8da24e9766c247e F ext/recover/recover1.test c484d01502239f11b61f23c1cee9f5dd19fa17617f8974e42e74d64639c524cf F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a F ext/recover/recoverbuild.test c74170e0f7b02456af41838afeb5353fdb985a48cc2331d661bbabbca7c6b8e3 F ext/recover/recoverclobber.test 3ba6c0c373c5c63d17e82eced64c05c57ccaf26c1abe1ca7141334022a79f32e F ext/recover/recovercorrupt.test 64c081ad1200ae77b447da99eb724785d6bf71715f394543dc7689642e92bf49 -F ext/recover/recovercorrupt2.test b9b974f006340a1300b5a7e687bd6097c5238498181c6f92d87406a77ece430b +F ext/recover/recovercorrupt2.test 1418f1710debc24ff38276cedfcea234beb37a34205708e7e3e6d76cc4a979db F ext/recover/recoverfault.test 9d9f88eeb222615a25e7514f234c950d46bee20d24cd8db49d8fff8d650dcfe1 F ext/recover/recoverfault2.test 730e7371bcda769554d15460cb23126abba1be8eca9539ccabf63623e7bb7e09 F ext/recover/recoverold.test 68db3d6f85dd2b98e785b6c4da4f5eea4bbe52ccf6674d9a94c7506dc92596aa @@ -492,7 +492,7 @@ F ext/recover/recoverpgsz.test 3658ab8e68475b1bb87d6af88baa04551c84b73280a566a1b F ext/recover/recoverrowid.test f948bf4024a5f41b0e21b8af80c60564c5b5d78c05a8d64fc00787715ff9f45f F ext/recover/recoverslowidx.test 5205a9742dd9490ee99950dabb622307355ef1662dea6a3a21030057bfd81411 F ext/recover/recoversql.test e66d01f95302a223bcd3fd42b5ee58dc2b53d70afa90b0d00e41e4b8eab20486 -F ext/recover/sqlite3recover.c e6eb20c469bcdb96f297f2241860bccabf9f036bfa7f3d47bcc6ca1191b108dc +F ext/recover/sqlite3recover.c 65ef0f56301a16c0536c9839fb7e23540c9c4f75da0afe3b7b4d163c8f624404 F ext/recover/sqlite3recover.h 011c799f02deb70ab685916f6f538e6bb32c4e0025e79bfd0e24ff9c74820959 F ext/recover/test_recover.c fd871a40f2238022bedcbdf3cb493b91225edaa94d6ae8892af97a10e7ccc4ba F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c02956cd5cbf87027ba201b5d273e0efd429836ee6cabdc2f6d5b8096c876b7b -R 14ee2c4095f13f5f59e64d6dfae705ab -U drh -Z 40f988c61dc13a84e5a7ab5ecd628e6c +P a6e26e778812c8409fca77183e24d3b70189c4d02fce10c7e74cd4ccc8c8ea97 +R b9c21ffc9d4065568ea5ca672bfa94a1 +U dan +Z a2100870dc1c15edbdbfdff1cdb0d2d0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3f94593291..e73f4c80e2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a6e26e778812c8409fca77183e24d3b70189c4d02fce10c7e74cd4ccc8c8ea97 \ No newline at end of file +e66a834bbab9d71e02b70588ad4c71eae2e13b50e299b0269d488402bc4a7fc5 \ No newline at end of file From 495ce22d49a8be9df2753b1ab33b354be2066a20 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Apr 2024 19:23:18 +0000 Subject: [PATCH 0318/1030] Fix a "shift exponent is too large" usan error that could occur in the fts3 snippet() function when a query phrase contains more than 64 tokens. FossilOrigin-Name: 6d2c7ac4ecfc1ec408cb1820985a70650d7cc5613b4b8fd1829f68ea48fce6a3 --- ext/fts3/fts3_snippet.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fts3snippet2.test | 11 +++++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 227c5f00f6..f6caabf4c9 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -446,7 +446,7 @@ static void fts3SnippetDetails( } mCover |= mPhrase; - for(j=0; jnToken; j++){ + for(j=0; jnToken && jnSnippet; j++){ mHighlight |= (mPos>>j); } diff --git a/manifest b/manifest index 0fa7d973a9..764ffbd97a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\ssome\sperformance\sproblems\sin\sthe\srecover\sextension\swhen\srecovering\sstrategically\scorrupted\sdatabases. -D 2024-04-09T15:09:54.458 +C Fix\sa\s"shift\sexponent\sis\stoo\slarge"\susan\serror\sthat\scould\soccur\sin\sthe\sfts3\ssnippet()\sfunction\swhen\sa\squery\sphrase\scontains\smore\sthan\s64\stokens. +D 2024-04-09T19:23:18.637 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -74,7 +74,7 @@ F ext/fts3/fts3_hash.c 8b6e31bfb0844c27dc6092c2620bdb1fca17ed613072db057d96952c6 F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c 305ce7fb6036484085b5556a9c8e62acdc7763f0f4cdf5fd538212a9f3720116 F ext/fts3/fts3_porter.c e19807ce0ae31c1c6e9898e89ecc93183d7ec224ea101af039722a4f49e5f2b8 -F ext/fts3/fts3_snippet.c 4d6523e3eddeb7b46e7a82b3476a0a86a0c04821e0e2b8dd40f45ee28057cb13 +F ext/fts3/fts3_snippet.c 610328fe128c047c6b0eba77768982ccf3933daae095d497949a75c9dfd47409 F ext/fts3/fts3_term.c 845f0e2456b1be42f7f1bec1da1dfc05bc347531eff90775ffc6698902c281de F ext/fts3/fts3_test.c d8d7b2734f894e8a489987447658e374cdd3a3bc8575c401decf1911cb7c6454 F ext/fts3/fts3_tokenize_vtab.c 7fd9ef364f257b97218b9c331f2378e307375c592f70fd541f714e747d944962 @@ -1200,7 +1200,7 @@ F test/fts3rank.test cd99bc83a3c923c8d52afd90d86979cf05fc41849f892faeac3988055ef F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0 F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e F test/fts3snippet.test 0887196d67cffbe365edde535b95ecc642a532ce8551ccd9a73aab5999c3ffae -F test/fts3snippet2.test e79afeb1f673713f96d7fc5655726081975399d11e659d15553207be43301dc4 +F test/fts3snippet2.test 03f6738ab3897bea2ba6be424a0613872e167acbf37a66200d655d737b470f65 F test/fts3sort.test ed34c716a11cc2009a35210e84ad5f9c102362ca F test/fts3tok1.test a663f4cac22a9505400bc22aacb818d7055240409c28729669ea7d4cc2120d15 F test/fts3tok_err.test 52273cd193b9036282f7bacb43da78c6be87418d @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a6e26e778812c8409fca77183e24d3b70189c4d02fce10c7e74cd4ccc8c8ea97 -R b9c21ffc9d4065568ea5ca672bfa94a1 +P e66a834bbab9d71e02b70588ad4c71eae2e13b50e299b0269d488402bc4a7fc5 +R 75450b3380949a2b13147c3a28eab747 U dan -Z a2100870dc1c15edbdbfdff1cdb0d2d0 +Z 0a239b81f481c07e165698bd6a5a4da2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e73f4c80e2..71eaeff0e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e66a834bbab9d71e02b70588ad4c71eae2e13b50e299b0269d488402bc4a7fc5 \ No newline at end of file +6d2c7ac4ecfc1ec408cb1820985a70650d7cc5613b4b8fd1829f68ea48fce6a3 \ No newline at end of file diff --git a/test/fts3snippet2.test b/test/fts3snippet2.test index 607b01e0f8..f55a5f203a 100644 --- a/test/fts3snippet2.test +++ b/test/fts3snippet2.test @@ -55,5 +55,16 @@ do_execsql_test 2.2 { '(def AND (one NEAR abc)) OR one' } {one} +#------------------------------------------------------------------------- + +do_execsql_test 3.0 { +CREATE VIRTUAL TABLE f USING fts3(a,b); +INSERT INTO f VALUES (101,x'056522650565056505650d051e056505650565286505650565056505056505650565056505650565056505650565056505650565056505656505650565056505650d05650505656505650565ef65056505844c746e65650565056505650565056505650565056505650565058405800565056505650565056505651e650565056505650565056505650d056505056565056505650565056505840580056505650565056f05650565056505650565056505650565050565056505640565056505650565056505651e05650565056505650565056505650505656565056505650565056505651e0565056505650565056505650565052265056505650569056505650565056505650565056505650565056505650500406505650565056505650565056505000101e5c501014b010101c501c5c501010101f5010201010101014101017373737373737373737373737373737373737373737373737373737330737373737373737373737373737365056505650d051e05650565056528056505650d05650505656505650565650565056505650565056505e505650565056505656505650565056505650d05650505656505650565ef65056505844c746e65650565056505650565056505650565056505650565058405800565056505650565056505651e650565056505650565056505650d056505056565056505650565056505840580056505650565286505c705650565050565059494949494949494949494949494949494949494949494949494949494949494949494650565056505650565056505650565056505650565056505656505650565056505650d05650505656505650565ef650565058405056505650565056505650565056505650565056505650565058405800565056505650565056505651e650565056505650565056505650d056505056565056505650565056505840580056505650565056505650565056505650505650565056505650565056505650565056500000000000000000000000000000000000000000000000000000000000000000565056505656505650565056505650d056500000000000000000000000000000000000000000000000000000000000000000100000000000000ed0000000000ffffffffffffffffffffff0007ffffff0001c5c50001c5c50001c5c50001c5c50001c5c50001c5c50001e5c50001c5c50001c5c50001c5c50001c5c50001c5c5000100000014720000000000000016dac5c50001c5c50001c5c50001c5c50001c5c50001c5c50d0505656505650565ef650565058405056505650565056505650565056505650565056505650565058405800465056505650565056505651e650565056505650565056505650d05650505656505650565050565650584058005650565056505650565056505650565056522650565056505650d051e056505650561286505c70565056505056505650565056505650565056505650565056505650565056505656505650565056505650d05650505656505650565ef650565058405056505650565056505650565056505650565056505650565058405800565056505650565056505651e650565056505650565056505650d056505056565056505650565056505840580056505650565056505650565056505650565226505737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373733a73737373737373737373737373737373737373737373737373737373737373737373737373737373737c7373737365056505650d051e05650565056528650565056505650505650565056505650565056505650565056505e505650565056505656505650565056505650d05650505656505650565ef65056505'); +} + +do_execsql_test 3.1 { + SELECT length(snippet(f)) FROM f WHERE b MATCH x'0565056505650565056505650565056505650565058405800565056505650565056505651e650565056505650565056505650d056505056565056505650565056505840580056505650565056505650565056505650565056505650565050565056505640565056505650565056505651e05650565056522650565056505650d051e056505650565286505650565056505056505650565056505650565056505650565056505650565056505656505650565056505650d05650505656505650565ef65056505844c746e65650565056505650565056505650565056505650565058405800565056505650565056505651e650565056505650565056505650d056505056565056505650565056505840580056505650565056f05650565056505650565056505650565050565056505640565056505650565056505651e05650565056505650565056505650505656565056505650565056505651e0565056505650565056505650565052265056505650569056505650565056505650565056505650565056505650500406505650565056505650565056505000101e5c501014b010101c501c5c501010101f50102010101010141010141010001017bf15905000000000017'; +} {192} + set sqlite_fts3_enable_parentheses 0 finish_test From b6d108f0b37a0fcda58647cfb75d18909a496d77 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Apr 2024 19:08:12 +0000 Subject: [PATCH 0319/1030] Fix handling of the SQLITE_OMIT_WAL check in one place. Resolves [forum:87cc13302de160eb|forum post 87cc13302de160eb]. FossilOrigin-Name: 5dae6e6df4921f42e45c6c8de40853ab63f53a4bd1d9088a8cdac957ce62f196 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 764ffbd97a..eab5ebd169 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\s"shift\sexponent\sis\stoo\slarge"\susan\serror\sthat\scould\soccur\sin\sthe\sfts3\ssnippet()\sfunction\swhen\sa\squery\sphrase\scontains\smore\sthan\s64\stokens. -D 2024-04-09T19:23:18.637 +C Fix\shandling\sof\sthe\sSQLITE_OMIT_WAL\scheck\sin\sone\splace.\sResolves\s[forum:87cc13302de160eb|forum\spost\s87cc13302de160eb]. +D 2024-04-11T19:08:12.217 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -737,7 +737,7 @@ F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d87210 F src/os_unix.c 6227cbc4ac93046f121436886cf3712da6f4e2082af6314f976eeae1d86b794a F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c ff60e98138d2499082ac6230f01ac508aba545315debccfca2fd6042f5f10fcd +F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a F src/parse.y 5bcef16094213efcc365a9d4dc4e3131f09251dc8838dce4a9e5f9764bff5b82 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e66a834bbab9d71e02b70588ad4c71eae2e13b50e299b0269d488402bc4a7fc5 -R 75450b3380949a2b13147c3a28eab747 -U dan -Z 0a239b81f481c07e165698bd6a5a4da2 +P 6d2c7ac4ecfc1ec408cb1820985a70650d7cc5613b4b8fd1829f68ea48fce6a3 +R 0071938b1b4e5105037f1334ca733633 +U stephan +Z d6eaf14882bbc596d43b8bd29ecbee42 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 71eaeff0e3..4d8c2440ec 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d2c7ac4ecfc1ec408cb1820985a70650d7cc5613b4b8fd1829f68ea48fce6a3 \ No newline at end of file +5dae6e6df4921f42e45c6c8de40853ab63f53a4bd1d9088a8cdac957ce62f196 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 37588f0b25..268dc7db31 100644 --- a/src/pager.c +++ b/src/pager.c @@ -7087,7 +7087,7 @@ sqlite3_file *sqlite3PagerFile(Pager *pPager){ ** This will be either the rollback journal or the WAL file. */ sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){ -#if SQLITE_OMIT_WAL +#ifdef SQLITE_OMIT_WAL return pPager->jfd; #else return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd; From c494fdb580bc7c738a3a53be1ad2fd2ca3aa08e5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 12 Apr 2024 02:57:52 +0000 Subject: [PATCH 0320/1030] Mark the BTree cell overflow cache as invalid whenever the rowid goes invalid. FossilOrigin-Name: 74c9e19c92c887012aebbe96450f6ed7a60ba22d6e3edbaa39a0f989fb7f2901 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/btree.c | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index eab5ebd169..2daa24ebaa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\shandling\sof\sthe\sSQLITE_OMIT_WAL\scheck\sin\sone\splace.\sResolves\s[forum:87cc13302de160eb|forum\spost\s87cc13302de160eb]. -D 2024-04-11T19:08:12.217 +C Mark\sthe\sBTree\scell\soverflow\scache\sas\sinvalid\swhenever\sthe\srowid\sgoes\sinvalid. +D 2024-04-12T02:57:52.425 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -689,7 +689,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 285b493d843e7ba8ef78b6ae7d31238e904901dbc0c484f7904de4cf18fd8802 +F src/btree.c a654c4b4d84821f4fdeb322df185317493be30c1b114cb75d56adb50dd3f661c F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 02f5b25ca854c83b5015cb02b8c9ab236c60b1795528675aee8a5070e58da52a @@ -2184,8 +2184,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6d2c7ac4ecfc1ec408cb1820985a70650d7cc5613b4b8fd1829f68ea48fce6a3 -R 0071938b1b4e5105037f1334ca733633 -U stephan -Z d6eaf14882bbc596d43b8bd29ecbee42 +P 5dae6e6df4921f42e45c6c8de40853ab63f53a4bd1d9088a8cdac957ce62f196 +R 991bf551528ac37b754c129e51db564b +T *branch * btree-ovfl-cache +T *sym-btree-ovfl-cache * +T -sym-trunk * +U drh +Z d43adcfd8cc8586ed5a00034a7473bf9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4d8c2440ec..5ce114455e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5dae6e6df4921f42e45c6c8de40853ab63f53a4bd1d9088a8cdac957ce62f196 \ No newline at end of file +74c9e19c92c887012aebbe96450f6ed7a60ba22d6e3edbaa39a0f989fb7f2901 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index ddfa3c63f3..e957ccb199 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9521,7 +9521,7 @@ int sqlite3BtreeInsert( }else if( loc<0 && pPage->nCell>0 ){ assert( pPage->leaf ); idx = ++pCur->ix; - pCur->curFlags &= ~BTCF_ValidNKey; + pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); }else{ assert( pPage->leaf ); } @@ -9551,7 +9551,7 @@ int sqlite3BtreeInsert( */ if( pPage->nOverflow ){ assert( rc==SQLITE_OK ); - pCur->curFlags &= ~(BTCF_ValidNKey); + pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); rc = balance(pCur); /* Must make sure nOverflow is reset to zero even if the balance() From 366b419d0084fad8b60ec47e89b882f8218b25e6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 12 Apr 2024 11:28:35 +0000 Subject: [PATCH 0321/1030] Test case for the fix in the previous check-in. FossilOrigin-Name: 0cf4d835dae260b01178e94e77be6b8a130f2031e898ef79ceba8df6c2bba58f --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/upsert1.test | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2daa24ebaa..3d880dd346 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Mark\sthe\sBTree\scell\soverflow\scache\sas\sinvalid\swhenever\sthe\srowid\sgoes\sinvalid. -D 2024-04-12T02:57:52.425 +C Test\scase\sfor\sthe\sfix\sin\sthe\sprevious\scheck-in. +D 2024-04-12T11:28:35.112 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1906,7 +1906,7 @@ F test/upfrom2.test 66f3ebf721b3cebd922faee5c386bf244f816d416b57c000753ff51af623 F test/upfrom3.test 6130f24ebf97f5ea865e5d2a14a2d543fe5428a62e87cc60f62d875e45c1f5f0 F test/upfrom4.test 78f742a6577c91a7a55c64edb8811004e7c6aa99b8d57b2320f70a918c357807 F test/upfromfault.test 3a10075a0043f0c4fad6614b2c371f88a8ba5a4acab68b907438413865d6a8d6 -F test/upsert1.test a512e2f884d3a36159fce2e45108c236f78ae38e35bda55f4050db580ceb25d3 +F test/upsert1.test beba4316fbd4b7b9d76784313f6129a548cfe7abea04d46db33e2efce1ab0ac2 F test/upsert2.test 720e94d09f7362a282bc69b3c6b83d51daeaaf0440eb4920a08b86518b8c7496 F test/upsert3.test 88d7d590a1948a9cb6eac1b54b0642f67a9f35a1fc0f19b200e97d5d39e3179c F test/upsert4.test 25d2a1da92f149331ae0c51ca6e3eee78189577585eab92de149900d62994fa5 @@ -2184,11 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5dae6e6df4921f42e45c6c8de40853ab63f53a4bd1d9088a8cdac957ce62f196 -R 991bf551528ac37b754c129e51db564b -T *branch * btree-ovfl-cache -T *sym-btree-ovfl-cache * -T -sym-trunk * +P 74c9e19c92c887012aebbe96450f6ed7a60ba22d6e3edbaa39a0f989fb7f2901 +R e5ebeec2e7c87917a5e915be853b1124 U drh -Z d43adcfd8cc8586ed5a00034a7473bf9 +Z 367db0044284a550a3cf0e6c6563bd86 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5ce114455e..3a012e5380 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -74c9e19c92c887012aebbe96450f6ed7a60ba22d6e3edbaa39a0f989fb7f2901 \ No newline at end of file +0cf4d835dae260b01178e94e77be6b8a130f2031e898ef79ceba8df6c2bba58f \ No newline at end of file diff --git a/test/upsert1.test b/test/upsert1.test index 7818311330..8af273a89a 100644 --- a/test/upsert1.test +++ b/test/upsert1.test @@ -268,4 +268,28 @@ do_catchsql_test upsert1-1210 { INSERT INTO t1(a,b) VALUES(1,2) ON CONFLICT(b+?1) DO NOTHING; } {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}} +# 2024-04-11 https://sqlite.org/forum/forumpost/284955a3cd454a15 +# Incorrect value passed into a trigger that fires as the result of +# an upsert. +# +reset_db +do_execsql_test upsert1-1300 { + CREATE TABLE t1(x INT, y TEXT); + INSERT INTO t1 VALUES + (11, printf('%.9000c','a')), + (11, printf('%.9000c','a')), + (33, printf('%.9000c','b')), + (33, printf('%.9000c','b')); + CREATE TABLE t2(x INT UNIQUE, y TEXT); + CREATE TRIGGER r1 BEFORE UPDATE ON t2 BEGIN + SELECT raise(ABORT,'Incorrect old.y value passed to trigger!') + WHERE old.y != new.y; + /* ^^^ This trigger will fire and cause the ABORT if the problem has + ** not been fixed, or if there is a regression. */ + END; + INSERT INTO t2(x, y) SELECT x, y FROM t1 + WHERE true + ON CONFLICT (x) DO UPDATE SET y = excluded.y; +} {} + finish_test From ae7ede4a4f70648170b05d176b877f97734d1383 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 12 Apr 2024 12:32:09 +0000 Subject: [PATCH 0322/1030] New assert() statements to verify the correctness of the BTCF_AtLast flag on btree cursors. FossilOrigin-Name: 4efecd6167de71500c90b63155eba1b8567c90e9d1e282fbea54130f9ee21813 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 31 +++++++++++++++++++------------ 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 3d880dd346..070fa270cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\scase\sfor\sthe\sfix\sin\sthe\sprevious\scheck-in. -D 2024-04-12T11:28:35.112 +C New\sassert()\sstatements\sto\sverify\sthe\scorrectness\sof\sthe\sBTCF_AtLast\sflag\non\sbtree\scursors. +D 2024-04-12T12:32:09.806 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -689,7 +689,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c a654c4b4d84821f4fdeb322df185317493be30c1b114cb75d56adb50dd3f661c +F src/btree.c b489280734e3c085774ecc86a07f5ad5b805d86e2cb28650c3b3e141673993d6 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 02f5b25ca854c83b5015cb02b8c9ab236c60b1795528675aee8a5070e58da52a @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 74c9e19c92c887012aebbe96450f6ed7a60ba22d6e3edbaa39a0f989fb7f2901 -R e5ebeec2e7c87917a5e915be853b1124 +P 0cf4d835dae260b01178e94e77be6b8a130f2031e898ef79ceba8df6c2bba58f +R 3352218b957f71135e62b28b93e477b6 U drh -Z 367db0044284a550a3cf0e6c6563bd86 +Z 55f6b761ddb19ac9081b9562cfbe54ea # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3a012e5380..01cbdd4cd6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0cf4d835dae260b01178e94e77be6b8a130f2031e898ef79ceba8df6c2bba58f \ No newline at end of file +4efecd6167de71500c90b63155eba1b8567c90e9d1e282fbea54130f9ee21813 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index e957ccb199..91c9e4fb57 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5624,6 +5624,23 @@ int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){ return rc; } +#ifdef SQLITE_DEBUG +/* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that +** this flags are true for a consistent database. +** +** This routine is is called from within assert() statements only. +** It is an internal verification routine and does not appear in production +** builds. +*/ +static int cursorIsAtLastEntry(BtCursor *pCur){ + int ii; + for(ii=0; iiiPage; ii++){ + if( pCur->aiIdx[ii]!=pCur->apPage[ii]->nCell ) return 0; + } + return pCur->ix==pCur->pPage->nCell-1 && pCur->pPage->leaf!=0; +} +#endif + /* Move the cursor to the last entry in the table. Return SQLITE_OK ** on success. Set *pRes to 0 if the cursor actually points to something ** or set *pRes to 1 if the table is empty. @@ -5652,18 +5669,7 @@ int sqlite3BtreeLast(BtCursor *pCur, int *pRes){ /* If the cursor already points to the last entry, this is a no-op. */ if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){ -#ifdef SQLITE_DEBUG - /* This block serves to assert() that the cursor really does point - ** to the last entry in the b-tree. */ - int ii; - for(ii=0; iiiPage; ii++){ - assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell ); - } - assert( pCur->ix==pCur->pPage->nCell-1 || CORRUPT_DB ); - testcase( pCur->ix!=pCur->pPage->nCell-1 ); - /* ^-- dbsqlfuzz b92b72e4de80b5140c30ab71372ca719b8feb618 */ - assert( pCur->pPage->leaf ); -#endif + assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB ); *pRes = 0; return SQLITE_OK; } @@ -5716,6 +5722,7 @@ int sqlite3BtreeTableMoveto( } if( pCur->info.nKeycurFlags & BTCF_AtLast)!=0 ){ + assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB ); *pRes = -1; return SQLITE_OK; } From 1d40237bc8b1c6ec71dfe763329e1aceacf022fa Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 12 Apr 2024 13:05:36 +0000 Subject: [PATCH 0323/1030] Add assert() statements to help verify the overflow page cache. FossilOrigin-Name: 0ebc65481f4a3e7974558adea51c620a025bc0e76c0a139e549b56c5abe0cabb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 070fa270cd..17af620303 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\sassert()\sstatements\sto\sverify\sthe\scorrectness\sof\sthe\sBTCF_AtLast\sflag\non\sbtree\scursors. -D 2024-04-12T12:32:09.806 +C Add\sassert()\sstatements\sto\shelp\sverify\sthe\soverflow\spage\scache. +D 2024-04-12T13:05:36.039 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -689,7 +689,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c b489280734e3c085774ecc86a07f5ad5b805d86e2cb28650c3b3e141673993d6 +F src/btree.c 8c2d32661d9b3333b5e2192a9baf0f34aaf50224c7e0130bdb96a1e5dee9009c F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 02f5b25ca854c83b5015cb02b8c9ab236c60b1795528675aee8a5070e58da52a @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0cf4d835dae260b01178e94e77be6b8a130f2031e898ef79ceba8df6c2bba58f -R 3352218b957f71135e62b28b93e477b6 +P 4efecd6167de71500c90b63155eba1b8567c90e9d1e282fbea54130f9ee21813 +R 733b2640d8dc44517728193a890baeff U drh -Z 55f6b761ddb19ac9081b9562cfbe54ea +Z 6194d89088ab528754e159fb92573073 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 01cbdd4cd6..621be8e4f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4efecd6167de71500c90b63155eba1b8567c90e9d1e282fbea54130f9ee21813 \ No newline at end of file +0ebc65481f4a3e7974558adea51c620a025bc0e76c0a139e549b56c5abe0cabb \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 91c9e4fb57..756ec942c3 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5143,6 +5143,10 @@ static int accessPayload( memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno)); pCur->curFlags |= BTCF_ValidOvfl; }else{ + /* Sanity check the validity of the overflow page cache */ + assert( pCur->aOverflow[0]==nextPage || pCur->aOverflow[0]==0 ); + assert( pCur->aOverflow[0]!=0 || pCur->aOverflow[offset/ovflSize]==0 ); + /* If the overflow page-list cache has been allocated and the ** entry for the first required overflow page is valid, skip ** directly to it. From 0221cacea70d50f8cf5033aecfa104e4582a1532 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 12 Apr 2024 18:46:34 +0000 Subject: [PATCH 0324/1030] If a build fails in testrunner.tcl, do not attempt to run the jobs that depend on that build. Instead, report those jobs as having been skipped. FossilOrigin-Name: b40580be719a129ecd1aa3c69d1086c967d063920fdd48617c864e73c059abc1 --- manifest | 13 ++++++------- manifest.uuid | 2 +- test/testrunner.tcl | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index ceff35c009..c7c6ea43af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sand\snew\stests\slogic\sto\sensure\sthat\sthe\sbtree\soverflow\spage\scache\sis\nonly\sused\swhen\sit\sis\sconsistent.\s\sThis\sresolves\sthe\smalfunction\sobserved\nin\s[forum:/forumpost/284955a3cd454a15|forum\spost\s284955a3cd454a15]. -D 2024-04-12T15:02:16.718 +C If\sa\sbuild\sfails\sin\stestrunner.tcl,\sdo\snot\sattempt\sto\srun\sthe\sjobs\sthat\ndepend\son\sthat\sbuild.\s\sInstead,\sreport\sthose\sjobs\sas\shaving\sbeen\sskipped. +D 2024-04-12T18:46:34.309 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1690,7 +1690,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf -F test/testrunner.tcl b48a8fc17e3b200244f53d60348afa7fe9482400d164e95709890743af9536d0 +F test/testrunner.tcl 1386667c04207d0a540ce1a9bc5ee0b734f7a3ba856c14a03943fb4f32de55bb F test/testrunner_data.tcl 3d36660cfd55ea5e20e661e8f94c0520feebcb437848f9b98b33c483cc479c0c F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2184,9 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5dae6e6df4921f42e45c6c8de40853ab63f53a4bd1d9088a8cdac957ce62f196 0ebc65481f4a3e7974558adea51c620a025bc0e76c0a139e549b56c5abe0cabb -R 733b2640d8dc44517728193a890baeff -T +closed 0ebc65481f4a3e7974558adea51c620a025bc0e76c0a139e549b56c5abe0cabb +P 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d +R 4f3eb54a5cce9aa23292ec96983abdb3 U drh -Z 49129cd4194bac4dbb6265651119b7c1 +Z 1648e8675f24aa01764212367c0fba7b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8b1f8f1238..b40ee8722e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d \ No newline at end of file +b40580be719a129ecd1aa3c69d1086c967d063920fdd48617c864e73c059abc1 \ No newline at end of file diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 05f7d4cc98..fd82716769 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -270,7 +270,7 @@ set TRG(schema) { /* Fields updated as jobs run */ starttime INTEGER, endtime INTEGER, - state TEXT CHECK( state IN ('', 'ready', 'running', 'done', 'failed') ), + state TEXT CHECK( state IN ('','ready','running','done','failed','omit') ), output TEXT ); @@ -447,6 +447,10 @@ if {[llength $argv]==1 } job { display_job [array get job] } + set nOmit [db one {SELECT count(*) FROM jobs WHERE state='omit'}] + if {$nOmit} { + puts "$nOmit jobs omitted due to failures" + } } mydb close @@ -975,11 +979,16 @@ proc make_new_testset {} { proc mark_job_as_finished {jobid output state endtm} { r_write_db { + if {$state=="failed"} { + set childstate omit + } else { + set childstate ready + } trdb eval { UPDATE jobs SET output=$output, state=$state, endtime=$endtm WHERE jobid=$jobid; - UPDATE jobs SET state='ready' WHERE depid=$jobid; + UPDATE jobs SET state=$childstate WHERE depid=$jobid; } } } @@ -1202,6 +1211,10 @@ proc run_testset {} { puts "FAILED: $displayname" } } + set nOmit [trdb one {SELECT count(*) FROM jobs WHERE state='omit'}] + if {$nOmit>0} { + puts "$nOmit jobs skipped due to prior failures" + } } puts "\nTest database is $TRG(dbname)" From 06915d014545ebf1b00163351e76fbaa6a3ba7b8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 15 Apr 2024 20:43:21 +0000 Subject: [PATCH 0325/1030] The first assert() added in [0ebc65481f4a3e79] is not necessarily true in a corrupt database file. So add a term to make it true. FossilOrigin-Name: 6b21cccdeec92db9f6ce3dd7ea5e61b8b46650cc1e550271aa51bdc619f55b11 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c7c6ea43af..51a37eef64 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\sbuild\sfails\sin\stestrunner.tcl,\sdo\snot\sattempt\sto\srun\sthe\sjobs\sthat\ndepend\son\sthat\sbuild.\s\sInstead,\sreport\sthose\sjobs\sas\shaving\sbeen\sskipped. -D 2024-04-12T18:46:34.309 +C The\sfirst\sassert()\sadded\sin\s[0ebc65481f4a3e79]\sis\snot\snecessarily\strue\sin\sa\ncorrupt\sdatabase\sfile.\s\sSo\sadd\sa\sterm\sto\smake\sit\strue. +D 2024-04-15T20:43:21.644 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -689,7 +689,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 8c2d32661d9b3333b5e2192a9baf0f34aaf50224c7e0130bdb96a1e5dee9009c +F src/btree.c 71b80e77b255144db47180fda8138740608e382a44231942464029b1a45fc036 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 02f5b25ca854c83b5015cb02b8c9ab236c60b1795528675aee8a5070e58da52a @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d -R 4f3eb54a5cce9aa23292ec96983abdb3 +P b40580be719a129ecd1aa3c69d1086c967d063920fdd48617c864e73c059abc1 +R 8fc5f990e4d938881ab9bd286e3b11d3 U drh -Z 1648e8675f24aa01764212367c0fba7b +Z fa0c07b8b0de569fa969f3e2656bc2dc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b40ee8722e..b31a38051e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b40580be719a129ecd1aa3c69d1086c967d063920fdd48617c864e73c059abc1 \ No newline at end of file +6b21cccdeec92db9f6ce3dd7ea5e61b8b46650cc1e550271aa51bdc619f55b11 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 756ec942c3..62b8989796 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5144,7 +5144,9 @@ static int accessPayload( pCur->curFlags |= BTCF_ValidOvfl; }else{ /* Sanity check the validity of the overflow page cache */ - assert( pCur->aOverflow[0]==nextPage || pCur->aOverflow[0]==0 ); + assert( pCur->aOverflow[0]==nextPage + || pCur->aOverflow[0]==0 + || CORRUPT_DB ); assert( pCur->aOverflow[0]!=0 || pCur->aOverflow[offset/ovflSize]==0 ); /* If the overflow page-list cache has been allocated and the From 0526db32e2657b2b16fa3333e5b8c6e24754eaf2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 18 Apr 2024 16:11:01 +0000 Subject: [PATCH 0326/1030] Correct handling of OUTER JOIN when on or the other operand is a subquery implemented using the VALUES-as-coroutine optimization. dbsqlfuzz bde3bf80aedf25afa56e2997a0545a314765d3f8. FossilOrigin-Name: 8c0f69e0e4ae0a446838cc193bfd4395fd251f3c7659b35ac388e5a0a7650a66 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/vdbe.c | 6 ++++-- src/where.c | 13 +++++++++++-- src/wherecode.c | 18 ++++++++++++++---- test/values.test | 23 ++++++++++++++++++++++- 6 files changed, 61 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 51a37eef64..98a7d3bada 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sfirst\sassert()\sadded\sin\s[0ebc65481f4a3e79]\sis\snot\snecessarily\strue\sin\sa\ncorrupt\sdatabase\sfile.\s\sSo\sadd\sa\sterm\sto\smake\sit\strue. -D 2024-04-15T20:43:21.644 +C Correct\shandling\sof\sOUTER\sJOIN\swhen\son\sor\sthe\sother\soperand\sis\sa\ssubquery\nimplemented\susing\sthe\sVALUES-as-coroutine\soptimization.\ndbsqlfuzz\sbde3bf80aedf25afa56e2997a0545a314765d3f8. +D 2024-04-18T16:11:01.833 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -820,7 +820,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 651aa0f31027d5d0a133eb7b41d11c41dc3b88ecb760b770430da0e477ae3b6c +F src/vdbe.c 298e8bf31adbcad0d8dfa37e106372e0d59ce531f2cca5b8ce559f9e173085f2 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -835,9 +835,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 09253e913dc1a93aa6e0e1a5d25a392b8fa39096cc30d230dd302264b3be0661 +F src/where.c 40ee94edd4cf31e6dc3e4c9ac814777b8cf4dc8ee985d87eb5f77bd4c42e69da F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 -F src/wherecode.c e033875570f5d65b99fdb5189e597d91c8bc34f4196089fd50e6086d174035e7 +F src/wherecode.c 4b5909be0c36030eec18ea0e7a64c60254180a21e626c9d2e0e9be3007ad47c1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1924,7 +1924,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 6c2426de40cd397a8ab68d375b6964ab3bce1244bbb69f5d1ed3ccd0e039c1f3 +F test/values.test 8c1e0157ba64aeaebdecd4b0b6b1b1422740664e29c17153499973e77ca5200b F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b40580be719a129ecd1aa3c69d1086c967d063920fdd48617c864e73c059abc1 -R 8fc5f990e4d938881ab9bd286e3b11d3 +P 6b21cccdeec92db9f6ce3dd7ea5e61b8b46650cc1e550271aa51bdc619f55b11 +R 742e51db40c512171314564bf9760205 U drh -Z fa0c07b8b0de569fa969f3e2656bc2dc +Z 2a179895cc5d13f95288c795c253907b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b31a38051e..2e5a76fc98 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b21cccdeec92db9f6ce3dd7ea5e61b8b46650cc1e550271aa51bdc619f55b11 \ No newline at end of file +8c0f69e0e4ae0a446838cc193bfd4395fd251f3c7659b35ac388e5a0a7650a66 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index ed1d277b23..143fd49c1e 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1152,7 +1152,9 @@ case OP_InitCoroutine: { /* jump0 */ ** ** The instruction at the address in register P1 is a Yield. ** Jump to the P2 parameter of that Yield. -** After the jump, register P1 becomes undefined. +** After the jump, the value register P1 is left with a value +** such that subsequent OP_Yields go back to the this same +** OP_EndCoroutine instruction. ** ** See also: InitCoroutine */ @@ -1164,8 +1166,8 @@ case OP_EndCoroutine: { /* in1 */ pCaller = &aOp[pIn1->u.i]; assert( pCaller->opcode==OP_Yield ); assert( pCaller->p2>=0 && pCaller->p2nOp ); + pIn1->u.i = (int)(pOp - p->aOp) - 1; pOp = &aOp[pCaller->p2 - 1]; - pIn1->flags = MEM_Undefined; break; } diff --git a/src/where.c b/src/where.c index 65b6ae2c92..93984347b7 100644 --- a/src/where.c +++ b/src/where.c @@ -6940,8 +6940,17 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v); assert( (ws & WHERE_IDX_ONLY)==0 || (ws & WHERE_INDEXED)!=0 ); if( (ws & WHERE_IDX_ONLY)==0 ){ - assert( pLevel->iTabCur==pTabList->a[pLevel->iFrom].iCursor ); - sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur); + SrcItem *pSrc = &pTabList->a[pLevel->iFrom]; + assert( pLevel->iTabCur==pSrc->iCursor ); + if( pSrc->fg.viaCoroutine ){ + int m, n; + n = pSrc->regResult; + assert( pSrc->pTab!=0 ); + m = pSrc->pTab->nCol; + sqlite3VdbeAddOp3(v, OP_Null, 0, n, n+m-1); + }else{ + sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur); + } } if( (ws & WHERE_INDEXED) || ((ws & WHERE_MULTI_OR) && pLevel->u.pCoveringIdx) diff --git a/src/wherecode.c b/src/wherecode.c index 1f9c84f008..e91bc283b7 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -2730,11 +2730,21 @@ SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( pRJ->regReturn); for(k=0; ka[k].pWLoop->iTab == pWInfo->a[k].iFrom ); + pRight = &pWInfo->pTabList->a[pWInfo->a[k].iFrom]; mAll |= pWInfo->a[k].pWLoop->maskSelf; - sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); - iIdxCur = pWInfo->a[k].iIdxCur; - if( iIdxCur ){ - sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur); + if( pRight->fg.viaCoroutine ){ + sqlite3VdbeAddOp3( + v, OP_Null, 0, pRight->regResult, + pRight->regResult + pRight->pSelect->pEList->nExpr-1 + ); + }else{ + sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); + iIdxCur = pWInfo->a[k].iIdxCur; + if( iIdxCur ){ + sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur); + } } } if( (pTabItem->fg.jointype & JT_LTORJ)==0 ){ diff --git a/test/values.test b/test/values.test index 4252f2e13b..7e81cdeebb 100644 --- a/test/values.test +++ b/test/values.test @@ -648,6 +648,27 @@ do_catchsql_test 18.5.3 { SELECT * FROM t1; } {0 {}} - +# 2024-04-18 dbsqlfuzz crash-bde3bf80aedf25afa56e2997a0545a314765d3f8 +# Verify that the VALUES expressions used as an argument to an outer +# join work correctly. +# +reset_db +db null NULL +do_execsql_test 19.1 { + CREATE TABLE t1(a INT, b INT); + INSERT INTO t1 VALUES(11,22); + SELECT * FROM t1 LEFT JOIN (VALUES(33,44),(55,66)) AS t2 ON a=b; +} {11 22 NULL NULL} +do_execsql_test 19.2 { + SELECT * FROM (VALUES(33,44),(55,66)) AS t2 RIGHT JOIN t1 ON a=b; +} {NULL NULL 11 22} +do_execsql_test 19.3 { + SELECT *, '|' FROM t1 FULL JOIN (VALUES(33,44),(55,66)) AS t2 ON a=b + ORDER BY +column1 +} {11 22 NULL NULL | NULL NULL 33 44 | NULL NULL 55 66 |} +do_execsql_test 19.4 { + SELECT *, '|' FROM (VALUES(33,44),(55,66)) AS t2 FULL JOIN t1 ON a=b + ORDER BY +column1 +} {NULL NULL 11 22 | 33 44 NULL NULL | 55 66 NULL NULL |} finish_test From d737feeacfdbf6ea5d44e383647ea6ced390c3ab Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 20 Apr 2024 15:14:06 +0000 Subject: [PATCH 0327/1030] Fix a problem where an expression like (a, b) IN (SELECT ...) might not use an index on (a, b) if the affinities and collation sequences of "a" and "b" are not identical. FossilOrigin-Name: 4d870fd8b5450047a7486fc023d1ac9439642e8ed91eadfd5026c4cda7cc9179 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/where.c | 38 ++++++++++++++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 98a7d3bada..5c55caac4b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correct\shandling\sof\sOUTER\sJOIN\swhen\son\sor\sthe\sother\soperand\sis\sa\ssubquery\nimplemented\susing\sthe\sVALUES-as-coroutine\soptimization.\ndbsqlfuzz\sbde3bf80aedf25afa56e2997a0545a314765d3f8. -D 2024-04-18T16:11:01.833 +C Fix\sa\sproblem\swhere\san\sexpression\slike\s(a,\sb)\sIN\s(SELECT\s...)\smight\snot\suse\san\sindex\son\s(a,\sb)\sif\sthe\saffinities\sand\scollation\ssequences\sof\s"a"\sand\s"b"\sare\snot\sidentical. +D 2024-04-20T15:14:06.554 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 40ee94edd4cf31e6dc3e4c9ac814777b8cf4dc8ee985d87eb5f77bd4c42e69da +F src/where.c b4eb20a2e5f74e299cb19095454dd257292ad2a23a90265a9eecd2390fd0552a F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 4b5909be0c36030eec18ea0e7a64c60254180a21e626c9d2e0e9be3007ad47c1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -2184,8 +2184,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6b21cccdeec92db9f6ce3dd7ea5e61b8b46650cc1e550271aa51bdc619f55b11 -R 742e51db40c512171314564bf9760205 -U drh -Z 2a179895cc5d13f95288c795c253907b +P 8c0f69e0e4ae0a446838cc193bfd4395fd251f3c7659b35ac388e5a0a7650a66 +R 76aaae3efae57f02d5fc2e79c67a8826 +T *branch * vector-in-fix +T *sym-vector-in-fix * +T -sym-trunk * +U dan +Z 8e2ed7e86b55b55a9e6d2d789c1dac73 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2e5a76fc98..c480de9800 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c0f69e0e4ae0a446838cc193bfd4395fd251f3c7659b35ac388e5a0a7650a66 \ No newline at end of file +4d870fd8b5450047a7486fc023d1ac9439642e8ed91eadfd5026c4cda7cc9179 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 93984347b7..f6b0990e67 100644 --- a/src/where.c +++ b/src/where.c @@ -302,6 +302,28 @@ static Expr *whereRightSubexprIsColumn(Expr *p){ return 0; } +static int SQLITE_NOINLINE indexInAffinityOk( + Parse *pParse, + WhereTerm *pTerm, + u8 idxaff, + CollSeq **ppColl +){ + Expr *pX = pTerm->pExpr; + Expr inexpr; + + if( sqlite3ExprIsVector(pX->pLeft) ){ + int iField = pTerm->u.x.iField - 1; + inexpr.op = TK_EQ; + inexpr.pLeft = pX->pLeft->x.pList->a[iField].pExpr; + assert( ExprUseXSelect(pX) ); + inexpr.pRight = pX->x.pSelect->pEList->a[iField].pExpr; + pX = &inexpr; + } + + *ppColl = sqlite3ExprCompareCollSeq(pParse, pX); + return sqlite3IndexAffinityOk(pX, idxaff); +} + /* ** Advance to the next WhereTerm that matches according to the criteria ** established when the pScan object was initialized by whereScanInit(). @@ -355,11 +377,19 @@ static WhereTerm *whereScanNext(WhereScan *pScan){ CollSeq *pColl; Parse *pParse = pWC->pWInfo->pParse; pX = pTerm->pExpr; - if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){ - continue; + + if( (pTerm->eOperator & WO_IN) ){ + if( !indexInAffinityOk(pParse, pTerm, pScan->idxaff, &pColl) ){ + continue; + } + }else{ + if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){ + continue; + } + assert(pX->pLeft); + pColl = sqlite3ExprCompareCollSeq(pParse, pX); } - assert(pX->pLeft); - pColl = sqlite3ExprCompareCollSeq(pParse, pX); + if( pColl==0 ) pColl = pParse->db->pDfltColl; if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){ continue; From 5749e1ee4386a2a6c436dfeb45770f8352abdb65 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 20 Apr 2024 19:19:30 +0000 Subject: [PATCH 0328/1030] Slight performance improvement for the new code on this branch. FossilOrigin-Name: 500c67f1341fe2a7e7333d525c90df201cc73a683b943ad5c1e41d4a4f639043 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/where.c | 35 ++++++++++++++++++++++++----------- test/in5.test | 22 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 5c55caac4b..d652ae551d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swhere\san\sexpression\slike\s(a,\sb)\sIN\s(SELECT\s...)\smight\snot\suse\san\sindex\son\s(a,\sb)\sif\sthe\saffinities\sand\scollation\ssequences\sof\s"a"\sand\s"b"\sare\snot\sidentical. -D 2024-04-20T15:14:06.554 +C Slight\sperformance\simprovement\sfor\sthe\snew\scode\son\sthis\sbranch. +D 2024-04-20T19:19:30.713 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c b4eb20a2e5f74e299cb19095454dd257292ad2a23a90265a9eecd2390fd0552a +F src/where.c 79c673bf23b3b7fcc5e9cfa0adcd88a97645cd47920d2365dd6aec8cab7b222a F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 4b5909be0c36030eec18ea0e7a64c60254180a21e626c9d2e0e9be3007ad47c1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -1274,7 +1274,7 @@ F test/in.test d1cad4ededd425568b2e39fb0c31fa9a3772311dd595801ff13ba3912b69bba6 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test bb767ec1cfd1730256f0a83219f0acda36bc251b63f8b8bb7d8c7cff17875a4f -F test/in5.test b32ce7f4a93f44c5dee94af16886d922cc16ebe33c8e1765c73d4049d0f4b40f +F test/in5.test 4fd79c70dfa0681313e8cdca07f5ff0400bdc0e20f808a5c59eaef1e4b48082a F test/in6.test f5f40d6816a8bb7c784424b58a10ac38efb76ab29127a2c17399e0cbeeda0e4b F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822 F test/incrblob2.test a494c9e848560039a23974b9119cfc2cf3ad3bd15cc2694ee6367ae537ef8f1f @@ -2184,11 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8c0f69e0e4ae0a446838cc193bfd4395fd251f3c7659b35ac388e5a0a7650a66 -R 76aaae3efae57f02d5fc2e79c67a8826 -T *branch * vector-in-fix -T *sym-vector-in-fix * -T -sym-trunk * +P 4d870fd8b5450047a7486fc023d1ac9439642e8ed91eadfd5026c4cda7cc9179 +R 6023edc800b34da7492bfeaa8c433f44 U dan -Z 8e2ed7e86b55b55a9e6d2d789c1dac73 +Z caab3df5b31f1752021c68136ff6d06a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c480de9800..6bb6214d88 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4d870fd8b5450047a7486fc023d1ac9439642e8ed91eadfd5026c4cda7cc9179 \ No newline at end of file +500c67f1341fe2a7e7333d525c90df201cc73a683b943ad5c1e41d4a4f639043 \ No newline at end of file diff --git a/src/where.c b/src/where.c index f6b0990e67..96a6df9deb 100644 --- a/src/where.c +++ b/src/where.c @@ -302,15 +302,25 @@ static Expr *whereRightSubexprIsColumn(Expr *p){ return 0; } -static int SQLITE_NOINLINE indexInAffinityOk( +/* +** Term pTerm is guaranteed to be a WO_IN term. It may be a component term +** of a vector IN expression of the form "(x, y, ...) IN (SELECT ...)". +** This function checks to see if the term is compatible with an index +** column with affinity idxaff (one of the SQLITE_AFF_XYZ values). If so, +** it returns a pointer to the name of the collation sequence (e.g. "BINARY" +** or "NOCASE") used by the comparison in pTerm. If it is not compatible +** with affinity idxaff, NULL is returned. +*/ +static SQLITE_NOINLINE const char *indexInAffinityOk( Parse *pParse, WhereTerm *pTerm, - u8 idxaff, - CollSeq **ppColl + u8 idxaff ){ Expr *pX = pTerm->pExpr; Expr inexpr; + assert( pTerm->eOperator & WO_IN ); + if( sqlite3ExprIsVector(pX->pLeft) ){ int iField = pTerm->u.x.iField - 1; inexpr.op = TK_EQ; @@ -320,8 +330,11 @@ static int SQLITE_NOINLINE indexInAffinityOk( pX = &inexpr; } - *ppColl = sqlite3ExprCompareCollSeq(pParse, pX); - return sqlite3IndexAffinityOk(pX, idxaff); + if( sqlite3IndexAffinityOk(pX, idxaff) ){ + CollSeq *pRet = sqlite3ExprCompareCollSeq(pParse, pX); + return pRet ? pRet->zName : sqlite3StrBINARY; + } + return 0; } /* @@ -374,24 +387,24 @@ static WhereTerm *whereScanNext(WhereScan *pScan){ if( (pTerm->eOperator & pScan->opMask)!=0 ){ /* Verify the affinity and collating sequence match */ if( pScan->zCollName && (pTerm->eOperator & WO_ISNULL)==0 ){ - CollSeq *pColl; + const char *zCollName; Parse *pParse = pWC->pWInfo->pParse; pX = pTerm->pExpr; if( (pTerm->eOperator & WO_IN) ){ - if( !indexInAffinityOk(pParse, pTerm, pScan->idxaff, &pColl) ){ - continue; - } + zCollName = indexInAffinityOk(pParse, pTerm, pScan->idxaff); + if( !zCollName ) continue; }else{ + CollSeq *pColl; if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){ continue; } assert(pX->pLeft); pColl = sqlite3ExprCompareCollSeq(pParse, pX); + zCollName = pColl ? pColl->zName : sqlite3StrBINARY; } - if( pColl==0 ) pColl = pParse->db->pDfltColl; - if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){ + if( sqlite3StrICmp(zCollName, pScan->zCollName) ){ continue; } } diff --git a/test/in5.test b/test/in5.test index 6680641ff3..933eb90026 100644 --- a/test/in5.test +++ b/test/in5.test @@ -266,4 +266,26 @@ do_execsql_test 9.2 { SELECT lower('1e500') FROM t0 WHERE rowid != lower('1e500'); } {1e500} +#------------------------------------------------------------------------- +# +reset_db + +do_execsql_test 10.0 { + CREATE TABLE t1(a, b TEXT COLLATE NOCASE); + INSERT INTO t1 VALUES('abc', 'def'); + INSERT INTO t1 VALUES('ghi', 'jkl'); +} + +do_execsql_test 10.1 { + SELECT rowid FROM t1 WHERE (a, b) IN ( VALUES('abc', 'def'), ('ghi', 'JKL') ); +} {1 2} + +do_execsql_test 10.2 { + CREATE INDEX i1 ON t1(a, b COLLATE BINARY); +} + +do_execsql_test 10.3 { + SELECT rowid FROM t1 WHERE (a, b) IN ( VALUES('abc', 'def'), ('ghi', 'JKL') ); +} {1 2} + finish_test From db2a33a3dd9ea37180f22dce60c2b6bbbfd781bf Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 21 Apr 2024 23:35:58 +0000 Subject: [PATCH 0329/1030] Fix an indentation problem in debugging routine sqlite3ShowSrcList(). No changes to production code. FossilOrigin-Name: 5560df2726fed215c98d602c5f6ebbf3c5ae23f8ba1074291c509bf446fdfe66 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/treeview.c | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 98a7d3bada..eed8f90418 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correct\shandling\sof\sOUTER\sJOIN\swhen\son\sor\sthe\sother\soperand\sis\sa\ssubquery\nimplemented\susing\sthe\sVALUES-as-coroutine\soptimization.\ndbsqlfuzz\sbde3bf80aedf25afa56e2997a0545a314765d3f8. -D 2024-04-18T16:11:01.833 +C Fix\san\sindentation\sproblem\sin\sdebugging\sroutine\ssqlite3ShowSrcList().\s\sNo\nchanges\sto\sproduction\scode. +D 2024-04-21T23:35:58.340 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -813,7 +813,7 @@ F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee +F src/treeview.c a8aa3086c886c6eb2ff2b6354b0f23d251f7219bf08fad52d4f2791e55324f1b F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6b21cccdeec92db9f6ce3dd7ea5e61b8b46650cc1e550271aa51bdc619f55b11 -R 742e51db40c512171314564bf9760205 +P 8c0f69e0e4ae0a446838cc193bfd4395fd251f3c7659b35ac388e5a0a7650a66 +R d1e0ee7f01676cc6df31262dd81ddd1f U drh -Z 2a179895cc5d13f95288c795c253907b +Z 8e24853569e668dc3bc8026735d6b031 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2e5a76fc98..c390f98bb8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c0f69e0e4ae0a446838cc193bfd4395fd251f3c7659b35ac388e5a0a7650a66 \ No newline at end of file +5560df2726fed215c98d602c5f6ebbf3c5ae23f8ba1074291c509bf446fdfe66 \ No newline at end of file diff --git a/src/treeview.c b/src/treeview.c index 2576532b65..c223db29e0 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -235,12 +235,14 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ sqlite3TreeViewIdList(pView, pItem->u3.pUsing, (--n)>0, "USING"); } if( pItem->pSelect ){ + sqlite3TreeViewPush(&pView, i+1nSrc); if( pItem->pTab ){ Table *pTab = pItem->pTab; sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1); } assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); sqlite3TreeViewSelect(pView, pItem->pSelect, (--n)>0); + sqlite3TreeViewPop(&pView); } if( pItem->fg.isTabFunc ){ sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); From 2c26adb87397842f90122a1029cb84d3f45a4090 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 22 Apr 2024 00:42:47 +0000 Subject: [PATCH 0330/1030] Continuation of the fix at [8c0f69e0e4ae0a44]: If a viaCoroutine FROM clause term is participating in a RIGHT or FULL JOIN, we have to create an always-NULL pseudo-cursor for that term when processing the RIGHT join. dbsqlfuzz 6fd1ff3a64bef4a6c092e8d757548e95698b0df5. FossilOrigin-Name: e1040e51ebd04f2a076f477b6f240f849afb10f543ebe518e09d6842cc3cb38e --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/vdbe.c | 3 ++- src/wherecode.c | 1 + test/values.test | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index eed8f90418..bf4199ab06 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sindentation\sproblem\sin\sdebugging\sroutine\ssqlite3ShowSrcList().\s\sNo\nchanges\sto\sproduction\scode. -D 2024-04-21T23:35:58.340 +C Continuation\sof\sthe\sfix\sat\s[8c0f69e0e4ae0a44]:\sIf\sa\sviaCoroutine\sFROM\sclause\nterm\sis\sparticipating\sin\sa\sRIGHT\sor\sFULL\sJOIN,\swe\shave\sto\screate\san\nalways-NULL\spseudo-cursor\sfor\sthat\sterm\swhen\sprocessing\sthe\sRIGHT\sjoin.\ndbsqlfuzz\s6fd1ff3a64bef4a6c092e8d757548e95698b0df5. +D 2024-04-22T00:42:47.056 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -820,7 +820,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 298e8bf31adbcad0d8dfa37e106372e0d59ce531f2cca5b8ce559f9e173085f2 +F src/vdbe.c 3b1793c5d2235ae89b01ef051a33d7d2ad3704c71799653b112686735ad401ff F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -837,7 +837,7 @@ F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 40ee94edd4cf31e6dc3e4c9ac814777b8cf4dc8ee985d87eb5f77bd4c42e69da F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 -F src/wherecode.c 4b5909be0c36030eec18ea0e7a64c60254180a21e626c9d2e0e9be3007ad47c1 +F src/wherecode.c b0224e0ec3c3c4e94cbdd221df109974a1bb26255637383f0fd81795358326fc F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1924,7 +1924,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 8c1e0157ba64aeaebdecd4b0b6b1b1422740664e29c17153499973e77ca5200b +F test/values.test 52102ad9e5068b449429e40a976486a52246041f7cd79d086a2b170e77dec925 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8c0f69e0e4ae0a446838cc193bfd4395fd251f3c7659b35ac388e5a0a7650a66 -R d1e0ee7f01676cc6df31262dd81ddd1f +P 5560df2726fed215c98d602c5f6ebbf3c5ae23f8ba1074291c509bf446fdfe66 +R ae9a50293e0c35742076bd20e79d2b4c U drh -Z 8e24853569e668dc3bc8026735d6b031 +Z 44b0654aae70868bd62dea2cbd768897 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c390f98bb8..192803b3e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5560df2726fed215c98d602c5f6ebbf3c5ae23f8ba1074291c509bf446fdfe66 \ No newline at end of file +e1040e51ebd04f2a076f477b6f240f849afb10f543ebe518e09d6842cc3cb38e \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 143fd49c1e..d8b471de2e 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4584,7 +4584,8 @@ case OP_SequenceTest: { ** is the only cursor opcode that works with a pseudo-table. ** ** P3 is the number of fields in the records that will be stored by -** the pseudo-table. +** the pseudo-table. If P2 is 0 or negative then the pseudo-cursor +** will return NULL for every column. */ case OP_OpenPseudo: { VdbeCursor *pCx; diff --git a/src/wherecode.c b/src/wherecode.c index e91bc283b7..cad2293ddd 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -2739,6 +2739,7 @@ SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( v, OP_Null, 0, pRight->regResult, pRight->regResult + pRight->pSelect->pEList->nExpr-1 ); + sqlite3VdbeAddOp1(v, OP_OpenPseudo, pWInfo->a[k].iTabCur); }else{ sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); iIdxCur = pWInfo->a[k].iIdxCur; diff --git a/test/values.test b/test/values.test index 7e81cdeebb..fed2c5c6cb 100644 --- a/test/values.test +++ b/test/values.test @@ -671,4 +671,45 @@ do_execsql_test 19.4 { ORDER BY +column1 } {NULL NULL 11 22 | 33 44 NULL NULL | 55 66 NULL NULL |} +# 2024-04-21 dbsqlfuzz 6fd1ff3a64bef4a6c092e8d757548e95698b0df5 +# A continuation of the 2024-04-18 problem above. We have to create +# Pseudo-cursor that is always NULL on the viaCoroutine loop in case +# there are OP_Columns generated against it by the sub-WHERE clause. +# +db null N +do_execsql_test 19.5 { + DROP TABLE IF EXISTS t1; + DROP TABLE IF EXISTS t2; + DROP TABLE IF EXISTS t3; + CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2); + CREATE TABLE t2(column1,column2); INSERT INTO t2 VALUES(11,22),(33,44); + CREATE TABLE t3(d,e); INSERT INTO t3 VALUES(3,4); +} +do_execsql_test 19.6 { + -- output verify using PG 14.2 + SELECT * + FROM t1 CROSS JOIN t2 FULL JOIN t3 ON a=d + ORDER BY +d, +column1; +} {1 2 11 22 N N + 1 2 33 44 N N + N N N N 3 4} +do_execsql_test 19.7 { + SELECT * + FROM t1 CROSS JOIN (VALUES(11,22),(33,44)) FULL JOIN t3 ON a=d + ORDER BY +d, +column1; +} {1 2 11 22 N N + 1 2 33 44 N N + N N N N 3 4} +do_execsql_test 19.8 { + -- output verified using PG 14.2 + SELECT * + FROM t1 CROSS JOIN t2 FULL JOIN t3 ON a=d + WHERE column1 IS NULL; +} {N N N N 3 4} +do_execsql_test 19.9 { + SELECT * + FROM t1 CROSS JOIN (VALUES(11,22),(33,44)) FULL JOIN t3 ON a=d + WHERE column1 IS NULL; +} {N N N N 3 4} + finish_test From 2469350ad9f84d902793d9c8c6b8caeffd4c0a7c Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 22 Apr 2024 11:48:03 +0000 Subject: [PATCH 0331/1030] For sqlite3.oo1.DB JavaScript classes, bypass execution of any on-open() SQL in SEE-capable builds because it would necessarily run before the client has an opportunity to provide their decryption key, which would leave the db handle in an unusable state and cause the ctor to throw. This currently affects only the OPFS VFSes. We may want to consider extending the ctor options object to optionally accept an SEE key and apply it when opening the db. FossilOrigin-Name: 5c505ee8a73f4b4a7053d98a12024d98340676f6ae9982311f9f88a9b46c8ae2 --- ext/wasm/api/sqlite3-api-oo1.js | 33 ++++++++++++++++++++++++++------- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index 425b52eeca..06d1df43f9 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -179,12 +179,30 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ const pVfs = capi.sqlite3_js_db_vfs(pDb); if(!pVfs) toss3("Internal error: cannot get VFS for new db handle."); const postInitSql = __vfsPostOpenSql[pVfs]; - if(postInitSql instanceof Function){ - postInitSql(this, sqlite3); - }else if(postInitSql){ - checkSqlite3Rc( - pDb, capi.sqlite3_exec(pDb, postInitSql, 0, 0, 0) - ); + if(postInitSql){ + if(capi.sqlite3_activate_see){ + /** + In SEE-capable builds we have to avoid running any db + code before the client has an opportunity to apply their + decryption key. If we first run any db code, e.g. pragma + journal_mode=..., then it will fail with SQLITE_NOTADB + and the db handle will be left in an unusuable + state. Note that at this point we do not actually know + whether the db is encrypted, but if a client has gone out + of their way to create an SEE build, it seems safe to + assume that they are using the encryption. + */ + sqlite3.config.warn( + "Disabling execution of on-open() db code "+ + "because this is an SEE build. DB: "+fnJs + ); + }else if(postInitSql instanceof Function){ + postInitSql(this, sqlite3); + }else{ + checkSqlite3Rc( + pDb, capi.sqlite3_exec(pDb, postInitSql, 0, 0, 0) + ); + } } }catch(e){ this.close(); @@ -288,7 +306,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ For purposes of passing a DB instance to C-style sqlite3 functions, the DB object's read-only `pointer` property holds its `sqlite3*` pointer value. That property can also be used to check - whether this DB instance is still open. + whether this DB instance is still open: it will evaluate to + `undefined` after the DB object's close() method is called. In the main window thread, the filenames `":localStorage:"` and `":sessionStorage:"` are special: they cause the db to use either diff --git a/manifest b/manifest index bf4199ab06..53cd1299e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Continuation\sof\sthe\sfix\sat\s[8c0f69e0e4ae0a44]:\sIf\sa\sviaCoroutine\sFROM\sclause\nterm\sis\sparticipating\sin\sa\sRIGHT\sor\sFULL\sJOIN,\swe\shave\sto\screate\san\nalways-NULL\spseudo-cursor\sfor\sthat\sterm\swhen\sprocessing\sthe\sRIGHT\sjoin.\ndbsqlfuzz\s6fd1ff3a64bef4a6c092e8d757548e95698b0df5. -D 2024-04-22T00:42:47.056 +C For\ssqlite3.oo1.DB\sJavaScript\sclasses,\sbypass\sexecution\sof\sany\son-open()\sSQL\sin\sSEE-capable\sbuilds\sbecause\sit\swould\snecessarily\srun\sbefore\sthe\sclient\shas\san\sopportunity\sto\sprovide\stheir\sdecryption\skey,\swhich\swould\sleave\sthe\sdb\shandle\sin\san\sunusable\sstate\sand\scause\sthe\sctor\sto\sthrow.\sThis\scurrently\saffects\sonly\sthe\sOPFS\sVFSes.\sWe\smay\swant\sto\sconsider\sextending\sthe\sctor\soptions\sobject\sto\soptionally\saccept\san\sSEE\skey\sand\sapply\sit\swhen\sopening\sthe\sdb. +D 2024-04-22T11:48:03.633 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -606,7 +606,7 @@ F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.js 2d35660c52dcb4bb16d00c56553d34e7caa6ad30083938b515e6f9aa0b312fbb -F ext/wasm/api/sqlite3-api-oo1.js 365b3ae01a461dc974796823652ef1ecb1a9fac5df295ee1a78002cc77afb0d8 +F ext/wasm/api/sqlite3-api-oo1.js 5b61a9ea9465d75a6086f89273778cad0c3c1794a59c23cce3363e06a1f78bfb F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5560df2726fed215c98d602c5f6ebbf3c5ae23f8ba1074291c509bf446fdfe66 -R ae9a50293e0c35742076bd20e79d2b4c -U drh -Z 44b0654aae70868bd62dea2cbd768897 +P e1040e51ebd04f2a076f477b6f240f849afb10f543ebe518e09d6842cc3cb38e +R c8b46c18574828a10017e60145eb2add +U stephan +Z 3fe04d60fbd968edc5f33b93665df17f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 192803b3e3..fa166b8784 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1040e51ebd04f2a076f477b6f240f849afb10f543ebe518e09d6842cc3cb38e \ No newline at end of file +5c505ee8a73f4b4a7053d98a12024d98340676f6ae9982311f9f88a9b46c8ae2 \ No newline at end of file From 4f2f6c74cab89f6075bc77e1ea0ba128ee8f91bf Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 22 Apr 2024 13:31:24 +0000 Subject: [PATCH 0332/1030] Extra robustness in the code that causes cursors to return NULL when they are participating in an OUTER JOIN. FossilOrigin-Name: 672c2869ef48e08447d37b0d76a1850cdafbe30ca1906ec98c55e3ab496fd9a6 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 3 +-- src/wherecode.c | 12 +++++------- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 53cd1299e0..c203544e0b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\ssqlite3.oo1.DB\sJavaScript\sclasses,\sbypass\sexecution\sof\sany\son-open()\sSQL\sin\sSEE-capable\sbuilds\sbecause\sit\swould\snecessarily\srun\sbefore\sthe\sclient\shas\san\sopportunity\sto\sprovide\stheir\sdecryption\skey,\swhich\swould\sleave\sthe\sdb\shandle\sin\san\sunusable\sstate\sand\scause\sthe\sctor\sto\sthrow.\sThis\scurrently\saffects\sonly\sthe\sOPFS\sVFSes.\sWe\smay\swant\sto\sconsider\sextending\sthe\sctor\soptions\sobject\sto\soptionally\saccept\san\sSEE\skey\sand\sapply\sit\swhen\sopening\sthe\sdb. -D 2024-04-22T11:48:03.633 +C Extra\srobustness\sin\sthe\scode\sthat\scauses\scursors\sto\sreturn\sNULL\swhen\sthey\nare\sparticipating\sin\san\sOUTER\sJOIN. +D 2024-04-22T13:31:24.188 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,9 +835,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 40ee94edd4cf31e6dc3e4c9ac814777b8cf4dc8ee985d87eb5f77bd4c42e69da +F src/where.c c6c14735091b8716763c05fb8db8b32907f4edca96ba0095bff892fbaba7f0e9 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 -F src/wherecode.c b0224e0ec3c3c4e94cbdd221df109974a1bb26255637383f0fd81795358326fc +F src/wherecode.c 1f6940349e92a6e056aecd70163b00f331554c815c362b4cc80906c48151d73d F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e1040e51ebd04f2a076f477b6f240f849afb10f543ebe518e09d6842cc3cb38e -R c8b46c18574828a10017e60145eb2add -U stephan -Z 3fe04d60fbd968edc5f33b93665df17f +P 5c505ee8a73f4b4a7053d98a12024d98340676f6ae9982311f9f88a9b46c8ae2 +R cf33b03e4c9b76c0999c9981aab311dd +U drh +Z 8e2859a20a59f6d407b535859ed9b4c0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fa166b8784..41b06bb769 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c505ee8a73f4b4a7053d98a12024d98340676f6ae9982311f9f88a9b46c8ae2 \ No newline at end of file +672c2869ef48e08447d37b0d76a1850cdafbe30ca1906ec98c55e3ab496fd9a6 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 93984347b7..95bea115d1 100644 --- a/src/where.c +++ b/src/where.c @@ -6948,9 +6948,8 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ assert( pSrc->pTab!=0 ); m = pSrc->pTab->nCol; sqlite3VdbeAddOp3(v, OP_Null, 0, n, n+m-1); - }else{ - sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur); } + sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur); } if( (ws & WHERE_INDEXED) || ((ws & WHERE_MULTI_OR) && pLevel->u.pCoveringIdx) diff --git a/src/wherecode.c b/src/wherecode.c index cad2293ddd..d95eae2797 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -2739,13 +2739,11 @@ SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( v, OP_Null, 0, pRight->regResult, pRight->regResult + pRight->pSelect->pEList->nExpr-1 ); - sqlite3VdbeAddOp1(v, OP_OpenPseudo, pWInfo->a[k].iTabCur); - }else{ - sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); - iIdxCur = pWInfo->a[k].iIdxCur; - if( iIdxCur ){ - sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur); - } + } + sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); + iIdxCur = pWInfo->a[k].iIdxCur; + if( iIdxCur ){ + sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur); } } if( (pTabItem->fg.jointype & JT_LTORJ)==0 ){ From 0a42e9913b233d433bd526c4c76825d0e1785bb6 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 22 Apr 2024 16:46:37 +0000 Subject: [PATCH 0333/1030] Extend the JS/WASM SEE build support by (A) filtering SEE-related bits out of the JS when not building with SEE and (B) accepting an optional key/textkey/hexkey option to the sqlite3.oo1.DB and subclass constructors to create/open SEE-encrypted databases with. Demonstrate SEE in the test app using the kvvfs. This obviates the changes made in [5c505ee8a7]. FossilOrigin-Name: 8fbda563d2f56f8dd3f695a5711e4356de79035f332270db45d4b33ed52fdfd2 --- ext/wasm/GNUmakefile | 9 +- ext/wasm/api/sqlite3-api-glue.js | 8 +- ext/wasm/api/sqlite3-api-oo1.js | 156 ++++++++++++++++++++++++++----- ext/wasm/api/sqlite3-wasm.c | 19 ++++ ext/wasm/tester1.c-pp.js | 52 ++++++++++- manifest | 22 ++--- manifest.uuid | 2 +- 7 files changed, 226 insertions(+), 42 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 6e7b49875f..1a119f9505 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -335,19 +335,26 @@ DISTCLEAN_FILES += $(bin.stripccomments) # # Note that the SQLITE_... build flags used here have NO EFFECT on the # JS/WASM build. They are solely for use with $(bin.c-pp) itself. +# +# -D... flags which should be included in all invocations should be +# appended to $(C-PP.FILTER.global). bin.c-pp := ./c-pp $(bin.c-pp): c-pp.c $(sqlite3.c) $(MAKEFILE) $(CC) -O0 -o $@ c-pp.c $(sqlite3.c) '-DCMPP_DEFAULT_DELIM="//#"' -I$(dir.top) \ -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_UTF16 \ -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_WAL -DSQLITE_THREADSAFE=0 \ -DSQLITE_TEMP_STORE=3 +C-PP.FILTER.global ?= +ifeq (1,$(SQLITE_C_IS_SEE)) + C-PP.FILTER.global += -Denable-see +endif define C-PP.FILTER # Create $2 from $1 using $(bin.c-pp) # $1 = Input file: c-pp -f $(1).js # $2 = Output file: c-pp -o $(2).js # $3 = optional c-pp -D... flags $(2): $(1) $$(MAKEFILE) $$(bin.c-pp) - $$(bin.c-pp) -f $(1) -o $$@ $(3) + $$(bin.c-pp) -f $(1) -o $$@ $(3) $(C-PP.FILTER.global) CLEAN_FILES += $(2) endef # /end C-PP.FILTER diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index b05d7a765a..cec0a8c0af 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -329,7 +329,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ wasm.bindingSignatures.push(["sqlite3_normalized_sql", "string", "sqlite3_stmt*"]); } - if(wasm.exports.sqlite3_activate_see instanceof Function){ +//#if enable-see + if(wasm.exports.sqlite3_key_v2 instanceof Function){ /** This code is capable of using an SEE build but note that an SEE WASM build is generally incompatible with SEE's license @@ -346,6 +347,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_activate_see", undefined, "string"] ); } +//#endif enable-see + /** Functions which require BigInt (int64) support are separated from the others because we need to conditionally bind them or apply @@ -627,7 +630,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3__wasm_vfs_create_file", "int", "sqlite3_vfs*","string","*", "int"], ["sqlite3__wasm_posix_create_file", "int", "string","*", "int"], - ["sqlite3__wasm_vfs_unlink", "int", "sqlite3_vfs*","string"] + ["sqlite3__wasm_vfs_unlink", "int", "sqlite3_vfs*","string"], + ["sqlite3__wasm_qfmt_token","string:dealloc", "string","int"] ]; /** diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index 06d1df43f9..a5dfcec958 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -87,6 +87,94 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ */ const __vfsPostOpenSql = Object.create(null); + /** + Converts ArrayBuffer or Uint8Array ba into a string of hex + digits. + */ + const byteArrayToHex = function(ba){ + if( ba instanceof ArrayBuffer ){ + ba = new Uint8Array(ba); + } + const li = []; + const digits = "0123456789abcdef"; + for( const d of ba ){ + li.push( digits[(d & 0xf0) >> 4], digits[d & 0x0f] ); + } + return li.join(''); + }; + +//#if enable-see + /** + Internal helper to apply an SEE key to a just-opened + database. Requires that db be-a DB object which has just been + opened, opt be the options object processed by its ctor, and opt + must have either the key, hexkey, or textkey properties, either + as a string, an ArrayBuffer, or a Uint8Array. + + This is a no-op in non-SEE builds. It throws on error and returns + without side effects if its key/textkey options are not of valid + types. + + Returns true if it applies the key, else a falsy value. + */ + const dbCtorApplySEEKey = function(db,opt){ + if( !capi.sqlite3_key_v2 ) return; + let keytype; + let key; + const check = (opt.key ? 1 : 0) + (opt.hexkey ? 1 : 0) + (opt.textkey ? 1 : 0); + if( !check ) return; + else if( check>1 ) toss3("Only ONE of (key, hexkey, textkey) may be provided."); + if( opt.key ){ + /* It is not legal to bind an argument to PRAGMA key=?, so we + convert it to a hexkey... */ + keytype = 'key'; + key = opt.key; + if('string'===typeof key){ + key = new TextEncoder('utf-8').encode(key); + } + if((key instanceof ArrayBuffer) || (key instanceof Uint8Array)){ + key = byteArrayToHex(key); + keytype = 'hexkey'; + }else{ + toss3("Invalid value for the 'key' option. Expecting a string, ArrayBuffer, or Uint8Array."); + return; + } + }else if( opt.textkey ){ + /* For textkey we need it to be in string form, so convert it to + a string if it's a byte array... */ + keytype = 'textkey'; + key = opt.textkey; + if(key instanceof ArrayBuffer){ + key = new Uint8Array(key); + } + if(key instanceof Uint8Array){ + key = new TextDecoder('utf-8').decode(key); + }else if('string'!==typeof key){ + toss3("Invalid value for the 'textkey' option. Expecting a string, ArrayBuffer, or Uint8Array."); + } + }else if( opt.hexkey ){ + keytype = 'hexkey'; + key = opt.hexkey; + if((key instanceof ArrayBuffer) || (key instanceof Uint8Array)){ + key = byteArrayToHex(key); + }else if('string'!==typeof key){ + toss3("Invalid value for the 'hexkey' option. Expecting a string, ArrayBuffer, or Uint8Array."); + } + /* else assume it's valid hex codes */; + }else{ + return; + } + let stmt; + try{ + stmt = db.prepare("PRAGMA "+keytype+"="+util.sqlite3__wasm_qfmt_token(key, 1)); + stmt.step(); + }finally{ + if(stmt) stmt.finalize(); + } + return true; + }; +//#endif enable-see + /** A proxy for DB class constructors. It must be called with the being-construct DB object as its "this". See the DB constructor @@ -175,28 +263,22 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ __ptrMap.set(this, pDb); __stmtMap.set(this, Object.create(null)); try{ +//#if enable-see + dbCtorApplySEEKey(this,opt); +//#endif // Check for per-VFS post-open SQL/callback... - const pVfs = capi.sqlite3_js_db_vfs(pDb); - if(!pVfs) toss3("Internal error: cannot get VFS for new db handle."); + const pVfs = capi.sqlite3_js_db_vfs(pDb) + || toss3("Internal error: cannot get VFS for new db handle."); const postInitSql = __vfsPostOpenSql[pVfs]; if(postInitSql){ - if(capi.sqlite3_activate_see){ - /** - In SEE-capable builds we have to avoid running any db - code before the client has an opportunity to apply their - decryption key. If we first run any db code, e.g. pragma - journal_mode=..., then it will fail with SQLITE_NOTADB - and the db handle will be left in an unusuable - state. Note that at this point we do not actually know - whether the db is encrypted, but if a client has gone out - of their way to create an SEE build, it seems safe to - assume that they are using the encryption. - */ - sqlite3.config.warn( - "Disabling execution of on-open() db code "+ - "because this is an SEE build. DB: "+fnJs - ); - }else if(postInitSql instanceof Function){ + /** + Reminder: if this db is encrypted and the client did _not_ pass + in the key, any init code will fail, causing the ctor to throw. + We don't actually know whether the db is encrypted, so we cannot + sensibly apply any heuristics which skip the init code only for + encrypted databases for which no key has yet been supplied. + */ + if(postInitSql instanceof Function){ postInitSql(this, sqlite3); }else{ checkSqlite3Rc( @@ -298,6 +380,20 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ - `flags`: open-mode flags - `vfs`: the VFS fname +//#if enable-see + And, for SEE-capable builds, optionally ONE of the following: + + - `key`, `hexkey`, or `textkey`: encryption key as a string, + ArrayBuffer, or Uint8Array. These flags function as documented + for the SEE pragmas of the same names. + + In non-SEE builds, these options are ignored. In SEE builds, + `PRAGMA key/textkey/hexkey=X` is executed immediately after + opening the db. If more than one of the options is provided, + or any option has an invalid argument type, an exception is + thrown. +//#endif enable-see + The `filename` and `vfs` arguments may be either JS strings or C-strings allocated via WASM. `flags` is required to be a JS string (because it's specific to this API, which is specific @@ -1562,7 +1658,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ they are larger than 32 bits, else double or int32, depending on whether they have a fractional part. Booleans are bound as integer 0 or 1. It is not expected the distinction of binding - doubles which have no fractional parts is integers is + doubles which have no fractional parts and integers is significant for the majority of clients due to sqlite3's data typing model. If [BigInt] support is enabled then this routine will bind BigInt values as 64-bit integers if they'll @@ -1946,16 +2042,26 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Functionally equivalent to DB(storageName,'c','kvvfs') except that it throws if the given storage name is not one of 'local' or 'session'. + + As of version 3.46, the argument may optionally be an options + object in the form: + + { + filename: 'session'|'local', + ... etc. (all options supported by the DB ctor) + } + + noting that the 'vfs' option supported by main DB + constructor is ignored here: the vfs is always 'kvvfs'. */ sqlite3.oo1.JsStorageDb = function(storageName='session'){ + const opt = dbCtorHelper.normalizeArgs(...arguments); + storageName = opt.filename; if('session'!==storageName && 'local'!==storageName){ toss3("JsStorageDb db name must be one of 'session' or 'local'."); } - dbCtorHelper.call(this, { - filename: storageName, - flags: 'c', - vfs: "kvvfs" - }); + opt.vfs = 'kvvfs'; + dbCtorHelper.call(this, opt); }; const jdb = sqlite3.oo1.JsStorageDb; jdb.prototype = Object.create(DB.prototype); diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index cc1db6723a..d315b43d6b 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -1678,6 +1678,25 @@ int sqlite3__wasm_config_j(int op, sqlite3_int64 arg){ return sqlite3_config(op, arg); } +/* +** This function is NOT part of the sqlite3 public API. It is strictly +** for use by the sqlite project's own JS/WASM bindings. +** +** If z is not NULL, returns the result of passing z to +** sqlite3_mprintf()'s %Q modifier (if addQuotes is true) or %q (if +** addQuotes is 0). Returns NULL if z is NULL or on OOM. +*/ +SQLITE_WASM_EXPORT +char * sqlite3__wasm_qfmt_token(char *z, int addQuotes){ + char * rc = 0; + if( z ){ + rc = addQuotes + ? sqlite3_mprintf("%Q", z) + : sqlite3_mprintf("%q", z); + } + return rc; +} + #if 0 // Pending removal after verification of a workaround discussed in the // forum post linked to below. diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index fdde986355..e78897bedf 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -1482,7 +1482,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; /*step() skipped intentionally*/.reset(true); } finally { T.assert(0===st.finalize()) - .assert(undefined===st.finalize()); + .assert(undefined===st.finalize()); } try { @@ -2587,7 +2587,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; const pVfs = capi.sqlite3_vfs_find('kvvfs'); T.assert(pVfs); const JDb = this.JDb = sqlite3.oo1.JsStorageDb; - const unlink = this.kvvfsUnlink = ()=>{JDb.clearStorage(filename)}; + const unlink = this.kvvfsUnlink = ()=>JDb.clearStorage(this.kvvfsDbFile); unlink(); let db = new JDb(filename); try { @@ -2605,6 +2605,54 @@ globalThis.sqlite3InitModule = sqlite3InitModule; } } }/*kvvfs sanity checks*/) +//#if enable-see + .t({ + name: 'kvvfs with SEE encryption', + predicate: ()=>(isUIThread() + || "Only available in main thread."), + test: function(sqlite3){ + this.kvvfsUnlink(); + let db; + try{ + db = new this.JDb({ + filename: this.kvvfsDbFile, + key: 'foo' + }); + db.exec([ + "create table t(a,b);", + "insert into t(a,b) values(1,2),(3,4)" + ]); + db.close(); + let err; + try{ + db = new this.JDb({ + filename: this.kvvfsDbFile, + flags: 'ct' + }); + T.assert(db) /* opening is fine, but... */; + db.exec("select 1 from sqlite_schema"); + console.warn("sessionStorage =",sessionStorage); + }catch(e){ + err = e; + }finally{ + db.close(); + } + T.assert(err,"Expecting an exception") + .assert(sqlite3.capi.SQLITE_NOTADB==err.resultCode, + "Expecting NOTADB"); + db = new sqlite3.oo1.DB({ + filename: this.kvvfsDbFile, + vfs: 'kvvfs', + hexkey: new Uint8Array([0x66,0x6f,0x6f]) // equivalent: '666f6f' + }); + T.assert( 4===db.selectValue('select sum(a) from t') ); + }finally{ + if( db ) db.close(); + this.kvvfsUnlink(); + } + } + })/*kvvfs with SEE*/ +//#endif enable-see ;/* end kvvfs tests */ //////////////////////////////////////////////////////////////////////// diff --git a/manifest b/manifest index c203544e0b..a0cb0217b3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Extra\srobustness\sin\sthe\scode\sthat\scauses\scursors\sto\sreturn\sNULL\swhen\sthey\nare\sparticipating\sin\san\sOUTER\sJOIN. -D 2024-04-22T13:31:24.188 +C Extend\sthe\sJS/WASM\sSEE\sbuild\ssupport\sby\s(A)\sfiltering\sSEE-related\sbits\sout\sof\sthe\sJS\swhen\snot\sbuilding\swith\sSEE\sand\s(B)\saccepting\san\soptional\skey/textkey/hexkey\soption\sto\sthe\ssqlite3.oo1.DB\sand\ssubclass\sconstructors\sto\screate/open\sSEE-encrypted\sdatabases\swith.\sDemonstrate\sSEE\sin\sthe\stest\sapp\susing\sthe\skvvfs.\sThis\sobviates\sthe\schanges\smade\sin\s[5c505ee8a7]. +D 2024-04-22T16:46:37.381 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -587,7 +587,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 4bb4cf70a8153dd5b5fee17d724075c54174da630b424bbcf48c744633396f62 +F ext/wasm/GNUmakefile 0d5ccc8a4814716c1c789bb3069dd4d71d5ef0a97bbea074ac182fbfb85a3ca8 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -605,8 +605,8 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.js 2d35660c52dcb4bb16d00c56553d34e7caa6ad30083938b515e6f9aa0b312fbb -F ext/wasm/api/sqlite3-api-oo1.js 5b61a9ea9465d75a6086f89273778cad0c3c1794a59c23cce3363e06a1f78bfb +F ext/wasm/api/sqlite3-api-glue.js c744f4b919e1254c898b467573858671a1c8797c2490d0eca2fdbadf2d0ac74b +F ext/wasm/api/sqlite3-api-oo1.js 708934dd9919863bb67e2a54ba6604b05835ba3779d4dc4486218c8512eb0771 F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 @@ -615,7 +615,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 -F ext/wasm/api/sqlite3-wasm.c afba6827a49151b564af5cf588a6bbd0401b16ef5cbe3269c66f676fee9ca92c +F ext/wasm/api/sqlite3-wasm.c 3f744dc45ac4be8125d58364448bdc9c082f332a88cec211bfd0143ad0acb373 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bd89edfe42a4d7122a6d6d405c5423cf00aabba1f76f6ea8e2dba9c628ddd91a F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -662,7 +662,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 18331ec28d7e63c8e262a9872a8da3964d37b7ac22eabe0016af93f3c6f74cc4 +F ext/wasm/tester1.c-pp.js 9f8ae7c716ad66523cd6238fe947826c82b6a3b5c1e9d528f9f39ad9c9280ac7 F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5c505ee8a73f4b4a7053d98a12024d98340676f6ae9982311f9f88a9b46c8ae2 -R cf33b03e4c9b76c0999c9981aab311dd -U drh -Z 8e2859a20a59f6d407b535859ed9b4c0 +P 672c2869ef48e08447d37b0d76a1850cdafbe30ca1906ec98c55e3ab496fd9a6 +R 69f9c602594d1ff3e9a25e02a2d41151 +U stephan +Z 6ab53eec83d52fe93f0c77e2c64383e8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 41b06bb769..61afb9adfe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -672c2869ef48e08447d37b0d76a1850cdafbe30ca1906ec98c55e3ab496fd9a6 \ No newline at end of file +8fbda563d2f56f8dd3f695a5711e4356de79035f332270db45d4b33ed52fdfd2 \ No newline at end of file From 5d8daf184d94e86695f45ea8b8b37e9517f7b000 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 22 Apr 2024 17:03:52 +0000 Subject: [PATCH 0334/1030] Minor cleanups to [8fbda563d2f5]. FossilOrigin-Name: 5ee2594b657b96aea9e482a175820dcbacfa9298da45b38cf17f39ad076d3f7f --- ext/wasm/api/sqlite3-api-oo1.js | 12 +++++++++--- ext/wasm/tester1.c-pp.js | 10 ++++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index a5dfcec958..b225d80b96 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -87,6 +87,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ */ const __vfsPostOpenSql = Object.create(null); +//#if enable-see /** Converts ArrayBuffer or Uint8Array ba into a string of hex digits. @@ -103,7 +104,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return li.join(''); }; -//#if enable-see /** Internal helper to apply an SEE key to a just-opened database. Requires that db be-a DB object which has just been @@ -160,7 +160,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }else if('string'!==typeof key){ toss3("Invalid value for the 'hexkey' option. Expecting a string, ArrayBuffer, or Uint8Array."); } - /* else assume it's valid hex codes */; + /* else assume it's valid hex codes */ }else{ return; } @@ -385,7 +385,13 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ - `key`, `hexkey`, or `textkey`: encryption key as a string, ArrayBuffer, or Uint8Array. These flags function as documented - for the SEE pragmas of the same names. + for the SEE pragmas of the same names. Using a byte array for + `hexkey` is equivalent to the same series of hex codes in + string form, so '666f6f' is equivalent to + Uint8Array([0x66,0x6f,0x6f]). A `textkey` byte array is assumed + to be UTF-8. A `key` string is transformed into a UTF-8 byte + array, and a `key` byte array is transformed into a `hexkey` + with the same bytes. In non-SEE builds, these options are ignored. In SEE builds, `PRAGMA key/textkey/hexkey=X` is executed immediately after diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index e78897bedf..fe5bdc8372 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2613,10 +2613,16 @@ globalThis.sqlite3InitModule = sqlite3InitModule; test: function(sqlite3){ this.kvvfsUnlink(); let db; + const encOpt1 = 1 + ? {textkey: 'foo'} + : {key: 'foo'}; + const encOpt2 = encOpt1.textkey + ? encOpt1 + : {hexkey: new Uint8Array([0x66,0x6f,0x6f]/*==>"foo"*/)} try{ db = new this.JDb({ filename: this.kvvfsDbFile, - key: 'foo' + ...encOpt1 }); db.exec([ "create table t(a,b);", @@ -2643,7 +2649,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; db = new sqlite3.oo1.DB({ filename: this.kvvfsDbFile, vfs: 'kvvfs', - hexkey: new Uint8Array([0x66,0x6f,0x6f]) // equivalent: '666f6f' + ...encOpt2 }); T.assert( 4===db.selectValue('select sum(a) from t') ); }finally{ diff --git a/manifest b/manifest index a0cb0217b3..4c968dedd4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Extend\sthe\sJS/WASM\sSEE\sbuild\ssupport\sby\s(A)\sfiltering\sSEE-related\sbits\sout\sof\sthe\sJS\swhen\snot\sbuilding\swith\sSEE\sand\s(B)\saccepting\san\soptional\skey/textkey/hexkey\soption\sto\sthe\ssqlite3.oo1.DB\sand\ssubclass\sconstructors\sto\screate/open\sSEE-encrypted\sdatabases\swith.\sDemonstrate\sSEE\sin\sthe\stest\sapp\susing\sthe\skvvfs.\sThis\sobviates\sthe\schanges\smade\sin\s[5c505ee8a7]. -D 2024-04-22T16:46:37.381 +C Minor\scleanups\sto\s[8fbda563d2f5]. +D 2024-04-22T17:03:52.050 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -606,7 +606,7 @@ F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.js c744f4b919e1254c898b467573858671a1c8797c2490d0eca2fdbadf2d0ac74b -F ext/wasm/api/sqlite3-api-oo1.js 708934dd9919863bb67e2a54ba6604b05835ba3779d4dc4486218c8512eb0771 +F ext/wasm/api/sqlite3-api-oo1.js 7a7828c2748d60664f155821fab2d091db23399e64f3470ea14f52080d3573f7 F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 @@ -662,7 +662,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 9f8ae7c716ad66523cd6238fe947826c82b6a3b5c1e9d528f9f39ad9c9280ac7 +F ext/wasm/tester1.c-pp.js 6d0a9aa44a97b4aadd582e0999ce45a2671b854a12ea3205d1c908da6bd4bdef F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 672c2869ef48e08447d37b0d76a1850cdafbe30ca1906ec98c55e3ab496fd9a6 -R 69f9c602594d1ff3e9a25e02a2d41151 +P 8fbda563d2f56f8dd3f695a5711e4356de79035f332270db45d4b33ed52fdfd2 +R 0674b1f5ea56f016fc52480ad40ed87d U stephan -Z 6ab53eec83d52fe93f0c77e2c64383e8 +Z 40a1a10b8d303ee230e900a2b2af4afd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 61afb9adfe..049eae30ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8fbda563d2f56f8dd3f695a5711e4356de79035f332270db45d4b33ed52fdfd2 \ No newline at end of file +5ee2594b657b96aea9e482a175820dcbacfa9298da45b38cf17f39ad076d3f7f \ No newline at end of file From 46435a04fd295e325f7d25839abd85be49d1d6d2 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 22 Apr 2024 20:09:17 +0000 Subject: [PATCH 0335/1030] Add extra tests for aborting conflicts in the sessions module. FossilOrigin-Name: b4a6d32662acacb7767cfb9b8e040e6eb1f99322cb7d0cd44e6265e9ac2fb2e8 --- ext/session/sessionconflict.test | 75 ++++++++++++++++++++++++++++++++ manifest | 13 +++--- manifest.uuid | 2 +- 3 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 ext/session/sessionconflict.test diff --git a/ext/session/sessionconflict.test b/ext/session/sessionconflict.test new file mode 100644 index 0000000000..c842a8aacb --- /dev/null +++ b/ext/session/sessionconflict.test @@ -0,0 +1,75 @@ +# 2011 March 07 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. +# + +if {![info exists testdir]} { + set testdir [file join [file dirname [info script]] .. .. test] +} +source [file join [file dirname [info script]] session_common.tcl] +source $testdir/tester.tcl +ifcapable !session {finish_test; return} + +set testprefix sessionconflict + +sqlite3_shutdown +test_sqlite3_log log +proc log {code msg} { puts "LOG $code $msg" } +sqlite3 db test.db + +forcedelete test.db2 +sqlite3 db2 test.db2 + +do_test 1.0 { + do_common_sql { + CREATE TABLE t1(a PRIMARY KEY, b, c UNIQUE); + INSERT INTO t1 VALUES(1, 1, 1); + INSERT INTO t1 VALUES(2, 2, 2); + INSERT INTO t1 VALUES(3, 3, 3); + } +} {} + +do_execsql_test -db db2 1.1 { + INSERT INTO t1 VALUES(6, 6, 6); +} + +proc xConflict {args} { + return "ABORT" +} + + +do_test 1.2 { + set chng [changeset_from_sql { + UPDATE t1 SET b=10, c=10 WHERE a=1; + UPDATE t1 SET b=444 WHERE a=2; + INSERT INTO t1 VALUES(4, 4, 4); + INSERT INTO t1 VALUES(5, 5, 5); + INSERT INTO t1 VALUES(6, 6, 6); + }] + + execsql BEGIN db2 + set res [list [catch { sqlite3changeset_apply db2 $chng xConflict } msg] $msg] + execsql ROLLBACK db2 + set res +} {1 SQLITE_ABORT} + +do_execsql_test -db db2 1.3 { + SELECT * FROM t1; +} { + 1 1 1 + 2 2 2 + 3 3 3 + 6 6 6 +} + + + +finish_test diff --git a/manifest b/manifest index 4c968dedd4..f00e2d54f5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\scleanups\sto\s[8fbda563d2f5]. -D 2024-04-22T17:03:52.050 +C Add\sextra\stests\sfor\saborting\sconflicts\sin\sthe\ssessions\smodule. +D 2024-04-22T20:09:17.153 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -566,6 +566,7 @@ F ext/session/session_speed_test.c dcf0ef58d76b70c8fbd9eab3be77cf9deb8bc1638fed8 F ext/session/sessionalter.test 460bdac2832a550519f6bc32e5db2c0cee94f335870aaf25a3a403a81ab20e17 F ext/session/sessionat.test 00c8badb35e43a2f12a716d2734a44d614ff62361979b6b85419035bc04b45ee F ext/session/sessionbig.test 47c381e7acfabeef17d98519a3080d69151723354d220afa2053852182ca7adf +F ext/session/sessionconflict.test 28890457bb90457be772d3067cdb5f78db9b51d997e4f3d09f22cddc9be80a38 F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec F ext/session/sessionfault.test 573bf027fb870d57bd4e7cf50822a3e4b17b2b923407438747aaa918dec57a09 F ext/session/sessionfault2.test b0d6a7c1d7398a7e800d84657404909c7d385965ea8576dc79ed344c46fbf41c @@ -2184,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8fbda563d2f56f8dd3f695a5711e4356de79035f332270db45d4b33ed52fdfd2 -R 0674b1f5ea56f016fc52480ad40ed87d -U stephan -Z 40a1a10b8d303ee230e900a2b2af4afd +P 5ee2594b657b96aea9e482a175820dcbacfa9298da45b38cf17f39ad076d3f7f +R 95bcc3fd0d6dba3139788e0776ab3daa +U dan +Z c4a19dd969db970154ebbee1de10bace # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 049eae30ae..89e87de37d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5ee2594b657b96aea9e482a175820dcbacfa9298da45b38cf17f39ad076d3f7f \ No newline at end of file +b4a6d32662acacb7767cfb9b8e040e6eb1f99322cb7d0cd44e6265e9ac2fb2e8 \ No newline at end of file From 6e6dfd6a236396b58b06d7636233f7687eea37b2 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 23 Apr 2024 05:38:49 +0000 Subject: [PATCH 0336/1030] When running the 'dist' target in ext/wasm for an SEE-capable build, ensure that the resulting zip file and directory name include '-see'. FossilOrigin-Name: 04c552b12e3b77b9dfd83838d35ce19a37ed024a8c18a2000ada10cf3d1eb6ad --- ext/wasm/dist.make | 9 +++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ext/wasm/dist.make b/ext/wasm/dist.make index 0ea53063b4..e820e066d4 100644 --- a/ext/wasm/dist.make +++ b/ext/wasm/dist.make @@ -19,10 +19,15 @@ MAKEFILE.dist := $(lastword $(MAKEFILE_LIST)) # built, and won't be built until we expand the dependencies. Thus we # have to use a temporary name for the archive until we can get # that binary built. +ifeq (1,$(SQLITE_C_IS_SEE)) +dist-name-extra := -see +else +dist-name-extra := +endif ifeq (,$(filter snapshot,$(MAKECMDGOALS))) -dist-name-prefix := sqlite-wasm +dist-name-prefix := sqlite-wasm$(dist-name-extra) else -dist-name-prefix := sqlite-wasm-snapshot-$(shell /usr/bin/date +%Y%m%d) +dist-name-prefix := sqlite-wasm$(dist-name-extra)-snapshot-$(shell /usr/bin/date +%Y%m%d) endif dist-name := $(dist-name-prefix)-TEMP diff --git a/manifest b/manifest index f00e2d54f5..7b3f6096ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\stests\sfor\saborting\sconflicts\sin\sthe\ssessions\smodule. -D 2024-04-22T20:09:17.153 +C When\srunning\sthe\s'dist'\starget\sin\sext/wasm\sfor\san\sSEE-capable\sbuild,\sensure\sthat\sthe\sresulting\szip\sfile\sand\sdirectory\sname\sinclude\s'-see'. +D 2024-04-23T05:38:49.383 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -637,7 +637,7 @@ F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a F ext/wasm/demo-worker1-promiser.c-pp.js fcc628cb42fcfaf07d250477801de1e6deb1e319d003976612a0db8d76b9fccc F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef -F ext/wasm/dist.make f2ce42305268fe33d4b50f6e4bb3daf4a60302a90736eee382f1b8af9ff32ec1 +F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle.make 3c2eace29255d6ddd219f5d8cc2728cb28b9fe717ea80b6062c2a6178947a16b F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5ee2594b657b96aea9e482a175820dcbacfa9298da45b38cf17f39ad076d3f7f -R 95bcc3fd0d6dba3139788e0776ab3daa -U dan -Z c4a19dd969db970154ebbee1de10bace +P b4a6d32662acacb7767cfb9b8e040e6eb1f99322cb7d0cd44e6265e9ac2fb2e8 +R 7804df285b1889ac6d0dbfb4c36fb69b +U stephan +Z 47a1361c4075358585b8d5f5c90006b4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 89e87de37d..a235332cd6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b4a6d32662acacb7767cfb9b8e040e6eb1f99322cb7d0cd44e6265e9ac2fb2e8 \ No newline at end of file +04c552b12e3b77b9dfd83838d35ce19a37ed024a8c18a2000ada10cf3d1eb6ad \ No newline at end of file From 642e950e637beaa6699db78f3c12f1bceae924b4 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 23 Apr 2024 06:36:28 +0000 Subject: [PATCH 0337/1030] Minor touchups in JS docs and exception messages. FossilOrigin-Name: 9e7fc9370dfca121244f7a2941e8de629b277f1799f8de08a43ff1d86f94b6f5 --- ext/wasm/api/sqlite3-api-oo1.js | 46 ++++++++++++++++++++-------- ext/wasm/api/sqlite3-api-prologue.js | 2 +- manifest | 14 ++++----- manifest.uuid | 2 +- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index b225d80b96..8cd50a14bb 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -112,10 +112,11 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ as a string, an ArrayBuffer, or a Uint8Array. This is a no-op in non-SEE builds. It throws on error and returns - without side effects if its key/textkey options are not of valid - types. + without side effects if none of the key/textkey/hexkey options + are set. It throws if more than one is set or if any are set to + values of an invalid type. - Returns true if it applies the key, else a falsy value. + Returns true if it applies the key, else an unspecified falsy value. */ const dbCtorApplySEEKey = function(db,opt){ if( !capi.sqlite3_key_v2 ) return; @@ -123,7 +124,10 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ let key; const check = (opt.key ? 1 : 0) + (opt.hexkey ? 1 : 0) + (opt.textkey ? 1 : 0); if( !check ) return; - else if( check>1 ) toss3("Only ONE of (key, hexkey, textkey) may be provided."); + else if( check>1 ){ + toss3(capi.SQLITE_MISUSE, + "Only ONE of (key, hexkey, textkey) may be provided."); + } if( opt.key ){ /* It is not legal to bind an argument to PRAGMA key=?, so we convert it to a hexkey... */ @@ -136,7 +140,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ key = byteArrayToHex(key); keytype = 'hexkey'; }else{ - toss3("Invalid value for the 'key' option. Expecting a string, ArrayBuffer, or Uint8Array."); + toss3(capi.SQLITE_MISUSE, + "Invalid value for the 'key' option. Expecting a string,", + "ArrayBuffer, or Uint8Array."); return; } }else if( opt.textkey ){ @@ -150,7 +156,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ if(key instanceof Uint8Array){ key = new TextDecoder('utf-8').decode(key); }else if('string'!==typeof key){ - toss3("Invalid value for the 'textkey' option. Expecting a string, ArrayBuffer, or Uint8Array."); + toss3(capi.SQLITE_MISUSE, + "Invalid value for the 'textkey' option. Expecting a string,", + "ArrayBuffer, or Uint8Array."); } }else if( opt.hexkey ){ keytype = 'hexkey'; @@ -158,7 +166,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ if((key instanceof ArrayBuffer) || (key instanceof Uint8Array)){ key = byteArrayToHex(key); }else if('string'!==typeof key){ - toss3("Invalid value for the 'hexkey' option. Expecting a string, ArrayBuffer, or Uint8Array."); + toss3(capi.SQLITE_MISUSE, + "Invalid value for the 'hexkey' option. Expecting a string,", + "ArrayBuffer, or Uint8Array."); } /* else assume it's valid hex codes */ }else{ @@ -381,23 +391,33 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ - `vfs`: the VFS fname //#if enable-see - And, for SEE-capable builds, optionally ONE of the following: + + SEE-capable builds optionally support ONE of the following + additional options: - `key`, `hexkey`, or `textkey`: encryption key as a string, ArrayBuffer, or Uint8Array. These flags function as documented for the SEE pragmas of the same names. Using a byte array for `hexkey` is equivalent to the same series of hex codes in - string form, so '666f6f' is equivalent to - Uint8Array([0x66,0x6f,0x6f]). A `textkey` byte array is assumed - to be UTF-8. A `key` string is transformed into a UTF-8 byte - array, and a `key` byte array is transformed into a `hexkey` - with the same bytes. + string form, so `'666f6f'` is equivalent to + `Uint8Array([0x66,0x6f,0x6f])`. A `textkey` byte array is + assumed to be UTF-8. A `key` string is transformed into a UTF-8 + byte array, and a `key` byte array is transformed into a + `hexkey` with the same bytes. In non-SEE builds, these options are ignored. In SEE builds, `PRAGMA key/textkey/hexkey=X` is executed immediately after opening the db. If more than one of the options is provided, or any option has an invalid argument type, an exception is thrown. + + Note that some DB subclasses may run post-initialization SQL + code, e.g. to set a busy-handler timeout or tweak the page cache + size. Such code is run _after_ the SEE key is applied. If no key + is supplied and the database is encrypted, execution of the + post-initialization SQL will fail, causing the constructor to + throw. + //#endif enable-see The `filename` and `vfs` arguments may be either JS strings or diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index c3cc25f43a..849dfe10f2 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -245,7 +245,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( The exception's message is created by concatenating its arguments with a space between each, except for the - two-args-with-an-objec form and that the first argument will + two-args-with-an-object form and that the first argument will get coerced to a string, as described above, if it's an integer. diff --git a/manifest b/manifest index 7b3f6096ff..59bddf164c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\srunning\sthe\s'dist'\starget\sin\sext/wasm\sfor\san\sSEE-capable\sbuild,\sensure\sthat\sthe\sresulting\szip\sfile\sand\sdirectory\sname\sinclude\s'-see'. -D 2024-04-23T05:38:49.383 +C Minor\stouchups\sin\sJS\sdocs\sand\sexception\smessages. +D 2024-04-23T06:36:28.862 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -607,8 +607,8 @@ F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.js c744f4b919e1254c898b467573858671a1c8797c2490d0eca2fdbadf2d0ac74b -F ext/wasm/api/sqlite3-api-oo1.js 7a7828c2748d60664f155821fab2d091db23399e64f3470ea14f52080d3573f7 -F ext/wasm/api/sqlite3-api-prologue.js 93a72b07b2a5d964d2edc76a90b439ece49298bd7ba60a1c6ae5d4878213701e +F ext/wasm/api/sqlite3-api-oo1.js 40f6834314b60e636f0046a9c49b8566a992dcf04be9ea593e680c23f6984b2b +F ext/wasm/api/sqlite3-api-prologue.js 34457b25dcf0005c81d76f011f207026ec164f6ff0f69f024b608025ca808ea9 F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 196ad83d36ca794e564044788c9d21b964679d63cad865f604da37c4afc9a285 @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b4a6d32662acacb7767cfb9b8e040e6eb1f99322cb7d0cd44e6265e9ac2fb2e8 -R 7804df285b1889ac6d0dbfb4c36fb69b +P 04c552b12e3b77b9dfd83838d35ce19a37ed024a8c18a2000ada10cf3d1eb6ad +R ed22115253110bc0abaf81953307bf22 U stephan -Z 47a1361c4075358585b8d5f5c90006b4 +Z 8b53fb3b4d609195342a0ce669cacf2a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a235332cd6..0b66f11a13 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -04c552b12e3b77b9dfd83838d35ce19a37ed024a8c18a2000ada10cf3d1eb6ad \ No newline at end of file +9e7fc9370dfca121244f7a2941e8de629b277f1799f8de08a43ff1d86f94b6f5 \ No newline at end of file From 3ac612dd7d242c5ed0d23000b7cb212e75a10874 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 23 Apr 2024 06:49:47 +0000 Subject: [PATCH 0338/1030] Remove some dead WASM-side code. FossilOrigin-Name: 0a07ee27bd6021a6fc1d81133012592351530ffcf6ae09322ea74624cff910df --- ext/wasm/api/sqlite3-wasm.c | 30 ------------------------------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index d315b43d6b..48ae2297ad 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -1697,36 +1697,6 @@ char * sqlite3__wasm_qfmt_token(char *z, int addQuotes){ return rc; } -#if 0 -// Pending removal after verification of a workaround discussed in the -// forum post linked to below. -/* -** This function is NOT part of the sqlite3 public API. It is strictly -** for use by the sqlite project's own JS/WASM bindings. -** -** Returns a pointer to sqlite3_free(). In compliant browsers the -** return value, when passed to sqlite3.wasm.exports.functionEntry(), -** must resolve to the same function as -** sqlite3.wasm.exports.sqlite3_free. i.e. from a dev console where -** sqlite3 is exported globally, the following must be true: -** -** ``` -** sqlite3.wasm.functionEntry( -** sqlite3.wasm.exports.sqlite3__wasm_ptr_to_sqlite3_free() -** ) === sqlite3.wasm.exports.sqlite3_free -** ``` -** -** Using a function to return this pointer, as opposed to exporting it -** via sqlite3__wasm_enum_json(), is an attempt to work around a -** Safari-specific quirk covered at -** https://sqlite.org/forum/info/e5b20e1feb37a19a. -**/ -SQLITE_WASM_EXPORT -void * sqlite3__wasm_ptr_to_sqlite3_free(void){ - return (void*)sqlite3_free; -} -#endif - #if defined(__EMSCRIPTEN__) && defined(SQLITE_ENABLE_WASMFS) #include diff --git a/manifest b/manifest index 59bddf164c..eb4d3a80ec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\stouchups\sin\sJS\sdocs\sand\sexception\smessages. -D 2024-04-23T06:36:28.862 +C Remove\ssome\sdead\sWASM-side\scode. +D 2024-04-23T06:49:47.154 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -616,7 +616,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 -F ext/wasm/api/sqlite3-wasm.c 3f744dc45ac4be8125d58364448bdc9c082f332a88cec211bfd0143ad0acb373 +F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bd89edfe42a4d7122a6d6d405c5423cf00aabba1f76f6ea8e2dba9c628ddd91a F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 04c552b12e3b77b9dfd83838d35ce19a37ed024a8c18a2000ada10cf3d1eb6ad -R ed22115253110bc0abaf81953307bf22 +P 9e7fc9370dfca121244f7a2941e8de629b277f1799f8de08a43ff1d86f94b6f5 +R b231e37736ffdee257e51342c04cf6fd U stephan -Z 8b53fb3b4d609195342a0ce669cacf2a +Z cab669345b54790908300b069b7a8aa6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0b66f11a13..77e13a296a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e7fc9370dfca121244f7a2941e8de629b277f1799f8de08a43ff1d86f94b6f5 \ No newline at end of file +0a07ee27bd6021a6fc1d81133012592351530ffcf6ae09322ea74624cff910df \ No newline at end of file From 0309fb919aef74ee2df3b87871c43da025cefeb4 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 23 Apr 2024 11:56:20 +0000 Subject: [PATCH 0339/1030] Fix an uninitialized variable problem in the new code on this branch. FossilOrigin-Name: 85625b38718c6e4cf7aa97fa3c52153bd25c810b68f19e7924e1f4b709c6a05d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index d652ae551d..1581ca907f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Slight\sperformance\simprovement\sfor\sthe\snew\scode\son\sthis\sbranch. -D 2024-04-20T19:19:30.713 +C Fix\san\suninitialized\svariable\sproblem\sin\sthe\snew\scode\son\sthis\sbranch. +D 2024-04-23T11:56:20.612 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,7 +835,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 79c673bf23b3b7fcc5e9cfa0adcd88a97645cd47920d2365dd6aec8cab7b222a +F src/where.c 09dc0b63e1c18c380179f5ca15dd25ec4b796fc142bfe202b6a1a4e6c4fa8100 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 4b5909be0c36030eec18ea0e7a64c60254180a21e626c9d2e0e9be3007ad47c1 F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 @@ -2184,8 +2184,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4d870fd8b5450047a7486fc023d1ac9439642e8ed91eadfd5026c4cda7cc9179 -R 6023edc800b34da7492bfeaa8c433f44 +P 500c67f1341fe2a7e7333d525c90df201cc73a683b943ad5c1e41d4a4f639043 +R 842a99b3ce378b1a997aef4384eecd35 U dan -Z caab3df5b31f1752021c68136ff6d06a +Z 6e531b1f6828a7a325bb114af8c59a31 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6bb6214d88..03f943f25c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -500c67f1341fe2a7e7333d525c90df201cc73a683b943ad5c1e41d4a4f639043 \ No newline at end of file +85625b38718c6e4cf7aa97fa3c52153bd25c810b68f19e7924e1f4b709c6a05d \ No newline at end of file diff --git a/src/where.c b/src/where.c index 96a6df9deb..38cf6b7287 100644 --- a/src/where.c +++ b/src/where.c @@ -323,6 +323,7 @@ static SQLITE_NOINLINE const char *indexInAffinityOk( if( sqlite3ExprIsVector(pX->pLeft) ){ int iField = pTerm->u.x.iField - 1; + inexpr.flags = 0; inexpr.op = TK_EQ; inexpr.pLeft = pX->pLeft->x.pList->a[iField].pExpr; assert( ExprUseXSelect(pX) ); From 99200b2f07034d516e863e32cc35ff0cc4c0a653 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 24 Apr 2024 06:43:17 +0000 Subject: [PATCH 0340/1030] Remove an undocumented feature from the JS Worker1.open API because it relies on broken behavior which has no VFS-agnostic workaround. FossilOrigin-Name: 3a640038c70c8511e7051af83aa35d163c4f96f05c5064cffd3e4e2e63cd44a9 --- ext/wasm/api/sqlite3-api-glue.js | 7 ++-- ext/wasm/api/sqlite3-api-worker1.js | 35 +------------------ ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | 2 +- manifest | 19 +++++----- manifest.uuid | 2 +- 5 files changed, 17 insertions(+), 48 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index cec0a8c0af..83b2ee1721 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -627,8 +627,11 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ wasm.bindingSignatures.wasmInternal = [ ["sqlite3__wasm_db_reset", "int", "sqlite3*"], ["sqlite3__wasm_db_vfs", "sqlite3_vfs*", "sqlite3*","string"], - ["sqlite3__wasm_vfs_create_file", "int", - "sqlite3_vfs*","string","*", "int"], + [/* DO NOT USE. This is deprecated since 2023-08-11 because it can + trigger assert() in debug builds when used with file sizes + which are not sizes to a multiple of a valid db page size. */ + "sqlite3__wasm_vfs_create_file", "int", "sqlite3_vfs*","string","*", "int" + ], ["sqlite3__wasm_posix_create_file", "int", "string","*", "int"], ["sqlite3__wasm_vfs_unlink", "int", "sqlite3_vfs*","string"], ["sqlite3__wasm_qfmt_token","string:dealloc", "string","int"] diff --git a/ext/wasm/api/sqlite3-api-worker1.js b/ext/wasm/api/sqlite3-api-worker1.js index bd99f3ec8e..2e597613e1 100644 --- a/ext/wasm/api/sqlite3-api-worker1.js +++ b/ext/wasm/api/sqlite3-api-worker1.js @@ -459,11 +459,6 @@ sqlite3.initWorker1API = function(){ return wState.dbList[0] && getDbId(wState.dbList[0]); }; - const guessVfs = function(filename){ - const m = /^file:.+(vfs=(\w+))/.exec(filename); - return sqlite3.capi.sqlite3_vfs_find(m ? m[2] : 0); - }; - const isSpecialDbFilename = (n)=>{ return ""===n || ':'===n[0]; }; @@ -485,36 +480,8 @@ sqlite3.initWorker1API = function(){ toss("Throwing because of simulateError flag."); } const rc = Object.create(null); - let byteArray, pVfs; oargs.vfs = args.vfs; - if(isSpecialDbFilename(args.filename)){ - oargs.filename = args.filename || ""; - }else{ - oargs.filename = args.filename; - byteArray = args.byteArray; - if(byteArray) pVfs = guessVfs(args.filename); - } - if(pVfs){ - /* 2022-11-02: this feature is as-yet untested except that - sqlite3__wasm_vfs_create_file() has been tested from the - browser dev console. */ - let pMem; - try{ - pMem = sqlite3.wasm.allocFromTypedArray(byteArray); - const rc = util.sqlite3__wasm_vfs_create_file( - pVfs, oargs.filename, pMem, byteArray.byteLength - ); - if(rc) sqlite3.SQLite3Error.toss(rc); - }catch(e){ - throw new sqlite3.SQLite3Error( - e.name+' creating '+args.filename+": "+e.message, { - cause: e - } - ); - }finally{ - if(pMem) sqlite3.wasm.dealloc(pMem); - } - } + oargs.filename = args.filename || ""; const db = wState.open(oargs); rc.filename = db.filename; rc.persistent = !!sqlite3.capi.sqlite3_js_db_uses_vfs(db.pointer, "opfs"); diff --git a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js index 878147acd6..8cfc709372 100644 --- a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js +++ b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js @@ -285,7 +285,7 @@ globalThis.sqlite3Worker1Promiser.defaultConfig = { }/*defaultConfig*/; /** - sqlite3Worker1Promiser.v2() works identically to + sqlite3Worker1Promiser.v2(), added in 3.46, works identically to sqlite3Worker1Promiser() except that it returns a Promise instead of relying an an onready callback in the config object. The Promise resolves to the same factory function which diff --git a/manifest b/manifest index 8e721c34a6..d09a6714d8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\svector\sIN\soperators\sused\swith\san\sindex\swhere\sthe\saffinities\nand\scollations\sfor\sthe\svarious\svector\sterms\sare\sdifferent. -D 2024-04-23T12:02:03.384 +C Remove\san\sundocumented\sfeature\sfrom\sthe\sJS\sWorker1.open\sAPI\sbecause\sit\srelies\son\sbroken\sbehavior\swhich\shas\sno\sVFS-agnostic\sworkaround. +D 2024-04-24T06:43:17.626 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -606,10 +606,10 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.js c744f4b919e1254c898b467573858671a1c8797c2490d0eca2fdbadf2d0ac74b +F ext/wasm/api/sqlite3-api-glue.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d F ext/wasm/api/sqlite3-api-oo1.js 40f6834314b60e636f0046a9c49b8566a992dcf04be9ea593e680c23f6984b2b F ext/wasm/api/sqlite3-api-prologue.js 34457b25dcf0005c81d76f011f207026ec164f6ff0f69f024b608025ca808ea9 -F ext/wasm/api/sqlite3-api-worker1.js 8d9c0562831f62218170a3373468d8a0b7a6503b5985e309b69bf71187b525cf +F ext/wasm/api/sqlite3-api-worker1.js 9704b77b5eb9d0d498ceeaf3e7a837021b14c52ac15d6556c7f97e278ec725c3 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 196ad83d36ca794e564044788c9d21b964679d63cad865f604da37c4afc9a285 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d @@ -617,7 +617,7 @@ F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c -F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bd89edfe42a4d7122a6d6d405c5423cf00aabba1f76f6ea8e2dba9c628ddd91a +F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 5bffc94b0ba45c658f7a70c683c536642cd95f4d6fc71d20785864111c396740 F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd @@ -2185,9 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0a07ee27bd6021a6fc1d81133012592351530ffcf6ae09322ea74624cff910df 85625b38718c6e4cf7aa97fa3c52153bd25c810b68f19e7924e1f4b709c6a05d -R c4a23a5323086d7b4821fb61d859ea24 -T +closed 85625b38718c6e4cf7aa97fa3c52153bd25c810b68f19e7924e1f4b709c6a05d -U drh -Z ae5e767d94a1a535bc8f32beb80ed40d +P 86e8c782e7494377de3c27b750cd83a7eb2302c1182ee2004d3864db50fca557 +R 13de094fa4800b17b613a51d0d124b97 +U stephan +Z ed94745ed0281633dd50a259c15a286e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d3da69e9df..3252cc5298 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -86e8c782e7494377de3c27b750cd83a7eb2302c1182ee2004d3864db50fca557 \ No newline at end of file +3a640038c70c8511e7051af83aa35d163c4f96f05c5064cffd3e4e2e63cd44a9 \ No newline at end of file From b065eceb560a32595ccfe0ecd99bc2a0488f8062 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 24 Apr 2024 11:21:27 +0000 Subject: [PATCH 0341/1030] Ensure that temporary SrcItem objects created by trigger processing have either SrcItem.zName or SrcItem.pSelect defined. Every SrcItem should have one or the other. FossilOrigin-Name: cef4d9e3ba586735598f03eb5e8f29072c9e6f62b0d34ddd2fb3ed1795f6e21c --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/resolve.c | 1 + src/trigger.c | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d09a6714d8..69f0bf480d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sundocumented\sfeature\sfrom\sthe\sJS\sWorker1.open\sAPI\sbecause\sit\srelies\son\sbroken\sbehavior\swhich\shas\sno\sVFS-agnostic\sworkaround. -D 2024-04-24T06:43:17.626 +C Ensure\sthat\stemporary\sSrcItem\sobjects\screated\sby\strigger\sprocessing\shave\neither\sSrcItem.zName\sor\sSrcItem.pSelect\sdefined.\s\sEvery\sSrcItem\sshould\shave\none\sor\sthe\sother. +D 2024-04-24T11:21:27.855 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -749,7 +749,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 6310bdfed32184cd3a5d6ba203dfee1ea323051cb38a6c2e80a5b79c069f4e87 +F src/resolve.c f430c3744a22486323a09b57185dbf38347c3dd1848af453e96ac42b3676c668 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 51893b3e34d38ad8d46b5010a6e380ca878b578be5001a640daa907336187424 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 @@ -815,7 +815,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 F src/treeview.c a8aa3086c886c6eb2ff2b6354b0f23d251f7219bf08fad52d4f2791e55324f1b -F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 +F src/trigger.c fd559df58f17e127701847c74e3a0d78419d356f6c662463bc959e39ac6fed9c F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 86e8c782e7494377de3c27b750cd83a7eb2302c1182ee2004d3864db50fca557 -R 13de094fa4800b17b613a51d0d124b97 -U stephan -Z ed94745ed0281633dd50a259c15a286e +P 3a640038c70c8511e7051af83aa35d163c4f96f05c5064cffd3e4e2e63cd44a9 +R 63f308f782c1ae167ab94842d682dae8 +U drh +Z 8a5b2c860abce773c65eadddadd69986 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3252cc5298..d3d5c10c8f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3a640038c70c8511e7051af83aa35d163c4f96f05c5064cffd3e4e2e63cd44a9 \ No newline at end of file +cef4d9e3ba586735598f03eb5e8f29072c9e6f62b0d34ddd2fb3ed1795f6e21c \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 68a1d94a26..81f3d99474 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1889,6 +1889,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ if( pOuterNC ) pOuterNC->nNestedSelect++; for(i=0; ipSrc->nSrc; i++){ SrcItem *pItem = &p->pSrc->a[i]; + assert( pItem->zName!=0 || pItem->pSelect!=0 ); if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ int nRef = pOuterNC ? pOuterNC->nRef : 0; const char *zSavedContext = pParse->zAuthContext; diff --git a/src/trigger.c b/src/trigger.c index 97ca249be5..813b2fac72 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -987,6 +987,7 @@ static void codeReturningTrigger( sSelect.pSrc = &sFrom; sFrom.nSrc = 1; sFrom.a[0].pTab = pTab; + sFrom.a[0].zName = pTab->zName; sFrom.a[0].iCursor = -1; sqlite3SelectPrep(pParse, &sSelect, 0); if( pParse->nErr==0 ){ From 5b27ecafbcf2dbdb7b407f8cf89703a463fb1da7 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 24 Apr 2024 11:40:47 +0000 Subject: [PATCH 0342/1030] Avoid slowdown when exprNodeIsConstant() is called on deeply nested SQL functions. FossilOrigin-Name: 1c0b0345451853846076467831884f951c92ec79476be40ce7f7b766fd2d8fc1 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 2 +- test/func2.test | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 69f0bf480d..2b45341662 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\stemporary\sSrcItem\sobjects\screated\sby\strigger\sprocessing\shave\neither\sSrcItem.zName\sor\sSrcItem.pSelect\sdefined.\s\sEvery\sSrcItem\sshould\shave\none\sor\sthe\sother. -D 2024-04-24T11:21:27.855 +C Avoid\sslowdown\swhen\sexprNodeIsConstant()\sis\scalled\son\sdeeply\snested\sSQL\sfunctions. +D 2024-04-24T11:40:47.022 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -701,7 +701,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 36071487e377356f1dd62e1e35870ed36a7212cb34ab1578b75d4a27ecdbfcb8 +F src/expr.c 005bf7a088a2fb12a50752a2a1d40d423b8942e1920e93c3a1ba76da0bfbe52b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -1232,7 +1232,7 @@ F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401b F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test b56905748ce0567c01d60005f3e6ad1af19453d224ba4730ee687d048fd09ef9 -F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f +F test/func2.test 69f6ae3751b4ec765bdc3b803c0a255aa0f693f28f44805bef03e6b4a3fd242f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5 F test/func5.test 863e6d1bd0013d09c17236f8a13ea34008dd857d87d85a13a673960e4c25d82a @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3a640038c70c8511e7051af83aa35d163c4f96f05c5064cffd3e4e2e63cd44a9 -R 63f308f782c1ae167ab94842d682dae8 -U drh -Z 8a5b2c860abce773c65eadddadd69986 +P cef4d9e3ba586735598f03eb5e8f29072c9e6f62b0d34ddd2fb3ed1795f6e21c +R fa1286c2555f60d15c35c2d35b75c5e3 +U dan +Z bda7fafbfb8a767264d15514a343fe9e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d3d5c10c8f..1e1865f9ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cef4d9e3ba586735598f03eb5e8f29072c9e6f62b0d34ddd2fb3ed1795f6e21c \ No newline at end of file +1c0b0345451853846076467831884f951c92ec79476be40ce7f7b766fd2d8fc1 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 2257422b83..aeb04a37f2 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2393,7 +2393,7 @@ static SQLITE_NOINLINE int exprNodeIsConstantFunction( pWalker->eCode = 0; return WRC_Abort; } - return WRC_Continue; + return WRC_Prune; } diff --git a/test/func2.test b/test/func2.test index 08ad857509..a7c7ec3fd8 100644 --- a/test/func2.test +++ b/test/func2.test @@ -508,4 +508,27 @@ do_test func2-3.9.2 { bin_to_hex [lindex $blob 0] } "12" +#------------------------------------------------------------------------- +# At one point this was extremely slow to compile. +# +do_test func2-3.10 { + set tm [time { + execsql { + SELECT '' IN (zerobloB(zerobloB(zerobloB(zerobloB(zerobloB( + zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB( + zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB( + zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB( + zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB( + zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB( + zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB( + zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB( + zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(1) + ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + } + }] + + set tm [lindex $tm 0] + expr $tm<2000000 +} {1} + finish_test From 35b771e221a5e70d7dc758d6a797c63e80a98fb0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 24 Apr 2024 11:51:51 +0000 Subject: [PATCH 0343/1030] Add comments linking the assert() added in [cef4d9e3ba586735] to the places where the precondition that the assert() tests are actually required. FossilOrigin-Name: 6f0e7e195275aeb4aefd9da20348af35e3ef7f0a6b2768a34824daeace16eff1 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/printf.c | 2 +- src/resolve.c | 2 +- src/trigger.c | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 2b45341662..fb4e297615 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sslowdown\swhen\sexprNodeIsConstant()\sis\scalled\son\sdeeply\snested\sSQL\sfunctions. -D 2024-04-24T11:40:47.022 +C Add\scomments\slinking\sthe\sassert()\sadded\sin\s[cef4d9e3ba586735]\sto\sthe\splaces\nwhere\sthe\sprecondition\sthat\sthe\sassert()\stests\sare\sactually\srequired. +D 2024-04-24T11:51:51.477 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -747,9 +747,9 @@ F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 F src/pragma.c f8f1845b42df684e9d31c5a1628c989a34939686049d7878bc5394ac1ae9cac4 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c -F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1 +F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c f430c3744a22486323a09b57185dbf38347c3dd1848af453e96ac42b3676c668 +F src/resolve.c 647edf93729ba124c0a6048982af56c2fa4f841e69d626e4f3caa620f082bb15 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 51893b3e34d38ad8d46b5010a6e380ca878b578be5001a640daa907336187424 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 @@ -815,7 +815,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 F src/treeview.c a8aa3086c886c6eb2ff2b6354b0f23d251f7219bf08fad52d4f2791e55324f1b -F src/trigger.c fd559df58f17e127701847c74e3a0d78419d356f6c662463bc959e39ac6fed9c +F src/trigger.c d087b9f50463871fc22c812835cff48d23496279758bc077bbffc17ebfe0470d F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cef4d9e3ba586735598f03eb5e8f29072c9e6f62b0d34ddd2fb3ed1795f6e21c -R fa1286c2555f60d15c35c2d35b75c5e3 -U dan -Z bda7fafbfb8a767264d15514a343fe9e +P 1c0b0345451853846076467831884f951c92ec79476be40ce7f7b766fd2d8fc1 +R 09140f401f2e5de2029c7707ae39c044 +U drh +Z 19c09d10e1b97b5d9274dbb80f3447f0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e1865f9ef..fd80c6f252 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c0b0345451853846076467831884f951c92ec79476be40ce7f7b766fd2d8fc1 \ No newline at end of file +6f0e7e195275aeb4aefd9da20348af35e3ef7f0a6b2768a34824daeace16eff1 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index eb22ee320d..c0dcc5d0fa 100644 --- a/src/printf.c +++ b/src/printf.c @@ -857,7 +857,7 @@ void sqlite3_str_vappendf( sqlite3_str_appendall(pAccum, pItem->zAlias); }else{ Select *pSel = pItem->pSelect; - assert( pSel!=0 ); + assert( pSel!=0 ); /* Because of tag-20240424-1 */ if( pSel->selFlags & SF_NestedFrom ){ sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId); }else if( pSel->selFlags & SF_MultiValue ){ diff --git a/src/resolve.c b/src/resolve.c index 81f3d99474..6a1d82606a 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1889,7 +1889,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ if( pOuterNC ) pOuterNC->nNestedSelect++; for(i=0; ipSrc->nSrc; i++){ SrcItem *pItem = &p->pSrc->a[i]; - assert( pItem->zName!=0 || pItem->pSelect!=0 ); + assert( pItem->zName!=0 || pItem->pSelect!=0 );/* Test of tag-20240424-1*/ if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ int nRef = pOuterNC ? pOuterNC->nRef : 0; const char *zSavedContext = pParse->zAuthContext; diff --git a/src/trigger.c b/src/trigger.c index 813b2fac72..34537918c9 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -987,7 +987,7 @@ static void codeReturningTrigger( sSelect.pSrc = &sFrom; sFrom.nSrc = 1; sFrom.a[0].pTab = pTab; - sFrom.a[0].zName = pTab->zName; + sFrom.a[0].zName = pTab->zName; /* tag-20240424-1 */ sFrom.a[0].iCursor = -1; sqlite3SelectPrep(pParse, &sSelect, 0); if( pParse->nErr==0 ){ From dfa628915328180a3cbb96d4407c11212258db94 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 24 Apr 2024 14:18:20 +0000 Subject: [PATCH 0344/1030] Fix a case where a corrupt stat4 record could go unrecognized due to integer overflow. FossilOrigin-Name: 240a4a48b27a2b1070bba6d7da76a8df8e3f1808e262045d7ad2cf910df08f3d --- manifest | 16 ++++----- manifest.uuid | 2 +- src/vdbemem.c | 8 ++--- test/corruptL.test | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index fb4e297615..b4352e70e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\scomments\slinking\sthe\sassert()\sadded\sin\s[cef4d9e3ba586735]\sto\sthe\splaces\nwhere\sthe\sprecondition\sthat\sthe\sassert()\stests\sare\sactually\srequired. -D 2024-04-24T11:51:51.477 +C Fix\sa\scase\swhere\sa\scorrupt\sstat4\srecord\scould\sgo\sunrecognized\sdue\sto\sinteger\soverflow. +D 2024-04-24T14:18:20.595 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -827,7 +827,7 @@ F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df F src/vdbeaux.c 6385727adf51a649e4993098870a62c3945fe21dbc0e0fd9013772aff930b8fb F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 -F src/vdbemem.c 213bf303826c0ef702e3a2a69dab2309d84b8381b822c6787885859fd7cd4c4e +F src/vdbemem.c 385c8b89da3b5ef9a468d77a466958aa72ee1212d5cb005f23ec63df1d413054 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 @@ -1020,7 +1020,7 @@ F test/corruptH.test 79801d97ec5c2f9f3c87739aa1ec2eb786f96454 F test/corruptI.test 9d8cbf6214e492abe9e822e759b9751ae336cec0a6fe3ff3b37bfbd8ff9c22ca F test/corruptJ.test 4d5ccc4bf959464229a836d60142831ef76a5aa4 F test/corruptK.test 5b4212fe346699831c5ad559a62c54e11c0611bdde1ea8423a091f9c01aa32af -F test/corruptL.test 504d90502d9993440226edc355d2275524b89064ea3df5ee5c27f7028ec59d07 +F test/corruptL.test 652fc8ac0763a6fd3eb28b951d481924167b2d9936083bcc68253b2274a0c8fe F test/corruptM.test 7d574320e08c1b36caa3e47262061f186367d593a7e305d35f15289cc2c3e067 F test/corruptN.test 7c099d153a554001b4fb829c799b01f2ea6276cbc32479131e0db0da4efd9cc4 F test/cost.test cc434a026b1e9d0d98137a147e24e5daf1b1ad09e9ff7da63b34c83ddd136d92 @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c0b0345451853846076467831884f951c92ec79476be40ce7f7b766fd2d8fc1 -R 09140f401f2e5de2029c7707ae39c044 -U drh -Z 19c09d10e1b97b5d9274dbb80f3447f0 +P 6f0e7e195275aeb4aefd9da20348af35e3ef7f0a6b2768a34824daeace16eff1 +R 8aa170676bd507dd4717ebad9ca82758 +U dan +Z 3e9a5a5005e3601585922bc0e00c59cc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fd80c6f252..1442db0c13 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f0e7e195275aeb4aefd9da20348af35e3ef7f0a6b2768a34824daeace16eff1 \ No newline at end of file +240a4a48b27a2b1070bba6d7da76a8df8e3f1808e262045d7ad2cf910df08f3d \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index d0015206d5..8a4011e10f 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1949,10 +1949,10 @@ int sqlite3Stat4Column( sqlite3_value **ppVal /* OUT: Extracted value */ ){ u32 t = 0; /* a column type code */ - int nHdr; /* Size of the header in the record */ - int iHdr; /* Next unread header byte */ - int iField; /* Next unread data byte */ - int szField = 0; /* Size of the current data field */ + u32 nHdr; /* Size of the header in the record */ + u32 iHdr; /* Next unread header byte */ + i64 iField; /* Next unread data byte */ + u32 szField = 0; /* Size of the current data field */ int i; /* Column index */ u8 *a = (u8*)pRec; /* Typecast byte array */ Mem *pMem = *ppVal; /* Write result into this Mem object */ diff --git a/test/corruptL.test b/test/corruptL.test index cf38764415..52adf6fd72 100644 --- a/test/corruptL.test +++ b/test/corruptL.test @@ -1505,4 +1505,89 @@ do_catchsql_test 19.4 { PRAGMA integrity_check; } {1 {database disk image is malformed}} +#------------------------------------------------------------------------- +reset_db +do_test 18.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +.open --hexdb +| size 20480 pagesize 4096 filename crash-a4150b729051e4.db +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05 .....@ ........ +| 32: 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 04 ................ +| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ +| 64: 00 00 00 00 00 00 00 00 00 00 ff f0 00 00 00 00 ................ +| 96: 00 00 00 00 0d 00 00 00 04 0e e5 00 0f c2 0f 75 ...............u +| 112: 0f 19 0e e5 00 00 00 00 00 00 00 01 00 00 00 00 ................ +| 3808: 00 00 00 00 00 32 04 06 17 17 11 01 4b 69 6e 64 .....2......Kind +| 3824: 65 78 74 31 61 62 63 74 31 05 43 52 45 41 54 45 ext1abct1.CREATE +| 3840: 20 49 4e 44 45 58 20 74 31 61 62 63 20 4f 4e 20 INDEX t1abc ON +| 3856: 74 31 28 61 2c 62 2c 63 29 5a 03 06 17 25 25 01 t1(a,b,c)Z...%%. +| 3872: 79 74 61 62 6c 65 73 71 6c 69 74 65 5f 73 74 61 ytablesqlite_sta +| 3888: 74 34 73 71 6c 69 74 65 5f 73 74 61 74 34 04 43 t4sqlite_stat4.C +| 3904: 52 45 41 54 45 20 54 41 42 4c 45 20 73 71 6c 69 REATE TABLE sqli +| 3920: 74 65 5f 73 74 61 74 34 28 74 62 6c 2c 69 64 78 te_stat4(tbl,idx +| 3936: 2c 6e 65 71 2c 6e 6c 74 2c 6e 64 6c 74 2c 73 61 ,neq,nlt,ndlt,sa +| 3952: 6d 70 6c 65 29 4b 02 06 17 25 25 01 5b 74 61 62 mple)K...%%.[tab +| 3968: 6c 65 73 71 6c 69 74 65 5f 73 74 61 74 31 73 71 lesqlite_stat1sq +| 3984: 6c 69 74 65 5f 73 74 61 74 31 03 43 52 45 41 54 lite_stat1.CREAT +| 4000: 45 20 54 41 42 4c 45 20 73 71 6c 69 74 65 5f 73 E TABLE sqlite_s +| 4016: 74 61 74 31 28 74 62 6c 2c 69 64 78 2c 73 74 61 tat1(tbl,idx,sta +| 4032: 74 29 3c 01 06 17 11 11 01 65 74 61 62 6c 65 74 t)<......etablet +| 4048: 31 74 31 02 43 52 45 41 54 45 20 54 41 42 4c 45 1t1.CREATE TABLE +| 4064: 20 74 31 28 61 20 54 45 58 54 2c 20 62 20 49 4e t1(a TEXT, b IN +| 4080: 54 2c 20 63 20 49 4e 54 2c 20 64 20 49 4e 54 29 T, c INT, d INT) +| page 2 offset 4096 +| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +| 4000: 0b 07 05 13 01 01 01 62 63 64 64 06 0b 0c 06 05 .......bcdd..... +| 4016: 13 02 01 01 64 65 66 01 59 09 0a 0c 05 05 13 03 ....def.Y....... +| 4032: 01 01 64 65 66 02 6f 08 09 0c 04 05 13 02 01 01 ..def.o......... +| 4048: 61 62 63 01 59 07 08 0c 03 05 13 02 01 01 87 62 abc.Y..........b +| 4064: 63 00 ea 06 07 0c 02 05 13 02 01 01 61 62 63 00 c...........abc. +| 4080: ea 06 06 0b 01 05 13 01 01 01 61 62 63 7b 04 04 ..........abc... +| page 3 offset 8192 +| 0: 0d 00 00 00 01 0f e0 00 0f e1 00 00 00 00 00 00 ................ +| 4064: 00 1d 01 04 11 17 31 74 31 74 31 61 62 63 31 30 ......1t1t1abc10 +| 4080: 30 30 30 20 35 30 30 30 20 32 30 30 30 20 31 30 000 5000 2000 10 +| page 4 offset 12288 +| 0: 0d 00 00 00 07 0e ac 00 0f d1 0f a0 0f 6f 0f 3e .............o.> +| 16: 0f 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +| 3744: 00 00 00 00 00 00 00 00 00 00 00 00 2f 07 07 11 ............/... +| 3760: 17 1b 1b 1b 24 74 31 74 31 61 62 63 32 20 31 20 ....$t1t1abc2 1 +| 3776: 31 20 31 35 20 36 20 36 20 36 32 20 35 20 36 20 1 15 6 6 62 5 6 +| 3792: 36 05 13 02 01 01 64 65 66 02 37 08 05 2f 06 07 6.....def.7../.. +| 3808: 11 17 1b 1b 1b 24 74 41 74 31 61 62 63 32 20 31 .....$tAt1abc2 1 +| 3824: 20 31 20 31 35 20 35 20 55 20 35 32 20 34 20 35 1 15 5 U 52 4 5 +| 3840: 20 35 05 13 02 01 01 64 65 66 01 59 09 06 2e 05 5.....def.Y.... +| 3856: 07 11 17 1b 1b 1b 22 74 31 74 31 61 62 63 31 20 .......t1t1abc1 +| 3872: 31 20 31 20 31 34 20 34 20 34 20 34 31 20 33 20 1 1 14 4 4 41 3 +| 3888: 34 20 34 08 b3 cd f0 f1 62 63 64 64 06 07 2f 05 4 4.....bcdd../. +| 3904: 07 11 17 1b 1b 1b 24 74 37 74 31 61 62 63 34 20 ......$t7t1abc4 +| 3920: 31 20 31 20 31 30 20 33 20 33 20 33 30 20 32 20 1 1 10 3 3 30 2 +| 3936: 33 20 33 05 13 02 01 01 61 62 63 01 59 07 04 2f 3 3.....abc.Y../ +| 3952: 03 07 11 17 1b 1b 1b 24 74 31 74 31 61 62 63 34 .......$t1t1abc4 +| 3968: 20 32 20 31 20 31 30 20 31 20 32 20 32 30 20 31 2 1 10 1 2 20 1 +| 3984: 20 32 20 32 05 13 02 01 01 61 62 63 00 ea 06 03 2 2.....abc.... +| 4000: 2f 02 07 11 17 1b 1b 1b 24 74 31 74 31 61 62 63 /.......$t1t1abc +| 4016: 34 20 32 20 31 20 31 30 20 31 20 31 20 31 30 20 4 2 1 10 1 1 10 +| 4032: 31 20 31 20 31 05 13 02 01 01 61 62 63 00 ea 05 1 1 1.....abc... +| 4048: 02 2d 01 07 11 17 1b 1b 1b 20 74 31 74 31 61 62 .-....... t1t1ab +| 4064: 63 34 20 31 20 31 20 31 30 20 30 20 30 1f 30 30 c4 1 1 10 0 0.00 +| 4080: 20 30 20 30 20 30 05 13 01 01 09 61 62 63 7b 04 0 0 0.....abc.. +| page 5 offset 16384 +| 0: 0a 00 00 00 07 0f a8 00 0f f5 00 00 00 00 00 00 ................ +| 4000: 00 00 00 00 00 00 00 00 0c 05 13 02 01 01 64 65 ..............de +| 4016: 66 02 37 08 05 0c 05 13 02 01 01 64 65 66 01 59 f.7........def.Y +| 4032: 09 06 0b 05 12 01 01 01 62 63 64 64 06 07 0c 05 ........bcdd.... +| 4048: 13 02 01 01 61 62 63 01 59 07 01 2c 05 13 02 01 ....abc.Y..,.... +| 4064: 01 61 62 63 00 ea 06 03 0c 05 13 02 01 01 61 62 .abc..........ab +| 4080: 63 00 ea 05 00 00 00 00 00 00 00 00 00 00 00 00 c............... +| end crash-a4150b729051e4.db +}]} {} + +do_catchsql_test 18.1 { + SELECT a FROM t1 WHERE b GLOB b AND b GLOB '0^x]␅6␚xz]'; +} {1 {database disk image is malformed}} + finish_test From 0868d58e2caa16f19e843602bf2ca58653653162 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 24 Apr 2024 16:36:37 +0000 Subject: [PATCH 0345/1030] If a RETURNING clause contains a subquery that references the table that is being updated in the statement that includes the RETURNING clause, then mark the subquery as correlated sot hat it is recomputed for each result and not just computed once and reused. See [forum:/forumpost/2c83569ce8945d39|forum post 2c83569ce8945d39]. FossilOrigin-Name: 9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e --- manifest | 16 +++++------ manifest.uuid | 2 +- src/trigger.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ test/returning1.test | 60 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b4352e70e4..e18f26c318 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scase\swhere\sa\scorrupt\sstat4\srecord\scould\sgo\sunrecognized\sdue\sto\sinteger\soverflow. -D 2024-04-24T14:18:20.595 +C If\sa\sRETURNING\sclause\scontains\sa\ssubquery\sthat\sreferences\sthe\stable\sthat\sis\nbeing\supdated\sin\sthe\sstatement\sthat\sincludes\sthe\sRETURNING\sclause,\sthen\smark\nthe\ssubquery\sas\scorrelated\ssot\shat\sit\sis\srecomputed\sfor\seach\sresult\sand\snot\njust\scomputed\sonce\sand\sreused.\s\sSee\n[forum:/forumpost/2c83569ce8945d39|forum\spost\s2c83569ce8945d39]. +D 2024-04-24T16:36:37.548 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -815,7 +815,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 F src/treeview.c a8aa3086c886c6eb2ff2b6354b0f23d251f7219bf08fad52d4f2791e55324f1b -F src/trigger.c d087b9f50463871fc22c812835cff48d23496279758bc077bbffc17ebfe0470d +F src/trigger.c 0858f75818ed1580332db274f1032bcc5effe567cb132df5c5be8b1d800ca97f F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e @@ -1530,7 +1530,7 @@ F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed13 F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d F test/resetdb.test 54c06f18bc832ac6d6319e5ab23d5c8dd49fdbeec7c696d791682a8006bd5fc3 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb -F test/returning1.test b27646c5e25431dd47cf72f525d1b2d5ad4ae14e21d9cf3d65769f05e48f64f3 +F test/returning1.test 2ebfe6e56f3de9b194295620f46a747c26cebdab937defb9afd84b96dd202ccb F test/returningfault.test ae4c4b5e8745813287a359d9ccdb9d5c883c2e68afb18fb0767937d5de5692a4 F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa F test/rollback2.test 3f3a4e20401825017df7e7671e9f31b6de5fae5620c2b9b49917f52f8c160a8f @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6f0e7e195275aeb4aefd9da20348af35e3ef7f0a6b2768a34824daeace16eff1 -R 8aa170676bd507dd4717ebad9ca82758 -U dan -Z 3e9a5a5005e3601585922bc0e00c59cc +P 240a4a48b27a2b1070bba6d7da76a8df8e3f1808e262045d7ad2cf910df08f3d +R 0443bbe68d7ebf5917ca0dd9f2f0960d +U drh +Z a1811f8f003e2400c1c50cad60d7b2cc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1442db0c13..62d8aa4756 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -240a4a48b27a2b1070bba6d7da76a8df8e3f1808e262045d7ad2cf910df08f3d \ No newline at end of file +9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e \ No newline at end of file diff --git a/src/trigger.c b/src/trigger.c index 34537918c9..98e8da58c1 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -951,6 +951,72 @@ static ExprList *sqlite3ExpandReturning( return pNew; } +/* If the Expr node is a subquery or an EXISTS operator or an IN operator that +** uses a subquery, and if the subquery is SF_Correlated, then mark the +** expression as EP_VarSelect. +*/ +static int sqlite3ReturningSubqueryVarSelect(Walker *NotUsed, Expr *pExpr){ + UNUSED_PARAMETER(NotUsed); + if( ExprUseXSelect(pExpr) + && (pExpr->x.pSelect->selFlags & SF_Correlated)!=0 + ){ + testcase( ExprHasProperty(pExpr, EP_VarSelect) ); + ExprSetProperty(pExpr, EP_VarSelect); + } + return WRC_Continue; +} + + +/* +** If the SELECT references the table pWalker->u.pTab, then do two things: +** +** (1) Mark the SELECT as as SF_Correlated. +** (2) Set pWalker->eCode to non-zero so that the caller will know +** that (1) has happened. +*/ +static int sqlite3ReturningSubqueryCorrelated(Walker *pWalker, Select *pSelect){ + int i; + SrcList *pSrc; + assert( pSelect!=0 ); + pSrc = pSelect->pSrc; + assert( pSrc!=0 ); + for(i=0; inSrc; i++){ + if( pSrc->a[i].pTab==pWalker->u.pTab ){ + testcase( pSelect->selFlags & SF_Correlated ); + pSelect->selFlags |= SF_Correlated; + pWalker->eCode = 1; + break; + } + } + return WRC_Continue; +} + +/* +** Scan the expression list that is the argument to RETURNING looking +** for subqueries that depend on the table which is being modified in the +** statement that is hosting the RETURNING clause (pTab). Mark all such +** subqueries as SF_Correlated. If the subqueries are part of an +** expression, mark the expression as EP_VarSelect. +** +** https://sqlite.org/forum/forumpost/2c83569ce8945d39 +*/ +static void sqlite3ProcessReturningSubqueries( + ExprList *pEList, + Table *pTab +){ + Walker w; + memset(&w, 0, sizeof(w)); + w.xExprCallback = sqlite3ExprWalkNoop; + w.xSelectCallback = sqlite3ReturningSubqueryCorrelated; + w.u.pTab = pTab; + sqlite3WalkExprList(&w, pEList); + if( w.eCode ){ + w.xExprCallback = sqlite3ReturningSubqueryVarSelect; + w.xSelectCallback = sqlite3SelectWalkNoop; + sqlite3WalkExprList(&w, pEList); + } +} + /* ** Generate code for the RETURNING trigger. Unlike other triggers ** that invoke a subprogram in the bytecode, the code for RETURNING @@ -1014,6 +1080,7 @@ static void codeReturningTrigger( int i; int nCol = pNew->nExpr; int reg = pParse->nMem+1; + sqlite3ProcessReturningSubqueries(pNew, pTab); pParse->nMem += nCol+2; pReturning->iRetReg = reg; for(i=0; i3 + RETURNING a, + (SELECT min(a) FROM t1), + (SELECT max(a) FROM t1), + (SELECT round(avg(a),2) FROM t1); + ROLLBACK; +} { + 1 2 8 4.6 + 2 3 8 5.25 + 4 3 8 5.67 + 6 3 8 5.5 + 8 3 3 3.0 +} +do_execsql_test 20.2 { + BEGIN; + DELETE FROM t1 + RETURNING a, + (SELECT min(a) FROM t1), + (SELECT max(a) FROM t1), + (SELECT round(avg(a),2) FROM t1); + ROLLBACK; +} { + 1 2 8 4.6 + 2 3 8 5.25 + 3 4 8 6.0 + 4 6 8 7.0 + 6 8 8 8.0 + 8 N N N +} +do_execsql_test 20.3 { + BEGIN; + DELETE FROM t1 + RETURNING a, + (SELECT min(t2.a)+t1.a*100 FROM t1 AS t2), + (SELECT max(t2.a)+t1.a*100 FROM t1 AS t2), + (SELECT round(avg(t2.a),2)+t1.a*100 FROM t1 AS t2); + ROLLBACK; +} { + 1 102 108 104.6 + 2 203 208 205.25 + 3 304 308 306.0 + 4 406 408 407.0 + 6 608 608 608.0 + 8 N N N +} + finish_test From f8e195159f933d310587bd991f66965ba184c252 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 24 Apr 2024 19:49:52 +0000 Subject: [PATCH 0346/1030] An experimental minor tweak to the way affinities are computed for compound subqueries, when the actual affinity is ambiguous. FossilOrigin-Name: 779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/select.c | 2 +- test/view.test | 6 +++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index e18f26c318..14d0ac506e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\sRETURNING\sclause\scontains\sa\ssubquery\sthat\sreferences\sthe\stable\sthat\sis\nbeing\supdated\sin\sthe\sstatement\sthat\sincludes\sthe\sRETURNING\sclause,\sthen\smark\nthe\ssubquery\sas\scorrelated\ssot\shat\sit\sis\srecomputed\sfor\seach\sresult\sand\snot\njust\scomputed\sonce\sand\sreused.\s\sSee\n[forum:/forumpost/2c83569ce8945d39|forum\spost\s2c83569ce8945d39]. -D 2024-04-24T16:36:37.548 +C An\sexperimental\sminor\stweak\sto\sthe\sway\saffinities\sare\scomputed\sfor\scompound\nsubqueries,\swhen\sthe\sactual\saffinity\sis\sambiguous. +D 2024-04-24T19:49:52.341 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -751,7 +751,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 647edf93729ba124c0a6048982af56c2fa4f841e69d626e4f3caa620f082bb15 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 51893b3e34d38ad8d46b5010a6e380ca878b578be5001a640daa907336187424 +F src/select.c 39c5dc8b2fca3b1e52db1a9b469507bfc312d3e3a4bf10c58a7a716626c4bdff F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1929,7 +1929,7 @@ F test/values.test 52102ad9e5068b449429e40a976486a52246041f7cd79d086a2b170e77dec F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 -F test/view.test d4c4281e1679245829db35597817282f60dc513fc39cc5439078f009bd118487 +F test/view.test 9df7e00eb1f96a9d738a317137989a594541ce7b9ebea0506e39f89de0c1319a F test/view2.test db32c8138b5b556f610b35dfddd38c5a58a292f07fda5281eedb0851b2672679 F test/view3.test ad8a8290ee2b55ff6ce66c9ef1ce3f1e47926273a3814e1c425293e128a95456 F test/vt02.c 5b44ac67b1a283fedecf2d6e2ceda61e7a157f01d44dcb4490dcb1e87d057060 @@ -2185,8 +2185,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 240a4a48b27a2b1070bba6d7da76a8df8e3f1808e262045d7ad2cf910df08f3d -R 0443bbe68d7ebf5917ca0dd9f2f0960d +P 9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e +R 069cab252330979e2eef5b88f83953a3 +T *branch * compound-subquery-affinity +T *sym-compound-subquery-affinity * +T -sym-trunk * U drh -Z a1811f8f003e2400c1c50cad60d7b2cc +Z 7c2ae6bcf3d76ce120ccc503dbc0842f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 62d8aa4756..b78d32b4c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e \ No newline at end of file +779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb \ No newline at end of file diff --git a/src/select.c b/src/select.c index 9c2bf3b93c..d391762039 100644 --- a/src/select.c +++ b/src/select.c @@ -6417,7 +6417,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ /* A sub-query in the FROM clause of a SELECT */ Select *pSel = pFrom->pSelect; if( pSel ){ - sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_NONE); + sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_BLOB); } } } diff --git a/test/view.test b/test/view.test index 90c9c99092..612e0cc2e4 100644 --- a/test/view.test +++ b/test/view.test @@ -737,16 +737,16 @@ do_execsql_test view-27.5 { do_execsql_test view-27.6 { SELECT c0 Date: Thu, 25 Apr 2024 06:52:19 +0000 Subject: [PATCH 0347/1030] wasm: add a makefile comment about the static sqlite3.h/c version info injected into the JS files possibly differing from the runtime-emited version info when a user provides their own sqlite3.c. FossilOrigin-Name: d99a01a0f6e1f70f70c9a0625aeaa8a8015eba352bcfb3978eafca6df10ba5a8 --- ext/wasm/GNUmakefile | 6 ++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 1a119f9505..115374e623 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -289,6 +289,12 @@ endif # embedding in the JS files and in building the distribution zip file. # It must NOT be in $(dir.tmp) because we need it to survive the # cleanup process for the dist build to work properly. +# +# Slight caveat: this uses the version info from the in-tree +# sqlite3.c/h, which may diff from a user-provided $(sqlite3.c). The +# end result is that the generated JS files may have static version +# info from $(bin.version-info) which differ from their runtime-emited +# version info (e.g. from sqlite3_libversion()). bin.version-info := $(dir.top)/version-info .NOTPARALLEL: $(bin.version-info) $(bin.version-info): $(dir.tool)/version-info.c $(sqlite3.h) $(dir.top)/Makefile diff --git a/manifest b/manifest index e18f26c318..a6c6f526b7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\sRETURNING\sclause\scontains\sa\ssubquery\sthat\sreferences\sthe\stable\sthat\sis\nbeing\supdated\sin\sthe\sstatement\sthat\sincludes\sthe\sRETURNING\sclause,\sthen\smark\nthe\ssubquery\sas\scorrelated\ssot\shat\sit\sis\srecomputed\sfor\seach\sresult\sand\snot\njust\scomputed\sonce\sand\sreused.\s\sSee\n[forum:/forumpost/2c83569ce8945d39|forum\spost\s2c83569ce8945d39]. -D 2024-04-24T16:36:37.548 +C wasm:\sadd\sa\smakefile\scomment\sabout\sthe\sstatic\ssqlite3.h/c\sversion\sinfo\sinjected\sinto\sthe\sJS\sfiles\spossibly\sdiffering\sfrom\sthe\sruntime-emited\sversion\sinfo\swhen\sa\suser\sprovides\stheir\sown\ssqlite3.c. +D 2024-04-25T06:52:19.923 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -588,7 +588,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 0d5ccc8a4814716c1c789bb3069dd4d71d5ef0a97bbea074ac182fbfb85a3ca8 +F ext/wasm/GNUmakefile 21f015f342e4ed9b7ff632c10750512259d26c836a34f4f535673fae9a7c9fcc F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 240a4a48b27a2b1070bba6d7da76a8df8e3f1808e262045d7ad2cf910df08f3d -R 0443bbe68d7ebf5917ca0dd9f2f0960d -U drh -Z a1811f8f003e2400c1c50cad60d7b2cc +P 9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e +R 64fc844d8bd132b5a1025854e240b927 +U stephan +Z 2ab8bdbf685d01a81ecb7a8256df40c5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 62d8aa4756..2cd915398f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e \ No newline at end of file +d99a01a0f6e1f70f70c9a0625aeaa8a8015eba352bcfb3978eafca6df10ba5a8 \ No newline at end of file From 23afc2c4ec1abc95f61e75411926527e93ebb500 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 25 Apr 2024 16:55:53 +0000 Subject: [PATCH 0348/1030] Back out the previous change on this branch. In its place: Determine the affinity of a subquery by the left-most arm of the subquery that has an affinity other than NONE. In other words, scan from left to right looking for an arm of the compound subquery with an affinity of BLOB, TEXT, INTEGER, or REAL and pick the first one found. Or stay with NONE if no arm has a defined affinity. Test cases added. FossilOrigin-Name: b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/select.c | 12 ++++++++---- test/view.test | 29 ++++++++++++++++++++++++++--- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 14d0ac506e..91f3bc3d8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\sexperimental\sminor\stweak\sto\sthe\sway\saffinities\sare\scomputed\sfor\scompound\nsubqueries,\swhen\sthe\sactual\saffinity\sis\sambiguous. -D 2024-04-24T19:49:52.341 +C Back\sout\sthe\sprevious\schange\son\sthis\sbranch.\s\sIn\sits\splace:\s\sDetermine\sthe\naffinity\sof\sa\ssubquery\sby\sthe\sleft-most\sarm\sof\sthe\ssubquery\sthat\shas\san\naffinity\sother\sthan\sNONE.\s\sIn\sother\swords,\sscan\sfrom\sleft\sto\sright\slooking\nfor\san\sarm\sof\sthe\scompound\ssubquery\swith\san\saffinity\sof\sBLOB,\sTEXT,\sINTEGER,\nor\sREAL\sand\spick\sthe\sfirst\sone\sfound.\s\sOr\sstay\swith\sNONE\sif\sno\sarm\shas\sa\ndefined\saffinity.\s\sTest\scases\sadded. +D 2024-04-25T16:55:53.038 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -751,7 +751,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 647edf93729ba124c0a6048982af56c2fa4f841e69d626e4f3caa620f082bb15 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 39c5dc8b2fca3b1e52db1a9b469507bfc312d3e3a4bf10c58a7a716626c4bdff +F src/select.c f0f8f7fd601aff50c303205c6ac6da789d02a6e420ccb25d9aaaeccc7fa314d7 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1929,7 +1929,7 @@ F test/values.test 52102ad9e5068b449429e40a976486a52246041f7cd79d086a2b170e77dec F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 -F test/view.test 9df7e00eb1f96a9d738a317137989a594541ce7b9ebea0506e39f89de0c1319a +F test/view.test 3c23d7a068e9e4a0c4e6907498042772adea725f0630c3d9638ffd4e5a08b92b F test/view2.test db32c8138b5b556f610b35dfddd38c5a58a292f07fda5281eedb0851b2672679 F test/view3.test ad8a8290ee2b55ff6ce66c9ef1ce3f1e47926273a3814e1c425293e128a95456 F test/vt02.c 5b44ac67b1a283fedecf2d6e2ceda61e7a157f01d44dcb4490dcb1e87d057060 @@ -2185,11 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e -R 069cab252330979e2eef5b88f83953a3 -T *branch * compound-subquery-affinity -T *sym-compound-subquery-affinity * -T -sym-trunk * +P 779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb +R 365eec55f15f0f323e41980c307a2a9e U drh -Z 7c2ae6bcf3d76ce120ccc503dbc0842f +Z 924642415660e94bafdaa96d702ef424 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b78d32b4c4..208bda000a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb \ No newline at end of file +b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5 \ No newline at end of file diff --git a/src/select.c b/src/select.c index d391762039..785f9bc255 100644 --- a/src/select.c +++ b/src/select.c @@ -2336,17 +2336,21 @@ void sqlite3SubqueryColumnTypes( for(i=0, pCol=pTab->aCol; inCol; i++, pCol++){ const char *zType; i64 n; + Select *pS2 = pSelect; pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT); p = a[i].pExpr; /* pCol->szEst = ... // Column size est for SELECT tables never used */ pCol->affinity = sqlite3ExprAffinity(p); + while( pCol->affinity<=SQLITE_AFF_NONE && pS2->pNext!=0 ){ + pS2 = pS2->pNext; + pCol->affinity = sqlite3ExprAffinity(pS2->pEList->a[i].pExpr); + } if( pCol->affinity<=SQLITE_AFF_NONE ){ pCol->affinity = aff; } - if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){ + if( pCol->affinity>=SQLITE_AFF_TEXT && pS2->pNext ){ int m = 0; - Select *pS2; - for(m=0, pS2=pSelect->pNext; pS2; pS2=pS2->pNext){ + for(m=0, pS2=pS2->pNext; pS2; pS2=pS2->pNext){ m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr); } if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){ @@ -6417,7 +6421,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ /* A sub-query in the FROM clause of a SELECT */ Select *pSel = pFrom->pSelect; if( pSel ){ - sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_BLOB); + sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_NONE); } } } diff --git a/test/view.test b/test/view.test index 612e0cc2e4..241742025c 100644 --- a/test/view.test +++ b/test/view.test @@ -737,16 +737,16 @@ do_execsql_test view-27.5 { do_execsql_test view-27.6 { SELECT c0 Date: Thu, 25 Apr 2024 17:52:10 +0000 Subject: [PATCH 0349/1030] Further improvements to the computation of affinity for compound subqueries: make sure that the selected affinity is compatible with a literal values in arms to the left of the arm that is used to determine affinity. FossilOrigin-Name: bbdf22e3d989f42b963f1f2f219dfeac11db786f17ac27097ab72f72e7638a2a --- manifest | 14 +++++------ manifest.uuid | 2 +- src/select.c | 7 +++--- test/subquery.test | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 91f3bc3d8e..59e89aa32f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\sthe\sprevious\schange\son\sthis\sbranch.\s\sIn\sits\splace:\s\sDetermine\sthe\naffinity\sof\sa\ssubquery\sby\sthe\sleft-most\sarm\sof\sthe\ssubquery\sthat\shas\san\naffinity\sother\sthan\sNONE.\s\sIn\sother\swords,\sscan\sfrom\sleft\sto\sright\slooking\nfor\san\sarm\sof\sthe\scompound\ssubquery\swith\san\saffinity\sof\sBLOB,\sTEXT,\sINTEGER,\nor\sREAL\sand\spick\sthe\sfirst\sone\sfound.\s\sOr\sstay\swith\sNONE\sif\sno\sarm\shas\sa\ndefined\saffinity.\s\sTest\scases\sadded. -D 2024-04-25T16:55:53.038 +C Further\simprovements\sto\sthe\scomputation\sof\saffinity\sfor\scompound\ssubqueries:\nmake\ssure\sthat\sthe\sselected\saffinity\sis\scompatible\swith\sa\sliteral\svalues\sin\narms\sto\sthe\sleft\sof\sthe\sarm\sthat\sis\sused\sto\sdetermine\saffinity. +D 2024-04-25T17:52:10.004 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -751,7 +751,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 647edf93729ba124c0a6048982af56c2fa4f841e69d626e4f3caa620f082bb15 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c f0f8f7fd601aff50c303205c6ac6da789d02a6e420ccb25d9aaaeccc7fa314d7 +F src/select.c 04178566d0188be7de471064ced8cec1d407920726cb49b609486282d78faf56 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1662,7 +1662,7 @@ F test/stmtvtab1.test 6873dfb24f8e79cbb5b799b95c2e4349060eb7a3b811982749a84b3594 F test/strict1.test 4d2b492152b984fd7e8196d23eb88e2ccb0ef9e46ca2f96c2ce7147ceef9d168 F test/strict2.test b22c7a98b5000aef937f1990776497f0e979b1a23bc4f63e2d53b00e59b20070 F test/subjournal.test 8d4e2572c0ee9a15549f0d8e40863161295107e52f07a3e8012a2e1fdd093c49 -F test/subquery.test 312c5d26304b0e93a56ba2cb9d4480b8a1c8217e3b2b8f8be2bfb0b2458ac3a7 +F test/subquery.test 903abf41049f8404256f7be24b3151328304a5b25162e17ab0079460237382fc F test/subquery2.test 90cf944b9de8204569cf656028391e4af1ccc8c0cc02d4ef38ee3be8de1ffb12 F test/subselect.test 0966aa8e720224dbd6a5e769a3ec2a723e332303 F test/substr.test a673e3763e247e9b5e497a6cacbaf3da2bd8ec8921c0677145c109f2e633f36b @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb -R 365eec55f15f0f323e41980c307a2a9e +P b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5 +R a7fab6239835ca1909d168c0371f9e50 U drh -Z 924642415660e94bafdaa96d702ef424 +Z 0a86570527084dd8d6c773960419770f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 208bda000a..392481f925 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5 \ No newline at end of file +bbdf22e3d989f42b963f1f2f219dfeac11db786f17ac27097ab72f72e7638a2a \ No newline at end of file diff --git a/src/select.c b/src/select.c index 785f9bc255..8ee59cf68a 100644 --- a/src/select.c +++ b/src/select.c @@ -2336,21 +2336,22 @@ void sqlite3SubqueryColumnTypes( for(i=0, pCol=pTab->aCol; inCol; i++, pCol++){ const char *zType; i64 n; + int m = 0; Select *pS2 = pSelect; pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT); p = a[i].pExpr; /* pCol->szEst = ... // Column size est for SELECT tables never used */ pCol->affinity = sqlite3ExprAffinity(p); while( pCol->affinity<=SQLITE_AFF_NONE && pS2->pNext!=0 ){ + m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr); pS2 = pS2->pNext; pCol->affinity = sqlite3ExprAffinity(pS2->pEList->a[i].pExpr); } if( pCol->affinity<=SQLITE_AFF_NONE ){ pCol->affinity = aff; } - if( pCol->affinity>=SQLITE_AFF_TEXT && pS2->pNext ){ - int m = 0; - for(m=0, pS2=pS2->pNext; pS2; pS2=pS2->pNext){ + if( pCol->affinity>=SQLITE_AFF_TEXT && (pS2->pNext || pS2!=pSelect) ){ + for(pS2=pS2->pNext; pS2; pS2=pS2->pNext){ m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr); } if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){ diff --git a/test/subquery.test b/test/subquery.test index c51edba040..17061d4b60 100644 --- a/test/subquery.test +++ b/test/subquery.test @@ -651,5 +651,64 @@ do_eqp_test subquery-10.2 { # `--SEARCH t1 USING INDEX x12 (aa=?) # +#----------------------------------------------------------------------------- +# 2024-04-25 Column affinities for columns of compound subqueries +# +reset_db +sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db +do_execsql_test subquery-11.1 { + CREATE TABLE t1(ix INT, rx REAL, bx BLOB, tx TEXT, ax); + INSERT INTO t1 VALUES(1,1.0,x'31','x',NULL); + WITH c(a) AS (SELECT 'y' UNION SELECT tx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT tx FROM t1 UNION SELECT 'y') SELECT affinity(a) FROM c; +} {text text text text} +do_execsql_test subquery-11.2 { + WITH c(a) AS (SELECT 2 UNION SELECT tx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT tx FROM t1 UNION SELECT 2) SELECT affinity(a) FROM c; +} {blob blob blob blob} +do_execsql_test subquery-11.3 { + WITH c(a) AS (SELECT 2.0 UNION SELECT tx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT tx FROM t1 UNION SELECT 2.0) SELECT affinity(a) FROM c; +} {blob blob blob blob} +do_execsql_test subquery-11.4 { + WITH c(a) AS (SELECT null UNION SELECT tx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT tx FROM t1 UNION SELECT null) SELECT affinity(a) FROM c; +} {text text text text} +do_execsql_test subquery-11.5 { + WITH c(a) AS (SELECT x'32' UNION SELECT tx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT tx FROM t1 UNION SELECT x'32') SELECT affinity(a) FROM c; +} {text text text text} +do_execsql_test subquery-11.6 { + WITH c(a) AS (SELECT 3 UNION SELECT ix FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT ix FROM t1 UNION SELECT 3) SELECT affinity(a) FROM c; +} {integer integer integer integer} +do_execsql_test subquery-11.7 { + WITH c(a) AS (SELECT 3.0 UNION SELECT ix FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT ix FROM t1 UNION SELECT 3.0) SELECT affinity(a) FROM c; +} {integer integer integer integer} +do_execsql_test subquery-11.8 { + WITH c(a) AS (SELECT '3' UNION SELECT ix FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT ix FROM t1 UNION SELECT '3') SELECT affinity(a) FROM c; +} {blob blob blob blob} +do_execsql_test subquery-11.10 { + WITH c(a) AS (SELECT x'32' UNION SELECT ix FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT ix FROM t1 UNION SELECT x'32') SELECT affinity(a) FROM c; +} {integer integer integer integer} +do_execsql_test subquery-11.11 { + WITH c(a) AS (SELECT 4 UNION SELECT rx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT rx FROM t1 UNION SELECT 4) SELECT affinity(a) FROM c; +} {real real real real} +do_execsql_test subquery-11.12 { + WITH c(a) AS (SELECT '4' UNION SELECT rx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT rx FROM t1 UNION SELECT '4') SELECT affinity(a) FROM c; +} {blob blob blob blob} +do_execsql_test subquery-11.13 { + WITH c(a) AS (SELECT null UNION SELECT rx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT rx FROM t1 UNION SELECT null) SELECT affinity(a) FROM c; +} {real real real real} +do_execsql_test subquery-11.14 { + WITH c(a) AS (SELECT x'b4' UNION SELECT rx FROM t1) SELECT affinity(a) FROM c; + WITH c(a) AS (SELECT rx FROM t1 UNION SELECT x'b4') SELECT affinity(a) FROM c; +} {real real real real} finish_test From fed13d50a98b1c173449e0626dd3bb19f791e495 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 26 Apr 2024 11:32:50 +0000 Subject: [PATCH 0350/1030] Fix the TreeView display of a LIMIT clause on a compound query. Debugging code only - not part of production builds. FossilOrigin-Name: 38f1e5ce4eedd59fbeb0a0d676d26dfe8a3313189ab9b9e4a5a1ed6721b73a14 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/treeview.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 0c6764a1bf..234d44e742 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvement\sto\sthe\sway\sthat\saffinity\sis\sdetermined\sfor\scolumns\sof\sa\ncompound\ssubquery.\s\sThe\saffinity\sis\sthe\saffinity\sof\sthe\sleft-most\narm\sof\sthe\scompound\ssubquery\sthat\shas\san\saffinity\sother\sthan\sNONE,\sadjusted\nto\saccommodate\sthe\sdata\stypes\scoming\sout\sof\sthe\sother\sarms. -D 2024-04-25T23:26:11.710 +C Fix\sthe\sTreeView\sdisplay\sof\sa\sLIMIT\sclause\son\sa\scompound\squery.\s\sDebugging\ncode\sonly\s-\snot\spart\sof\sproduction\sbuilds. +D 2024-04-26T11:32:50.631 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -814,7 +814,7 @@ F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c a8aa3086c886c6eb2ff2b6354b0f23d251f7219bf08fad52d4f2791e55324f1b +F src/treeview.c 4f9ba6c1c7c9893fc046fdb0bc1f6bdec7660122b1ae37e51fb9b64c286caafd F src/trigger.c 0858f75818ed1580332db274f1032bcc5effe567cb132df5c5be8b1d800ca97f F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d99a01a0f6e1f70f70c9a0625aeaa8a8015eba352bcfb3978eafca6df10ba5a8 bbdf22e3d989f42b963f1f2f219dfeac11db786f17ac27097ab72f72e7638a2a -R 654e0ae3f3741f82dda9d50fba2bb5a6 +P e6df846f36209bac3e420dd80ce2bbbd87ab7a20b8063fce05f78a3c7ab6027e +R cad28780e6b446bd6e2b3d9b26a145c6 U drh -Z cd9aa5444a2a196c931f4e6dcda6cddb +Z 00ad49f6765aaa2802fdc1e87b94bb22 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d5803c8f68..17975a5072 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e6df846f36209bac3e420dd80ce2bbbd87ab7a20b8063fce05f78a3c7ab6027e \ No newline at end of file +38f1e5ce4eedd59fbeb0a0d676d26dfe8a3313189ab9b9e4a5a1ed6721b73a14 \ No newline at end of file diff --git a/src/treeview.c b/src/treeview.c index c223db29e0..d3346b4686 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -346,7 +346,7 @@ void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){ sqlite3TreeViewItem(pView, "LIMIT", (n--)>0); sqlite3TreeViewExpr(pView, p->pLimit->pLeft, p->pLimit->pRight!=0); if( p->pLimit->pRight ){ - sqlite3TreeViewItem(pView, "OFFSET", (n--)>0); + sqlite3TreeViewItem(pView, "OFFSET", 0); sqlite3TreeViewExpr(pView, p->pLimit->pRight, 0); sqlite3TreeViewPop(&pView); } From d591a5b93d4f84c3e0a3080109936be22292607f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 26 Apr 2024 12:01:17 +0000 Subject: [PATCH 0351/1030] Add test demonstrating the problem at [forum:/forumpost/c243b8f856|forum post c243b8f856]. No fix yet. FossilOrigin-Name: 1685495c0a00238c9c92cce01af8108204a2fad22433ed3e7bba3c9da9ee0766 --- manifest | 16 +++-- manifest.uuid | 2 +- test/bestindexC.test | 137 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 7 deletions(-) create mode 100644 test/bestindexC.test diff --git a/manifest b/manifest index 0c6764a1bf..5aaf6f32cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvement\sto\sthe\sway\sthat\saffinity\sis\sdetermined\sfor\scolumns\sof\sa\ncompound\ssubquery.\s\sThe\saffinity\sis\sthe\saffinity\sof\sthe\sleft-most\narm\sof\sthe\scompound\ssubquery\sthat\shas\san\saffinity\sother\sthan\sNONE,\sadjusted\nto\saccommodate\sthe\sdata\stypes\scoming\sout\sof\sthe\sother\sarms. -D 2024-04-25T23:26:11.710 +C Add\stest\sdemonstrating\sthe\sproblem\sat\s[forum:/forumpost/c243b8f856|forum\spost\sc243b8f856].\sNo\sfix\syet. +D 2024-04-26T12:01:17.532 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -936,6 +936,7 @@ F test/bestindex8.test 333ad8c6a554b885a49b68c019166eda92b05f493a92b36b0acdf7f76 F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede39673a451a0 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce +F test/bestindexC.test cddef2bfebfce49f27d93de6db070e158842e9414ade05e2ddd9f869691bf698 F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -2185,8 +2186,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d99a01a0f6e1f70f70c9a0625aeaa8a8015eba352bcfb3978eafca6df10ba5a8 bbdf22e3d989f42b963f1f2f219dfeac11db786f17ac27097ab72f72e7638a2a -R 654e0ae3f3741f82dda9d50fba2bb5a6 -U drh -Z cd9aa5444a2a196c931f4e6dcda6cddb +P e6df846f36209bac3e420dd80ce2bbbd87ab7a20b8063fce05f78a3c7ab6027e +R 86e9e2a691d55b415e3c7d753f120811 +T *branch * vtab-limit-fix +T *sym-vtab-limit-fix * +T -sym-trunk * +U dan +Z 98d2dacd3c5e1da28914a036142cb128 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d5803c8f68..80649ce5f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e6df846f36209bac3e420dd80ce2bbbd87ab7a20b8063fce05f78a3c7ab6027e \ No newline at end of file +1685495c0a00238c9c92cce01af8108204a2fad22433ed3e7bba3c9da9ee0766 \ No newline at end of file diff --git a/test/bestindexC.test b/test/bestindexC.test new file mode 100644 index 0000000000..91b8f027eb --- /dev/null +++ b/test/bestindexC.test @@ -0,0 +1,137 @@ +# 2023-10-26 +# +# 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 +set testprefix bestindexB + +ifcapable !vtab { + finish_test + return +} + +register_tcl_module db + +proc vtab_command {lVal method args} { + switch -- $method { + xConnect { + return "CREATE TABLE t1(a)" + } + + xBestIndex { + set hdl [lindex $args 0] + set clist [$hdl constraints] + set orderby [$hdl orderby] + + set idxstr [list] + set res [list] + + set idx 0 + foreach c $clist { + array set a $c + if {$a(usable)==0} continue + if {$a(op)=="limit"} { + lappend idxstr limit + lappend res omit $idx + } + if {$a(op)=="offset"} { + lappend idxstr offset + lappend res omit $idx + } + incr idx + } + + return "cost 1000000 rows 1000000 idxnum 0 idxstr {$idxstr} $res" + } + + xFilter { + set idxstr [lindex $args 1] + set LIMIT "" + foreach a $idxstr b [lindex $args 2] { + append LIMIT " $a $b" + } + + set idx 1 + foreach v $lVal { + lappend lRow "($idx, '$v')" + incr idx + } + + return [list sql " + SELECT * FROM ( VALUES [join $lRow ,]) $LIMIT + "] + } + } + + return {} +} + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE x1 USING tcl(vtab_command "a b c d e f"); + CREATE VIRTUAL TABLE x2 USING tcl(vtab_command "A B C D E F a b"); +} {} + +do_execsql_test 1.1 { + CREATE TEMP TABLE t_unionall AS + SELECT * FROM x1 UNION ALL SELECT * FROM x2; + + CREATE TEMP TABLE t_intersect AS + SELECT * FROM x1 INTERSECT SELECT * FROM x2; + + CREATE TEMP TABLE t_union AS + SELECT * FROM x1 UNION SELECT * FROM x2; + + CREATE TEMP TABLE t_except AS + SELECT * FROM x1 EXCEPT SELECT * FROM x2; +} + +foreach {tn limit} { + 1 "LIMIT 8" + 2 "LIMIT 4" + 3 "LIMIT 4 OFFSET 2" + 4 "LIMIT 8 OFFSET 4" +} { + + foreach {op tbl} { + "UNION ALL" t_unionall + "UNION" t_union + "INTERSECT" t_intersect + "EXCEPT" t_except + } { + + set expect [execsql "SELECT * FROM $tbl $limit"] + do_execsql_test 1.2.$tbl.$tn "SELECT * FROM ( + SELECT * FROM x1 $op SELECT * FROM x2 + ) $limit" $expect + + } + +} + +#------------------------------------------------------------------------- +reset_db +register_tcl_module db + +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE x1 USING tcl(vtab_command "a b c d e f"); + CREATE VIRTUAL TABLE x2 USING tcl(vtab_command "a b e f"); +} {} + +do_execsql_test 2.1 { + SELECT * FROM x1 + EXCEPT + SELECT * FROM x2 + LIMIT 3 +} {c d} + +finish_test From 317b7416a6e1a33446ee2fe3478ae4c13075c18b Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 26 Apr 2024 13:30:48 +0000 Subject: [PATCH 0352/1030] Enhance the generated_series() table-valued-function to respond to LIMIT and OFFSET. Use this to add new test cases for LIMIT and OFFSET on virtual tables in a compound SELECT. FossilOrigin-Name: 408d47ecaa3b906d0886f76a22b76339ec5878270ffe8d1838c74de09c29a33e --- ext/misc/series.c | 80 +++++++++++++++++++++++++++++++++------------ manifest | 19 +++++------ manifest.uuid | 2 +- test/tabfunc01.test | 26 +++++++++++++++ 4 files changed, 94 insertions(+), 33 deletions(-) diff --git a/ext/misc/series.c b/ext/misc/series.c index 3e859a8f23..22968854ca 100644 --- a/ext/misc/series.c +++ b/ext/misc/series.c @@ -376,13 +376,13 @@ static int seriesEof(sqlite3_vtab_cursor *cur){ ** parameter. (idxStr is not used in this implementation.) idxNum ** is a bitmask showing which constraints are available: ** -** 1: start=VALUE -** 2: stop=VALUE -** 4: step=VALUE -** -** Also, if bit 8 is set, that means that the series should be output -** in descending order rather than in ascending order. If bit 16 is -** set, then output must appear in ascending order. +** 0x01: start=VALUE +** 0x02: stop=VALUE +** 0x04: step=VALUE +** 0x08: descending order +** 0x10: ascending order +** 0x20: LIMIT VALUE +** 0x40: OFFSET VALUE ** ** This routine should initialize the cursor and position it so that it ** is pointing at the first row, or pointing off the end of the table @@ -396,17 +396,17 @@ static int seriesFilter( series_cursor *pCur = (series_cursor *)pVtabCursor; int i = 0; (void)idxStrUnused; - if( idxNum & 1 ){ + if( idxNum & 0x01 ){ pCur->ss.iBase = sqlite3_value_int64(argv[i++]); }else{ pCur->ss.iBase = 0; } - if( idxNum & 2 ){ + if( idxNum & 0x02 ){ pCur->ss.iTerm = sqlite3_value_int64(argv[i++]); }else{ pCur->ss.iTerm = 0xffffffff; } - if( idxNum & 4 ){ + if( idxNum & 0x04 ){ pCur->ss.iStep = sqlite3_value_int64(argv[i++]); if( pCur->ss.iStep==0 ){ pCur->ss.iStep = 1; @@ -416,6 +416,24 @@ static int seriesFilter( }else{ pCur->ss.iStep = 1; } + if( idxNum & 0x20 ){ + sqlite3_int64 iLimit = sqlite3_value_int64(argv[i++]); + sqlite3_int64 iTerm; + if( idxNum & 0x40 ){ + sqlite3_int64 iOffset = sqlite3_value_int64(argv[i++]); + if( iOffset>0 ){ + pCur->ss.iBase += pCur->ss.iStep*iOffset; + } + } + if( iLimit>=0 ){ + iTerm = pCur->ss.iBase + (iLimit - 1)*pCur->ss.iStep; + if( pCur->ss.iStep<0 ){ + if( iTerm>pCur->ss.iTerm ) pCur->ss.iTerm = iTerm; + }else{ + if( iTermss.iTerm ) pCur->ss.iTerm = iTerm; + } + } + } for(i=0; iss.isReversing = pCur->ss.iStep > 0; }else{ pCur->ss.isReversing = pCur->ss.iStep < 0; @@ -446,10 +464,13 @@ static int seriesFilter( ** ** The query plan is represented by bits in idxNum: ** -** (1) start = $value -- constraint exists -** (2) stop = $value -- constraint exists -** (4) step = $value -- constraint exists -** (8) output in descending order +** 0x01 start = $value -- constraint exists +** 0x02 stop = $value -- constraint exists +** 0x04 step = $value -- constraint exists +** 0x08 output is in descending order +** 0x10 output is in ascending order +** 0x20 LIMIT $value -- constraint exists +** 0x40 OFFSET $value -- constraint exists */ static int seriesBestIndex( sqlite3_vtab *pVTab, @@ -460,7 +481,7 @@ static int seriesBestIndex( int bStartSeen = 0; /* EQ constraint seen on the START column */ int unusableMask = 0; /* Mask of unusable constraints */ int nArg = 0; /* Number of arguments that seriesFilter() expects */ - int aIdx[3]; /* Constraints on start, stop, and step */ + int aIdx[5]; /* Constraints on start, stop, step, LIMIT, OFFSET */ const struct sqlite3_index_constraint *pConstraint; /* This implementation assumes that the start, stop, and step columns @@ -468,11 +489,22 @@ static int seriesBestIndex( assert( SERIES_COLUMN_STOP == SERIES_COLUMN_START+1 ); assert( SERIES_COLUMN_STEP == SERIES_COLUMN_START+2 ); - aIdx[0] = aIdx[1] = aIdx[2] = -1; + aIdx[0] = aIdx[1] = aIdx[2] = aIdx[3] = aIdx[4] = -1; pConstraint = pIdxInfo->aConstraint; for(i=0; inConstraint; i++, pConstraint++){ int iCol; /* 0 for start, 1 for stop, 2 for step */ int iMask; /* bitmask for those column */ + int op = pConstraint->op; + if( op!=SQLITE_INDEX_CONSTRAINT_EQ ){ + if( op==SQLITE_INDEX_CONSTRAINT_LIMIT ){ + aIdx[3] = i; + idxNum |= 0x20; + }else if( op==SQLITE_INDEX_CONSTRAINT_OFFSET ){ + aIdx[4] = i; + idxNum |= 0x40; + } + continue; + } if( pConstraint->iColumniColumn - SERIES_COLUMN_START; assert( iCol>=0 && iCol<=2 ); @@ -486,10 +518,16 @@ static int seriesBestIndex( aIdx[iCol] = i; } } - for(i=0; i<3; i++){ + if( aIdx[3]==0 ){ + /* Ignore OFFSET if LIMIT is omitted */ + idxNum &= ~0x60; + aIdx[4] = 0; + } + for(i=0; i<5; i++){ if( (j = aIdx[i])>=0 ){ pIdxInfo->aConstraintUsage[j].argvIndex = ++nArg; - pIdxInfo->aConstraintUsage[j].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY; + pIdxInfo->aConstraintUsage[j].omit = + !SQLITE_SERIES_CONSTRAINT_VERIFY || i>=3; } } /* The current generate_column() implementation requires at least one @@ -517,9 +555,9 @@ static int seriesBestIndex( pIdxInfo->estimatedRows = 1000; if( pIdxInfo->nOrderBy>=1 && pIdxInfo->aOrderBy[0].iColumn==0 ){ if( pIdxInfo->aOrderBy[0].desc ){ - idxNum |= 8; + idxNum |= 0x08; }else{ - idxNum |= 16; + idxNum |= 0x10; } pIdxInfo->orderByConsumed = 1; } diff --git a/manifest b/manifest index 5aaf6f32cc..df3495002e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\sdemonstrating\sthe\sproblem\sat\s[forum:/forumpost/c243b8f856|forum\spost\sc243b8f856].\sNo\sfix\syet. -D 2024-04-26T12:01:17.532 +C Enhance\sthe\sgenerated_series()\stable-valued-function\sto\srespond\sto\nLIMIT\sand\sOFFSET.\s\sUse\sthis\sto\sadd\snew\stest\scases\sfor\sLIMIT\sand\sOFFSET\non\svirtual\stables\sin\sa\scompound\sSELECT. +D 2024-04-26T13:30:48.724 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -411,7 +411,7 @@ F ext/misc/regexp.c 4bdd0045912f81c84908bd535ec5ad3b1c8540b4287c70ab840709636240 F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 -F ext/misc/series.c 384f93a8a09cf45e1aa6575660cb580ed61d372c590aad05cdcd4a84fbd8f6ab +F ext/misc/series.c 69df6c989a37c58d831dcd4c6742ea7c98bc1517d45905290445f3bb277d2cbf F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d F ext/misc/shathree.c 543af7ce71d391cd3a9ab6924a6a1124efc63211fd0f2e240dc4b56077ba88ac F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 @@ -1679,7 +1679,7 @@ F test/sync.test 89539f4973c010eda5638407e71ca7fddbcd8e0594f4c9980229f804d433309 F test/sync2.test 8f9f7d4f6d5be8ca8941a8dadcc4299e558cb6a1ff653a9469146c7a76ef2039 F test/syscall.test a39d9a36f852ae6e4800f861bc2f2e83f68bbc2112d9399931ecfadeabd2d69d F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test 54f27eacd054aa528a8b6e3331192c484104f30aaee351ad035f2b39a00f87c4 +F test/tabfunc01.test f150d206294471d20f50029e6b46b76b87a7a010b16dc57eb44245c76dd02802 F test/table.test 7862a00b58b5541511a26757ea9c5c7c3f8298766e98aa099deec703d9c0a8e0 F test/tableapi.test ecbcc29c4ab62c1912c3717c48ea5c5e59f7d64e4a91034e6148bd2b82f177f4 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -2186,11 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e6df846f36209bac3e420dd80ce2bbbd87ab7a20b8063fce05f78a3c7ab6027e -R 86e9e2a691d55b415e3c7d753f120811 -T *branch * vtab-limit-fix -T *sym-vtab-limit-fix * -T -sym-trunk * -U dan -Z 98d2dacd3c5e1da28914a036142cb128 +P 1685495c0a00238c9c92cce01af8108204a2fad22433ed3e7bba3c9da9ee0766 +R 5bce82b446834e1e285fe6cb5599985f +U drh +Z 002d1fa139abb35e0569e061564589d9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 80649ce5f9..9a585c8218 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1685495c0a00238c9c92cce01af8108204a2fad22433ed3e7bba3c9da9ee0766 \ No newline at end of file +408d47ecaa3b906d0886f76a22b76339ec5878270ffe8d1838c74de09c29a33e \ No newline at end of file diff --git a/test/tabfunc01.test b/test/tabfunc01.test index 8e90c549fa..3a62b81f99 100644 --- a/test/tabfunc01.test +++ b/test/tabfunc01.test @@ -322,6 +322,32 @@ ifcapable altertable { } {1 {table pragma_compile_options may not be altered}} } +#----------------------------------------------------------------------------- +# 2024-04-26 LIMIT and OFFSET passed into virtual tables +# https://sqlite.org/forum/forumpost/c243b8f856 +# +do_execsql_test tabfunc01-900 { + SELECT * FROM ( + SELECT * FROM generate_series(1,10) + UNION ALL + SELECT * FROM generate_series(101,104) + ) LIMIT 10 OFFSET 5; +} {6 7 8 9 10 101 102 103 104} +do_execsql_test tabfunc01-910 { + SELECT * FROM ( + SELECT * FROM generate_series(1,10) + UNION ALL + SELECT * FROM generate_series(101,104) + ) LIMIT -1 OFFSET 5; +} {6 7 8 9 10 101 102 103 104} +do_execsql_test tabfunc01-920 { + SELECT * FROM ( + SELECT * FROM generate_series(1,10) + UNION ALL + SELECT * FROM generate_series(101,104) + ) LIMIT -1 OFFSET 0; +} {1 2 3 4 5 6 7 8 9 10 101 102 103 104} + # Free up memory allocations intarray_addr From 99ac2324aa7f52713d4a14b29e0dde6f2c9479aa Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 26 Apr 2024 13:38:43 +0000 Subject: [PATCH 0353/1030] Fix handling of LIMIT and OFFSET in virtual tables that are part of a compound SELECT. FossilOrigin-Name: 40421c1c4ed5bb1ed79ad7ee37cb5a4f0b7864c1eb94abd8ee357ab2202cad30 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 8 +++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index df3495002e..29cf2f4115 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sgenerated_series()\stable-valued-function\sto\srespond\sto\nLIMIT\sand\sOFFSET.\s\sUse\sthis\sto\sadd\snew\stest\scases\sfor\sLIMIT\sand\sOFFSET\non\svirtual\stables\sin\sa\scompound\sSELECT. -D 2024-04-26T13:30:48.724 +C Fix\shandling\sof\sLIMIT\sand\sOFFSET\sin\svirtual\stables\sthat\sare\spart\sof\na\scompound\sSELECT. +D 2024-04-26T13:38:43.836 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -839,7 +839,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 447d8761632fb0a18b03077161415d9713cbd0a81bf34a35cee63480e5c401c5 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 1f6940349e92a6e056aecd70163b00f331554c815c362b4cc80906c48151d73d -F src/whereexpr.c 7b64295f1d82ad0928df435925dd7bbd5997b44a026153113eace0d9e71ff435 +F src/whereexpr.c f6c25f7c8c0301f983dbf2ca06dc0081728e3a6c104f6ffdfacd64d80c5c2e76 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2186,8 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1685495c0a00238c9c92cce01af8108204a2fad22433ed3e7bba3c9da9ee0766 -R 5bce82b446834e1e285fe6cb5599985f +P 408d47ecaa3b906d0886f76a22b76339ec5878270ffe8d1838c74de09c29a33e +R 6c52e220da37a777a1b67496ddeb5f65 U drh -Z 002d1fa139abb35e0569e061564589d9 +Z b21bac460d0c0d27bd69b9e1b44612bb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9a585c8218..e5ba1bb14a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -408d47ecaa3b906d0886f76a22b76339ec5878270ffe8d1838c74de09c29a33e \ No newline at end of file +40421c1c4ed5bb1ed79ad7ee37cb5a4f0b7864c1eb94abd8ee357ab2202cad30 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 9d1f947a09..ff6f753b5a 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1652,9 +1652,11 @@ void SQLITE_NOINLINE sqlite3WhereAddLimit(WhereClause *pWC, Select *p){ /* All conditions are met. Add the terms to the where-clause object. */ assert( p->pLimit->op==TK_LIMIT ); - whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft, - iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT); - if( p->iOffset>0 ){ + if( p->iOffset==0 || (p->selFlags & SF_Compound)==0 ){ + whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft, + iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT); + } + if( p->iOffset!=0 && (p->selFlags & SF_Compound)==0 ){ whereAddLimitExpr(pWC, p->iOffset, p->pLimit->pRight, iCsr, SQLITE_INDEX_CONSTRAINT_OFFSET); } From 3afd5b6d6565902271c09d6fa487e68fef3e92a4 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 26 Apr 2024 14:32:58 +0000 Subject: [PATCH 0354/1030] Fix a problem allowing a LIMIT constraint to be passed to a virtual table in cases where there exist WHERE terms that cannot also be passed. FossilOrigin-Name: 72c8ed9698dd2aadee7b84fd293e8306233f0fe5b5b5731687482444fdf461c7 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/whereexpr.c | 1 + test/bestindexC.test | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 29cf2f4115..a2f90a673f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\shandling\sof\sLIMIT\sand\sOFFSET\sin\svirtual\stables\sthat\sare\spart\sof\na\scompound\sSELECT. -D 2024-04-26T13:38:43.836 +C Fix\sa\sproblem\sallowing\sa\sLIMIT\sconstraint\sto\sbe\spassed\sto\sa\svirtual\stable\sin\scases\swhere\sthere\sexist\sWHERE\sterms\sthat\scannot\salso\sbe\spassed. +D 2024-04-26T14:32:58.805 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -839,7 +839,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 447d8761632fb0a18b03077161415d9713cbd0a81bf34a35cee63480e5c401c5 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 1f6940349e92a6e056aecd70163b00f331554c815c362b4cc80906c48151d73d -F src/whereexpr.c f6c25f7c8c0301f983dbf2ca06dc0081728e3a6c104f6ffdfacd64d80c5c2e76 +F src/whereexpr.c e8e26dbdefa3d89c726251c8b9690ad9766ad00b92cfd11c54402e7dd1350ce7 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -936,7 +936,7 @@ F test/bestindex8.test 333ad8c6a554b885a49b68c019166eda92b05f493a92b36b0acdf7f76 F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede39673a451a0 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce -F test/bestindexC.test cddef2bfebfce49f27d93de6db070e158842e9414ade05e2ddd9f869691bf698 +F test/bestindexC.test c4957155d9bd21a3e5bdd7cf32e9753b721fff7a373fdc7a8769a2a072877b7f F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -2186,8 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 408d47ecaa3b906d0886f76a22b76339ec5878270ffe8d1838c74de09c29a33e -R 6c52e220da37a777a1b67496ddeb5f65 -U drh -Z b21bac460d0c0d27bd69b9e1b44612bb +P 40421c1c4ed5bb1ed79ad7ee37cb5a4f0b7864c1eb94abd8ee357ab2202cad30 +R 2db4adc3908600896b903e9d700f2b90 +U dan +Z 2050298cecb5ad6b15cc33d4bff9b8cd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e5ba1bb14a..ba5576360c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -40421c1c4ed5bb1ed79ad7ee37cb5a4f0b7864c1eb94abd8ee357ab2202cad30 \ No newline at end of file +72c8ed9698dd2aadee7b84fd293e8306233f0fe5b5b5731687482444fdf461c7 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index ff6f753b5a..d25bce5f08 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1638,6 +1638,7 @@ void SQLITE_NOINLINE sqlite3WhereAddLimit(WhereClause *pWC, Select *p){ continue; } if( pWC->a[ii].leftCursor!=iCsr ) return; + if( pWC->a[ii].prereqRight!=0 ) return; } /* Check condition (5). Return early if it is not met. */ diff --git a/test/bestindexC.test b/test/bestindexC.test index 91b8f027eb..769f1601db 100644 --- a/test/bestindexC.test +++ b/test/bestindexC.test @@ -134,4 +134,24 @@ do_execsql_test 2.1 { LIMIT 3 } {c d} +#------------------------------------------------------------------------- +reset_db +register_tcl_module db +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE y1 USING tcl(vtab_command "1 2 3 4 5 6 7 8 9 10"); +} {} + +do_execsql_test 3.1 { + SELECT * FROM y1 WHERE a = COALESCE('8', a) LIMIT 3 +} {8} + +do_execsql_test 3.2 { + SELECT * FROM y1 WHERE a = '2' LIMIT 3 +} {2} + +load_static_extension db series +do_execsql_test 3.3 { + SELECT * FROM generate_series(1, 5) WHERE value = (value & 14) LIMIT 3 +} {2 4} + finish_test From 84a231eb619f462ea183969eb29be23f5f4ecdda Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 26 Apr 2024 14:36:28 +0000 Subject: [PATCH 0355/1030] Use hex flag masks rather than decimals in ext/misc/series.c. FossilOrigin-Name: a94e2cd02873c283d46bf6c21d0306ad454881d7882bb167d043cc79f79a2396 --- ext/misc/series.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/misc/series.c b/ext/misc/series.c index 22968854ca..e355e5aab7 100644 --- a/ext/misc/series.c +++ b/ext/misc/series.c @@ -411,7 +411,7 @@ static int seriesFilter( if( pCur->ss.iStep==0 ){ pCur->ss.iStep = 1; }else if( pCur->ss.iStep<0 ){ - if( (idxNum & 16)==0 ) idxNum |= 8; + if( (idxNum & 0x10)==0 ) idxNum |= 0x08; } }else{ pCur->ss.iStep = 1; diff --git a/manifest b/manifest index a2f90a673f..6ebcff0402 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sallowing\sa\sLIMIT\sconstraint\sto\sbe\spassed\sto\sa\svirtual\stable\sin\scases\swhere\sthere\sexist\sWHERE\sterms\sthat\scannot\salso\sbe\spassed. -D 2024-04-26T14:32:58.805 +C Use\shex\sflag\smasks\srather\sthan\sdecimals\sin\sext/misc/series.c. +D 2024-04-26T14:36:28.914 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -411,7 +411,7 @@ F ext/misc/regexp.c 4bdd0045912f81c84908bd535ec5ad3b1c8540b4287c70ab840709636240 F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 -F ext/misc/series.c 69df6c989a37c58d831dcd4c6742ea7c98bc1517d45905290445f3bb277d2cbf +F ext/misc/series.c ba7c22c607e24c42bd8e6f289e246abb997e6a11b76b1a385d6f4272eae1ac88 F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d F ext/misc/shathree.c 543af7ce71d391cd3a9ab6924a6a1124efc63211fd0f2e240dc4b56077ba88ac F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 @@ -2186,8 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 40421c1c4ed5bb1ed79ad7ee37cb5a4f0b7864c1eb94abd8ee357ab2202cad30 -R 2db4adc3908600896b903e9d700f2b90 -U dan -Z 2050298cecb5ad6b15cc33d4bff9b8cd +P 72c8ed9698dd2aadee7b84fd293e8306233f0fe5b5b5731687482444fdf461c7 +R e853dfcde05ddfe7b4221b55af72f1df +U drh +Z 2da9867ae5f646560b353212baa0f0fb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ba5576360c..bc24868c16 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -72c8ed9698dd2aadee7b84fd293e8306233f0fe5b5b5731687482444fdf461c7 \ No newline at end of file +a94e2cd02873c283d46bf6c21d0306ad454881d7882bb167d043cc79f79a2396 \ No newline at end of file From d3a4dbe4b84732a57393a1966bae5ab56460478e Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 26 Apr 2024 17:09:33 +0000 Subject: [PATCH 0356/1030] Further fixes and improvements to the generate_series() enhancements on this branch. FossilOrigin-Name: b7d9bd7ee2f4100608063fdf7648f290351465d393bc876a89704f643358853e --- ext/misc/series.c | 26 ++++++++++++++++++++------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ext/misc/series.c b/ext/misc/series.c index e355e5aab7..0dfed181f6 100644 --- a/ext/misc/series.c +++ b/ext/misc/series.c @@ -478,7 +478,9 @@ static int seriesBestIndex( ){ int i, j; /* Loop over constraints */ int idxNum = 0; /* The query plan bitmask */ +#ifndef ZERO_ARGUMENT_GENERATE_SERIES int bStartSeen = 0; /* EQ constraint seen on the START column */ +#endif int unusableMask = 0; /* Mask of unusable constraints */ int nArg = 0; /* Number of arguments that seriesFilter() expects */ int aIdx[5]; /* Constraints on start, stop, step, LIMIT, OFFSET */ @@ -495,11 +497,16 @@ static int seriesBestIndex( int iCol; /* 0 for start, 1 for stop, 2 for step */ int iMask; /* bitmask for those column */ int op = pConstraint->op; - if( op!=SQLITE_INDEX_CONSTRAINT_EQ ){ - if( op==SQLITE_INDEX_CONSTRAINT_LIMIT ){ + if( op>=SQLITE_INDEX_CONSTRAINT_LIMIT + && op<=SQLITE_INDEX_CONSTRAINT_OFFSET + ){ + if( pConstraint->usable==0 ){ + /* do nothing */ + }else if( op==SQLITE_INDEX_CONSTRAINT_LIMIT ){ aIdx[3] = i; idxNum |= 0x20; - }else if( op==SQLITE_INDEX_CONSTRAINT_OFFSET ){ + }else{ + assert( op==SQLITE_INDEX_CONSTRAINT_OFFSET ); aIdx[4] = i; idxNum |= 0x40; } @@ -509,11 +516,15 @@ static int seriesBestIndex( iCol = pConstraint->iColumn - SERIES_COLUMN_START; assert( iCol>=0 && iCol<=2 ); iMask = 1 << iCol; - if( iCol==0 ) bStartSeen = 1; +#ifndef ZERO_ARGUMENT_GENERATE_SERIES + if( iCol==0 && op==SQLITE_INDEX_CONSTRAINT_EQ ){ + bStartSeen = 1; + } +#endif if( pConstraint->usable==0 ){ unusableMask |= iMask; continue; - }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){ + }else if( op==SQLITE_INDEX_CONSTRAINT_EQ ){ idxNum |= iMask; aIdx[iCol] = i; } @@ -548,7 +559,7 @@ static int seriesBestIndex( ** this plan is unusable */ return SQLITE_CONSTRAINT; } - if( (idxNum & 3)==3 ){ + if( (idxNum & 0x03)==0x03 ){ /* Both start= and stop= boundaries are available. This is the ** the preferred case */ pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0)); @@ -561,6 +572,9 @@ static int seriesBestIndex( } pIdxInfo->orderByConsumed = 1; } + }else if( (idxNum & 0x21)==0x21 ){ + /* We have start= and LIMIT */ + pIdxInfo->estimatedRows = 2500; }else{ /* If either boundary is missing, we have to generate a huge span ** of numbers. Make this case very expensive so that the query diff --git a/manifest b/manifest index 6ebcff0402..8aa5658ec1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\shex\sflag\smasks\srather\sthan\sdecimals\sin\sext/misc/series.c. -D 2024-04-26T14:36:28.914 +C Further\sfixes\sand\simprovements\sto\sthe\sgenerate_series()\senhancements\son\nthis\sbranch. +D 2024-04-26T17:09:33.571 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -411,7 +411,7 @@ F ext/misc/regexp.c 4bdd0045912f81c84908bd535ec5ad3b1c8540b4287c70ab840709636240 F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 -F ext/misc/series.c ba7c22c607e24c42bd8e6f289e246abb997e6a11b76b1a385d6f4272eae1ac88 +F ext/misc/series.c d96e5aac21658c6b5d54f918ac140460ec7197734c1a4fba806950831a7b1e7a F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d F ext/misc/shathree.c 543af7ce71d391cd3a9ab6924a6a1124efc63211fd0f2e240dc4b56077ba88ac F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 @@ -2186,8 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 72c8ed9698dd2aadee7b84fd293e8306233f0fe5b5b5731687482444fdf461c7 -R e853dfcde05ddfe7b4221b55af72f1df +P a94e2cd02873c283d46bf6c21d0306ad454881d7882bb167d043cc79f79a2396 +R 321007e70e23799770941a10ae3004c2 U drh -Z 2da9867ae5f646560b353212baa0f0fb +Z 725229cc9017e5eea01f2ec07aa5dfdd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bc24868c16..269ea1f24e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a94e2cd02873c283d46bf6c21d0306ad454881d7882bb167d043cc79f79a2396 \ No newline at end of file +b7d9bd7ee2f4100608063fdf7648f290351465d393bc876a89704f643358853e \ No newline at end of file From 297472a2fcae79eb2e531d8c93fdb7f36725afdb Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 26 Apr 2024 17:19:59 +0000 Subject: [PATCH 0357/1030] Have where.c ignore any plan from a virtual table that tries to use LIMIT/OFFSET without also using all WHERE constraints. FossilOrigin-Name: 7d30596496c6a7a37b925f13d8d94d5de224ec31bb86594fa4cc07b10082e776 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 30 ++++++++++++++++++++++++++---- test/bestindexC.test | 8 ++++++-- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 8aa5658ec1..f0eb8e05e2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\sfixes\sand\simprovements\sto\sthe\sgenerate_series()\senhancements\son\nthis\sbranch. -D 2024-04-26T17:09:33.571 +C Have\swhere.c\signore\sany\splan\sfrom\sa\svirtual\stable\sthat\stries\sto\suse\sLIMIT/OFFSET\swithout\salso\susing\sall\sWHERE\sconstraints. +D 2024-04-26T17:19:59.258 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -836,7 +836,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 447d8761632fb0a18b03077161415d9713cbd0a81bf34a35cee63480e5c401c5 +F src/where.c 0ef9638651b900d64d7e1e877af37cd7900159ff875547ec29b918a1497e5c9c F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 1f6940349e92a6e056aecd70163b00f331554c815c362b4cc80906c48151d73d F src/whereexpr.c e8e26dbdefa3d89c726251c8b9690ad9766ad00b92cfd11c54402e7dd1350ce7 @@ -936,7 +936,7 @@ F test/bestindex8.test 333ad8c6a554b885a49b68c019166eda92b05f493a92b36b0acdf7f76 F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede39673a451a0 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce -F test/bestindexC.test c4957155d9bd21a3e5bdd7cf32e9753b721fff7a373fdc7a8769a2a072877b7f +F test/bestindexC.test 6a632d3b58ffce7b9d4492c93901384d5ede891b0db76c30f90805eaccacc3bc F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -2186,8 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a94e2cd02873c283d46bf6c21d0306ad454881d7882bb167d043cc79f79a2396 -R 321007e70e23799770941a10ae3004c2 -U drh -Z 725229cc9017e5eea01f2ec07aa5dfdd +P b7d9bd7ee2f4100608063fdf7648f290351465d393bc876a89704f643358853e +R 730af36fce33d6528809ae8d9bef3e6c +U dan +Z 5c5972d6c199bce591c9d5b5a3c5a03a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 269ea1f24e..a43f8e3abf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b7d9bd7ee2f4100608063fdf7648f290351465d393bc876a89704f643358853e \ No newline at end of file +7d30596496c6a7a37b925f13d8d94d5de224ec31bb86594fa4cc07b10082e776 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 39210ddb28..820e922490 100644 --- a/src/where.c +++ b/src/where.c @@ -4057,6 +4057,21 @@ static int isLimitTerm(WhereTerm *pTerm){ && pTerm->eMatchOp<=SQLITE_INDEX_CONSTRAINT_OFFSET; } +/* +** Return true if the first nCons constraints in the pUsage array are +** marked as in-use (have argvIndex>0). False otherwise. +*/ +static int allConstraintsUsed( + struct sqlite3_index_constraint_usage *aUsage, + int nCons +){ + int ii; + for(ii=0; iipNew->iTab. This @@ -4197,13 +4212,20 @@ static int whereLoopAddVirtualOne( *pbIn = 1; assert( (mExclude & WO_IN)==0 ); } + /* Unless pbRetryLimit is non-NULL, there should be no LIMIT/OFFSET + ** terms. And if there are any, they should follow all other terms. */ assert( pbRetryLimit || !isLimitTerm(pTerm) ); - if( isLimitTerm(pTerm) && *pbIn ){ + assert( !isLimitTerm(pTerm) || i>=nConstraint-2 ); + assert( !isLimitTerm(pTerm) || i==nConstraint-1 || isLimitTerm(pTerm+1) ); + + if( isLimitTerm(pTerm) && (*pbIn || !allConstraintsUsed(pUsage, i)) ){ /* If there is an IN(...) term handled as an == (separate call to ** xFilter for each value on the RHS of the IN) and a LIMIT or - ** OFFSET term handled as well, the plan is unusable. Set output - ** variable *pbRetryLimit to true to tell the caller to retry with - ** LIMIT and OFFSET disabled. */ + ** OFFSET term handled as well, the plan is unusable. Similarly, + ** if there is a LIMIT/OFFSET and there are other unused terms, + ** the plan cannot be used. In these cases set variable *pbRetryLimit + ** to true to tell the caller to retry with LIMIT and OFFSET + ** disabled. */ if( pIdxInfo->needToFreeIdxStr ){ sqlite3_free(pIdxInfo->idxStr); pIdxInfo->idxStr = 0; diff --git a/test/bestindexC.test b/test/bestindexC.test index 769f1601db..d854216008 100644 --- a/test/bestindexC.test +++ b/test/bestindexC.test @@ -1,4 +1,4 @@ -# 2023-10-26 +# 2024-04-26 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: @@ -13,7 +13,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl -set testprefix bestindexB +set testprefix bestindexC ifcapable !vtab { finish_test @@ -154,4 +154,8 @@ do_execsql_test 3.3 { SELECT * FROM generate_series(1, 5) WHERE value = (value & 14) LIMIT 3 } {2 4} +do_execsql_test 3.4 { + SELECT value FROM generate_series(1,10) WHERE value>2 LIMIT 4 OFFSET 1; +} {4 5 6 7} + finish_test From 4c3ab545a91d50fd13e711dc250cce6927407ca2 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 26 Apr 2024 18:13:11 +0000 Subject: [PATCH 0358/1030] Allow virtual table implementations to handle OFFSET but not LIMIT, but not LIMIT but not OFFSET. FossilOrigin-Name: 90e5c8226a695e838e8c1703a9b8598e654d216799e8806c4d1a1f20c28c6486 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/whereexpr.c | 8 ++++---- test/bestindex8.test | 2 +- test/bestindexC.test | 23 ++++++++++++++++++++--- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index f0eb8e05e2..e044be16da 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\swhere.c\signore\sany\splan\sfrom\sa\svirtual\stable\sthat\stries\sto\suse\sLIMIT/OFFSET\swithout\salso\susing\sall\sWHERE\sconstraints. -D 2024-04-26T17:19:59.258 +C Allow\svirtual\stable\simplementations\sto\shandle\sOFFSET\sbut\snot\sLIMIT,\sbut\snot\sLIMIT\sbut\snot\sOFFSET. +D 2024-04-26T18:13:11.880 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -839,7 +839,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 0ef9638651b900d64d7e1e877af37cd7900159ff875547ec29b918a1497e5c9c F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c 1f6940349e92a6e056aecd70163b00f331554c815c362b4cc80906c48151d73d -F src/whereexpr.c e8e26dbdefa3d89c726251c8b9690ad9766ad00b92cfd11c54402e7dd1350ce7 +F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -932,11 +932,11 @@ F test/bestindex4.test 3039894f2dad50f3a68443dffad1b44c9b067ac03870102df1ce3d9a4 F test/bestindex5.test a0c90b2dad7836e80a01379e200e5f8ec9476d49b349af02c0dbff2fb75dc98d F test/bestindex6.test 16942535b551273f3ad9df8d7cc4b7f22b1fcd8882714358859eb049a6f99dd4 F test/bestindex7.test f094c669a6400777f4d2ddc3ed28e39169f1adb5be3d59b55f22ccf8c414b71e -F test/bestindex8.test 333ad8c6a554b885a49b68c019166eda92b05f493a92b36b0acdf7f766d04dad +F test/bestindex8.test b63a4f171a2c83d481bb14c431a8b72e85d27b2ffdaa0435a95d58ca941678f9 F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede39673a451a0 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce -F test/bestindexC.test 6a632d3b58ffce7b9d4492c93901384d5ede891b0db76c30f90805eaccacc3bc +F test/bestindexC.test c14a8c8639b6825b0efa1ae693f34ec04f41a46e3056e7063d6e0f46bf4ff692 F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -2186,8 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b7d9bd7ee2f4100608063fdf7648f290351465d393bc876a89704f643358853e -R 730af36fce33d6528809ae8d9bef3e6c +P 7d30596496c6a7a37b925f13d8d94d5de224ec31bb86594fa4cc07b10082e776 +R 9eed5aaa8e26bff88d62db6ed7adfa29 U dan -Z 5c5972d6c199bce591c9d5b5a3c5a03a +Z d168d9476b0b5c157ebfbc91beb1e6fe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a43f8e3abf..3d3eb37fa7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7d30596496c6a7a37b925f13d8d94d5de224ec31bb86594fa4cc07b10082e776 \ No newline at end of file +90e5c8226a695e838e8c1703a9b8598e654d216799e8806c4d1a1f20c28c6486 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index d25bce5f08..5465dc953b 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1653,14 +1653,14 @@ void SQLITE_NOINLINE sqlite3WhereAddLimit(WhereClause *pWC, Select *p){ /* All conditions are met. Add the terms to the where-clause object. */ assert( p->pLimit->op==TK_LIMIT ); - if( p->iOffset==0 || (p->selFlags & SF_Compound)==0 ){ - whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft, - iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT); - } if( p->iOffset!=0 && (p->selFlags & SF_Compound)==0 ){ whereAddLimitExpr(pWC, p->iOffset, p->pLimit->pRight, iCsr, SQLITE_INDEX_CONSTRAINT_OFFSET); } + if( p->iOffset==0 || (p->selFlags & SF_Compound)==0 ){ + whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft, + iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT); + } } } diff --git a/test/bestindex8.test b/test/bestindex8.test index e95c3c6dc2..3ed7f6703e 100644 --- a/test/bestindex8.test +++ b/test/bestindex8.test @@ -158,7 +158,7 @@ do_test 2.2 { set ::lFilterArgs [list] execsql { SELECT * FROM vt1 LIMIT 5 OFFSET 50 } set ::lFilterArgs -} {{5 50}} +} {{50 5}} do_test 2.3 { set ::lFilterArgs [list] diff --git a/test/bestindexC.test b/test/bestindexC.test index d854216008..476ea39faa 100644 --- a/test/bestindexC.test +++ b/test/bestindexC.test @@ -40,11 +40,11 @@ proc vtab_command {lVal method args} { foreach c $clist { array set a $c if {$a(usable)==0} continue - if {$a(op)=="limit"} { + if {$a(op)=="limit" && ![info exists ::do_not_use_limit]} { lappend idxstr limit lappend res omit $idx } - if {$a(op)=="offset"} { + if {$a(op)=="offset" && ![info exists ::do_not_use_offset]} { lappend idxstr offset lappend res omit $idx } @@ -58,9 +58,13 @@ proc vtab_command {lVal method args} { set idxstr [lindex $args 1] set LIMIT "" foreach a $idxstr b [lindex $args 2] { - append LIMIT " $a $b" + set x($a) $b } + if {![info exists x(limit)]} { set x(limit) -1 } + if {![info exists x(offset)]} { set x(offset) -1 } + set LIMIT " LIMIT $x(limit) OFFSET $x(offset)" + set idx 1 foreach v $lVal { lappend lRow "($idx, '$v')" @@ -158,4 +162,17 @@ do_execsql_test 3.4 { SELECT value FROM generate_series(1,10) WHERE value>2 LIMIT 4 OFFSET 1; } {4 5 6 7} +set ::do_not_use_limit 1 +do_execsql_test 3.5 { + SELECT * FROM y1 LIMIT 5 OFFSET 3 +} {4 5 6 7 8} +unset ::do_not_use_limit +set ::do_not_use_offset 1 +do_execsql_test 3.6 { + SELECT * FROM y1 LIMIT 5 OFFSET 3 +} {4 5 6 7 8} +unset ::do_not_use_offset + + + finish_test From 6c290ccd49248e6e53937172bea6598ed77eee69 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 26 Apr 2024 18:24:23 +0000 Subject: [PATCH 0359/1030] Additional internal docs in the wasm utilities. FossilOrigin-Name: 5a2245a9ebae6d23cd343e46b9d730f66ec4d5ffc91b83ed11a0fbd2194ad807 --- ext/wasm/common/whwasmutil.js | 28 +++++++++++++++++++++++++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index 0437ef35d8..65421e3fac 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -1382,15 +1382,19 @@ globalThis.WhWasmUtilInstaller = function(target){ conversion of argument or return types, but see xWrap() and xCallWrapped() for variants which do. + If the first argument is a function is is assumed to be + a WASM-bound function and is used as-is instead of looking up + the function via xGet(). + As a special case, if passed only 1 argument after the name and that argument in an Array, that array's entries become the function arguments. (This is not an ambiguous case because it's not legal to pass an Array object to a WASM function.) */ target.xCall = function(fname, ...args){ - const f = target.xGet(fname); + const f = (fname instanceof Function) ? fname : target.xGet(fname); if(!(f instanceof Function)) toss("Exported symbol",fname,"is not a function."); - if(f.length!==args.length) __argcMismatch(fname,f.length) + if(f.length!==args.length) __argcMismatch(((f===fname) ? f.name : fname),f.length) /* This is arguably over-pedantic but we want to help clients keep from shooting themselves in the foot when calling C APIs. */; return (2===arguments.length && Array.isArray(arguments[1])) @@ -1537,7 +1541,7 @@ globalThis.WhWasmUtilInstaller = function(target){ jsFuncToWasm(). - bindScope (string): one of ('transient', 'context', - 'singleton'). Bind scopes are: + 'singleton', 'permanent'). Bind scopes are: - 'transient': it will convert JS functions to WASM only for the duration of the xWrap()'d function call, using @@ -1787,11 +1791,29 @@ globalThis.WhWasmUtilInstaller = function(target){ const __xResultAdapterCheck = (t)=>xResult.get(t) || toss("Result adapter not found:",t); + /** + Fetches the xWrap() argument adapter mapped to t, calls it, + passing in all remaining arguments, and returns the result. + Throws if t is not mapped to an argument converter. + */ cache.xWrap.convertArg = (t,...args)=>__xArgAdapterCheck(t)(...args); + /** + Identical to convertArg() except that it does not perform + an is-defined check on the mapping to t before invoking it. + */ cache.xWrap.convertArgNoCheck = (t,...args)=>xArg.get(t)(...args); + /** + Fetches the xWrap() result adapter mapped to t, calls it, passing + it v, and returns the result. Throws if t is not mapped to an + argument converter. + */ cache.xWrap.convertResult = (t,v)=>(null===t ? v : (t ? __xResultAdapterCheck(t)(v) : undefined)); + /** + Identical to convertResult() except that it does not perform an + is-defined check on the mapping to t before invoking it. + */ cache.xWrap.convertResultNoCheck = (t,v)=>(null===t ? v : (t ? xResult.get(t)(v) : undefined)); diff --git a/manifest b/manifest index 234d44e742..321eb88a47 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sTreeView\sdisplay\sof\sa\sLIMIT\sclause\son\sa\scompound\squery.\s\sDebugging\ncode\sonly\s-\snot\spart\sof\sproduction\sbuilds. -D 2024-04-26T11:32:50.631 +C Additional\sinternal\sdocs\sin\sthe\swasm\sutilities. +D 2024-04-26T18:24:23.472 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -627,7 +627,7 @@ F ext/wasm/c-pp.c 6d80d8569d85713effe8b0818a3cf51dc779e3f0bf8dc88771b8998552ee25 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f -F ext/wasm/common/whwasmutil.js 4c64594eecc7af4ae64259e95a71ba2a7edf118881aaff0bba86d0c7164e78e4 +F ext/wasm/common/whwasmutil.js fc923692f51b9a47cb6c3d0ab350db542cf6774c39d9e4ed9e894b55180d6989 F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e6df846f36209bac3e420dd80ce2bbbd87ab7a20b8063fce05f78a3c7ab6027e -R cad28780e6b446bd6e2b3d9b26a145c6 -U drh -Z 00ad49f6765aaa2802fdc1e87b94bb22 +P 38f1e5ce4eedd59fbeb0a0d676d26dfe8a3313189ab9b9e4a5a1ed6721b73a14 +R 42961bb992b575c9ac9834f429717116 +U stephan +Z e5e500cd82301a12835836646a3b6e08 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 17975a5072..8452508501 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38f1e5ce4eedd59fbeb0a0d676d26dfe8a3313189ab9b9e4a5a1ed6721b73a14 \ No newline at end of file +5a2245a9ebae6d23cd343e46b9d730f66ec4d5ffc91b83ed11a0fbd2194ad807 \ No newline at end of file From b95c1d0ac9d020a9abd51c221194e188f25b69a9 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 26 Apr 2024 18:42:50 +0000 Subject: [PATCH 0360/1030] Internal JS doc touchups. No functional changes. FossilOrigin-Name: 626b997b4e727554d7ec8b60fb37b2a94cb861a87325da4ae484bd9aa8961ca5 --- ext/wasm/common/whwasmutil.js | 18 +++++++++--------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index 65421e3fac..bbcf3d4930 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -1925,15 +1925,15 @@ globalThis.WhWasmUtilInstaller = function(target){ const C-string, encoded as UTF-8, copies it to a JS string, and returns that JS string. - - `string:dealloc` or `utf8:dealloc) (results): treats the result value - as a non-const UTF-8 C-string, ownership of which has just been - transfered to the caller. It copies the C-string to a JS - string, frees the C-string, and returns the JS string. If such - a result value is NULL, the JS result is `null`. Achtung: when - using an API which returns results from a specific allocator, - e.g. `my_malloc()`, this conversion _is not legal_. Instead, an - equivalent conversion which uses the appropriate deallocator is - required. For example: + - `string:dealloc` or `utf8:dealloc` (results): treats the result + value as a non-const UTF-8 C-string, ownership of which has + just been transfered to the caller. It copies the C-string to a + JS string, frees the C-string, and returns the JS string. If + such a result value is NULL, the JS result is `null`. Achtung: + when using an API which returns results from a specific + allocator, e.g. `my_malloc()`, this conversion _is not + legal_. Instead, an equivalent conversion which uses the + appropriate deallocator is required. For example: ```js target.xWrap.resultAdapter('string:my_free',(i)=>{ diff --git a/manifest b/manifest index 321eb88a47..bf1d462898 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\sinternal\sdocs\sin\sthe\swasm\sutilities. -D 2024-04-26T18:24:23.472 +C Internal\sJS\sdoc\stouchups.\sNo\sfunctional\schanges. +D 2024-04-26T18:42:50.715 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -627,7 +627,7 @@ F ext/wasm/c-pp.c 6d80d8569d85713effe8b0818a3cf51dc779e3f0bf8dc88771b8998552ee25 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f -F ext/wasm/common/whwasmutil.js fc923692f51b9a47cb6c3d0ab350db542cf6774c39d9e4ed9e894b55180d6989 +F ext/wasm/common/whwasmutil.js e474e0fac695abf88e5385581e26d53e5706cd268cab9d92a56eab2873c08daa F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf @@ -2185,8 +2185,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38f1e5ce4eedd59fbeb0a0d676d26dfe8a3313189ab9b9e4a5a1ed6721b73a14 -R 42961bb992b575c9ac9834f429717116 +P 5a2245a9ebae6d23cd343e46b9d730f66ec4d5ffc91b83ed11a0fbd2194ad807 +R 2adc6cf9c9a2aba61ab0a2581495ddf7 U stephan -Z e5e500cd82301a12835836646a3b6e08 +Z fc84f35cfa574620d41dff4fcae199b4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8452508501..9a6a4621eb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a2245a9ebae6d23cd343e46b9d730f66ec4d5ffc91b83ed11a0fbd2194ad807 \ No newline at end of file +626b997b4e727554d7ec8b60fb37b2a94cb861a87325da4ae484bd9aa8961ca5 \ No newline at end of file From 8d5fe073d25b8bfd632d10d4875461316806481d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 30 Apr 2024 19:34:15 +0000 Subject: [PATCH 0361/1030] Avoid 32-bit overflow when calculating ncycle for ".scanstats vm". FossilOrigin-Name: 2858efa06d4fc7b412b892f35f5e9a766b467b4a5b74d602a030d25443f9efb4 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/vdbevtab.c | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 137c5c9d3a..903dfbc746 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sissues\sin\s[/info/1e227ad9f413227f|LIMIT/OFFSET\ssupport\sfor\svirtual\stables].\nThe\sfirst\sproblem\swas\sreported\sby\n[forum:/forumpost/c243b8f856|forum\spost\sc243b8f856].\s\sThat\sreport\sprompted\nan\senhancement\sto\sthe\sgenerate_series()\s(also\sincluded\sin\sthis\smerge)\swhich\nin\sturn\sidentified\sother\ssimilar\sissues. -D 2024-04-26T19:10:15.851 +C Avoid\s32-bit\soverflow\swhen\scalculating\sncycle\sfor\s".scanstats\svm". +D 2024-04-30T19:34:15.474 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -830,7 +830,7 @@ F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe F src/vdbemem.c 385c8b89da3b5ef9a468d77a466958aa72ee1212d5cb005f23ec63df1d413054 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 -F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7 +F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 F src/vtab.c 4c475fb672a6fe57830561e614dbee21a9a24a6f616d1cfcbe85f356a09f14ad F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 @@ -2186,9 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 626b997b4e727554d7ec8b60fb37b2a94cb861a87325da4ae484bd9aa8961ca5 90e5c8226a695e838e8c1703a9b8598e654d216799e8806c4d1a1f20c28c6486 -R 2a7971e3914aa76c70593754ba02f5ed -T +closed 90e5c8226a695e838e8c1703a9b8598e654d216799e8806c4d1a1f20c28c6486 -U drh -Z e187ac779304121a02fd3106018bb12d +P 5f6c079d847e3664ec5acaf1b3e989efe0d548c211ae4a18936162b36df89065 +R 903fbc18fbeeda59fd5e86360c55f235 +U dan +Z 0ade4d9c1bbdd68ad336341e8aad91d0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 58acb63008..07075e1cbb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f6c079d847e3664ec5acaf1b3e989efe0d548c211ae4a18936162b36df89065 \ No newline at end of file +2858efa06d4fc7b412b892f35f5e9a766b467b4a5b74d602a030d25443f9efb4 \ No newline at end of file diff --git a/src/vdbevtab.c b/src/vdbevtab.c index b295dff7b6..1c9909a1aa 100644 --- a/src/vdbevtab.c +++ b/src/vdbevtab.c @@ -286,10 +286,10 @@ static int bytecodevtabColumn( #ifdef SQLITE_ENABLE_STMT_SCANSTATUS case 9: /* nexec */ - sqlite3_result_int(ctx, pOp->nExec); + sqlite3_result_int64(ctx, pOp->nExec); break; case 10: /* ncycle */ - sqlite3_result_int(ctx, pOp->nCycle); + sqlite3_result_int64(ctx, pOp->nCycle); break; #else case 9: /* nexec */ From 19ca99eea479f2f1a4290e30ded7efee4c195769 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 1 May 2024 14:42:20 +0000 Subject: [PATCH 0362/1030] Fix a problem causing the recovery extension to use excessive memory and CPU time in some cases. FossilOrigin-Name: 8de85170d53e1d2a2abe14508a222377b9493e25f3174b8f0f773427deb8df26 --- ext/recover/dbdata.c | 79 ++++++++++++++++++++++++++++++++------------ manifest | 12 +++---- manifest.uuid | 2 +- 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/ext/recover/dbdata.c b/ext/recover/dbdata.c index ca6371026e..3f3c3d71d5 100644 --- a/ext/recover/dbdata.c +++ b/ext/recover/dbdata.c @@ -88,6 +88,15 @@ typedef unsigned int u32; typedef struct DbdataTable DbdataTable; typedef struct DbdataCursor DbdataCursor; +typedef struct DbdataBuffer DbdataBuffer; + +/* +** Buffer type. +*/ +struct DbdataBuffer { + u8 *aBuf; + sqlite3_int64 nBuf; +}; /* Cursor object */ struct DbdataCursor { @@ -104,7 +113,7 @@ struct DbdataCursor { sqlite3_int64 iRowid; /* Only for the sqlite_dbdata table */ - u8 *pRec; /* Buffer containing current record */ + DbdataBuffer rec; sqlite3_int64 nRec; /* Size of pRec[] in bytes */ sqlite3_int64 nHdr; /* Size of header in bytes */ int iField; /* Current field number */ @@ -149,6 +158,31 @@ struct DbdataTable { " schema TEXT HIDDEN" \ ")" +/* +** Ensure the buffer passed as the first argument is at least nMin bytes +** in size. If an error occurs while attempting to resize the buffer, +** SQLITE_NOMEM is returned. Otherwise, SQLITE_OK. +*/ +static int dbdataBufferSize(DbdataBuffer *pBuf, sqlite3_int64 nMin){ + if( nMin>pBuf->nBuf ){ + sqlite3_int64 nNew = nMin+16384; + u8 *aNew = (u8*)sqlite3_realloc64(pBuf->aBuf, nNew); + + if( aNew==0 ) return SQLITE_NOMEM; + pBuf->aBuf = aNew; + pBuf->nBuf = nNew; + } + return SQLITE_OK; +} + +/* +** Release the allocation managed by buffer pBuf. +*/ +static void dbdataBufferFree(DbdataBuffer *pBuf){ + sqlite3_free(pBuf->aBuf); + memset(pBuf, 0, sizeof(*pBuf)); +} + /* ** Connect to an sqlite_dbdata (pAux==0) or sqlite_dbptr (pAux!=0) virtual ** table. @@ -289,8 +323,7 @@ static void dbdataResetCursor(DbdataCursor *pCsr){ pCsr->iField = 0; pCsr->bOnePage = 0; sqlite3_free(pCsr->aPage); - sqlite3_free(pCsr->pRec); - pCsr->pRec = 0; + dbdataBufferFree(&pCsr->rec); pCsr->aPage = 0; } @@ -551,7 +584,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ } }else{ /* If there is no record loaded, load it now. */ - if( pCsr->pRec==0 ){ + if( pCsr->nRec==0 ){ int bHasRowid = 0; int nPointer = 0; sqlite3_int64 nPayload = 0; @@ -595,6 +628,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ }else{ iOff += dbdataGetVarintU32(&pCsr->aPage[iOff], &nPayload); if( nPayload>0x7fffff00 ) nPayload &= 0x3fff; + if( nPayload==0 ) nPayload = 1; } /* If this is a leaf intkey cell, load the rowid */ @@ -629,13 +663,13 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ /* Allocate space for payload. And a bit more to catch small buffer ** overruns caused by attempting to read a varint or similar from ** near the end of a corrupt record. */ - pCsr->pRec = (u8*)sqlite3_malloc64(nPayload+DBDATA_PADDING_BYTES); - if( pCsr->pRec==0 ) return SQLITE_NOMEM; - memset(pCsr->pRec, 0, nPayload+DBDATA_PADDING_BYTES); + rc = dbdataBufferSize(&pCsr->rec, nPayload+DBDATA_PADDING_BYTES); + if( rc!=SQLITE_OK ) return rc; + assert( nPayload!=0 ); pCsr->nRec = nPayload; /* Load the nLocal bytes of payload */ - memcpy(pCsr->pRec, &pCsr->aPage[iOff], nLocal); + memcpy(pCsr->rec.aBuf, &pCsr->aPage[iOff], nLocal); iOff += nLocal; /* Load content from overflow pages */ @@ -653,19 +687,22 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ nCopy = U-4; if( nCopy>nRem ) nCopy = nRem; - memcpy(&pCsr->pRec[nPayload-nRem], &aOvfl[4], nCopy); + memcpy(&pCsr->rec.aBuf[nPayload-nRem], &aOvfl[4], nCopy); nRem -= nCopy; pgnoOvfl = get_uint32(aOvfl); sqlite3_free(aOvfl); } + memset(&pCsr->rec.aBuf[nPayload-nRem], 0, DBDATA_PADDING_BYTES); + }else{ + memset(&pCsr->rec.aBuf[nLocal], 0, DBDATA_PADDING_BYTES); } - iHdr = dbdataGetVarintU32(pCsr->pRec, &nHdr); + iHdr = dbdataGetVarintU32(pCsr->rec.aBuf, &nHdr); if( nHdr>nPayload ) nHdr = 0; pCsr->nHdr = nHdr; - pCsr->pHdrPtr = &pCsr->pRec[iHdr]; - pCsr->pPtr = &pCsr->pRec[pCsr->nHdr]; + pCsr->pHdrPtr = &pCsr->rec.aBuf[iHdr]; + pCsr->pPtr = &pCsr->rec.aBuf[pCsr->nHdr]; pCsr->iField = (bHasRowid ? -1 : 0); } } @@ -673,7 +710,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ pCsr->iField++; if( pCsr->iField>0 ){ sqlite3_int64 iType; - if( pCsr->pHdrPtr>=&pCsr->pRec[pCsr->nRec] + if( pCsr->pHdrPtr>=&pCsr->rec.aBuf[pCsr->nRec] || pCsr->iField>=DBDATA_MX_FIELD ){ bNextPage = 1; @@ -681,8 +718,8 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ int szField = 0; pCsr->pHdrPtr += dbdataGetVarintU32(pCsr->pHdrPtr, &iType); szField = dbdataValueBytes(iType); - if( (pCsr->nRec - (pCsr->pPtr - pCsr->pRec))pPtr = &pCsr->pRec[pCsr->nRec]; + if( (pCsr->nRec - (pCsr->pPtr - pCsr->rec.aBuf))pPtr = &pCsr->rec.aBuf[pCsr->nRec]; }else{ pCsr->pPtr += szField; } @@ -692,20 +729,18 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ if( bNextPage ){ sqlite3_free(pCsr->aPage); - sqlite3_free(pCsr->pRec); pCsr->aPage = 0; - pCsr->pRec = 0; + pCsr->nRec = 0; if( pCsr->bOnePage ) return SQLITE_OK; pCsr->iPgno++; }else{ - if( pCsr->iField<0 || pCsr->pHdrPtr<&pCsr->pRec[pCsr->nHdr] ){ + if( pCsr->iField<0 || pCsr->pHdrPtr<&pCsr->rec.aBuf[pCsr->nHdr] ){ return SQLITE_OK; } /* Advance to the next cell. The next iteration of the loop will load ** the record and so on. */ - sqlite3_free(pCsr->pRec); - pCsr->pRec = 0; + pCsr->nRec = 0; pCsr->iCell++; } } @@ -895,12 +930,12 @@ static int dbdataColumn( case DBDATA_COLUMN_VALUE: { if( pCsr->iField<0 ){ sqlite3_result_int64(ctx, pCsr->iIntkey); - }else if( &pCsr->pRec[pCsr->nRec] >= pCsr->pPtr ){ + }else if( &pCsr->rec.aBuf[pCsr->nRec] >= pCsr->pPtr ){ sqlite3_int64 iType; dbdataGetVarintU32(pCsr->pHdrPtr, &iType); dbdataValue( ctx, pCsr->enc, iType, pCsr->pPtr, - &pCsr->pRec[pCsr->nRec] - pCsr->pPtr + &pCsr->rec.aBuf[pCsr->nRec] - pCsr->pPtr ); } break; diff --git a/manifest b/manifest index 903dfbc746..dece840222 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\s32-bit\soverflow\swhen\scalculating\sncycle\sfor\s".scanstats\svm". -D 2024-04-30T19:34:15.474 +C Fix\sa\sproblem\scausing\sthe\srecovery\sextension\sto\suse\sexcessive\smemory\sand\sCPU\stime\sin\ssome\scases. +D 2024-05-01T14:42:20.390 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -478,7 +478,7 @@ F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69 F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055 -F ext/recover/dbdata.c d2e00d3cac74319c9c6def2e56ab2146b4f4ba5d820ab275e8da24e9766c247e +F ext/recover/dbdata.c bca5845064cf07b5583f4030d91906b1f147c52a80eff4adf591893d3a7c286c F ext/recover/recover1.test c484d01502239f11b61f23c1cee9f5dd19fa17617f8974e42e74d64639c524cf F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a F ext/recover/recoverbuild.test c74170e0f7b02456af41838afeb5353fdb985a48cc2331d661bbabbca7c6b8e3 @@ -2186,8 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5f6c079d847e3664ec5acaf1b3e989efe0d548c211ae4a18936162b36df89065 -R 903fbc18fbeeda59fd5e86360c55f235 +P 2858efa06d4fc7b412b892f35f5e9a766b467b4a5b74d602a030d25443f9efb4 +R 3b77a71cd99d532953a23626b8d60d55 U dan -Z 0ade4d9c1bbdd68ad336341e8aad91d0 +Z d212fc82f6805723a5e49c9577f6a006 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 07075e1cbb..041e2c89a9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2858efa06d4fc7b412b892f35f5e9a766b467b4a5b74d602a030d25443f9efb4 \ No newline at end of file +8de85170d53e1d2a2abe14508a222377b9493e25f3174b8f0f773427deb8df26 \ No newline at end of file From 2ad1e92858e36399797263a2b7f7f2951c96e4a2 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 1 May 2024 16:25:46 +0000 Subject: [PATCH 0363/1030] Fix another problem in the recovery extension where a corrupt sqlite_schema table could lead to excessive memory consumption. FossilOrigin-Name: 1c7e33a8aa0e6122b5ef606e4a7d95e8ecd9440216d4b099fe8f2a40653422be --- ext/recover/dbdata.c | 5 +- ext/recover/recovercorrupt3.test | 549 +++++++++++++++++++++++++++++++ manifest | 13 +- manifest.uuid | 2 +- 4 files changed, 559 insertions(+), 10 deletions(-) create mode 100644 ext/recover/recovercorrupt3.test diff --git a/ext/recover/dbdata.c b/ext/recover/dbdata.c index 3f3c3d71d5..b01e544885 100644 --- a/ext/recover/dbdata.c +++ b/ext/recover/dbdata.c @@ -693,10 +693,9 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ pgnoOvfl = get_uint32(aOvfl); sqlite3_free(aOvfl); } - memset(&pCsr->rec.aBuf[nPayload-nRem], 0, DBDATA_PADDING_BYTES); - }else{ - memset(&pCsr->rec.aBuf[nLocal], 0, DBDATA_PADDING_BYTES); + nPayload -= nRem; } + memset(&pCsr->rec.aBuf[nPayload], 0, DBDATA_PADDING_BYTES); iHdr = dbdataGetVarintU32(pCsr->rec.aBuf, &nHdr); if( nHdr>nPayload ) nHdr = 0; diff --git a/ext/recover/recovercorrupt3.test b/ext/recover/recovercorrupt3.test new file mode 100644 index 0000000000..9a7c2d0946 --- /dev/null +++ b/ext/recover/recovercorrupt3.test @@ -0,0 +1,549 @@ +# 2024 May 1 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +source [file join [file dirname [info script]] recover_common.tcl] +set testprefix recovercorrupt3 + +#| 0: d5 d5 9b d5 d5 d5 d5 d5 d5 d5 d5 d5 d5 d5 d5 d5 ................ +#| 16: 04 00 00 00 1d 00 00 00 00 00 00 00 5f 5f 5f 5f ............____ +#| 32: 5f 5f 5f 5f 5f 5f 5f 5f 71 5f 5f 5f 02 02 02 02 ________q___.... +#| 48: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +#| 64: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +#| 80: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +#| 96: 02 02 02 02 + +#------------------------------------------------------------------------- +reset_db +do_test 1.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +| size 3821 pagesize 1024 filename clusterfuzz-testcase-sql_recovery_fuzzer-5803962339885056 +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 02 .....@ ........ +| 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................ +| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ +| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................ +| 96: 00 2e 7a 70 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 112: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 128: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 144: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 160: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 176: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 192: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 208: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 224: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 240: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 256: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 272: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 288: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 304: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 320: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 336: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 352: 02 02 02 02 a0 02 02 02 02 02 02 02 02 02 02 02 ................ +| 368: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 384: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 400: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 416: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 432: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 448: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 29 29 ..............)) +| 464: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 480: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 496: 29 29 29 dd dd dd dd dd dd dd dd dd dd dd dd dd )))............. +| 512: dd dd dd dd dd dd dd dd dd 6e 69 d2 e9 e9 e9 d2 .........ni..... +| 528: d2 d2 d2 d2 dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 544: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 560: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 576: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 592: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 608: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 624: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 640: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 656: dd dd dd dd dd dd dd da dd dd dd dd dd dd dd dd ................ +| 672: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 688: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 704: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 720: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 736: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 752: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 768: dd dd dd dd dd dd dd dd dd dd dd dd dd 29 29 29 .............))) +| 784: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 800: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 816: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 832: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 848: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 864: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 880: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 896: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 912: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 928: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 944: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 960: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 976: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 992: 29 29 29 29 29 29 29 29 29 29 dd dd dd dd dd dd ))))))))))...... +| 1008: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| page 2 offset 1024 +| 0: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 16: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 32: dd dd 6e 69 d2 e9 e9 e9 d2 d2 d2 d2 d2 dd dd dd ..ni............ +| 48: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 64: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 80: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 96: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 112: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 128: dd dd dd dd dd dd 29 29 29 29 29 29 29 29 29 29 ......)))))))))) +| 144: 29 29 29 29 29 29 29 29 29 ad a5 29 29 29 29 00 )))))))))..)))). +| 160: 75 9c 11 00 5b e5 64 28 7c ca 09 69 28 2d 69 00 u...[.d(|..i(-i. +| 176: 85 88 6c 81 48 83 a0 93 c0 c0 82 8b 81 84 85 f9 ..l.H........... +| 192: 88 7a 00 7f 00 96 40 7b 12 4b 84 75 a0 00 99 a0 .z....@..K.u.... +| 208: df a0 7e 81 c6 90 8f 7f 84 85 cc 84 82 90 88 60 ..~............` +| 224: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 240: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 256: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 272: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 288: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 02 02 ................ +| 304: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 320: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 336: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 352: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 368: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 384: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 400: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 416: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 432: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 448: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 464: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 480: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 496: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 512: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 528: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 544: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 560: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 576: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 592: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 608: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 624: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 640: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 656: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 672: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 688: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 704: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 720: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 736: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 752: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 768: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 784: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 800: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 816: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 832: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 848: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 864: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 880: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 896: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 912: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 928: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 944: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 960: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 976: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 992: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 1008: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| page 3 offset 2048 +| 0: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 16: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 32: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 48: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 64: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 80: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 96: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 112: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 128: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 144: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 160: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 176: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 192: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 208: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 224: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 240: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 256: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 272: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 288: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 304: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 320: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 336: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 352: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 368: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 384: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 400: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 416: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 432: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 448: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 464: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 480: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 496: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 512: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 528: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 544: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 560: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 576: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 592: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 608: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 624: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 640: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 656: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 672: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 688: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 704: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 720: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 736: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 752: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 768: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 784: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 800: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 816: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 832: 02 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 848: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 864: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 880: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 896: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 912: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 928: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 944: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 960: 80 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 976: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 992: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 1008: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| page 4 offset 3072 +| 0: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 16: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 32: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 48: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 64: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 80: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 96: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 112: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 128: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 144: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 160: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 176: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 192: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 208: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 224: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 240: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 256: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 272: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 288: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 304: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 320: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 336: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 352: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 368: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 384: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 400: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 416: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 432: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 448: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 464: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 480: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 496: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 512: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 528: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 544: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 560: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 576: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 592: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 608: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 624: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 640: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 656: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 672: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 688: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 704: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 720: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 736: 5f 5f 5f 5f 5f 5f 5f 00 d5 fe fe fe 08 00 00 00 _______......... +| end clusterfuzz-testcase-sql_recovery_fuzzer-5803962339885056 +}]} {} + +sqlite3_dbdata_init db +do_execsql_test 1.1 { + PRAGMA writable_schema = 1; +} + +do_test 1.2 { + set R [sqlite3_recover_init db main test.db2] + $R run + $R finish +} {} + +#------------------------------------------------------------------------- +reset_db +do_test 2.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +| size 3821 pagesize 1024 filename clusterfuzz-testcase-sql_recovery_fuzzer-5803962339885056 +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 04 00 01 01 00 40 20 20 00 00 00 01 00 00 00 02 .....@ ........ +| 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................ +| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ +| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................ +| 96: 00 2e 7a 70 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 112: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 128: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 144: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 160: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 176: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 192: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 208: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 224: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 240: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 256: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 272: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 288: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 304: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 320: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 336: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 352: 02 02 02 02 a0 02 02 02 02 02 02 02 02 02 02 02 ................ +| 368: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 384: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 400: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 416: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 432: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 448: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 29 29 ..............)) +| 464: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 480: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 496: 29 29 29 dd dd dd dd dd dd dd dd dd dd dd dd dd )))............. +| 512: dd dd dd dd dd dd dd dd dd 6e 69 d2 e9 e9 e9 d2 .........ni..... +| 528: d2 d2 d2 d2 dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 544: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 560: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 576: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 592: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 608: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 624: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 640: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 656: dd dd dd dd dd dd dd da dd dd dd dd dd dd dd dd ................ +| 672: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 688: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 704: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 720: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 736: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 752: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 768: dd dd dd dd dd dd dd dd dd dd dd dd dd 29 29 29 .............))) +| 784: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 800: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 816: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 832: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 848: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 864: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 880: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 896: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 912: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 928: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 944: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 960: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 976: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 )))))))))))))))) +| 992: 29 29 29 29 29 29 29 29 29 29 dd dd dd dd dd dd ))))))))))...... +| 1008: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| page 2 offset 1024 +| 0: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 16: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 32: dd dd 6e 69 d2 e9 e9 e9 d2 d2 d2 d2 d2 dd dd dd ..ni............ +| 48: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 64: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 80: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 96: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 112: dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd ................ +| 128: dd dd dd dd dd dd 29 29 29 29 29 29 29 29 29 29 ......)))))))))) +| 144: 29 29 29 29 29 29 29 29 29 ad a5 29 29 29 29 00 )))))))))..)))). +| 160: 75 9c 11 00 5b e5 64 28 7c ca 09 69 28 2d 69 00 u...[.d(|..i(-i. +| 176: 85 88 6c 81 48 83 a0 93 c0 c0 82 8b 81 84 85 f9 ..l.H........... +| 192: 88 7a 00 7f 00 96 40 7b 12 4b 84 75 a0 00 99 a0 .z....@..K.u.... +| 208: df a0 7e 81 c6 90 8f 7f 84 85 cc 84 82 90 88 60 ..~............` +| 224: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 240: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 256: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 272: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 288: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 02 02 ................ +| 304: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 320: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 336: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 352: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 368: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 384: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 400: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 416: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 432: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 448: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 464: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 480: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 496: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 512: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 528: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 544: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 560: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 576: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 592: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 608: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 624: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 640: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 656: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 672: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 688: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 704: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 720: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 736: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 752: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 768: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 784: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 800: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 816: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 832: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 848: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 864: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 880: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 896: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 912: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 928: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 944: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 960: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 976: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 992: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 1008: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| page 3 offset 2048 +| 0: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 16: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 32: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 48: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 64: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 80: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 96: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 112: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 128: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 144: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 160: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 176: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 192: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 208: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 224: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 240: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 256: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 272: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 288: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 304: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 320: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 336: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 352: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 368: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 384: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 400: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 416: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 432: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 448: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 464: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 480: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 496: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 512: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 528: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 544: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 560: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 576: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 592: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 608: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 624: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 640: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 656: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 672: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 688: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 704: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 720: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 736: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 752: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 768: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 784: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 800: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 816: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 832: 02 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 848: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 864: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 880: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 896: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 912: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 928: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 944: 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ................ +| 960: 80 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 976: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 992: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 1008: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| page 4 offset 3072 +| 0: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 16: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 32: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 48: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 64: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 80: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 96: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 112: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 128: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 144: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 160: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 176: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 192: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 208: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 224: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 240: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 256: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 272: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 288: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 304: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 320: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 336: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 352: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 368: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 384: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 400: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 416: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 432: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 448: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 464: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 480: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 496: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 512: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 528: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 544: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 560: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 576: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 592: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 608: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 624: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 640: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 656: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 672: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 688: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 704: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 720: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 ................ +| 736: 5f 5f 5f 5f 5f 5f 5f 00 d5 fe fe fe 08 00 00 00 _______......... +| end clusterfuzz-testcase-sql_recovery_fuzzer-5803962339885056 +}]} {} + +sqlite3_dbdata_init db +do_execsql_test 2.1 { + PRAGMA writable_schema = 1; +} + +do_test 2.2 { + set R [sqlite3_recover_init db main test.db2] + $R run + $R finish +} {} + +finish_test + diff --git a/manifest b/manifest index dece840222..86cb7fabac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\sthe\srecovery\sextension\sto\suse\sexcessive\smemory\sand\sCPU\stime\sin\ssome\scases. -D 2024-05-01T14:42:20.390 +C Fix\sanother\sproblem\sin\sthe\srecovery\sextension\swhere\sa\scorrupt\ssqlite_schema\stable\scould\slead\sto\sexcessive\smemory\sconsumption. +D 2024-05-01T16:25:46.099 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -478,13 +478,14 @@ F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69 F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055 -F ext/recover/dbdata.c bca5845064cf07b5583f4030d91906b1f147c52a80eff4adf591893d3a7c286c +F ext/recover/dbdata.c 520636e61eddfa22fe13b0324c0e7b67b699464ff63aeaf4c26ff00b7ba0844c F ext/recover/recover1.test c484d01502239f11b61f23c1cee9f5dd19fa17617f8974e42e74d64639c524cf F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a F ext/recover/recoverbuild.test c74170e0f7b02456af41838afeb5353fdb985a48cc2331d661bbabbca7c6b8e3 F ext/recover/recoverclobber.test 3ba6c0c373c5c63d17e82eced64c05c57ccaf26c1abe1ca7141334022a79f32e F ext/recover/recovercorrupt.test 64c081ad1200ae77b447da99eb724785d6bf71715f394543dc7689642e92bf49 F ext/recover/recovercorrupt2.test 1418f1710debc24ff38276cedfcea234beb37a34205708e7e3e6d76cc4a979db +F ext/recover/recovercorrupt3.test 2e7b9a1b528ca23ed382cec6f64e3fcbbd0f8e852add7562397fd8df83f335d5 F ext/recover/recoverfault.test 9d9f88eeb222615a25e7514f234c950d46bee20d24cd8db49d8fff8d650dcfe1 F ext/recover/recoverfault2.test 730e7371bcda769554d15460cb23126abba1be8eca9539ccabf63623e7bb7e09 F ext/recover/recoverold.test 68db3d6f85dd2b98e785b6c4da4f5eea4bbe52ccf6674d9a94c7506dc92596aa @@ -2186,8 +2187,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2858efa06d4fc7b412b892f35f5e9a766b467b4a5b74d602a030d25443f9efb4 -R 3b77a71cd99d532953a23626b8d60d55 +P 8de85170d53e1d2a2abe14508a222377b9493e25f3174b8f0f773427deb8df26 +R 2e43de06901a93042cb97fda0a6a1240 U dan -Z d212fc82f6805723a5e49c9577f6a006 +Z 503087664d848ee9e213d2cb778368c0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 041e2c89a9..f2af8cbeb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8de85170d53e1d2a2abe14508a222377b9493e25f3174b8f0f773427deb8df26 \ No newline at end of file +1c7e33a8aa0e6122b5ef606e4a7d95e8ecd9440216d4b099fe8f2a40653422be \ No newline at end of file From f3ea92cceb577524c1d329aed2400127d7fd716a Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 1 May 2024 19:48:24 +0000 Subject: [PATCH 0364/1030] Avoid an OP_Next in cases where an IN(...) query against a UNIQUE index may return at most 1 row. FossilOrigin-Name: 560f64157d2fe40e107582eebb6526185c9c43305e364f4132e182dbec5b210a --- manifest | 16 +++++--- manifest.uuid | 2 +- src/wherecode.c | 25 ++++++++++- test/in7.test | 107 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 8 deletions(-) create mode 100644 test/in7.test diff --git a/manifest b/manifest index 903dfbc746..fea7669dba 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\s32-bit\soverflow\swhen\scalculating\sncycle\sfor\s".scanstats\svm". -D 2024-04-30T19:34:15.474 +C Avoid\san\sOP_Next\sin\scases\swhere\san\sIN(...)\squery\sagainst\sa\sUNIQUE\sindex\smay\sreturn\sat\smost\s1\srow. +D 2024-05-01T19:48:24.190 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -838,7 +838,7 @@ F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 0ef9638651b900d64d7e1e877af37cd7900159ff875547ec29b918a1497e5c9c F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 -F src/wherecode.c 1f6940349e92a6e056aecd70163b00f331554c815c362b4cc80906c48151d73d +F src/wherecode.c b73b5bcd0840491e8faa126fbf933e3bda0d9bf85222ddc7ff608154f0f86d1e F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1278,6 +1278,7 @@ F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test bb767ec1cfd1730256f0a83219f0acda36bc251b63f8b8bb7d8c7cff17875a4f F test/in5.test 4fd79c70dfa0681313e8cdca07f5ff0400bdc0e20f808a5c59eaef1e4b48082a F test/in6.test f5f40d6816a8bb7c784424b58a10ac38efb76ab29127a2c17399e0cbeeda0e4b +F test/in7.test e0b3bd735c13547f038f386440152ad2642a066e9f96366552763bb5455117d0 F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822 F test/incrblob2.test a494c9e848560039a23974b9119cfc2cf3ad3bd15cc2694ee6367ae537ef8f1f F test/incrblob3.test 67621a04b3084113bf38ce03797d70eca012d9d8f948193b8f655df577b0da6f @@ -2186,8 +2187,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5f6c079d847e3664ec5acaf1b3e989efe0d548c211ae4a18936162b36df89065 -R 903fbc18fbeeda59fd5e86360c55f235 +P 2858efa06d4fc7b412b892f35f5e9a766b467b4a5b74d602a030d25443f9efb4 +R 5dedafa0dd1df259fa093801bd417269 +T *branch * unique-in-opt +T *sym-unique-in-opt * +T -sym-trunk * U dan -Z 0ade4d9c1bbdd68ad336341e8aad91d0 +Z 057540a67356c4bc1a4b77adc8c49f86 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 07075e1cbb..cb59acdb7c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2858efa06d4fc7b412b892f35f5e9a766b467b4a5b74d602a030d25443f9efb4 \ No newline at end of file +560f64157d2fe40e107582eebb6526185c9c43305e364f4132e182dbec5b210a \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index d95eae2797..a895d3935b 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1337,6 +1337,27 @@ static SQLITE_NOINLINE void filterPullDown( } } +/* +** Loop pLoop is a WHERE_INDEXED level that uses at least one IN(...) +** operator. Return true if level pLoop is guaranteed to visit only one +** row for each key generated for the index. +*/ +static int whereLoopIsOneRow(WhereLoop *pLoop){ + if( pLoop->u.btree.pIndex->onError + && pLoop->nSkip==0 + && pLoop->u.btree.nEq==pLoop->u.btree.pIndex->nKeyCol + ){ + int ii; + for(ii=0; iiu.btree.nEq; ii++){ + if( pLoop->aLTerm[ii]->eOperator & (WO_IS|WO_ISNULL) ){ + return 0; + } + } + return 1; + } + return 0; +} + /* ** Generate code for the start of the iLevel-th loop in the WHERE clause ** implementation described by pWInfo. @@ -2084,7 +2105,9 @@ Bitmask sqlite3WhereCodeOneLoopStart( } /* Record the instruction used to terminate the loop. */ - if( pLoop->wsFlags & WHERE_ONEROW ){ + if( (pLoop->wsFlags & WHERE_ONEROW) + || (pLevel->u.in.nIn && whereLoopIsOneRow(pLoop)) + ){ pLevel->op = OP_Noop; }else if( bRev ){ pLevel->op = OP_Prev; diff --git a/test/in7.test b/test/in7.test new file mode 100644 index 0000000000..8917d4432f --- /dev/null +++ b/test/in7.test @@ -0,0 +1,107 @@ +# 2024-05-01 +# +# 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 +set testprefix in7 + +do_execsql_test 1.0 { + CREATE TABLE t1(a, b, c PRIMARY KEY); + CREATE TABLE t2(x, y, z); +} + +foreach {tn nNext idx sql} { + 1 1 { + CREATE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE (a, b) IN (SELECT x, y FROM t2) + } + + 2 0 { + CREATE UNIQUE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE (a, b) IN (SELECT x, y FROM t2) + } + + 3 0 { + CREATE UNIQUE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE a = ? AND b = ? + } + + 3 1 { + CREATE UNIQUE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE a = ? AND b IS ? + } + + 4 0 { + CREATE UNIQUE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE a = ? AND b IN (?, ?, ?); + } + + 5 1 { + CREATE UNIQUE INDEX i1 ON t1(a, b, c); + } { + SELECT * FROM t1 WHERE a = ? AND b = ? + } + + 6 0 { + } { + SELECT * FROM t1 WHERE c IN (SELECT z FROM t2) + } + + 7 0 { + } { + SELECT * FROM t1 WHERE (a, c) IN (SELECT z, x FROM t2) + } + + 8 1 { + } { + SELECT * FROM t1 WHERE a IN (SELECT z FROM t2) + } +} { + do_test 1.1.$tn { + execsql BEGIN + execsql $idx + + catch { array unset root_to_tbl } + catch { array unset csr_to_root } + + db eval {SELECT rootpage, tbl_name FROM sqlite_schema} { + set root_to_tbl($rootpage) $tbl_name + } + + set nSeen 0 + db eval "explain $sql" { + if {$opcode=="OpenRead"} { + set csr_to_root($p1) $p2 + } + if {$opcode=="Next"} { + catch { + set root $csr_to_root($p1) + set tbl $root_to_tbl($root) + if {$tbl=="t1"} {incr nSeen} + } + } + } + + execsql ROLLBACK + + set nSeen + } $nNext +} + + +finish_test From 2ae4531c89bbf9a3f01827e8019eddac0705765b Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 2 May 2024 11:51:26 +0000 Subject: [PATCH 0365/1030] Omit the OP_SqlExec to "PRAGMA integrity_check" added by [348fa7aaf7958b3f] because it is a no-op. Even if the integrity_check failes, the CREATE TABLE is stull successful. The OP_SqlExec just burns CPU cycles for no reason. FossilOrigin-Name: 532795acd1c800751737fe70148f9ae691e9cf11b836577f8538421d24cab2fe --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/build.c | 3 --- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 86cb7fabac..c00ad06360 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\sproblem\sin\sthe\srecovery\sextension\swhere\sa\scorrupt\ssqlite_schema\stable\scould\slead\sto\sexcessive\smemory\sconsumption. -D 2024-05-01T16:25:46.099 +C Omit\sthe\sOP_SqlExec\sto\s"PRAGMA\sintegrity_check"\sadded\sby\s[348fa7aaf7958b3f]\nbecause\sit\sis\sa\sno-op.\s\sEven\sif\sthe\sintegrity_check\sfailes,\sthe\sCREATE\sTABLE\nis\sstull\ssuccessful.\s\sThe\sOP_SqlExec\sjust\sburns\sCPU\scycles\sfor\sno\sreason. +D 2024-05-02T11:51:26.866 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -694,7 +694,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 71b80e77b255144db47180fda8138740608e382a44231942464029b1a45fc036 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 02f5b25ca854c83b5015cb02b8c9ab236c60b1795528675aee8a5070e58da52a +F src/build.c 11ec7014a3c468e7b3ccc8dda8d9111cd5a29a358df18818788601e0600aaabd F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 @@ -2187,8 +2187,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8de85170d53e1d2a2abe14508a222377b9493e25f3174b8f0f773427deb8df26 -R 2e43de06901a93042cb97fda0a6a1240 -U dan -Z 503087664d848ee9e213d2cb778368c0 +P 1c7e33a8aa0e6122b5ef606e4a7d95e8ecd9440216d4b099fe8f2a40653422be +R fa686d9a513ff74fa7b322c41469fcee +T *branch * faster-create +T *sym-faster-create * +T -sym-trunk * +U drh +Z 8e0fd4c6a3749c78cd7f96ba5b5be837 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f2af8cbeb6..ab55c07118 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c7e33a8aa0e6122b5ef606e4a7d95e8ecd9440216d4b099fe8f2a40653422be \ No newline at end of file +532795acd1c800751737fe70148f9ae691e9cf11b836577f8538421d24cab2fe \ No newline at end of file diff --git a/src/build.c b/src/build.c index 8279c0a89c..10aa342407 100644 --- a/src/build.c +++ b/src/build.c @@ -2927,9 +2927,6 @@ void sqlite3EndTable( sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"", db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); } - sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0, - sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)", - db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); } /* Add the table to the in-memory representation of the database. From 78bc1339ac9abe90927fdfcd71bf017595b80554 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 2 May 2024 11:52:31 +0000 Subject: [PATCH 0366/1030] Do not accept a string that looks like a number used as an argument to PRAGMA integrity_check as a number. Treat it as a table name that just happens to look like a number. FossilOrigin-Name: b04e7a23478f1012e501a810f3e09cca81a66e802f5f72cae80c81120174e2cb --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/pragma.c | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index c00ad06360..d7bfebc567 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sthe\sOP_SqlExec\sto\s"PRAGMA\sintegrity_check"\sadded\sby\s[348fa7aaf7958b3f]\nbecause\sit\sis\sa\sno-op.\s\sEven\sif\sthe\sintegrity_check\sfailes,\sthe\sCREATE\sTABLE\nis\sstull\ssuccessful.\s\sThe\sOP_SqlExec\sjust\sburns\sCPU\scycles\sfor\sno\sreason. -D 2024-05-02T11:51:26.866 +C Do\snot\saccept\sa\sstring\sthat\slooks\slike\sa\snumber\sused\sas\san\sargument\sto\nPRAGMA\sintegrity_check\sas\sa\snumber.\s\sTreat\sit\sas\sa\stable\sname\sthat\sjust\nhappens\sto\slook\slike\sa\snumber. +D 2024-05-02T11:52:31.688 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -745,7 +745,7 @@ F src/parse.y 5bcef16094213efcc365a9d4dc4e3131f09251dc8838dce4a9e5f9764bff5b82 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c f8f1845b42df684e9d31c5a1628c989a34939686049d7878bc5394ac1ae9cac4 +F src/pragma.c d357a25276d222adfd4637c48880409ec4539f30844b74001c6ba5c7d1a1f0f7 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 @@ -2187,11 +2187,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c7e33a8aa0e6122b5ef606e4a7d95e8ecd9440216d4b099fe8f2a40653422be -R fa686d9a513ff74fa7b322c41469fcee -T *branch * faster-create -T *sym-faster-create * -T -sym-trunk * +P 532795acd1c800751737fe70148f9ae691e9cf11b836577f8538421d24cab2fe +R ac4ea06b7b0d066e4f57370f325b3bc3 U drh -Z 8e0fd4c6a3749c78cd7f96ba5b5be837 +Z fc28259a0336795cd85fcb803ce7457a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ab55c07118..ac399de21c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -532795acd1c800751737fe70148f9ae691e9cf11b836577f8538421d24cab2fe \ No newline at end of file +b04e7a23478f1012e501a810f3e09cca81a66e802f5f72cae80c81120174e2cb \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 8af18cbf20..80864da79f 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1703,7 +1703,7 @@ void sqlite3Pragma( /* Set the maximum error count */ mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; if( zRight ){ - if( sqlite3GetInt32(zRight, &mxErr) ){ + if( sqlite3GetInt32(pValue->z, &mxErr) ){ if( mxErr<=0 ){ mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; } From 9b4e7898d754bc533be38908825d62a526bd6e75 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 2 May 2024 12:00:36 +0000 Subject: [PATCH 0367/1030] Add a test case to the fix to PRAGMA integrity_check in the previous check-in. FossilOrigin-Name: 39a57b596d309d9e2d4c59409fe5d36e0665781ce0307d157ff8b6e883161bbb --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/pragma.test | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index d7bfebc567..0582d49a23 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\saccept\sa\sstring\sthat\slooks\slike\sa\snumber\sused\sas\san\sargument\sto\nPRAGMA\sintegrity_check\sas\sa\snumber.\s\sTreat\sit\sas\sa\stable\sname\sthat\sjust\nhappens\sto\slook\slike\sa\snumber. -D 2024-05-02T11:52:31.688 +C Add\sa\stest\scase\sto\sthe\sfix\sto\sPRAGMA\sintegrity_check\sin\sthe\sprevious\scheck-in. +D 2024-05-02T12:00:36.739 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1501,7 +1501,7 @@ F test/pendingrace.test 6aa33756b950c4529f79c4f3817a9a1e4025bd0d9961571a05c0279b F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff F test/permutations.test 405542f1d659942994a6b38a9e024cf5cfd23eaa68c806aeb24a72d7c9186e80 F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f -F test/pragma.test 8bb6d3992c1c31ff6d5553d1e0693d642f7e19015648c6ae7034cb497d26bbd4 +F test/pragma.test 11cb9310c42f921918f7f563e3c0b6e70f9f9c3a6a1cf12af8fccb6c574f3882 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 F test/pragma4.test 22834a228e59b80f5c15b519b710474859d91535002670ddb7cd13ac44b54e9a @@ -2187,8 +2187,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 532795acd1c800751737fe70148f9ae691e9cf11b836577f8538421d24cab2fe -R ac4ea06b7b0d066e4f57370f325b3bc3 +P b04e7a23478f1012e501a810f3e09cca81a66e802f5f72cae80c81120174e2cb +R 0ac28bb5468fe4b54198e9b7f938f439 U drh -Z fc28259a0336795cd85fcb803ce7457a +Z 39f04eb486031705b188423b1deb4083 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ac399de21c..37970c7581 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b04e7a23478f1012e501a810f3e09cca81a66e802f5f72cae80c81120174e2cb \ No newline at end of file +39a57b596d309d9e2d4c59409fe5d36e0665781ce0307d157ff8b6e883161bbb \ No newline at end of file diff --git a/test/pragma.test b/test/pragma.test index 048dee8386..e823a67630 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -387,6 +387,9 @@ ifcapable attach { PRAGMA integrity_check=4 } } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}} + do_catchsql_test pragma-3.5.2 { + PRAGMA integrity_check='4' + } {1 {no such table: 4}} do_catchsql_test pragma-3.6 { PRAGMA integrity_check=xyz } {1 {no such table: xyz}} From 01508c814ccf21be880bfab14776a1015283e82a Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 2 May 2024 17:46:52 +0000 Subject: [PATCH 0368/1030] Fix a case where the recovery extension might write uninitialized data to the recovered database. FossilOrigin-Name: 8519b4d0393ed17eed06bceffbc891fe8cae0bc1d466a79eba0602ef46b07c56 --- ext/recover/dbdata.c | 2 +- manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/recover/dbdata.c b/ext/recover/dbdata.c index b01e544885..1905e68813 100644 --- a/ext/recover/dbdata.c +++ b/ext/recover/dbdata.c @@ -666,7 +666,6 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ rc = dbdataBufferSize(&pCsr->rec, nPayload+DBDATA_PADDING_BYTES); if( rc!=SQLITE_OK ) return rc; assert( nPayload!=0 ); - pCsr->nRec = nPayload; /* Load the nLocal bytes of payload */ memcpy(pCsr->rec.aBuf, &pCsr->aPage[iOff], nLocal); @@ -696,6 +695,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ nPayload -= nRem; } memset(&pCsr->rec.aBuf[nPayload], 0, DBDATA_PADDING_BYTES); + pCsr->nRec = nPayload; iHdr = dbdataGetVarintU32(pCsr->rec.aBuf, &nHdr); if( nHdr>nPayload ) nHdr = 0; diff --git a/manifest b/manifest index 7d77c4e1d2..d003fac95f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\san\sOP_Next\sin\scases\swhere\san\sIN(...)\squery\sagainst\sa\sUNIQUE\sindex\smay\sreturn\sat\smost\s1\srow. -D 2024-05-02T14:48:58.295 +C Fix\sa\scase\swhere\sthe\srecovery\sextension\smight\swrite\suninitialized\sdata\sto\sthe\srecovered\sdatabase. +D 2024-05-02T17:46:52.967 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -478,7 +478,7 @@ F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69 F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055 -F ext/recover/dbdata.c 520636e61eddfa22fe13b0324c0e7b67b699464ff63aeaf4c26ff00b7ba0844c +F ext/recover/dbdata.c e518c1a221a259a1ea594d9db8fce356861bfa450e6f54eda999242b9bd5c50a F ext/recover/recover1.test c484d01502239f11b61f23c1cee9f5dd19fa17617f8974e42e74d64639c524cf F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a F ext/recover/recoverbuild.test c74170e0f7b02456af41838afeb5353fdb985a48cc2331d661bbabbca7c6b8e3 @@ -2188,9 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 71f08b912251c8a3ac1bd8e344903336648e4187f7493f8c126e60b3b51b9f09 560f64157d2fe40e107582eebb6526185c9c43305e364f4132e182dbec5b210a -R 86283dd1f6bad0a3523b1ba3ad89b434 -T +closed 560f64157d2fe40e107582eebb6526185c9c43305e364f4132e182dbec5b210a +P d7648e21605a0b381b1935a47e5a77bdfacc4cc96f03d6bb7956f8f4e6a40648 +R 91204a904de412874c1ad0642f190840 U dan -Z 136e857f8914132ecc08f9fc952c59a7 +Z c29162d93ac6c523dea45672137e5762 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d6d09be1f3..1fad912567 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d7648e21605a0b381b1935a47e5a77bdfacc4cc96f03d6bb7956f8f4e6a40648 \ No newline at end of file +8519b4d0393ed17eed06bceffbc891fe8cae0bc1d466a79eba0602ef46b07c56 \ No newline at end of file From 72814933b9f072685788e49c6df409ba3f16668e Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 2 May 2024 18:16:23 +0000 Subject: [PATCH 0369/1030] Avoid an assert failure accessible only when internal testing features are enabled. dbsqlfuzz crash-66abacda6bca6bd531e25595e8c8068e2c710326.txt. FossilOrigin-Name: fbc446daac761dd1b66a85c9b61e1d5af194a8fd665600c43a874da38cc6ec10 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 3 ++- test/returning1.test | 11 +++++++++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d003fac95f..f3c1c280fd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scase\swhere\sthe\srecovery\sextension\smight\swrite\suninitialized\sdata\sto\sthe\srecovered\sdatabase. -D 2024-05-02T17:46:52.967 +C Avoid\san\sassert\sfailure\saccessible\sonly\swhen\sinternal\stesting\sfeatures\sare\senabled.\sdbsqlfuzz\scrash-66abacda6bca6bd531e25595e8c8068e2c710326.txt. +D 2024-05-02T18:16:23.502 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -750,7 +750,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 647edf93729ba124c0a6048982af56c2fa4f841e69d626e4f3caa620f082bb15 +F src/resolve.c 8816212645e4e9bdf3cc2f2d298304f388d699f8fab47f3a5712ef5bbc5b6ccc F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 04178566d0188be7de471064ced8cec1d407920726cb49b609486282d78faf56 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 @@ -1533,7 +1533,7 @@ F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed13 F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d F test/resetdb.test 54c06f18bc832ac6d6319e5ab23d5c8dd49fdbeec7c696d791682a8006bd5fc3 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb -F test/returning1.test 2ebfe6e56f3de9b194295620f46a747c26cebdab937defb9afd84b96dd202ccb +F test/returning1.test 38eee9d07ac1dd4fbd4ce7373497f3783db86b9a76f13ea6a9f9afaf934f888b F test/returningfault.test ae4c4b5e8745813287a359d9ccdb9d5c883c2e68afb18fb0767937d5de5692a4 F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa F test/rollback2.test 3f3a4e20401825017df7e7671e9f31b6de5fae5620c2b9b49917f52f8c160a8f @@ -2188,8 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d7648e21605a0b381b1935a47e5a77bdfacc4cc96f03d6bb7956f8f4e6a40648 -R 91204a904de412874c1ad0642f190840 +P 8519b4d0393ed17eed06bceffbc891fe8cae0bc1d466a79eba0602ef46b07c56 +R 0a3b026a0a16d38bbb74d5089bed24b2 U dan -Z c29162d93ac6c523dea45672137e5762 +Z ae138bbd9a4a27c1543b292e5b8d0d96 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1fad912567..9a2c0a20d2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8519b4d0393ed17eed06bceffbc891fe8cae0bc1d466a79eba0602ef46b07c56 \ No newline at end of file +fbc446daac761dd1b66a85c9b61e1d5af194a8fd665600c43a874da38cc6ec10 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 6a1d82606a..898c78654c 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -528,7 +528,8 @@ static int lookupName( if( pParse->bReturning ){ if( (pNC->ncFlags & NC_UBaseReg)!=0 && ALWAYS(zTab==0 - || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0) + || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0 + || isValidSchemaTableName(zTab, pParse->pTriggerTab, 0)) ){ pExpr->iTable = op!=TK_DELETE; pTab = pParse->pTriggerTab; diff --git a/test/returning1.test b/test/returning1.test index 8a2001de93..05bd445a2f 100644 --- a/test/returning1.test +++ b/test/returning1.test @@ -520,4 +520,15 @@ do_execsql_test 20.3 { 8 N N N } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 21.0 { + PRAGMA writable_schema=ON; + INSERT INTO sqlite_schema DEFAULT VALUES RETURNING sqlite_schema.name; +} {{}} + +do_execsql_test 21.1 { + INSERT INTO sqlite_temp_schema DEFAULT VALUES RETURNING sqlite_temp_schema.name; +} {{}} + finish_test From 9c0d777a9f4a84f09b6145b74184a38a3abd7db0 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 2 May 2024 19:22:23 +0000 Subject: [PATCH 0370/1030] Fix a problem with queries that use "IN(...) ORDER BY ... NULLS LAST" or similar introduced by [d7648e21605a0b38]. FossilOrigin-Name: 26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/wherecode.c | 2 +- test/in7.test | 13 +++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f3c1c280fd..a0040a7b29 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\san\sassert\sfailure\saccessible\sonly\swhen\sinternal\stesting\sfeatures\sare\senabled.\sdbsqlfuzz\scrash-66abacda6bca6bd531e25595e8c8068e2c710326.txt. -D 2024-05-02T18:16:23.502 +C Fix\sa\sproblem\swith\squeries\sthat\suse\s"IN(...)\sORDER\sBY\s...\sNULLS\sLAST"\sor\ssimilar\sintroduced\sby\s[d7648e21605a0b38]. +D 2024-05-02T19:22:23.368 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -839,7 +839,7 @@ F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 0ef9638651b900d64d7e1e877af37cd7900159ff875547ec29b918a1497e5c9c F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 -F src/wherecode.c b73b5bcd0840491e8faa126fbf933e3bda0d9bf85222ddc7ff608154f0f86d1e +F src/wherecode.c b9908c0a1aab095822a1e7032556bedc03b6d29641191e9ca535fb2307cd733d F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1279,7 +1279,7 @@ F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test bb767ec1cfd1730256f0a83219f0acda36bc251b63f8b8bb7d8c7cff17875a4f F test/in5.test 4fd79c70dfa0681313e8cdca07f5ff0400bdc0e20f808a5c59eaef1e4b48082a F test/in6.test f5f40d6816a8bb7c784424b58a10ac38efb76ab29127a2c17399e0cbeeda0e4b -F test/in7.test e0b3bd735c13547f038f386440152ad2642a066e9f96366552763bb5455117d0 +F test/in7.test b3a87d5e4f608ac9787e707fc4f8f2a0d89359489d109fdcac01470c3a6832f4 F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822 F test/incrblob2.test a494c9e848560039a23974b9119cfc2cf3ad3bd15cc2694ee6367ae537ef8f1f F test/incrblob3.test 67621a04b3084113bf38ce03797d70eca012d9d8f948193b8f655df577b0da6f @@ -2188,8 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8519b4d0393ed17eed06bceffbc891fe8cae0bc1d466a79eba0602ef46b07c56 -R 0a3b026a0a16d38bbb74d5089bed24b2 +P fbc446daac761dd1b66a85c9b61e1d5af194a8fd665600c43a874da38cc6ec10 +R 36f998b45a8aa5d9ecb00ca50d9b4f7d U dan -Z ae138bbd9a4a27c1543b292e5b8d0d96 +Z b095a9ec23cb25cb4e9e06b89cd38b3b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9a2c0a20d2..91bc583d15 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fbc446daac761dd1b66a85c9b61e1d5af194a8fd665600c43a874da38cc6ec10 \ No newline at end of file +26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index a895d3935b..4aca6eb624 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -2106,7 +2106,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( /* Record the instruction used to terminate the loop. */ if( (pLoop->wsFlags & WHERE_ONEROW) - || (pLevel->u.in.nIn && whereLoopIsOneRow(pLoop)) + || (pLevel->u.in.nIn && regBignull==0 && whereLoopIsOneRow(pLoop)) ){ pLevel->op = OP_Noop; }else if( bRev ){ diff --git a/test/in7.test b/test/in7.test index 8917d4432f..cf17933a39 100644 --- a/test/in7.test +++ b/test/in7.test @@ -103,5 +103,18 @@ foreach {tn nNext idx sql} { } $nNext } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 { + CREATE TABLE t1(a TEXT PRIMARY KEY, b TEXT) WITHOUT ROWID; + INSERT INTO t1 VALUES('1', 'one'); + INSERT INTO t1 VALUES('2', NULL); + INSERT INTO t1 VALUES('3', 'three'); +} + +do_execsql_test 2.1 { + SELECT b FROM t1 WHERE a IN (1,2,3) ORDER BY b ASC NULLS LAST; +} {one three {}} + finish_test From 0901571f0a66a2528c3fc6986b44d7a0323e36a1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 3 May 2024 19:35:43 +0000 Subject: [PATCH 0371/1030] The coalesce(), ifnull(), and iif() functions pass through subtype values from their arguments, and hence need to have the SQLITE_RESULT_SUBTYPE flag set. This fixes an corner-case for the patch at [ba789a7804ab96d8]. FossilOrigin-Name: cdd1610c44876623e629bb8e5779ea689e6d23c545552b088eca63ad2d1cf8da --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/func.c | 6 +++--- test/indexexpr1.test | 28 ++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index a0040a7b29..1ed79f3c89 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\squeries\sthat\suse\s"IN(...)\sORDER\sBY\s...\sNULLS\sLAST"\sor\ssimilar\sintroduced\sby\s[d7648e21605a0b38]. -D 2024-05-02T19:22:23.368 +C The\scoalesce(),\sifnull(),\sand\siif()\sfunctions\spass\sthrough\ssubtype\svalues\nfrom\stheir\sarguments,\sand\shence\sneed\sto\shave\sthe\sSQLITE_RESULT_SUBTYPE\sflag\nset.\s\sThis\sfixes\san\scorner-case\sfor\sthe\spatch\sat\s[ba789a7804ab96d8]. +D 2024-05-03T19:35:43.156 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c 005bf7a088a2fb12a50752a2a1d40d423b8942e1920e93c3a1ba76da0bfbe52b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 -F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f +F src/func.c ac6e03e7f39feced49681a1a67c50a82b43e8573dd7a9278ca4ff291317f2b0d F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -1302,7 +1302,7 @@ F test/index8.test caa097735c91dbc23d8a402f5e63a2a03c83840ba3928733ed7f9a03f8a91 F test/index9.test 2ac891806a4136ef3e91280477e23114e67575207dc331e6797fa0ed9379f997 F test/indexA.test 11d84f6995e6e5b9d8315953fb1b6d29772ee7c7803ee9112715e7e4dd3e4974 F test/indexedby.test f21eca4f7a6ffe14c8500a7ad6cd53166666c99e5ccd311842a28bc94a195fe0 -F test/indexexpr1.test 833f511213a5e26549186813f0566bd72f978177a7e6e98a2d2dd695de3c670d +F test/indexexpr1.test 870ffcf3911ef447e7714d49c4504a92580410ecb0d6d76499493f9a5591efb1 F test/indexexpr2.test 1c382e81ef996d8ae8b834a74f2a9013dddf59214c32201d7c8a656d739f999a F test/indexfault.test 98d78a8ff1f5335628b62f886a1cb7c7dac1ef6d48fa39c51ec871c87dce9811 F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -2188,8 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fbc446daac761dd1b66a85c9b61e1d5af194a8fd665600c43a874da38cc6ec10 -R 36f998b45a8aa5d9ecb00ca50d9b4f7d -U dan -Z b095a9ec23cb25cb4e9e06b89cd38b3b +P 26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e +R 0268c566eccde5bd7b524cfab1a24524 +U drh +Z ad416147806e454b3211249b5d00a37b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 91bc583d15..b99a890c23 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e \ No newline at end of file +cdd1610c44876623e629bb8e5779ea689e6d23c545552b088eca63ad2d1cf8da \ No newline at end of file diff --git a/src/func.c b/src/func.c index 18004984d9..472efa2110 100644 --- a/src/func.c +++ b/src/func.c @@ -2643,7 +2643,7 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ), FUNCTION(concat_ws, 0, 0, 0, 0 ), FUNCTION(concat_ws, 1, 0, 0, 0 ), - INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), + INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, SQLITE_RESULT_SUBTYPE), VFUNCTION(random, 0, 0, 0, randomFunc ), VFUNCTION(randomblob, 1, 0, 0, randomBlob ), FUNCTION(nullif, 2, 0, 1, nullifFunc ), @@ -2725,8 +2725,8 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(pi, 0, 0, 0, piFunc ), #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ FUNCTION(sign, 1, 0, 0, signFunc ), - INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ), - INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ), + INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, SQLITE_RESULT_SUBTYPE), + INLINE_FUNC(iif, 3, INLINEFUNC_iif, SQLITE_RESULT_SUBTYPE), }; #ifndef SQLITE_OMIT_ALTERTABLE sqlite3AlterFunctions(); diff --git a/test/indexexpr1.test b/test/indexexpr1.test index 0316ee9d42..e6b3fb6333 100644 --- a/test/indexexpr1.test +++ b/test/indexexpr1.test @@ -615,6 +615,34 @@ do_execsql_test indexexpr1-2200 { GROUP BY t2.type, t1.tag ) v ON v.type = 0 AND v.tag = u.tag; } {7 100 8 101} +do_execsql_test indexexpr1-2210 { + DROP TABLE t1; + CREATE TABLE t1(x INT, y TEXT); + INSERT INTO t1(x,y) VALUES(1,'{b:5}'); + SELECT json_insert('{}', '$.a', coalesce(null,json(y)))->>'$.a.b' FROM t1; +} {5} +db null NULL +do_execsql_test indexexpr1-2211 { + CREATE INDEX t1j ON t1(coalesce(null,json(y))); + SELECT json_insert('{}', '$.a', coalesce(null,json(y)))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2220 { + DROP INDEX t1j; + SELECT json_insert('{}', '$.a', iif(1,json(y),123))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2221 { + CREATE INDEX t1j ON t1(iif(1,json(y),123)); + SELECT json_insert('{}', '$.a', iif(1,json(y),123))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2230 { + DROP INDEX t1j; + SELECT json_insert('{}', '$.a', ifnull(NULL,json(y)))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2231 { + CREATE INDEX t1j ON t1(ifnull(NULL,json(y))); + SELECT json_insert('{}', '$.a', ifnull(NULL,json(y)))->>'$.a.b' FROM t1; +} {5} + # 2023-11-08 Forum post https://sqlite.org/forum/forumpost/68d284c86b082c3e # From 5b9b7cba227ee0ec1532416637623103bbe43086 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 4 May 2024 11:31:34 +0000 Subject: [PATCH 0372/1030] Functions that pass through the sqlite3_value of one of their arguments must also be marked as SQLITE_RESULT_SUBTYPE, in case one of their arguments has a subtype. FossilOrigin-Name: 2f9fba931d9f80b3d5dffb175180098756bccc6a8f665d7aaf8826970ab60d72 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 7 ++++--- test/indexexpr1.test | 24 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 1ed79f3c89..95c66ec418 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\scoalesce(),\sifnull(),\sand\siif()\sfunctions\spass\sthrough\ssubtype\svalues\nfrom\stheir\sarguments,\sand\shence\sneed\sto\shave\sthe\sSQLITE_RESULT_SUBTYPE\sflag\nset.\s\sThis\sfixes\san\scorner-case\sfor\sthe\spatch\sat\s[ba789a7804ab96d8]. -D 2024-05-03T19:35:43.156 +C Functions\sthat\spass\sthrough\sthe\ssqlite3_value\sof\sone\sof\stheir\sarguments\smust\nalso\sbe\smarked\sas\sSQLITE_RESULT_SUBTYPE,\sin\scase\sone\sof\stheir\sarguments\shas\na\ssubtype. +D 2024-05-04T11:31:34.734 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c 005bf7a088a2fb12a50752a2a1d40d423b8942e1920e93c3a1ba76da0bfbe52b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 -F src/func.c ac6e03e7f39feced49681a1a67c50a82b43e8573dd7a9278ca4ff291317f2b0d +F src/func.c ee81e2fd91b93da5cee11f2abc1a197d32f037e00a8084d003a47e49b17a6c21 F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -1302,7 +1302,7 @@ F test/index8.test caa097735c91dbc23d8a402f5e63a2a03c83840ba3928733ed7f9a03f8a91 F test/index9.test 2ac891806a4136ef3e91280477e23114e67575207dc331e6797fa0ed9379f997 F test/indexA.test 11d84f6995e6e5b9d8315953fb1b6d29772ee7c7803ee9112715e7e4dd3e4974 F test/indexedby.test f21eca4f7a6ffe14c8500a7ad6cd53166666c99e5ccd311842a28bc94a195fe0 -F test/indexexpr1.test 870ffcf3911ef447e7714d49c4504a92580410ecb0d6d76499493f9a5591efb1 +F test/indexexpr1.test 24fa85a12da384dd1d56f7b24e593c51a8a54b4c5e2e8bbb9e5fdf1099427faf F test/indexexpr2.test 1c382e81ef996d8ae8b834a74f2a9013dddf59214c32201d7c8a656d739f999a F test/indexfault.test 98d78a8ff1f5335628b62f886a1cb7c7dac1ef6d48fa39c51ec871c87dce9811 F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -2188,8 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e -R 0268c566eccde5bd7b524cfab1a24524 +P cdd1610c44876623e629bb8e5779ea689e6d23c545552b088eca63ad2d1cf8da +R 33e55f0c34c1768cb20638651312a57f U drh -Z ad416147806e454b3211249b5d00a37b +Z 72ec691afb693a210c0cb7b3a98963ca # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b99a890c23..34db1cbfb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cdd1610c44876623e629bb8e5779ea689e6d23c545552b088eca63ad2d1cf8da \ No newline at end of file +2f9fba931d9f80b3d5dffb175180098756bccc6a8f665d7aaf8826970ab60d72 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 472efa2110..3c98ba96f5 100644 --- a/src/func.c +++ b/src/func.c @@ -984,6 +984,7 @@ static void nullifFunc( UNUSED_PARAMETER(NotUsed); if( sqlite3MemCompare(argv[0], argv[1], pColl)!=0 ){ sqlite3_result_value(context, argv[0]); + sqlite3_result_subtype(context, sqlite3_value_subtype(argv[0])); } } @@ -2608,11 +2609,11 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(rtrim, 2, 2, 0, trimFunc ), FUNCTION(trim, 1, 3, 0, trimFunc ), FUNCTION(trim, 2, 3, 0, trimFunc ), - FUNCTION(min, -1, 0, 1, minmaxFunc ), + FUNCTION2(min, -1, 0, 1, minmaxFunc, SQLITE_RESULT_SUBTYPE), FUNCTION(min, 0, 0, 1, 0 ), WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), - FUNCTION(max, -1, 1, 1, minmaxFunc ), + FUNCTION2(max, -1, 1, 1, minmaxFunc, SQLITE_RESULT_SUBTYPE), FUNCTION(max, 0, 1, 1, 0 ), WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), @@ -2646,7 +2647,7 @@ void sqlite3RegisterBuiltinFunctions(void){ INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, SQLITE_RESULT_SUBTYPE), VFUNCTION(random, 0, 0, 0, randomFunc ), VFUNCTION(randomblob, 1, 0, 0, randomBlob ), - FUNCTION(nullif, 2, 0, 1, nullifFunc ), + FUNCTION2(nullif, 2, 0, 1, nullifFunc, SQLITE_RESULT_SUBTYPE), DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ), DFUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), FUNCTION(sqlite_log, 2, 0, 0, errlogFunc ), diff --git a/test/indexexpr1.test b/test/indexexpr1.test index e6b3fb6333..3ba59449d5 100644 --- a/test/indexexpr1.test +++ b/test/indexexpr1.test @@ -642,6 +642,30 @@ do_execsql_test indexexpr1-2231 { CREATE INDEX t1j ON t1(ifnull(NULL,json(y))); SELECT json_insert('{}', '$.a', ifnull(NULL,json(y)))->>'$.a.b' FROM t1; } {5} +do_execsql_test indexexpr1-2240 { + DROP INDEX t1j; + SELECT json_insert('{}', '$.a', nullif(json(y),8))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2241 { + CREATE INDEX t1j ON t1(nullif(json(y),8)); + SELECT json_insert('{}', '$.a', nullif(json(y),8))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2250 { + DROP INDEX t1j; + SELECT json_insert('{}', '$.a', min('~',json(y)))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2251 { + CREATE INDEX t1j ON t1(min('~',json(y))); + SELECT json_insert('{}', '$.a', min('~',json(y)))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2260 { + DROP INDEX t1j; + SELECT json_insert('{}', '$.a', max('...',json(y)))->>'$.a.b' FROM t1; +} {5} +do_execsql_test indexexpr1-2261 { + CREATE INDEX t1j ON t1(max('...',json(y))); + SELECT json_insert('{}', '$.a', max('...',json(y)))->>'$.a.b' FROM t1; +} {5} # 2023-11-08 Forum post https://sqlite.org/forum/forumpost/68d284c86b082c3e From 2eb9adb564ee209e2f0ad38718d621ace1c55c72 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 4 May 2024 15:04:45 +0000 Subject: [PATCH 0373/1030] Assume that a function is able to return a subtype if either (1) it is itself marked with SQLITE_RESULT_SUBTYPE, or (2) one of its arguments is a function that is able to return a subtype. This check-in backs out the code changes from the previous two on this same branch, but keeps the test cases from the previous two. FossilOrigin-Name: f16b200f25a0ec59ad765d254d81c3ffdba21f79e6e82807a7b80d00627952e2 --- manifest | 14 +++++------ manifest.uuid | 2 +- src/func.c | 13 +++++------ src/where.c | 64 +++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 95c66ec418..0f9a114b45 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Functions\sthat\spass\sthrough\sthe\ssqlite3_value\sof\sone\sof\stheir\sarguments\smust\nalso\sbe\smarked\sas\sSQLITE_RESULT_SUBTYPE,\sin\scase\sone\sof\stheir\sarguments\shas\na\ssubtype. -D 2024-05-04T11:31:34.734 +C Assume\sthat\sa\sfunction\sis\sable\sto\sreturn\sa\ssubtype\sif\seither\s(1)\sit\sis\sitself\nmarked\swith\sSQLITE_RESULT_SUBTYPE,\sor\s(2)\sone\sof\sits\sarguments\sis\sa\sfunction\nthat\sis\sable\sto\sreturn\sa\ssubtype.\s\sThis\scheck-in\sbacks\sout\sthe\scode\schanges\nfrom\sthe\sprevious\stwo\son\sthis\ssame\sbranch,\sbut\skeeps\sthe\stest\scases\sfrom\nthe\sprevious\stwo. +D 2024-05-04T15:04:45.707 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c 005bf7a088a2fb12a50752a2a1d40d423b8942e1920e93c3a1ba76da0bfbe52b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 -F src/func.c ee81e2fd91b93da5cee11f2abc1a197d32f037e00a8084d003a47e49b17a6c21 +F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -837,7 +837,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 0ef9638651b900d64d7e1e877af37cd7900159ff875547ec29b918a1497e5c9c +F src/where.c d235ba520b0147f60732b3bd411e119b43be33d348251edaa6e304a8ad52c511 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c b9908c0a1aab095822a1e7032556bedc03b6d29641191e9ca535fb2307cd733d F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2188,8 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cdd1610c44876623e629bb8e5779ea689e6d23c545552b088eca63ad2d1cf8da -R 33e55f0c34c1768cb20638651312a57f +P 2f9fba931d9f80b3d5dffb175180098756bccc6a8f665d7aaf8826970ab60d72 +R 14886039188c50fb101aa25afbe73592 U drh -Z 72ec691afb693a210c0cb7b3a98963ca +Z 80e41ac2288666eefe08d1c7b25daa7c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 34db1cbfb6..6c653e5a23 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f9fba931d9f80b3d5dffb175180098756bccc6a8f665d7aaf8826970ab60d72 \ No newline at end of file +f16b200f25a0ec59ad765d254d81c3ffdba21f79e6e82807a7b80d00627952e2 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 3c98ba96f5..18004984d9 100644 --- a/src/func.c +++ b/src/func.c @@ -984,7 +984,6 @@ static void nullifFunc( UNUSED_PARAMETER(NotUsed); if( sqlite3MemCompare(argv[0], argv[1], pColl)!=0 ){ sqlite3_result_value(context, argv[0]); - sqlite3_result_subtype(context, sqlite3_value_subtype(argv[0])); } } @@ -2609,11 +2608,11 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(rtrim, 2, 2, 0, trimFunc ), FUNCTION(trim, 1, 3, 0, trimFunc ), FUNCTION(trim, 2, 3, 0, trimFunc ), - FUNCTION2(min, -1, 0, 1, minmaxFunc, SQLITE_RESULT_SUBTYPE), + FUNCTION(min, -1, 0, 1, minmaxFunc ), FUNCTION(min, 0, 0, 1, 0 ), WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), - FUNCTION2(max, -1, 1, 1, minmaxFunc, SQLITE_RESULT_SUBTYPE), + FUNCTION(max, -1, 1, 1, minmaxFunc ), FUNCTION(max, 0, 1, 1, 0 ), WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), @@ -2644,10 +2643,10 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ), FUNCTION(concat_ws, 0, 0, 0, 0 ), FUNCTION(concat_ws, 1, 0, 0, 0 ), - INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, SQLITE_RESULT_SUBTYPE), + INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), VFUNCTION(random, 0, 0, 0, randomFunc ), VFUNCTION(randomblob, 1, 0, 0, randomBlob ), - FUNCTION2(nullif, 2, 0, 1, nullifFunc, SQLITE_RESULT_SUBTYPE), + FUNCTION(nullif, 2, 0, 1, nullifFunc ), DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ), DFUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), FUNCTION(sqlite_log, 2, 0, 0, errlogFunc ), @@ -2726,8 +2725,8 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(pi, 0, 0, 0, piFunc ), #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ FUNCTION(sign, 1, 0, 0, signFunc ), - INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, SQLITE_RESULT_SUBTYPE), - INLINE_FUNC(iif, 3, INLINEFUNC_iif, SQLITE_RESULT_SUBTYPE), + INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ), + INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ), }; #ifndef SQLITE_OMIT_ALTERTABLE sqlite3AlterFunctions(); diff --git a/src/where.c b/src/where.c index 820e922490..13a362dcca 100644 --- a/src/where.c +++ b/src/where.c @@ -5989,6 +5989,58 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful( } } +/* +** Expression Node callback for sqlite3ExprCanReturnSubtype(). +** +** Only a function call is able to return a subtype. So if the node +** is not a function call, return WRC_Prune immediately. +** +** A function call is able to return a subtype if it has the +** SQLITE_RESULT_SUBTYPE property. +** +** Assume that every function is able to pass-through a subtype from +** one of its argument (using sqlite3_result_value()). Most functions +** are not this way, but we don't have a mechanism to distinguish those +** that are from those that are not, so assume they all work this way. +** That means that if one of its arguments is another function and that +** other function is able to return a subtype, then this function is +** able to return a subtype. +*/ +static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){ + int n; + FuncDef *pDef; + sqlite3 *db; + if( pExpr->op!=TK_FUNCTION ){ + return WRC_Prune; + } + assert( ExprUseXList(pExpr) ); + db = pWalker->pParse->db; + n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; + pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); + if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ + pWalker->eCode = 1; + return WRC_Prune; + } + return WRC_Continue; +} + +/* +** Return TRUE if expression pExpr is able to return a subtype. +** +** A TRUE return does not guarantee that a subtype will be returned. +** It only indicates that a subtype return is possible. False positives +** are acceptable as they only disable an optimization. False negatives, +** on the other hand, can lead to incorrect answers. +*/ +static int sqlite3ExprCanReturnSubtype(Parse *pParse, Expr *pExpr){ + Walker w; + memset(&w, 0, sizeof(w)); + w.pParse = pParse; + w.xExprCallback = exprNodeCanReturnSubtype; + sqlite3WalkExpr(&w, pExpr); + return w.eCode; +} + /* ** The index pIdx is used by a query and contains one or more expressions. ** In other words pIdx is an index on an expression. iIdxCur is the cursor @@ -6022,19 +6074,11 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( continue; } if( sqlite3ExprIsConstant(0,pExpr) ) continue; - if( pExpr->op==TK_FUNCTION ){ + if( pExpr->op==TK_FUNCTION && sqlite3ExprCanReturnSubtype(pParse,pExpr) ){ /* Functions that might set a subtype should not be replaced by the ** value taken from an expression index since the index omits the ** subtype. https://sqlite.org/forum/forumpost/68d284c86b082c3e */ - int n; - FuncDef *pDef; - sqlite3 *db = pParse->db; - assert( ExprUseXList(pExpr) ); - n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; - pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); - if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ - continue; - } + continue; } p = sqlite3DbMallocRaw(pParse->db, sizeof(IndexedExpr)); if( p==0 ) break; From c52c00f67095b4ca7c21b2215e607c5119cecb24 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 4 May 2024 16:50:47 +0000 Subject: [PATCH 0374/1030] Add test cases to test/in7.test. No code changes. FossilOrigin-Name: 8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- test/in7.test | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index edb0851ed9..6d144c0637 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Assume\sthat\san\sSQL\sfunction\sis\sable\sto\sreturn\sa\ssubtype\sif\sany\sof\sits\narguments\sare\sSQL\sfunctions\sthat\sare\sable\sto\sreturn\ssubtypes.\s\sThis\scloses\na\scorner-case\shole\sin\sthe\spatch\sat\s[ba789a7804ab96d8]. -D 2024-05-04T15:10:37.959 +C Add\stest\scases\sto\stest/in7.test.\sNo\scode\schanges. +D 2024-05-04T16:50:47.770 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1279,7 +1279,7 @@ F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test bb767ec1cfd1730256f0a83219f0acda36bc251b63f8b8bb7d8c7cff17875a4f F test/in5.test 4fd79c70dfa0681313e8cdca07f5ff0400bdc0e20f808a5c59eaef1e4b48082a F test/in6.test f5f40d6816a8bb7c784424b58a10ac38efb76ab29127a2c17399e0cbeeda0e4b -F test/in7.test b3a87d5e4f608ac9787e707fc4f8f2a0d89359489d109fdcac01470c3a6832f4 +F test/in7.test 742b18c284cd9a9cd1347d3a8affeee44b8de11e875e91a1d40498c18ba16441 F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822 F test/incrblob2.test a494c9e848560039a23974b9119cfc2cf3ad3bd15cc2694ee6367ae537ef8f1f F test/incrblob3.test 67621a04b3084113bf38ce03797d70eca012d9d8f948193b8f655df577b0da6f @@ -2188,9 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e f16b200f25a0ec59ad765d254d81c3ffdba21f79e6e82807a7b80d00627952e2 -R 14886039188c50fb101aa25afbe73592 -T +closed f16b200f25a0ec59ad765d254d81c3ffdba21f79e6e82807a7b80d00627952e2 -U drh -Z 1c69cc89e2338f86c36480d46824bedd +P b36d499e4cdb41a5d7e44a1c4347a059d7654f85ade9c5c04d18ac95ddc09fde +R 960c98e5734bcdd93c02bad4a02cdc67 +U dan +Z a883d658d4cc670b0c73f4c6321f0eb9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 114badcf32..2b94ecb6ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b36d499e4cdb41a5d7e44a1c4347a059d7654f85ade9c5c04d18ac95ddc09fde \ No newline at end of file +8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50 \ No newline at end of file diff --git a/test/in7.test b/test/in7.test index cf17933a39..099f75c5f7 100644 --- a/test/in7.test +++ b/test/in7.test @@ -71,6 +71,27 @@ foreach {tn nNext idx sql} { } { SELECT * FROM t1 WHERE a IN (SELECT z FROM t2) } + + 9 1 { + CREATE UNIQUE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE a IN (SELECT z FROM t2) AND b IS ? + } + 10 0 { + CREATE UNIQUE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE a IN (SELECT z FROM t2) AND b = ? + } + 11 1 { + CREATE UNIQUE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE a IS NULL AND b IN (SELECT z FROM t2) + } + 12 0 { + CREATE UNIQUE INDEX i1 ON t1(a, b); + } { + SELECT * FROM t1 WHERE a = ? AND b IN (SELECT z FROM t2) + } } { do_test 1.1.$tn { execsql BEGIN From 5b80dbe6b37fd246d6b29df6182d726655057dc1 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 4 May 2024 21:10:24 +0000 Subject: [PATCH 0375/1030] Add new sessions API sqlite3changegroup_add_change(). FossilOrigin-Name: 73647db1ddfdaf40cbf18f1e47c10b4a906489f6d34d7667f0f2ff532f1eb37c --- ext/session/sqlite3session.c | 251 +++++++++++++++++++++-------------- ext/session/sqlite3session.h | 19 +++ ext/session/test_session.c | 66 +++++++++ manifest | 19 +-- manifest.uuid | 2 +- 5 files changed, 252 insertions(+), 105 deletions(-) diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index acb945194d..e6081a6ce0 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -3685,14 +3685,14 @@ static int sessionChangesetNextOne( p->rc = sessionInputBuffer(&p->in, 2); if( p->rc!=SQLITE_OK ) return p->rc; + sessionDiscardData(&p->in); + p->in.iCurrent = p->in.iNext; + /* If the iterator is already at the end of the changeset, return DONE. */ if( p->in.iNext>=p->in.nData ){ return SQLITE_DONE; } - sessionDiscardData(&p->in); - p->in.iCurrent = p->in.iNext; - op = p->in.aData[p->in.iNext++]; while( op=='T' || op=='P' ){ if( pbNew ) *pbNew = 1; @@ -5427,6 +5427,7 @@ struct sqlite3_changegroup { int rc; /* Error code */ int bPatch; /* True to accumulate patchsets */ SessionTable *pList; /* List of tables in current patch */ + SessionBuffer rec; sqlite3 *db; /* Configured by changegroup_schema() */ char *zDb; /* Configured by changegroup_schema() */ @@ -5725,108 +5726,128 @@ static int sessionChangesetExtendRecord( } /* -** Add all changes in the changeset traversed by the iterator passed as -** the first argument to the changegroup hash tables. +** Locate or create a SessionTable object that may be used to add the +** change currently pointed to by iterator pIter to changegroup pGrp. +** If successful, set output variable (*ppTab) to point to the table +** object and return SQLITE_OK. Otherwise, if some error occurs, return +** an SQLite error code and leave (*ppTab) set to NULL. */ -static int sessionChangesetToHash( - sqlite3_changeset_iter *pIter, /* Iterator to read from */ - sqlite3_changegroup *pGrp, /* Changegroup object to add changeset to */ - int bRebase /* True if hash table is for rebasing */ +static int sessionChangesetFindTable( + sqlite3_changegroup *pGrp, + const char *zTab, + sqlite3_changeset_iter *pIter, + SessionTable **ppTab ){ - u8 *aRec; - int nRec; int rc = SQLITE_OK; SessionTable *pTab = 0; - SessionBuffer rec = {0, 0, 0}; + int nTab = (int)strlen(zTab); + u8 *abPK = 0; + int nCol = 0; - while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ - const char *zNew; - int nCol; - int op; - int iHash; - int bIndirect; - SessionChange *pChange; - SessionChange *pExist = 0; - SessionChange **pp; - - /* Ensure that only changesets, or only patchsets, but not a mixture - ** of both, are being combined. It is an error to try to combine a - ** changeset and a patchset. */ - if( pGrp->pList==0 ){ - pGrp->bPatch = pIter->bPatchset; - }else if( pIter->bPatchset!=pGrp->bPatch ){ - rc = SQLITE_ERROR; - break; - } + *ppTab = 0; + sqlite3changeset_pk(pIter, &abPK, &nCol); - sqlite3changeset_op(pIter, &zNew, &nCol, &op, &bIndirect); - if( !pTab || sqlite3_stricmp(zNew, pTab->zName) ){ - /* Search the list for a matching table */ - int nNew = (int)strlen(zNew); - u8 *abPK; + /* Search the list for an existing table */ + for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){ + if( 0==sqlite3_strnicmp(pTab->zName, zTab, nTab+1) ) break; + } - sqlite3changeset_pk(pIter, &abPK, 0); - for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){ - if( 0==sqlite3_strnicmp(pTab->zName, zNew, nNew+1) ) break; + /* If one was not found above, create a new table now */ + if( !pTab ){ + SessionTable **ppNew; + + pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nTab+1); + if( !pTab ){ + return SQLITE_NOMEM; + } + memset(pTab, 0, sizeof(SessionTable)); + pTab->nCol = nCol; + pTab->abPK = (u8*)&pTab[1]; + memcpy(pTab->abPK, abPK, nCol); + pTab->zName = (char*)&pTab->abPK[nCol]; + memcpy(pTab->zName, zTab, nTab+1); + + if( pGrp->db ){ + pTab->nCol = 0; + rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb); + if( rc ){ + assert( pTab->azCol==0 ); + sqlite3_free(pTab); + return rc; } - if( !pTab ){ - SessionTable **ppTab; + } - pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nNew+1); - if( !pTab ){ - rc = SQLITE_NOMEM; - break; - } - memset(pTab, 0, sizeof(SessionTable)); - pTab->nCol = nCol; - pTab->abPK = (u8*)&pTab[1]; - memcpy(pTab->abPK, abPK, nCol); - pTab->zName = (char*)&pTab->abPK[nCol]; - memcpy(pTab->zName, zNew, nNew+1); - - if( pGrp->db ){ - pTab->nCol = 0; - rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb); - if( rc ){ - assert( pTab->azCol==0 ); - sqlite3_free(pTab); - break; - } - } + /* The new object must be linked on to the end of the list, not + ** simply added to the start of it. This is to ensure that the + ** tables within the output of sqlite3changegroup_output() are in + ** the right order. */ + for(ppNew=&pGrp->pList; *ppNew; ppNew=&(*ppNew)->pNext); + *ppNew = pTab; + } - /* The new object must be linked on to the end of the list, not - ** simply added to the start of it. This is to ensure that the - ** tables within the output of sqlite3changegroup_output() are in - ** the right order. */ - for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); - *ppTab = pTab; - } + /* Check that the table is compatible. */ + if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){ + rc = SQLITE_SCHEMA; + } - if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){ - rc = SQLITE_SCHEMA; - break; - } - } + *ppTab = pTab; + return rc; +} - if( nColnCol ){ - assert( pGrp->db ); - rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, &rec); - if( rc ) break; - aRec = rec.aBuf; - nRec = rec.nBuf; - } +/* +** Add the change currently indicated by iterator pIter to the hash table +** belonging to changegroup pGrp. +*/ +static int sessionOneChangeToHash( + sqlite3_changegroup *pGrp, + sqlite3_changeset_iter *pIter, + int bRebase +){ + int rc = SQLITE_OK; + int nCol = 0; + int op = 0; + int iHash = 0; + int bIndirect = 0; + SessionChange *pChange = 0; + SessionChange *pExist = 0; + SessionChange **pp = 0; + SessionTable *pTab = 0; + u8 *aRec = &pIter->in.aData[pIter->in.iCurrent + 2]; + int nRec = (pIter->in.iNext - pIter->in.iCurrent) - 2; - if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ - rc = SQLITE_NOMEM; - break; - } + /* Ensure that only changesets, or only patchsets, but not a mixture + ** of both, are being combined. It is an error to try to combine a + ** changeset and a patchset. */ + if( pGrp->pList==0 ){ + pGrp->bPatch = pIter->bPatchset; + }else if( pIter->bPatchset!=pGrp->bPatch ){ + rc = SQLITE_ERROR; + } + + if( rc==SQLITE_OK ){ + const char *zTab = 0; + sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect); + rc = sessionChangesetFindTable(pGrp, zTab, pIter, &pTab); + } + + if( rc==SQLITE_OK && nColnCol ){ + SessionBuffer *pBuf = &pGrp->rec; + rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, pBuf); + aRec = pBuf->aBuf; + nRec = pBuf->nBuf; + assert( pGrp->db ); + } + + if( rc==SQLITE_OK && sessionGrowHash(0, pIter->bPatchset, pTab) ){ + rc = SQLITE_NOMEM; + } + + if( rc==SQLITE_OK ){ + /* Search for existing entry. If found, remove it from the hash table. + ** Code below may link it back in. */ iHash = sessionChangeHash( pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange ); - - /* Search for existing entry. If found, remove it from the hash table. - ** Code below may link it back in. - */ for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){ int bPkOnly1 = 0; int bPkOnly2 = 0; @@ -5841,19 +5862,41 @@ static int sessionChangesetToHash( break; } } + } + if( rc==SQLITE_OK ){ rc = sessionChangeMerge(pTab, bRebase, pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange ); - if( rc ) break; - if( pChange ){ - pChange->pNext = pTab->apChange[iHash]; - pTab->apChange[iHash] = pChange; - pTab->nEntry++; - } + } + if( rc==SQLITE_OK && pChange ){ + pChange->pNext = pTab->apChange[iHash]; + pTab->apChange[iHash] = pChange; + pTab->nEntry++; + } + + if( rc==SQLITE_OK ) rc = pIter->rc; + return rc; +} + +/* +** Add all changes in the changeset traversed by the iterator passed as +** the first argument to the changegroup hash tables. +*/ +static int sessionChangesetToHash( + sqlite3_changeset_iter *pIter, /* Iterator to read from */ + sqlite3_changegroup *pGrp, /* Changegroup object to add changeset to */ + int bRebase /* True if hash table is for rebasing */ +){ + u8 *aRec; + int nRec; + int rc = SQLITE_OK; + + while( SQLITE_ROW==(sessionChangesetNext(pIter, &aRec, &nRec, 0)) ){ + rc = sessionOneChangeToHash(pGrp, pIter, bRebase); + if( rc!=SQLITE_OK ) break; } - sqlite3_free(rec.aBuf); if( rc==SQLITE_OK ) rc = pIter->rc; return rc; } @@ -5981,6 +6024,20 @@ int sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void *pData){ return rc; } +/* +** Add a single change to a changeset-group. +*/ +int sqlite3changegroup_add_change( + sqlite3_changegroup *pGrp, + sqlite3_changeset_iter *pIter +){ + if( pIter->in.iCurrent==pIter->in.iNext || pIter->rc!=SQLITE_OK ){ + /* Iterator does not point to any valid entry. */ + return SQLITE_ERROR; + } + return sessionChangesetToHash(pIter, pGrp, 0); +} + /* ** Obtain a buffer containing a changeset representing the concatenation ** of all changesets added to the group so far. @@ -6030,6 +6087,7 @@ void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ if( pGrp ){ sqlite3_free(pGrp->zDb); sessionDeleteTable(0, pGrp->pList); + sqlite3_free(pGrp->rec.aBuf); sqlite3_free(pGrp); } } @@ -6431,6 +6489,7 @@ int sqlite3rebaser_rebase_strm( void sqlite3rebaser_delete(sqlite3_rebaser *p){ if( p ){ sessionDeleteTable(0, p->grp.pList); + sqlite3_free(p->grp.rec.aBuf); sqlite3_free(p); } } diff --git a/ext/session/sqlite3session.h b/ext/session/sqlite3session.h index 160ea8786b..69c8ee588c 100644 --- a/ext/session/sqlite3session.h +++ b/ext/session/sqlite3session.h @@ -1057,6 +1057,25 @@ int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); */ int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); +/* +** CAPI3REF: Add A Single Change To A Changegroup +** METHOD: sqlite3_changegroup +** +** This function adds the single change currently indicated by the iterator +** passed as the second argument to the changegroup object. The rules for +** adding the change are just as described for [sqlite3_changegroup_add()]. +** +** The iterator must point to a valid entry when this function is called. +** If it does not, SQLITE_ERROR is returned and no change is added to the +** changegroup. +*/ +int sqlite3changegroup_add_change( + sqlite3_changegroup*, + sqlite3_changeset_iter* +); + + + /* ** CAPI3REF: Obtain A Composite Changeset From A Changegroup ** METHOD: sqlite3_changegroup diff --git a/ext/session/test_session.c b/ext/session/test_session.c index af42351ba7..f6db38c8a2 100644 --- a/ext/session/test_session.c +++ b/ext/session/test_session.c @@ -1585,6 +1585,71 @@ static int SQLITE_TCLAPI test_sqlite3changegroup( return TCL_OK; } +typedef struct TestChangeIter TestChangeIter; +struct TestChangeIter { + sqlite3_changeset_iter *pIter; +}; + +static int SQLITE_TCLAPI test_iter_cmd( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + return TCL_OK; +} + +/* +** Tclcmd: sqlite3changeset_start ?-invert? CHANGESET +*/ +static int SQLITE_TCLAPI test_sqlite3changeset_start( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + int isInvert = 0; + void *pChangeset = 0; /* Buffer containing changeset */ + int nChangeset = 0; /* Size of buffer aChangeset in bytes */ + TestChangeIter *pNew = 0; + sqlite3_changeset_iter *pIter = 0; + int flags = 0; + int rc = SQLITE_OK; + + static int iCmd = 1; + char zCmd[64]; + + if( objc==3 ){ + int n = 0; + const char *z = Tcl_GetStringFromObj(objv[1], &n); + isInvert = (n>=2 && sqlite3_strnicmp(z, "-invert", n)==0); + } + + if( objc!=2 && (objc!=3 || !isInvert) ){ + Tcl_WrongNumArgs(interp, 1, objv, "?-invert? CHANGESET"); + return TCL_ERROR; + } + + flags = isInvert ? SQLITE_CHANGESETSTART_INVERT : 0; + pChangeset = (void *)Tcl_GetByteArrayFromObj(objv[objc-1], &nChangeset); + rc = sqlite3changeset_start_v2(&pIter, nChangeset, pChangeset, flags); + if( rc!=SQLITE_OK ){ + char *zErr = sqlite3_mprintf( + "error in sqlite3changeset_start_v2() - %d", rc + ); + Tcl_AppendResult(interp, zErr, (char*)0); + return TCL_ERROR; + } + + pNew = (TestChangeIter*)ckalloc(sizeof(TestChangeIter)); + pNew->pIter = pIter; + + sprintf(zCmd, "csiter%d", iCmd++); + Tcl_CreateObjCommand(interp, zCmd, test_iter_cmd, (void*)pNew, 0); + Tcl_SetObjResult(interp, Tcl_NewStringObj(zCmd, -1)); + return TCL_OK; +} + int TestSession_Init(Tcl_Interp *interp){ struct Cmd { const char *zCmd; @@ -1592,6 +1657,7 @@ int TestSession_Init(Tcl_Interp *interp){ } aCmd[] = { { "sqlite3session", test_sqlite3session }, { "sqlite3changegroup", test_sqlite3changegroup }, + { "sqlite3changeset_start", test_sqlite3changeset_start }, { "sqlite3session_foreach", test_sqlite3session_foreach }, { "sqlite3changeset_invert", test_sqlite3changeset_invert }, { "sqlite3changeset_concat", test_sqlite3changeset_concat }, diff --git a/manifest b/manifest index 6d144c0637..e95fd9eb1b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sto\stest/in7.test.\sNo\scode\schanges. -D 2024-05-04T16:50:47.770 +C Add\snew\ssessions\sAPI\ssqlite3changegroup_add_change(). +D 2024-05-04T21:10:24.120 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -582,9 +582,9 @@ F ext/session/sessionrowid.test 85187c2f1b38861a5844868126f69f9ec62223a03449a98a F ext/session/sessionsize.test 8fcf4685993c3dbaa46a24183940ab9f5aa9ed0d23e5fb63bfffbdb56134b795 F ext/session/sessionstat1.test 5e718d5888c0c49bbb33a7a4f816366db85f59f6a4f97544a806421b85dc2dec F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009ecef8511f4cf3fc -F ext/session/sqlite3session.c 829d468f0f3d2710aace56b0116a7ca3f414683ce78e3125ae5e21547a895078 -F ext/session/sqlite3session.h 4cf19a51975746d7cff2fdd74db8b769c570958e1c3639ac150d824ac1553b3e -F ext/session/test_session.c 7b94ad945cd4afe6c73ee935aeb3d44b4446186e1729362af616c7695a5283d9 +F ext/session/sqlite3session.c 0cdf052460fe11fd00a5c3f83b4a7152ed6c72ff7dacd4664c30ce16579748d7 +F ext/session/sqlite3session.h e36392d1087e42f4e691caff23cb99f4e9fc3b8b88ac7504dac3ea30883dc08b +F ext/session/test_session.c ba40d22840f3ed667448e34ab4eaa38e69f62f23af530c0f8f70a64ed92b039b F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb @@ -2188,8 +2188,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b36d499e4cdb41a5d7e44a1c4347a059d7654f85ade9c5c04d18ac95ddc09fde -R 960c98e5734bcdd93c02bad4a02cdc67 +P 8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50 +R 92b682ff0cdf49829f0c1fddda225a0c +T *branch * changegroup-add-change +T *sym-changegroup-add-change * +T -sym-trunk * U dan -Z a883d658d4cc670b0c73f4c6321f0eb9 +Z d18fc76401ae213ec8fe7cdec8b2f0ce # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2b94ecb6ca..6e66176619 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50 \ No newline at end of file +73647db1ddfdaf40cbf18f1e47c10b4a906489f6d34d7667f0f2ff532f1eb37c \ No newline at end of file From 1aa94b58213bb39fc7252e04ba867c766460871c Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 5 May 2024 10:00:02 +0000 Subject: [PATCH 0376/1030] Add comment to the test/lemon-test01.y file indicating that it does not work and is for historical reference only. FossilOrigin-Name: 9bdf73a8d4a3b4a72f2882252f9ed29a6f1a26d3f50c071f27455bcf10458c4b --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/lemon-test01.y | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6d144c0637..9cd03f667f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sto\stest/in7.test.\sNo\scode\schanges. -D 2024-05-04T16:50:47.770 +C Add\scomment\sto\sthe\stest/lemon-test01.y\sfile\sindicating\sthat\sit\sdoes\snot\swork\nand\sis\sfor\shistorical\sreference\sonly. +D 2024-05-05T10:00:02.569 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1369,7 +1369,7 @@ F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff F test/kvtest.c 6e0228409ea7ca0497dad503fbd109badb5e59545d131014b6aaac68b56f484a F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 -F test/lemon-test01.y 58b764610fd934e189ffbb0bbfa33d171b9cb06019b55bdc04d090d6767e11d7 +F test/lemon-test01.y f6280e3787ff9ab57b12527e814c205e1ba1f25fc7458dd6986e2d3351eee320 F test/like.test 242ee7f5d08a031144c0daf63bbd7e7710c847ccf387a83347e0b61b3aa69526 F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3d3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c @@ -2188,8 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b36d499e4cdb41a5d7e44a1c4347a059d7654f85ade9c5c04d18ac95ddc09fde -R 960c98e5734bcdd93c02bad4a02cdc67 -U dan -Z a883d658d4cc670b0c73f4c6321f0eb9 +P 8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50 +R efcb64168ddc99770223ec8b44cbaf4e +U drh +Z 71bad1f699deb7358af8858b2f47ba10 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2b94ecb6ca..066dbed864 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50 \ No newline at end of file +9bdf73a8d4a3b4a72f2882252f9ed29a6f1a26d3f50c071f27455bcf10458c4b \ No newline at end of file diff --git a/test/lemon-test01.y b/test/lemon-test01.y index 0fd514ff3a..929b00b62c 100644 --- a/test/lemon-test01.y +++ b/test/lemon-test01.y @@ -2,6 +2,11 @@ // // lemon lemon-test01.y && gcc -g lemon-test01.c && ./a.out // +// This testcase was made obsolete by check-in 7cca80808cef192f on +// 2021-08-17 (associated with Forum Thread +// https://sqlite.org/forum/forumpost/bd91fd965c9803c4) and no longer +// works. It is retained for historical reference only. +// %token_prefix TK_ %token_type int %default_type int From 1002bcff43697e6facff465d36d36ca822a8c5a1 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 6 May 2024 11:27:47 +0000 Subject: [PATCH 0377/1030] Fix problem in sqlar_uncompress() when being used to extract symbolic links. FossilOrigin-Name: 4d90c3f179a3d7355b6b0202faf56f0be4be56986920576e528208cb84daa4af --- ext/misc/sqlar.c | 7 ++++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ext/misc/sqlar.c b/ext/misc/sqlar.c index be079a546a..9f726f0b89 100644 --- a/ext/misc/sqlar.c +++ b/ext/misc/sqlar.c @@ -81,7 +81,7 @@ static void sqlarUncompressFunc( sqlite3_value **argv ){ uLong nData; - uLongf sz; + sqlite3_int64 sz; assert( argc==2 ); sz = sqlite3_value_int(argv[1]); @@ -89,14 +89,15 @@ static void sqlarUncompressFunc( if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){ sqlite3_result_value(context, argv[0]); }else{ + uLongf szf = sz; const Bytef *pData= sqlite3_value_blob(argv[0]); Bytef *pOut = sqlite3_malloc(sz); if( pOut==0 ){ sqlite3_result_error_nomem(context); - }else if( Z_OK!=uncompress(pOut, &sz, pData, nData) ){ + }else if( Z_OK!=uncompress(pOut, &szf, pData, nData) ){ sqlite3_result_error(context, "error in uncompress()", -1); }else{ - sqlite3_result_blob(context, pOut, sz, SQLITE_TRANSIENT); + sqlite3_result_blob(context, pOut, szf, SQLITE_TRANSIENT); } sqlite3_free(pOut); } diff --git a/manifest b/manifest index 9cd03f667f..1c056496d9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\scomment\sto\sthe\stest/lemon-test01.y\sfile\sindicating\sthat\sit\sdoes\snot\swork\nand\sis\sfor\shistorical\sreference\sonly. -D 2024-05-05T10:00:02.569 +C Fix\sproblem\sin\ssqlar_uncompress()\swhen\sbeing\sused\sto\sextract\ssymbolic\slinks. +D 2024-05-06T11:27:47.649 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -416,7 +416,7 @@ F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f0 F ext/misc/shathree.c 543af7ce71d391cd3a9ab6924a6a1124efc63211fd0f2e240dc4b56077ba88ac F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c c0aa7b80d6df45f7da59d912b38752bcac1af53a5766966160e6c5cdd397dbea -F ext/misc/sqlar.c 53e7d48f68d699a24f1a92e68e71eca8b3a9ff991fe9588c2a05bde103c6e7b7 +F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 F ext/misc/templatevtab.c 10f15b165b95423ddef593bc5dcb915ec4eb5e0f1066d585e5435a368b8bc22b F ext/misc/totype.c 75ed9827d19cc3b434fc2aeb60725d4d46e1534373615612a4d1cfdcc3d60922 @@ -2188,8 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50 -R efcb64168ddc99770223ec8b44cbaf4e -U drh -Z 71bad1f699deb7358af8858b2f47ba10 +P 9bdf73a8d4a3b4a72f2882252f9ed29a6f1a26d3f50c071f27455bcf10458c4b +R c4e317266c51f659c5ce93f052688c23 +U dan +Z d759657d9ef1cadf5eb299f7ac2ab3b0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 066dbed864..3cdac355c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9bdf73a8d4a3b4a72f2882252f9ed29a6f1a26d3f50c071f27455bcf10458c4b \ No newline at end of file +4d90c3f179a3d7355b6b0202faf56f0be4be56986920576e528208cb84daa4af \ No newline at end of file From 0f78aafec82d913c4d9b8337d77aad5b952df7b4 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 6 May 2024 17:21:23 +0000 Subject: [PATCH 0378/1030] Add tests for sqlite3changegroup_add_change(). FossilOrigin-Name: 9d67bedc20c3a59e5488f0eaea6a6611940a9cb63f7cf5e687b061cb5d510943 --- ext/session/sqlite3session.c | 9 +- ext/session/sqlite3session.h | 4 +- ext/session/test_session.c | 200 +++++++++++++++++++++++------------ manifest | 19 ++-- manifest.uuid | 2 +- 5 files changed, 152 insertions(+), 82 deletions(-) diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index e6081a6ce0..7a8132bfa6 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -6031,11 +6031,14 @@ int sqlite3changegroup_add_change( sqlite3_changegroup *pGrp, sqlite3_changeset_iter *pIter ){ - if( pIter->in.iCurrent==pIter->in.iNext || pIter->rc!=SQLITE_OK ){ - /* Iterator does not point to any valid entry. */ + if( pIter->in.iCurrent==pIter->in.iNext + || pIter->rc!=SQLITE_OK + || pIter->bInvert + ){ + /* Iterator does not point to any valid entry or is an INVERT iterator. */ return SQLITE_ERROR; } - return sessionChangesetToHash(pIter, pGrp, 0); + return sessionOneChangeToHash(pGrp, pIter, 0); } /* diff --git a/ext/session/sqlite3session.h b/ext/session/sqlite3session.h index 69c8ee588c..ebd2cc5312 100644 --- a/ext/session/sqlite3session.h +++ b/ext/session/sqlite3session.h @@ -1067,7 +1067,9 @@ int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); ** ** The iterator must point to a valid entry when this function is called. ** If it does not, SQLITE_ERROR is returned and no change is added to the -** changegroup. +** changegroup. Additionally, the iterator must not have been opened with +** the SQLITE_CHANGESETAPPLY_INVERT flag. In this case SQLITE_ERROR is also +** returned. */ int sqlite3changegroup_add_change( sqlite3_changegroup*, diff --git a/ext/session/test_session.c b/ext/session/test_session.c index f6db38c8a2..00c3c25068 100644 --- a/ext/session/test_session.c +++ b/ext/session/test_session.c @@ -1038,6 +1038,64 @@ static int SQLITE_TCLAPI test_sqlite3changeset_concat( return rc; } +static Tcl_Obj *testIterData(sqlite3_changeset_iter *pIter){ + Tcl_Obj *pVar = 0; + int nCol; /* Number of columns in table */ + int nCol2; /* Number of columns in table */ + int op; /* SQLITE_INSERT, UPDATE or DELETE */ + const char *zTab; /* Name of table change applies to */ + Tcl_Obj *pOld; /* Vector of old.* values */ + Tcl_Obj *pNew; /* Vector of new.* values */ + int bIndirect; + + char *zPK; + unsigned char *abPK; + int i; + + sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect); + pVar = Tcl_NewObj(); + + Tcl_ListObjAppendElement(0, pVar, Tcl_NewStringObj( + op==SQLITE_INSERT ? "INSERT" : + op==SQLITE_UPDATE ? "UPDATE" : + "DELETE", -1 + )); + + Tcl_ListObjAppendElement(0, pVar, Tcl_NewStringObj(zTab, -1)); + Tcl_ListObjAppendElement(0, pVar, Tcl_NewBooleanObj(bIndirect)); + + zPK = ckalloc(nCol+1); + memset(zPK, 0, nCol+1); + sqlite3changeset_pk(pIter, &abPK, &nCol2); + assert( nCol==nCol2 ); + for(i=0; ipGrp, pIter->pIter); + if( rc!=SQLITE_OK ){ + rc = test_session_error(interp, rc, 0); + } + break; + }; + default: { /* delete */ assert( iSub==3 ); Tcl_DeleteCommand(interp, Tcl_GetString(objv[0])); @@ -1585,10 +1609,16 @@ static int SQLITE_TCLAPI test_sqlite3changegroup( return TCL_OK; } -typedef struct TestChangeIter TestChangeIter; -struct TestChangeIter { - sqlite3_changeset_iter *pIter; -}; +extern const char *sqlite3ErrName(int); + +/* +** Destructor for Tcl iterator command object. +*/ +static void test_iter_del(void *clientData){ + TestChangeIter *p = (TestChangeIter*)clientData; + sqlite3changeset_finalize(p->pIter); + ckfree(p); +} static int SQLITE_TCLAPI test_iter_cmd( void * clientData, @@ -1596,6 +1626,44 @@ static int SQLITE_TCLAPI test_iter_cmd( int objc, Tcl_Obj *CONST objv[] ){ + static const char *aSub[] = { + "next", /* 0 */ + "data", /* 1 */ + "finalize", /* 2 */ + 0 + }; + int iSub = 0; + + TestChangeIter *p = (TestChangeIter*)clientData; + int rc = SQLITE_OK; + + if( objc<2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "CMD"); + return TCL_ERROR; + } + + if( Tcl_GetIndexFromObj(interp, objv[1], aSub, "sub-command", 0, &iSub) ){ + return TCL_ERROR; + } + switch( iSub ){ + case 0: + rc = sqlite3changeset_next(p->pIter); + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); + break; + case 1: + Tcl_SetObjResult(interp, testIterData(p->pIter)); + break; + case 2: + rc = sqlite3changeset_finalize(p->pIter); + p->pIter = 0; + Tcl_DeleteCommand(interp, Tcl_GetString(objv[0])); + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); + break; + default: + assert( 0 ); + break; + } + return TCL_OK; } @@ -1645,7 +1713,7 @@ static int SQLITE_TCLAPI test_sqlite3changeset_start( pNew->pIter = pIter; sprintf(zCmd, "csiter%d", iCmd++); - Tcl_CreateObjCommand(interp, zCmd, test_iter_cmd, (void*)pNew, 0); + Tcl_CreateObjCommand(interp, zCmd, test_iter_cmd, (void*)pNew, test_iter_del); Tcl_SetObjResult(interp, Tcl_NewStringObj(zCmd, -1)); return TCL_OK; } diff --git a/manifest b/manifest index e95fd9eb1b..d8069fa67e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\ssessions\sAPI\ssqlite3changegroup_add_change(). -D 2024-05-04T21:10:24.120 +C Add\stests\sfor\ssqlite3changegroup_add_change(). +D 2024-05-06T17:21:23.939 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -582,9 +582,9 @@ F ext/session/sessionrowid.test 85187c2f1b38861a5844868126f69f9ec62223a03449a98a F ext/session/sessionsize.test 8fcf4685993c3dbaa46a24183940ab9f5aa9ed0d23e5fb63bfffbdb56134b795 F ext/session/sessionstat1.test 5e718d5888c0c49bbb33a7a4f816366db85f59f6a4f97544a806421b85dc2dec F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009ecef8511f4cf3fc -F ext/session/sqlite3session.c 0cdf052460fe11fd00a5c3f83b4a7152ed6c72ff7dacd4664c30ce16579748d7 -F ext/session/sqlite3session.h e36392d1087e42f4e691caff23cb99f4e9fc3b8b88ac7504dac3ea30883dc08b -F ext/session/test_session.c ba40d22840f3ed667448e34ab4eaa38e69f62f23af530c0f8f70a64ed92b039b +F ext/session/sqlite3session.c c7473aafbd88f796391a8c25aa90975a8f3729ab7f4f8cf74ab9d3b014e10abe +F ext/session/sqlite3session.h 1e9a1ab23701d85bb1a3794bae38a4c618c652ff84f744a7fd9b6339e9c8af2e +F ext/session/test_session.c 8bcc857125372e640f75ab63b4188080f9bbab92b65f86dfd160721c574b2044 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb @@ -2188,11 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8c3086f9fe502dfc4a1fa610a23794fb037721df29dc5d2126cfb749a9d44a50 -R 92b682ff0cdf49829f0c1fddda225a0c -T *branch * changegroup-add-change -T *sym-changegroup-add-change * -T -sym-trunk * +P 73647db1ddfdaf40cbf18f1e47c10b4a906489f6d34d7667f0f2ff532f1eb37c +R 57bf39cdeb4ff65bb7bb7b027bf86eec U dan -Z d18fc76401ae213ec8fe7cdec8b2f0ce +Z 43c000dbcc9bde7f8ce3b6fbffdd9a33 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6e66176619..18a3d1fa2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -73647db1ddfdaf40cbf18f1e47c10b4a906489f6d34d7667f0f2ff532f1eb37c \ No newline at end of file +9d67bedc20c3a59e5488f0eaea6a6611940a9cb63f7cf5e687b061cb5d510943 \ No newline at end of file From cbea8d5c3fe95e8d3381102748846e7bc79949d9 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 6 May 2024 17:32:26 +0000 Subject: [PATCH 0379/1030] Edit comments in sqlite3session.h. FossilOrigin-Name: 49f84878e21f85d44d8429cdc2908f87383e59737e1af3fdbccf0c276d883567 --- ext/session/sqlite3session.h | 3 +++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ext/session/sqlite3session.h b/ext/session/sqlite3session.h index ebd2cc5312..aa4862eb2e 100644 --- a/ext/session/sqlite3session.h +++ b/ext/session/sqlite3session.h @@ -1065,6 +1065,9 @@ int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); ** passed as the second argument to the changegroup object. The rules for ** adding the change are just as described for [sqlite3_changegroup_add()]. ** +** If the change is successfully added to the changegroup, SQLITE_OK is +** returned. Otherwise, an SQLite error code is returned. +** ** The iterator must point to a valid entry when this function is called. ** If it does not, SQLITE_ERROR is returned and no change is added to the ** changegroup. Additionally, the iterator must not have been opened with diff --git a/manifest b/manifest index d8069fa67e..0839ba753d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sfor\ssqlite3changegroup_add_change(). -D 2024-05-06T17:21:23.939 +C Edit\scomments\sin\ssqlite3session.h. +D 2024-05-06T17:32:26.518 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -583,7 +583,7 @@ F ext/session/sessionsize.test 8fcf4685993c3dbaa46a24183940ab9f5aa9ed0d23e5fb63b F ext/session/sessionstat1.test 5e718d5888c0c49bbb33a7a4f816366db85f59f6a4f97544a806421b85dc2dec F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009ecef8511f4cf3fc F ext/session/sqlite3session.c c7473aafbd88f796391a8c25aa90975a8f3729ab7f4f8cf74ab9d3b014e10abe -F ext/session/sqlite3session.h 1e9a1ab23701d85bb1a3794bae38a4c618c652ff84f744a7fd9b6339e9c8af2e +F ext/session/sqlite3session.h c02e7bbeb38647436fa7d6f364ffe90ac61b8ba5a28f0c04b22a23887baab6cb F ext/session/test_session.c 8bcc857125372e640f75ab63b4188080f9bbab92b65f86dfd160721c574b2044 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c @@ -2188,8 +2188,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 73647db1ddfdaf40cbf18f1e47c10b4a906489f6d34d7667f0f2ff532f1eb37c -R 57bf39cdeb4ff65bb7bb7b027bf86eec +P 9d67bedc20c3a59e5488f0eaea6a6611940a9cb63f7cf5e687b061cb5d510943 +R 296c227b21afb6ad42dfd04c5c56b363 U dan -Z 43c000dbcc9bde7f8ce3b6fbffdd9a33 +Z 10947964774872afcdccffdf87f6a27b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 18a3d1fa2a..79b44f13a7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d67bedc20c3a59e5488f0eaea6a6611940a9cb63f7cf5e687b061cb5d510943 \ No newline at end of file +49f84878e21f85d44d8429cdc2908f87383e59737e1af3fdbccf0c276d883567 \ No newline at end of file From ebf9702b34ee0c4049e30df2f0382501125eb2ad Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 6 May 2024 19:04:46 +0000 Subject: [PATCH 0380/1030] Avoid unnecessary recursion in sqlite3ExprDeleteNN(). This complicates the code, but it is needed to prevent nuisance "stack overflow" reports from OSSFuzz while it is running the latest ASAN. FossilOrigin-Name: 70abc144ca90a58ea25dc2d90683545246c084d961215c20ec070b0abe640371 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/expr.c | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f7d7702ed9..66484c6c9a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\ssessions\sAPI\ssqlite3changegroup_add_change(). -D 2024-05-06T17:55:19.315 +C Avoid\sunnecessary\srecursion\sin\ssqlite3ExprDeleteNN().\s\sThis\scomplicates\sthe\ncode,\sbut\sit\sis\sneeded\sto\sprevent\snuisance\s"stack\soverflow"\sreports\sfrom\nOSSFuzz\swhile\sit\sis\srunning\sthe\slatest\sASAN. +D 2024-05-06T19:04:46.744 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -703,7 +703,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 005bf7a088a2fb12a50752a2a1d40d423b8942e1920e93c3a1ba76da0bfbe52b +F src/expr.c 3428b046cb731be83770eaa34317d0ae5bdf8f5e7c3a0abd57528d0a03a8f9f9 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -2189,9 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4d90c3f179a3d7355b6b0202faf56f0be4be56986920576e528208cb84daa4af 49f84878e21f85d44d8429cdc2908f87383e59737e1af3fdbccf0c276d883567 -R 17b8f244002104b13ac86f24d06a1235 -T +closed 49f84878e21f85d44d8429cdc2908f87383e59737e1af3fdbccf0c276d883567 -U dan -Z ea504d9f33b8a329c60b503f8918f722 +P 5eaab43ce48bb8d710f784ecd6aa9a4b3e708b44b0f7e49daf66a3f8bc2b9873 +R ff7af78ebbbdb04b1ac8e2867e48ea3c +U drh +Z 931e0d906bc176d6db5edaecc3c54370 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 048c98751c..a2d92af012 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5eaab43ce48bb8d710f784ecd6aa9a4b3e708b44b0f7e49daf66a3f8bc2b9873 \ No newline at end of file +70abc144ca90a58ea25dc2d90683545246c084d961215c20ec070b0abe640371 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index aeb04a37f2..a5272df7c9 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1368,6 +1368,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){ assert( p!=0 ); assert( db!=0 ); +exprDeleteRestart: assert( !ExprUseUValue(p) || p->u.iValue>=0 ); assert( !ExprUseYWin(p) || !ExprUseYSub(p) ); assert( !ExprUseYWin(p) || p->y.pWin!=0 || db->mallocFailed ); @@ -1383,7 +1384,6 @@ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){ if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){ /* The Expr.x union is never used at the same time as Expr.pRight */ assert( (ExprUseXList(p) && p->x.pList==0) || p->pRight==0 ); - if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft); if( p->pRight ){ assert( !ExprHasProperty(p, EP_WinFunc) ); sqlite3ExprDeleteNN(db, p->pRight); @@ -1398,6 +1398,19 @@ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){ } #endif } + if( p->pLeft && p->op!=TK_SELECT_COLUMN ){ + Expr *pLeft = p->pLeft; + if( !ExprHasProperty(p, EP_Static) + && !ExprHasProperty(pLeft, EP_Static) + ){ + /* Avoid unnecessary recursion on unary operators */ + sqlite3DbNNFreeNN(db, p); + p = pLeft; + goto exprDeleteRestart; + }else{ + sqlite3ExprDeleteNN(db, pLeft); + } + } } if( !ExprHasProperty(p, EP_Static) ){ sqlite3DbNNFreeNN(db, p); From 07305e3a3ab5aaaa1062417f8176b95c13e73954 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 6 May 2024 20:18:30 +0000 Subject: [PATCH 0381/1030] Omit redundant unary + operators from the AST. FossilOrigin-Name: f81cc149e5e308785502b36e83eaaf3d31c72520793e0596d5496abd70f9cda8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/parse.y | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 66484c6c9a..adb660aa80 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sunnecessary\srecursion\sin\ssqlite3ExprDeleteNN().\s\sThis\scomplicates\sthe\ncode,\sbut\sit\sis\sneeded\sto\sprevent\snuisance\s"stack\soverflow"\sreports\sfrom\nOSSFuzz\swhile\sit\sis\srunning\sthe\slatest\sASAN. -D 2024-05-06T19:04:46.744 +C Omit\sredundant\sunary\s+\soperators\sfrom\sthe\sAST. +D 2024-05-06T20:18:30.134 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -742,7 +742,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 5bcef16094213efcc365a9d4dc4e3131f09251dc8838dce4a9e5f9764bff5b82 +F src/parse.y 50516253433303673ff6b009983bb246d1527415e5a9af22acc51b0eedb9a10d F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5eaab43ce48bb8d710f784ecd6aa9a4b3e708b44b0f7e49daf66a3f8bc2b9873 -R ff7af78ebbbdb04b1ac8e2867e48ea3c +P 70abc144ca90a58ea25dc2d90683545246c084d961215c20ec070b0abe640371 +R 6e7646721881518bcc2dce999a09299b U drh -Z 931e0d906bc176d6db5edaecc3c54370 +Z 6285aee0842c44c0bef4e5561a9995b3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a2d92af012..1eabb503c3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -70abc144ca90a58ea25dc2d90683545246c084d961215c20ec070b0abe640371 \ No newline at end of file +f81cc149e5e308785502b36e83eaaf3d31c72520793e0596d5496abd70f9cda8 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index d22c8e6fc2..071e10abd4 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1282,8 +1282,17 @@ expr(A) ::= NOT(B) expr(X). expr(A) ::= BITNOT(B) expr(X). {A = sqlite3PExpr(pParse, @B, X, 0);/*A-overwrites-B*/} expr(A) ::= PLUS|MINUS(B) expr(X). [BITNOT] { - A = sqlite3PExpr(pParse, @B==TK_PLUS ? TK_UPLUS : TK_UMINUS, X, 0); - /*A-overwrites-B*/ + Expr *p = X; + u8 op = @B + (TK_UPLUS-TK_PLUS); + assert( TK_UPLUS>TK_PLUS ); + assert( TK_UMINUS == TK_MINUS + (TK_UPLUS - TK_PLUS) ); + if( p && p->op==TK_UPLUS ){ + p->op = op; + A = p; + }else{ + A = sqlite3PExpr(pParse, op, p, 0); + /*A-overwrites-B*/ + } } expr(A) ::= expr(B) PTR(C) expr(D). { @@ -1929,8 +1938,8 @@ filter_clause(A) ::= FILTER LP WHERE expr(X) RP. { A = X; } TRUEFALSE /* True or false keyword */ ISNOT /* Combination of IS and NOT */ FUNCTION /* A function invocation */ - UMINUS /* Unary minus */ UPLUS /* Unary plus */ + UMINUS /* Unary minus */ TRUTH /* IS TRUE or IS FALSE or IS NOT TRUE or IS NOT FALSE */ REGISTER /* Reference to a VDBE register */ VECTOR /* Vector */ From 11a088b7eb9b563419253badf56fa50e897d5123 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 6 May 2024 20:21:31 +0000 Subject: [PATCH 0382/1030] When extracting links from sqlar archives, clobber any existing file or link, and do not call utimes() to set the timestamp - it looks through the link and operates on the target. FossilOrigin-Name: 2bf8c3f99ad8b74f707d17272fa12b674bec66082d3e8349ebef3dac42ba0782 --- ext/misc/fileio.c | 24 ++++++++++++++++-------- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/shell8.test | 27 ++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 70546adfca..ca8090ed2e 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -372,7 +372,9 @@ static int writeFile( #if !defined(_WIN32) && !defined(WIN32) if( S_ISLNK(mode) ){ const char *zTo = (const char*)sqlite3_value_text(pData); - if( zTo==0 || symlink(zTo, zFile)<0 ) return 1; + if( zTo==0 ) return 1; + unlink(zFile); + if( symlink(zTo, zFile)<0 ) return 1; }else #endif { @@ -458,13 +460,19 @@ static int writeFile( return 1; } #else - /* Legacy unix */ - struct timeval times[2]; - times[0].tv_usec = times[1].tv_usec = 0; - times[0].tv_sec = time(0); - times[1].tv_sec = mtime; - if( utimes(zFile, times) ){ - return 1; + /* Legacy unix. + ** + ** Do not use utimes() on a symbolic link - it sees through the link and + ** modifies the timestamps on the target. Or fails if the target does + ** not exist. */ + if( 0==S_ISLNK(mode) ){ + struct timeval times[2]; + times[0].tv_usec = times[1].tv_usec = 0; + times[0].tv_sec = time(0); + times[1].tv_sec = mtime; + if( utimes(zFile, times) ){ + return 1; + } } #endif } diff --git a/manifest b/manifest index adb660aa80..1414eb9756 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sredundant\sunary\s+\soperators\sfrom\sthe\sAST. -D 2024-05-06T20:18:30.134 +C When\sextracting\slinks\sfrom\ssqlar\sarchives,\sclobber\sany\sexisting\sfile\sor\slink,\sand\sdo\snot\scall\sutimes()\sto\sset\sthe\stimestamp\s-\sit\slooks\sthrough\sthe\slink\sand\soperates\son\sthe\starget. +D 2024-05-06T20:21:31.369 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -391,7 +391,7 @@ F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f82 F ext/misc/decimal.c 172cf81a8634e6a0f0bedaf71a8372fee63348cf5a3c4e1b78bb233c35889fdc F ext/misc/eval.c 04bc9aada78c888394204b4ed996ab834b99726fb59603b0ee3ed6e049755dc1 F ext/misc/explain.c 606100185fb90d6a1eade1ed0414d53503c86820d8956a06e3b0a56291894f2b -F ext/misc/fileio.c d88e60f63557d76d4e38acffda5556b2ab42e98f5d830897f22aba65930d975c +F ext/misc/fileio.c 916638042f318701460485032e33981056747d0f92e6757aa9499f2363ea7047 F ext/misc/fossildelta.c 8c026e086e406e2b69947f1856fa3b848fff5379962276430d10085b8756b05a F ext/misc/fuzzer.c 8b28acf1a7e95d50e332bdd47e792ff27054ad99d3f9bc2e91273814d4b31a5a F ext/misc/ieee754.c 62a90978204d2c956d5036eb89e548e736ca5fac0e965912867ddd7bb833256d @@ -1615,7 +1615,7 @@ F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f F test/shell5.test 5b2ab1c0540217773f939927c24163a56257446da3f564d4724042620bfea762 F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bdbb8 F test/shell7.test 753c6ece5361df50025a50cadf378ea36db9cc05fb23d7a96cff7fa130626ef9 -F test/shell8.test 9b71d56a6f6fc62edd9163534ac21eaa328ad95f1b9026e7bd08d5b4621eacf6 +F test/shell8.test aea51ecbcd4494c746b096aeff51d841d04d5f0dc4b62eb42427f16109b87acd F test/shell9.test 8742a5b390cdcef6369f5aa223e415aa4255a4129ef249b177887dc635a87209 F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 70abc144ca90a58ea25dc2d90683545246c084d961215c20ec070b0abe640371 -R 6e7646721881518bcc2dce999a09299b -U drh -Z 6285aee0842c44c0bef4e5561a9995b3 +P f81cc149e5e308785502b36e83eaaf3d31c72520793e0596d5496abd70f9cda8 +R 11a1bb72646a7cee54c6968ddd222fda +U dan +Z 139d76aa50084d40f26f43b610be1a4e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1eabb503c3..2c00a6909f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f81cc149e5e308785502b36e83eaaf3d31c72520793e0596d5496abd70f9cda8 \ No newline at end of file +2bf8c3f99ad8b74f707d17272fa12b674bec66082d3e8349ebef3dac42ba0782 \ No newline at end of file diff --git a/test/shell8.test b/test/shell8.test index 944173a2a1..ca37598e93 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -165,7 +165,7 @@ foreach {tn tcl} { # # Because it is slow, only do this for $tn==1. if {$tn==1} { - do_test 1.$tn.1 { + do_test 1.$tn.4 { catchcmd test_ar.db $c1 file delete -force ar1 after 2000 @@ -194,4 +194,29 @@ do_test 2.1.1 { regsub -all {ar4} [dir_content ar4] ar2 } {ar2/file1 ar2/file2 ar2/junk1} +# Test symbolic links. +# +if {$tcl_platform(platform)=="unix"} { + populate_dir ar2 { + file1 "1234" + file2 "3456" + } + file link ar2/link1 file1 + + forcedelete shell8.db + forcedelete link1 + + do_test 3.1 { + catchcmd shell8.db {.ar -C ar2 -c file2 link1 } + } {0 {}} + + do_test 3.2 { + catchcmd shell8.db {.ar -x} + } {0 {}} + + do_test 3.3 { + catchcmd shell8.db {.ar -x} + } {0 {}} +} + finish_test From e871779f7e48185c65954a41b0fb1d65768b8be4 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 7 May 2024 13:20:24 +0000 Subject: [PATCH 0383/1030] Fix a compilation error in test/lemon-test01.y, reported in [forum:f0ad095705|forum post f0ad095705]. FossilOrigin-Name: 576b68c8b5132eb8901789b7fafb37e5ad7a00c1c7154090b42ddc5934ac0396 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/lemon-test01.y | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 1414eb9756..8d4e3858f7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sextracting\slinks\sfrom\ssqlar\sarchives,\sclobber\sany\sexisting\sfile\sor\slink,\sand\sdo\snot\scall\sutimes()\sto\sset\sthe\stimestamp\s-\sit\slooks\sthrough\sthe\slink\sand\soperates\son\sthe\starget. -D 2024-05-06T20:21:31.369 +C Fix\sa\scompilation\serror\sin\stest/lemon-test01.y,\sreported\sin\s[forum:f0ad095705|forum\spost\sf0ad095705]. +D 2024-05-07T13:20:24.512 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1370,7 +1370,7 @@ F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff F test/kvtest.c 6e0228409ea7ca0497dad503fbd109badb5e59545d131014b6aaac68b56f484a F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 -F test/lemon-test01.y f6280e3787ff9ab57b12527e814c205e1ba1f25fc7458dd6986e2d3351eee320 +F test/lemon-test01.y 70110eff607ab137ccc851edb2bc7e14a6d4f246b5d2d25f82a60b69d87a9ff2 F test/like.test 242ee7f5d08a031144c0daf63bbd7e7710c847ccf387a83347e0b61b3aa69526 F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3d3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f81cc149e5e308785502b36e83eaaf3d31c72520793e0596d5496abd70f9cda8 -R 11a1bb72646a7cee54c6968ddd222fda -U dan -Z 139d76aa50084d40f26f43b610be1a4e +P 2bf8c3f99ad8b74f707d17272fa12b674bec66082d3e8349ebef3dac42ba0782 +R cd6817873ffd9cbd41715e29850cbbb5 +U stephan +Z ea3f55e2a2ab2609bdac4d75c8a5f3af # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2c00a6909f..2581198f30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2bf8c3f99ad8b74f707d17272fa12b674bec66082d3e8349ebef3dac42ba0782 \ No newline at end of file +576b68c8b5132eb8901789b7fafb37e5ad7a00c1c7154090b42ddc5934ac0396 \ No newline at end of file diff --git a/test/lemon-test01.y b/test/lemon-test01.y index 929b00b62c..67890c6376 100644 --- a/test/lemon-test01.y +++ b/test/lemon-test01.y @@ -33,7 +33,7 @@ all ::= error B. #include "lemon-test01.h" static int nTest = 0; static int nErr = 0; - static int testCase(int testId, int shouldBe, int actual){ + static void testCase(int testId, int shouldBe, int actual){ nTest++; if( shouldBe==actual ){ printf("test %d: ok\n", testId); From a40cae78027eed3212b0207c478a5879ba49bea2 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 7 May 2024 17:58:07 +0000 Subject: [PATCH 0384/1030] Ensure successive scans of pragma virtual tables return consistent rowids. FossilOrigin-Name: 6838bf3ac130c5862f5fbc718b3e49ece154fa840b6539af2616cffa31e73808 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pragma.c | 1 + test/pragma4.test | 28 ++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8d4e3858f7..6f4f8b70a4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scompilation\serror\sin\stest/lemon-test01.y,\sreported\sin\s[forum:f0ad095705|forum\spost\sf0ad095705]. -D 2024-05-07T13:20:24.512 +C Ensure\ssuccessive\sscans\sof\spragma\svirtual\stables\sreturn\sconsistent\srowids. +D 2024-05-07T17:58:07.671 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -746,7 +746,7 @@ F src/parse.y 50516253433303673ff6b009983bb246d1527415e5a9af22acc51b0eedb9a10d F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 -F src/pragma.c d357a25276d222adfd4637c48880409ec4539f30844b74001c6ba5c7d1a1f0f7 +F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 @@ -1506,7 +1506,7 @@ F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b76 F test/pragma.test 11cb9310c42f921918f7f563e3c0b6e70f9f9c3a6a1cf12af8fccb6c574f3882 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31 -F test/pragma4.test 22834a228e59b80f5c15b519b710474859d91535002670ddb7cd13ac44b54e9a +F test/pragma4.test f93f317693e90ece4ed0f5505d9035cae03f9fc684b718278433f2e48703f693 F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d9102 F test/pragma6.test c5ec577ba087954b4dfa619a3cbe97b155b60a0af487527abe89b10fc17e6512 F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8 @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2bf8c3f99ad8b74f707d17272fa12b674bec66082d3e8349ebef3dac42ba0782 -R cd6817873ffd9cbd41715e29850cbbb5 -U stephan -Z ea3f55e2a2ab2609bdac4d75c8a5f3af +P 576b68c8b5132eb8901789b7fafb37e5ad7a00c1c7154090b42ddc5934ac0396 +R dd0146b65a6f2cce89315f9eb819a1ea +U dan +Z 7d535aaf3f019393b2ad327e44317dcb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2581198f30..f3000e5cae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -576b68c8b5132eb8901789b7fafb37e5ad7a00c1c7154090b42ddc5934ac0396 \ No newline at end of file +6838bf3ac130c5862f5fbc718b3e49ece154fa840b6539af2616cffa31e73808 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 80864da79f..a8045aab1e 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2911,6 +2911,7 @@ static void pragmaVtabCursorClear(PragmaVtabCursor *pCsr){ int i; sqlite3_finalize(pCsr->pPragma); pCsr->pPragma = 0; + pCsr->iRowid = 0; for(i=0; iazArg); i++){ sqlite3_free(pCsr->azArg[i]); pCsr->azArg[i] = 0; diff --git a/test/pragma4.test b/test/pragma4.test index 6d59b4fff3..5360fbac40 100644 --- a/test/pragma4.test +++ b/test/pragma4.test @@ -283,4 +283,32 @@ ifcapable vtab { } {t2 t1 d a 1} } +# 2024-05-08 https://sqlite.org/forum/forumpost/cf29a33e94 +# +ifcapable vtab { + do_execsql_test 7.0 { + CREATE TABLE t3 ("a" TEXT, "b" TEXT); + CREATE TABLE t4 ("a" TEXT, "b" TEXT, "c" TEXT); + } + + do_execsql_test 7.1 { + CREATE TABLE pragma_t3 AS SELECT * FROM pragma_table_info('t3'); + CREATE TABLE pragma_t4 AS SELECT * FROM pragma_table_info('t4'); + } + + do_execsql_test 7.2 { + SELECT pragma_t4.name, pragma_t3.name + FROM pragma_t4 RIGHT JOIN pragma_t3 ON (pragma_t4.name=pragma_t3.name); + } {a a b b} + + do_execsql_test 7.3 { + SELECT t4.name, t3.name + FROM pragma_table_info('t4') t4 + RIGHT JOIN pragma_table_info('t3') t3 ON (t4.name=t3.name); + } {a a b b} +} + + + + finish_test From d1122a4c0f1aa72b5033a8ae03d293c0a1afb04a Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 7 May 2024 19:45:05 +0000 Subject: [PATCH 0385/1030] Fix bug in test script sessionconflict.test. FossilOrigin-Name: e29decb8b1991bb586f41fd74bbaa4d6c4bd63e22617145828b2500d697d7869 --- ext/session/sessionconflict.test | 1 + manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ext/session/sessionconflict.test b/ext/session/sessionconflict.test index c842a8aacb..25b2602998 100644 --- a/ext/session/sessionconflict.test +++ b/ext/session/sessionconflict.test @@ -20,6 +20,7 @@ ifcapable !session {finish_test; return} set testprefix sessionconflict +db close sqlite3_shutdown test_sqlite3_log log proc log {code msg} { puts "LOG $code $msg" } diff --git a/manifest b/manifest index 6f4f8b70a4..e71dcac966 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\ssuccessive\sscans\sof\spragma\svirtual\stables\sreturn\sconsistent\srowids. -D 2024-05-07T17:58:07.671 +C Fix\sbug\sin\stest\sscript\ssessionconflict.test. +D 2024-05-07T19:45:05.255 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -568,7 +568,7 @@ F ext/session/sessionalter.test 460bdac2832a550519f6bc32e5db2c0cee94f335870aaf25 F ext/session/sessionat.test 00c8badb35e43a2f12a716d2734a44d614ff62361979b6b85419035bc04b45ee F ext/session/sessionbig.test 47c381e7acfabeef17d98519a3080d69151723354d220afa2053852182ca7adf F ext/session/sessionchange.test 77c4702050f24270b58070e2cf01c95c3d232a3ef164b70f31974b386ce69903 -F ext/session/sessionconflict.test 28890457bb90457be772d3067cdb5f78db9b51d997e4f3d09f22cddc9be80a38 +F ext/session/sessionconflict.test 8b8cbd98548e2e636ddc17d0986276f60e833fb865617dd4f88ea5bbe3a16b96 F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec F ext/session/sessionfault.test 573bf027fb870d57bd4e7cf50822a3e4b17b2b923407438747aaa918dec57a09 F ext/session/sessionfault2.test b0d6a7c1d7398a7e800d84657404909c7d385965ea8576dc79ed344c46fbf41c @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 576b68c8b5132eb8901789b7fafb37e5ad7a00c1c7154090b42ddc5934ac0396 -R dd0146b65a6f2cce89315f9eb819a1ea +P 6838bf3ac130c5862f5fbc718b3e49ece154fa840b6539af2616cffa31e73808 +R 7cad8658624c310fc9eec1405b0ca964 U dan -Z 7d535aaf3f019393b2ad327e44317dcb +Z 1d9426ac7036e4e699729b91e2ba47ed # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f3000e5cae..eff0e01131 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6838bf3ac130c5862f5fbc718b3e49ece154fa840b6539af2616cffa31e73808 \ No newline at end of file +e29decb8b1991bb586f41fd74bbaa4d6c4bd63e22617145828b2500d697d7869 \ No newline at end of file From 538ad6ce58c47e48f2c85abfcb31c968e615fc40 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 8 May 2024 11:51:56 +0000 Subject: [PATCH 0386/1030] Fix a hyperlink typo in session documentation. FossilOrigin-Name: 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf --- ext/session/sqlite3session.h | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/session/sqlite3session.h b/ext/session/sqlite3session.h index aa4862eb2e..f950d419b5 100644 --- a/ext/session/sqlite3session.h +++ b/ext/session/sqlite3session.h @@ -1063,7 +1063,7 @@ int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); ** ** This function adds the single change currently indicated by the iterator ** passed as the second argument to the changegroup object. The rules for -** adding the change are just as described for [sqlite3_changegroup_add()]. +** adding the change are just as described for [sqlite3changegroup_add()]. ** ** If the change is successfully added to the changegroup, SQLITE_OK is ** returned. Otherwise, an SQLite error code is returned. diff --git a/manifest b/manifest index e71dcac966..32bc04aaf5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sbug\sin\stest\sscript\ssessionconflict.test. -D 2024-05-07T19:45:05.255 +C Fix\sa\shyperlink\stypo\sin\ssession\sdocumentation. +D 2024-05-08T11:51:56.927 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -584,7 +584,7 @@ F ext/session/sessionsize.test 8fcf4685993c3dbaa46a24183940ab9f5aa9ed0d23e5fb63b F ext/session/sessionstat1.test 5e718d5888c0c49bbb33a7a4f816366db85f59f6a4f97544a806421b85dc2dec F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009ecef8511f4cf3fc F ext/session/sqlite3session.c c7473aafbd88f796391a8c25aa90975a8f3729ab7f4f8cf74ab9d3b014e10abe -F ext/session/sqlite3session.h c02e7bbeb38647436fa7d6f364ffe90ac61b8ba5a28f0c04b22a23887baab6cb +F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b F ext/session/test_session.c 8bcc857125372e640f75ab63b4188080f9bbab92b65f86dfd160721c574b2044 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6838bf3ac130c5862f5fbc718b3e49ece154fa840b6539af2616cffa31e73808 -R 7cad8658624c310fc9eec1405b0ca964 -U dan -Z 1d9426ac7036e4e699729b91e2ba47ed +P e29decb8b1991bb586f41fd74bbaa4d6c4bd63e22617145828b2500d697d7869 +R bd6c2a6994b109d4181b29475acc71ca +U drh +Z b1677682f99b4b1ca04906a7901df3be # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index eff0e01131..d0915126d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e29decb8b1991bb586f41fd74bbaa4d6c4bd63e22617145828b2500d697d7869 \ No newline at end of file +42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf \ No newline at end of file From 788ade3487252c4de2da94a2b8f9ec7ebdd83c95 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 8 May 2024 17:42:13 +0000 Subject: [PATCH 0387/1030] Allow arbitrary expressions as the second argument to RAISE(). FossilOrigin-Name: 003e1c8c27824cb917b3869bdf9000f32ff0b6887a2aff8516712cfe865cf34d --- manifest | 27 +++++++++++++++------------ manifest.uuid | 2 +- src/expr.c | 9 ++++----- src/fkey.c | 3 ++- src/parse.y | 4 ++-- src/treeview.c | 3 ++- src/vdbe.c | 26 +++++++++++++++++++------- test/colname.test | 2 +- test/trigger1.test | 13 +++++++++++++ 9 files changed, 59 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index 32bc04aaf5..2c7cfc8e18 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\shyperlink\stypo\sin\ssession\sdocumentation. -D 2024-05-08T11:51:56.927 +C Allow\sarbitrary\sexpressions\sas\sthe\ssecond\sargument\sto\sRAISE(). +D 2024-05-08T17:42:13.761 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -703,9 +703,9 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 3428b046cb731be83770eaa34317d0ae5bdf8f5e7c3a0abd57528d0a03a8f9f9 +F src/expr.c dff4775b9aa9e6a397b37dda601207c6c0024df8cb5ec43e66fd07f5efd9bd6c F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 -F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 +F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 @@ -742,7 +742,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 50516253433303673ff6b009983bb246d1527415e5a9af22acc51b0eedb9a10d +F src/parse.y de2da0ffd33f6532c1640e7c6a6c6d8ac5ae85b0dbb0b1d7c3194d243a4c1e6a F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -816,14 +816,14 @@ F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c 4f9ba6c1c7c9893fc046fdb0bc1f6bdec7660122b1ae37e51fb9b64c286caafd +F src/treeview.c 5538cc0e88cb87c55e26326c7a02d5fe45deaeb2edbd5436af7a674ed6491ff2 F src/trigger.c 0858f75818ed1580332db274f1032bcc5effe567cb132df5c5be8b1d800ca97f F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 3b1793c5d2235ae89b01ef051a33d7d2ad3704c71799653b112686735ad401ff +F src/vdbe.c 2fdfe0535fa517fb4590144121c040c5703db318e7479d6d62ba6ab2e699e001 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -997,7 +997,7 @@ F test/collate9.test 3adcc799229545940df2f25308dd1ad65869145a F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/collateB.test 1e68906951b846570f29f20102ed91d29e634854ee47454d725f2151ecac0b95 F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 -F test/colname.test 87ad5458bb8709312dac0d6755fd30e8e4ca83298d0a9ef6e5c24277a3c3390e +F test/colname.test 387e880eeac0889900f7b3e9703c375515f5d323f71fd4f2bb5428a4ac8e2023 F test/columncount.test 6fe99c2f35738b0129357a1cf3fa483f76140f4cd8a89014c88c33c876d2638f F test/conflict.test b705cddf025a675d3c13d62fa78ab1e2696fb8e07a3d7cccce1596ff8b301492 F test/conflict2.test 5557909ce683b1073982f5d1b61dfb1d41e369533bfdaf003180c5bc87282dd1 @@ -1866,7 +1866,7 @@ F test/trans.test 45f6f9ab6f66a7b5744f1caac06b558f95da62501916906cf55586a896f9f4 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 F test/transitive1.test f8ee983600b33d167da1885657f064aec404e1c0d0bc8765fdf163f4c749237a -F test/trigger1.test 02cc64dc98278816c1c1ed8e472e18db8edbad88f37018bf46223e9614831963 +F test/trigger1.test 2834f8830a1ae338d95c2e3ea0c2a7bc4cda126cdeb715004cf0fd071892e44f F test/trigger2.test 30fcb3a6aa6782020d47968735ee6086ed795f73a7affa9406c8d5a36e7b5265 F test/trigger3.test aa640bb2bbb03edd5ff69c055117ea088f121945 F test/trigger4.test 74700b76ebf3947b2f7a92405141eb2cf2a5d359 @@ -2189,8 +2189,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e29decb8b1991bb586f41fd74bbaa4d6c4bd63e22617145828b2500d697d7869 -R bd6c2a6994b109d4181b29475acc71ca +P 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf +R 2f3bd2a16acd125a41b6775ce57250d9 +T *branch * enhanced-raise +T *sym-enhanced-raise * +T -sym-trunk * U drh -Z b1677682f99b4b1ca04906a7901df3be +Z 0fd130dec139b10d531d7d8015ffe4ed # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d0915126d9..6014fe7714 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf \ No newline at end of file +003e1c8c27824cb917b3869bdf9000f32ff0b6887a2aff8516712cfe865cf34d \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index a5272df7c9..2157cf4ed8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -5306,15 +5306,14 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ } assert( !ExprHasProperty(pExpr, EP_IntValue) ); if( pExpr->affExpr==OE_Ignore ){ - sqlite3VdbeAddOp4( - v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0); + sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, OE_Ignore); VdbeCoverage(v); }else{ - sqlite3HaltConstraint(pParse, + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); + sqlite3VdbeAddOp3(v, OP_Halt, pParse->pTriggerTab ? SQLITE_CONSTRAINT_TRIGGER : SQLITE_ERROR, - pExpr->affExpr, pExpr->u.zToken, 0, 0); + pExpr->affExpr, r1); } - break; } #endif diff --git a/src/fkey.c b/src/fkey.c index bace1ae5e2..1efdc0bba1 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1328,7 +1328,8 @@ static Trigger *fkActionTrigger( SrcList *pSrc; Expr *pRaise; - pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed"); + pRaise = sqlite3Expr(db, TK_STRING, "FOREIGN KEY constraint failed"), + pRaise = sqlite3PExpr(pParse, TK_RAISE, pRaise, 0); if( pRaise ){ pRaise->affExpr = OE_Abort; } diff --git a/src/parse.y b/src/parse.y index 071e10abd4..90277f9c0c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1658,8 +1658,8 @@ expr(A) ::= RAISE LP IGNORE RP. { A->affExpr = OE_Ignore; } } -expr(A) ::= RAISE LP raisetype(T) COMMA nm(Z) RP. { - A = sqlite3ExprAlloc(pParse->db, TK_RAISE, &Z, 1); +expr(A) ::= RAISE LP raisetype(T) COMMA expr(Z) RP. { + A = sqlite3PExpr(pParse, TK_RAISE, Z, 0); if( A ) { A->affExpr = (char)T; } diff --git a/src/treeview.c b/src/treeview.c index d3346b4686..586106cada 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -818,7 +818,8 @@ void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){ case OE_Ignore: zType = "ignore"; break; } assert( !ExprHasProperty(pExpr, EP_IntValue) ); - sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken); + sqlite3TreeViewLine(pView, "RAISE %s", zType); + sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); break; } #endif diff --git a/src/vdbe.c b/src/vdbe.c index d8b471de2e..f06a71da40 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1214,7 +1214,7 @@ case OP_HaltIfNull: { /* in3 */ /* no break */ deliberate_fall_through } -/* Opcode: Halt P1 P2 * P4 P5 +/* Opcode: Halt P1 P2 P3 P4 P5 ** ** Exit immediately. All open cursors, etc are closed ** automatically. @@ -1227,18 +1227,22 @@ case OP_HaltIfNull: { /* in3 */ ** then back out all changes that have occurred during this execution of the ** VDBE, but do not rollback the transaction. ** -** If P4 is not null then it is an error message string. +** If P3 is not zero and P4 is NULL, then P3 is a register that holds the +** text of an error message. ** -** P5 is a value between 0 and 4, inclusive, that modifies the P4 string. +** If P3 is zero and P4 is not null then the error message string is held +** in P4. +** +** P5 is a value between 1 and 4, inclusive, then the P4 error message +** string is modified as follows: ** -** 0: (no change) ** 1: NOT NULL constraint failed: P4 ** 2: UNIQUE constraint failed: P4 ** 3: CHECK constraint failed: P4 ** 4: FOREIGN KEY constraint failed: P4 ** -** If P5 is not zero and P4 is NULL, then everything after the ":" is -** omitted. +** If P3 is zero and P5 is not zero and P4 is NULL, then everything after +** the ":" is omitted. ** ** There is an implied "Halt 0 0 0" instruction inserted at the very end of ** every program. So a jump past the last instruction of the program @@ -1251,6 +1255,9 @@ case OP_Halt: { #ifdef SQLITE_DEBUG if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); } #endif + assert( pOp->p4type==P4_NOTUSED + || pOp->p4type==P4_STATIC + || pOp->p4type==P4_DYNAMIC ); /* A deliberately coded "OP_Halt SQLITE_INTERNAL * * * *" opcode indicates ** something is wrong with the code generator. Raise an assertion in order @@ -1281,7 +1288,12 @@ case OP_Halt: { p->errorAction = (u8)pOp->p2; assert( pOp->p5<=4 ); if( p->rc ){ - if( pOp->p5 ){ + if( pOp->p3>0 && pOp->p4type==P4_NOTUSED ){ + const char *zErr; + assert( pOp->p3<=(p->nMem + 1 - p->nCursor) ); + zErr = sqlite3ValueText(&aMem[pOp->p3], SQLITE_UTF8); + sqlite3VdbeError(p, "%s", zErr); + }else if( pOp->p5 ){ static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK", "FOREIGN KEY" }; testcase( pOp->p5==1 ); diff --git a/test/colname.test b/test/colname.test index 5fa0b601f9..24fb51acfc 100644 --- a/test/colname.test +++ b/test/colname.test @@ -424,7 +424,7 @@ do_catchsql_test colname-9.400 { # do_catchsql_test colname-9.410 { CREATE TABLE t5 AS SELECT RAISE(abort,a); -} {1 {RAISE() may only be used within a trigger-program}} +} {1 {no such column: a}} # Make sure the quotation marks get removed from the column names # when constructing a new table from an aggregate SELECT. diff --git a/test/trigger1.test b/test/trigger1.test index 6de121fa9c..afeb7ddccb 100644 --- a/test/trigger1.test +++ b/test/trigger1.test @@ -838,4 +838,17 @@ do_catchsql_test trigger1-23.1 { END; } {1 {near "#1": syntax error}} +# 2024-05-08 Allow arbitrary expressions as the 2nd argument to RAISE(). +# +do_catchsql_test trigger1-24.1 { + CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN + SELECT raise(abort,format('attempt to insert %d where is not a power of 2',new.a)) + WHERE (new.a & (new.a-1))!=0; + END; + INSERT INTO t1 VALUES(0),(1),(2),(4),(8),(65536); +} {0 {}} +do_catchsql_test trigger1-24.2 { + INSERT INTO t1 VALUES(9876); +} {1 {attempt to insert 9876 where is not a power of 2}} + finish_test From f0c9bc596ebd178fdab62634df88a03ae4da1d3e Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 8 May 2024 17:57:45 +0000 Subject: [PATCH 0388/1030] Rename a shadowed local var, as reported in [forum:2ba65af3148585cf|forum post 2ba65af31]. No functional changes. FossilOrigin-Name: d030c87c4d410e9ca2b90ec7cb63e752f4490c60e2feac84f233861593142c7d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 32bc04aaf5..6387c6f73c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\shyperlink\stypo\sin\ssession\sdocumentation. -D 2024-05-08T11:51:56.927 +C Rename\sa\sshadowed\slocal\svar,\sas\sreported\sin\s[forum:2ba65af3148585cf|forum\spost\s2ba65af31].\sNo\sfunctional\schanges. +D 2024-05-08T17:57:45.450 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -753,7 +753,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 8816212645e4e9bdf3cc2f2d298304f388d699f8fab47f3a5712ef5bbc5b6ccc F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 04178566d0188be7de471064ced8cec1d407920726cb49b609486282d78faf56 +F src/select.c ce81687d769b174aa547b8216a34fabc9cafc05789b615494ab78dc2c1e799fa F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e29decb8b1991bb586f41fd74bbaa4d6c4bd63e22617145828b2500d697d7869 -R bd6c2a6994b109d4181b29475acc71ca -U drh -Z b1677682f99b4b1ca04906a7901df3be +P 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf +R 720970f4b793c1274abaf8cd5acc207b +U stephan +Z ded7a2dedc55d6033e03441501e1782b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d0915126d9..1393352ef3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf \ No newline at end of file +d030c87c4d410e9ca2b90ec7cb63e752f4490c60e2feac84f233861593142c7d \ No newline at end of file diff --git a/src/select.c b/src/select.c index 8ee59cf68a..532fbd19e5 100644 --- a/src/select.c +++ b/src/select.c @@ -2381,12 +2381,12 @@ void sqlite3SubqueryColumnTypes( } } if( zType ){ - i64 m = sqlite3Strlen30(zType); + const i64 k = sqlite3Strlen30(zType); n = sqlite3Strlen30(pCol->zCnName); - pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2); + pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+k+2); pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL); if( pCol->zCnName ){ - memcpy(&pCol->zCnName[n+1], zType, m+1); + memcpy(&pCol->zCnName[n+1], zType, k+1); pCol->colFlags |= COLFLAG_HASTYPE; } } From 0e93237b17e652f92a4977abd4c8f8a98804fa4c Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 9 May 2024 18:00:14 +0000 Subject: [PATCH 0389/1030] Reformulate a for-in loop to a for loop in wasm.xWrap() to work around a downstream framework-level misbehavior, as reported in [forum:b549992634b55104|forum post b549992634b55104]. FossilOrigin-Name: dc58ed654928574ef254af289bd21c654c587aac80aea36ab96772c35d4ca754 --- ext/wasm/common/whwasmutil.js | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index bbcf3d4930..326b28e22f 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -2035,7 +2035,8 @@ globalThis.WhWasmUtilInstaller = function(target){ arguments are, is _not_ part of the public interface and is _not_ stable. */ - for(const i in args) args[i] = cxw.convertArgNoCheck( + let i = 0; + for(; i < args.length; ++i) args[i] = cxw.convertArgNoCheck( argTypes[i], args[i], args, i ); return cxw.convertResultNoCheck(resultType, xf.apply(null,args)); diff --git a/manifest b/manifest index 6387c6f73c..03ae78d768 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\sa\sshadowed\slocal\svar,\sas\sreported\sin\s[forum:2ba65af3148585cf|forum\spost\s2ba65af31].\sNo\sfunctional\schanges. -D 2024-05-08T17:57:45.450 +C Reformulate\sa\sfor-in\sloop\sto\sa\sfor\sloop\sin\swasm.xWrap()\sto\swork\saround\sa\sdownstream\sframework-level\smisbehavior,\sas\sreported\sin\s[forum:b549992634b55104|forum\spost\sb549992634b55104]. +D 2024-05-09T18:00:14.716 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -629,7 +629,7 @@ F ext/wasm/c-pp.c 6d80d8569d85713effe8b0818a3cf51dc779e3f0bf8dc88771b8998552ee25 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f -F ext/wasm/common/whwasmutil.js e474e0fac695abf88e5385581e26d53e5706cd268cab9d92a56eab2873c08daa +F ext/wasm/common/whwasmutil.js 22a81c8ca81ceb2662db4a73ded2e8bef22300fd8894410fac0ffd45f32da8fd F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf -R 720970f4b793c1274abaf8cd5acc207b +P d030c87c4d410e9ca2b90ec7cb63e752f4490c60e2feac84f233861593142c7d +R 1ce3f637477b3f3b2a8d1fc27a6cb38f U stephan -Z ded7a2dedc55d6033e03441501e1782b +Z 6f5fe3e373ae24dc54ff89790b691517 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1393352ef3..bc458de973 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d030c87c4d410e9ca2b90ec7cb63e752f4490c60e2feac84f233861593142c7d \ No newline at end of file +dc58ed654928574ef254af289bd21c654c587aac80aea36ab96772c35d4ca754 \ No newline at end of file From a8c43830f2bdfe7777350646040f70285a665e9f Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 9 May 2024 18:39:54 +0000 Subject: [PATCH 0390/1030] Add a maintenance-reminder comment explaining [dc58ed65492857]. FossilOrigin-Name: 857f5d7fadce1cfe30b3468826f403f736cfecacb1eb6d3b858b01ea3cfd6ffc --- ext/wasm/common/whwasmutil.js | 3 +++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index 326b28e22f..b8a2a87742 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -2034,6 +2034,9 @@ globalThis.WhWasmUtilInstaller = function(target){ arguments may be passed in after that one, and what those arguments are, is _not_ part of the public interface and is _not_ stable. + + Maintenance reminder: the Ember framework modifies the core + Array type, breaking for-in loops. */ let i = 0; for(; i < args.length; ++i) args[i] = cxw.convertArgNoCheck( diff --git a/manifest b/manifest index 03ae78d768..583b3d98ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reformulate\sa\sfor-in\sloop\sto\sa\sfor\sloop\sin\swasm.xWrap()\sto\swork\saround\sa\sdownstream\sframework-level\smisbehavior,\sas\sreported\sin\s[forum:b549992634b55104|forum\spost\sb549992634b55104]. -D 2024-05-09T18:00:14.716 +C Add\sa\smaintenance-reminder\scomment\sexplaining\s[dc58ed65492857]. +D 2024-05-09T18:39:54.271 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -629,7 +629,7 @@ F ext/wasm/c-pp.c 6d80d8569d85713effe8b0818a3cf51dc779e3f0bf8dc88771b8998552ee25 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f -F ext/wasm/common/whwasmutil.js 22a81c8ca81ceb2662db4a73ded2e8bef22300fd8894410fac0ffd45f32da8fd +F ext/wasm/common/whwasmutil.js f7b3461028899b923fb554029a5c980396b02800b742aabb44346dd8704fd11b F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d030c87c4d410e9ca2b90ec7cb63e752f4490c60e2feac84f233861593142c7d -R 1ce3f637477b3f3b2a8d1fc27a6cb38f +P dc58ed654928574ef254af289bd21c654c587aac80aea36ab96772c35d4ca754 +R 1ed7609111b28491e4b1197daa094882 U stephan -Z 6f5fe3e373ae24dc54ff89790b691517 +Z e11e22686e88a9ceee16613611fcb507 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bc458de973..ccb12330aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dc58ed654928574ef254af289bd21c654c587aac80aea36ab96772c35d4ca754 \ No newline at end of file +857f5d7fadce1cfe30b3468826f403f736cfecacb1eb6d3b858b01ea3cfd6ffc \ No newline at end of file From 8292aa7a18da4d4f5b927bf396479f460ff6d041 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 10 May 2024 09:26:53 +0000 Subject: [PATCH 0391/1030] Squelch two OMIT-flag-related warnings reported in [forum:388243d9882067a9|forum post 388243d9882067a9]. No functional changes. FossilOrigin-Name: 1d6716054d7fc50df237996c3db30e5fb8e32acbf48cb8b9af472360515945c4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 2 ++ src/vdbeaux.c | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 583b3d98ac..d73b846391 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smaintenance-reminder\scomment\sexplaining\s[dc58ed65492857]. -D 2024-05-09T18:39:54.271 +C Squelch\stwo\sOMIT-flag-related\swarnings\sreported\sin\s[forum:388243d9882067a9|forum\spost\s388243d9882067a9].\sNo\sfunctional\schanges. +D 2024-05-10T09:26:53.619 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -758,7 +758,7 @@ F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be219 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 4ca38e206befb3738d8cca97b6c6ee56c10f1c5bdb379ac5442d0f1a71b9fefa +F src/sqliteInt.h 2eff008d787b12e76a906fd670dbe478dd1c7f2925fb59768e1f7d81c77a0600 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -827,7 +827,7 @@ F src/vdbe.c 3b1793c5d2235ae89b01ef051a33d7d2ad3704c71799653b112686735ad401ff F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df -F src/vdbeaux.c 6385727adf51a649e4993098870a62c3945fe21dbc0e0fd9013772aff930b8fb +F src/vdbeaux.c 3bcf13776c39bf660a52b4b97f6389a421c2756f9ffbf4c0d94f73e1935d8d9c F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 385c8b89da3b5ef9a468d77a466958aa72ee1212d5cb005f23ec63df1d413054 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dc58ed654928574ef254af289bd21c654c587aac80aea36ab96772c35d4ca754 -R 1ed7609111b28491e4b1197daa094882 +P 857f5d7fadce1cfe30b3468826f403f736cfecacb1eb6d3b858b01ea3cfd6ffc +R f270cbcd240352fa10729fed65c3c5a2 U stephan -Z e11e22686e88a9ceee16613611fcb507 +Z 06aaa7e94b8e9b6ffd39f925ee912fbc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ccb12330aa..a03c415635 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -857f5d7fadce1cfe30b3468826f403f736cfecacb1eb6d3b858b01ea3cfd6ffc \ No newline at end of file +1d6716054d7fc50df237996c3db30e5fb8e32acbf48cb8b9af472360515945c4 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0d33f9ee2a..0da289d525 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -5267,7 +5267,9 @@ void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...); void sqlite3Error(sqlite3*,int); void sqlite3ErrorClear(sqlite3*); void sqlite3SystemError(sqlite3*,int); +#if !defined(SQLITE_OMIT_BLOB_LITERAL) void *sqlite3HexToBlob(sqlite3*, const char *z, int n); +#endif u8 sqlite3HexToInt(int h); int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index e5c8303435..e4c174e3fb 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3355,9 +3355,9 @@ int sqlite3VdbeHalt(Vdbe *p){ /* Check for immediate foreign key violations. */ if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){ - sqlite3VdbeCheckFk(p, 0); + (void)sqlite3VdbeCheckFk(p, 0); } - + /* If the auto-commit flag is set and this is the only active writer ** VM, then we do either a commit or rollback of the current transaction. ** From 7e60106d150571b8d8dd7f5d056add1d0383e2a0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 10 May 2024 16:28:35 +0000 Subject: [PATCH 0392/1030] Add an sqlite3FaultSim(300) call to the sqlite3ParserAddCleanup() routine for more precise simulation of OOM errors in that routine. FossilOrigin-Name: 1e8863909ac369e5e62e82e53b6e5a7cc6794100cef281ede00b0bb9bbc28594 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/prepare.c | 7 ++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d73b846391..a3741d8008 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Squelch\stwo\sOMIT-flag-related\swarnings\sreported\sin\s[forum:388243d9882067a9|forum\spost\s388243d9882067a9].\sNo\sfunctional\schanges. -D 2024-05-10T09:26:53.619 +C Add\san\ssqlite3FaultSim(300)\scall\sto\sthe\ssqlite3ParserAddCleanup()\sroutine\nfor\smore\sprecise\ssimulation\sof\sOOM\serrors\sin\sthat\sroutine. +D 2024-05-10T16:28:35.966 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -748,7 +748,7 @@ F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 -F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c +F src/prepare.c 32a8ff049785282acb5fa5cbe5f16ff7b2bfb17e12105606d4371f6f8549640f F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 8816212645e4e9bdf3cc2f2d298304f388d699f8fab47f3a5712ef5bbc5b6ccc @@ -2189,8 +2189,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 857f5d7fadce1cfe30b3468826f403f736cfecacb1eb6d3b858b01ea3cfd6ffc -R f270cbcd240352fa10729fed65c3c5a2 -U stephan -Z 06aaa7e94b8e9b6ffd39f925ee912fbc +P 1d6716054d7fc50df237996c3db30e5fb8e32acbf48cb8b9af472360515945c4 +R dbff3b0072db6fdc65663e31e8141b09 +T *branch * cleanup-testing +T *sym-cleanup-testing * +T -sym-trunk * +U drh +Z 3a787a3d44ce577cad9fbd2868c41f20 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a03c415635..d308dd1551 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1d6716054d7fc50df237996c3db30e5fb8e32acbf48cb8b9af472360515945c4 \ No newline at end of file +1e8863909ac369e5e62e82e53b6e5a7cc6794100cef281ede00b0bb9bbc28594 \ No newline at end of file diff --git a/src/prepare.c b/src/prepare.c index 87569ee91d..80c9fa71a3 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -633,7 +633,12 @@ void *sqlite3ParserAddCleanup( void (*xCleanup)(sqlite3*,void*), /* The cleanup routine */ void *pPtr /* Pointer to object to be cleaned up */ ){ - ParseCleanup *pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup)); + ParseCleanup *pCleanup; + if( sqlite3FaultSim(300) ){ + pCleanup = 0; + }else{ + pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup)); + } if( pCleanup ){ pCleanup->pNext = pParse->pCleanup; pParse->pCleanup = pCleanup; From 0e4afddadfb0843cc1d5acbab8b5affc9e14e106 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 10 May 2024 17:05:24 +0000 Subject: [PATCH 0393/1030] Improvements to the ".testctrl fault_install" command in the CLI. FossilOrigin-Name: 48b34ded82d0cec8a7dd67431f057b320b8c459b1b78c0fbf79bc2b355e85d4e --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/shell.c.in | 29 ++++++++++++++++++++++++----- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index a3741d8008..594fc55a50 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\ssqlite3FaultSim(300)\scall\sto\sthe\ssqlite3ParserAddCleanup()\sroutine\nfor\smore\sprecise\ssimulation\sof\sOOM\serrors\sin\sthat\sroutine. -D 2024-05-10T16:28:35.966 +C Improvements\sto\sthe\s".testctrl\sfault_install"\scommand\sin\sthe\sCLI. +D 2024-05-10T17:05:24.627 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -754,7 +754,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 8816212645e4e9bdf3cc2f2d298304f388d699f8fab47f3a5712ef5bbc5b6ccc F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ce81687d769b174aa547b8216a34fabc9cafc05789b615494ab78dc2c1e799fa -F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 +F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b6 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2189,11 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1d6716054d7fc50df237996c3db30e5fb8e32acbf48cb8b9af472360515945c4 -R dbff3b0072db6fdc65663e31e8141b09 -T *branch * cleanup-testing -T *sym-cleanup-testing * -T -sym-trunk * +P 1e8863909ac369e5e62e82e53b6e5a7cc6794100cef281ede00b0bb9bbc28594 +R 8cf25f7e0890ed58515d4489ba665230 U drh -Z 3a787a3d44ce577cad9fbd2868c41f20 +Z ccce4523fbbf328d3eae15c83868f55f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d308dd1551..888c859d2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1e8863909ac369e5e62e82e53b6e5a7cc6794100cef281ede00b0bb9bbc28594 \ No newline at end of file +48b34ded82d0cec8a7dd67431f057b320b8c459b1b78c0fbf79bc2b355e85d4e \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 2f91ac8ba1..2984853442 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -7940,7 +7940,10 @@ static struct { int iCnt; /* Trigger the fault only if iCnt is already zero */ int iInterval; /* Reset iCnt to this value after each fault */ int eVerbose; /* When to print output */ -} faultsim_state = {-1, 0, 0, 0, 0}; + int nHit; /* Number of hits seen so far */ + int nRepeat; /* Turn off after this many hits. 0 for never */ + int nSkip; /* Skip this many before first fault */ +} faultsim_state = {-1, 0, 0, 0, 0, 0, 0}; /* ** This is the fault-sim callback @@ -7949,8 +7952,8 @@ static int faultsim_callback(int iArg){ if( faultsim_state.iId>0 && faultsim_state.iId!=iArg ){ return SQLITE_OK; } - if( faultsim_state.iCnt>0 ){ - faultsim_state.iCnt--; + if( faultsim_state.iCnt ){ + if( faultsim_state.iCnt>0 ) faultsim_state.iCnt--; if( faultsim_state.eVerbose>=2 ){ oputf("FAULT-SIM id=%d no-fault (cnt=%d)\n", iArg, faultsim_state.iCnt); } @@ -7960,6 +7963,10 @@ static int faultsim_callback(int iArg){ oputf("FAULT-SIM id=%d returns %d\n", iArg, faultsim_state.iErr); } faultsim_state.iCnt = faultsim_state.iInterval; + faultsim_state.nHit++; + if( faultsim_state.nRepeat>0 && faultsim_state.nRepeat<=faultsim_state.nHit ){ + faultsim_state.iCnt = -1; + } return faultsim_state.iErr; } @@ -11121,17 +11128,23 @@ static int do_meta_command(char *zLine, ShellState *p){ if( cli_strcmp(z,"off")==0 ){ sqlite3_test_control(testctrl, 0); }else if( cli_strcmp(z,"on")==0 ){ - faultsim_state.iCnt = faultsim_state.iInterval; + faultsim_state.iCnt = faultsim_state.nSkip; if( faultsim_state.iErr==0 ) faultsim_state.iErr = 1; + faultsim_state.nHit = 0; sqlite3_test_control(testctrl, faultsim_callback); }else if( cli_strcmp(z,"reset")==0 ){ - faultsim_state.iCnt = faultsim_state.iInterval; + faultsim_state.iCnt = faultsim_state.nSkip; + faultsim_state.nHit = 0; + sqlite3_test_control(testctrl, faultsim_callback); }else if( cli_strcmp(z,"status")==0 ){ oputf("faultsim.iId: %d\n", faultsim_state.iId); oputf("faultsim.iErr: %d\n", faultsim_state.iErr); oputf("faultsim.iCnt: %d\n", faultsim_state.iCnt); + oputf("faultsim.nHit: %d\n", faultsim_state.nHit); oputf("faultsim.iInterval: %d\n", faultsim_state.iInterval); oputf("faultsim.eVerbose: %d\n", faultsim_state.eVerbose); + oputf("faultsim.nRepeat: %d\n", faultsim_state.nRepeat); + oputf("faultsim.nSkip: %d\n", faultsim_state.nSkip); }else if( cli_strcmp(z,"-v")==0 ){ if( faultsim_state.eVerbose<2 ) faultsim_state.eVerbose++; }else if( cli_strcmp(z,"-q")==0 ){ @@ -11142,6 +11155,10 @@ static int do_meta_command(char *zLine, ShellState *p){ faultsim_state.iErr = atoi(azArg[++kk]); }else if( cli_strcmp(z,"-interval")==0 && kk+1 Date: Fri, 10 May 2024 18:10:34 +0000 Subject: [PATCH 0394/1030] The sqlite3FaultSim(300) error from [1e8863909ac369e5] must be treated as an OOM, since it simulates an OOM. Also fix deferred deletion of Expr objects from [a53bdd311c4154fd] so that it does not corrupt the AST if an OOM occurs. FossilOrigin-Name: c623d9a51e0ae6b4a8e1186714d14e7aa3df55246e123323481f07f07749dea5 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 14 ++++++-------- src/prepare.c | 1 + src/sqliteInt.h | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 594fc55a50..7027d257c0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\s".testctrl\sfault_install"\scommand\sin\sthe\sCLI. -D 2024-05-10T17:05:24.627 +C The\ssqlite3FaultSim(300)\serror\sfrom\s[1e8863909ac369e5]\smust\sbe\streated\sas\nan\sOOM,\ssince\sit\ssimulates\san\sOOM.\s\sAlso\sfix\sdeferred\sdeletion\sof\sExpr\sobjects\nfrom\s[a53bdd311c4154fd]\sso\sthat\sit\sdoes\snot\scorrupt\sthe\sAST\sif\san\sOOM\soccurs. +D 2024-05-10T18:10:34.762 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -703,7 +703,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 3428b046cb731be83770eaa34317d0ae5bdf8f5e7c3a0abd57528d0a03a8f9f9 +F src/expr.c f7bad20d2f74005f1f876e7fbb627222ea28250e44b296b047403720c5c21818 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00 F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f @@ -748,7 +748,7 @@ F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 -F src/prepare.c 32a8ff049785282acb5fa5cbe5f16ff7b2bfb17e12105606d4371f6f8549640f +F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 8816212645e4e9bdf3cc2f2d298304f388d699f8fab47f3a5712ef5bbc5b6ccc @@ -758,7 +758,7 @@ F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 2eff008d787b12e76a906fd670dbe478dd1c7f2925fb59768e1f7d81c77a0600 +F src/sqliteInt.h adcf1cebb6fc00fc1f1329c00bb65ac36655736080acfd2071d84aa83a104afe F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1e8863909ac369e5e62e82e53b6e5a7cc6794100cef281ede00b0bb9bbc28594 -R 8cf25f7e0890ed58515d4489ba665230 +P 48b34ded82d0cec8a7dd67431f057b320b8c459b1b78c0fbf79bc2b355e85d4e +R cc5b938e964753c73fb58412e75a41dc U drh -Z ccce4523fbbf328d3eae15c83868f55f +Z 632961c30d31ace9e6d9239d4b43ad92 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 888c859d2c..e1839a2f8f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48b34ded82d0cec8a7dd67431f057b320b8c459b1b78c0fbf79bc2b355e85d4e \ No newline at end of file +c623d9a51e0ae6b4a8e1186714d14e7aa3df55246e123323481f07f07749dea5 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index a5272df7c9..27f89d659d 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1443,11 +1443,11 @@ void sqlite3ClearOnOrUsing(sqlite3 *db, OnOrUsing *p){ ** ** The pExpr might be deleted immediately on an OOM error. ** -** The deferred delete is (currently) implemented by adding the -** pExpr to the pParse->pConstExpr list with a register number of 0. +** Return 0 if the delete was successfully deferred. Return non-zero +** if the delete happened immediately because of an OOM. */ -void sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){ - sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr); +int sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){ + return 0==sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr); } /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the @@ -6681,9 +6681,8 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){ && pAggInfo->aCol[iAgg].pCExpr==pExpr ){ pExpr = sqlite3ExprDup(db, pExpr, 0); - if( pExpr ){ + if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){ pAggInfo->aCol[iAgg].pCExpr = pExpr; - sqlite3ExprDeferredDelete(pParse, pExpr); } } }else{ @@ -6692,9 +6691,8 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){ && pAggInfo->aFunc[iAgg].pFExpr==pExpr ){ pExpr = sqlite3ExprDup(db, pExpr, 0); - if( pExpr ){ + if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){ pAggInfo->aFunc[iAgg].pFExpr = pExpr; - sqlite3ExprDeferredDelete(pParse, pExpr); } } } diff --git a/src/prepare.c b/src/prepare.c index 80c9fa71a3..df9c98f743 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -636,6 +636,7 @@ void *sqlite3ParserAddCleanup( ParseCleanup *pCleanup; if( sqlite3FaultSim(300) ){ pCleanup = 0; + sqlite3OomFault(pParse->db); }else{ pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup)); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0da289d525..aa8bfc4b7b 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4856,7 +4856,7 @@ void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); void sqlite3ExprDelete(sqlite3*, Expr*); void sqlite3ExprDeleteGeneric(sqlite3*,void*); -void sqlite3ExprDeferredDelete(Parse*, Expr*); +int sqlite3ExprDeferredDelete(Parse*, Expr*); void sqlite3ExprUnmapAndDelete(Parse*, Expr*); ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); From e09e451a48f0e1ef74e15b3469f2dd78dee349a8 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 10 May 2024 18:15:03 +0000 Subject: [PATCH 0395/1030] Add a test for the fixes on this branch. FossilOrigin-Name: 716088d673b80446ea5f9cb83f6aad8a9ea2ec769d4894e02ab916930e4cf169 --- manifest | 13 +++++++------ manifest.uuid | 2 +- test/exprfault2.test | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 test/exprfault2.test diff --git a/manifest b/manifest index 7027d257c0..0baf00c3f8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssqlite3FaultSim(300)\serror\sfrom\s[1e8863909ac369e5]\smust\sbe\streated\sas\nan\sOOM,\ssince\sit\ssimulates\san\sOOM.\s\sAlso\sfix\sdeferred\sdeletion\sof\sExpr\sobjects\nfrom\s[a53bdd311c4154fd]\sso\sthat\sit\sdoes\snot\scorrupt\sthe\sAST\sif\san\sOOM\soccurs. -D 2024-05-10T18:10:34.762 +C Add\sa\stest\sfor\sthe\sfixes\son\sthis\sbranch. +D 2024-05-10T18:15:03.688 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1115,6 +1115,7 @@ F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac F test/expr.test 5c06696478212e5a04e04b043f993373f6f8e5ce5a80f5548a84703b123b6caa F test/expr2.test c27327ae9c017a7ff6280123f67aff496f912da74d78c888926d68b46ec75fd8 F test/exprfault.test da33606d799718e2f8e34efd0e5858884a1ad87f608774c552a7f5517cc27181 +F test/exprfault2.test c49e84273898969af5dbc4fe6a3f4335f14639799f343590336c9ddf84425965 F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9 F test/external_reader.test c7d34694f1b25c32d866f56ac80c1e29edddc42b4ef90cad589263ffac2cde0c F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79 @@ -2189,8 +2190,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48b34ded82d0cec8a7dd67431f057b320b8c459b1b78c0fbf79bc2b355e85d4e -R cc5b938e964753c73fb58412e75a41dc -U drh -Z 632961c30d31ace9e6d9239d4b43ad92 +P c623d9a51e0ae6b4a8e1186714d14e7aa3df55246e123323481f07f07749dea5 +R 19835e40d33408ef0911b62a1ca97162 +U dan +Z 94556ae52ccd512ae4690e06866d27a0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e1839a2f8f..465515fa0d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c623d9a51e0ae6b4a8e1186714d14e7aa3df55246e123323481f07f07749dea5 \ No newline at end of file +716088d673b80446ea5f9cb83f6aad8a9ea2ec769d4894e02ab916930e4cf169 \ No newline at end of file diff --git a/test/exprfault2.test b/test/exprfault2.test new file mode 100644 index 0000000000..acbead59f6 --- /dev/null +++ b/test/exprfault2.test @@ -0,0 +1,35 @@ +# 2024-05-11 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix exprfault2 + +do_execsql_test 1.0 { + CREATE TABLE t1(a,b,c,d,f,PRIMARY KEY(b,b)); + CREATE TABLE t2(x INT PRIMARY KEY, y, z); + CREATE TABLE t3(a,b,c,d,e,PRIMARY KEY(a,b))WITHOUT ROWID; +} +faultsim_save_and_close + + +do_faultsim_test 1 -faults oom-t* -prep { + faultsim_restore_and_reopen +} -body { + execsql { + UPDATE t3 SET (d,d,d,d, a )=(SELECT EXISTS(SELECT 1 NOT IN(SELECT EXISTS(SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t2 UNION SELECT (SELECT max( 1 IN(SELECT x NOT IN(SELECT 1 NOT IN(SELECT EXISTS(SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t2 UNION SELECT (SELECT max( (SELECT x NOT IN(SELECT 1 NOT IN(SELECT EXISTS(SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t2 UNION SELECT (SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t2 UNION SELECT x ORDER BY 1)))INTERSECT SELECT (SELECT 1 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) ORDERa)| (SELECT 1 x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) a)| (SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(ORDER BY sum((SELECT DISTINCT y FROM t2 UNION SELECT x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT x ORDER BY 1) ORDER BY 1) z)|9 AS blob) IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT DISTINCT y FROM t2 UNION SELECT x ORDER BY 1)))EXCEPT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) z) ORDER BY 1) IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT DISTINCT y FROM t2 UNION SELECT x ORDER BY 1)))INTERSECT SELECT (SELECT 1 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) ORDERa)| (SELECT 1 x ORDER BY 1)))EXCEPT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) a)| (SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT DISTINCT y FROM t2 UNION SELECT x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT x ORDER BY 1) ORDER BY 1) z)|9 AS blob) IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT DISTINCT y FROM t2 UNION SELECT x ORDER BY 1)))EXCEPT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) z) ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t2 UNION SELECT x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) ORDERa)| (SELECT 1 x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 5 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) ORDERa)| (SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(ORDER BY sum((SELECT DISTINCT y FROM t2 UNION SELECT x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT x ORDER BY 1) ORDER BY 1) z)| 1 AS blob) IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT DISTINCT y FROM t2 UNION SELECT x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t2 UNION SELECT d ORDER BY 1) ORDER BY 1) z)| (SELECT 1 IN(SELECT max( 1 IN(SELECT c ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t2 UNION SELECT x ORDER BY 1)))INTERSECT SELECT (SELECT 1 FROM t2 UNION SELECT x ORDER BY 1) ORDER BY 1) e)|9 AS blob) FROM t2 WHERE a Date: Sat, 11 May 2024 16:44:56 +0000 Subject: [PATCH 0396/1030] Add tests to bestindexC.test. No changes to code. FossilOrigin-Name: 58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- test/bestindexC.test | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index eceb5d9184..1c2904f809 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\saggregate\sfunction\sprocessing\sto\scorrectly\sdeal\swith\sOOMs\sinside\sof\nsqlite3ParserAddCleanup().\s\n(dbsqlfuzz\sb2d11ca70e55ee8bde48ae0b53fa3e9355812f95).\nAlso\sadd\simproved\stesting\ssupport\sby\scausing\ssqlite3FaultSim(300)\sto\nsimulate\san\sOOM\sinside\sof\ssqlite3ParserAddCleanup()\sand\sby\sadding\nimproved\sfault-sim\ssupport\sto\sthe\sCLI. -D 2024-05-10T18:24:15.938 +C Add\stests\sto\sbestindexC.test.\sNo\schanges\sto\scode. +D 2024-05-11T16:44:56.528 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -938,7 +938,7 @@ F test/bestindex8.test b63a4f171a2c83d481bb14c431a8b72e85d27b2ffdaa0435a95d58ca9 F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede39673a451a0 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce -F test/bestindexC.test c14a8c8639b6825b0efa1ae693f34ec04f41a46e3056e7063d6e0f46bf4ff692 +F test/bestindexC.test a2d4ab909e17bb58fe4d66a394460e713620c7b2964b450bc82216c171d264a2 F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -2190,9 +2190,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1d6716054d7fc50df237996c3db30e5fb8e32acbf48cb8b9af472360515945c4 716088d673b80446ea5f9cb83f6aad8a9ea2ec769d4894e02ab916930e4cf169 -R 19835e40d33408ef0911b62a1ca97162 -T +closed 716088d673b80446ea5f9cb83f6aad8a9ea2ec769d4894e02ab916930e4cf169 -U drh -Z 7c60328ccced7c5397c63b972a68b6fa +P c6fd70b3c23fa00eaac9286d4a67e5c8ac76f926c11c220250c34032647bedc1 +R da518a0d510ea768080aa36a2357bedd +U dan +Z 00211d5eb53202476ca10f2c5f60b56e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b3549e902d..1e5e1fe061 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c6fd70b3c23fa00eaac9286d4a67e5c8ac76f926c11c220250c34032647bedc1 \ No newline at end of file +58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5 \ No newline at end of file diff --git a/test/bestindexC.test b/test/bestindexC.test index 476ea39faa..708e56f774 100644 --- a/test/bestindexC.test +++ b/test/bestindexC.test @@ -173,6 +173,25 @@ do_execsql_test 3.6 { } {4 5 6 7 8} unset ::do_not_use_offset +#------------------------------------------------------------------------- +reset_db +proc vtab_command {lVal method args} { + switch -- $method { + xConnect { + error "not happy!" + } + } + + return {} +} + +register_tcl_module db +do_catchsql_test 4.0 { + CREATE VIRTUAL TABLE y1 USING tcl(vtab_command 1); +} {1 {not happy!}} +do_test 4.1 { + sqlite3_errcode db +} SQLITE_ERROR finish_test From 4f59d0964869e27daca41035125759e96142bc19 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 12 May 2024 00:26:08 +0000 Subject: [PATCH 0397/1030] Optimization in the implementation of OP_OpenRead and OP_OpenWrite FossilOrigin-Name: 3a256a1667b15702dc5048fdf2fdba9c1e551106ce8cf391360f156fab35ecc5 --- manifest | 16 +++++++++------- manifest.uuid | 2 +- src/vdbe.c | 30 +++++++++++++++--------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index eceb5d9184..3cb7a0d73a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\saggregate\sfunction\sprocessing\sto\scorrectly\sdeal\swith\sOOMs\sinside\sof\nsqlite3ParserAddCleanup().\s\n(dbsqlfuzz\sb2d11ca70e55ee8bde48ae0b53fa3e9355812f95).\nAlso\sadd\simproved\stesting\ssupport\sby\scausing\ssqlite3FaultSim(300)\sto\nsimulate\san\sOOM\sinside\sof\ssqlite3ParserAddCleanup()\sand\sby\sadding\nimproved\sfault-sim\ssupport\sto\sthe\sCLI. -D 2024-05-10T18:24:15.938 +C Optimization\sin\sthe\simplementation\sof\sOP_OpenRead\sand\sOP_OpenWrite +D 2024-05-12T00:26:08.975 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -823,7 +823,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 3b1793c5d2235ae89b01ef051a33d7d2ad3704c71799653b112686735ad401ff +F src/vdbe.c cddb27d049602441e635e5301d5c6301af287fd8298fa3cfd71fbd4497c80364 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -2190,9 +2190,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1d6716054d7fc50df237996c3db30e5fb8e32acbf48cb8b9af472360515945c4 716088d673b80446ea5f9cb83f6aad8a9ea2ec769d4894e02ab916930e4cf169 -R 19835e40d33408ef0911b62a1ca97162 -T +closed 716088d673b80446ea5f9cb83f6aad8a9ea2ec769d4894e02ab916930e4cf169 +P c6fd70b3c23fa00eaac9286d4a67e5c8ac76f926c11c220250c34032647bedc1 +R 94b8709f5c282eb8bc9897cb13e98353 +T *branch * faster-openread +T *sym-faster-openread * +T -sym-trunk * U drh -Z 7c60328ccced7c5397c63b972a68b6fa +Z 9b80a9cf5df794917ed8b64261d9c345 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b3549e902d..d67b982a54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c6fd70b3c23fa00eaac9286d4a67e5c8ac76f926c11c220250c34032647bedc1 \ No newline at end of file +3a256a1667b15702dc5048fdf2fdba9c1e551106ce8cf391360f156fab35ecc5 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index d8b471de2e..257c319c7e 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4324,23 +4324,23 @@ case OP_OpenWrite: if( pDb->pSchema->file_format < p->minWriteFileFormat ){ p->minWriteFileFormat = pDb->pSchema->file_format; } + if( pOp->p5 & OPFLAG_P2ISREG ){ + assert( p2>0 ); + assert( p2<=(u32)(p->nMem+1 - p->nCursor) ); + pIn2 = &aMem[p2]; + assert( memIsValid(pIn2) ); + assert( (pIn2->flags & MEM_Int)!=0 ); + sqlite3VdbeMemIntegerify(pIn2); + p2 = (int)pIn2->u.i; + /* The p2 value always comes from a prior OP_CreateBtree opcode and + ** that opcode will always set the p2 value to 2 or more or else fail. + ** If there were a failure, the prepared statement would have halted + ** before reaching this instruction. */ + assert( p2>=2 ); + } }else{ wrFlag = 0; - } - if( pOp->p5 & OPFLAG_P2ISREG ){ - assert( p2>0 ); - assert( p2<=(u32)(p->nMem+1 - p->nCursor) ); - assert( pOp->opcode==OP_OpenWrite ); - pIn2 = &aMem[p2]; - assert( memIsValid(pIn2) ); - assert( (pIn2->flags & MEM_Int)!=0 ); - sqlite3VdbeMemIntegerify(pIn2); - p2 = (int)pIn2->u.i; - /* The p2 value always comes from a prior OP_CreateBtree opcode and - ** that opcode will always set the p2 value to 2 or more or else fail. - ** If there were a failure, the prepared statement would have halted - ** before reaching this instruction. */ - assert( p2>=2 ); + assert( (pOp->p5 & OPFLAG_P2ISREG)==0 ); } if( pOp->p4type==P4_KEYINFO ){ pKeyInfo = pOp->p4.pKeyInfo; From 12b205c637804c43cd9c991d8583085a523698b4 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 13 May 2024 20:06:08 +0000 Subject: [PATCH 0398/1030] Allow existing fts5 tables to be dropped even if the associated tokenizer is not available. FossilOrigin-Name: 69ef47eeee8b53684c321393be34f03600694fbc86377f8720ff80307846aff6 --- ext/fts5/fts5Int.h | 22 ++++++------ ext/fts5/fts5_config.c | 58 +++++++++++++------------------- ext/fts5/fts5_main.c | 46 ++++++++++++++++++------- ext/fts5/test/fts5tokenizer.test | 43 +++++++++++++++++++++++ ext/fts5/test/fts5trigram2.test | 13 ++++++- manifest | 23 +++++++------ manifest.uuid | 2 +- 7 files changed, 139 insertions(+), 68 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 9beb26e056..f1a02c1841 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -142,6 +142,15 @@ struct Fts5Colset { */ typedef struct Fts5Config Fts5Config; +typedef struct Fts5TokenizerConfig Fts5TokenizerConfig; + +struct Fts5TokenizerConfig { + Fts5Tokenizer *pTok; + fts5_tokenizer *pTokApi; + const char **azArg; + int nArg; + int ePattern; /* FTS_PATTERN_XXX constant */ +}; /* ** An instance of the following structure encodes all information that can @@ -184,6 +193,7 @@ typedef struct Fts5Config Fts5Config; */ struct Fts5Config { sqlite3 *db; /* Database handle */ + Fts5Global *pGlobal; /* Global fts5 object for handle db */ char *zDb; /* Database holding FTS index (e.g. "main") */ char *zName; /* Name of FTS index */ int nCol; /* Number of columns */ @@ -199,10 +209,8 @@ struct Fts5Config { int bTokendata; /* "tokendata=" option value (dflt==0) */ int eDetail; /* FTS5_DETAIL_XXX value */ char *zContentExprlist; - Fts5Tokenizer *pTok; - fts5_tokenizer *pTokApi; + Fts5TokenizerConfig t; int bLock; /* True when table is preparing statement */ - int ePattern; /* FTS_PATTERN_XXX constant */ /* Values loaded from the %_config table */ int iVersion; /* fts5 file format 'version' */ @@ -597,13 +605,7 @@ struct Fts5Table { Fts5Index *pIndex; /* Full-text index */ }; -int sqlite3Fts5GetTokenizer( - Fts5Global*, - const char **azArg, - int nArg, - Fts5Config*, - char **pzErr -); +int sqlite3Fts5LoadTokenizer(Fts5Config *pConfig); Fts5Table *sqlite3Fts5TableFromCsrid(Fts5Global*, i64); diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index d2e8309cd2..32f52a6cab 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -298,12 +298,11 @@ static int fts5ConfigParseSpecial( if( sqlite3_strnicmp("tokenize", zCmd, nCmd)==0 ){ const char *p = (const char*)zArg; sqlite3_int64 nArg = strlen(zArg) + 1; - char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg); - char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2); - char *pSpace = pDel; + char **azArg = sqlite3Fts5MallocZero(&rc, (sizeof(char*) + 2) * nArg); - if( azArg && pSpace ){ - if( pConfig->pTok ){ + if( azArg ){ + char *pSpace = (char*)&azArg[nArg]; + if( pConfig->t.azArg ){ *pzErr = sqlite3_mprintf("multiple tokenize=... directives"); rc = SQLITE_ERROR; }else{ @@ -326,16 +325,14 @@ static int fts5ConfigParseSpecial( *pzErr = sqlite3_mprintf("parse error in tokenize directive"); rc = SQLITE_ERROR; }else{ - rc = sqlite3Fts5GetTokenizer(pGlobal, - (const char**)azArg, (int)nArg, pConfig, - pzErr - ); + pConfig->t.azArg = (const char**)azArg; + pConfig->t.nArg = nArg; + azArg = 0; } } } - sqlite3_free(azArg); - sqlite3_free(pDel); + return rc; } @@ -412,16 +409,6 @@ static int fts5ConfigParseSpecial( return SQLITE_ERROR; } -/* -** Allocate an instance of the default tokenizer ("simple") at -** Fts5Config.pTokenizer. Return SQLITE_OK if successful, or an SQLite error -** code if an error occurs. -*/ -static int fts5ConfigDefaultTokenizer(Fts5Global *pGlobal, Fts5Config *pConfig){ - assert( pConfig->pTok==0 && pConfig->pTokApi==0 ); - return sqlite3Fts5GetTokenizer(pGlobal, 0, 0, pConfig, 0); -} - /* ** Gobble up the first bareword or quoted word from the input buffer zIn. ** Return a pointer to the character immediately following the last in @@ -554,6 +541,7 @@ int sqlite3Fts5ConfigParse( *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config)); if( pRet==0 ) return SQLITE_NOMEM; memset(pRet, 0, sizeof(Fts5Config)); + pRet->pGlobal = pGlobal; pRet->db = db; pRet->iCookie = -1; @@ -640,13 +628,6 @@ int sqlite3Fts5ConfigParse( rc = SQLITE_ERROR; } - /* If a tokenizer= option was successfully parsed, the tokenizer has - ** already been allocated. Otherwise, allocate an instance of the default - ** tokenizer (unicode61) now. */ - if( rc==SQLITE_OK && pRet->pTok==0 ){ - rc = fts5ConfigDefaultTokenizer(pGlobal, pRet); - } - /* If no zContent option was specified, fill in the default values. */ if( rc==SQLITE_OK && pRet->zContent==0 ){ const char *zTail = 0; @@ -688,9 +669,10 @@ int sqlite3Fts5ConfigParse( void sqlite3Fts5ConfigFree(Fts5Config *pConfig){ if( pConfig ){ int i; - if( pConfig->pTok ){ - pConfig->pTokApi->xDelete(pConfig->pTok); + if( pConfig->t.pTok ){ + pConfig->t.pTokApi->xDelete(pConfig->t.pTok); } + sqlite3_free(pConfig->t.azArg); sqlite3_free(pConfig->zDb); sqlite3_free(pConfig->zName); for(i=0; inCol; i++){ @@ -765,10 +747,18 @@ int sqlite3Fts5Tokenize( void *pCtx, /* Context passed to xToken() */ int (*xToken)(void*, int, const char*, int, int, int) /* Callback */ ){ - if( pText==0 ) return SQLITE_OK; - return pConfig->pTokApi->xTokenize( - pConfig->pTok, pCtx, flags, pText, nText, xToken - ); + int rc = SQLITE_OK; + if( pText ){ + if( pConfig->t.pTok==0 ){ + rc = sqlite3Fts5LoadTokenizer(pConfig); + } + if( rc==SQLITE_OK ){ + rc = pConfig->t.pTokApi->xTokenize( + pConfig->t.pTok, pCtx, flags, pText, nText, xToken + ); + } + } + return rc; } /* diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index f609f7f34a..0155a27f4c 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -377,8 +377,12 @@ static int fts5InitVtab( assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 ); } if( rc==SQLITE_OK ){ + pConfig->pzErrmsg = pzErr; pTab->p.pConfig = pConfig; pTab->pGlobal = pGlobal; + if( bCreate ){ + rc = sqlite3Fts5LoadTokenizer(pConfig); + } } /* Open the index sub-system */ @@ -400,11 +404,8 @@ static int fts5InitVtab( /* Load the initial configuration */ if( rc==SQLITE_OK ){ - assert( pConfig->pzErrmsg==0 ); - pConfig->pzErrmsg = pzErr; rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); sqlite3Fts5IndexRollback(pTab->p.pIndex); - pConfig->pzErrmsg = 0; } if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ @@ -414,6 +415,7 @@ static int fts5InitVtab( rc = sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); } + if( pConfig ) pConfig->pzErrmsg = 0; if( rc!=SQLITE_OK ){ fts5FreeVtab(pTab); pTab = 0; @@ -481,10 +483,10 @@ static int fts5UsePatternMatch( ){ assert( FTS5_PATTERN_GLOB==SQLITE_INDEX_CONSTRAINT_GLOB ); assert( FTS5_PATTERN_LIKE==SQLITE_INDEX_CONSTRAINT_LIKE ); - if( pConfig->ePattern==FTS5_PATTERN_GLOB && p->op==FTS5_PATTERN_GLOB ){ + if( pConfig->t.ePattern==FTS5_PATTERN_GLOB && p->op==FTS5_PATTERN_GLOB ){ return 1; } - if( pConfig->ePattern==FTS5_PATTERN_LIKE + if( pConfig->t.ePattern==FTS5_PATTERN_LIKE && (p->op==FTS5_PATTERN_LIKE || p->op==FTS5_PATTERN_GLOB) ){ return 1; @@ -584,6 +586,14 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ return SQLITE_ERROR; } + if( pConfig->t.pTok==0 ){ + int rc; + pConfig->pzErrmsg = &pVTab->zErrMsg; + rc = sqlite3Fts5LoadTokenizer(pConfig); + pConfig->pzErrmsg = 0; + if( rc!=SQLITE_OK ) return rc; + } + idxStr = (char*)sqlite3_malloc(pInfo->nConstraint * 8 + 1); if( idxStr==0 ) return SQLITE_NOMEM; pInfo->idxStr = idxStr; @@ -626,6 +636,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ idxStr += strlen(&idxStr[iIdxStr]); pInfo->aConstraintUsage[i].argvIndex = ++iCons; assert( idxStr[iIdxStr]=='\0' ); + bSeenMatch = 1; }else if( bSeenEq==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol<0 ){ idxStr[iIdxStr++] = '='; bSeenEq = 1; @@ -2860,7 +2871,7 @@ static int fts5FindTokenizer( return rc; } -int sqlite3Fts5GetTokenizer( +int fts5GetTokenizer( Fts5Global *pGlobal, const char **azArg, int nArg, @@ -2877,26 +2888,37 @@ int sqlite3Fts5GetTokenizer( *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); }else{ rc = pMod->x.xCreate( - pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->pTok + pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->t.pTok ); - pConfig->pTokApi = &pMod->x; + pConfig->t.pTokApi = &pMod->x; if( rc!=SQLITE_OK ){ if( pzErr ) *pzErr = sqlite3_mprintf("error in tokenizer constructor"); }else{ - pConfig->ePattern = sqlite3Fts5TokenizerPattern( - pMod->x.xCreate, pConfig->pTok + pConfig->t.ePattern = sqlite3Fts5TokenizerPattern( + pMod->x.xCreate, pConfig->t.pTok ); } } if( rc!=SQLITE_OK ){ - pConfig->pTokApi = 0; - pConfig->pTok = 0; + pConfig->t.pTokApi = 0; + pConfig->t.pTok = 0; } return rc; } +/* +** Attempt to instantiate the tokenizer. +*/ +int sqlite3Fts5LoadTokenizer(Fts5Config *pConfig){ + return fts5GetTokenizer( + pConfig->pGlobal, pConfig->t.azArg, pConfig->t.nArg, + pConfig, pConfig->pzErrmsg + ); +} + + static void fts5ModuleDestroy(void *pCtx){ Fts5TokenizerModule *pTok, *pNextTok; Fts5Auxiliary *pAux, *pNextAux; diff --git a/ext/fts5/test/fts5tokenizer.test b/ext/fts5/test/fts5tokenizer.test index 27370657ed..f469a98888 100644 --- a/ext/fts5/test/fts5tokenizer.test +++ b/ext/fts5/test/fts5tokenizer.test @@ -300,5 +300,48 @@ set ::flags [list] do_execsql_test 9.5.1 { SELECT * FROM t1('"abc xyz*"'); } {} do_test 9.5.2 { set ::flags } {query} +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 10.1 { + CREATE VIRTUAL TABLE x1 USING fts5(x, tokenize=unicode61); + PRAGMA writable_schema = 1; + UPDATE sqlite_schema + SET sql = 'CREATE VIRTUAL TABLE x1 USING fts5(x, tokenize="unicode61 error");' + WHERE name = 'x1'; +} + +db close +sqlite3 db test.db + +do_catchsql_test 10.2 { + SELECT * FROM x1 +} {1 {error in tokenizer constructor}} + +do_catchsql_test 10.3 { + INSERT INTO x1 VALUES('abc'); +} {1 {error in tokenizer constructor}} + +do_execsql_test 10.4 { + PRAGMA writable_schema = 1; + UPDATE sqlite_schema + SET sql = 'CREATE VIRTUAL TABLE x1 USING fts5(x, tokenize="nosuch error");' + WHERE name = 'x1'; +} + +db close +sqlite3 db test.db + +do_catchsql_test 10.5 { + SELECT * FROM x1 +} {1 {no such tokenizer: nosuch}} +do_catchsql_test 10.6 { + INSERT INTO x1 VALUES('abc'); +} {1 {no such tokenizer: nosuch}} + +do_execsql_test 10.7 { + DROP TABLE x1; + SELECT * FROM sqlite_schema; +} finish_test diff --git a/ext/fts5/test/fts5trigram2.test b/ext/fts5/test/fts5trigram2.test index f5beae5b28..00f6d43952 100644 --- a/ext/fts5/test/fts5trigram2.test +++ b/ext/fts5/test/fts5trigram2.test @@ -101,9 +101,20 @@ do_execsql_test 4.0 { CREATE VIRTUAL TABLE t4 USING fts5(z, tokenize=trigram); } {} -breakpoint do_execsql_test 4.1 { INSERT INTO t4 VALUES('ABCD'); + INSERT INTO t4 VALUES('DEFG'); } {} +db close +sqlite3 db test.db + +do_eqp_test 4.1 { + SELECT rowid FROM t4 WHERE z LIKE '%abc%' +} {VIRTUAL TABLE INDEX 0:L0} + +do_execsql_test 4.2 { + SELECT rowid FROM t4 WHERE z LIKE '%abc%' +} {1} + finish_test diff --git a/manifest b/manifest index 1c2904f809..3c967f0f90 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\sbestindexC.test.\sNo\schanges\sto\scode. -D 2024-05-11T16:44:56.528 +C Allow\sexisting\sfts5\stables\sto\sbe\sdropped\seven\sif\sthe\sassociated\stokenizer\sis\snot\savailable. +D 2024-05-13T20:06:08.273 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,14 +93,14 @@ F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6d F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h 8856e11a5f0269cd346754cea0765efe8089635b80cad3222e8bfdb08cd5348a -F ext/fts5/fts5Int.h defa43c0932265138ee910ca416e6baccf8b774e0f3d610e74be1ab2880e9834 +F ext/fts5/fts5Int.h 965ded9eedfa4bbe6b39048d4b0cce804a13ec954f11a088d1205a48703ce03f F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 8072a207034b51ae9b7694121d1b5715c794e94b275e088f70ae532378ca5cdf +F ext/fts5/fts5_config.c 74093394dc26750becc302922e5fe308a8597a70e6e83e66c892242952468163 F ext/fts5/fts5_expr.c e91156ebdcc08d837f4f324168f69f3c0d7fdef0e521fd561efb48ef3297b696 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c d68bd9533d5a638b7f6fae61c3cb0a15257dcdcccedaf3d0b3c9f55940c85048 +F ext/fts5/fts5_main.c 942fea921d67f75f745d02bf383e5b949bf96a8b78bcfffca40f06439d252fae F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -227,10 +227,10 @@ F ext/fts5/test/fts5synonym.test 1651815b8008de170e8e600dcacc17521d765482ea8f074 F ext/fts5/test/fts5synonym2.test e2f6ff68c4fbe12a866a3a87510f553d9dac99bcb74c10b56487c4c0a562fcf5 F ext/fts5/test/fts5tok1.test 1f7817499f5971450d8c4a652114b3d833393c8134e32422d0af27884ffe9cef F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 -F ext/fts5/test/fts5tokenizer.test ac3c9112b263a639fb0508ae73a3ee886bf4866d2153771a8e8a20c721305a43 +F ext/fts5/test/fts5tokenizer.test e5ff1fa93ae267592ad2280ae545133ac24d19cf44116c736e7ece9c02285b5b F ext/fts5/test/fts5tokenizer2.test cb5428c7cfb3b6a74b7adfcde65506e329112003e8dffa7501d01c2d18d02569 F ext/fts5/test/fts5trigram.test 6c4e37864f3e7d90673db5563d9736d7e40080ab94d10ebdffa94c1b77941da0 -F ext/fts5/test/fts5trigram2.test 9fe4207f8a4241747aff1005258b564958588d21bfd240d6cd4c2e955d31c156 +F ext/fts5/test/fts5trigram2.test c91f0a94f7e1ff859682228646abeab4c0eba2effc46af2cbc8f0f48b05a0566 F ext/fts5/test/fts5ubsan.test 783d5a8d13ebfa169e634940228db54540780e3ba7a87ad1e4510e61440bf64b F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 F ext/fts5/test/fts5unicode.test 17056f4efe6b0a5d4f41fdf7a7dc9af2873004562eaa899d40633b93dc95f5a9 @@ -2190,8 +2190,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c6fd70b3c23fa00eaac9286d4a67e5c8ac76f926c11c220250c34032647bedc1 -R da518a0d510ea768080aa36a2357bedd +P 58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5 +R 8cd6e7131b6ecbfb841a3c6de5597a39 +T *branch * fts5-delay-tokenizer +T *sym-fts5-delay-tokenizer * +T -sym-trunk * U dan -Z 00211d5eb53202476ca10f2c5f60b56e +Z f97ec1a719d45c2730606c10145cb9ed # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e5e1fe061..a91811beb8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5 \ No newline at end of file +69ef47eeee8b53684c321393be34f03600694fbc86377f8720ff80307846aff6 \ No newline at end of file From 32ca0dbcdff617fb4fe15a454191e74a8edce599 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 14 May 2024 17:16:09 +0000 Subject: [PATCH 0399/1030] Have fts5 tables delay initializing the tokenizer until it is first used in all cases where the tokenizer is not "trigram". FossilOrigin-Name: ca4fdcb8ae95d2a61236b949f852d2bf25ea2dbbff7eedafbd8eb84e8fd96687 --- ext/fts5/fts5Int.h | 1 + ext/fts5/fts5_expr.c | 2 +- ext/fts5/fts5_main.c | 10 +--------- ext/fts5/fts5_tokenize.c | 10 ++++++++++ ext/fts5/fts5_vocab.c | 2 +- ext/fts5/test/fts5tokenizer.test | 31 +++++++++++++++++++++++++++++-- manifest | 25 +++++++++++-------------- manifest.uuid | 2 +- 8 files changed, 55 insertions(+), 28 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index f1a02c1841..0ed291c955 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -868,6 +868,7 @@ int sqlite3Fts5TokenizerPattern( int (*xCreate)(void*, const char**, int, Fts5Tokenizer**), Fts5Tokenizer *pTok ); +int sqlite3Fts5TokenizerPreload(Fts5TokenizerConfig*); /* ** End of interface to code in fts5_tokenizer.c. **************************************************************************/ diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 05c1b59c14..7180e22f8a 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -324,7 +324,7 @@ int sqlite3Fts5ExprNew( } sqlite3_free(sParse.apPhrase); - *pzErr = sParse.zErr; + if( 0==*pzErr ) *pzErr = sParse.zErr; return sParse.rc; } diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 0155a27f4c..384fdc1c19 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -380,7 +380,7 @@ static int fts5InitVtab( pConfig->pzErrmsg = pzErr; pTab->p.pConfig = pConfig; pTab->pGlobal = pGlobal; - if( bCreate ){ + if( bCreate || sqlite3Fts5TokenizerPreload(&pConfig->t) ){ rc = sqlite3Fts5LoadTokenizer(pConfig); } } @@ -586,14 +586,6 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ return SQLITE_ERROR; } - if( pConfig->t.pTok==0 ){ - int rc; - pConfig->pzErrmsg = &pVTab->zErrMsg; - rc = sqlite3Fts5LoadTokenizer(pConfig); - pConfig->pzErrmsg = 0; - if( rc!=SQLITE_OK ) return rc; - } - idxStr = (char*)sqlite3_malloc(pInfo->nConstraint * 8 + 1); if( idxStr==0 ) return SQLITE_NOMEM; pInfo->idxStr = idxStr; diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index f12056170f..3e9fdff3eb 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -1428,6 +1428,16 @@ int sqlite3Fts5TokenizerPattern( return FTS5_PATTERN_NONE; } +/* +** Return true if the tokenizer described by p->azArg[] is the trigram +** tokenizer. This tokenizer needs to be loaded before xBestIndex is +** called for the first time in order to correctly handle LIKE/GLOB. +*/ +int sqlite3Fts5TokenizerPreload(Fts5TokenizerConfig *p){ + return (p->nArg>=1 && 0==sqlite3_stricmp(p->azArg[0], "trigram")); +} + + /* ** Register all built-in tokenizers with FTS5. */ diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index 4782d0fb94..086ef42e09 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -365,7 +365,7 @@ static int fts5VocabOpenMethod( if( rc==SQLITE_OK ){ pVTab->zErrMsg = sqlite3_mprintf( "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl - ); + ); rc = SQLITE_ERROR; } }else{ diff --git a/ext/fts5/test/fts5tokenizer.test b/ext/fts5/test/fts5tokenizer.test index f469a98888..7497024dca 100644 --- a/ext/fts5/test/fts5tokenizer.test +++ b/ext/fts5/test/fts5tokenizer.test @@ -315,7 +315,7 @@ db close sqlite3 db test.db do_catchsql_test 10.2 { - SELECT * FROM x1 + SELECT * FROM x1('abc'); } {1 {error in tokenizer constructor}} do_catchsql_test 10.3 { @@ -333,7 +333,7 @@ db close sqlite3 db test.db do_catchsql_test 10.5 { - SELECT * FROM x1 + SELECT * FROM x1('abc'); } {1 {no such tokenizer: nosuch}} do_catchsql_test 10.6 { INSERT INTO x1 VALUES('abc'); @@ -344,4 +344,31 @@ do_execsql_test 10.7 { SELECT * FROM sqlite_schema; } +reset_db +do_execsql_test 10.8 { + CREATE VIRTUAL TABLE x1 USING fts5(x, tokenize=unicode61); + INSERT INTO x1 VALUES('a b c'), ('d e f'), ('a b c'); + CREATE VIRTUAL TABLE x1v USING fts5vocab(x1, row); + + PRAGMA writable_schema = 1; + UPDATE sqlite_schema + SET sql = 'CREATE VIRTUAL TABLE x1 USING fts5(x, tokenize=simplify);' + WHERE name = 'x1'; +} + +do_execsql_test 10.9 { + SELECT * FROM x1v +} { + a 2 2 b 2 2 c 2 2 d 1 1 e 1 1 f 1 1 +} + +db close +sqlite3 db test.db + +do_execsql_test 10.10 { + SELECT * FROM x1v +} { + a 2 2 b 2 2 c 2 2 d 1 1 e 1 1 f 1 1 +} + finish_test diff --git a/manifest b/manifest index 3c967f0f90..e1799ea541 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sexisting\sfts5\stables\sto\sbe\sdropped\seven\sif\sthe\sassociated\stokenizer\sis\snot\savailable. -D 2024-05-13T20:06:08.273 +C Have\sfts5\stables\sdelay\sinitializing\sthe\stokenizer\suntil\sit\sis\sfirst\sused\sin\sall\scases\swhere\sthe\stokenizer\sis\snot\s"trigram". +D 2024-05-14T17:16:09.294 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,22 +93,22 @@ F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6d F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h 8856e11a5f0269cd346754cea0765efe8089635b80cad3222e8bfdb08cd5348a -F ext/fts5/fts5Int.h 965ded9eedfa4bbe6b39048d4b0cce804a13ec954f11a088d1205a48703ce03f +F ext/fts5/fts5Int.h 407ee36addad0ae6df5d37a811f0bd509ab6708b29640884ed5c7509e5f75143 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 74093394dc26750becc302922e5fe308a8597a70e6e83e66c892242952468163 -F ext/fts5/fts5_expr.c e91156ebdcc08d837f4f324168f69f3c0d7fdef0e521fd561efb48ef3297b696 +F ext/fts5/fts5_expr.c a84df51a1d178fe38a89c0feb9ee6da3e5b98d204dde4d241fc8115464987d7a F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c 942fea921d67f75f745d02bf383e5b949bf96a8b78bcfffca40f06439d252fae +F ext/fts5/fts5_main.c dc6938b7233e9d88b3612fe2e88ce0a62130c43083be59beab8e6f01aa496689 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b -F ext/fts5/fts5_tokenize.c 83cfcede3898001cab84432a36ce1503e3080cf9b1c682b022ec82e267ea4c13 +F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be F ext/fts5/fts5_unicode2.c eca63dbc797f8ff0572e97caf4631389c0ab900d6364861b915bdd4735973f00 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 -F ext/fts5/fts5_vocab.c 209e0c151e108d5f3621fa24b91e9b02f3750ee6c3f9ccec312df39481b68a09 +F ext/fts5/fts5_vocab.c 00a098ee63290d7f6e3711f14e56f0d77f3a7c07c0a3909843fcf9826aea5b5f F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 3378732aae2a7d9a4b9b5c40bde678d4259ca16bd490883325aecc4747bcb384 @@ -227,7 +227,7 @@ F ext/fts5/test/fts5synonym.test 1651815b8008de170e8e600dcacc17521d765482ea8f074 F ext/fts5/test/fts5synonym2.test e2f6ff68c4fbe12a866a3a87510f553d9dac99bcb74c10b56487c4c0a562fcf5 F ext/fts5/test/fts5tok1.test 1f7817499f5971450d8c4a652114b3d833393c8134e32422d0af27884ffe9cef F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 -F ext/fts5/test/fts5tokenizer.test e5ff1fa93ae267592ad2280ae545133ac24d19cf44116c736e7ece9c02285b5b +F ext/fts5/test/fts5tokenizer.test abeb8b2d00415e5c8eae48d2dcb91357b7f7e1fddbb2b650f00b589a7bea9659 F ext/fts5/test/fts5tokenizer2.test cb5428c7cfb3b6a74b7adfcde65506e329112003e8dffa7501d01c2d18d02569 F ext/fts5/test/fts5trigram.test 6c4e37864f3e7d90673db5563d9736d7e40080ab94d10ebdffa94c1b77941da0 F ext/fts5/test/fts5trigram2.test c91f0a94f7e1ff859682228646abeab4c0eba2effc46af2cbc8f0f48b05a0566 @@ -2190,11 +2190,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5 -R 8cd6e7131b6ecbfb841a3c6de5597a39 -T *branch * fts5-delay-tokenizer -T *sym-fts5-delay-tokenizer * -T -sym-trunk * +P 69ef47eeee8b53684c321393be34f03600694fbc86377f8720ff80307846aff6 +R db8162066c5e98d7999ebd78f85cf216 U dan -Z f97ec1a719d45c2730606c10145cb9ed +Z 6313824362f7fdc689bb0b31fedc6732 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a91811beb8..ec9f975d50 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69ef47eeee8b53684c321393be34f03600694fbc86377f8720ff80307846aff6 \ No newline at end of file +ca4fdcb8ae95d2a61236b949f852d2bf25ea2dbbff7eedafbd8eb84e8fd96687 \ No newline at end of file From 433af7ab9384f30f862911fd803985b0416ad005 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 14 May 2024 19:09:54 +0000 Subject: [PATCH 0400/1030] Avoid calculating the value of the "cnt" column for fts5vocab(row) queries that do not use it. FossilOrigin-Name: c0c91e306c252ce1b398e92ab958e2a3de0fc43db05cfdffc548380654fc9f13 --- ext/fts5/fts5_vocab.c | 18 +++++++++++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index 086ef42e09..f0730ff389 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -64,6 +64,7 @@ struct Fts5VocabCursor { int nLeTerm; /* Size of zLeTerm in bytes */ char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */ + int colUsed; /* Copy of sqlite3_index_info.colUsed */ /* These are used by 'col' tables only */ int iCol; @@ -90,9 +91,11 @@ struct Fts5VocabCursor { /* ** Bits for the mask used as the idxNum value by xBestIndex/xFilter. */ -#define FTS5_VOCAB_TERM_EQ 0x01 -#define FTS5_VOCAB_TERM_GE 0x02 -#define FTS5_VOCAB_TERM_LE 0x04 +#define FTS5_VOCAB_TERM_EQ 0x0100 +#define FTS5_VOCAB_TERM_GE 0x0200 +#define FTS5_VOCAB_TERM_LE 0x0400 + +#define FTS5_VOCAB_COLUSED_MASK 0xFF /* @@ -269,11 +272,13 @@ static int fts5VocabBestIndexMethod( int iTermEq = -1; int iTermGe = -1; int iTermLe = -1; - int idxNum = 0; + int idxNum = (int)pInfo->colUsed; int nArg = 0; UNUSED_PARAM(pUnused); + assert( (pInfo->colUsed & FTS5_VOCAB_COLUSED_MASK)==pInfo->colUsed ); + for(i=0; inConstraint; i++){ struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; if( p->usable==0 ) continue; @@ -525,7 +530,9 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ switch( pTab->eType ){ case FTS5_VOCAB_ROW: - if( eDetail==FTS5_DETAIL_FULL ){ + /* Do not bother counting the number of instances if the "cnt" + ** column is not being read (according to colUsed). */ + if( eDetail==FTS5_DETAIL_FULL && (pCsr->colUsed & 0x04) ){ while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ pCsr->aCnt[0]++; } @@ -625,6 +632,7 @@ static int fts5VocabFilterMethod( if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++]; if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++]; if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++]; + pCsr->colUsed = (idxNum & FTS5_VOCAB_COLUSED_MASK); if( pEq ){ zTerm = (const char *)sqlite3_value_text(pEq); diff --git a/manifest b/manifest index e1799ea541..e40addb45d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sfts5\stables\sdelay\sinitializing\sthe\stokenizer\suntil\sit\sis\sfirst\sused\sin\sall\scases\swhere\sthe\stokenizer\sis\snot\s"trigram". -D 2024-05-14T17:16:09.294 +C Avoid\scalculating\sthe\svalue\sof\sthe\s"cnt"\scolumn\sfor\sfts5vocab(row)\squeries\sthat\sdo\snot\suse\sit. +D 2024-05-14T19:09:54.416 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -108,7 +108,7 @@ F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be F ext/fts5/fts5_unicode2.c eca63dbc797f8ff0572e97caf4631389c0ab900d6364861b915bdd4735973f00 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 -F ext/fts5/fts5_vocab.c 00a098ee63290d7f6e3711f14e56f0d77f3a7c07c0a3909843fcf9826aea5b5f +F ext/fts5/fts5_vocab.c faa8c6d8e0102037694165734a46b94d06f4460bde797af7486ed62c05764e35 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 3378732aae2a7d9a4b9b5c40bde678d4259ca16bd490883325aecc4747bcb384 @@ -2190,8 +2190,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 69ef47eeee8b53684c321393be34f03600694fbc86377f8720ff80307846aff6 -R db8162066c5e98d7999ebd78f85cf216 +P ca4fdcb8ae95d2a61236b949f852d2bf25ea2dbbff7eedafbd8eb84e8fd96687 +R 17e05953d472a335ac30c411c88ba602 U dan -Z 6313824362f7fdc689bb0b31fedc6732 +Z 6157f839a4ddd69a6600b93afee6568d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ec9f975d50..125d507b0d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ca4fdcb8ae95d2a61236b949f852d2bf25ea2dbbff7eedafbd8eb84e8fd96687 \ No newline at end of file +c0c91e306c252ce1b398e92ab958e2a3de0fc43db05cfdffc548380654fc9f13 \ No newline at end of file From a0693f21fc90ece0061e7307b657d29fa37fb233 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 14 May 2024 19:41:19 +0000 Subject: [PATCH 0401/1030] Optimize queries against fts5vocab(row) tables that do use the "cnt" column. FossilOrigin-Name: 96a591c202cb4218999ece3de063bf466b6fd81bd23383893f3913ecb52dda36 --- ext/fts5/fts5_vocab.c | 12 ++++++++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index f0730ff389..fb280567f4 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -533,8 +533,16 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ /* Do not bother counting the number of instances if the "cnt" ** column is not being read (according to colUsed). */ if( eDetail==FTS5_DETAIL_FULL && (pCsr->colUsed & 0x04) ){ - while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ - pCsr->aCnt[0]++; + while( iPosaCnt[] */ + pCsr->aCnt[0]++; + } } } pCsr->aDoc[0]++; diff --git a/manifest b/manifest index e40addb45d..ce12661dbc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\scalculating\sthe\svalue\sof\sthe\s"cnt"\scolumn\sfor\sfts5vocab(row)\squeries\sthat\sdo\snot\suse\sit. -D 2024-05-14T19:09:54.416 +C Optimize\squeries\sagainst\sfts5vocab(row)\stables\sthat\sdo\suse\sthe\s"cnt"\scolumn. +D 2024-05-14T19:41:19.118 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -108,7 +108,7 @@ F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be F ext/fts5/fts5_unicode2.c eca63dbc797f8ff0572e97caf4631389c0ab900d6364861b915bdd4735973f00 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 -F ext/fts5/fts5_vocab.c faa8c6d8e0102037694165734a46b94d06f4460bde797af7486ed62c05764e35 +F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 3378732aae2a7d9a4b9b5c40bde678d4259ca16bd490883325aecc4747bcb384 @@ -2190,8 +2190,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ca4fdcb8ae95d2a61236b949f852d2bf25ea2dbbff7eedafbd8eb84e8fd96687 -R 17e05953d472a335ac30c411c88ba602 +P c0c91e306c252ce1b398e92ab958e2a3de0fc43db05cfdffc548380654fc9f13 +R c8ee37ea6d4a33968236083c174d19e7 U dan -Z 6157f839a4ddd69a6600b93afee6568d +Z 493cbd0a2ca537422c58bc5b9554c10a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 125d507b0d..84c463d5a0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c0c91e306c252ce1b398e92ab958e2a3de0fc43db05cfdffc548380654fc9f13 \ No newline at end of file +96a591c202cb4218999ece3de063bf466b6fd81bd23383893f3913ecb52dda36 \ No newline at end of file From 9a1a4822e8f7d7483d71733ecf13d0d1e3e2335f Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 15 May 2024 15:06:27 +0000 Subject: [PATCH 0402/1030] If there is no data available for a field in a corrupted record, but the type is available, have the recovery extension substitute 0, 0.0, '' or X'' instead of a NULL value. FossilOrigin-Name: 8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d --- ext/recover/dbdata.c | 118 +++++++++++++++++-------------- ext/recover/recover1.test | 15 +++- ext/recover/recovercorrupt4.test | 58 +++++++++++++++ manifest | 15 ++-- manifest.uuid | 2 +- 5 files changed, 145 insertions(+), 63 deletions(-) create mode 100644 ext/recover/recovercorrupt4.test diff --git a/ext/recover/dbdata.c b/ext/recover/dbdata.c index 1905e68813..a999f1a853 100644 --- a/ext/recover/dbdata.c +++ b/ext/recover/dbdata.c @@ -466,63 +466,75 @@ static void dbdataValue( u8 *pData, sqlite3_int64 nData ){ - if( eType>=0 && dbdataValueBytes(eType)<=nData ){ - switch( eType ){ - case 0: - case 10: - case 11: - sqlite3_result_null(pCtx); - break; - - case 8: - sqlite3_result_int(pCtx, 0); - break; - case 9: - sqlite3_result_int(pCtx, 1); - break; - - case 1: case 2: case 3: case 4: case 5: case 6: case 7: { - sqlite3_uint64 v = (signed char)pData[0]; - pData++; - switch( eType ){ - case 7: - case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; - case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; - case 4: v = (v<<8) + pData[0]; pData++; - case 3: v = (v<<8) + pData[0]; pData++; - case 2: v = (v<<8) + pData[0]; pData++; - } - - if( eType==7 ){ - double r; - memcpy(&r, &v, sizeof(r)); - sqlite3_result_double(pCtx, r); - }else{ - sqlite3_result_int64(pCtx, (sqlite3_int64)v); + if( eType>=0 ){ + if( dbdataValueBytes(eType)<=nData ){ + switch( eType ){ + case 0: + case 10: + case 11: + sqlite3_result_null(pCtx); + break; + + case 8: + sqlite3_result_int(pCtx, 0); + break; + case 9: + sqlite3_result_int(pCtx, 1); + break; + + case 1: case 2: case 3: case 4: case 5: case 6: case 7: { + sqlite3_uint64 v = (signed char)pData[0]; + pData++; + switch( eType ){ + case 7: + case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; + case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; + case 4: v = (v<<8) + pData[0]; pData++; + case 3: v = (v<<8) + pData[0]; pData++; + case 2: v = (v<<8) + pData[0]; pData++; + } + + if( eType==7 ){ + double r; + memcpy(&r, &v, sizeof(r)); + sqlite3_result_double(pCtx, r); + }else{ + sqlite3_result_int64(pCtx, (sqlite3_int64)v); + } + break; } - break; - } - - default: { - int n = ((eType-12) / 2); - if( eType % 2 ){ - switch( enc ){ -#ifndef SQLITE_OMIT_UTF16 - case SQLITE_UTF16BE: - sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT); - break; - case SQLITE_UTF16LE: - sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT); - break; -#endif - default: - sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT); - break; + + default: { + int n = ((eType-12) / 2); + if( eType % 2 ){ + switch( enc ){ + #ifndef SQLITE_OMIT_UTF16 + case SQLITE_UTF16BE: + sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT); + break; + case SQLITE_UTF16LE: + sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT); + break; + #endif + default: + sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT); + break; + } + }else{ + sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT); } - }else{ - sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT); } } + }else{ + if( eType==7 ){ + sqlite3_result_double(pCtx, 0.0); + }else if( eType<7 ){ + sqlite3_result_int(pCtx, 0); + }else if( eType%2 ){ + sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC); + }else{ + sqlite3_result_blob(pCtx, "", 0, SQLITE_STATIC); + } } } } diff --git a/ext/recover/recover1.test b/ext/recover/recover1.test index 070dd03d69..11a43780d9 100644 --- a/ext/recover/recover1.test +++ b/ext/recover/recover1.test @@ -342,7 +342,7 @@ foreach enc {utf8 utf16 utf16le utf16be} { DELETE FROM sqlite_schema WHERE name='t1'; } - proc my_sql_hook {sql} { + proc my_sql_hook2 {sql} { if {[string match "INSERT INTO lostandfound*" $sql]} { lappend ::script $sql } @@ -350,7 +350,7 @@ foreach enc {utf8 utf16 utf16le utf16be} { } do_test 18.$enc.2 { set ::script [list] - set R [sqlite3_recover_init_sql db main my_sql_hook] + set R [sqlite3_recover_init_sql db main my_sql_hook2] $R config lostandfound lostandfound $R run $R finish @@ -358,7 +358,18 @@ foreach enc {utf8 utf16 utf16le utf16be} { } {{INSERT INTO lostandfound VALUES(2, 2, 2, 1, 'abc', 'def')}} } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 19.0 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); + INSERT INTO t1 VALUES(1, 'one'); + INSERT INTO t1 VALUES(2, 'two'); + + ALTER TABLE t1 ADD COLUMN c NOT NULL DEFAULT 13; + INSERT INTO t1 VALUES(3, 'three', 'hello world'); +} +do_recover_test 19.1 diff --git a/ext/recover/recovercorrupt4.test b/ext/recover/recovercorrupt4.test new file mode 100644 index 0000000000..53d691fbc4 --- /dev/null +++ b/ext/recover/recovercorrupt4.test @@ -0,0 +1,58 @@ +# 2024 May 15 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +source [file join [file dirname [info script]] recover_common.tcl] +set testprefix recovercorrupt4 + +database_may_be_corrupt + +do_execsql_test 1.0 { + CREATE TABLE rows(indexed INTEGER NOT NULL, unindexed INTEGER NOT NULL, filler BLOB NOT NULL DEFAULT 13); + -- CREATE UNIQUE INDEX rows_index ON rows(indexed); + INSERT INTO rows(indexed, unindexed, filler) VALUES(1, 1, x'31'); + INSERT INTO rows(indexed, unindexed, filler) VALUES(2, 2, x'32'); + INSERT INTO rows(indexed, unindexed, filler) VALUES(4, 4, x'34'); + INSERT INTO rows(indexed, unindexed, filler) VALUES(8, 8, randomblob(2048)); +} + +db close + +do_test 1.1 { + set sz [expr [file size test.db] - 1024] + set fd [open test.db] + fconfigure $fd -encoding binary -translation binary + + set data [read $fd $sz] + set fd2 [open test.db2 w] + fconfigure $fd2 -encoding binary -translation binary + puts -nonewline $fd2 $data + close $fd2 + set {} {} +} {} + +do_test 1.2 { + forcedelete test.db3 + sqlite3 db test.db2 + set R [sqlite3_recover_init db main test.db3] + $R run + $R finish +} {} + +do_test 1.3 { + sqlite3 db test.db3 + execsql { + SELECT indexed, unindexed FROM rows + } +} {1 1 2 2 4 4 8 8} + +finish_test + diff --git a/manifest b/manifest index 1c2904f809..78d7bf26c8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\sbestindexC.test.\sNo\schanges\sto\scode. -D 2024-05-11T16:44:56.528 +C If\sthere\sis\sno\sdata\savailable\sfor\sa\sfield\sin\sa\scorrupted\srecord,\sbut\sthe\stype\sis\savailable,\shave\sthe\srecovery\sextension\ssubstitute\s0,\s0.0,\s''\sor\sX''\sinstead\sof\sa\sNULL\svalue. +D 2024-05-15T15:06:27.777 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -478,14 +478,15 @@ F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69 F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055 -F ext/recover/dbdata.c e518c1a221a259a1ea594d9db8fce356861bfa450e6f54eda999242b9bd5c50a -F ext/recover/recover1.test c484d01502239f11b61f23c1cee9f5dd19fa17617f8974e42e74d64639c524cf +F ext/recover/dbdata.c 0a943861ec096de375097e0aaff07b480a002eab9b01fecd3f9e828faf4ef624 +F ext/recover/recover1.test e16d78e94183562abff569967b18b7c77451d7044365516cd0fe14713a284851 F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a F ext/recover/recoverbuild.test c74170e0f7b02456af41838afeb5353fdb985a48cc2331d661bbabbca7c6b8e3 F ext/recover/recoverclobber.test 3ba6c0c373c5c63d17e82eced64c05c57ccaf26c1abe1ca7141334022a79f32e F ext/recover/recovercorrupt.test 64c081ad1200ae77b447da99eb724785d6bf71715f394543dc7689642e92bf49 F ext/recover/recovercorrupt2.test 1418f1710debc24ff38276cedfcea234beb37a34205708e7e3e6d76cc4a979db F ext/recover/recovercorrupt3.test 2e7b9a1b528ca23ed382cec6f64e3fcbbd0f8e852add7562397fd8df83f335d5 +F ext/recover/recovercorrupt4.test 8990c3a76da616b938e800cd2b40eb1f7adf9352624966ba0af0303c7a015f00 F ext/recover/recoverfault.test 9d9f88eeb222615a25e7514f234c950d46bee20d24cd8db49d8fff8d650dcfe1 F ext/recover/recoverfault2.test 730e7371bcda769554d15460cb23126abba1be8eca9539ccabf63623e7bb7e09 F ext/recover/recoverold.test 68db3d6f85dd2b98e785b6c4da4f5eea4bbe52ccf6674d9a94c7506dc92596aa @@ -2190,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c6fd70b3c23fa00eaac9286d4a67e5c8ac76f926c11c220250c34032647bedc1 -R da518a0d510ea768080aa36a2357bedd +P 58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5 +R cd015e2f2734629b19947eb11f0220ff U dan -Z 00211d5eb53202476ca10f2c5f60b56e +Z be5ac0bdafce0ff1c422be3037819109 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e5e1fe061..205cf17a54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5 \ No newline at end of file +8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d \ No newline at end of file From 1550771a6ad4b5a16ed5b2d2f3d8f6d57c0d70a7 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 15 May 2024 21:38:04 +0000 Subject: [PATCH 0403/1030] Fix a case where an error in the ORDER BY clause of an aggregate function that is part of a trigger body might cause an assert() to fail in an ALTER TABLE command. FossilOrigin-Name: b79a8be37b44c1eff7d00f7af7cd9d0e13614ce5961bb88ddb9ec63f6a846c78 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/resolve.c | 4 +--- test/altertab2.test | 22 ++++++++++++++++++++++ 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 78d7bf26c8..5ee97b85cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sthere\sis\sno\sdata\savailable\sfor\sa\sfield\sin\sa\scorrupted\srecord,\sbut\sthe\stype\sis\savailable,\shave\sthe\srecovery\sextension\ssubstitute\s0,\s0.0,\s''\sor\sX''\sinstead\sof\sa\sNULL\svalue. -D 2024-05-15T15:06:27.777 +C Fix\sa\scase\swhere\san\serror\sin\sthe\sORDER\sBY\sclause\sof\san\saggregate\sfunction\sthat\sis\spart\sof\sa\strigger\sbody\smight\scause\san\sassert()\sto\sfail\sin\san\sALTER\sTABLE\scommand. +D 2024-05-15T21:38:04.100 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -752,7 +752,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 8816212645e4e9bdf3cc2f2d298304f388d699f8fab47f3a5712ef5bbc5b6ccc +F src/resolve.c 6adf4bf10151bca046f3206ae8ff07dbf90b49de20bea49197f010276f5f494d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ce81687d769b174aa547b8216a34fabc9cafc05789b615494ab78dc2c1e799fa F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b6 @@ -870,7 +870,7 @@ F test/altermalloc2.test 17fb3724c4b004c469c27dc4ef181608aa644555fbd3f3236767584 F test/altermalloc3.test 8040e486368403f2fdd6fc3998258b499bd4cc2f3ddbb5f8f874cd436f076e81 F test/alterqf.test 8ec03d776de9c391daa0078ea8f838903bdcfb11dfae4ba3576b48436834ccba F test/altertab.test 8a2712f9076da5012a002d0b5cc0a421398a5bf61c25bab41b77c427586a7a27 -F test/altertab2.test 62597b6fd08feaba1b6bfe7d31dac6117c67e06dc9ce9c478a3abe75b5926de0 +F test/altertab2.test fff90e3f01e8eb0e09282f538b8ec7cfeb035dbedbe570fe1983440f4613ad0e F test/altertab3.test b331ae34e69594e19605e3297805202d6156fcc8f75379dfd972a2e51cae8721 F test/altertrig.test aacc980b657354fe2d3d4d3a004f07d04ccc1a93e5ef82d68a79088c274ddc6b F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f @@ -2191,8 +2191,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5 -R cd015e2f2734629b19947eb11f0220ff +P 8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d +R 0bf8213edb19e5bc165e2308c6d79a06 +T *branch * alter-table-fix +T *sym-alter-table-fix * +T -sym-trunk * U dan -Z be5ac0bdafce0ff1c422be3037819109 +Z c2a36fdf7fb0d25294933bfa681979d4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 205cf17a54..b79cfa76c6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d \ No newline at end of file +b79a8be37b44c1eff7d00f7af7cd9d0e13614ce5961bb88ddb9ec63f6a846c78 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 898c78654c..546731afe5 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1281,11 +1281,9 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ #endif } } -#ifndef SQLITE_OMIT_WINDOWFUNC - else if( ExprHasProperty(pExpr, EP_WinFunc) ){ + else if( ExprHasProperty(pExpr, EP_WinFunc) || pExpr->pLeft ){ is_agg = 1; } -#endif sqlite3WalkExprList(pWalker, pList); if( is_agg ){ if( pExpr->pLeft ){ diff --git a/test/altertab2.test b/test/altertab2.test index def9e56686..576dc49670 100644 --- a/test/altertab2.test +++ b/test/altertab2.test @@ -360,4 +360,26 @@ do_catchsql_test 8.6 { SELECT sql FROM sqlite_master WHERE name='i0'; } {1 {error in index i0: second argument to likelihood() must be a constant between 0.0 and 1.0}} + +reset_db + +do_execsql_test 9.0 { + CREATE TABLE t1(a,b,c,d); + CREATE TABLE t2(a,b,c,d,x); + + CREATE TRIGGER AFTER INSERT ON t2 BEGIN + + SELECT group_conct( + 123 ORDER BY ( + SELECT 1 FROM ( VALUES(a, 'b'), ('c') ) + )) + FROM t1; + + END; +} + +do_catchsql_test 9.1 { + ALTER TABLE t2 RENAME TO newname; +} {1 {error in trigger AFTER: all VALUES must have the same number of terms}} + finish_test From 61f2ee6ab88dbc230b6c95af7d731327ddb727ce Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 15 May 2024 23:36:24 +0000 Subject: [PATCH 0404/1030] Back out the assert() fixes from [a9443dbfbe25e588] and [3afaeac56dff58db] (but keep the corresponding test cases) because they are both made obsolete by the previous fix on this branch. FossilOrigin-Name: 3120c7c8a3565b8a3ca321129c09db96839c2f9af1777fc7a1668fef81973603 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/select.c | 6 ++---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 5ee97b85cd..9e0cc7c88b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scase\swhere\san\serror\sin\sthe\sORDER\sBY\sclause\sof\san\saggregate\sfunction\sthat\sis\spart\sof\sa\strigger\sbody\smight\scause\san\sassert()\sto\sfail\sin\san\sALTER\sTABLE\scommand. -D 2024-05-15T21:38:04.100 +C Back\sout\sthe\sassert()\sfixes\sfrom\s[a9443dbfbe25e588]\sand\n[3afaeac56dff58db]\s(but\skeep\sthe\scorresponding\stest\scases)\sbecause\sthey\nare\sboth\smade\sobsolete\sby\sthe\sprevious\sfix\son\sthis\sbranch. +D 2024-05-15T23:36:24.437 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -754,7 +754,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 6adf4bf10151bca046f3206ae8ff07dbf90b49de20bea49197f010276f5f494d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c ce81687d769b174aa547b8216a34fabc9cafc05789b615494ab78dc2c1e799fa +F src/select.c 1a841c38974d45cf15a7611398479182b61ad4c187423c380741d8b1688fe607 F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b6 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2191,11 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d -R 0bf8213edb19e5bc165e2308c6d79a06 -T *branch * alter-table-fix -T *sym-alter-table-fix * -T -sym-trunk * -U dan -Z c2a36fdf7fb0d25294933bfa681979d4 +P b79a8be37b44c1eff7d00f7af7cd9d0e13614ce5961bb88ddb9ec63f6a846c78 +R 91267a6a1982f21ea275bc49553555c1 +U drh +Z d62affd8eb7ffd4672ed09ea764a6e2a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b79cfa76c6..ffce3cc964 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b79a8be37b44c1eff7d00f7af7cd9d0e13614ce5961bb88ddb9ec63f6a846c78 \ No newline at end of file +3120c7c8a3565b8a3ca321129c09db96839c2f9af1777fc7a1668fef81973603 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 532fbd19e5..9278ea18b8 100644 --- a/src/select.c +++ b/src/select.c @@ -2324,8 +2324,7 @@ void sqlite3SubqueryColumnTypes( NameContext sNC; assert( pSelect!=0 ); - testcase( (pSelect->selFlags & SF_Resolved)==0 ); - assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT ); + assert( (pSelect->selFlags & SF_Resolved)!=0 ); assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 ); assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB ); if( db->mallocFailed || IN_RENAME_OBJECT ) return; @@ -6412,8 +6411,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ if( p->selFlags & SF_HasTypeInfo ) return; p->selFlags |= SF_HasTypeInfo; pParse = pWalker->pParse; - testcase( (p->selFlags & SF_Resolved)==0 ); - assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT ); + assert( (p->selFlags & SF_Resolved) ); pTabList = p->pSrc; for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ Table *pTab = pFrom->pTab; From c72953a4bc68c5716c224e714557d59fe3d91df4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 16 May 2024 15:57:42 +0000 Subject: [PATCH 0405/1030] The sqlite3_declare_vtab() interface should return SQLITE_ERROR, not SQLITE_MISUSE when a nonsense SQL input is provided, for legacy compatibility. [forum:/forumpost/4b875d7b2a|Forum post 4b875d7b2a]. FossilOrigin-Name: 1ec2961a0341619ae88832942b52606b3246fc0de07ca6da0300e4bfc656ecf0 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/vtab.c | 5 ++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8bc618777b..6365b053b1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scase\swhere\san\serror\sin\sthe\sORDER\sBY\sclause\sof\san\saggregate\sfunction\sthat\sis\spart\sof\sa\strigger\sbody\smight\scause\san\sassert()\sto\sfail\sin\san\sALTER\sTABLE\scommand.\s\sdbsqlfuzz\s899d9255555a07f1fe11a0bb51a2fe197b3150cd -D 2024-05-16T00:20:43.867 +C The\ssqlite3_declare_vtab()\sinterface\sshould\sreturn\sSQLITE_ERROR,\snot\nSQLITE_MISUSE\swhen\sa\snonsense\sSQL\sinput\sis\sprovided,\sfor\slegacy\scompatibility.\n[forum:/forumpost/4b875d7b2a|Forum\spost\s4b875d7b2a]. +D 2024-05-16T15:57:42.281 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -834,7 +834,7 @@ F src/vdbemem.c 385c8b89da3b5ef9a468d77a466958aa72ee1212d5cb005f23ec63df1d413054 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 -F src/vtab.c 4c475fb672a6fe57830561e614dbee21a9a24a6f616d1cfcbe85f356a09f14ad +F src/vtab.c 5fb499d20494b7eecaadb7584634af9afcb374cb0524912b475fcb1712458a1b F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 @@ -2191,9 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d 3120c7c8a3565b8a3ca321129c09db96839c2f9af1777fc7a1668fef81973603 -R 91267a6a1982f21ea275bc49553555c1 -T +closed 3120c7c8a3565b8a3ca321129c09db96839c2f9af1777fc7a1668fef81973603 +P 953271f29e7bd6ba9b85f73250b1c22b08eef317f9ac3c7c3d92cbaa57d7efd5 +R bd9b1f3e12a43e6ce15734622e6a391b U drh -Z 697456db2f591cb2a06b3f31c7640456 +Z b7a4080de77f5c75fed04a53319240a7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b10e4da54e..e169c99247 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -953271f29e7bd6ba9b85f73250b1c22b08eef317f9ac3c7c3d92cbaa57d7efd5 \ No newline at end of file +1ec2961a0341619ae88832942b52606b3246fc0de07ca6da0300e4bfc656ecf0 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index 61dafab711..1036eed445 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -831,7 +831,10 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ for(i=0; aKeyword[i]; i++){ int tokenType = 0; do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE ); - if( tokenType!=aKeyword[i] ) return SQLITE_MISUSE_BKPT; + if( tokenType!=aKeyword[i] ){ + sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error"); + return SQLITE_ERROR; + } } sqlite3_mutex_enter(db->mutex); From fa0763eb3437cf0c16342e8e38a03014a557eb91 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 16 May 2024 16:22:51 +0000 Subject: [PATCH 0406/1030] Add extra tests for the error messages generated by sqlite3_declare_vtab() when passed something other than a well-formed CREATE TABLE statement. FossilOrigin-Name: 5fa0c2a026f0467af3a76ea80cee8168b7a49553c350f642d1dff02ff9e7aeed --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/test_bestindex.c | 3 +++ test/bestindexC.test | 22 +++++++++++++++++++--- test/vtabL.test | 11 +++++++++-- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 6365b053b1..ea1aa1987f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssqlite3_declare_vtab()\sinterface\sshould\sreturn\sSQLITE_ERROR,\snot\nSQLITE_MISUSE\swhen\sa\snonsense\sSQL\sinput\sis\sprovided,\sfor\slegacy\scompatibility.\n[forum:/forumpost/4b875d7b2a|Forum\spost\s4b875d7b2a]. -D 2024-05-16T15:57:42.281 +C Add\sextra\stests\sfor\sthe\serror\smessages\sgenerated\sby\ssqlite3_declare_vtab()\swhen\spassed\ssomething\sother\sthan\sa\swell-formed\sCREATE\sTABLE\sstatement. +D 2024-05-16T16:22:51.903 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -775,7 +775,7 @@ F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a F src/test_autoext.c 915d245e736652a219a907909bb6710f0d587871 F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 -F src/test_bestindex.c 1ee3d64b49ca06a9cb8195fab04f1a0585cafc90d25a2a817caa14e7caab22e7 +F src/test_bestindex.c 770429c434221afe6216ec81fe4c00ad3bbdad1d5e64576aa613ffb7c5a984f0 F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 F src/test_config.c 5fa77ee6064ba546e144c4fea870c5ede2c54314616f81485c6a9c4192100c75 @@ -939,7 +939,7 @@ F test/bestindex8.test b63a4f171a2c83d481bb14c431a8b72e85d27b2ffdaa0435a95d58ca9 F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede39673a451a0 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce -F test/bestindexC.test a2d4ab909e17bb58fe4d66a394460e713620c7b2964b450bc82216c171d264a2 +F test/bestindexC.test 9e6f184be080fd9c4605a7e5c7097eed1a259372f9af78151c37b072a9086f86 F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -1958,7 +1958,7 @@ F test/vtabH.test 2efb5a24b0bb50796b21eca23032cfb77abfa4b0c03938e38ce5897abac404 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtabJ.test a6aef49d558af90fae10565b29501f82a95781cb4f797f2d13e2d19f9b6bc77b F test/vtabK.test 13293177528fada1235c0112db0d187d754af1355c5a39371abd365104e3afbf -F test/vtabL.test 49ec7342e8bfcb0d6c3d2443c619f430c609c042d5d7e6ddf52def65d6d1812f +F test/vtabL.test c7b7f537978005d063fa2f53a3cd5a46ecf651ecd19970cb9ed4203698398deb F test/vtab_alter.test 736e66fb5ec7b4fee58229aa3ada2f27ec58bc58c00edae4836890c3784c6783 F test/vtab_err.test dcc8b7b9cb67522b3fe7a272c73856829dae4ab7fdb30399aea1b6981bda2b65 F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 953271f29e7bd6ba9b85f73250b1c22b08eef317f9ac3c7c3d92cbaa57d7efd5 -R bd9b1f3e12a43e6ce15734622e6a391b -U drh -Z b7a4080de77f5c75fed04a53319240a7 +P 1ec2961a0341619ae88832942b52606b3246fc0de07ca6da0300e4bfc656ecf0 +R 3e80a1a8d16383b10a9edc0a3a535e00 +U dan +Z 4379dfd9de0672673743bdb6b799c4de # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e169c99247..5851bda00f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1ec2961a0341619ae88832942b52606b3246fc0de07ca6da0300e4bfc656ecf0 \ No newline at end of file +5fa0c2a026f0467af3a76ea80cee8168b7a49553c350f642d1dff02ff9e7aeed \ No newline at end of file diff --git a/src/test_bestindex.c b/src/test_bestindex.c index 6b6b413950..0e1e86a81c 100644 --- a/src/test_bestindex.c +++ b/src/test_bestindex.c @@ -215,6 +215,9 @@ static int tclConnect( rc = SQLITE_ERROR; }else{ rc = sqlite3_declare_vtab(db, Tcl_GetStringResult(interp)); + if( rc!=SQLITE_OK ){ + *pzErr = sqlite3_mprintf("declare_vtab: %s", sqlite3_errmsg(db)); + } } if( rc!=SQLITE_OK ){ diff --git a/test/bestindexC.test b/test/bestindexC.test index 708e56f774..c6ddf30618 100644 --- a/test/bestindexC.test +++ b/test/bestindexC.test @@ -177,9 +177,7 @@ unset ::do_not_use_offset reset_db proc vtab_command {lVal method args} { switch -- $method { - xConnect { - error "not happy!" - } + xConnect { error "not happy!" } } return {} @@ -193,5 +191,23 @@ do_test 4.1 { sqlite3_errcode db } SQLITE_ERROR +proc vtab_command {lVal method args} { + switch -- $method { + xConnect { + return $lVal + } + } + return {} +} + +do_catchsql_test 4.2 { + CREATE VIRTUAL TABLE y1 USING tcl(vtab_command "PRAGMA page_size=1024"); +} {1 {declare_vtab: syntax error}} +do_catchsql_test 4.3 { + CREATE VIRTUAL TABLE y1 USING tcl(vtab_command "CREATE TABLE x1("); +} {1 {declare_vtab: incomplete input}} +do_catchsql_test 4.4 { + CREATE VIRTUAL TABLE y1 USING tcl(vtab_command "CREATE TABLE x1(insert)"); +} {1 {declare_vtab: near "insert": syntax error}} finish_test diff --git a/test/vtabL.test b/test/vtabL.test index 0834655ffd..45528edcbd 100644 --- a/test/vtabL.test +++ b/test/vtabL.test @@ -31,7 +31,6 @@ proc vtab_command {method args} { return {} } -breakpoint foreach {tn cts} { 1 {SELECT 123} 2 {SELECT 123, 456} @@ -41,13 +40,21 @@ foreach {tn cts} { 6 {DROP TABLE nosuchtable} 7 {DROP TABLE x1} 8 {DROP TABLE t1} +} { + set ::create_table_sql $cts + do_catchsql_test 1.$tn { + CREATE VIRTUAL TABLE x1 USING tcl(vtab_command); + } {1 {declare_vtab: syntax error}} +} + +foreach {tn cts} { 9 {CREATE TABLE xyz AS SELECT * FROM sqlite_schema} 10 {CREATE TABLE xyz AS SELECT 1 AS 'col'} } { set ::create_table_sql $cts do_catchsql_test 1.$tn { CREATE VIRTUAL TABLE x1 USING tcl(vtab_command); - } {1 {vtable constructor failed: x1}} + } {1 {declare_vtab: SQL logic error}} } foreach {tn cts} { From 0445cd102020dd34c70364aef9c10249dcfd985d Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 17 May 2024 13:56:38 +0000 Subject: [PATCH 0407/1030] Fix a problem in where.c preventing SQLite from identifying some ONEROW scans, leading to (slightly) sub-optimal byte-code. FossilOrigin-Name: b41e71208abcdf988f57c3fd7e6a372bbaf442c32a8e2c051beb8d45c8001e0f --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ea1aa1987f..1546c38dec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\stests\sfor\sthe\serror\smessages\sgenerated\sby\ssqlite3_declare_vtab()\swhen\spassed\ssomething\sother\sthan\sa\swell-formed\sCREATE\sTABLE\sstatement. -D 2024-05-16T16:22:51.903 +C Fix\sa\sproblem\sin\swhere.c\spreventing\sSQLite\sfrom\sidentifying\ssome\sONEROW\sscans,\sleading\sto\s(slightly)\ssub-optimal\sbyte-code. +D 2024-05-17T13:56:38.514 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -839,7 +839,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c d235ba520b0147f60732b3bd411e119b43be33d348251edaa6e304a8ad52c511 +F src/where.c 211c073b4295cf3087fca78d77aff8309cf6ec8267a510f38336080740fb3bb1 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c b9908c0a1aab095822a1e7032556bedc03b6d29641191e9ca535fb2307cd733d F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2191,8 +2191,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1ec2961a0341619ae88832942b52606b3246fc0de07ca6da0300e4bfc656ecf0 -R 3e80a1a8d16383b10a9edc0a3a535e00 +P 5fa0c2a026f0467af3a76ea80cee8168b7a49553c350f642d1dff02ff9e7aeed +R 2eb5df88e143b963f30ca5abd4335fa3 +T *branch * fix-onerow-opt +T *sym-fix-onerow-opt * +T -sym-trunk * U dan -Z 4379dfd9de0672673743bdb6b799c4de +Z 4e3116b49700fa7a9c75b5f5cd140ab3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5851bda00f..d7af65ac77 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5fa0c2a026f0467af3a76ea80cee8168b7a49553c350f642d1dff02ff9e7aeed \ No newline at end of file +b41e71208abcdf988f57c3fd7e6a372bbaf442c32a8e2c051beb8d45c8001e0f \ No newline at end of file diff --git a/src/where.c b/src/where.c index 13a362dcca..07c5b9cf97 100644 --- a/src/where.c +++ b/src/where.c @@ -3170,7 +3170,7 @@ static int whereLoopAddBtreeIndex( || (iCol>=0 && nInMul==0 && saved_nEq==pProbe->nKeyCol-1) ){ if( iCol==XN_ROWID || pProbe->uniqNotNull - || (pProbe->nKeyCol==1 && pProbe->onError && eOp==WO_EQ) + || (pProbe->nKeyCol==1 && pProbe->onError && (eOp & WO_EQ)) ){ pNew->wsFlags |= WHERE_ONEROW; }else{ From b834f629ccdea6452d92f9bfcf41c24a833a6dbd Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 May 2024 22:51:03 +0000 Subject: [PATCH 0408/1030] Improvements to a VDBE comment. No changes to anything that affects queries. FossilOrigin-Name: c2188da860a1debd7c5d28b223deeef15035c33c2c5aefae9d9b620b6a2b4677 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/wherecode.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ea1aa1987f..3b1d18c556 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\stests\sfor\sthe\serror\smessages\sgenerated\sby\ssqlite3_declare_vtab()\swhen\spassed\ssomething\sother\sthan\sa\swell-formed\sCREATE\sTABLE\sstatement. -D 2024-05-16T16:22:51.903 +C Improvements\sto\sa\sVDBE\scomment.\s\sNo\schanges\sto\sanything\sthat\saffects\squeries. +D 2024-05-17T22:51:03.662 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -841,7 +841,7 @@ F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c d235ba520b0147f60732b3bd411e119b43be33d348251edaa6e304a8ad52c511 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 -F src/wherecode.c b9908c0a1aab095822a1e7032556bedc03b6d29641191e9ca535fb2307cd733d +F src/wherecode.c f5255f49d1f42b6e7e6b0362ff3522fa88cbcaa7213e52f9374744027ecdebca F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1ec2961a0341619ae88832942b52606b3246fc0de07ca6da0300e4bfc656ecf0 -R 3e80a1a8d16383b10a9edc0a3a535e00 -U dan -Z 4379dfd9de0672673743bdb6b799c4de +P 5fa0c2a026f0467af3a76ea80cee8168b7a49553c350f642d1dff02ff9e7aeed +R ff343800565c823ff5271a08e7be7456 +U drh +Z c91b300408dcad01064e8ec2c6e1dc4c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5851bda00f..781081e058 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5fa0c2a026f0467af3a76ea80cee8168b7a49553c350f642d1dff02ff9e7aeed \ No newline at end of file +c2188da860a1debd7c5d28b223deeef15035c33c2c5aefae9d9b620b6a2b4677 \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index 4aca6eb624..a620a5ac06 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1436,7 +1436,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){ pLevel->iLeftJoin = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin); - VdbeComment((v, "init LEFT JOIN no-match flag")); + VdbeComment((v, "init LEFT JOIN match flag")); } /* Compute a safe address to jump to if we discover that the table for From 79dac84b315ced19266d55f769341782f429e6b4 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 18 May 2024 15:21:45 +0000 Subject: [PATCH 0409/1030] JS error message and doc typos reported in the forum. No code changes. FossilOrigin-Name: 1a073f9acfb691eebf4a8cc78a72ff47ebbb6aba4acede6755fa3faefae48f2b --- ext/wasm/api/sqlite3-api-oo1.js | 2 +- ext/wasm/api/sqlite3-api-prologue.js | 2 +- ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | 2 +- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index 8cd50a14bb..e557cbd578 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -1868,7 +1868,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ an exception is thrown. By default it will determine the data type of the result - automatically. If passed a second arugment, it must be one + automatically. If passed a second argument, it must be one of the enumeration values for sqlite3 types, which are defined as members of the sqlite3 module: SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB. Any other value, diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index 849dfe10f2..689c79ae34 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -1838,7 +1838,7 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( /** Calls either sqlite3_result_error_nomem(), if e is-a WasmAllocError, or sqlite3_result_error(). In the latter case, - the second arugment is coerced to a string to create the error + the second argument is coerced to a string to create the error message. The first argument is a (sqlite3_context*). Returns void. diff --git a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js index 8cfc709372..55e497ead5 100644 --- a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js +++ b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js @@ -207,7 +207,7 @@ globalThis.sqlite3Worker1Promiser = function callee(config = callee.defaultConfi msg.args = arguments[1]; msg.dbId = msg.args.dbId; }else{ - toss("Invalid arugments for sqlite3Worker1Promiser()-created factory."); + toss("Invalid arguments for sqlite3Worker1Promiser()-created factory."); } if(!msg.dbId && msg.type!=='open') msg.dbId = dbId; msg.messageId = genMsgId(msg); diff --git a/manifest b/manifest index 3b1d18c556..acf63d973b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sa\sVDBE\scomment.\s\sNo\schanges\sto\sanything\sthat\saffects\squeries. -D 2024-05-17T22:51:03.662 +C JS\serror\smessage\sand\sdoc\stypos\sreported\sin\sthe\sforum.\sNo\scode\schanges. +D 2024-05-18T15:21:45.610 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -610,8 +610,8 @@ F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d -F ext/wasm/api/sqlite3-api-oo1.js 40f6834314b60e636f0046a9c49b8566a992dcf04be9ea593e680c23f6984b2b -F ext/wasm/api/sqlite3-api-prologue.js 34457b25dcf0005c81d76f011f207026ec164f6ff0f69f024b608025ca808ea9 +F ext/wasm/api/sqlite3-api-oo1.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e +F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.js 9704b77b5eb9d0d498ceeaf3e7a837021b14c52ac15d6556c7f97e278ec725c3 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 196ad83d36ca794e564044788c9d21b964679d63cad865f604da37c4afc9a285 @@ -620,7 +620,7 @@ F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c -F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 5bffc94b0ba45c658f7a70c683c536642cd95f4d6fc71d20785864111c396740 +F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5fa0c2a026f0467af3a76ea80cee8168b7a49553c350f642d1dff02ff9e7aeed -R ff343800565c823ff5271a08e7be7456 -U drh -Z c91b300408dcad01064e8ec2c6e1dc4c +P c2188da860a1debd7c5d28b223deeef15035c33c2c5aefae9d9b620b6a2b4677 +R 54dd93ee4a8dfed3331a7d693fe52477 +U stephan +Z f16374626a15dcefe372431613b7ed3c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 781081e058..1518cbf1b1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c2188da860a1debd7c5d28b223deeef15035c33c2c5aefae9d9b620b6a2b4677 \ No newline at end of file +1a073f9acfb691eebf4a8cc78a72ff47ebbb6aba4acede6755fa3faefae48f2b \ No newline at end of file From 04624990514ae7c593ad224dd87cd9037cec752f Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 18 May 2024 20:00:08 +0000 Subject: [PATCH 0410/1030] Fix the definition of sqlite3_vtab_distinct() such that return codes 2 and 3 mean that all rows must be distinct over "colUsed" which is a superset of "aOrderBy". Also, disallow return codes 2 and 3 if the rowid of the virtual table is accessed. FossilOrigin-Name: 922731ce98c0ce7837784ff7966049e59fa73da2aa04abf3506503b6fc4aa048 --- manifest | 25 ++++++++++++++----------- manifest.uuid | 2 +- src/resolve.c | 8 ++++++-- src/sqlite.h.in | 16 +++++++++------- src/sqliteInt.h | 1 + src/treeview.c | 6 ++++-- src/where.c | 2 +- 7 files changed, 36 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index acf63d973b..401fc0177e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C JS\serror\smessage\sand\sdoc\stypos\sreported\sin\sthe\sforum.\sNo\scode\schanges. -D 2024-05-18T15:21:45.610 +C Fix\sthe\sdefinition\sof\ssqlite3_vtab_distinct()\ssuch\sthat\sreturn\scodes\s2\sand\n3\smean\sthat\sall\srows\smust\sbe\sdistinct\sover\s"colUsed"\swhich\sis\sa\ssuperset\sof\n"aOrderBy".\s\sAlso,\sdisallow\sreturn\scodes\s2\sand\s3\sif\sthe\srowid\sof\sthe\svirtual\ntable\sis\saccessed. +D 2024-05-18T20:00:08.988 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -752,14 +752,14 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 6adf4bf10151bca046f3206ae8ff07dbf90b49de20bea49197f010276f5f494d +F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 1a841c38974d45cf15a7611398479182b61ad4c187423c380741d8b1688fe607 F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b6 -F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b +F src/sqlite.h.in 6d645f9c2da3b64ea44944024df0c733bba186ee200d849a72a25bf8ae9beac4 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h adcf1cebb6fc00fc1f1329c00bb65ac36655736080acfd2071d84aa83a104afe +F src/sqliteInt.h 6a9fa3902c9faca2b57060e822f2afadfbf96d64c4ede81e201f0e0c42d7e4aa F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -817,7 +817,7 @@ F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c 4f9ba6c1c7c9893fc046fdb0bc1f6bdec7660122b1ae37e51fb9b64c286caafd +F src/treeview.c 38eefdc85d2793c4059ae651a611b30eb034389fb428f69e572bbea565da6c78 F src/trigger.c 0858f75818ed1580332db274f1032bcc5effe567cb132df5c5be8b1d800ca97f F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 @@ -839,7 +839,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c d235ba520b0147f60732b3bd411e119b43be33d348251edaa6e304a8ad52c511 +F src/where.c 6f02c3936d1f9a637d8d7b5ad7362371af3e4434b0ec1eb950189a83de560d59 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c f5255f49d1f42b6e7e6b0362ff3522fa88cbcaa7213e52f9374744027ecdebca F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2191,8 +2191,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c2188da860a1debd7c5d28b223deeef15035c33c2c5aefae9d9b620b6a2b4677 -R 54dd93ee4a8dfed3331a7d693fe52477 -U stephan -Z f16374626a15dcefe372431613b7ed3c +P 1a073f9acfb691eebf4a8cc78a72ff47ebbb6aba4acede6755fa3faefae48f2b +R be7ef6a3dcb331720f0112bf3c3e9c8c +T *branch * vtab-distinct-fix +T *sym-vtab-distinct-fix * +T -sym-trunk * +U drh +Z 3a71e5f761d3443220a5a5a181b974f3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1518cbf1b1..6968f2e6b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a073f9acfb691eebf4a8cc78a72ff47ebbb6aba4acede6755fa3faefae48f2b \ No newline at end of file +922731ce98c0ce7837784ff7966049e59fa73da2aa04abf3506503b6fc4aa048 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 546731afe5..bf8326aa64 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -828,8 +828,12 @@ static int lookupName( ** If a generated column is referenced, set bits for every column ** of the table. */ - if( pExpr->iColumn>=0 && cnt==1 && pMatch!=0 ){ - pMatch->colUsed |= sqlite3ExprColUsed(pExpr); + if( pMatch ){ + if( pExpr->iColumn>=0 ){ + pMatch->colUsed |= sqlite3ExprColUsed(pExpr); + }else{ + pMatch->fg.rowidUsed = 1; + } } pExpr->op = eNewExprOp; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index d553abb7bf..459af929b1 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -9942,20 +9942,22 @@ const char *sqlite3_vtab_collation(sqlite3_index_info*,int); **
  • ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means ** that the query planner does not need the rows returned in any particular -** order, as long as rows with the same values in all "aOrderBy" columns +** order, as long as rows with the same values in all "colUsed" columns ** are adjacent.)^ ^(Furthermore, only a single row for each particular -** combination of values in the columns identified by the "aOrderBy" field +** combination of values in the columns identified by the "colUsed" field ** needs to be returned.)^ ^It is always ok for two or more rows with the same -** values in all "aOrderBy" columns to be returned, as long as all such rows +** values in all "colUsed" columns to be returned, as long as all such rows ** are adjacent. ^The virtual table may, if it chooses, omit extra rows -** that have the same value for all columns identified by "aOrderBy". +** that have the same value for all columns identified by "colUsed". ** ^However omitting the extra rows is optional. ** This mode is used for a DISTINCT query. **

  • ** ^(If the sqlite3_vtab_distinct() interface returns 3, that means -** that the query planner needs only distinct rows but it does need the -** rows to be sorted.)^ ^The virtual table implementation is free to omit -** rows that are identical in all aOrderBy columns, if it wants to, but +** that the query planner needs only rows that are distinct over the +** set of columns defined by "colUsed" but it does need the +** rows to be sorted according to the order defined by "aOrderBy".)^ +** ^The virtual table implementation is free to omit +** rows that are identical in all "colUsed" columns, if it wants to, but ** it is not required to omit any rows. This mode is used for queries ** that have both DISTINCT and ORDER BY clauses. ** diff --git a/src/sqliteInt.h b/src/sqliteInt.h index aa8bfc4b7b..d98a4f7f06 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3312,6 +3312,7 @@ struct SrcItem { unsigned isOn :1; /* u3.pOn was once valid and non-NULL */ unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */ unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */ + unsigned rowidUsed :1; /* The ROWID of this table is referenced */ } fg; int iCursor; /* The VDBE cursor number used to access this table */ union { diff --git a/src/treeview.c b/src/treeview.c index d3346b4686..fa9eac6142 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -194,8 +194,10 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ x.printfFlags |= SQLITE_PRINTF_INTERNAL; sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem); if( pItem->pTab ){ - sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx", - pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed); + sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx%s", + pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, + pItem->colUsed, + pItem->fg.rowidUsed ? "+rowid" : ""); } if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==(JT_LEFT|JT_RIGHT) ){ sqlite3_str_appendf(&x, " FULL-OUTER-JOIN"); diff --git a/src/where.c b/src/where.c index 13a362dcca..fac0f6c5eb 100644 --- a/src/where.c +++ b/src/where.c @@ -1416,7 +1416,7 @@ static sqlite3_index_info *allocateIndexInfo( } if( i==n ){ nOrderBy = n; - if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) ){ + if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) && !pSrc->fg.rowidUsed ){ eDistinct = 2 + ((pWInfo->wctrlFlags & WHERE_SORTBYGROUP)!=0); }else if( pWInfo->wctrlFlags & WHERE_GROUPBY ){ eDistinct = 1; From df903fe0565e3793888bbd8f8a329245eec4d9ea Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 20 May 2024 16:00:27 +0000 Subject: [PATCH 0411/1030] Improvements to the sqlite3_vtab_distinct() documentation. FossilOrigin-Name: 6ee041d34f292b94701919f51bbb9e12bcb9e0c4f45e4c0b83f30ff328070637 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 49 ++++++++++++++++++++++++++++++++++--------------- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 401fc0177e..ce10a0198d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sdefinition\sof\ssqlite3_vtab_distinct()\ssuch\sthat\sreturn\scodes\s2\sand\n3\smean\sthat\sall\srows\smust\sbe\sdistinct\sover\s"colUsed"\swhich\sis\sa\ssuperset\sof\n"aOrderBy".\s\sAlso,\sdisallow\sreturn\scodes\s2\sand\s3\sif\sthe\srowid\sof\sthe\svirtual\ntable\sis\saccessed. -D 2024-05-18T20:00:08.988 +C Improvements\sto\sthe\ssqlite3_vtab_distinct()\sdocumentation. +D 2024-05-20T16:00:27.117 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -756,7 +756,7 @@ F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 1a841c38974d45cf15a7611398479182b61ad4c187423c380741d8b1688fe607 F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b6 -F src/sqlite.h.in 6d645f9c2da3b64ea44944024df0c733bba186ee200d849a72a25bf8ae9beac4 +F src/sqlite.h.in c71d9ef76a6d32dc7ff2d373f2e57ce09056af26c1457bcadae5358b7628c7c3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 6a9fa3902c9faca2b57060e822f2afadfbf96d64c4ede81e201f0e0c42d7e4aa @@ -2191,11 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1a073f9acfb691eebf4a8cc78a72ff47ebbb6aba4acede6755fa3faefae48f2b -R be7ef6a3dcb331720f0112bf3c3e9c8c -T *branch * vtab-distinct-fix -T *sym-vtab-distinct-fix * -T -sym-trunk * +P 922731ce98c0ce7837784ff7966049e59fa73da2aa04abf3506503b6fc4aa048 +R 65c04e4dfc1793594341c544753e5e70 U drh -Z 3a71e5f761d3443220a5a5a181b974f3 +Z 4b4899e535e10a58b98edaa878f294f3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6968f2e6b3..1200d1128c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -922731ce98c0ce7837784ff7966049e59fa73da2aa04abf3506503b6fc4aa048 \ No newline at end of file +6ee041d34f292b94701919f51bbb9e12bcb9e0c4f45e4c0b83f30ff328070637 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 459af929b1..549b52a153 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -9942,26 +9942,45 @@ const char *sqlite3_vtab_collation(sqlite3_index_info*,int); **

  • ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means ** that the query planner does not need the rows returned in any particular -** order, as long as rows with the same values in all "colUsed" columns -** are adjacent.)^ ^(Furthermore, only a single row for each particular -** combination of values in the columns identified by the "colUsed" field -** needs to be returned.)^ ^It is always ok for two or more rows with the same -** values in all "colUsed" columns to be returned, as long as all such rows -** are adjacent. ^The virtual table may, if it chooses, omit extra rows -** that have the same value for all columns identified by "colUsed". -** ^However omitting the extra rows is optional. +** order, as long as rows with the same values in all columns identified +** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows +** contain the same values for all columns identified by "colUsed", all but +** one such row may optionally be omitted from the result.)^ +** The virtual table is not required to omit rows that are duplicates +** over the "colUsed" columns, but if the virtual table can do that without +** too much extra effort, it could potentially help the query to run faster. ** This mode is used for a DISTINCT query. **

  • -** ^(If the sqlite3_vtab_distinct() interface returns 3, that means -** that the query planner needs only rows that are distinct over the -** set of columns defined by "colUsed" but it does need the -** rows to be sorted according to the order defined by "aOrderBy".)^ -** ^The virtual table implementation is free to omit -** rows that are identical in all "colUsed" columns, if it wants to, but -** it is not required to omit any rows. This mode is used for queries +** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the +** virtual table must return rows in the order defined by "aOrderBy" as +** if the sqlite3_vtab_distinct() interface had returned 0. However if +** two or more rows in the result have the same values for all columns +** identified by "colUsed", then all but one such row may optionally be +** omitted.)^ Like when the return value is 2, the virtual table +** is not required to omit rows that are duplicates over the "colUsed" +** columns, but if the virtual table can do that without +** too much extra effort, it could potentially help the query to run faster. +** This mode is used for queries ** that have both DISTINCT and ORDER BY clauses. ** ** +**

    The following table summarizes the conditions under which the +** virtual table is allowed to set the "orderByConsumed" flag based on +** the value returned by sqlite3_vtab_distinct(). This table is a +** restatement of the previous four paragraphs: +** +** +** +**
    sqlite3_vtab_distinct() return value +** Rows are returned in aOrderBy order +** Rows with the same value in all aOrderBy columns are adjacent +** Duplicates over all colUsed columns may be omitted +**
    0yesyesno +**
    1noyesno +**
    2noyesyes +**
    3yesyesyes +**
    +** ** ^For the purposes of comparing virtual table output values to see if the ** values are same value for sorting purposes, two NULL values are considered ** to be the same. In other words, the comparison operator is "IS" From f765aec406c7cae212d579fa0fc1506f82d25812 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 20 May 2024 19:51:06 +0000 Subject: [PATCH 0412/1030] Do not run the tests in recovercorrupt4.test with the inmemory_journal permutation. FossilOrigin-Name: c13205d66b8406cccfc937c88ac515fa758fe2ade8b3d30f0c1e79fe974e9600 --- ext/recover/recovercorrupt4.test | 80 +++++++++++++++++--------------- manifest | 15 +++--- manifest.uuid | 2 +- 3 files changed, 51 insertions(+), 46 deletions(-) diff --git a/ext/recover/recovercorrupt4.test b/ext/recover/recovercorrupt4.test index 53d691fbc4..0ff0b502df 100644 --- a/ext/recover/recovercorrupt4.test +++ b/ext/recover/recovercorrupt4.test @@ -15,44 +15,50 @@ set testprefix recovercorrupt4 database_may_be_corrupt -do_execsql_test 1.0 { - CREATE TABLE rows(indexed INTEGER NOT NULL, unindexed INTEGER NOT NULL, filler BLOB NOT NULL DEFAULT 13); - -- CREATE UNIQUE INDEX rows_index ON rows(indexed); - INSERT INTO rows(indexed, unindexed, filler) VALUES(1, 1, x'31'); - INSERT INTO rows(indexed, unindexed, filler) VALUES(2, 2, x'32'); - INSERT INTO rows(indexed, unindexed, filler) VALUES(4, 4, x'34'); - INSERT INTO rows(indexed, unindexed, filler) VALUES(8, 8, randomblob(2048)); -} - -db close - -do_test 1.1 { - set sz [expr [file size test.db] - 1024] - set fd [open test.db] - fconfigure $fd -encoding binary -translation binary - - set data [read $fd $sz] - set fd2 [open test.db2 w] - fconfigure $fd2 -encoding binary -translation binary - puts -nonewline $fd2 $data - close $fd2 - set {} {} -} {} - -do_test 1.2 { - forcedelete test.db3 - sqlite3 db test.db2 - set R [sqlite3_recover_init db main test.db3] - $R run - $R finish -} {} - -do_test 1.3 { - sqlite3 db test.db3 - execsql { - SELECT indexed, unindexed FROM rows +if {[permutation]!="inmemory_journal"} { + # This test cannot be run with the inmemory_journal permutation, as it + # must open a truncated, corrupt, database file. With the inmemory_journal + # permutation, this fails (SQLITE_CORRUPT error) when the [sqlite3] wrapper + # executes "PRAGMA journal_mode = memory". + do_execsql_test 1.0 { + CREATE TABLE rows(indexed INTEGER NOT NULL, unindexed INTEGER NOT NULL, filler BLOB NOT NULL DEFAULT 13); + -- CREATE UNIQUE INDEX rows_index ON rows(indexed); + INSERT INTO rows(indexed, unindexed, filler) VALUES(1, 1, x'31'); + INSERT INTO rows(indexed, unindexed, filler) VALUES(2, 2, x'32'); + INSERT INTO rows(indexed, unindexed, filler) VALUES(4, 4, x'34'); + INSERT INTO rows(indexed, unindexed, filler) VALUES(8, 8, randomblob(2048)); } -} {1 1 2 2 4 4 8 8} + + db close + + do_test 1.1 { + set sz [expr [file size test.db] - 1024] + set fd [open test.db] + fconfigure $fd -encoding binary -translation binary + + set data [read $fd $sz] + set fd2 [open test.db2 w] + fconfigure $fd2 -encoding binary -translation binary + puts -nonewline $fd2 $data + close $fd2 + set {} {} + } {} + + do_test 1.2 { + forcedelete test.db3 + sqlite3 db test.db2 + set R [sqlite3_recover_init db main test.db3] + $R run + $R finish + } {} + + do_test 1.3 { + sqlite3 db test.db3 + execsql { + SELECT indexed, unindexed FROM rows + } + } {1 1 2 2 4 4 8 8} +} finish_test diff --git a/manifest b/manifest index 29d10b5d87..8b165fad08 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sdocumentation\sof\ssqlite3_vtab_distinct().\s\sDo\snot\sallow\nsqlite3_vtab_distinct()\sto\sreturn\s2\sor\s3\sif\sthe\srowid\scolumn\sof\sthe\svirtual\ntable\sis\sused,\sas\sdoing\sso\smight\slead\sto\san\sincorrect\sanswer. -D 2024-05-20T17:52:35.621 +C Do\snot\srun\sthe\stests\sin\srecovercorrupt4.test\swith\sthe\sinmemory_journal\spermutation. +D 2024-05-20T19:51:06.196 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -486,7 +486,7 @@ F ext/recover/recoverclobber.test 3ba6c0c373c5c63d17e82eced64c05c57ccaf26c1abe1c F ext/recover/recovercorrupt.test 64c081ad1200ae77b447da99eb724785d6bf71715f394543dc7689642e92bf49 F ext/recover/recovercorrupt2.test 1418f1710debc24ff38276cedfcea234beb37a34205708e7e3e6d76cc4a979db F ext/recover/recovercorrupt3.test 2e7b9a1b528ca23ed382cec6f64e3fcbbd0f8e852add7562397fd8df83f335d5 -F ext/recover/recovercorrupt4.test 8990c3a76da616b938e800cd2b40eb1f7adf9352624966ba0af0303c7a015f00 +F ext/recover/recovercorrupt4.test cc4a56086c50fba6a5b20db122a3f220195b3d4f11a86e0858c7f5f5d8ba58d1 F ext/recover/recoverfault.test 9d9f88eeb222615a25e7514f234c950d46bee20d24cd8db49d8fff8d650dcfe1 F ext/recover/recoverfault2.test 730e7371bcda769554d15460cb23126abba1be8eca9539ccabf63623e7bb7e09 F ext/recover/recoverold.test 68db3d6f85dd2b98e785b6c4da4f5eea4bbe52ccf6674d9a94c7506dc92596aa @@ -2191,9 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1a073f9acfb691eebf4a8cc78a72ff47ebbb6aba4acede6755fa3faefae48f2b 6ee041d34f292b94701919f51bbb9e12bcb9e0c4f45e4c0b83f30ff328070637 -R 65c04e4dfc1793594341c544753e5e70 -T +closed 6ee041d34f292b94701919f51bbb9e12bcb9e0c4f45e4c0b83f30ff328070637 -U drh -Z fa3617d3b707c5d55775f8d830ee0281 +P 08058d66d1bde4fcf8324482ee4c6c030c681383470d5076b6f75b74aac2ae29 +R 01944e27726a0e53c62f6b779625a02f +U dan +Z f9b21623fcc9b31310e5e703021ca634 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7aeea9e86c..4b60b06ff3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -08058d66d1bde4fcf8324482ee4c6c030c681383470d5076b6f75b74aac2ae29 \ No newline at end of file +c13205d66b8406cccfc937c88ac515fa758fe2ade8b3d30f0c1e79fe974e9600 \ No newline at end of file From 00208479fd4c371eec868cadb6b9968fd9045fb8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 20 May 2024 19:59:32 +0000 Subject: [PATCH 0413/1030] Omit a capi3 test from 2007 that depends upon undefined behavior (UAF). FossilOrigin-Name: a60a0b75137c015e97b8dcd0070444fcb608f502ce88b2ee744dd6230dbdc120 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/capi3.test | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8b165fad08..374394b147 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srun\sthe\stests\sin\srecovercorrupt4.test\swith\sthe\sinmemory_journal\spermutation. -D 2024-05-20T19:51:06.196 +C Omit\sa\scapi3\stest\sfrom\s2007\sthat\sdepends\supon\sundefined\sbehavior\s(UAF). +D 2024-05-20T19:59:32.762 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -969,7 +969,7 @@ F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de F test/cacheflush.test af25bb1509df04c1da10e38d8f322d66eceedf61 F test/cachespill.test 895997f84a25b323b166aecb69baab2d6380ea98f9e0bcc688c4493c535cfab9 F test/capi2.test 4ee545824adc3eb33bf57ef89f77440b28188ec3da72e5425ff0fcdba32e8d5a -F test/capi3.test 3910a73c38ac76d69778dd9eb481ab7cd6ed59117fc047b4f6056a5c72529de1 +F test/capi3.test 4892b5e53d2a6941edc9d204a0ab174dd66e8689282d9a15e4384561c3965945 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test 31d3a6778f2d06f2d9222bd7660c41a516d1518a059b069e96ebbeadb5a490f7 F test/capi3d.test 8b778794af891b0dca3d900bd345fbc8ebd2aa2aae425a9dccdd10d5233dfbde @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 08058d66d1bde4fcf8324482ee4c6c030c681383470d5076b6f75b74aac2ae29 -R 01944e27726a0e53c62f6b779625a02f -U dan -Z f9b21623fcc9b31310e5e703021ca634 +P c13205d66b8406cccfc937c88ac515fa758fe2ade8b3d30f0c1e79fe974e9600 +R afa580b78e84297da9d918d4b239628f +U drh +Z dd88f180c52872ac43a520d8ec94266a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4b60b06ff3..58c5ec3196 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c13205d66b8406cccfc937c88ac515fa758fe2ade8b3d30f0c1e79fe974e9600 \ No newline at end of file +a60a0b75137c015e97b8dcd0070444fcb608f502ce88b2ee744dd6230dbdc120 \ No newline at end of file diff --git a/test/capi3.test b/test/capi3.test index 40d87ac8e3..e65f90e3aa 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -181,7 +181,7 @@ do_test capi3-3.4 { do_test capi3-3.5 { list [sqlite3_system_errno $db2] [sqlite3_close $db2] } [list $::capi3_errno SQLITE_OK] -if {[clang_sanitize_address]==0} { +if {[clang_sanitize_address]==0 && 0} { do_test capi3-3.6.1-misuse { sqlite3_close $db2 } {SQLITE_MISUSE} From b8337932b36e85b85f9fc8efc4b141371078c119 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 21 May 2024 11:11:29 +0000 Subject: [PATCH 0414/1030] Fix the -> and ->> operators so that when the RHS is a string that looks like a number, it is still treated as a string, because that is what PG does. [forum:/forumpost/9e52cdfe15c3926e|Forum post 9e52cdfe15c3926e]. FossilOrigin-Name: de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/json.c | 9 +-------- test/json102.test | 31 +++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 374394b147..cccb4e7b93 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sa\scapi3\stest\sfrom\s2007\sthat\sdepends\supon\sundefined\sbehavior\s(UAF). -D 2024-05-20T19:59:32.762 +C Fix\sthe\s->\sand\s->>\soperators\sso\sthat\swhen\sthe\sRHS\sis\sa\sstring\sthat\slooks\slike\na\snumber,\sit\sis\sstill\streated\sas\sa\sstring,\sbecause\sthat\sis\swhat\sPG\sdoes.\n[forum:/forumpost/9e52cdfe15c3926e|Forum\spost\s9e52cdfe15c3926e]. +D 2024-05-21T11:11:29.610 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -714,7 +714,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 4bd7c7e54a1062dcd0214b7a6296f7194eb10fb14d3ddca1ed20b01c2a86a18c -F src/json.c e2e40760d6689134c3e2ece38c6a496b34ff5e2661a8f238444a119af666fdce +F src/json.c bf1b51e32158b3d01d96a878d3dba8d2e633a7e5bf2534d4617f89de8a6b9a91 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 8a59d297ec77e6b78550433bfccb95a1b26f2fb69aaaf233206e21579a1cfcc1 @@ -1358,7 +1358,7 @@ F test/json/json-q1.txt 65f9d1cdcc4cffa9823fb73ed936aae5658700cd001fde448f68bfb9 F test/json/json-speed-check.sh 912ee03e700a65c827ee0c7b4752c21ec5ef69cf7679d2f482ca817042bead52 x F test/json/jsonb-q1.txt 1e180fe6491efab307e318b22879e3a736ac9a96539bbde7911a13ee5b33abc7 F test/json101.test 30db5b055b103ccabc53a29cfe6cda3345d07e171aeb25403dafa04f19e98b19 -F test/json102.test 557a46e16df1aa9bdbc4076a71a45814ea0e7503d6621d87d42a8c04cbc2b0ef +F test/json102.test 4b3a0f94535f033239b67c13dbee8b47d2b5ee467e0f2fdab5eadf370bbe5fd3 F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba0114348c1 F test/json105.test 043838b56e68f3252a0dcf5be1689016f6f3f05056f8dcfcdc9d074f4d932988 @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c13205d66b8406cccfc937c88ac515fa758fe2ade8b3d30f0c1e79fe974e9600 -R afa580b78e84297da9d918d4b239628f +P a60a0b75137c015e97b8dcd0070444fcb608f502ce88b2ee744dd6230dbdc120 +R 83e05fc293c948e3f22eef5dc075f9b9 U drh -Z dd88f180c52872ac43a520d8ec94266a +Z 9111b0a4bac0297dbe95168c7eba24aa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 58c5ec3196..2b76157e99 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a60a0b75137c015e97b8dcd0070444fcb608f502ce88b2ee744dd6230dbdc120 \ No newline at end of file +de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb \ No newline at end of file diff --git a/src/json.c b/src/json.c index 44ae846461..4db468c92d 100644 --- a/src/json.c +++ b/src/json.c @@ -3795,13 +3795,6 @@ static void jsonArrayLengthFunc( jsonParseFree(p); } -/* True if the string is all digits */ -static int jsonAllDigits(const char *z, int n){ - int i; - for(i=0; i $[NUMBER] // Not PG. Purely for convenience */ jsonStringInit(&jx, ctx); - if( jsonAllDigits(zPath, nPath) ){ + if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){ jsonAppendRawNZ(&jx, "[", 1); jsonAppendRaw(&jx, zPath, nPath); jsonAppendRawNZ(&jx, "]", 2); diff --git a/test/json102.test b/test/json102.test index 15a54b47c4..1a00cb67ae 100644 --- a/test/json102.test +++ b/test/json102.test @@ -764,4 +764,35 @@ do_execsql_test json102-1720 { SELECT * FROM t1; } {ok 2023-08-03 876 5 {{"x":77,"y":6}}} +# 2024-05-21 https://sqlite.org/forum/forumpost/9e52cdfe15c3926e +# What if the RHS of the -> or ->> operator is a string that looks +# like a number? PostgreSQL treats it as a string. +# +do_execsql_test json102-1800 { + SELECT '{"1":"one","2":"two","3":"three"}'->>'2'; +} two +db null NULL +do_execsql_test json102-1801 { + SELECT '{"1":"one","2":"two","3":"three"}'->>2; +} NULL +do_execsql_test json102-1810 { + SELECT '["zero","one","two"]'->>'1'; +} NULL +do_execsql_test json102-1811 { + SELECT '["zero","one","two"]'->>1; +} one +do_execsql_test json102-1820 { + SELECT '{"1":"one","2":"two","3":"three"}'->'2'; +} {{"two"}} +do_execsql_test json102-1821 { + SELECT '{"1":"one","2":"two","3":"three"}'->2; +} {NULL} +do_execsql_test json102-1830 { + SELECT '["zero","one","two"]'->'1'; +} {NULL} +do_execsql_test json102-1831 { + SELECT '["zero","one","two"]'->1; +} {{"one"}} + + finish_test From 33087dbf3059d29ffe0bd1ff495d886db0747dd4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 21 May 2024 13:34:26 +0000 Subject: [PATCH 0415/1030] Fix harmless compiler warnings. FossilOrigin-Name: aab59f9f7c1c4cfac4d29d7c7a381583295312baf3b9a75e30a617b1541e12e1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 2 +- src/vdbemem.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index cccb4e7b93..09a9da69c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s->\sand\s->>\soperators\sso\sthat\swhen\sthe\sRHS\sis\sa\sstring\sthat\slooks\slike\na\snumber,\sit\sis\sstill\streated\sas\sa\sstring,\sbecause\sthat\sis\swhat\sPG\sdoes.\n[forum:/forumpost/9e52cdfe15c3926e|Forum\spost\s9e52cdfe15c3926e]. -D 2024-05-21T11:11:29.610 +C Fix\sharmless\scompiler\swarnings. +D 2024-05-21T13:34:26.341 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -755,7 +755,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 1a841c38974d45cf15a7611398479182b61ad4c187423c380741d8b1688fe607 -F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b6 +F src/shell.c.in 885dafabb3f16d68bdb4576683afb0e39a1939f50985b162255bf656c470babf F src/sqlite.h.in c71d9ef76a6d32dc7ff2d373f2e57ce09056af26c1457bcadae5358b7628c7c3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -830,7 +830,7 @@ F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df F src/vdbeaux.c 3bcf13776c39bf660a52b4b97f6389a421c2756f9ffbf4c0d94f73e1935d8d9c F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 -F src/vdbemem.c 385c8b89da3b5ef9a468d77a466958aa72ee1212d5cb005f23ec63df1d413054 +F src/vdbemem.c 831a244831eaa45335f9ae276b50a7a82ee10d8c46c2c72492d4eb8c98d94d89 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a60a0b75137c015e97b8dcd0070444fcb608f502ce88b2ee744dd6230dbdc120 -R 83e05fc293c948e3f22eef5dc075f9b9 +P de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb +R 48a1dfe76e5f9714f60170e25f19a5ec U drh -Z 9111b0a4bac0297dbe95168c7eba24aa +Z 85ec8dacf40c6db93df32b415530df39 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2b76157e99..0c3ade05c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb \ No newline at end of file +aab59f9f7c1c4cfac4d29d7c7a381583295312baf3b9a75e30a617b1541e12e1 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 2984853442..0029682f32 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -7943,7 +7943,7 @@ static struct { int nHit; /* Number of hits seen so far */ int nRepeat; /* Turn off after this many hits. 0 for never */ int nSkip; /* Skip this many before first fault */ -} faultsim_state = {-1, 0, 0, 0, 0, 0, 0}; +} faultsim_state = {-1, 0, 0, 0, 0, 0, 0, 0}; /* ** This is the fault-sim callback diff --git a/src/vdbemem.c b/src/vdbemem.c index 8a4011e10f..8e2aa4a6c9 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1959,7 +1959,7 @@ int sqlite3Stat4Column( assert( iCol>0 ); iHdr = getVarint32(a, nHdr); - if( nHdr>nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT; + if( nHdr>(u32)nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT; iField = nHdr; for(i=0; i<=iCol; i++){ iHdr += getVarint32(&a[iHdr], t); From 25266685561fbe6db25dd72e3ae9b70a4a8da02f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 May 2024 14:54:46 +0000 Subject: [PATCH 0416/1030] Do not attempt to run mmapcorrupt.test with builds that do not support mmap(). FossilOrigin-Name: 54a49f1847f95c377f0f611eb10f635b879bba8c2eb25e65e2f66a56f4f9a505 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/mmapcorrupt.test | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 09a9da69c2..20bade802b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings. -D 2024-05-21T13:34:26.341 +C Do\snot\sattempt\sto\srun\smmapcorrupt.test\swith\sbuilds\sthat\sdo\snot\ssupport\smmap(). +D 2024-05-21T14:54:46.724 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1447,7 +1447,7 @@ F test/mmap1.test 18de3fd7b70a777af6004ca2feecfcdd3d0be17fa04058e808baf530c94b1a F test/mmap2.test 9d6dd9ddb4ad2379f29cc78f38ce1e63ed418022 F test/mmap3.test b3c297e78e6a8520aafcc1a8f140535594c9086e F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93 -F test/mmapcorrupt.test 0d89724591f22a376019f3df60d075b838dd2ba6dae6effb0be465c49cf86d4a +F test/mmapcorrupt.test 470fb44fe92e99c1d23701d156f8c17865f5b027063c9119dcfdb842791f4465 F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3 F test/mmapwarm.test 2272005969cd17a910077bd5082f70bc1fefad9a875afec7fc9af483898ecaf3 F test/multiplex.test d74c034e52805f6de8cc5432cef8c9eb774bb64ec29b83a22effc8ca4dac1f08 @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb -R 48a1dfe76e5f9714f60170e25f19a5ec -U drh -Z 85ec8dacf40c6db93df32b415530df39 +P aab59f9f7c1c4cfac4d29d7c7a381583295312baf3b9a75e30a617b1541e12e1 +R 818d4377176309545f29a9d7bd0669c5 +U dan +Z 22a050d68d008d1c3bd9c69172084f42 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0c3ade05c4..4f0d499f6c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aab59f9f7c1c4cfac4d29d7c7a381583295312baf3b9a75e30a617b1541e12e1 \ No newline at end of file +54a49f1847f95c377f0f611eb10f635b879bba8c2eb25e65e2f66a56f4f9a505 \ No newline at end of file diff --git a/test/mmapcorrupt.test b/test/mmapcorrupt.test index 70dbe84647..d434ec1836 100644 --- a/test/mmapcorrupt.test +++ b/test/mmapcorrupt.test @@ -16,6 +16,10 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix mmapcorrupt +ifcapable !mmap { + finish_test + return +} database_may_be_corrupt db close From 3731703dbb9dc9f88c8ed0da5bb88c35399478c0 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 May 2024 17:37:50 +0000 Subject: [PATCH 0417/1030] Ensure an sqlite_dbdata cursor is properly reset before being used again, even if it has already encountered database corruption. FossilOrigin-Name: 3210e1ca4d0efedf9710c97abd050ba10d3af98cb1f029c26daa84daf42fbc7e --- ext/recover/dbdata.c | 2 ++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ext/recover/dbdata.c b/ext/recover/dbdata.c index a999f1a853..109aeef2d6 100644 --- a/ext/recover/dbdata.c +++ b/ext/recover/dbdata.c @@ -325,6 +325,7 @@ static void dbdataResetCursor(DbdataCursor *pCsr){ sqlite3_free(pCsr->aPage); dbdataBufferFree(&pCsr->rec); pCsr->aPage = 0; + pCsr->nRec = 0; } /* @@ -596,6 +597,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ } }else{ /* If there is no record loaded, load it now. */ + assert( pCsr->rec.aBuf!=0 || pCsr->nRec==0 ); if( pCsr->nRec==0 ){ int bHasRowid = 0; int nPointer = 0; diff --git a/manifest b/manifest index 20bade802b..42c7c3296e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sattempt\sto\srun\smmapcorrupt.test\swith\sbuilds\sthat\sdo\snot\ssupport\smmap(). -D 2024-05-21T14:54:46.724 +C Ensure\san\ssqlite_dbdata\scursor\sis\sproperly\sreset\sbefore\sbeing\sused\sagain,\seven\sif\sit\shas\salready\sencountered\sdatabase\scorruption. +D 2024-05-21T17:37:50.943 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -478,7 +478,7 @@ F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69 F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055 -F ext/recover/dbdata.c 0a943861ec096de375097e0aaff07b480a002eab9b01fecd3f9e828faf4ef624 +F ext/recover/dbdata.c a22ecd689f00ff2ad33b5633c4ef84c8f088c65faeac18d4eb73c128395c7aec F ext/recover/recover1.test e16d78e94183562abff569967b18b7c77451d7044365516cd0fe14713a284851 F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a F ext/recover/recoverbuild.test c74170e0f7b02456af41838afeb5353fdb985a48cc2331d661bbabbca7c6b8e3 @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aab59f9f7c1c4cfac4d29d7c7a381583295312baf3b9a75e30a617b1541e12e1 -R 818d4377176309545f29a9d7bd0669c5 +P 54a49f1847f95c377f0f611eb10f635b879bba8c2eb25e65e2f66a56f4f9a505 +R 03f38bbe86d08cc2accd8330faccbd25 U dan -Z 22a050d68d008d1c3bd9c69172084f42 +Z 9c29ad8747a8fddc9cb270f4ac86c97e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4f0d499f6c..b6db5e040b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54a49f1847f95c377f0f611eb10f635b879bba8c2eb25e65e2f66a56f4f9a505 \ No newline at end of file +3210e1ca4d0efedf9710c97abd050ba10d3af98cb1f029c26daa84daf42fbc7e \ No newline at end of file From bebe2d8be8acfd02592c4972f4ba32c3b4e4a33f Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 23 May 2024 13:25:27 +0000 Subject: [PATCH 0418/1030] Version 3.46.0 FossilOrigin-Name: 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e --- manifest | 13 ++++++++----- manifest.uuid | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 42c7c3296e..430e219336 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\san\ssqlite_dbdata\scursor\sis\sproperly\sreset\sbefore\sbeing\sused\sagain,\seven\sif\sit\shas\salready\sencountered\sdatabase\scorruption. -D 2024-05-21T17:37:50.943 +C Version\s3.46.0 +D 2024-05-23T13:25:27.566 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2191,8 +2191,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 54a49f1847f95c377f0f611eb10f635b879bba8c2eb25e65e2f66a56f4f9a505 +P 3210e1ca4d0efedf9710c97abd050ba10d3af98cb1f029c26daa84daf42fbc7e R 03f38bbe86d08cc2accd8330faccbd25 -U dan -Z 9c29ad8747a8fddc9cb270f4ac86c97e +T +sym-major-release * +T +sym-release * +T +sym-version-3.46.0 * +U drh +Z 82f35d0822d1dfbb574e5dd2459b4a36 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b6db5e040b..db75fc9bf9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3210e1ca4d0efedf9710c97abd050ba10d3af98cb1f029c26daa84daf42fbc7e \ No newline at end of file +96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e \ No newline at end of file From 18ec0d4a34f5ccea7230cbdbb14ffa5467046df5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 23 May 2024 14:58:31 +0000 Subject: [PATCH 0419/1030] Increase the version number to 3.47.0 to begin the next development cycle. FossilOrigin-Name: 20e228a22e4c5a8d62fae003ac176de62126d8e121871c5ca14a5480c4d4b6a2 --- VERSION | 2 +- autoconf/tea/configure.ac | 2 +- configure | 18 +++++++++--------- manifest | 19 ++++++++----------- manifest.uuid | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/VERSION b/VERSION index 850ac8f28c..5e895b2435 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.46.0 +3.47.0 diff --git a/autoconf/tea/configure.ac b/autoconf/tea/configure.ac index f188f22039..4fe1a83968 100644 --- a/autoconf/tea/configure.ac +++ b/autoconf/tea/configure.ac @@ -19,7 +19,7 @@ dnl to configure the system for the local environment. # so that we create the export library with the dll. #----------------------------------------------------------------------- -AC_INIT([sqlite],[3.46.0]) +AC_INIT([sqlite],[3.47.0]) #-------------------------------------------------------------------- # Call TEA_INIT as the first TEA_ macro to set up initial vars. diff --git a/configure b/configure index f6717f96fb..625d3f8cb9 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.46.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.47.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.46.0' -PACKAGE_STRING='sqlite 3.46.0' +PACKAGE_VERSION='3.47.0' +PACKAGE_STRING='sqlite 3.47.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1472,7 +1472,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.46.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.47.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1537,7 +1537,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.46.0:";; + short | recursive ) echo "Configuration of sqlite 3.47.0:";; esac cat <<\_ACEOF @@ -1668,7 +1668,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.46.0 +sqlite configure 3.47.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2087,7 +2087,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.46.0, which was +It was created by sqlite $as_me 3.47.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -12481,7 +12481,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.46.0, which was +This file was extended by sqlite $as_me 3.47.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12547,7 +12547,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.46.0 +sqlite config.status 3.47.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/manifest b/manifest index 430e219336..b5212d24ce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.46.0 -D 2024-05-23T13:25:27.566 +C Increase\sthe\sversion\snumber\sto\s3.47.0\sto\sbegin\sthe\snext\sdevelopment\scycle. +D 2024-05-23T14:58:31.543 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -7,7 +7,7 @@ F Makefile.in 993a7874e3d3721df61846f03dda4a9ef7490da11953ae36ba1bb0c0346eaf4a F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc e64a52619310d3067f6c38f56eedd15918a82dade70954197d6da486ad99d7f4 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 -F VERSION c84541c6a9e8426462176fbb1f9ecb5cfd7d1bb56228053ff7eeba8841673eb6 +F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 F art/icon-80x90.gif 65509ce3e5f86a9cd64fe7fca2d23954199f31fe44c1e09e208c80fb83d87031 @@ -24,7 +24,7 @@ F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d F autoconf/tea/Makefile.in 106a96f2f745d41a0f6193f1de98d7355830b65d45032c18cd7c90295ec24196 F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 -F autoconf/tea/configure.ac 9e74135563a901d9b1a019bad1c9d73a6659fa32325f6a565bef72bfb0ec7297 +F autoconf/tea/configure.ac 0deb5d6c49c8119f75f436488219fc043127d72057af5dfba2c9ce096a5734bc F autoconf/tea/doc/sqlite3.n e1fe45d4f5286ee3d0ccc877aca2a0def488e9bb F autoconf/tea/license.terms 13bd403c9610fd2b76ece0ab50c4c5eda933d523 F autoconf/tea/pkgIndex.tcl.in b9eb6dd37f64e08e637d576b3c83259814b9cddd78bec4af2e5abfc6c5c750ce @@ -35,7 +35,7 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 40f7af9ed5ca0d44a4b9bc7ad34f1ee4867bb4eeb19e75036be6bed66193a498 x +F configure 27d144c2edfa993ac155a2ad5e6b431e4ec811159598ef55a59f345bc2e5e533 x F configure.ac f25bd7843120f2c2b8bc9db5a92b0502bbdd28e68907415c3d42fc8e57c657b9 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd @@ -2191,11 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3210e1ca4d0efedf9710c97abd050ba10d3af98cb1f029c26daa84daf42fbc7e -R 03f38bbe86d08cc2accd8330faccbd25 -T +sym-major-release * -T +sym-release * -T +sym-version-3.46.0 * +P 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e +R c841fa8f021d8f0e7db7ccbf58585698 U drh -Z 82f35d0822d1dfbb574e5dd2459b4a36 +Z 19bbf589edce5b1123a18efb65256692 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index db75fc9bf9..0702dba946 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e \ No newline at end of file +20e228a22e4c5a8d62fae003ac176de62126d8e121871c5ca14a5480c4d4b6a2 \ No newline at end of file From e6d3c572045518a70ff20aaa1ed59d77fc759f40 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 23 May 2024 23:26:04 +0000 Subject: [PATCH 0420/1030] Fix the window-function group_concat() so that it returns an empty string if it has one or more empty string inputs. This fixes a bug introduced by [c6da39115d3e2b0f] on 2019-03-26 (version 3.28.0) and reported by [forum/forumpost/bf8f43aa522c2299|forum post bf8f43aa522c2299]. FossilOrigin-Name: cec6bb3fc9932ea78ec8e63d9c2d4e56a4d94b8973b9ea46033cc4baa87c0476 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/func.c | 2 ++ test/window1.test | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index a44f6d62d5..c0b624d26b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\svarious\senhancements\sthat\swere\sbeing\sheld\son\sa\sbranch\suntil\safter\sthe\n3.46.0\srelease.\s\s(1)\sAllow\sarbitrary\sexpressions\sin\sthe\ssecond\sargument\sto\nthe\sRAISE()\sfunction.\s(2)\sPerformance\soptimization\sto\sthe\sOP_OpenRead\sand\nOP_OpenWrite\sbytecode\soperators.\s(3)\sAllow\sFTS5\stables\sto\sbe\sdropped\seven\sif\nthe\sassociated\stokenizer\sis\snot\savailable.\s\s(4)\sPerformance\soptimizations\sin\nFTS5.\s\s(5)\sGenerate\sbetter\sbytecode\sto\simprove\sperformance\sof\sONEROW\sscans. -D 2024-05-23T15:05:57.348 +C Fix\sthe\swindow-function\sgroup_concat()\sso\sthat\sit\sreturns\san\sempty\sstring\s\nif\sit\shas\sone\sor\smore\sempty\sstring\sinputs.\s\sThis\sfixes\na\sbug\sintroduced\sby\s[c6da39115d3e2b0f]\son\s2019-03-26\s(version\s3.28.0)\sand\nreported\sby\s[forum/forumpost/bf8f43aa522c2299|forum\spost\sbf8f43aa522c2299]. +D 2024-05-23T23:26:04.652 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -707,7 +707,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c 50e71ed518f1b1ba8401006922a309e200d205b2ca5b93d6fd8a006a336dbf67 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a -F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f +F src/func.c f1f57c6863c1380f31ecf3d61732495bfff847a8e35a832c7e306e310db5a799 F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -2034,7 +2034,7 @@ F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2 F test/win32lock.test e0924eb8daac02bf80e9da88930747bd44dd9b230b7759fed927b1655b467c9c F test/win32longpath.test 4baffc3acb2e5188a5e3a895b2b543ed09e62f7c72d713c1feebf76222fe9976 F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc -F test/window1.test 5e8abe56a7d667eeddbba6de180086dcf69ed528d046447a25464f945ece101f +F test/window1.test 79dc3b9a2226f622d7e104a1fc750d1c4c3c08d6147b59085bdbe05352947ffa F test/window2.tcl 492c125fa550cda1dd3555768a2303b3effbeceee215293adf8871efc25f1476 F test/window2.test e466a88bd626d66edc3d352d7d7e1d5531e0079b549ba44efb029d1fbff9fd3c F test/window3.tcl acea6e86a4324a210fd608d06741010ca83ded9fde438341cb978c49928faf03 @@ -2191,9 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 20e228a22e4c5a8d62fae003ac176de62126d8e121871c5ca14a5480c4d4b6a2 6dc6472175bccbed15ebf6811c209d1a0b5fad60158fb32040210f2cdae916a6 -R 8bddc71c9aad2b206ce1df483c24253e -T +closed 6dc6472175bccbed15ebf6811c209d1a0b5fad60158fb32040210f2cdae916a6 +P 1e5385ffc30743412ade1536583504eec36790cac5355042aa1e12d8d2271d1f +R c2083a7140dca6efcab0abf6ed5aec5a U drh -Z bb39af0ce41ef3b8a3492c4ff2e0362a +Z b173c105f45a8c5809d898ff2ee0b454 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3c034e800f..6de5dbf4ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1e5385ffc30743412ade1536583504eec36790cac5355042aa1e12d8d2271d1f \ No newline at end of file +cec6bb3fc9932ea78ec8e63d9c2d4e56a4d94b8973b9ea46033cc4baa87c0476 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 18004984d9..058f71cb64 100644 --- a/src/func.c +++ b/src/func.c @@ -2206,6 +2206,8 @@ static void groupConcatValue(sqlite3_context *context){ sqlite3_result_error_toobig(context); }else if( pAccum->accError==SQLITE_NOMEM ){ sqlite3_result_error_nomem(context); + }else if( pGCC->nAccum>0 && pAccum->nChar==0 ){ + sqlite3_result_text(context, "", 1, SQLITE_STATIC); }else{ const char *zText = sqlite3_str_value(pAccum); sqlite3_result_text(context, zText, pAccum->nChar, SQLITE_TRANSIENT); diff --git a/test/window1.test b/test/window1.test index d8348a8980..457852c145 100644 --- a/test/window1.test +++ b/test/window1.test @@ -2375,5 +2375,23 @@ do_execsql_test 77.2 { SELECT max(~likely(x)) FILTER (WHERE true) FROM t1 INDEXED BY t1x GROUP BY x; } {-2 -3 -5 -9} +# 2024-05-23 https://sqlite.org/forum/forumpost/bf8f43aa522c2299 +# +# A bug in group_concat() when used as a window function, reported +# just hours after the 3.46.0 release, though first appearing +# in 3.28.0. +# +# When used as a window function, a group_concat() was not +# correctly distinguishing between NULL and empty-string for +# its return value. +# +do_execsql_test 78.1 { + SELECT quote(group_concat(x) OVER ()) FROM (SELECT '' AS x); +} '' +do_execsql_test 78.2 { + SELECT quote(group_concat(x) OVER ( + ORDER BY y RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING + )) FROM (SELECT 'abc' AS x, 1 AS y); +} NULL finish_test From 7c492a250b912ac49fce7b816f0700568586af20 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 May 2024 13:33:39 +0000 Subject: [PATCH 0421/1030] Fix an "ifcapable" expression in values.test. FossilOrigin-Name: b8442d2a6012b1f2e15381613267db0982e36bb4c748b15b56e668e0d0a3d0d2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/values.test | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c0b624d26b..d3f4577a14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\swindow-function\sgroup_concat()\sso\sthat\sit\sreturns\san\sempty\sstring\s\nif\sit\shas\sone\sor\smore\sempty\sstring\sinputs.\s\sThis\sfixes\na\sbug\sintroduced\sby\s[c6da39115d3e2b0f]\son\s2019-03-26\s(version\s3.28.0)\sand\nreported\sby\s[forum/forumpost/bf8f43aa522c2299|forum\spost\sbf8f43aa522c2299]. -D 2024-05-23T23:26:04.652 +C Fix\san\s"ifcapable"\sexpression\sin\svalues.test. +D 2024-05-24T13:33:39.715 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1931,7 +1931,7 @@ F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7 F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuum6.test b137b04bf3392d3f5c3b8fda0ce85a6775a70ca112f6559f74ff52dc9ce042fd F test/vacuummem.test 4b30f5b95a9ff86e9d5c20741e50a898b2dc10b0962a3211571eb165357003fb -F test/values.test 52102ad9e5068b449429e40a976486a52246041f7cd79d086a2b170e77dec925 +F test/values.test 0eda08a6ce6545f1ab012dff4cc72a7dd0fee2510f42444136bb2b2b5ed84bc0 F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -2191,8 +2191,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1e5385ffc30743412ade1536583504eec36790cac5355042aa1e12d8d2271d1f -R c2083a7140dca6efcab0abf6ed5aec5a -U drh -Z b173c105f45a8c5809d898ff2ee0b454 +P cec6bb3fc9932ea78ec8e63d9c2d4e56a4d94b8973b9ea46033cc4baa87c0476 +R 203911405be61016c300aab6226a6699 +U dan +Z 51255f9b31c7a540d78da0504b6db5c1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6de5dbf4ef..e6c0f8bcc4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cec6bb3fc9932ea78ec8e63d9c2d4e56a4d94b8973b9ea46033cc4baa87c0476 \ No newline at end of file +b8442d2a6012b1f2e15381613267db0982e36bb4c748b15b56e668e0d0a3d0d2 \ No newline at end of file diff --git a/test/values.test b/test/values.test index fed2c5c6cb..c3c52ceb1e 100644 --- a/test/values.test +++ b/test/values.test @@ -380,7 +380,7 @@ do_execsql_test 10.2 { #------------------------------------------------------------------------- reset_db -ifcapable fts5 { +ifcapable fts3 { do_execsql_test 11.0 { CREATE VIRTUAL TABLE ft USING fts3(x); } From 31079226f78a3011b9de6c310c2df3ce727fe883 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 24 May 2024 14:16:06 +0000 Subject: [PATCH 0422/1030] Add the stmtrand() extension function for use in testing. FossilOrigin-Name: 5c97a5b9d163b1c427e002f3734687ca0384bc0da6a90fc4bfd358c654d3a7b3 --- Makefile.in | 1 + Makefile.msc | 1 + ext/misc/stmtrand.c | 97 +++++++++++++++++++++++++++++++++++++++++++++ main.mk | 1 + manifest | 24 ++++++----- manifest.uuid | 2 +- src/shell.c.in | 3 +- src/test1.c | 2 + test/stmtrand.test | 48 ++++++++++++++++++++++ 9 files changed, 166 insertions(+), 13 deletions(-) create mode 100644 ext/misc/stmtrand.c create mode 100644 test/stmtrand.test diff --git a/Makefile.in b/Makefile.in index c16e1c127d..4ce4b7392f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -454,6 +454,7 @@ TESTSRC += \ $(TOP)/ext/misc/remember.c \ $(TOP)/ext/misc/series.c \ $(TOP)/ext/misc/spellfix.c \ + $(TOP)/ext/misc/stmtrand.c \ $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/unionvtab.c \ $(TOP)/ext/misc/wholenumber.c \ diff --git a/Makefile.msc b/Makefile.msc index 5257cee981..a5191739ff 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1596,6 +1596,7 @@ TESTEXT = \ $(TOP)\ext\misc\remember.c \ $(TOP)\ext\misc\series.c \ $(TOP)\ext\misc\spellfix.c \ + $(TOP)\ext\misc\stmtrand.c \ $(TOP)\ext\misc\totype.c \ $(TOP)\ext\misc\unionvtab.c \ $(TOP)\ext\misc\wholenumber.c \ diff --git a/ext/misc/stmtrand.c b/ext/misc/stmtrand.c new file mode 100644 index 0000000000..b5e3b89a32 --- /dev/null +++ b/ext/misc/stmtrand.c @@ -0,0 +1,97 @@ +/* +** 2024-05-24 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** An SQL function that return pseudo-random non-negative integers. +** +** SELECT stmtrand(123); +** +** A special feature of this function is that the same sequence of random +** integers is returned for each invocation of the statement. This makes +** the results repeatable, and hence useful for testing. The argument is +** an integer which is the seed for the random number sequence. The seed +** is used by the first invocation of this function only and is ignored +** for all subsequent calls within the same statement. +** +** Resetting a statement (sqlite3_reset()) also resets the random number +** sequence. +*/ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 +#include +#include + +/* State of the pseudo-random number generator */ +typedef struct Stmtrand { + unsigned int x, y; +} Stmtrand; + +/* auxdata key */ +#define STMTRAND_KEY (-4418371) + +/* +** Function: stmtrand(SEED) +** +** Return a pseudo-random number. +*/ +static void stmtrandFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + Stmtrand *p; + + p = (Stmtrand*)sqlite3_get_auxdata(context, STMTRAND_KEY); + if( p==0 ){ + unsigned int seed; + p = sqlite3_malloc( sizeof(*p) ); + if( p==0 ){ + sqlite3_result_error_nomem(context); + return; + } + if( argc>=1 ){ + seed = (unsigned int)sqlite3_value_int(argv[0]); + }else{ + seed = 0; + } + p->x = seed | 1; + p->y = seed; + sqlite3_set_auxdata(context, STMTRAND_KEY, p, sqlite3_free); + p = (Stmtrand*)sqlite3_get_auxdata(context, STMTRAND_KEY); + if( p==0 ){ + sqlite3_result_error_nomem(context); + return; + } + } + p->x = (p->x>>1) ^ ((1+~(p->x&1)) & 0xd0000001); + p->y = p->y*1103515245 + 12345; + sqlite3_result_int(context, (int)((p->x ^ p->y)&0x7fffffff)); +} + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int sqlite3_stmtrand_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + int rc = SQLITE_OK; + SQLITE_EXTENSION_INIT2(pApi); + (void)pzErrMsg; /* Unused parameter */ + rc = sqlite3_create_function(db, "stmtrand", 1, SQLITE_UTF8, 0, + stmtrandFunc, 0, 0); + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "stmtrand", 0, SQLITE_UTF8, 0, + stmtrandFunc, 0, 0); + } + return rc; +} diff --git a/main.mk b/main.mk index 139e182eb1..baf8260417 100644 --- a/main.mk +++ b/main.mk @@ -364,6 +364,7 @@ TESTSRC += \ $(TOP)/ext/misc/remember.c \ $(TOP)/ext/misc/series.c \ $(TOP)/ext/misc/spellfix.c \ + $(TOP)/ext/misc/stmtrand.c \ $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/unionvtab.c \ $(TOP)/ext/misc/wholenumber.c \ diff --git a/manifest b/manifest index d3f4577a14..648a0b12d6 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Fix\san\s"ifcapable"\sexpression\sin\svalues.test. -D 2024-05-24T13:33:39.715 +C Add\sthe\sstmtrand()\sextension\sfunction\sfor\suse\sin\stesting. +D 2024-05-24T14:16:06.243 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 993a7874e3d3721df61846f03dda4a9ef7490da11953ae36ba1bb0c0346eaf4a +F Makefile.in 58c2cc5010aa5fd5e8eef6fe24d4ebcec7dc2e8c56f135d4f49e90a099bbc531 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc e64a52619310d3067f6c38f56eedd15918a82dade70954197d6da486ad99d7f4 +F Makefile.msc 993f8addade63bcac7192416e7161ceee60edcee2376299ea48b2a74c66ac2d5 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -418,6 +418,7 @@ F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c c0aa7b80d6df45f7da59d912b38752bcac1af53a5766966160e6c5cdd397dbea F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 +F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc F ext/misc/templatevtab.c 10f15b165b95423ddef593bc5dcb915ec4eb5e0f1066d585e5435a368b8bc22b F ext/misc/totype.c 75ed9827d19cc3b434fc2aeb60725d4d46e1534373615612a4d1cfdcc3d60922 F ext/misc/uint.c 053fed3bce2e89583afcd4bf804d75d659879bbcedac74d0fa9ed548839a030b @@ -674,7 +675,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk e5da4b6c13f2b15bba7f1efb0a47089dfdde0973e85a024785485655d59fd758 +F main.mk 9541ffdce424ddddb463e2480c3f1cb4067bbd3a6d2c84b3f083cb128a2fa721 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -755,7 +756,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 1a841c38974d45cf15a7611398479182b61ad4c187423c380741d8b1688fe607 -F src/shell.c.in 885dafabb3f16d68bdb4576683afb0e39a1939f50985b162255bf656c470babf +F src/shell.c.in 31249f26684467e95e529915bf486961c535ae8288ed7e79890cc9ed3d781d8f F src/sqlite.h.in c71d9ef76a6d32dc7ff2d373f2e57ce09056af26c1457bcadae5358b7628c7c3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -764,7 +765,7 @@ F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c ecbc3c99c0d0c3ed122a913f143026c26d38d57f33e06bb71185dd5c1efe37cd -F src/test1.c 310f43eb17a9252a7790726ca652e4ea3197da17c19eec93b8578863a49dc7b4 +F src/test1.c 6bd203421934f2af4d4a4b673f609879f1e0c35164f7e21d0d6cdc0da2eeee8f F src/test2.c 54520d0565ef2b9bf0f8f1dcac43dc4d06baf4ffe13d10905f8d8c3ad3e4b9ab F src/test3.c e5178558c41ff53236ae0271e9acb3d6885a94981d2eb939536ee6474598840e F src/test4.c 4533b76419e7feb41b40582554663ed3cd77aaa54e135cf76b3205098cd6e664 @@ -1664,6 +1665,7 @@ F test/startup.c 1beb5ca66fcc0fce95c3444db9d1674f90fc605499a574ae2434dcfc10d2280 F test/stat.test 123212a20ceb496893d5254a5f6c76442ce549fdc08d1702d8288a2bbaac8408 F test/statfault.test 064f43379e4992b5221b7d9ac887c313b3191f85cce605d78e416fc4045da64e F test/stmt.test 54ed2cc0764bf3e48a058331813c3dbd19fc1d0827c3d8369914a5d8f564ec75 +F test/stmtrand.test 340e2ea4841c5cdc02d36e33739769c5d907ab529b12bb535407def0e413ca17 F test/stmtvtab1.test 6873dfb24f8e79cbb5b799b95c2e4349060eb7a3b811982749a84b359468e2d5 F test/strict1.test 4d2b492152b984fd7e8196d23eb88e2ccb0ef9e46ca2f96c2ce7147ceef9d168 F test/strict2.test b22c7a98b5000aef937f1990776497f0e979b1a23bc4f63e2d53b00e59b20070 @@ -2191,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cec6bb3fc9932ea78ec8e63d9c2d4e56a4d94b8973b9ea46033cc4baa87c0476 -R 203911405be61016c300aab6226a6699 -U dan -Z 51255f9b31c7a540d78da0504b6db5c1 +P b8442d2a6012b1f2e15381613267db0982e36bb4c748b15b56e668e0d0a3d0d2 +R 01f61db2371d56efe0fc89de21914b9a +U drh +Z 5bafe7bbe2cfe723081ab4c42a45e0a5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e6c0f8bcc4..745372d9b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8442d2a6012b1f2e15381613267db0982e36bb4c748b15b56e668e0d0a3d0d2 \ No newline at end of file +5c97a5b9d163b1c427e002f3734687ca0384bc0da6a90fc4bfd358c654d3a7b3 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 0029682f32..2da78c3f25 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1221,9 +1221,9 @@ INCLUDE ../ext/misc/sqlar.c #endif INCLUDE ../ext/expert/sqlite3expert.h INCLUDE ../ext/expert/sqlite3expert.c - INCLUDE ../ext/intck/sqlite3intck.h INCLUDE ../ext/intck/sqlite3intck.c +INCLUDE ../ext/misc/stmtrand.c #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) #define SQLITE_SHELL_HAVE_RECOVER 1 @@ -5364,6 +5364,7 @@ static void open_db(ShellState *p, int openFlags){ #endif sqlite3_shathree_init(p->db, 0, 0); sqlite3_uint_init(p->db, 0, 0); + sqlite3_stmtrand_init(p->db, 0, 0); sqlite3_decimal_init(p->db, 0, 0); sqlite3_base64_init(p->db, 0, 0); sqlite3_base85_init(p->db, 0, 0); diff --git a/src/test1.c b/src/test1.c index 8faf5a397b..975758131e 100644 --- a/src/test1.c +++ b/src/test1.c @@ -8174,6 +8174,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( extern int sqlite3_remember_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_series_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*); + extern int sqlite3_stmtrand_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_unionvtab_init(sqlite3*,char**,const sqlite3_api_routines*); @@ -8207,6 +8208,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( { "remember", sqlite3_remember_init }, { "series", sqlite3_series_init }, { "spellfix", sqlite3_spellfix_init }, + { "stmtrand", sqlite3_stmtrand_init }, { "totype", sqlite3_totype_init }, { "unionvtab", sqlite3_unionvtab_init }, { "wholenumber", sqlite3_wholenumber_init }, diff --git a/test/stmtrand.test b/test/stmtrand.test new file mode 100644 index 0000000000..e2f6935b85 --- /dev/null +++ b/test/stmtrand.test @@ -0,0 +1,48 @@ +# 2024-05-24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Verify that the stmtrand() extension function works. +# +# Stmtrand() is a pseudo-random number generator designed for testing. +# it has the property that it returns the same sequence of pseudo-random +# numbers for each SQL statement invocation. This makes it suitable for +# testing because the results are reproducible. +# +# The optional argument is the seed for the PRNG. The seed is only used +# on the first invocation. If the argument is omitted, a seed of 0 is +# used. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix stmtrand + +load_static_extension db stmtrand + +do_execsql_test 1.1 { + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<30) + SELECT stmtrand()%10 FROM c +} {4 1 8 3 6 1 4 9 2 1 2 1 0 1 8 1 4 7 6 1 8 7 0 3 0 9 4 5 9 9} +do_execsql_test 1.2 { + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<30) + SELECT stmtrand(0)%10 FROM c +} {4 1 8 3 6 1 4 9 2 1 2 1 0 1 8 1 4 7 6 1 8 7 0 3 0 9 4 5 9 9} +do_execsql_test 1.3 { + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<30) + SELECT stmtrand(1)%10 FROM c +} {3 8 9 4 7 2 3 8 5 2 7 0 3 0 7 2 5 6 1 8 5 6 7 8 7 2 9 6 8 0} +do_execsql_test 1.4 { + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<30) + SELECT stmtrand(x)%10 FROM c +} {3 8 9 4 7 2 3 8 5 2 7 0 3 0 7 2 5 6 1 8 5 6 7 8 7 2 9 6 8 0} + + +finish_test From 89b04f37864a3dcd30e2e2a6766eac5de3b51baa Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 May 2024 18:31:39 +0000 Subject: [PATCH 0423/1030] Ensure that queries like "SELECT indeterministic(a) FROM tbl GROUP BY 1" invoke the indeterministic function only once for each row of tbl. FossilOrigin-Name: 4555d66547e28cb110e1012b145bcf3aafb5d4bde05e9d27bcb4ca33837b28f5 --- manifest | 23 +++++++++++++---------- manifest.uuid | 2 +- src/expr.c | 6 +++--- src/select.c | 14 +++++++++++++- src/sqliteInt.h | 1 + test/distinct2.test | 23 +++++++++++++++++++++++ 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 648a0b12d6..3a1a676133 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sstmtrand()\sextension\sfunction\sfor\suse\sin\stesting. -D 2024-05-24T14:16:06.243 +C Ensure\sthat\squeries\slike\s"SELECT\sindeterministic(a)\sFROM\stbl\sGROUP\sBY\s1"\sinvoke\sthe\sindeterministic\sfunction\sonly\sonce\sfor\seach\srow\sof\stbl. +D 2024-05-24T18:31:39.505 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 50e71ed518f1b1ba8401006922a309e200d205b2ca5b93d6fd8a006a336dbf67 +F src/expr.c 585109ab97149b2d484697e7469f28c91d495cd1330cc760d24711b7be8d22fb F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c f1f57c6863c1380f31ecf3d61732495bfff847a8e35a832c7e306e310db5a799 @@ -755,12 +755,12 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 1a841c38974d45cf15a7611398479182b61ad4c187423c380741d8b1688fe607 +F src/select.c cbdaf9cb2d9a697ee9ce1484f27d2e96762d33cc19259aedfb818a68b9d3be10 F src/shell.c.in 31249f26684467e95e529915bf486961c535ae8288ed7e79890cc9ed3d781d8f F src/sqlite.h.in c71d9ef76a6d32dc7ff2d373f2e57ce09056af26c1457bcadae5358b7628c7c3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 6a9fa3902c9faca2b57060e822f2afadfbf96d64c4ede81e201f0e0c42d7e4aa +F src/sqliteInt.h 98ba756789b37f8d8217407ce077c31faf0b9b21d593b327c2b9667ad5bea1ac F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -1074,7 +1074,7 @@ F test/descidx2.test a0ba347037ff3b811f4c6ceca5fd0f9d5d72e74e59f2d9de346a9d2f6ad F test/descidx3.test 953c831df7ea219c73826dfbf2f6ee02d95040725aa88ccb4fa43d1a1999b926 F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e F test/distinct.test 691c9e850b0d0b56b66e7e235453198cb4cf0760e324b7403d3c5abbeab0a014 -F test/distinct2.test bb71cc7b5e58e895787f9910a788c254f679928d324732d063fe9bc202ecbe71 +F test/distinct2.test c936bb8652258c04bf066706284f5cd54ec693817399dbd6503c49d41ace626e F test/distinctagg.test 40d7169ae5846caaf62c6e307d2ca3c333daf9b6f7cde888956a339a97afe85f F test/e_blobbytes.test 4c01dfe4f12087b92b20705a3fdfded45dc4ed16d5a211fed4e1d2786ba68a52 F test/e_blobclose.test 692fc02a058476c2222a63d97e3f3b2b809c1842e5525ded7f854d540ac2e075 @@ -2193,8 +2193,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b8442d2a6012b1f2e15381613267db0982e36bb4c748b15b56e668e0d0a3d0d2 -R 01f61db2371d56efe0fc89de21914b9a -U drh -Z 5bafe7bbe2cfe723081ab4c42a45e0a5 +P 5c97a5b9d163b1c427e002f3734687ca0384bc0da6a90fc4bfd358c654d3a7b3 +R 5fdf8e25d08374c3b6caf60dac9645e5 +T *branch * group-by-consistency +T *sym-group-by-consistency * +T -sym-trunk * +U dan +Z 5149149f75ab1db4d2d6bfcada9a5ce2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 745372d9b3..2a7f5c0822 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c97a5b9d163b1c427e002f3734687ca0384bc0da6a90fc4bfd358c654d3a7b3 \ No newline at end of file +4555d66547e28cb110e1012b145bcf3aafb5d4bde05e9d27bcb4ca33837b28f5 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 7cd50e660d..4bab383635 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4243,7 +4243,7 @@ void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){ ** register iReg. The caller must ensure that iReg already contains ** the correct value for the expression. */ -static void exprToRegister(Expr *pExpr, int iReg){ +void sqlite3ExprToRegister(Expr *pExpr, int iReg){ Expr *p = sqlite3ExprSkipCollateAndLikely(pExpr); if( NEVER(p==0) ) return; p->op2 = p->op; @@ -5252,7 +5252,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ break; } testcase( pX->op==TK_COLUMN ); - exprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1)); + sqlite3ExprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1)); testcase( regFree1==0 ); memset(&opCompare, 0, sizeof(opCompare)); opCompare.op = TK_EQ; @@ -5602,7 +5602,7 @@ static void exprCodeBetween( compRight.op = TK_LE; compRight.pLeft = pDel; compRight.pRight = pExpr->x.pList->a[1].pExpr; - exprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1)); + sqlite3ExprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1)); if( xJump ){ xJump(pParse, &exprAnd, dest, jumpIfNull); }else{ diff --git a/src/select.c b/src/select.c index 9278ea18b8..9ff5c6c536 100644 --- a/src/select.c +++ b/src/select.c @@ -7847,12 +7847,18 @@ int sqlite3Select( */ if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0 + && OptimizationEnabled(db, SQLITE_GroupByOrder) #ifndef SQLITE_OMIT_WINDOWFUNC && p->pWin==0 #endif ){ p->selFlags &= ~SF_Distinct; pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0); + if( pGroupBy ){ + for(i=0; inExpr; i++){ + pGroupBy->a[i].u.x.iOrderByCol = i+1; + } + } p->selFlags |= SF_Aggregate; /* Notice that even thought SF_Distinct has been cleared from p->selFlags, ** the sDistinct.isTnct is still set. Hence, isTnct represents the @@ -8315,12 +8321,18 @@ int sqlite3Select( sortOut, sortPTab); } for(j=0; jnExpr; j++){ + int iOrderByCol = pGroupBy->a[j].u.x.iOrderByCol; + if( groupBySort ){ sqlite3VdbeAddOp3(v, OP_Column, sortPTab, j, iBMem+j); }else{ pAggInfo->directMode = 1; sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j); } + + if( iOrderByCol ){ + sqlite3ExprToRegister(p->pEList->a[iOrderByCol-1].pExpr, iAMem+j); + } } sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr, (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO); @@ -8336,9 +8348,9 @@ int sqlite3Select( ** and resets the aggregate accumulator registers in preparation ** for the next GROUP BY batch. */ - sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr); sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow); VdbeComment((v, "output one row")); + sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr); sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v); VdbeComment((v, "check abort flag")); sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index d98a4f7f06..f4f8fc5e49 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -5025,6 +5025,7 @@ void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int); int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); void sqlite3ExprCodeMove(Parse*, int, int, int); +void sqlite3ExprToRegister(Expr *pExpr, int iReg); void sqlite3ExprCode(Parse*, Expr*, int); #ifndef SQLITE_OMIT_GENERATED_COLUMNS void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int); diff --git a/test/distinct2.test b/test/distinct2.test index 958d9634fd..ca88f5a285 100644 --- a/test/distinct2.test +++ b/test/distinct2.test @@ -313,4 +313,27 @@ do_execsql_test 4020 { SELECT b FROM t1 UNION SELECT 1; } {1 { }} +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 5010 { + CREATE TABLE cnt(a); + WITH RECURSIVE cnt2(x) AS ( + VALUES(1) UNION ALL SELECT x+1 FROM cnt2 WHERE x<50 + ) + INSERT INTO cnt SELECT x FROM cnt2; +} + +do_execsql_test 5020 { + SELECT DISTINCT abs(random())%5 AS r FROM cnt ORDER BY r; +} {0 1 2 3 4} + +do_execsql_test 5030 { + SELECT abs(random())%5 AS r FROM cnt GROUP BY 1 ORDER BY 1; +} {0 1 2 3 4} + +do_execsql_test 5040 { + SELECT a FROM cnt WHERE a>45 GROUP BY 1; +} {46 47 48 49 50} + finish_test From 4aaf45e246c6dca14bab3ab4ac6e070ec795eb25 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 24 May 2024 20:18:16 +0000 Subject: [PATCH 0424/1030] When omitting result columns for the vector-IN optimization, make sure that any result-set column references in both the ORDER BY clause and the GROUP BY clause are updated appropriately. FossilOrigin-Name: f890812df0a57fcd201647640d8b9ee26047cd93cd7171bc6fd050f574649345 --- manifest | 17 ++++++--------- manifest.uuid | 2 +- src/wherecode.c | 58 ++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 53 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 3a1a676133..c89949eb99 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\squeries\slike\s"SELECT\sindeterministic(a)\sFROM\stbl\sGROUP\sBY\s1"\sinvoke\sthe\sindeterministic\sfunction\sonly\sonce\sfor\seach\srow\sof\stbl. -D 2024-05-24T18:31:39.505 +C When\somitting\sresult\scolumns\sfor\sthe\svector-IN\soptimization,\smake\ssure\sthat\nany\sresult-set\scolumn\sreferences\sin\sboth\sthe\sORDER\sBY\sclause\sand\sthe\nGROUP\sBY\sclause\sare\supdated\sappropriately. +D 2024-05-24T20:18:16.599 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -842,7 +842,7 @@ F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 9b2ab23fcc2198ebcee1e6e840a9ff22350668bd3a99195a5dc7299d5908370a F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 -F src/wherecode.c f5255f49d1f42b6e7e6b0362ff3522fa88cbcaa7213e52f9374744027ecdebca +F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -2193,11 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5c97a5b9d163b1c427e002f3734687ca0384bc0da6a90fc4bfd358c654d3a7b3 -R 5fdf8e25d08374c3b6caf60dac9645e5 -T *branch * group-by-consistency -T *sym-group-by-consistency * -T -sym-trunk * -U dan -Z 5149149f75ab1db4d2d6bfcada9a5ce2 +P 4555d66547e28cb110e1012b145bcf3aafb5d4bde05e9d27bcb4ca33837b28f5 +R 956873244f968f95be3366298765be9b +U drh +Z ab0b66dde2c2b53f84c20902891068f4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2a7f5c0822..eeb28cef23 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4555d66547e28cb110e1012b145bcf3aafb5d4bde05e9d27bcb4ca33837b28f5 \ No newline at end of file +f890812df0a57fcd201647640d8b9ee26047cd93cd7171bc6fd050f574649345 \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index a620a5ac06..30624be8a2 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -460,6 +460,39 @@ static void updateRangeAffinityStr( } } +/* +** The pOrderBy->a[].u.x.iOrderByCol values might be incorrect because +** columns might have been rearranged in the result set. This routine +** fixes them up. +** +** pEList is the new result set. The pEList->a[].u.x.iOrderByCol values +** contain the *old* locations of each expression. This is a temporary +** use of u.x.iOrderByCol, not its intended use. The caller must reset +** u.x.iOrderByCol back to zero for all entries in pEList before the +** caller returns. +** +** This routine changes pOrderBy->a[].u.x.iOrderByCol values from +** pEList->a[N].u.x.iOrderByCol into N+1. (The "+1" is because of the 1-based +** indexing used by iOrderByCol.) Or if no match, iOrderByCol is set to zero. +*/ +static void adjustOrderByCol(ExprList *pOrderBy, ExprList *pEList){ + int i, j; + if( pOrderBy==0 ) return; + for(i=0; inExpr; i++){ + int t = pOrderBy->a[i].u.x.iOrderByCol; + if( t==0 ) continue; + for(j=0; jnExpr; j++){ + if( pEList->a[j].u.x.iOrderByCol==t ){ + pOrderBy->a[i].u.x.iOrderByCol = j+1; + break; + } + } + if( j>=pEList->nExpr ){ + pOrderBy->a[i].u.x.iOrderByCol = 0; + } + } +} + /* ** pX is an expression of the form: (vector) IN (SELECT ...) @@ -522,7 +555,8 @@ static Expr *removeUnindexableInClauseTerms( iField = pLoop->aLTerm[i]->u.x.iField - 1; if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */ pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr); - pOrigRhs->a[iField].pExpr = 0; + pOrigRhs->a[iField].pExpr = 0; + if( pRhs ) pRhs->a[pRhs->nExpr-1].u.x.iOrderByCol = iField+1; if( pOrigLhs ){ assert( pOrigLhs->a[iField].pExpr!=0 ); pLhs = sqlite3ExprListAppend(pParse,pLhs,pOrigLhs->a[iField].pExpr); @@ -545,18 +579,16 @@ static Expr *removeUnindexableInClauseTerms( sqlite3ExprDelete(db, pNew->pLeft); pNew->pLeft = p; } - if( pSelect->pOrderBy ){ - /* If the SELECT statement has an ORDER BY clause, zero the - ** iOrderByCol variables. These are set to non-zero when an - ** ORDER BY term exactly matches one of the terms of the - ** result-set. Since the result-set of the SELECT statement may - ** have been modified or reordered, these variables are no longer - ** set correctly. Since setting them is just an optimization, - ** it's easiest just to zero them here. */ - ExprList *pOrderBy = pSelect->pOrderBy; - for(i=0; inExpr; i++){ - pOrderBy->a[i].u.x.iOrderByCol = 0; - } + + /* If either the ORDER BY clause or the GROUP BY clause contains + ** references to result-set columns, those references might now be + ** obsolete. So fix them up. + */ + assert( pRhs!=0 || db->mallocFailed ); + if( pRhs ){ + adjustOrderByCol(pSelect->pOrderBy, pRhs); + adjustOrderByCol(pSelect->pGroupBy, pRhs); + for(i=0; inExpr; i++) pRhs->a[i].u.x.iOrderByCol = 0; } #if 0 From 0e7a7e57cc28a3df6f5ffdc74c7540fcf126706b Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 May 2024 21:23:36 +0000 Subject: [PATCH 0425/1030] Fix a crash in fts5 that could occur within "PRAGMA integrity_check" if the specified tokenizer was unknown. FossilOrigin-Name: 061d7b69e6a43474cd7123a69f4ee65b5649a0b5e51474343defef5ae5262657 --- ext/fts5/fts5_expr.c | 6 +++++- ext/fts5/fts5_main.c | 22 ++++++++++++++-------- ext/fts5/test/fts5integrity.test | 27 +++++++++++++++++++++++++++ manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 7180e22f8a..b8958ba74e 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -324,7 +324,11 @@ int sqlite3Fts5ExprNew( } sqlite3_free(sParse.apPhrase); - if( 0==*pzErr ) *pzErr = sParse.zErr; + if( 0==*pzErr ){ + *pzErr = sParse.zErr; + }else{ + sqlite3_free(sParse.zErr); + } return sParse.rc; } diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 384fdc1c19..71f3a9f0f0 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2989,17 +2989,23 @@ static int fts5IntegrityMethod( assert( pzErr!=0 && *pzErr==0 ); UNUSED_PARAM(isQuick); + assert( pTab->p.pConfig->pzErrmsg==0 ); + pTab->p.pConfig->pzErrmsg = pzErr; rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, 0); - if( (rc&0xff)==SQLITE_CORRUPT ){ - *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", - zSchema, zTabname); - rc = (*pzErr) ? SQLITE_OK : SQLITE_NOMEM; - }else if( rc!=SQLITE_OK ){ - *pzErr = sqlite3_mprintf("unable to validate the inverted index for" - " FTS5 table %s.%s: %s", - zSchema, zTabname, sqlite3_errstr(rc)); + if( *pzErr==0 && rc!=SQLITE_OK ){ + if( (rc&0xff)==SQLITE_CORRUPT ){ + *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", + zSchema, zTabname); + rc = (*pzErr) ? SQLITE_OK : SQLITE_NOMEM; + }else{ + *pzErr = sqlite3_mprintf("unable to validate the inverted index for" + " FTS5 table %s.%s: %s", + zSchema, zTabname, sqlite3_errstr(rc)); + } } + sqlite3Fts5IndexCloseReader(pTab->p.pIndex); + pTab->p.pConfig->pzErrmsg = 0; return rc; } diff --git a/ext/fts5/test/fts5integrity.test b/ext/fts5/test/fts5integrity.test index 1bb367538d..7936729340 100644 --- a/ext/fts5/test/fts5integrity.test +++ b/ext/fts5/test/fts5integrity.test @@ -380,5 +380,32 @@ do_execsql_test 12.3 { } {ok} +#------------------------------------------------------------------- +reset_db +do_execsql_test 13.1 { + CREATE VIRTUAL TABLE t1 USING fts5(a, tokenize=ascii); + INSERT INTO t1 VALUES('a b c'), ('d e f'); + PRAGMA integrity_check; +} {ok} + +db close +sqlite3 db test.db +do_catchsql_test 13.2 { + PRAGMA integrity_check; +} {0 ok} + +do_execsql_test 13.3 { + PRAGMA writable_schema = 1; + UPDATE sqlite_schema SET sql = 'CREATE VIRTUAL TABLE t1 USING fts5(a, tokenize=blah)' + WHERE name = 't1'; +} + +db close +sqlite3 db test.db +breakpoint +do_catchsql_test 13.4 { + PRAGMA integrity_check; +} {1 {SQL logic error}} + finish_test diff --git a/manifest b/manifest index 648a0b12d6..ed6476718f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sstmtrand()\sextension\sfunction\sfor\suse\sin\stesting. -D 2024-05-24T14:16:06.243 +C Fix\sa\scrash\sin\sfts5\sthat\scould\soccur\swithin\s"PRAGMA\sintegrity_check"\sif\sthe\sspecified\stokenizer\swas\sunknown. +D 2024-05-24T21:23:36.411 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -97,10 +97,10 @@ F ext/fts5/fts5Int.h 407ee36addad0ae6df5d37a811f0bd509ab6708b29640884ed5c7509e5f F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 74093394dc26750becc302922e5fe308a8597a70e6e83e66c892242952468163 -F ext/fts5/fts5_expr.c a84df51a1d178fe38a89c0feb9ee6da3e5b98d204dde4d241fc8115464987d7a +F ext/fts5/fts5_expr.c 85789f6fb01995f2578b60a360057ed754335a890b1ab2e57e238b3670a9ae6c F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c dc6938b7233e9d88b3612fe2e88ce0a62130c43083be59beab8e6f01aa496689 +F ext/fts5/fts5_main.c c44064d5f6d77b04f95edd53d463eb2508dd7aa9c344f5f006b177e3228c3c01 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -178,7 +178,7 @@ F ext/fts5/test/fts5first.test 3fcf2365c00a15fc9704233674789a3b95131d12de18a9b99 F ext/fts5/test/fts5full.test e1701a112354e0ff9a1fdffb0c940c576530c33732ee20ac5e8361777070d717 F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e F ext/fts5/test/fts5hash.test dc7bc7e0cdeb42cfce31294ad2f8fcf43192bfd0145bb7f3ecc5465d8c72696f -F ext/fts5/test/fts5integrity.test f1723fe9fb9381b26c946ab4d7505041434df2c449d1cd53f45c7bf8c098dfa2 +F ext/fts5/test/fts5integrity.test e1af628af123669d018e84a649283ca41944429dfeb279ceaed9f3f480597153 F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fdde7ea00e78ea283d227 F ext/fts5/test/fts5lastrowid.test be98fe3e03235296585b72daad7aed5717ba0062bae5e5c18dd6e04e194c6b28 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b8442d2a6012b1f2e15381613267db0982e36bb4c748b15b56e668e0d0a3d0d2 -R 01f61db2371d56efe0fc89de21914b9a -U drh -Z 5bafe7bbe2cfe723081ab4c42a45e0a5 +P 5c97a5b9d163b1c427e002f3734687ca0384bc0da6a90fc4bfd358c654d3a7b3 +R 2fcf1976d410fe43c1d60c1a11289b2f +U dan +Z ee3c12cd3f911cb4276e3945584d93ed # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 745372d9b3..e576a74ec0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c97a5b9d163b1c427e002f3734687ca0384bc0da6a90fc4bfd358c654d3a7b3 \ No newline at end of file +061d7b69e6a43474cd7123a69f4ee65b5649a0b5e51474343defef5ae5262657 \ No newline at end of file From c598fdd10cceaaef16a7b5f3552a587cbc6ebdce Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 May 2024 21:38:37 +0000 Subject: [PATCH 0426/1030] Fix another fts5 problem related to unknown tokenizer modules. FossilOrigin-Name: e78b7783040ef1ad34d4287af8a7a5998d360d50076e0de42a116d9a96fe74b4 --- ext/fts5/fts5_main.c | 2 +- ext/fts5/test/fts5aux.test | 24 ++++++++++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 71f3a9f0f0..9287330aff 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2877,7 +2877,7 @@ int fts5GetTokenizer( if( pMod==0 ){ assert( nArg>0 ); rc = SQLITE_ERROR; - *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); + if( pzErr ) *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); }else{ rc = pMod->x.xCreate( pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->t.pTok diff --git a/ext/fts5/test/fts5aux.test b/ext/fts5/test/fts5aux.test index 5569f48cf3..2a623e78bd 100644 --- a/ext/fts5/test/fts5aux.test +++ b/ext/fts5/test/fts5aux.test @@ -377,4 +377,28 @@ do_catchsql_test 12.3.3 { SELECT fts5_collist(t1, 1) FROM t1('one AND two'); } {0 1} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 13.1 { + CREATE VIRTUAL TABLE t1 USING fts5(a, tokenize=ascii); + INSERT INTO t1 VALUES('a b c'), ('d e f'); + PRAGMA integrity_check; +} {ok} + +do_catchsql_test 13.2 { + SELECT highlight(t1, 0, '[', ']') FROM t1 +} {0 {{a b c} {d e f}}} + +do_execsql_test 13.3 { + PRAGMA writable_schema = 1; + UPDATE sqlite_schema SET sql = 'CREATE VIRTUAL TABLE t1 USING fts5(a, tokenize=blah)' + WHERE name = 't1'; +} + +db close +sqlite3 db test.db +do_catchsql_test 13.4 { + SELECT highlight(t1, 0, '[', ']') FROM t1 +} {1 {SQL logic error}} + finish_test diff --git a/manifest b/manifest index ed6476718f..cb11dc182d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scrash\sin\sfts5\sthat\scould\soccur\swithin\s"PRAGMA\sintegrity_check"\sif\sthe\sspecified\stokenizer\swas\sunknown. -D 2024-05-24T21:23:36.411 +C Fix\sanother\sfts5\sproblem\srelated\sto\sunknown\stokenizer\smodules. +D 2024-05-24T21:38:37.049 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 74093394dc26750becc302922e5fe308a8597a70e6e83e66c892242 F ext/fts5/fts5_expr.c 85789f6fb01995f2578b60a360057ed754335a890b1ab2e57e238b3670a9ae6c F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c c44064d5f6d77b04f95edd53d463eb2508dd7aa9c344f5f006b177e3228c3c01 +F ext/fts5/fts5_main.c 6b39f263b1651634c03ed0c6de67cc6b4556c847cb57e667ed9f6e2e5879f734 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -126,7 +126,7 @@ F ext/fts5/test/fts5ak.test f459a64c9d38698af72a7c657ab6349bca96150241dd69fcce75 F ext/fts5/test/fts5al.test 00c4c1c6a1366b73aa48ce2068c634520867c3cf7f5d1676ebbb775ee1f35734 F ext/fts5/test/fts5alter.test 5565f7e4605512b69171ac18ca84398603f9f6456dbe377beeca97e83cc242cd F ext/fts5/test/fts5auto.test 78989e6527ce69c9eddbef7392fea5c10b0010cd2b2ae68eec7bc869c471e691 -F ext/fts5/test/fts5aux.test ed3596469f85a6cff5f6060e0cd9e3f9602051d8db2b497f5d12c85d39f20a62 +F ext/fts5/test/fts5aux.test f3b4aa403cb672b0d79af1a87519e5896b309ab026de6425fa179589da55d7a5 F ext/fts5/test/fts5auxdata.test eacc97ff04892f1a5f3d4df5a73f8bcbc3955ea1d12c9f24137eb1fc079e7611 F ext/fts5/test/fts5bigid.test 2860854c2561a57594192b00c33a29f91cb85e25f3d6c03b5c2b8f62708f39dd F ext/fts5/test/fts5bigpl.test 6466c89b38439f0aba26ac09e232a6b963f29b1cbe1304f6a664fe1e7a8f5fd3 @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5c97a5b9d163b1c427e002f3734687ca0384bc0da6a90fc4bfd358c654d3a7b3 -R 2fcf1976d410fe43c1d60c1a11289b2f +P 061d7b69e6a43474cd7123a69f4ee65b5649a0b5e51474343defef5ae5262657 +R 3aafd6df183b6b2f11ed23abd162a1b9 U dan -Z ee3c12cd3f911cb4276e3945584d93ed +Z 44d9629757a5b761f90f7e7a3350237c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e576a74ec0..a645f84142 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -061d7b69e6a43474cd7123a69f4ee65b5649a0b5e51474343defef5ae5262657 \ No newline at end of file +e78b7783040ef1ad34d4287af8a7a5998d360d50076e0de42a116d9a96fe74b4 \ No newline at end of file From 4ed784d1e82c13221950f1de8bf39d633e215918 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 25 May 2024 23:13:15 +0000 Subject: [PATCH 0427/1030] Ensure that sqlite3ViewGetColumnNames() returns non-zero on any error. dbsqlfuzz d9de2a508f693e5a228d7a01d5341e3c64326fbb. FossilOrigin-Name: 57aeb3a287fc190bf8d438a7b03d6715c05fd3fd71559c6a14d7bd910d37b38d --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/build.c | 7 ++++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 2da77e2fcf..90916b82d6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\squeries\slike\s"SELECT\sfunc(a)\sFROM\stab\sGROUP\sBY\s1"\sonly\scall\sthe\nfunc()\sfunction\sonce\sper\srow.\s\sFix\sfor\sthe\sissue\sdescribed\sin\n[forum:/forumpost/bf8f43aa522c2299|forum\sthread\sbf8f43aa522c2299]. -D 2024-05-24T23:44:48.546 +C Ensure\sthat\ssqlite3ViewGetColumnNames()\sreturns\snon-zero\son\sany\serror.\ndbsqlfuzz\sd9de2a508f693e5a228d7a01d5341e3c64326fbb. +D 2024-05-25T23:13:15.836 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -697,7 +697,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 71b80e77b255144db47180fda8138740608e382a44231942464029b1a45fc036 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 11ec7014a3c468e7b3ccc8dda8d9111cd5a29a358df18818788601e0600aaabd +F src/build.c 237ccc0290d131d646be722f418e92ee0a38043aee25e7dfdc75f8ce5b3abe4e F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 @@ -2193,9 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e78b7783040ef1ad34d4287af8a7a5998d360d50076e0de42a116d9a96fe74b4 f890812df0a57fcd201647640d8b9ee26047cd93cd7171bc6fd050f574649345 -R 7c1f360041d0b2281ef0245348adc37d -T +closed f890812df0a57fcd201647640d8b9ee26047cd93cd7171bc6fd050f574649345 +P 663f5dd32d9db83249fcf85602a756464ece74e1899dc881ac9519d872638441 +R 67dd292b009e7afb9767bed1b386f5c7 U drh -Z 6771d4e20dc444e2cd5eac1a731f4290 +Z 741f9768ce72f3e0695011ad58c7b55d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f70301fa83..17add0eb74 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -663f5dd32d9db83249fcf85602a756464ece74e1899dc881ac9519d872638441 \ No newline at end of file +57aeb3a287fc190bf8d438a7b03d6715c05fd3fd71559c6a14d7bd910d37b38d \ No newline at end of file diff --git a/src/build.c b/src/build.c index 10aa342407..9747810e82 100644 --- a/src/build.c +++ b/src/build.c @@ -3064,8 +3064,9 @@ void sqlite3CreateView( #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) /* ** The Table structure pTable is really a VIEW. Fill in the names of -** the columns of the view in the pTable structure. Return the number -** of errors. If an error is seen leave an error message in pParse->zErrMsg. +** the columns of the view in the pTable structure. Return non-zero if +** there are errors. If an error is seen an error message is left +** in pParse->zErrMsg. */ static SQLITE_NOINLINE int viewGetColumnNames(Parse *pParse, Table *pTable){ Table *pSelTab; /* A fake table from which we get the result set */ @@ -3188,7 +3189,7 @@ static SQLITE_NOINLINE int viewGetColumnNames(Parse *pParse, Table *pTable){ sqlite3DeleteColumnNames(db, pTable); } #endif /* SQLITE_OMIT_VIEW */ - return nErr; + return nErr + pParse->nErr; } int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ assert( pTable!=0 ); From ee8f926027d5af33e2d276de52e5a0691ea0e927 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 May 2024 11:31:02 +0000 Subject: [PATCH 0428/1030] Add new assert() statements to help out a static analyzer. Response to [forum:/forumpost/17fe8ac32e0de4f5|forum post 17fe8ac32e0de4f5]. FossilOrigin-Name: 857f6d530949221d154b5120ecc2aa906418bec6f69d1c13197a432ba3cad8eb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 90916b82d6..056cbd8b8d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\ssqlite3ViewGetColumnNames()\sreturns\snon-zero\son\sany\serror.\ndbsqlfuzz\sd9de2a508f693e5a228d7a01d5341e3c64326fbb. -D 2024-05-25T23:13:15.836 +C Add\snew\sassert()\sstatements\sto\shelp\sout\sa\sstatic\sanalyzer.\s\sResponse\sto\n[forum:/forumpost/17fe8ac32e0de4f5|forum\spost\s17fe8ac32e0de4f5]. +D 2024-05-27T11:31:02.983 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -694,7 +694,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 71b80e77b255144db47180fda8138740608e382a44231942464029b1a45fc036 +F src/btree.c c786c0e9ee3d848e01e96fa3a84b0e44dbc80477b0accf406de810d87a7d0426 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 237ccc0290d131d646be722f418e92ee0a38043aee25e7dfdc75f8ce5b3abe4e @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 663f5dd32d9db83249fcf85602a756464ece74e1899dc881ac9519d872638441 -R 67dd292b009e7afb9767bed1b386f5c7 +P 57aeb3a287fc190bf8d438a7b03d6715c05fd3fd71559c6a14d7bd910d37b38d +R 7cbf595b1ca4596681b998a2f0ff06f6 U drh -Z 741f9768ce72f3e0695011ad58c7b55d +Z 965bcfdda628566a6226377c41ce768a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 17add0eb74..2cd71fe929 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -57aeb3a287fc190bf8d438a7b03d6715c05fd3fd71559c6a14d7bd910d37b38d \ No newline at end of file +857f6d530949221d154b5120ecc2aa906418bec6f69d1c13197a432ba3cad8eb \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 62b8989796..aa41ec3ba2 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7568,6 +7568,7 @@ static int rebuildPage( memcpy(&pTmp[j], &aData[j], usableSize - j); for(k=0; ALWAYS(kixNx[k]<=i; k++){} + assert( kapEnd[k]; pData = pEnd; @@ -7651,6 +7652,7 @@ static int pageInsertArray( assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */ if( iEnd<=iFirst ) return 0; for(k=0; ALWAYS(kixNx[k]<=i ; k++){} + assert( kapEnd[k]; while( 1 /*Exit by break*/ ){ int sz, rc; @@ -8762,6 +8764,7 @@ static int balance_nonroot( assert( sz<=pBt->maxLocal+23 ); assert( iOvflSpace <= (int)pBt->pageSize ); for(k=0; ALWAYS(k Date: Mon, 27 May 2024 11:35:05 +0000 Subject: [PATCH 0429/1030] Fix a possible buffer overwrite in the ".import" command. [forum:/forumpost/0c447f0548|forum post 0c447f0548]. FossilOrigin-Name: 0fd958fa9b56a8ef254127e29800ca2a267590e86edf739bd339239b25a5da6e --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/shell.c.in | 13 +++++++++---- test/shell5.test | 12 ++++++++++++ 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 056cbd8b8d..309839cbc3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sassert()\sstatements\sto\shelp\sout\sa\sstatic\sanalyzer.\s\sResponse\sto\n[forum:/forumpost/17fe8ac32e0de4f5|forum\spost\s17fe8ac32e0de4f5]. -D 2024-05-27T11:31:02.983 +C Fix\sa\spossible\sbuffer\soverwrite\sin\sthe\s".import"\scommand.\s[forum:/forumpost/0c447f0548|forum\spost\s0c447f0548]. +D 2024-05-27T11:35:05.208 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -756,7 +756,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c cbdaf9cb2d9a697ee9ce1484f27d2e96762d33cc19259aedfb818a68b9d3be10 -F src/shell.c.in 31249f26684467e95e529915bf486961c535ae8288ed7e79890cc9ed3d781d8f +F src/shell.c.in cba809572972ff736aa6c3423ffb87015c740864206d97e168bb77316129015f F src/sqlite.h.in c71d9ef76a6d32dc7ff2d373f2e57ce09056af26c1457bcadae5358b7628c7c3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -1615,7 +1615,7 @@ F test/shell1.test 17a5ca9c6f24f807b2f505b4b38fcbce143d96cd8664c06c34bbbe0672bf7 F test/shell2.test 56da24128304c9ab67da2964cc80beff7b35761c446ec6e6e98bff2775b15026 F test/shell3.test 5ad4b2813717956414f2c0c8a2027895cd98ccf7dd54dbacbde4d4f5591ce5a1 F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f807 -F test/shell5.test 5b2ab1c0540217773f939927c24163a56257446da3f564d4724042620bfea762 +F test/shell5.test 6a49440bddc33a132f856fb189e71228f8132963655d12a2c8b8a161263b9632 F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bdbb8 F test/shell7.test 753c6ece5361df50025a50cadf378ea36db9cc05fb23d7a96cff7fa130626ef9 F test/shell8.test aea51ecbcd4494c746b096aeff51d841d04d5f0dc4b62eb42427f16109b87acd @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 57aeb3a287fc190bf8d438a7b03d6715c05fd3fd71559c6a14d7bd910d37b38d -R 7cbf595b1ca4596681b998a2f0ff06f6 -U drh -Z 965bcfdda628566a6226377c41ce768a +P 857f6d530949221d154b5120ecc2aa906418bec6f69d1c13197a432ba3cad8eb +R 208aed0e15e5a9e1542642ed290f707d +U dan +Z dedd3aceb57544d244ea5c9933280761 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2cd71fe929..a2019d0631 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -857f6d530949221d154b5120ecc2aa906418bec6f69d1c13197a432ba3cad8eb \ No newline at end of file +0fd958fa9b56a8ef254127e29800ca2a267590e86edf739bd339239b25a5da6e \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 2da78c3f25..b895fb0501 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8978,7 +8978,6 @@ static int do_meta_command(char *zLine, ShellState *p){ import_cleanup(&sCtx); shell_out_of_memory(); } - nByte = strlen(zSql); rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); zSql = 0; @@ -8997,16 +8996,21 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_finalize(pStmt); pStmt = 0; if( nCol==0 ) return 0; /* no columns, no error */ - zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 ); + + nByte = 64 /* space for "INSERT INTO", "VALUES(", ")\0" */ + + (zSchema ? strlen(zSchema)*2 + 2: 0) /* Quoted schema name */ + + strlen(zTable)*2 + 2 /* Quoted table name */ + + nCol*2; /* Space for ",?" for each column */ + zSql = sqlite3_malloc64( nByte ); if( zSql==0 ){ import_cleanup(&sCtx); shell_out_of_memory(); } if( zSchema ){ - sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\".\"%w\" VALUES(?", + sqlite3_snprintf(nByte, zSql, "INSERT INTO \"%w\".\"%w\" VALUES(?", zSchema, zTable); }else{ - sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable); + sqlite3_snprintf(nByte, zSql, "INSERT INTO \"%w\" VALUES(?", zTable); } j = strlen30(zSql); for(i=1; i=2 ){ oputf("Insert using: %s\n", zSql); } diff --git a/test/shell5.test b/test/shell5.test index 877676d726..8727edaafb 100644 --- a/test/shell5.test +++ b/test/shell5.test @@ -585,4 +585,16 @@ do_test shell5-7.1 { SELECT * FROM t1;} } {0 aaa|bbb|aaabbb} +#------------------------------------------------------------------------- + +do_test shell5-8.1 { + + set out [open shell5.csv w] + fconfigure $out -translation lf + puts $out x + close $out + + catchcmd :memory: {.import --csv shell5.csv '""""""""""""""""""""""""""""""""""""""""""""""'} +} {0 {}} + finish_test From fefe24ddf883a1adce600e0812703cfcc9b20b20 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 May 2024 13:24:39 +0000 Subject: [PATCH 0430/1030] For compatibility with PostgreSQL, when right-hand side of the ->> operator is negative, it should index from the right side of the JSON array on the left-hand side. FossilOrigin-Name: 82365a45b96536c1146a384e5d3efce80a6ec469a54713c7f40bf15eb834b5fd --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/json.c | 6 ++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 309839cbc3..d93e0f7c76 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spossible\sbuffer\soverwrite\sin\sthe\s".import"\scommand.\s[forum:/forumpost/0c447f0548|forum\spost\s0c447f0548]. -D 2024-05-27T11:35:05.208 +C For\scompatibility\swith\sPostgreSQL,\swhen\sright-hand\sside\sof\sthe\s->>\soperator\nis\snegative,\sit\sshould\sindex\sfrom\sthe\sright\sside\sof\sthe\sJSON\sarray\son\sthe\nleft-hand\sside. +D 2024-05-27T13:24:39.941 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -715,7 +715,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 4bd7c7e54a1062dcd0214b7a6296f7194eb10fb14d3ddca1ed20b01c2a86a18c -F src/json.c bf1b51e32158b3d01d96a878d3dba8d2e633a7e5bf2534d4617f89de8a6b9a91 +F src/json.c 06cd3a8df28a1bf29e3ee731fc04318aad58bf3fe48f82c8cf98038a98c3bd73 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 8a59d297ec77e6b78550433bfccb95a1b26f2fb69aaaf233206e21579a1cfcc1 @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 857f6d530949221d154b5120ecc2aa906418bec6f69d1c13197a432ba3cad8eb -R 208aed0e15e5a9e1542642ed290f707d -U dan -Z dedd3aceb57544d244ea5c9933280761 +P 0fd958fa9b56a8ef254127e29800ca2a267590e86edf739bd339239b25a5da6e +R 36f341dbd61e9f589a60e0c721370ef1 +U drh +Z 1b11798b82660ce66802b4d7d9bc3cf5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a2019d0631..d191958e3d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0fd958fa9b56a8ef254127e29800ca2a267590e86edf739bd339239b25a5da6e \ No newline at end of file +82365a45b96536c1146a384e5d3efce80a6ec469a54713c7f40bf15eb834b5fd \ No newline at end of file diff --git a/src/json.c b/src/json.c index 4db468c92d..b30189307b 100644 --- a/src/json.c +++ b/src/json.c @@ -3857,10 +3857,16 @@ static void jsonExtractFunc( ** NUMBER ==> $[NUMBER] // PG compatible ** LABEL ==> $.LABEL // PG compatible ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience + ** + ** Updated 2024-05-27: If the NUMBER is negative, then PG counts from + ** the write of the array. Hence for negative NUMBER: + ** + ** NUMBER ==> $[#NUMBER] // PG compatible */ jsonStringInit(&jx, ctx); if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){ jsonAppendRawNZ(&jx, "[", 1); + if( zPath[0]=='-' ) jsonAppendRawNZ(&jx,"#",1); jsonAppendRaw(&jx, zPath, nPath); jsonAppendRawNZ(&jx, "]", 2); }else if( jsonAllAlphanum(zPath, nPath) ){ From 20c118faec2e41089dc72ac974e21c096c2654bb Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 27 May 2024 13:41:46 +0000 Subject: [PATCH 0431/1030] Doc typo fix. No code changes. FossilOrigin-Name: eaf07fe69f383938dd394f58cedad3f16f146d9b48e66bc1ba17446cf75ffb3f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/json.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d93e0f7c76..098e85249a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\scompatibility\swith\sPostgreSQL,\swhen\sright-hand\sside\sof\sthe\s->>\soperator\nis\snegative,\sit\sshould\sindex\sfrom\sthe\sright\sside\sof\sthe\sJSON\sarray\son\sthe\nleft-hand\sside. -D 2024-05-27T13:24:39.941 +C Doc\stypo\sfix.\sNo\scode\schanges. +D 2024-05-27T13:41:46.728 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -715,7 +715,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 4bd7c7e54a1062dcd0214b7a6296f7194eb10fb14d3ddca1ed20b01c2a86a18c -F src/json.c 06cd3a8df28a1bf29e3ee731fc04318aad58bf3fe48f82c8cf98038a98c3bd73 +F src/json.c 5b6a1d6015997b9ee848a32948720bdb26a0ef2de5a2127ebf7355ce66dbdc0d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 F src/main.c 8a59d297ec77e6b78550433bfccb95a1b26f2fb69aaaf233206e21579a1cfcc1 @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0fd958fa9b56a8ef254127e29800ca2a267590e86edf739bd339239b25a5da6e -R 36f341dbd61e9f589a60e0c721370ef1 -U drh -Z 1b11798b82660ce66802b4d7d9bc3cf5 +P 82365a45b96536c1146a384e5d3efce80a6ec469a54713c7f40bf15eb834b5fd +R 69243fb48d2d86f0aae5c62167ad4060 +U stephan +Z 7c55017839b224ee3043f5b1beb0d3bd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d191958e3d..d845d92d41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -82365a45b96536c1146a384e5d3efce80a6ec469a54713c7f40bf15eb834b5fd \ No newline at end of file +eaf07fe69f383938dd394f58cedad3f16f146d9b48e66bc1ba17446cf75ffb3f \ No newline at end of file diff --git a/src/json.c b/src/json.c index b30189307b..7361c46d89 100644 --- a/src/json.c +++ b/src/json.c @@ -3859,7 +3859,7 @@ static void jsonExtractFunc( ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience ** ** Updated 2024-05-27: If the NUMBER is negative, then PG counts from - ** the write of the array. Hence for negative NUMBER: + ** the right of the array. Hence for negative NUMBER: ** ** NUMBER ==> $[#NUMBER] // PG compatible */ From 09d8e696dcb553c3733f012b964d195cfaa1953c Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 May 2024 15:13:49 +0000 Subject: [PATCH 0432/1030] Very small performance increase and size reduction by removing unnecessary ALWAYS() macros from the btree balance logic and replacing them with special initialization of CellArray and some assert()s. FossilOrigin-Name: 32b79041d9b6858e4ffade5841898619c7d25d20c4638bf85447a2ca9cc4a3d3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 16 +++++++++------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 098e85249a..b54a84d33d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Doc\stypo\sfix.\sNo\scode\schanges. -D 2024-05-27T13:41:46.728 +C Very\ssmall\sperformance\sincrease\sand\ssize\sreduction\sby\sremoving\sunnecessary\nALWAYS()\smacros\sfrom\sthe\sbtree\sbalance\slogic\sand\sreplacing\sthem\swith\nspecial\sinitialization\sof\sCellArray\sand\ssome\sassert()s. +D 2024-05-27T15:13:49.723 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -694,7 +694,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c c786c0e9ee3d848e01e96fa3a84b0e44dbc80477b0accf406de810d87a7d0426 +F src/btree.c 1a77e763f03a775b5e7c17f4e2f043c46538b107c12e425ecc68cf78a71d9a51 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 237ccc0290d131d646be722f418e92ee0a38043aee25e7dfdc75f8ce5b3abe4e @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 82365a45b96536c1146a384e5d3efce80a6ec469a54713c7f40bf15eb834b5fd -R 69243fb48d2d86f0aae5c62167ad4060 -U stephan -Z 7c55017839b224ee3043f5b1beb0d3bd +P eaf07fe69f383938dd394f58cedad3f16f146d9b48e66bc1ba17446cf75ffb3f +R dc12087fabeb41552a351cfb5dec1bee +U drh +Z 1b0c3733cd5c8aecb350c7623a6fceee # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d845d92d41..8f8f2422fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eaf07fe69f383938dd394f58cedad3f16f146d9b48e66bc1ba17446cf75ffb3f \ No newline at end of file +32b79041d9b6858e4ffade5841898619c7d25d20c4638bf85447a2ca9cc4a3d3 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index aa41ec3ba2..1c47ace501 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7567,8 +7567,8 @@ static int rebuildPage( if( j>(u32)usableSize ){ j = 0; } memcpy(&pTmp[j], &aData[j], usableSize - j); - for(k=0; ALWAYS(kixNx[k]<=i; k++){} - assert( kixNx[NB*2-1]>i ); + for(k=0; pCArray->ixNx[k]<=i; k++){} pSrcEnd = pCArray->apEnd[k]; pData = pEnd; @@ -7651,8 +7651,8 @@ static int pageInsertArray( u8 *pEnd; /* Maximum extent of cell data */ assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */ if( iEnd<=iFirst ) return 0; - for(k=0; ALWAYS(kixNx[k]<=i ; k++){} - assert( kixNx[NB*2-1]>i ); + for(k=0; pCArray->ixNx[k]<=i ; k++){} pEnd = pCArray->apEnd[k]; while( 1 /*Exit by break*/ ){ int sz, rc; @@ -8172,7 +8172,9 @@ static int balance_nonroot( CellArray b; /* Parsed information on cells being balanced */ memset(abDone, 0, sizeof(abDone)); - memset(&b, 0, sizeof(b)); + assert( sizeof(b) - sizeof(b.ixNx) == offsetof(CellArray,ixNx) ); + memset(&b, 0, sizeof(b)-sizeof(b.ixNx)); + b.ixNx[NB*2-1] = 0x7fffffff; pBt = pParent->pBt; assert( sqlite3_mutex_held(pBt->mutex) ); assert( sqlite3PagerIswriteable(pParent->pDbPage) ); @@ -8763,8 +8765,8 @@ static int balance_nonroot( iOvflSpace += sz; assert( sz<=pBt->maxLocal+23 ); assert( iOvflSpace <= (int)pBt->pageSize ); - for(k=0; ALWAYS(kj ); + for(k=0; b.ixNx[k]<=j; k++){} pSrcEnd = b.apEnd[k]; if( SQLITE_OVERFLOW(pSrcEnd, pCell, pCell+sz) ){ rc = SQLITE_CORRUPT_BKPT; From d081df0a5d7e8c14465cb2af596ff9873011947e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 May 2024 18:15:08 +0000 Subject: [PATCH 0433/1030] Fix typo in comment used to generate parts of the documentation. [forum:/forumpost/da5a2ca4db|Forum post da5a2ca4db]. FossilOrigin-Name: 428aadf0c71473ccb0681b2b7146281c62949ee99556873e49895d44eec7aee5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b54a84d33d..00e2bf5c2e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Very\ssmall\sperformance\sincrease\sand\ssize\sreduction\sby\sremoving\sunnecessary\nALWAYS()\smacros\sfrom\sthe\sbtree\sbalance\slogic\sand\sreplacing\sthem\swith\nspecial\sinitialization\sof\sCellArray\sand\ssome\sassert()s. -D 2024-05-27T15:13:49.723 +C Fix\stypo\sin\scomment\sused\sto\sgenerate\sparts\sof\sthe\sdocumentation.\n[forum:/forumpost/da5a2ca4db|Forum\spost\sda5a2ca4db]. +D 2024-05-27T18:15:08.730 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -757,7 +757,7 @@ F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c cbdaf9cb2d9a697ee9ce1484f27d2e96762d33cc19259aedfb818a68b9d3be10 F src/shell.c.in cba809572972ff736aa6c3423ffb87015c740864206d97e168bb77316129015f -F src/sqlite.h.in c71d9ef76a6d32dc7ff2d373f2e57ce09056af26c1457bcadae5358b7628c7c3 +F src/sqlite.h.in 954a55f03801617876d30329a4496f365d73f4d91fde7dabc61869f51e2967e8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 98ba756789b37f8d8217407ce077c31faf0b9b21d593b327c2b9667ad5bea1ac @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eaf07fe69f383938dd394f58cedad3f16f146d9b48e66bc1ba17446cf75ffb3f -R dc12087fabeb41552a351cfb5dec1bee +P 32b79041d9b6858e4ffade5841898619c7d25d20c4638bf85447a2ca9cc4a3d3 +R 6d7e8d363f9510bd5e196509859708e6 U drh -Z 1b0c3733cd5c8aecb350c7623a6fceee +Z 62c8271bd132db7f532d96e8c36d38b0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8f8f2422fa..b1dac23277 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32b79041d9b6858e4ffade5841898619c7d25d20c4638bf85447a2ca9cc4a3d3 \ No newline at end of file +428aadf0c71473ccb0681b2b7146281c62949ee99556873e49895d44eec7aee5 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 549b52a153..a9731faf9e 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3570,7 +3570,7 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** ** [[OPEN_EXRESCODE]] ^(

    [SQLITE_OPEN_EXRESCODE]
    **
    The database connection comes up in "extended result code mode". -** In other words, the database behaves has if +** In other words, the database behaves as if ** [sqlite3_extended_result_codes(db,1)] where called on the database ** connection as soon as the connection is created. In addition to setting ** the extended result code mode, this flag also causes [sqlite3_open_v2()] From eeb8506c18173fb26c0b2d93f89a2a66b90711cc Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 May 2024 19:52:24 +0000 Subject: [PATCH 0434/1030] The previous check-in was a little two aggressive about skipping the initialization of entries in the CellArray.ixNx array. Fixed here. FossilOrigin-Name: 1b6d1fbcdecf14bc79dc7b5df50e585d2fcc1484a9987b863c190e8f7ba2c39f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 00e2bf5c2e..4e2cea56dd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\scomment\sused\sto\sgenerate\sparts\sof\sthe\sdocumentation.\n[forum:/forumpost/da5a2ca4db|Forum\spost\sda5a2ca4db]. -D 2024-05-27T18:15:08.730 +C The\sprevious\scheck-in\swas\sa\slittle\stwo\saggressive\sabout\sskipping\sthe\ninitialization\sof\sentries\sin\sthe\sCellArray.ixNx\sarray.\s\sFixed\shere. +D 2024-05-27T19:52:24.258 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -694,7 +694,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 1a77e763f03a775b5e7c17f4e2f043c46538b107c12e425ecc68cf78a71d9a51 +F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 237ccc0290d131d646be722f418e92ee0a38043aee25e7dfdc75f8ce5b3abe4e @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 32b79041d9b6858e4ffade5841898619c7d25d20c4638bf85447a2ca9cc4a3d3 -R 6d7e8d363f9510bd5e196509859708e6 +P 428aadf0c71473ccb0681b2b7146281c62949ee99556873e49895d44eec7aee5 +R 4ca5c510c21258f08a4799ee1f04b980 U drh -Z 62c8271bd132db7f532d96e8c36d38b0 +Z e77b6b7828b797641ee06ff1dc47219a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b1dac23277..1de423f654 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -428aadf0c71473ccb0681b2b7146281c62949ee99556873e49895d44eec7aee5 \ No newline at end of file +1b6d1fbcdecf14bc79dc7b5df50e585d2fcc1484a9987b863c190e8f7ba2c39f \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 1c47ace501..c752b0771b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7937,6 +7937,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){ b.szCell = &szCell; b.apEnd[0] = pPage->aDataEnd; b.ixNx[0] = 2; + b.ixNx[NB*2-1] = 0x7fffffff; rc = rebuildPage(&b, 0, 1, pNew); if( NEVER(rc) ){ releasePage(pNew); @@ -8173,7 +8174,7 @@ static int balance_nonroot( memset(abDone, 0, sizeof(abDone)); assert( sizeof(b) - sizeof(b.ixNx) == offsetof(CellArray,ixNx) ); - memset(&b, 0, sizeof(b)-sizeof(b.ixNx)); + memset(&b, 0, sizeof(b)-sizeof(b.ixNx[0])); b.ixNx[NB*2-1] = 0x7fffffff; pBt = pParent->pBt; assert( sqlite3_mutex_held(pBt->mutex) ); From b23f92b2867e89ddecc4f4ccb6dc406e4d5ab726 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 May 2024 21:55:01 +0000 Subject: [PATCH 0435/1030] Avoid creating an automatic index on a column that is known to be not very selective. FossilOrigin-Name: 70409763f70faa2a0f4f072fd318a687b109a0905cc57906ad7f80d2885fe6d9 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/where.c | 43 ++++++++++++++++++++++++++++++++++++++++--- test/autoindex3.test | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 4e2cea56dd..d844021f66 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sprevious\scheck-in\swas\sa\slittle\stwo\saggressive\sabout\sskipping\sthe\ninitialization\sof\sentries\sin\sthe\sCellArray.ixNx\sarray.\s\sFixed\shere. -D 2024-05-27T19:52:24.258 +C Avoid\screating\san\sautomatic\sindex\son\sa\scolumn\sthat\sis\sknown\sto\sbe\snot\svery\nselective. +D 2024-05-27T21:55:01.258 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 9b2ab23fcc2198ebcee1e6e840a9ff22350668bd3a99195a5dc7299d5908370a +F src/where.c 555c75e91b44b8f575579eea4f2cf86c419ab4e79e44ce546e399a60cd3020e2 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -910,7 +910,7 @@ F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e188 F test/autoinc.test 997d6f185f138229dc4251583a1d04816423dddc2fc034871a01aeb1d728cb39 F test/autoindex1.test d34caffb0384003ee28eae87679214c029e9be4b332d9649a79e0b94ab70502c F test/autoindex2.test 12ef578928102baaa0dc23ad397601a2f4ecb0df -F test/autoindex3.test dcd6b2f8bed2be67b131e2e671f892e971d934e24fd00988952d0e0a67e24aa7 +F test/autoindex3.test ca502c8050166ac6107a7b4fe4e951f4d3270a23a958af02b14f1b962b83c4b6 F test/autoindex4.test 3c2105e9172920e26f950ba3c5823e4972190e022c1e6f260ba476b0af24c593 F test/autoindex5.test 2ee94f033b87ca0160e08d81034c507aff8e230df2627f0304fa309b2fee19a3 F test/autovacuum.test 00671369bbf96c6a49989a9425f5b78b94075d6a4b031e5e00000c2c32f365df @@ -2193,8 +2193,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 428aadf0c71473ccb0681b2b7146281c62949ee99556873e49895d44eec7aee5 -R 4ca5c510c21258f08a4799ee1f04b980 +P 1b6d1fbcdecf14bc79dc7b5df50e585d2fcc1484a9987b863c190e8f7ba2c39f +R 33d42e8c7f39f01a63aa7a9a3cae7431 +T *branch * auto-index-improvements +T *sym-auto-index-improvements * +T -sym-trunk * U drh -Z e77b6b7828b797641ee06ff1dc47219a +Z ae3dc9b91b8cb58bdaacbf4b44d36f22 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1de423f654..0233074f46 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b6d1fbcdecf14bc79dc7b5df50e585d2fcc1484a9987b863c190e8f7ba2c39f \ No newline at end of file +70409763f70faa2a0f4f072fd318a687b109a0905cc57906ad7f80d2885fe6d9 \ No newline at end of file diff --git a/src/where.c b/src/where.c index a266b51d03..accad86251 100644 --- a/src/where.c +++ b/src/where.c @@ -840,6 +840,40 @@ static int constraintCompatibleWithOuterJoin( return 1; } +#ifndef SQLITE_OMIT_AUTOMATIC_INDEX +/* +** Return true if column iCol of table pTab seem like it might be a +** good column to use as part of a query-time index. +** +** Current algorithm (subject to improvement!): +** +** 1. If iCol is already the left-most column of some other index, +** then return false. +** +** 2. If iCol is part of an existing index that has an aiRowLogEst of +** more than 20, then return false. +** +** 3. If no disqualifying conditions above are found, return true. +*/ +static SQLITE_NOINLINE int columnIsGoodIndexCandidate( + const Table *pTab, + int iCol +){ + const Index *pIdx; + for(pIdx = pTab->pIndex; pIdx!=0; pIdx=pIdx->pNext){ + int j; + for(j=0; jnKeyCol; j++){ + if( pIdx->aiColumn[j]==iCol ){ + if( j==0 ) return 0; + if( pIdx->hasStat1 && pIdx->aiRowLogEst[j+1]>20 ) return 0; + break; + } + } + } + return 1; +} +#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */ + #ifndef SQLITE_OMIT_AUTOMATIC_INDEX @@ -854,6 +888,8 @@ static int termCanDriveIndex( const Bitmask notReady /* Tables in outer loops of the join */ ){ char aff; + int leftCol; + if( pTerm->leftCursor!=pSrc->iCursor ) return 0; if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0; assert( (pSrc->fg.jointype & JT_RIGHT)==0 ); @@ -864,11 +900,12 @@ static int termCanDriveIndex( } if( (pTerm->prereqRight & notReady)!=0 ) return 0; assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); - if( pTerm->u.x.leftColumn<0 ) return 0; - aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity; + leftCol = pTerm->u.x.leftColumn; + if( leftCol<0 ) return 0; + aff = pSrc->pTab->aCol[leftCol].affinity; if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; testcase( pTerm->pExpr->op==TK_IS ); - return 1; + return columnIsGoodIndexCandidate(pSrc->pTab, leftCol); } #endif diff --git a/test/autoindex3.test b/test/autoindex3.test index 3da7a70586..aa6aa00128 100644 --- a/test/autoindex3.test +++ b/test/autoindex3.test @@ -90,5 +90,40 @@ do_eqp_test 220 { `--SEARCH u USING AUTOMATIC COVERING INDEX (b=?) } +# 2024-05-27 +# ticket https://sqlite.org/src/tktview/8ff324e120 +# forum post https://sqlite.org/forum/forumpost/b21c2101a559be0a +# +# If an index with STAT1 data indicates that a column is not very +# selective, then do not attempt to create an automatic index on +# that column. +# +reset_db +do_execsql_test 300 { + CREATE TABLE t1(id INTEGER PRIMARY KEY); + CREATE TABLE t2(cid INT, pid INT, rx INT, PRIMARY KEY(cid, pid, rx)); + CREATE INDEX x1 ON t2(pid, rx); + ANALYZE sqlite_schema; + REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES + ('t2', 'x1', '500000 250 250'), + ('t2','sqlite_autoindex_t2_1','500000 1 1 1'); + ANALYZE sqlite_schema; +} +do_eqp_test 310 { + WITH RECURSIVE children(id) AS ( + SELECT cid FROM t2 WHERE pid = ?1 AND rx = ?2 + UNION + SELECT cid FROM t2 JOIN children ON t2.pid = children.id AND rx = ?2 + ) SELECT count(id) FROM children; +} { + QUERY PLAN + |--CO-ROUTINE children + | |--SETUP + | | `--SEARCH t2 USING INDEX x1 (pid=? AND rx=?) + | `--RECURSIVE STEP + | |--SCAN children + | `--SEARCH t2 USING INDEX x1 (pid=? AND rx=?) + `--SCAN children +} finish_test From 38af12523865b98cdc64fa518fc85ea754697e09 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 May 2024 00:01:07 +0000 Subject: [PATCH 0436/1030] Query planner tuning: Increase the maximum number of simultaneous solutions to track int eh solver from 10 to 12. FossilOrigin-Name: fe2e1dadbacbe6392ceed44fd287a2ed82189cb8055f35631d37967d9a7a5d1d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 14 ++++++++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 4e2cea56dd..bd1edcd570 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sprevious\scheck-in\swas\sa\slittle\stwo\saggressive\sabout\sskipping\sthe\ninitialization\sof\sentries\sin\sthe\sCellArray.ixNx\sarray.\s\sFixed\shere. -D 2024-05-27T19:52:24.258 +C Query\splanner\stuning:\s\sIncrease\sthe\smaximum\snumber\sof\ssimultaneous\ssolutions\nto\strack\sint\seh\ssolver\sfrom\s10\sto\s12. +D 2024-05-28T00:01:07.835 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 9b2ab23fcc2198ebcee1e6e840a9ff22350668bd3a99195a5dc7299d5908370a +F src/where.c dd7d9eb570c35caf94797814f9d54b187175bd21966f7f4dfd36b0c1f63aa501 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 428aadf0c71473ccb0681b2b7146281c62949ee99556873e49895d44eec7aee5 -R 4ca5c510c21258f08a4799ee1f04b980 +P 1b6d1fbcdecf14bc79dc7b5df50e585d2fcc1484a9987b863c190e8f7ba2c39f +R 81c36ec13694e48008fb110fd73a5f00 U drh -Z e77b6b7828b797641ee06ff1dc47219a +Z 108dc3aeba08b8d2b68875bf68eaf849 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1de423f654..49840006bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b6d1fbcdecf14bc79dc7b5df50e585d2fcc1484a9987b863c190e8f7ba2c39f \ No newline at end of file +fe2e1dadbacbe6392ceed44fd287a2ed82189cb8055f35631d37967d9a7a5d1d \ No newline at end of file diff --git a/src/where.c b/src/where.c index a266b51d03..9ef48fb333 100644 --- a/src/where.c +++ b/src/where.c @@ -5242,10 +5242,16 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pParse = pWInfo->pParse; nLoop = pWInfo->nLevel; - /* TUNING: For simple queries, only the best path is tracked. - ** For 2-way joins, the 5 best paths are followed. - ** For joins of 3 or more tables, track the 10 best paths */ - mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10); + /* TUNING: mxChoice is the maximum number of possible paths to preserve + ** at each step. Based on the number of loops in the FROM clause: + ** + ** nLoop mxChoice + ** ----- -------- + ** 1 1 // the most common case + ** 2 5 + ** 3+ 12 + */ + mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 12); assert( nLoop<=pWInfo->pTabList->nSrc ); WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n", nRowEst, pParse->nQueryLoop)); From 2386943f19d154795bd2b9ef402dbb110829e654 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 28 May 2024 10:57:24 +0000 Subject: [PATCH 0437/1030] Fix a problem with the error message reported by fts5 in some OOM cases. FossilOrigin-Name: c7aaa28f786567e29ebee3848283b5c740dd3b8144dc14372e56260ae1b76922 --- ext/fts5/fts5_main.c | 4 +++- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 9287330aff..eca6db5728 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2884,7 +2884,9 @@ int fts5GetTokenizer( ); pConfig->t.pTokApi = &pMod->x; if( rc!=SQLITE_OK ){ - if( pzErr ) *pzErr = sqlite3_mprintf("error in tokenizer constructor"); + if( pzErr && rc!=SQLITE_NOMEM ){ + *pzErr = sqlite3_mprintf("error in tokenizer constructor"); + } }else{ pConfig->t.ePattern = sqlite3Fts5TokenizerPattern( pMod->x.xCreate, pConfig->t.pTok diff --git a/manifest b/manifest index b3acb600f9..4100662c28 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sthe\sautomatic-index\sdecision\ssuch\sthat\sno\sattempt\sis\smade\sto\screate\nan\sautomatic\sindex\son\sa\scolumn\sthat\sis\sknown\sto\sbe\snon-selective\sbecause\sif\nits\suse\sin\sother\sindexes\sthat\shave\sbeen\sanalyzed.\s\sSee\n[src:/tktview/8ff324e120|ticket\s8ff324e120]\sand\n[forum:/forumpost/b21c2101a559be0a|forum\spost\sb21c2101a559be0a]. -D 2024-05-28T00:16:52.505 +C Fix\sa\sproblem\swith\sthe\serror\smessage\sreported\sby\sfts5\sin\ssome\sOOM\scases. +D 2024-05-28T10:57:24.214 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 74093394dc26750becc302922e5fe308a8597a70e6e83e66c892242 F ext/fts5/fts5_expr.c 85789f6fb01995f2578b60a360057ed754335a890b1ab2e57e238b3670a9ae6c F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c 6b39f263b1651634c03ed0c6de67cc6b4556c847cb57e667ed9f6e2e5879f734 +F ext/fts5/fts5_main.c ac3aaf0c885cf4e274c0c09ece632e17ff2fce01f2c9c0f4c50ffbbb3e267bde F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -2193,9 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fe2e1dadbacbe6392ceed44fd287a2ed82189cb8055f35631d37967d9a7a5d1d 70409763f70faa2a0f4f072fd318a687b109a0905cc57906ad7f80d2885fe6d9 -R a2e2cddff59ec6ba73015ce8c07a73b7 -T +closed 70409763f70faa2a0f4f072fd318a687b109a0905cc57906ad7f80d2885fe6d9 -U drh -Z 8ce1e608e60c39ba63116e451ee082d8 +P 2a7603c327d11d5e6bc4d40c29151fea544d650f51200ff76efb921adb0c38df +R ff0cddca97b62cc7381118a6c452dba8 +U dan +Z ca96a632d84f04e3255ed7e04ddf12c2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 57d33a3566..d5e6410205 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2a7603c327d11d5e6bc4d40c29151fea544d650f51200ff76efb921adb0c38df \ No newline at end of file +c7aaa28f786567e29ebee3848283b5c740dd3b8144dc14372e56260ae1b76922 \ No newline at end of file From 6fa46d0e06a805817c574e38f307ee4ea2d9c7a8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 May 2024 11:24:18 +0000 Subject: [PATCH 0438/1030] Documentation typo fix. [forum:/forumpost/772d6688f5|Forum post 772d6688f5]. FossilOrigin-Name: 1f2f9c709eaee3c45664afa062f0fb2b912de446581066c87ea144b8ba55b55c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4100662c28..3247aa1954 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sthe\serror\smessage\sreported\sby\sfts5\sin\ssome\sOOM\scases. -D 2024-05-28T10:57:24.214 +C Documentation\stypo\sfix.\s[forum:/forumpost/772d6688f5|Forum\spost\s772d6688f5]. +D 2024-05-28T11:24:18.163 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -757,7 +757,7 @@ F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c cbdaf9cb2d9a697ee9ce1484f27d2e96762d33cc19259aedfb818a68b9d3be10 F src/shell.c.in cba809572972ff736aa6c3423ffb87015c740864206d97e168bb77316129015f -F src/sqlite.h.in 954a55f03801617876d30329a4496f365d73f4d91fde7dabc61869f51e2967e8 +F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 98ba756789b37f8d8217407ce077c31faf0b9b21d593b327c2b9667ad5bea1ac @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2a7603c327d11d5e6bc4d40c29151fea544d650f51200ff76efb921adb0c38df -R ff0cddca97b62cc7381118a6c452dba8 -U dan -Z ca96a632d84f04e3255ed7e04ddf12c2 +P c7aaa28f786567e29ebee3848283b5c740dd3b8144dc14372e56260ae1b76922 +R 99deae99ebcbc8da3b4fce909c96ce2b +U drh +Z 7b99bdb14543b75f33551b066f25d602 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d5e6410205..74666dedbe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c7aaa28f786567e29ebee3848283b5c740dd3b8144dc14372e56260ae1b76922 \ No newline at end of file +1f2f9c709eaee3c45664afa062f0fb2b912de446581066c87ea144b8ba55b55c \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index a9731faf9e..ae82088423 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3571,7 +3571,7 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** [[OPEN_EXRESCODE]] ^(
    [SQLITE_OPEN_EXRESCODE]
    **
    The database connection comes up in "extended result code mode". ** In other words, the database behaves as if -** [sqlite3_extended_result_codes(db,1)] where called on the database +** [sqlite3_extended_result_codes(db,1)] were called on the database ** connection as soon as the connection is created. In addition to setting ** the extended result code mode, this flag also causes [sqlite3_open_v2()] ** to return an extended result code.
    From efe474af97decf22821c8b5249075101bd7feea5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 May 2024 12:41:11 +0000 Subject: [PATCH 0439/1030] Increase the number of parallel paths in the query solver from 12 to 20. In the .wheretrace output, sort the parallel paths in order of increasing cost. FossilOrigin-Name: 8ba2c2f5cb31f7bcc426bec78457316ef11d0b5debf24e8da8c6fc2f95878b1e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 32 ++++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 3247aa1954..d105c89f60 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Documentation\stypo\sfix.\s[forum:/forumpost/772d6688f5|Forum\spost\s772d6688f5]. -D 2024-05-28T11:24:18.163 +C Increase\sthe\snumber\sof\sparallel\spaths\sin\sthe\squery\ssolver\sfrom\s12\sto\s20.\nIn\sthe\s.wheretrace\soutput,\ssort\sthe\sparallel\spaths\sin\sorder\sof\sincreasing\ncost. +D 2024-05-28T12:41:11.505 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c ad4866c036a9d64f0c79ccf2ec60ac65bb64cb81b9facce453b0a920caac7a1d +F src/where.c c65f8862835077fdd6aefe8467990f4e50766d3a3fe96b976e81b04d83752750 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c7aaa28f786567e29ebee3848283b5c740dd3b8144dc14372e56260ae1b76922 -R 99deae99ebcbc8da3b4fce909c96ce2b +P 1f2f9c709eaee3c45664afa062f0fb2b912de446581066c87ea144b8ba55b55c +R 621f31ea7fc9d463b84af6cc3d551a91 U drh -Z 7b99bdb14543b75f33551b066f25d602 +Z 9d869639496738a8fa8ca13e1d3ba3ec # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 74666dedbe..0e1420ab4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f2f9c709eaee3c45664afa062f0fb2b912de446581066c87ea144b8ba55b55c \ No newline at end of file +8ba2c2f5cb31f7bcc426bec78457316ef11d0b5debf24e8da8c6fc2f95878b1e \ No newline at end of file diff --git a/src/where.c b/src/where.c index 9800479475..fc4a88eabf 100644 --- a/src/where.c +++ b/src/where.c @@ -5286,9 +5286,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** ----- -------- ** 1 1 // the most common case ** 2 5 - ** 3+ 12 + ** 3+ 20 */ - mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 12); + mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 20); assert( nLoop<=pWInfo->pTabList->nSrc ); WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n", nRowEst, pParse->nQueryLoop)); @@ -5535,16 +5535,28 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ #ifdef WHERETRACE_ENABLED /* >=2 */ if( sqlite3WhereTrace & 0x02 ){ + LogEst rMin, rFloor = 0; + int nDone = 0; sqlite3DebugPrintf("---- after round %d ----\n", iLoop); - for(ii=0, pTo=aTo; iirCost, pTo->nRow, - pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?'); - if( pTo->isOrdered>0 ){ - sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop); - }else{ - sqlite3DebugPrintf("\n"); + while( nDonerCost>rFloor && pTo->rCostrCost; + } + for(ii=0, pTo=aTo; iirCost==rMin ){ + sqlite3DebugPrintf(" %s cost=%-3d nrow=%-3d order=%c", + wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow, + pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?'); + if( pTo->isOrdered>0 ){ + sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop); + }else{ + sqlite3DebugPrintf("\n"); + } + nDone++; + } } + rFloor = rMin; } } #endif From 05665e9de9ee326254d43666d260e319f2bc50c1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 May 2024 18:53:36 +0000 Subject: [PATCH 0440/1030] Tweaks to the query planner so that it is better able to deal with star queries with many dimensions and bad indexes. FossilOrigin-Name: 1e49081001f93b75ee499536f8a61a0f49225a1745117bb9267249c38c4bf803 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d105c89f60..4b7723af27 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increase\sthe\snumber\sof\sparallel\spaths\sin\sthe\squery\ssolver\sfrom\s12\sto\s20.\nIn\sthe\s.wheretrace\soutput,\ssort\sthe\sparallel\spaths\sin\sorder\sof\sincreasing\ncost. -D 2024-05-28T12:41:11.505 +C Tweaks\sto\sthe\squery\splanner\sso\sthat\sit\sis\sbetter\sable\sto\sdeal\swith\sstar\nqueries\swith\smany\sdimensions\sand\sbad\sindexes. +D 2024-05-28T18:53:36.983 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c c65f8862835077fdd6aefe8467990f4e50766d3a3fe96b976e81b04d83752750 +F src/where.c 692d3d72c6d616c03aae0864366deffc367ddd8b428ec8eb41223f40afe3e2f5 F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1f2f9c709eaee3c45664afa062f0fb2b912de446581066c87ea144b8ba55b55c -R 621f31ea7fc9d463b84af6cc3d551a91 +P 8ba2c2f5cb31f7bcc426bec78457316ef11d0b5debf24e8da8c6fc2f95878b1e +R fd070e1c470e7cb887dfee0f031bfa9f U drh -Z 9d869639496738a8fa8ca13e1d3ba3ec +Z 87376a4b1930f95ae7c482e4326c0a9e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0e1420ab4a..fc87393522 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ba2c2f5cb31f7bcc426bec78457316ef11d0b5debf24e8da8c6fc2f95878b1e \ No newline at end of file +1e49081001f93b75ee499536f8a61a0f49225a1745117bb9267249c38c4bf803 \ No newline at end of file diff --git a/src/where.c b/src/where.c index fc4a88eabf..aa21b06558 100644 --- a/src/where.c +++ b/src/where.c @@ -5286,9 +5286,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** ----- -------- ** 1 1 // the most common case ** 2 5 - ** 3+ 20 + ** 3+ 8*(N-2) */ - mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 20); + mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 8*(nLoop-2)); assert( nLoop<=pWInfo->pTabList->nSrc ); WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n", nRowEst, pParse->nQueryLoop)); From d60a503b4c9197871f006051fb4dd089355b202c Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 May 2024 19:08:18 +0000 Subject: [PATCH 0441/1030] Fix a couple of assert() statements so that they cannot fire when the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS debugging capability is activated. dbsqlfuzz f5b347cf167a62fbe08062b2feee65cb9306e363. FossilOrigin-Name: 273504b74cb9c3cfa2497a1339e706a1f2d2c3ce81b23a16beb47da9292535e0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4b7723af27..61db16ed25 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tweaks\sto\sthe\squery\splanner\sso\sthat\sit\sis\sbetter\sable\sto\sdeal\swith\sstar\nqueries\swith\smany\sdimensions\sand\sbad\sindexes. -D 2024-05-28T18:53:36.983 +C Fix\sa\scouple\sof\sassert()\sstatements\sso\sthat\sthey\scannot\sfire\nwhen\sthe\sSQLITE_TESTCTRL_INTERNAL_FUNCTIONS\sdebugging\scapability\nis\sactivated.\s\sdbsqlfuzz\sf5b347cf167a62fbe08062b2feee65cb9306e363. +D 2024-05-28T19:08:18.051 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -829,7 +829,7 @@ F src/vdbe.c 2448b34ff095efa5a8d9dd525c4c0842ef7226e44b68fe8df1053ee9894aa5fd F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df -F src/vdbeaux.c 3bcf13776c39bf660a52b4b97f6389a421c2756f9ffbf4c0d94f73e1935d8d9c +F src/vdbeaux.c 6e37cb918506c28fe7657454fcbc2e01e66bfba4164f306c2f075fd5c5fef609 F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 831a244831eaa45335f9ae276b50a7a82ee10d8c46c2c72492d4eb8c98d94d89 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8ba2c2f5cb31f7bcc426bec78457316ef11d0b5debf24e8da8c6fc2f95878b1e -R fd070e1c470e7cb887dfee0f031bfa9f +P 1e49081001f93b75ee499536f8a61a0f49225a1745117bb9267249c38c4bf803 +R 64eb34d956a538c4310c3186c1ebd004 U drh -Z 87376a4b1930f95ae7c482e4326c0a9e +Z bedb48464f906f24fcbe994c86e9e98f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fc87393522..a8287142f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1e49081001f93b75ee499536f8a61a0f49225a1745117bb9267249c38c4bf803 \ No newline at end of file +273504b74cb9c3cfa2497a1339e706a1f2d2c3ce81b23a16beb47da9292535e0 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index e4c174e3fb..665f6cd17a 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -5336,7 +5336,8 @@ sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ assert( iVar>0 ); if( v ){ Mem *pMem = &v->aVar[iVar-1]; - assert( (v->db->flags & SQLITE_EnableQPSG)==0 ); + assert( (v->db->flags & SQLITE_EnableQPSG)==0 + || (v->db->mDbFlags & DBFLAG_InternalFunc)!=0 ); if( 0==(pMem->flags & MEM_Null) ){ sqlite3_value *pRet = sqlite3ValueNew(v->db); if( pRet ){ @@ -5356,7 +5357,8 @@ sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ */ void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){ assert( iVar>0 ); - assert( (v->db->flags & SQLITE_EnableQPSG)==0 ); + assert( (v->db->flags & SQLITE_EnableQPSG)==0 + || (v->db->mDbFlags & DBFLAG_InternalFunc)!=0 ); if( iVar>=32 ){ v->expmask |= 0x80000000; }else{ From c34ff12c597f1a34dc2f4df21424c2381adf36dd Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 29 May 2024 00:38:12 +0000 Subject: [PATCH 0442/1030] Use a heuristic in the query planner to help it better cope with large star schema queries. FossilOrigin-Name: a98be0f548f277fab8f38a2dec6ddcbe7a7fff27856ba19e76ad8c5641894b7b --- manifest | 18 +- manifest.uuid | 2 +- src/where.c | 67 ++++- src/whereInt.h | 1 + test/starschema1.test | 584 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 662 insertions(+), 10 deletions(-) create mode 100644 test/starschema1.test diff --git a/manifest b/manifest index 61db16ed25..56178c42c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\sof\sassert()\sstatements\sso\sthat\sthey\scannot\sfire\nwhen\sthe\sSQLITE_TESTCTRL_INTERNAL_FUNCTIONS\sdebugging\scapability\nis\sactivated.\s\sdbsqlfuzz\sf5b347cf167a62fbe08062b2feee65cb9306e363. -D 2024-05-28T19:08:18.051 +C Use\sa\sheuristic\sin\sthe\squery\splanner\sto\shelp\sit\sbetter\scope\swith\slarge\nstar\sschema\squeries. +D 2024-05-29T00:38:12.212 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,8 +840,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 692d3d72c6d616c03aae0864366deffc367ddd8b428ec8eb41223f40afe3e2f5 -F src/whereInt.h 82a13766f13d1a53b05387c2e60726289ef26404bc7b9b1f7770204d97357fb8 +F src/where.c 4b777f3c20be01c9849f651a99f187a83300effd20ed8079e16e6498ca99a1f6 +F src/whereInt.h aff769fab5e21f8da96d4588f49204fa341f5d0f762ce965826dcf4f57c5a9d1 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 @@ -1661,6 +1661,7 @@ F test/spellfix4.test 51c7c26514ade169855c66bcf130bd5acfb4d7fd090cc624645ab275ae F test/sqldiff1.test 1b7ab4f312442c5cc6b3a5f299fa8ca051416d1dd173cb1126fd51bf64f2c3fb F test/sqllimits1.test dee96a51b83ef866d06ec3c687d4c951d97b02549facc5be88c9dfcb215b98bf F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a +F test/starschema1.test b8dad4cd297e7639698d3f3af97693efc2f740f1ba66f92acef900d1bb0d82a4 F test/startup.c 1beb5ca66fcc0fce95c3444db9d1674f90fc605499a574ae2434dcfc10d22805 F test/stat.test 123212a20ceb496893d5254a5f6c76442ce549fdc08d1702d8288a2bbaac8408 F test/statfault.test 064f43379e4992b5221b7d9ac887c313b3191f85cce605d78e416fc4045da64e @@ -2193,8 +2194,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1e49081001f93b75ee499536f8a61a0f49225a1745117bb9267249c38c4bf803 -R 64eb34d956a538c4310c3186c1ebd004 +P 273504b74cb9c3cfa2497a1339e706a1f2d2c3ce81b23a16beb47da9292535e0 +R 22ac7091c1a5acc513b0e5ab9d7bf6ee +T *branch * star-schema +T *sym-star-schema * +T -sym-trunk * U drh -Z bedb48464f906f24fcbe994c86e9e98f +Z 6e119c920cb95d32552c3e003a8c097f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a8287142f9..74da6398aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -273504b74cb9c3cfa2497a1339e706a1f2d2c3ce81b23a16beb47da9292535e0 \ No newline at end of file +a98be0f548f277fab8f38a2dec6ddcbe7a7fff27856ba19e76ad8c5641894b7b \ No newline at end of file diff --git a/src/where.c b/src/where.c index aa21b06558..15ca06237f 100644 --- a/src/where.c +++ b/src/where.c @@ -5244,6 +5244,63 @@ static LogEst whereSortingCost( return rSortCost; } +/* +** Compute the maximum number of paths in the solver algorithm, for +** queries that have three or more terms in the FROM clause. Queries with +** two or fewer FROM clause terms are handled by the caller. +** +** Query planning is NP-hard. We must limit the number of paths at +** each step of the solver search algorithm to avoid exponential behavior. +** +** The value returned is a tuning parameter. Currently the value is +** 12 for normal queries and 18 for "star-queries". A star-query is +** a query with large central table that is joined against three or +** more smaller tables. The central table is called the "fact" table. +** The smaller tables that get joined are "dimension tables". +** +** SIDE EFFECT: +** +** If pWInfo describes a star-query, then the cost on WhereLoops for the +** fact table is reduced. This heuristic helps keep fact tables in +** outer loops. Without this heuristic, paths with fact tables in outer +** loops tend to get pruned by the mxChoice limit on the number of paths, +** resulting in poor query plans. +*/ +static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ + int nLoop = pWInfo->nLevel; /* Number of terms in the join */ + if( nRowEst==0 && nLoop>=4 ){ + /* Check to see if we are dealing with a star schema and if so, reduce + ** the cost of fact tables relative to dimension tables, as a heuristic + ** to help keep the fact tables in outer loops. + */ + int iLoop; /* Counter over join terms */ + Bitmask m; /* Bitmask for current loop */ + assert( pWInfo->nOutStarDelta==0 ); + for(iLoop=0, m=1; iLooppLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + if( (pWLoop->prereq & m)!=0 && (pWLoop->maskSelf & mSeen)==0 ){ + nDep++; + mSeen |= pWLoop->maskSelf; + } + } + if( nDep<=3 ) continue; + rDelta = 15*(nDep-3); + pWInfo->nOutStarDelta += rDelta; + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + if( pWLoop->maskSelf==m ){ + pWLoop->rRun -= rDelta; + pWLoop->nOut -= rDelta; + } + } + } + } + return pWInfo->nOutStarDelta>0 ? 18 : 12; +} + /* ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine ** attempts to find the lowest cost path that visits each WhereLoop @@ -5288,7 +5345,13 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** 2 5 ** 3+ 8*(N-2) */ - mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 8*(nLoop-2)); + if( nLoop<=1 ){ + mxChoice = 1; + }else if( nLoop==2 ){ + mxChoice = 5; + }else{ + mxChoice = computeMxChoice(pWInfo, nRowEst); + } assert( nLoop<=pWInfo->pTabList->nSrc ); WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n", nRowEst, pParse->nQueryLoop)); @@ -5651,7 +5714,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ } } - pWInfo->nRowOut = pFrom->nRow; + pWInfo->nRowOut = pFrom->nRow + pWInfo->nOutStarDelta; /* Free temporary memory and return success */ sqlite3StackFreeNN(pParse->db, pSpace); diff --git a/src/whereInt.h b/src/whereInt.h index f3cc5776a0..fc9b32a36d 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -482,6 +482,7 @@ struct WhereInfo { unsigned untestedTerms :1; /* Not all WHERE terms resolved by outer loop */ unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */ unsigned sorted :1; /* True if really sorted (not just grouped) */ + LogEst nOutStarDelta; /* Artifical nOut reduction for star-query */ LogEst nRowOut; /* Estimated number of output rows */ int iTop; /* The very beginning of the WHERE loop */ int iEndWhere; /* End of the WHERE clause itself */ diff --git a/test/starschema1.test b/test/starschema1.test new file mode 100644 index 0000000000..d06a1e52f1 --- /dev/null +++ b/test/starschema1.test @@ -0,0 +1,584 @@ +# 2024-05-28 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Test cases for the ability of the query planner to cope with +# star-schema queries on databases with goofy indexes. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix starschema1 + +do_execsql_test 1.1 { +CREATE TABLE t1( + a01 INT, a02 INT, a03 INT, a04 INT, a05 INT, a06 INT, a07 INT, a08 INT, + a09 INT, a10 INT, a11 INT, a12 INT, a13 INT, a14 INT, a15 INT, a16 INT, + a17 INT, a18 INT, a19 INT, a20 INT, a21 INT, a22 INT, a23 INT, a24 INT, + a25 INT, a26 INT, a27 INT, a28 INT, a29 INT, a30 INT, a31 INT, a32 INT, + a33 INT, a34 INT, a35 INT, a36 INT, a37 INT, a38 INT, a39 INT, a40 INT, + a41 INT, a42 INT, a43 INT, a44 INT, a45 INT, a46 INT, a47 INT, a48 INT, + a49 INT, a50 INT, a51 INT, a52 INT, a53 INT, a54 INT, a55 INT, a56 INT, + a57 INT, a58 INT, a59 INT, a60 INT, a61 INT, a62 INT, a63 INT, d TEXT); +CREATE TABLE x01(b01 INT, c01 TEXT); +CREATE TABLE x02(b02 INT, c02 TEXT); +CREATE TABLE x03(b03 INT, c03 TEXT); +CREATE TABLE x04(b04 INT, c04 TEXT); +CREATE TABLE x05(b05 INT, c05 TEXT); +CREATE TABLE x06(b06 INT, c06 TEXT); +CREATE TABLE x07(b07 INT, c07 TEXT); +CREATE TABLE x08(b08 INT, c08 TEXT); +CREATE TABLE x09(b09 INT, c09 TEXT); +CREATE TABLE x10(b10 INT, c10 TEXT); +CREATE TABLE x11(b11 INT, c11 TEXT); +CREATE TABLE x12(b12 INT, c12 TEXT); +CREATE TABLE x13(b13 INT, c13 TEXT); +CREATE TABLE x14(b14 INT, c14 TEXT); +CREATE TABLE x15(b15 INT, c15 TEXT); +CREATE TABLE x16(b16 INT, c16 TEXT); +CREATE TABLE x17(b17 INT, c17 TEXT); +CREATE TABLE x18(b18 INT, c18 TEXT); +CREATE TABLE x19(b19 INT, c19 TEXT); +CREATE TABLE x20(b20 INT, c20 TEXT); +CREATE TABLE x21(b21 INT, c21 TEXT); +CREATE TABLE x22(b22 INT, c22 TEXT); +CREATE TABLE x23(b23 INT, c23 TEXT); +CREATE TABLE x24(b24 INT, c24 TEXT); +CREATE TABLE x25(b25 INT, c25 TEXT); +CREATE TABLE x26(b26 INT, c26 TEXT); +CREATE TABLE x27(b27 INT, c27 TEXT); +CREATE TABLE x28(b28 INT, c28 TEXT); +CREATE TABLE x29(b29 INT, c29 TEXT); +CREATE TABLE x30(b30 INT, c30 TEXT); +CREATE TABLE x31(b31 INT, c31 TEXT); +CREATE TABLE x32(b32 INT, c32 TEXT); +CREATE TABLE x33(b33 INT, c33 TEXT); +CREATE TABLE x34(b34 INT, c34 TEXT); +CREATE TABLE x35(b35 INT, c35 TEXT); +CREATE TABLE x36(b36 INT, c36 TEXT); +CREATE TABLE x37(b37 INT, c37 TEXT); +CREATE TABLE x38(b38 INT, c38 TEXT); +CREATE TABLE x39(b39 INT, c39 TEXT); +CREATE TABLE x40(b40 INT, c40 TEXT); +CREATE TABLE x41(b41 INT, c41 TEXT); +CREATE TABLE x42(b42 INT, c42 TEXT); +CREATE TABLE x43(b43 INT, c43 TEXT); +CREATE TABLE x44(b44 INT, c44 TEXT); +CREATE TABLE x45(b45 INT, c45 TEXT); +CREATE TABLE x46(b46 INT, c46 TEXT); +CREATE TABLE x47(b47 INT, c47 TEXT); +CREATE TABLE x48(b48 INT, c48 TEXT); +CREATE TABLE x49(b49 INT, c49 TEXT); +CREATE TABLE x50(b50 INT, c50 TEXT); +CREATE TABLE x51(b51 INT, c51 TEXT); +CREATE TABLE x52(b52 INT, c52 TEXT); +CREATE TABLE x53(b53 INT, c53 TEXT); +CREATE TABLE x54(b54 INT, c54 TEXT); +CREATE TABLE x55(b55 INT, c55 TEXT); +CREATE TABLE x56(b56 INT, c56 TEXT); +CREATE TABLE x57(b57 INT, c57 TEXT); +CREATE TABLE x58(b58 INT, c58 TEXT); +CREATE TABLE x59(b59 INT, c59 TEXT); +CREATE TABLE x60(b60 INT, c60 TEXT); +CREATE TABLE x61(b61 INT, c61 TEXT); +CREATE TABLE x62(b62 INT, c62 TEXT); +CREATE TABLE x63(b63 INT, c63 TEXT); +/**** Uncomment to generate actual data ************************************ +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<172800) + INSERT INTO t1 + SELECT stmtrand()%12, stmtrand()%13, stmtrand()%14, stmtrand()%15, + stmtrand()%16, stmtrand()%17, stmtrand()%18, stmtrand()%19, + stmtrand()%20, stmtrand()%21, stmtrand()%22, stmtrand()%23, + stmtrand()%24, stmtrand()%25, stmtrand()%26, stmtrand()%27, + stmtrand()%28, stmtrand()%29, stmtrand()%30, stmtrand()%31, + stmtrand()%32, stmtrand()%33, stmtrand()%34, stmtrand()%35, + stmtrand()%36, stmtrand()%37, stmtrand()%38, stmtrand()%39, + stmtrand()%40, stmtrand()%41, stmtrand()%42, stmtrand()%43, + stmtrand()%28, stmtrand()%29, stmtrand()%30, stmtrand()%31, + stmtrand()%32, stmtrand()%33, stmtrand()%34, stmtrand()%35, + stmtrand()%36, stmtrand()%37, stmtrand()%38, stmtrand()%39, + stmtrand()%40, stmtrand()%41, stmtrand()%42, stmtrand()%43, + stmtrand()%28, stmtrand()%29, stmtrand()%30, stmtrand()%31, + stmtrand()%32, stmtrand()%33, stmtrand()%34, stmtrand()%35, + stmtrand()%36, stmtrand()%37, stmtrand()%38, stmtrand()%39, + stmtrand()%40, stmtrand()%41, stmtrand()%42, stmtrand() FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<8) + INSERT INTO x01 SELECT n%4, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<12) + INSERT INTO x02 SELECT n%6, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<16) + INSERT INTO x03 SELECT n%8, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<20) + INSERT INTO x04 SELECT n%10, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<24) + INSERT INTO x05 SELECT n%12, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<32) + INSERT INTO x06 SELECT n%16, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<36) + INSERT INTO x07 SELECT n%18, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<40) + INSERT INTO x08 SELECT n%20, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<44) + INSERT INTO x09 SELECT n%22, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<48) + INSERT INTO x10 SELECT n%24, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<52) + INSERT INTO x11 SELECT n%26, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<56) + INSERT INTO x12 SELECT n%28, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<60) + INSERT INTO x13 SELECT n%30, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<64) + INSERT INTO x14 SELECT n%32, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<72) + INSERT INTO x15 SELECT n%36, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<80) + INSERT INTO x16 SELECT n%40, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<8) + INSERT INTO x17 SELECT n%4, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<12) + INSERT INTO x18 SELECT n%6, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<16) + INSERT INTO x19 SELECT n%8, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<20) + INSERT INTO x20 SELECT n%10, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<24) + INSERT INTO x21 SELECT n%12, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<32) + INSERT INTO x22 SELECT n%16, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<36) + INSERT INTO x23 SELECT n%18, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<40) + INSERT INTO x24 SELECT n%20, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<44) + INSERT INTO x25 SELECT n%22, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<48) + INSERT INTO x26 SELECT n%24, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<52) + INSERT INTO x27 SELECT n%26, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<56) + INSERT INTO x28 SELECT n%28, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<60) + INSERT INTO x29 SELECT n%30, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<64) + INSERT INTO x30 SELECT n%32, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<72) + INSERT INTO x31 SELECT n%36, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<80) + INSERT INTO x32 SELECT n%40, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<8) + INSERT INTO x33 SELECT n%4, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<12) + INSERT INTO x34 SELECT n%6, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<16) + INSERT INTO x35 SELECT n%8, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<20) + INSERT INTO x36 SELECT n%10, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<24) + INSERT INTO x37 SELECT n%12, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<32) + INSERT INTO x38 SELECT n%16, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<36) + INSERT INTO x39 SELECT n%18, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<40) + INSERT INTO x40 SELECT n%20, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<44) + INSERT INTO x41 SELECT n%22, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<48) + INSERT INTO x42 SELECT n%24, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<52) + INSERT INTO x43 SELECT n%26, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<56) + INSERT INTO x44 SELECT n%28, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<60) + INSERT INTO x45 SELECT n%30, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<64) + INSERT INTO x46 SELECT n%32, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<72) + INSERT INTO x47 SELECT n%36, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<80) + INSERT INTO x48 SELECT n%40, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<8) + INSERT INTO x49 SELECT n%4, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<12) + INSERT INTO x50 SELECT n%6, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<16) + INSERT INTO x51 SELECT n%8, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<20) + INSERT INTO x52 SELECT n%10, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<24) + INSERT INTO x53 SELECT n%12, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<32) + INSERT INTO x54 SELECT n%16, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<36) + INSERT INTO x55 SELECT n%18, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<40) + INSERT INTO x56 SELECT n%20, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<44) + INSERT INTO x57 SELECT n%22, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<48) + INSERT INTO x58 SELECT n%24, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<52) + INSERT INTO x59 SELECT n%26, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<56) + INSERT INTO x60 SELECT n%28, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<60) + INSERT INTO x61 SELECT n%30, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<64) + INSERT INTO x62 SELECT n%32, format('%d-or-0x%04x',n,n) FROM c; +WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<72) + INSERT INTO x63 SELECT n%36, format('%d-or-0x%04x',n,n) FROM c; +****************************************************************************/ +CREATE INDEX t1a01 ON t1(a01); +CREATE INDEX t1a02 ON t1(a02); +CREATE INDEX t1a03 ON t1(a03); +CREATE INDEX t1a04 ON t1(a04); +CREATE INDEX t1a05 ON t1(a05); +CREATE INDEX t1a06 ON t1(a06); +CREATE INDEX t1a07 ON t1(a07); +CREATE INDEX t1a08 ON t1(a08); +CREATE INDEX t1a09 ON t1(a09); +CREATE INDEX t1a10 ON t1(a10); +CREATE INDEX t1a11 ON t1(a11); +CREATE INDEX t1a12 ON t1(a12); +CREATE INDEX t1a13 ON t1(a13); +CREATE INDEX t1a14 ON t1(a14); +CREATE INDEX t1a15 ON t1(a15); +CREATE INDEX t1a16 ON t1(a16); +CREATE INDEX t1a17 ON t1(a17); +CREATE INDEX t1a18 ON t1(a18); +CREATE INDEX t1a19 ON t1(a19); +CREATE INDEX t1a20 ON t1(a20); +CREATE INDEX t1a21 ON t1(a21); +CREATE INDEX t1a22 ON t1(a22); +CREATE INDEX t1a23 ON t1(a23); +CREATE INDEX t1a24 ON t1(a24); +CREATE INDEX t1a25 ON t1(a25); +CREATE INDEX t1a26 ON t1(a26); +CREATE INDEX t1a27 ON t1(a27); +CREATE INDEX t1a28 ON t1(a28); +CREATE INDEX t1a29 ON t1(a29); +CREATE INDEX t1a30 ON t1(a30); +CREATE INDEX t1a31 ON t1(a31); +CREATE INDEX t1a32 ON t1(a32); +CREATE INDEX t1a33 ON t1(a33); +CREATE INDEX t1a34 ON t1(a34); +CREATE INDEX t1a35 ON t1(a35); +CREATE INDEX t1a36 ON t1(a36); +CREATE INDEX t1a37 ON t1(a37); +CREATE INDEX t1a38 ON t1(a38); +CREATE INDEX t1a39 ON t1(a39); +CREATE INDEX t1a40 ON t1(a40); +CREATE INDEX t1a41 ON t1(a41); +CREATE INDEX t1a42 ON t1(a42); +CREATE INDEX t1a43 ON t1(a43); +CREATE INDEX t1a44 ON t1(a44); +CREATE INDEX t1a45 ON t1(a45); +CREATE INDEX t1a46 ON t1(a46); +CREATE INDEX t1a47 ON t1(a47); +CREATE INDEX t1a48 ON t1(a48); +CREATE INDEX t1a49 ON t1(a49); +CREATE INDEX t1a50 ON t1(a50); +CREATE INDEX t1a51 ON t1(a51); +CREATE INDEX t1a52 ON t1(a52); +CREATE INDEX t1a53 ON t1(a53); +CREATE INDEX t1a54 ON t1(a54); +CREATE INDEX t1a55 ON t1(a55); +CREATE INDEX t1a56 ON t1(a56); +CREATE INDEX t1a57 ON t1(a57); +CREATE INDEX t1a58 ON t1(a58); +CREATE INDEX t1a59 ON t1(a59); +CREATE INDEX t1a60 ON t1(a60); +CREATE INDEX t1a61 ON t1(a61); +CREATE INDEX t1a62 ON t1(a62); +CREATE INDEX t1a63 ON t1(a63); +CREATE INDEX x01x ON x01(b01); +CREATE INDEX x02x ON x02(b02); +CREATE INDEX x03x ON x03(b03); +CREATE INDEX x04x ON x04(b04); +CREATE INDEX x05x ON x05(b05); +CREATE INDEX x06x ON x06(b06); +CREATE INDEX x07x ON x07(b07); +CREATE INDEX x08x ON x08(b08); +CREATE INDEX x09x ON x09(b09); +CREATE INDEX x10x ON x10(b10); +CREATE INDEX x11x ON x11(b11); +CREATE INDEX x12x ON x12(b12); +CREATE INDEX x13x ON x13(b13); +CREATE INDEX x14x ON x14(b14); +CREATE INDEX x15x ON x15(b15); +CREATE INDEX x16x ON x16(b16); +CREATE INDEX x17x ON x17(b17); +CREATE INDEX x18x ON x18(b18); +CREATE INDEX x19x ON x19(b19); +CREATE INDEX x20x ON x20(b20); +CREATE INDEX x21x ON x21(b21); +CREATE INDEX x22x ON x22(b22); +CREATE INDEX x23x ON x23(b23); +CREATE INDEX x24x ON x24(b24); +CREATE INDEX x25x ON x25(b25); +CREATE INDEX x26x ON x26(b26); +CREATE INDEX x27x ON x27(b27); +CREATE INDEX x28x ON x28(b28); +CREATE INDEX x29x ON x29(b29); +CREATE INDEX x30x ON x30(b30); +CREATE INDEX x31x ON x31(b31); +CREATE INDEX x32x ON x32(b32); +CREATE INDEX x33x ON x33(b33); +CREATE INDEX x34x ON x34(b34); +CREATE INDEX x35x ON x35(b35); +CREATE INDEX x36x ON x36(b36); +CREATE INDEX x37x ON x37(b37); +CREATE INDEX x38x ON x38(b38); +CREATE INDEX x39x ON x39(b39); +CREATE INDEX x40x ON x40(b40); +CREATE INDEX x41x ON x41(b41); +CREATE INDEX x42x ON x42(b42); +CREATE INDEX x43x ON x43(b43); +CREATE INDEX x44x ON x44(b44); +CREATE INDEX x45x ON x45(b45); +CREATE INDEX x46x ON x46(b46); +CREATE INDEX x47x ON x47(b47); +CREATE INDEX x48x ON x48(b48); +CREATE INDEX x49x ON x49(b49); +CREATE INDEX x50x ON x50(b50); +CREATE INDEX x51x ON x51(b51); +CREATE INDEX x52x ON x52(b52); +CREATE INDEX x53x ON x53(b53); +CREATE INDEX x54x ON x54(b54); +CREATE INDEX x55x ON x55(b55); +CREATE INDEX x56x ON x56(b56); +CREATE INDEX x57x ON x57(b57); +CREATE INDEX x58x ON x58(b58); +CREATE INDEX x59x ON x59(b59); +CREATE INDEX x60x ON x60(b60); +CREATE INDEX x61x ON x61(b61); +CREATE INDEX x62x ON x62(b62); +CREATE INDEX x63x ON x63(b63); +ANALYZE sqlite_schema; +INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES + ('t1','t1a01','172800 14400'), + ('t1','t1a02','172800 13293'), + ('t1','t1a03','172800 12343'), + ('t1','t1a04','172800 11520'), + ('t1','t1a05','172800 10800'), + ('t1','t1a06','172800 10165'), + ('t1','t1a07','172800 9600'), + ('t1','t1a08','172800 9095'), + ('t1','t1a09','172800 8640'), + ('t1','t1a10','172800 8229'), + ('t1','t1a11','172800 7855'), + ('t1','t1a12','172800 7514'), + ('t1','t1a13','172800 7200'), + ('t1','t1a14','172800 6912'), + ('t1','t1a15','172800 6647'), + ('t1','t1a16','172800 6400'), + ('t1','t1a17','172800 6172'), + ('t1','t1a18','172800 5959'), + ('t1','t1a19','172800 5760'), + ('t1','t1a20','172800 5575'), + ('t1','t1a21','172800 5400'), + ('t1','t1a22','172800 5237'), + ('t1','t1a23','172800 5083'), + ('t1','t1a24','172800 4938'), + ('t1','t1a25','172800 4800'), + ('t1','t1a26','172800 4671'), + ('t1','t1a27','172800 4548'), + ('t1','t1a28','172800 4431'), + ('t1','t1a29','172800 4320'), + ('t1','t1a30','172800 4215'), + ('t1','t1a31','172800 4115'), + ('t1','t1a32','172800 4019'), + ('t1','t1a33','172800 6172'), + ('t1','t1a34','172800 5959'), + ('t1','t1a35','172800 5760'), + ('t1','t1a36','172800 5575'), + ('t1','t1a37','172800 5400'), + ('t1','t1a38','172800 5237'), + ('t1','t1a39','172800 5083'), + ('t1','t1a40','172800 4938'), + ('t1','t1a41','172800 4800'), + ('t1','t1a42','172800 4671'), + ('t1','t1a43','172800 4548'), + ('t1','t1a44','172800 4431'), + ('t1','t1a45','172800 4320'), + ('t1','t1a46','172800 4215'), + ('t1','t1a47','172800 4115'), + ('t1','t1a48','172800 4019'), + ('t1','t1a49','172800 6172'), + ('t1','t1a50','172800 5959'), + ('t1','t1a51','172800 5760'), + ('t1','t1a52','172800 5575'), + ('t1','t1a53','172800 5400'), + ('t1','t1a54','172800 5237'), + ('t1','t1a55','172800 5083'), + ('t1','t1a56','172800 4938'), + ('t1','t1a57','172800 4800'), + ('t1','t1a58','172800 4671'), + ('t1','t1a59','172800 4548'), + ('t1','t1a60','172800 4431'), + ('t1','t1a61','172800 4320'), + ('t1','t1a62','172800 4215'), + ('t1','t1a63','172800 4115'), + ('x01','x01x','80 2'), + ('x02','x02x','120 2'), + ('x03','x03x','160 2'), + ('x04','x04x','20 2'), + ('x05','x05x','24 2'), + ('x06','x06x','32 2'), + ('x07','x07x','36 2'), + ('x08','x08x','40 2'), + ('x09','x09x','44 2'), + ('x10','x10x','48 2'), + ('x11','x11x','52 2'), + ('x12','x12x','56 2'), + ('x13','x13x','60 2'), + ('x14','x14x','64 2'), + ('x15','x15x','72 2'), + ('x16','x16x','80 2'), + ('x17','x17x','80 2'), + ('x18','x18x','120 2'), + ('x19','x19x','160 2'), + ('x20','x20x','20 2'), + ('x21','x21x','24 2'), + ('x22','x22x','32 2'), + ('x23','x23x','36 2'), + ('x24','x24x','40 2'), + ('x25','x25x','44 2'), + ('x26','x26x','48 2'), + ('x27','x27x','52 2'), + ('x28','x28x','56 2'), + ('x29','x29x','60 2'), + ('x30','x30x','64 2'), + ('x31','x31x','72 2'), + ('x32','x32x','80 2'), + ('x33','x33x','80 2'), + ('x34','x34x','120 2'), + ('x35','x35x','160 2'), + ('x36','x36x','20 2'), + ('x37','x37x','24 2'), + ('x38','x38x','32 2'), + ('x39','x39x','36 2'), + ('x40','x40x','40 2'), + ('x41','x41x','44 2'), + ('x42','x42x','48 2'), + ('x43','x43x','52 2'), + ('x44','x44x','56 2'), + ('x45','x45x','60 2'), + ('x46','x46x','64 2'), + ('x47','x47x','72 2'), + ('x48','x48x','80 2'), + ('x49','x49x','80 2'), + ('x50','x50x','120 2'), + ('x51','x51x','160 2'), + ('x52','x52x','20 2'), + ('x53','x53x','24 2'), + ('x54','x54x','32 2'), + ('x55','x55x','36 2'), + ('x56','x56x','40 2'), + ('x57','x57x','44 2'), + ('x58','x58x','48 2'), + ('x59','x59x','52 2'), + ('x60','x60x','56 2'), + ('x61','x61x','60 2'), + ('x62','x62x','64 2'), + ('x63','x63x','72 2'); +ANALYZE sqlite_schema; +} +do_execsql_test 1.2 { + EXPLAIN QUERY PLAN + SELECT c01, c02, c03 + FROM t1, x01, x02, x03 + WHERE a01=b01 AND a02=b02 AND a03=b03; +} {/SCAN t1.*SEARCH.*SEARCH.*SEARCH/} +do_execsql_test 1.3 { + EXPLAIN QUERY PLAN + SELECT c01, c02, c03, c04 + FROM t1, x01, x02, x03, x04 + WHERE a01=b01 AND a02=b02 AND a03=b03 AND a04=b04; +} {/SCAN .*SEARCH .*SEARCH .*SEARCH .*SEARCH /} +do_execsql_test 1.4 { + EXPLAIN QUERY PLAN + SELECT c01, c02, c03, c04, c05 + FROM t1, x01, x02, x03, x04, x05 + WHERE a01=b01 AND a02=b02 AND a03=b03 AND a04=b04 AND a05=b05; +} {/SCAN .*SEARCH .*SEARCH .*SEARCH .*SEARCH .*SEARCH/} +do_execsql_test 1.5 { + EXPLAIN QUERY PLAN + SELECT c01, c02, c03, c04, c05, c06 + FROM t1, x01, x02, x03, x04, x05, x06 + WHERE a01=b01 AND a02=b02 AND a03=b03 AND a04=b04 AND a05=b05 + AND a06=b06; +} {/SCAN .*SEARCH .*SEARCH .*SEARCH .*SEARCH .*SEARCH .*SEARCH/} +do_execsql_test 1.6 { + EXPLAIN QUERY PLAN + SELECT c01, c02, c03, c04, c05, c06, c07 + FROM t1, x01, x02, x03, x04, x05, x06, x07 + WHERE a01=b01 AND a02=b02 AND a03=b03 AND a04=b04 AND a05=b05 + AND a06=b06 AND a07=b07; +} {/SCAN .*SEARCH .*SEARCH .*SEARCH .*SEARCH .*SEARCH .*SEARCH .*SEARCH/} +do_execsql_test 1.7 { + EXPLAIN QUERY PLAN + SELECT c01, c02, c03, c04, c05, c06, c07, c08 + FROM t1, x01, x02, x03, x04, x05, x06, x07, x08 + WHERE a01=b01 AND a02=b02 AND a03=b03 AND a04=b04 AND a05=b05 + AND a06=b06 AND a07=b07 AND a08=b08; +} {~/SCAN.*SCAN/} +do_execsql_test 1.8 { + EXPLAIN QUERY PLAN + SELECT c01, c02, c03, c04, c05, c06, c07, c08, + c09, c10, c11, c12, c13, c14, c15, c16, + c17, c18, c19, c20, c21, c22, c23, c24, + c25, c26, c27, c28, c29, c30, c31, c32 + FROM t1, x01, x02, x03, x04, x05, x06, x07, x08, + x09, x10, x11, x12, x13, x14, x15, x16, + x17, x18, x19, x20, x21, x22, x23, x24, + x25, x26, x27, x28, x29, x30, x31, x32 + WHERE a01=b01 AND a02=b02 AND a03=b03 AND a04=b04 AND a05=b05 AND a06=b06 + AND a07=b07 AND a08=b08 AND a09=b09 AND a10=b10 AND a11=b11 AND a12=b12 + AND a13=b13 AND a14=b14 AND a15=b15 AND a16=b16 AND a17=b17 AND a18=b18 + AND a19=b19 AND a20=b20 AND a21=b21 AND a22=b22 AND a23=b23 AND a24=b24 + AND a25=b25 AND a26=b26 AND a27=b27 AND a28=b29 AND a29=b29 AND a30=b30 + AND a31=b31 AND a32=b32; +} {~/SCAN.*SCAN.*SCAN/} +do_execsql_test 1.9 { + EXPLAIN QUERY PLAN + SELECT c01, c02, c03, c04, c05, c06, c07, c08, + c09, c10, c11, c12, c13, c14, c15, c16, + c17, c18, c19, c20, c21, c22, c23, c24, + c25, c26, c27, c28, c29, c30, c31, c32, + c33, c34, c35, c36, c37, c38, c39, c40, + c41, c42, c43, c44, c45, c46, c47, c48, + c49, c50, c51, c52, c53, c54, c55, c56, + c57, c58, c59, c60, c61, c62, c63 + FROM t1, x01, x02, x03, x04, x05, x06, x07, x08, + x09, x10, x11, x12, x13, x14, x15, x16, + x17, x18, x19, x20, x21, x22, x23, x24, + x25, x26, x27, x28, x29, x30, x31, x32, + x33, x34, x35, x36, x37, x38, x39, x40, + x41, x42, x43, x44, x45, x46, x47, x48, + x49, x50, x51, x52, x53, x54, x55, x56, + x57, x58, x59, x60, x61, x62, x63 + WHERE a01=b01 AND a02=b02 AND a03=b03 AND a04=b04 AND a05=b05 AND a06=b06 + AND a07=b07 AND a08=b08 AND a09=b09 AND a10=b10 AND a11=b11 AND a12=b12 + AND a13=b13 AND a14=b14 AND a15=b15 AND a16=b16 AND a17=b17 AND a18=b18 + AND a19=b19 AND a20=b20 AND a21=b21 AND a22=b22 AND a23=b23 AND a24=b24 + AND a25=b25 AND a26=b26 AND a27=b27 AND a28=b29 AND a29=b29 AND a30=b30 + AND a31=b31 AND a32=b32 AND a33=b33 AND a34=b34 AND a35=b35 AND a36=b36 + AND a37=b37 AND a38=b38 AND a39=b39 AND a40=b40 AND a41=b41 AND a42=b42 + AND a43=b43 AND a44=b44 AND a45=b45 AND a46=b46 AND a47=b47 AND a48=b48 + AND a49=b49 AND a50=b50 AND a51=b51 AND a52=b52 AND a53=b53 AND a54=b54 + AND a55=b55 AND a56=b56 AND a57=b57 AND a58=b58 AND a59=b59 AND a60=b60 + AND a61=b61 AND a62=b62 AND a63=b63; +} {~/SCAN.*SCAN.*SCAN/} + + + +finish_test From 7c6256234c25af338a2085c6378e2e12906ece95 Mon Sep 17 00:00:00 2001 From: larrybr Date: Wed, 29 May 2024 03:35:40 +0000 Subject: [PATCH 0443/1030] [forum:/forumpost/c9b8d923d5|Fix sqldiff out-of-bounds char classification error mentioned in the forum.] FossilOrigin-Name: b31933d87301bd93763f0923e0ce06a183700875e6107c9f185faffbd99797d9 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/sqldiff.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 61db16ed25..ada3a3fbf8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\sof\sassert()\sstatements\sso\sthat\sthey\scannot\sfire\nwhen\sthe\sSQLITE_TESTCTRL_INTERNAL_FUNCTIONS\sdebugging\scapability\nis\sactivated.\s\sdbsqlfuzz\sf5b347cf167a62fbe08062b2feee65cb9306e363. -D 2024-05-28T19:08:18.051 +C [forum:/forumpost/c9b8d923d5|Fix\ssqldiff\sout-of-bounds\schar\sclassification\serror\smentioned\sin\sthe\sforum.] +D 2024-05-29T03:35:40.577 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2154,7 +2154,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 -F tool/sqldiff.c 985452ffc8554baee0f945d078859d393a22abc0bbf553a9f12acae1b6e1fdd0 +F tool/sqldiff.c 1e0a2c264c2ad5aca745d35deee3c7715cb00c703839cfb0b85be079db55194c F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 @@ -2193,8 +2193,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1e49081001f93b75ee499536f8a61a0f49225a1745117bb9267249c38c4bf803 -R 64eb34d956a538c4310c3186c1ebd004 -U drh -Z bedb48464f906f24fcbe994c86e9e98f +P 273504b74cb9c3cfa2497a1339e706a1f2d2c3ce81b23a16beb47da9292535e0 +R 3d29219632b829c340a5b12dd13b21a4 +U larrybr +Z ea2c1f12bb191533813291014e73a3d6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a8287142f9..9d57e9af9c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -273504b74cb9c3cfa2497a1339e706a1f2d2c3ce81b23a16beb47da9292535e0 \ No newline at end of file +b31933d87301bd93763f0923e0ce06a183700875e6107c9f185faffbd99797d9 \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index cbdfc35cd0..a213a67041 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -383,7 +383,7 @@ static void printQuoted(FILE *out, sqlite3_value *X){ fprintf(out, "'"); for(i=j=0; zArg[i]; i++){ char c = zArg[i]; - int ctl = iscntrl(c); + int ctl = iscntrl((unsigned char)c); if( ctl>inctl ){ inctl = ctl; fprintf(out, "%.*s'||X'%02x", i-j, &zArg[j], c); From d79ce8a45922541e0ddc24b13adefe0879db7cd2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 29 May 2024 09:53:19 +0000 Subject: [PATCH 0444/1030] Fix typos in the star-schema test cases. FossilOrigin-Name: 4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/starschema1.test | 8 ++++---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 56178c42c3..780408aedf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sa\sheuristic\sin\sthe\squery\splanner\sto\shelp\sit\sbetter\scope\swith\slarge\nstar\sschema\squeries. -D 2024-05-29T00:38:12.212 +C Fix\stypos\sin\sthe\sstar-schema\stest\scases. +D 2024-05-29T09:53:19.834 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1661,7 +1661,7 @@ F test/spellfix4.test 51c7c26514ade169855c66bcf130bd5acfb4d7fd090cc624645ab275ae F test/sqldiff1.test 1b7ab4f312442c5cc6b3a5f299fa8ca051416d1dd173cb1126fd51bf64f2c3fb F test/sqllimits1.test dee96a51b83ef866d06ec3c687d4c951d97b02549facc5be88c9dfcb215b98bf F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a -F test/starschema1.test b8dad4cd297e7639698d3f3af97693efc2f740f1ba66f92acef900d1bb0d82a4 +F test/starschema1.test a84205f97fe278a015ac39546c86b97228d22043af28f3a2ef809e8d5637ce1d F test/startup.c 1beb5ca66fcc0fce95c3444db9d1674f90fc605499a574ae2434dcfc10d22805 F test/stat.test 123212a20ceb496893d5254a5f6c76442ce549fdc08d1702d8288a2bbaac8408 F test/statfault.test 064f43379e4992b5221b7d9ac887c313b3191f85cce605d78e416fc4045da64e @@ -2194,11 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 273504b74cb9c3cfa2497a1339e706a1f2d2c3ce81b23a16beb47da9292535e0 -R 22ac7091c1a5acc513b0e5ab9d7bf6ee -T *branch * star-schema -T *sym-star-schema * -T -sym-trunk * +P a98be0f548f277fab8f38a2dec6ddcbe7a7fff27856ba19e76ad8c5641894b7b +R aa7180ddabb7c050acee0a4bf1b87870 U drh -Z 6e119c920cb95d32552c3e003a8c097f +Z 802df12468bb23a40911cf024be4e536 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 74da6398aa..8880d8ddd0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a98be0f548f277fab8f38a2dec6ddcbe7a7fff27856ba19e76ad8c5641894b7b \ No newline at end of file +4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659 \ No newline at end of file diff --git a/test/starschema1.test b/test/starschema1.test index d06a1e52f1..af8168b510 100644 --- a/test/starschema1.test +++ b/test/starschema1.test @@ -545,9 +545,9 @@ do_execsql_test 1.8 { AND a07=b07 AND a08=b08 AND a09=b09 AND a10=b10 AND a11=b11 AND a12=b12 AND a13=b13 AND a14=b14 AND a15=b15 AND a16=b16 AND a17=b17 AND a18=b18 AND a19=b19 AND a20=b20 AND a21=b21 AND a22=b22 AND a23=b23 AND a24=b24 - AND a25=b25 AND a26=b26 AND a27=b27 AND a28=b29 AND a29=b29 AND a30=b30 + AND a25=b25 AND a26=b26 AND a27=b27 AND a28=b28 AND a29=b29 AND a30=b30 AND a31=b31 AND a32=b32; -} {~/SCAN.*SCAN.*SCAN/} +} {~/SCAN.*SCAN/} do_execsql_test 1.9 { EXPLAIN QUERY PLAN SELECT c01, c02, c03, c04, c05, c06, c07, c08, @@ -570,14 +570,14 @@ do_execsql_test 1.9 { AND a07=b07 AND a08=b08 AND a09=b09 AND a10=b10 AND a11=b11 AND a12=b12 AND a13=b13 AND a14=b14 AND a15=b15 AND a16=b16 AND a17=b17 AND a18=b18 AND a19=b19 AND a20=b20 AND a21=b21 AND a22=b22 AND a23=b23 AND a24=b24 - AND a25=b25 AND a26=b26 AND a27=b27 AND a28=b29 AND a29=b29 AND a30=b30 + AND a25=b25 AND a26=b26 AND a27=b27 AND a28=b28 AND a29=b29 AND a30=b30 AND a31=b31 AND a32=b32 AND a33=b33 AND a34=b34 AND a35=b35 AND a36=b36 AND a37=b37 AND a38=b38 AND a39=b39 AND a40=b40 AND a41=b41 AND a42=b42 AND a43=b43 AND a44=b44 AND a45=b45 AND a46=b46 AND a47=b47 AND a48=b48 AND a49=b49 AND a50=b50 AND a51=b51 AND a52=b52 AND a53=b53 AND a54=b54 AND a55=b55 AND a56=b56 AND a57=b57 AND a58=b58 AND a59=b59 AND a60=b60 AND a61=b61 AND a62=b62 AND a63=b63; -} {~/SCAN.*SCAN.*SCAN/} +} {~/SCAN.*SCAN/} From 54bfc9435fc8d1d6e70e349b2442539e839cfc6b Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 29 May 2024 10:40:53 +0000 Subject: [PATCH 0445/1030] Remember the amount of the heuristic cost adjustment associated with star schemas and compensate when computing whether or not to use Bloom filters. FossilOrigin-Name: 21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 15 +++++++++++---- src/whereInt.h | 2 ++ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 780408aedf..ee9f8a9dec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sin\sthe\sstar-schema\stest\scases. -D 2024-05-29T09:53:19.834 +C Remember\sthe\samount\sof\sthe\sheuristic\scost\sadjustment\sassociated\swith\nstar\sschemas\sand\scompensate\swhen\scomputing\swhether\sor\snot\sto\suse\sBloom\nfilters. +D 2024-05-29T10:40:53.540 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,8 +840,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 4b777f3c20be01c9849f651a99f187a83300effd20ed8079e16e6498ca99a1f6 -F src/whereInt.h aff769fab5e21f8da96d4588f49204fa341f5d0f762ce965826dcf4f57c5a9d1 +F src/where.c c0252858ec8a592a65de1055762bc4ec2d4c420264379ebf16a6f04c3f11db79 +F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a98be0f548f277fab8f38a2dec6ddcbe7a7fff27856ba19e76ad8c5641894b7b -R aa7180ddabb7c050acee0a4bf1b87870 +P 4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659 +R 09573248d7c98d9580312274c1891d0f U drh -Z 802df12468bb23a40911cf024be4e536 +Z f728ba1bce4df2db5c498d1d421f9c75 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8880d8ddd0..df7005455d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659 \ No newline at end of file +21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 15ca06237f..6fc67ed2f9 100644 --- a/src/where.c +++ b/src/where.c @@ -5277,10 +5277,10 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ Bitmask m; /* Bitmask for current loop */ assert( pWInfo->nOutStarDelta==0 ); for(iLoop=0, m=1; iLooppLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ if( (pWLoop->prereq & m)!=0 && (pWLoop->maskSelf & mSeen)==0 ){ nDep++; @@ -5289,11 +5289,17 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ } if( nDep<=3 ) continue; rDelta = 15*(nDep-3); + if( pWInfo->nOutStarDelta==0 ){ + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + pWLoop->rStarDelta = 0; + } + } pWInfo->nOutStarDelta += rDelta; for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ if( pWLoop->maskSelf==m ){ pWLoop->rRun -= rDelta; pWLoop->nOut -= rDelta; + pWLoop->rStarDelta = rDelta; } } } @@ -6104,6 +6110,7 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful( } } nSearch += pLoop->nOut; + if( pWInfo->nOutStarDelta ) nSearch += pLoop->rStarDelta; } } diff --git a/src/whereInt.h b/src/whereInt.h index fc9b32a36d..d3226e0868 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -160,6 +160,8 @@ struct WhereLoop { /**** whereLoopXfer() copies fields above ***********************/ # define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot) u16 nLSlot; /* Number of slots allocated for aLTerm[] */ + LogEst rStarDelta; /* Cost delta due to star-schema heuristic. Not + ** initialized unless pWInfo->nOutStarDelta>0 */ WhereTerm **aLTerm; /* WhereTerms used */ WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */ WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */ From bb24c75b418a6f75a2cab5ab5674b2810e466d35 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 29 May 2024 13:29:39 +0000 Subject: [PATCH 0446/1030] Improvements to comments and debugging output. FossilOrigin-Name: 85164ee155e42809fe34e6c6b6fbe0a2baa9d616326a811173a0b0c8a885fcce --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 30 ++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index ee9f8a9dec..ac9d2b1802 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remember\sthe\samount\sof\sthe\sheuristic\scost\sadjustment\sassociated\swith\nstar\sschemas\sand\scompensate\swhen\scomputing\swhether\sor\snot\sto\suse\sBloom\nfilters. -D 2024-05-29T10:40:53.540 +C Improvements\sto\scomments\sand\sdebugging\soutput. +D 2024-05-29T13:29:39.023 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c c0252858ec8a592a65de1055762bc4ec2d4c420264379ebf16a6f04c3f11db79 +F src/where.c 8b1e8f8db0d1be2e724c55dd2bd9d6df0d4084455fe5d7c08533ad56bc51f0e9 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659 -R 09573248d7c98d9580312274c1891d0f +P 21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2 +R 4cfa81a11fe00a9778c1578283da953a U drh -Z f728ba1bce4df2db5c498d1d421f9c75 +Z b6f4b963a23017a1edcad5f2b0da308c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index df7005455d..1de88c6c8a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2 \ No newline at end of file +85164ee155e42809fe34e6c6b6fbe0a2baa9d616326a811173a0b0c8a885fcce \ No newline at end of file diff --git a/src/where.c b/src/where.c index 6fc67ed2f9..5a5fd7b28f 100644 --- a/src/where.c +++ b/src/where.c @@ -5252,10 +5252,14 @@ static LogEst whereSortingCost( ** Query planning is NP-hard. We must limit the number of paths at ** each step of the solver search algorithm to avoid exponential behavior. ** -** The value returned is a tuning parameter. Currently the value is -** 12 for normal queries and 18 for "star-queries". A star-query is -** a query with large central table that is joined against three or -** more smaller tables. The central table is called the "fact" table. +** The value returned is a tuning parameter. Currently the value is: +** +** 18 for star queries +** 12 otherwise +** +** For the purposes of SQLite, a star-query is defined as a query +** with a large central table that is joined against four or more +** smaller tables. The central table is called the "fact" table. ** The smaller tables that get joined are "dimension tables". ** ** SIDE EFFECT: @@ -5264,7 +5268,9 @@ static LogEst whereSortingCost( ** fact table is reduced. This heuristic helps keep fact tables in ** outer loops. Without this heuristic, paths with fact tables in outer ** loops tend to get pruned by the mxChoice limit on the number of paths, -** resulting in poor query plans. +** resulting in poor query plans. The total amount of heuristic cost +** adjustment is stored in pWInfo->nOutStarDelta and the cost adjustment +** for each WhereLoop is stored in its rStarDelta field. */ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ int nLoop = pWInfo->nLevel; /* Number of terms in the join */ @@ -5289,6 +5295,14 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ } if( nDep<=3 ) continue; rDelta = 15*(nDep-3); +#ifdef WHERETRACE_ENABLED /* 0x4 */ + if( sqlite3WhereTrace&0x4 ){ + SrcItem *pItem = pWInfo->pTabList->a + iLoop; + sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n", + pItem->zAlias ? pItem->zAlias : pItem->pTab->zName, + nDep, rDelta); + } +#endif if( pWInfo->nOutStarDelta==0 ){ for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ pWLoop->rStarDelta = 0; @@ -5342,6 +5356,8 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pParse = pWInfo->pParse; nLoop = pWInfo->nLevel; + WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n", + nRowEst, pParse->nQueryLoop)); /* TUNING: mxChoice is the maximum number of possible paths to preserve ** at each step. Based on the number of loops in the FROM clause: ** @@ -5349,7 +5365,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** ----- -------- ** 1 1 // the most common case ** 2 5 - ** 3+ 8*(N-2) + ** 3+ 12 or 18 // see computeMxChoice() */ if( nLoop<=1 ){ mxChoice = 1; @@ -5359,8 +5375,6 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ mxChoice = computeMxChoice(pWInfo, nRowEst); } assert( nLoop<=pWInfo->pTabList->nSrc ); - WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n", - nRowEst, pParse->nQueryLoop)); /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this ** case the purpose of this call is to estimate the number of rows returned From eccb42eb0e522646d54b0e1a87d872339a7613dc Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 29 May 2024 14:04:52 +0000 Subject: [PATCH 0447/1030] Small performance enhancement in wherePathSolver() FossilOrigin-Name: bdab69641df4704f7b080cf7841bbf39da9160222f7b664a79ed662b70ca7b0a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ac9d2b1802..4cd59f57db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\scomments\sand\sdebugging\soutput. -D 2024-05-29T13:29:39.023 +C Small\sperformance\senhancement\sin\swherePathSolver() +D 2024-05-29T14:04:52.593 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 8b1e8f8db0d1be2e724c55dd2bd9d6df0d4084455fe5d7c08533ad56bc51f0e9 +F src/where.c ae248eaaa25432b770147e3f76e2b3a933669f207b5b42a831128bb762b73e02 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2 -R 4cfa81a11fe00a9778c1578283da953a +P 85164ee155e42809fe34e6c6b6fbe0a2baa9d616326a811173a0b0c8a885fcce +R 1a7e0e6bfeb5455dea75e487f47f86c2 U drh -Z b6f4b963a23017a1edcad5f2b0da308c +Z a5d1401220c4de69b865dec1abe508f7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1de88c6c8a..57c8db329e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -85164ee155e42809fe34e6c6b6fbe0a2baa9d616326a811173a0b0c8a885fcce \ No newline at end of file +bdab69641df4704f7b080cf7841bbf39da9160222f7b664a79ed662b70ca7b0a \ No newline at end of file diff --git a/src/where.c b/src/where.c index 5a5fd7b28f..fe2e39b9c5 100644 --- a/src/where.c +++ b/src/where.c @@ -5457,7 +5457,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ /* At this point, pWLoop is a candidate to be the next loop. ** Compute its cost */ - rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow); + rUnsorted = pWLoop->rRun + pFrom->nRow; + if( pWLoop->rSetup ){ + rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup, rUnsorted); + } rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted); nOut = pFrom->nRow + pWLoop->nOut; maskNew = pFrom->maskLoop | pWLoop->maskSelf; @@ -5502,6 +5505,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))" for the range ** of legal values for isOrdered, -1..64. */ + assert( nTo>0 ); for(jj=0, pTo=aTo; jjmaskLoop==maskNew && ((pTo->isOrdered^isOrdered)&0x80)==0 From 1085eee0987b0f2a7ea38315343656b5ad74a220 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 29 May 2024 14:32:22 +0000 Subject: [PATCH 0448/1030] Change an assert() (incorrectly) added by the previous check-in into a testcase(). FossilOrigin-Name: 5e64b541d175c10a5df67ef3419ecd74fcb51392af5f5458973cea85ee6a3246 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4cd59f57db..87b3f96cd0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\sperformance\senhancement\sin\swherePathSolver() -D 2024-05-29T14:04:52.593 +C Change\san\sassert()\s(incorrectly)\sadded\sby\sthe\sprevious\scheck-in\sinto\sa\ntestcase(). +D 2024-05-29T14:32:22.539 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c ae248eaaa25432b770147e3f76e2b3a933669f207b5b42a831128bb762b73e02 +F src/where.c fee27468ac2d50e79c65fb31dcdfd0ed194a8cc20824bdca476df7b03b56d8cd F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 85164ee155e42809fe34e6c6b6fbe0a2baa9d616326a811173a0b0c8a885fcce -R 1a7e0e6bfeb5455dea75e487f47f86c2 +P bdab69641df4704f7b080cf7841bbf39da9160222f7b664a79ed662b70ca7b0a +R 2a6ba38d83a3c0f2b4854f963fadd689 U drh -Z a5d1401220c4de69b865dec1abe508f7 +Z bf4a72e79f5764478d8942ced8c501c4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 57c8db329e..4b2f92a750 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bdab69641df4704f7b080cf7841bbf39da9160222f7b664a79ed662b70ca7b0a \ No newline at end of file +5e64b541d175c10a5df67ef3419ecd74fcb51392af5f5458973cea85ee6a3246 \ No newline at end of file diff --git a/src/where.c b/src/where.c index fe2e39b9c5..6f7d469736 100644 --- a/src/where.c +++ b/src/where.c @@ -5505,7 +5505,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))" for the range ** of legal values for isOrdered, -1..64. */ - assert( nTo>0 ); + testcase( nTo==0 ); for(jj=0, pTo=aTo; jjmaskLoop==maskNew && ((pTo->isOrdered^isOrdered)&0x80)==0 From 7da33383c7952e88b6ded2b684d12545b93caca0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 29 May 2024 15:16:17 +0000 Subject: [PATCH 0449/1030] Remove an unused parameter from fts5ConfigParseSpecial(). Compiler-warning fix only - no functional changes. FossilOrigin-Name: c08dd245f7706f2fd2269d700be480477619a722e27e6b439462ae543302c49f --- ext/fts5/fts5_config.c | 3 +-- manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 32f52a6cab..a9a6c54380 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -234,7 +234,6 @@ static int fts5ConfigSetEnum( ** eventually free any such error message using sqlite3_free(). */ static int fts5ConfigParseSpecial( - Fts5Global *pGlobal, Fts5Config *pConfig, /* Configuration object to update */ const char *zCmd, /* Special command to parse */ const char *zArg, /* Argument to parse */ @@ -590,7 +589,7 @@ int sqlite3Fts5ConfigParse( rc = SQLITE_ERROR; }else{ if( bOption ){ - rc = fts5ConfigParseSpecial(pGlobal, pRet, + rc = fts5ConfigParseSpecial(pRet, ALWAYS(zOne)?zOne:"", zTwo?zTwo:"", pzErr diff --git a/manifest b/manifest index 21fc713357..5ff1e3b94c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sa\sheuristic\sof\sartifically\slowering\sthe\scost\sof\sfact\stables\sin\sa\nstar-schema\squery\sin\sorder\sto\sprevent\splans\swhere\sthe\sfact\stables\sare\nin\souter\sloops\sfrom\sbeing\strimmed\sby\sthe\spath\slimiter.\s\sThis\shelps\sto\ngenerate\sbetter\s(faster)\squery\splans\sin\sthose\sparticular\scases. -D 2024-05-29T15:08:20.872 +C Remove\san\sunused\sparameter\sfrom\sfts5ConfigParseSpecial().\s\sCompiler-warning\nfix\sonly\s-\sno\sfunctional\schanges. +D 2024-05-29T15:16:17.746 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -96,7 +96,7 @@ F ext/fts5/fts5.h 8856e11a5f0269cd346754cea0765efe8089635b80cad3222e8bfdb08cd534 F ext/fts5/fts5Int.h 407ee36addad0ae6df5d37a811f0bd509ab6708b29640884ed5c7509e5f75143 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 74093394dc26750becc302922e5fe308a8597a70e6e83e66c892242952468163 +F ext/fts5/fts5_config.c 1ae512e7374caca6ab250055b3b29e46b007a27b098eafcc7ff4d13b06228cee F ext/fts5/fts5_expr.c 85789f6fb01995f2578b60a360057ed754335a890b1ab2e57e238b3670a9ae6c F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 @@ -2194,9 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b31933d87301bd93763f0923e0ce06a183700875e6107c9f185faffbd99797d9 5e64b541d175c10a5df67ef3419ecd74fcb51392af5f5458973cea85ee6a3246 -R a7284e1bb0965e7b34781f7fb4e63af1 -T +closed 5e64b541d175c10a5df67ef3419ecd74fcb51392af5f5458973cea85ee6a3246 +P 38db9b5c83dfb3021333365b2f6b11e3b54afd7033e9f4dadf0c0df1d4b082d8 +R 63a18f932f7717068d6dced4ac639265 U drh -Z 539ceed68c0106ac122fd205cce60827 +Z c0825dd43d1a5a8b45060034ee2bb433 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0234c23118..804506c8a1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38db9b5c83dfb3021333365b2f6b11e3b54afd7033e9f4dadf0c0df1d4b082d8 \ No newline at end of file +c08dd245f7706f2fd2269d700be480477619a722e27e6b439462ae543302c49f \ No newline at end of file From 5b7048d5af1ec22371bb1f57556548f9724903c3 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 30 May 2024 11:14:16 +0000 Subject: [PATCH 0450/1030] Update shell.c to use the msteve fork of linenoise, per /chat discussion. FossilOrigin-Name: ee92fa8366b743266b17c692499087c0d11b9302d096c3dfb4e6356b467e939e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 9 ++++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 5ff1e3b94c..b726f2bc02 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunused\sparameter\sfrom\sfts5ConfigParseSpecial().\s\sCompiler-warning\nfix\sonly\s-\sno\sfunctional\schanges. -D 2024-05-29T15:16:17.746 +C Update\sshell.c\sto\suse\sthe\smsteve\sfork\sof\slinenoise,\sper\s/chat\sdiscussion. +D 2024-05-30T11:14:16.476 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -756,7 +756,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c cbdaf9cb2d9a697ee9ce1484f27d2e96762d33cc19259aedfb818a68b9d3be10 -F src/shell.c.in cba809572972ff736aa6c3423ffb87015c740864206d97e168bb77316129015f +F src/shell.c.in a4d5957a853d6065549a1f2d8f46ded9940f72835e0328bbad292560f36b4d45 F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38db9b5c83dfb3021333365b2f6b11e3b54afd7033e9f4dadf0c0df1d4b082d8 -R 63a18f932f7717068d6dced4ac639265 -U drh -Z c0825dd43d1a5a8b45060034ee2bb433 +P c08dd245f7706f2fd2269d700be480477619a722e27e6b439462ae543302c49f +R 72c04f74ef51a04b1a629955fe9bd59f +U stephan +Z 89260005431ea7f0523c5c606191a398 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 804506c8a1..3471ecfb66 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c08dd245f7706f2fd2269d700be480477619a722e27e6b439462ae543302c49f \ No newline at end of file +ee92fa8366b743266b17c692499087c0d11b9302d096c3dfb4e6356b467e939e \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index b895fb0501..6773b2b4ee 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -5518,15 +5518,18 @@ static char **readline_completion(const char *zText, int iStart, int iEnd){ #elif HAVE_LINENOISE /* -** Linenoise completion callback +** Linenoise completion callback. Note that the 3rd argument is from +** the "msteveb" version of linenoise, not the "antirez" version. */ -static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){ +static void linenoise_completion(const char *zLine, linenoiseCompletions *lc, + void *pUserData){ i64 nLine = strlen(zLine); i64 i, iStart; sqlite3_stmt *pStmt = 0; char *zSql; char zBuf[1000]; + UNUSED_PARAMETER(pUserData); if( nLine>(i64)sizeof(zBuf)-30 ) return; if( zLine[0]=='.' || zLine[0]=='#') return; for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){} @@ -12799,7 +12802,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ #if HAVE_READLINE || HAVE_EDITLINE rl_attempted_completion_function = readline_completion; #elif HAVE_LINENOISE - linenoiseSetCompletionCallback(linenoise_completion); + linenoiseSetCompletionCallback(linenoise_completion, NULL); #endif data.in = 0; rc = process_input(&data); From 1344b540d92f65c7a981b2aaaf3982687f9f792f Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 30 May 2024 13:27:29 +0000 Subject: [PATCH 0451/1030] Ensure that the second pass call to wherePathSolver() always reports a positive value for the estimated number of output rows. This fixes a long-standing (though exceedingly minor) problem that was only revealed by a new assert() added yesterday. dbsqlfuzz 545d6debc2da496ab2b915e33ea34d9a35a935df FossilOrigin-Name: a47c644fef71f3ab3dc584ea917eaab9a8e5b4c9dcb57bdd29747ba32108e85f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b726f2bc02..60c84c3786 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sshell.c\sto\suse\sthe\smsteve\sfork\sof\slinenoise,\sper\s/chat\sdiscussion. -D 2024-05-30T11:14:16.476 +C Ensure\sthat\sthe\ssecond\spass\scall\sto\swherePathSolver()\salways\sreports\sa\spositive\nvalue\sfor\sthe\sestimated\snumber\sof\soutput\srows.\s\sThis\sfixes\sa\slong-standing\n(though\sexceedingly\sminor)\sproblem\sthat\swas\sonly\srevealed\sby\sa\snew\sassert()\nadded\syesterday.\s\sdbsqlfuzz\s545d6debc2da496ab2b915e33ea34d9a35a935df +D 2024-05-30T13:27:29.661 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c fee27468ac2d50e79c65fb31dcdfd0ed194a8cc20824bdca476df7b03b56d8cd +F src/where.c 5ddff7d4e0c0f7a2616efc126e4b8224387ce5fa4f5adf0737c8daa3e83824cf F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c08dd245f7706f2fd2269d700be480477619a722e27e6b439462ae543302c49f -R 72c04f74ef51a04b1a629955fe9bd59f -U stephan -Z 89260005431ea7f0523c5c606191a398 +P ee92fa8366b743266b17c692499087c0d11b9302d096c3dfb4e6356b467e939e +R 26b2d1af00d15dbbae9294d17198b2cc +U drh +Z 06aea7a30f870e0d4619820ebd6e3381 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3471ecfb66..4fecaa6a8e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ee92fa8366b743266b17c692499087c0d11b9302d096c3dfb4e6356b467e939e \ No newline at end of file +a47c644fef71f3ab3dc584ea917eaab9a8e5b4c9dcb57bdd29747ba32108e85f \ No newline at end of file diff --git a/src/where.c b/src/where.c index 6f7d469736..ed095fa3b0 100644 --- a/src/where.c +++ b/src/where.c @@ -6644,7 +6644,7 @@ WhereInfo *sqlite3WhereBegin( if( db->mallocFailed ) goto whereBeginError; if( pWInfo->pOrderBy ){ whereInterstageHeuristic(pWInfo); - wherePathSolver(pWInfo, pWInfo->nRowOut+1); + wherePathSolver(pWInfo, pWInfo->nRowOut<0 ? 1 : pWInfo->nRowOut+1); if( db->mallocFailed ) goto whereBeginError; } From 4c86b2db0fff39f8f2d00ecd39d9ebfeed97d758 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 30 May 2024 17:56:26 +0000 Subject: [PATCH 0452/1030] Remove the unconditional SQLITE_OMIT_WAL when building in wasi-sdk mode, per [forum:80003e91a7a6cb4d|requests in the forum]. FossilOrigin-Name: dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 60c84c3786..56c0d61be4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\ssecond\spass\scall\sto\swherePathSolver()\salways\sreports\sa\spositive\nvalue\sfor\sthe\sestimated\snumber\sof\soutput\srows.\s\sThis\sfixes\sa\slong-standing\n(though\sexceedingly\sminor)\sproblem\sthat\swas\sonly\srevealed\sby\sa\snew\sassert()\nadded\syesterday.\s\sdbsqlfuzz\s545d6debc2da496ab2b915e33ea34d9a35a935df -D 2024-05-30T13:27:29.661 +C Remove\sthe\sunconditional\sSQLITE_OMIT_WAL\swhen\sbuilding\sin\swasi-sdk\smode,\sper\s[forum:80003e91a7a6cb4d|requests\sin\sthe\sforum]. +D 2024-05-30T17:56:26.243 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -757,7 +757,7 @@ F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c cbdaf9cb2d9a697ee9ce1484f27d2e96762d33cc19259aedfb818a68b9d3be10 F src/shell.c.in a4d5957a853d6065549a1f2d8f46ded9940f72835e0328bbad292560f36b4d45 -F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 +F src/sqlite.h.in cbd3e4177791a61c056fd81e37a5b21bb6c8cb2ea8cac558c625974673f50acf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 98ba756789b37f8d8217407ce077c31faf0b9b21d593b327c2b9667ad5bea1ac @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ee92fa8366b743266b17c692499087c0d11b9302d096c3dfb4e6356b467e939e -R 26b2d1af00d15dbbae9294d17198b2cc -U drh -Z 06aea7a30f870e0d4619820ebd6e3381 +P a47c644fef71f3ab3dc584ea917eaab9a8e5b4c9dcb57bdd29747ba32108e85f +R dbf8da7df3d6710109e3f50f2572dd2b +U stephan +Z d943edf9ee101c09eebc6bdb1635bbc9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4fecaa6a8e..33a986d625 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a47c644fef71f3ab3dc584ea917eaab9a8e5b4c9dcb57bdd29747ba32108e85f \ No newline at end of file +dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ae82088423..8cca648367 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -10832,8 +10832,6 @@ int sqlite3_deserialize( #if defined(__wasi__) # undef SQLITE_WASI # define SQLITE_WASI 1 -# undef SQLITE_OMIT_WAL -# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */ # ifndef SQLITE_OMIT_LOAD_EXTENSION # define SQLITE_OMIT_LOAD_EXTENSION # endif From 2f755cdc3ac105837b9cd0aecf35275b83c56b07 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 30 May 2024 21:54:16 +0000 Subject: [PATCH 0453/1030] Back out [dcc2bb2c562e97e090174], as it breaks the --with-wasi-sdk builds. FossilOrigin-Name: 62199562c26f77d059aa0bbda42a421a7aece828aa94d14a40c701a6384d1cf6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 56c0d61be4..f722e3deb9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sunconditional\sSQLITE_OMIT_WAL\swhen\sbuilding\sin\swasi-sdk\smode,\sper\s[forum:80003e91a7a6cb4d|requests\sin\sthe\sforum]. -D 2024-05-30T17:56:26.243 +C Back\sout\s[dcc2bb2c562e97e090174],\sas\sit\sbreaks\sthe\s--with-wasi-sdk\sbuilds. +D 2024-05-30T21:54:16.706 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -757,7 +757,7 @@ F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c cbdaf9cb2d9a697ee9ce1484f27d2e96762d33cc19259aedfb818a68b9d3be10 F src/shell.c.in a4d5957a853d6065549a1f2d8f46ded9940f72835e0328bbad292560f36b4d45 -F src/sqlite.h.in cbd3e4177791a61c056fd81e37a5b21bb6c8cb2ea8cac558c625974673f50acf +F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 98ba756789b37f8d8217407ce077c31faf0b9b21d593b327c2b9667ad5bea1ac @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a47c644fef71f3ab3dc584ea917eaab9a8e5b4c9dcb57bdd29747ba32108e85f -R dbf8da7df3d6710109e3f50f2572dd2b +P dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 +R 26b2d1af00d15dbbae9294d17198b2cc U stephan -Z d943edf9ee101c09eebc6bdb1635bbc9 +Z 5e10d8a42e727262c6d109f98d1a95c0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 33a986d625..bcca3c37fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 \ No newline at end of file +62199562c26f77d059aa0bbda42a421a7aece828aa94d14a40c701a6384d1cf6 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8cca648367..ae82088423 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -10832,6 +10832,8 @@ int sqlite3_deserialize( #if defined(__wasi__) # undef SQLITE_WASI # define SQLITE_WASI 1 +# undef SQLITE_OMIT_WAL +# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */ # ifndef SQLITE_OMIT_LOAD_EXTENSION # define SQLITE_OMIT_LOAD_EXTENSION # endif From d72ca8f810a0159d87cc16321a8d974373eceab3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 31 May 2024 14:39:42 +0000 Subject: [PATCH 0454/1030] Document the OP_Explain opcode. Add the WhereLoop.rRun value as P3 in OP_Explain opcodes associated with WhereLoops, for testing purposes. FossilOrigin-Name: 996c46e61d9a53a54018672dd407b8ba8c480dd6795393428f9d5fcb81b47ab5 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/vdbe.c | 29 ++++++++++++++++++++++------- src/where.c | 2 +- src/wherecode.c | 3 ++- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index f722e3deb9..c7aef4ab52 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\s[dcc2bb2c562e97e090174],\sas\sit\sbreaks\sthe\s--with-wasi-sdk\sbuilds. -D 2024-05-30T21:54:16.706 +C Document\sthe\sOP_Explain\sopcode.\s\sAdd\sthe\sWhereLoop.rRun\svalue\sas\sP3\sin\nOP_Explain\sopcodes\sassociated\swith\sWhereLoops,\sfor\stesting\spurposes. +D 2024-05-31T14:39:42.881 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -825,7 +825,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 2448b34ff095efa5a8d9dd525c4c0842ef7226e44b68fe8df1053ee9894aa5fd +F src/vdbe.c b05777c3ff2ed7b9dfc347e7cdee18e371aa6811cef1fe83454691b0dbe2cc9f F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -840,9 +840,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 5ddff7d4e0c0f7a2616efc126e4b8224387ce5fa4f5adf0737c8daa3e83824cf +F src/where.c 301bedd98cf76463fd57081881607943442bfbba213a58240f7981dec5a160cf F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 -F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 +F src/wherecode.c 5ad509221ebb4d3b35a8a6ef361f2c5b54129b8c273aa434dd3053d2e25d1794 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 -R 26b2d1af00d15dbbae9294d17198b2cc -U stephan -Z 5e10d8a42e727262c6d109f98d1a95c0 +P 62199562c26f77d059aa0bbda42a421a7aece828aa94d14a40c701a6384d1cf6 +R 85967a315d01ec0513367341097e62e2 +U drh +Z b127a4b9aa205bcbd712a7eda1be0138 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bcca3c37fe..5d06e47e84 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -62199562c26f77d059aa0bbda42a421a7aece828aa94d14a40c701a6384d1cf6 \ No newline at end of file +996c46e61d9a53a54018672dd407b8ba8c480dd6795393428f9d5fcb81b47ab5 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 6bfcb0ee19..28f12e0542 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -9015,14 +9015,29 @@ case OP_ReleaseReg: { /* Opcode: Noop * * * * * ** -** Do nothing. This instruction is often useful as a jump -** destination. +** Do nothing. Continue downward to the next opcode. */ -/* -** The magic Explain opcode are only inserted when explain==2 (which -** is to say when the EXPLAIN QUERY PLAN syntax is used.) -** This opcode records information from the optimizer. It is the -** the same as a no-op. This opcodesnever appears in a real VM program. +/* Opcode: Explain P1 P2 P3 P4 * +** +** This is the same as OP_Noop during normal query execution. The +** purpose of this opcode is to hold information about the query +** plan for the purpose of EXPLAIN QUERY PLAN output. +** +** The P4 value is human-readable text that describes the query plan +** element. Something like "SCAN t1" or "SEARCH t2 USING INDEX t2x1". +** +** The P1 value is the ID of the current element and P2 is the parent +** element for the case of nested query plan elements. If P2 is zero +** then this element is a top-level element. +** +** For loop elements, P3 is the estimated code of each invocation of this +** element. +** +** As with all opcodes, the meanings of the parameters for OP_Explain +** are subject to change from one release to the next. Applications +** should not attempt to interpret or use any of the information +** contined in the OP_Explain opcode. The information provided by this +** opcode is intended for testing and debugging use only. */ default: { /* This is really OP_Noop, OP_Explain */ assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain ); diff --git a/src/where.c b/src/where.c index ed095fa3b0..64bda2327f 100644 --- a/src/where.c +++ b/src/where.c @@ -5262,7 +5262,7 @@ static LogEst whereSortingCost( ** smaller tables. The central table is called the "fact" table. ** The smaller tables that get joined are "dimension tables". ** -** SIDE EFFECT: +** SIDE EFFECT: (and really the whole point of this subroutine) ** ** If pWInfo describes a star-query, then the cost on WhereLoops for the ** fact table is reduced. This heuristic helps keep fact tables in diff --git a/src/wherecode.c b/src/wherecode.c index 30624be8a2..80fbbfac4c 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -218,7 +218,8 @@ int sqlite3WhereExplainOneScan( zMsg = sqlite3StrAccumFinish(&str); sqlite3ExplainBreakpoint("",zMsg); ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v), - pParse->addrExplain, 0, zMsg,P4_DYNAMIC); + pParse->addrExplain, pLoop->rRun, + zMsg, P4_DYNAMIC); } return ret; } From 5ef9c899770b764a2760f3b35571c3ec8bba5e95 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 31 May 2024 15:39:00 +0000 Subject: [PATCH 0455/1030] Do not even try star-schema detection if the join has fewer than 5 tables, since 5 is the minimum for a positive detection. FossilOrigin-Name: a07ec16bbc056fbc23a7bd58e5e32ef691c13e9babeb542918cf9a01cac40c20 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c7aef4ab52..8a3110d657 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Document\sthe\sOP_Explain\sopcode.\s\sAdd\sthe\sWhereLoop.rRun\svalue\sas\sP3\sin\nOP_Explain\sopcodes\sassociated\swith\sWhereLoops,\sfor\stesting\spurposes. -D 2024-05-31T14:39:42.881 +C Do\snot\seven\stry\sstar-schema\sdetection\sif\sthe\sjoin\shas\sfewer\sthan\s5\stables,\nsince\s5\sis\sthe\sminimum\sfor\sa\spositive\sdetection. +D 2024-05-31T15:39:00.555 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 301bedd98cf76463fd57081881607943442bfbba213a58240f7981dec5a160cf +F src/where.c 593d28d3776985733da0f09639100003b444a43db7b6f9a35139f544fdbea358 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c 5ad509221ebb4d3b35a8a6ef361f2c5b54129b8c273aa434dd3053d2e25d1794 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 62199562c26f77d059aa0bbda42a421a7aece828aa94d14a40c701a6384d1cf6 -R 85967a315d01ec0513367341097e62e2 +P 996c46e61d9a53a54018672dd407b8ba8c480dd6795393428f9d5fcb81b47ab5 +R a2ca0792af2e5fd1149a2be149730242 U drh -Z b127a4b9aa205bcbd712a7eda1be0138 +Z dd2c4dbd585f8635955a8cbd6ced885b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5d06e47e84..2b915c652e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -996c46e61d9a53a54018672dd407b8ba8c480dd6795393428f9d5fcb81b47ab5 \ No newline at end of file +a07ec16bbc056fbc23a7bd58e5e32ef691c13e9babeb542918cf9a01cac40c20 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 64bda2327f..2418b41560 100644 --- a/src/where.c +++ b/src/where.c @@ -5274,7 +5274,7 @@ static LogEst whereSortingCost( */ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ int nLoop = pWInfo->nLevel; /* Number of terms in the join */ - if( nRowEst==0 && nLoop>=4 ){ + if( nRowEst==0 && nLoop>=5 ){ /* Check to see if we are dealing with a star schema and if so, reduce ** the cost of fact tables relative to dimension tables, as a heuristic ** to help keep the fact tables in outer loops. From cadfdd4e096f595f7eb6b5acacfbd5ba5cb946ad Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 31 May 2024 19:26:22 +0000 Subject: [PATCH 0456/1030] Better handle WHERE terms that are common to two or more OR branches when planning virtual table queries. FossilOrigin-Name: 4edd9b29f58621335b8a562280c991c34804bbba090f90c951261d043cff1965 --- manifest | 21 +++--- manifest.uuid | 2 +- src/test_bestindex.c | 4 ++ src/where.c | 154 ++++++++++++++++++++++++------------------- test/bestindexC.test | 75 +++++++++++++++++++++ 5 files changed, 179 insertions(+), 77 deletions(-) diff --git a/manifest b/manifest index 56c0d61be4..50e722946a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sunconditional\sSQLITE_OMIT_WAL\swhen\sbuilding\sin\swasi-sdk\smode,\sper\s[forum:80003e91a7a6cb4d|requests\sin\sthe\sforum]. -D 2024-05-30T17:56:26.243 +C Better\shandle\sWHERE\sterms\sthat\sare\scommon\sto\stwo\sor\smore\sOR\sbranches\swhen\splanning\svirtual\stable\squeries. +D 2024-05-31T19:26:22.693 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -776,7 +776,7 @@ F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a F src/test_autoext.c 915d245e736652a219a907909bb6710f0d587871 F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 -F src/test_bestindex.c 770429c434221afe6216ec81fe4c00ad3bbdad1d5e64576aa613ffb7c5a984f0 +F src/test_bestindex.c e8ae36817864ca80bd4608d109634cbc35cca099234313ff9f3c061a22783bd8 F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 F src/test_config.c 5fa77ee6064ba546e144c4fea870c5ede2c54314616f81485c6a9c4192100c75 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 5ddff7d4e0c0f7a2616efc126e4b8224387ce5fa4f5adf0737c8daa3e83824cf +F src/where.c ddffcd89b1b794a3d7ce56ac31315ae7a5625313046f6aff3942a682b3fa0d48 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -940,7 +940,7 @@ F test/bestindex8.test b63a4f171a2c83d481bb14c431a8b72e85d27b2ffdaa0435a95d58ca9 F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede39673a451a0 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce -F test/bestindexC.test 9e6f184be080fd9c4605a7e5c7097eed1a259372f9af78151c37b072a9086f86 +F test/bestindexC.test ae34a3ceb64b117cd20aba71ea8e9fadd639b021cf232e15a57fe2eefe1f29ea F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -2194,8 +2194,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a47c644fef71f3ab3dc584ea917eaab9a8e5b4c9dcb57bdd29747ba32108e85f -R dbf8da7df3d6710109e3f50f2572dd2b -U stephan -Z d943edf9ee101c09eebc6bdb1635bbc9 +P dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 +R 586dbe3b8a77baf191835ccb84865021 +T *branch * xbestindex-or-terms +T *sym-xbestindex-or-terms * +T -sym-trunk * +U dan +Z cae40e4fc9a5b7b19f7dc2f2cabe22f0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 33a986d625..4309f282d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 \ No newline at end of file +4edd9b29f58621335b8a562280c991c34804bbba090f90c951261d043cff1965 \ No newline at end of file diff --git a/src/test_bestindex.c b/src/test_bestindex.c index 0e1e86a81c..072bff2e74 100644 --- a/src/test_bestindex.c +++ b/src/test_bestindex.c @@ -700,6 +700,10 @@ static int tclBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ pIdxInfo->aConstraintUsage[iCons].omit = bOmit; } } + }else + if( sqlite3_stricmp("constraint", zCmd)==0 ){ + rc = SQLITE_CONSTRAINT; + pTab->base.zErrMsg = sqlite3_mprintf("%s", Tcl_GetString(p)); }else{ rc = SQLITE_ERROR; pTab->base.zErrMsg = sqlite3_mprintf("unexpected: %s", zCmd); diff --git a/src/where.c b/src/where.c index ed095fa3b0..53be42888a 100644 --- a/src/where.c +++ b/src/where.c @@ -1346,6 +1346,20 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter( #ifndef SQLITE_OMIT_VIRTUALTABLE +/* +** Return term iTerm of the WhereClause passed as the first argument. Terms +** are numbered from 0 upwards, starting with the terms in pWC->a[], then +** those in pWC->pOuter->a[] (if any), and so on. +*/ +static WhereTerm *termFromWhereClause(WhereClause *pWC, int iTerm){ + WhereClause *p; + for(p=pWC; p; p=p->pOuter){ + if( iTermnTerm ) return &p->a[iTerm]; + iTerm -= p->nTerm; + } + return 0; +} + /* ** Allocate and populate an sqlite3_index_info structure. It is the ** responsibility of the caller to eventually release the structure @@ -1372,6 +1386,7 @@ static sqlite3_index_info *allocateIndexInfo( const Table *pTab; int eDistinct = 0; ExprList *pOrderBy = pWInfo->pOrderBy; + WhereClause *p; assert( pSrc!=0 ); pTab = pSrc->pTab; @@ -1382,28 +1397,30 @@ static sqlite3_index_info *allocateIndexInfo( ** Mark each term with the TERM_OK flag. Set nTerm to the number of ** terms found. */ - for(i=nTerm=0, pTerm=pWC->a; inTerm; i++, pTerm++){ - pTerm->wtFlags &= ~TERM_OK; - if( pTerm->leftCursor != pSrc->iCursor ) continue; - if( pTerm->prereqRight & mUnusable ) continue; - assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) ); - testcase( pTerm->eOperator & WO_IN ); - testcase( pTerm->eOperator & WO_ISNULL ); - testcase( pTerm->eOperator & WO_IS ); - testcase( pTerm->eOperator & WO_ALL ); - if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; - if( pTerm->wtFlags & TERM_VNULL ) continue; + for(p=pWC, nTerm=0; p; p=p->pOuter){ + for(i=0, pTerm=p->a; inTerm; i++, pTerm++){ + pTerm->wtFlags &= ~TERM_OK; + if( pTerm->leftCursor != pSrc->iCursor ) continue; + if( pTerm->prereqRight & mUnusable ) continue; + assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) ); + testcase( pTerm->eOperator & WO_IN ); + testcase( pTerm->eOperator & WO_ISNULL ); + testcase( pTerm->eOperator & WO_IS ); + testcase( pTerm->eOperator & WO_ALL ); + if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; + if( pTerm->wtFlags & TERM_VNULL ) continue; - assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); - assert( pTerm->u.x.leftColumn>=XN_ROWID ); - assert( pTerm->u.x.leftColumnnCol ); - if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 - && !constraintCompatibleWithOuterJoin(pTerm,pSrc) - ){ - continue; + assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); + assert( pTerm->u.x.leftColumn>=XN_ROWID ); + assert( pTerm->u.x.leftColumnnCol ); + if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 + && !constraintCompatibleWithOuterJoin(pTerm,pSrc) + ){ + continue; + } + nTerm++; + pTerm->wtFlags |= TERM_OK; } - nTerm++; - pTerm->wtFlags |= TERM_OK; } /* If the ORDER BY clause contains only columns in the current @@ -1482,49 +1499,52 @@ static sqlite3_index_info *allocateIndexInfo( pHidden->pParse = pParse; pHidden->eDistinct = eDistinct; pHidden->mIn = 0; - for(i=j=0, pTerm=pWC->a; inTerm; i++, pTerm++){ - u16 op; - if( (pTerm->wtFlags & TERM_OK)==0 ) continue; - pIdxCons[j].iColumn = pTerm->u.x.leftColumn; - pIdxCons[j].iTermOffset = i; - op = pTerm->eOperator & WO_ALL; - if( op==WO_IN ){ - if( (pTerm->wtFlags & TERM_SLICE)==0 ){ - pHidden->mIn |= SMASKBIT32(j); + for(p=pWC, i=j=0; p; p=p->pOuter){ + int nLast = i+p->nTerm;; + for(pTerm=p->a; iwtFlags & TERM_OK)==0 ) continue; + pIdxCons[j].iColumn = pTerm->u.x.leftColumn; + pIdxCons[j].iTermOffset = i; + op = pTerm->eOperator & WO_ALL; + if( op==WO_IN ){ + if( (pTerm->wtFlags & TERM_SLICE)==0 ){ + pHidden->mIn |= SMASKBIT32(j); + } + op = WO_EQ; } - op = WO_EQ; - } - if( op==WO_AUX ){ - pIdxCons[j].op = pTerm->eMatchOp; - }else if( op & (WO_ISNULL|WO_IS) ){ - if( op==WO_ISNULL ){ - pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_ISNULL; + if( op==WO_AUX ){ + pIdxCons[j].op = pTerm->eMatchOp; + }else if( op & (WO_ISNULL|WO_IS) ){ + if( op==WO_ISNULL ){ + pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_ISNULL; + }else{ + pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_IS; + } }else{ - pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_IS; - } - }else{ - pIdxCons[j].op = (u8)op; - /* The direct assignment in the previous line is possible only because - ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The - ** following asserts verify this fact. */ - assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ ); - assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT ); - assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE ); - assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT ); - assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE ); - assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) ); - - if( op & (WO_LT|WO_LE|WO_GT|WO_GE) - && sqlite3ExprIsVector(pTerm->pExpr->pRight) - ){ - testcase( j!=i ); - if( j<16 ) mNoOmit |= (1 << j); - if( op==WO_LT ) pIdxCons[j].op = WO_LE; - if( op==WO_GT ) pIdxCons[j].op = WO_GE; + pIdxCons[j].op = (u8)op; + /* The direct assignment in the previous line is possible only because + ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The + ** following asserts verify this fact. */ + assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ ); + assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT ); + assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE ); + assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT ); + assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE ); + assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) ); + + if( op & (WO_LT|WO_LE|WO_GT|WO_GE) + && sqlite3ExprIsVector(pTerm->pExpr->pRight) + ){ + testcase( j!=i ); + if( j<16 ) mNoOmit |= (1 << j); + if( op==WO_LT ) pIdxCons[j].op = WO_LE; + if( op==WO_GT ) pIdxCons[j].op = WO_GE; + } } - } - j++; + j++; + } } assert( j==nTerm ); pIdxInfo->nConstraint = j; @@ -4159,7 +4179,7 @@ static int whereLoopAddVirtualOne( ** arguments mUsable and mExclude. */ pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint; for(i=0; ia[pIdxCons->iTermOffset]; + WhereTerm *pTerm = termFromWhereClause(pWC, pIdxCons->iTermOffset); pIdxCons->usable = 0; if( (pTerm->prereqRight & mUsable)==pTerm->prereqRight && (pTerm->eOperator & mExclude)==0 @@ -4207,7 +4227,7 @@ static int whereLoopAddVirtualOne( int j = pIdxCons->iTermOffset; if( iTerm>=nConstraint || j<0 - || j>=pWC->nTerm + || (pTerm = termFromWhereClause(pWC, j))==0 || pNew->aLTerm[iTerm]!=0 || pIdxCons->usable==0 ){ @@ -4218,7 +4238,6 @@ static int whereLoopAddVirtualOne( testcase( iTerm==nConstraint-1 ); testcase( j==0 ); testcase( j==pWC->nTerm-1 ); - pTerm = &pWC->a[j]; pNew->prereq |= pTerm->prereqRight; assert( iTermnLSlot ); pNew->aLTerm[iTerm] = pTerm; @@ -4335,7 +4354,7 @@ const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int iCons){ if( iCons>=0 && iConsnConstraint ){ CollSeq *pC = 0; int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset; - Expr *pX = pHidden->pWC->a[iTerm].pExpr; + Expr *pX = termFromWhereClause(pHidden->pWC, iTerm)->pExpr; if( pX->pLeft ){ pC = sqlite3ExprCompareCollSeq(pHidden->pParse, pX); } @@ -4381,7 +4400,9 @@ int sqlite3_vtab_rhs_value( rc = SQLITE_MISUSE_BKPT; /* EV: R-30545-25046 */ }else{ if( pH->aRhs[iCons]==0 ){ - WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; + WhereTerm *pTerm = termFromWhereClause( + pH->pWC, pIdxInfo->aConstraint[iCons].iTermOffset + ); rc = sqlite3ValueFromExpr( pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db), SQLITE_AFF_BLOB, &pH->aRhs[iCons] @@ -4537,9 +4558,8 @@ static int whereLoopAddVirtual( Bitmask mNext = ALLBITS; assert( mNext>0 ); for(i=0; ia[p->aConstraint[i].iTermOffset].prereqRight & ~mPrereq - ); + int iTerm = p->aConstraint[i].iTermOffset; + Bitmask mThis = termFromWhereClause(pWC, iTerm)->prereqRight & ~mPrereq; if( mThis>mPrev && mThis0} { + set missing [list] + for {set i 0} {$i < 3} {incr i} { + catch { lappend missing $cols($i) } + } + set msg "missing required constraints: [join $missing ,]" + return [list constraint $msg] + } + + return "cost 1000 rows 1000 idxnum $idxnum $res" + } + + xFilter { + return [list sql "SELECT 1, '', '', '' WHERE 0"] + } + } + + return {} +} + +do_execsql_test 5.1 { + CREATE VIRTUAL TABLE x1 USING tcl(vtab_command t1); +} + +foreach {tn where ok} { + 1 "WHERE a=? AND b=? AND c=?" 1 + 2 "WHERE a=? AND b=? AND (c=? OR c=?)" 1 + 3 "WHERE a=? AND b=? AND (c=? OR c=? OR c=?)" 1 + 4 "WHERE a=? AND b=? AND (c IS ? OR c IS ?)" 1 + 5 "WHERE a=? AND ((b=? AND c=?) OR (c=? AND b=?))" 1 + 6 "WHERE a=? AND ((b=? AND c=?) OR (c=?))" 0 +} { + do_test 5.2.$tn { + catch { execsql "SELECT * FROM x1 $::where" } + } [expr !$ok] +} + + finish_test From af354324005140bb1d002816d6035fbdcba9fdf7 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 31 May 2024 20:32:10 +0000 Subject: [PATCH 0457/1030] Further tests for OR constraints on virtual tables. FossilOrigin-Name: ff4a30056f8dbcbd045afdbee485f6671c3580b95187144aa9a77c97dfda2647 --- manifest | 17 ++++------ manifest.uuid | 2 +- src/test_bestindex.c | 20 +++++++++--- test/bestindexC.test | 78 ++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 94 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 50e722946a..dc8a120397 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Better\shandle\sWHERE\sterms\sthat\sare\scommon\sto\stwo\sor\smore\sOR\sbranches\swhen\splanning\svirtual\stable\squeries. -D 2024-05-31T19:26:22.693 +C Further\stests\sfor\sOR\sconstraints\son\svirtual\stables. +D 2024-05-31T20:32:10.798 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -776,7 +776,7 @@ F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a F src/test_autoext.c 915d245e736652a219a907909bb6710f0d587871 F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 -F src/test_bestindex.c e8ae36817864ca80bd4608d109634cbc35cca099234313ff9f3c061a22783bd8 +F src/test_bestindex.c 1b5a1407b66c5caa67cfe1d93d96de5ec5d9d516bc69eb512482f85c037858c3 F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 F src/test_config.c 5fa77ee6064ba546e144c4fea870c5ede2c54314616f81485c6a9c4192100c75 @@ -940,7 +940,7 @@ F test/bestindex8.test b63a4f171a2c83d481bb14c431a8b72e85d27b2ffdaa0435a95d58ca9 F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede39673a451a0 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce -F test/bestindexC.test ae34a3ceb64b117cd20aba71ea8e9fadd639b021cf232e15a57fe2eefe1f29ea +F test/bestindexC.test 2df6ada16d8f00d9bb6a9664d9c323560aeed0e0ebc7a32b99d85d70037fd250 F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -2194,11 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 -R 586dbe3b8a77baf191835ccb84865021 -T *branch * xbestindex-or-terms -T *sym-xbestindex-or-terms * -T -sym-trunk * +P 4edd9b29f58621335b8a562280c991c34804bbba090f90c951261d043cff1965 +R 7e0b53e0bf1f5f31582edfc766b004d3 U dan -Z cae40e4fc9a5b7b19f7dc2f2cabe22f0 +Z 60bf1853e2bb5029309100d75a83bcc9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4309f282d1..4b2b009f72 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4edd9b29f58621335b8a562280c991c34804bbba090f90c951261d043cff1965 \ No newline at end of file +ff4a30056f8dbcbd045afdbee485f6671c3580b95187144aa9a77c97dfda2647 \ No newline at end of file diff --git a/src/test_bestindex.c b/src/test_bestindex.c index 072bff2e74..c89cab2e39 100644 --- a/src/test_bestindex.c +++ b/src/test_bestindex.c @@ -305,11 +305,9 @@ static int tclFilter( Tcl_IncrRefCount(pScript); Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj("xFilter", -1)); Tcl_ListObjAppendElement(interp, pScript, Tcl_NewIntObj(idxNum)); - if( idxStr ){ - Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(idxStr, -1)); - }else{ - Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj("", -1)); - } + Tcl_ListObjAppendElement( + interp, pScript, Tcl_NewStringObj(idxStr ? idxStr : "", -1) + ); pArg = Tcl_NewObj(); Tcl_IncrRefCount(pArg); @@ -530,6 +528,7 @@ static int SQLITE_TCLAPI testBestIndexObj( "distinct", /* 3 */ "in", /* 4 */ "rhs_value", /* 5 */ + "collation", /* 6 */ 0 }; int ii; @@ -610,6 +609,17 @@ static int SQLITE_TCLAPI testBestIndexObj( Tcl_SetObjResult(interp, Tcl_NewStringObj(zVal, -1)); break; } + + case 6: assert( sqlite3_stricmp(azSub[ii], "collation")==0 ); { + int iCons = 0; + const char *zColl = ""; + if( Tcl_GetIntFromObj(interp, objv[2], &iCons) ){ + return TCL_ERROR; + } + zColl = sqlite3_vtab_collation(pIdxInfo, iCons); + Tcl_SetObjResult(interp, Tcl_NewStringObj(zColl, -1)); + break; + } } return TCL_OK; diff --git a/test/bestindexC.test b/test/bestindexC.test index a6f420cc2c..48f3a27655 100644 --- a/test/bestindexC.test +++ b/test/bestindexC.test @@ -214,6 +214,10 @@ do_catchsql_test 4.4 { reset_db register_tcl_module db +proc quote {str} { + return "'[string map {' ''} $str]'" +} + proc vtab_command {lVal method args} { switch -- $method { xConnect { @@ -232,16 +236,19 @@ proc vtab_command {lVal method args} { set cols(1) b set cols(2) c - #puts "xBestIndex: $clist" + set lCons [list] foreach c $clist { array set a $c if {$a(usable)==0} continue - if {$a(op)=="eq" || $a(op)=="is"} { - lappend res use $idx - catch { unset cols($a(column)) } + if {($a(op)=="eq" || $a(op)=="is") && [info exists cols($a(column))]} { + lappend res omit $idx + set coll [$hdl collation $idx] + lappend lCons "$cols($a(column)) = %[llength $lCons]% COLLATE $coll" + set idxnum [expr {$idx + (1 << $a(column))}] + catch { unset cols($a(column)) } } incr idx @@ -256,11 +263,20 @@ proc vtab_command {lVal method args} { return [list constraint $msg] } - return "cost 1000 rows 1000 idxnum $idxnum $res" + set idxstr [join $lCons " AND "] + return "cost 1000 rows 1000 idxnum $idxnum $res idxstr {$idxstr}" } xFilter { - return [list sql "SELECT 1, '', '', '' WHERE 0"] + foreach {idxnum idxstr lArg} $args {} + set i 0 + set where $idxstr + foreach a $lArg { + set where [string map [list %$i% [quote $a]] $where] + incr i + } + # puts $where + return [list sql "SELECT rowid, * FROM $lVal WHERE $where"] } } @@ -269,9 +285,11 @@ proc vtab_command {lVal method args} { do_execsql_test 5.1 { CREATE VIRTUAL TABLE x1 USING tcl(vtab_command t1); + CREATE TABLE t1(a, b, c, d); } foreach {tn where ok} { + 0 "WHERE a=? AND b=? AND c=? AND c=?" 1 1 "WHERE a=? AND b=? AND c=?" 1 2 "WHERE a=? AND b=? AND (c=? OR c=?)" 1 3 "WHERE a=? AND b=? AND (c=? OR c=? OR c=?)" 1 @@ -280,9 +298,55 @@ foreach {tn where ok} { 6 "WHERE a=? AND ((b=? AND c=?) OR (c=?))" 0 } { do_test 5.2.$tn { - catch { execsql "SELECT * FROM x1 $::where" } + catch { execsql "SELECT * FROM x1 $::where" } msg +# if {$tn==0 || $tn==2 || $tn==3} { puts "MSG: $msg" } } [expr !$ok] } +do_execsql_test 5.3 { + SELECT * FROM x1 WHERE (a, b, c) = (?, ?, ?); +} + +do_execsql_test 5.4 { + INSERT INTO t1(rowid, a, b, c, d) VALUES(1, 'x', 'y', 'z', 'one'); + INSERT INTO t1(rowid, a, b, c, d) VALUES(2, 'X', 'Y', 'Z', 'two'); + SELECT * FROM x1 WHERE (a, b, c) = ('X', 'Y', 'Z'); +} {X Y Z two} +do_execsql_test 5.5 { + SELECT * FROM x1 WHERE a='x' AND b='y' AND c='z'; +} {x y z one} +do_execsql_test 5.6 { + SELECT * FROM x1 + WHERE a='x' COLLATE nocase AND b='y' COLLATE nocase AND c='z'COLLATE nocase; +} {x y z one X Y Z two} + +do_execsql_test 5.7 { + DELETE FROM t1; + + INSERT INTO t1(rowid, a, b, c, d) VALUES(0, 'x', 'y', 'z', 'zero'); + INSERT INTO t1(rowid, a, b, c, d) VALUES(1, 'x', 'y', 'Z', 'one'); + INSERT INTO t1(rowid, a, b, c, d) VALUES(2, 'x', 'Y', 'z', 'two'); + INSERT INTO t1(rowid, a, b, c, d) VALUES(3, 'x', 'Y', 'Z', 'three'); + INSERT INTO t1(rowid, a, b, c, d) VALUES(4, 'X', 'y', 'z', 'four'); + INSERT INTO t1(rowid, a, b, c, d) VALUES(5, 'X', 'y', 'Z', 'five'); + INSERT INTO t1(rowid, a, b, c, d) VALUES(6, 'X', 'Y', 'z', 'six'); + INSERT INTO t1(rowid, a, b, c, d) VALUES(7, 'X', 'Y', 'z', 'seven'); +} + +do_execsql_test 5.8 { + SELECT d FROM x1 + WHERE a='x' AND ((b='y' AND c='z') OR (b='Y' AND c='z' COLLATE nocase)) +} { + zero two three +} + +do_execsql_test 5.9 { + SELECT d FROM x1 + WHERE a='x' COLLATE nocase + AND ((b='y' AND c='z') OR (b='Y' AND c='z' COLLATE nocase)) +} { + zero four two + three six seven +} finish_test From 9c3eef8c0d18a32cc82a70a366f5dc77987749cc Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 1 Jun 2024 17:56:58 +0000 Subject: [PATCH 0458/1030] Have fts5.xBestIndex return SQLITE_CONSTRAINT, instead of a large cost, when no usable plan can be found. FossilOrigin-Name: 7c470945372dc98610f7c9840ce8cab18c19b655352f0187e4f31040cea77363 --- ext/fts5/fts5_main.c | 34 +++++++++++++++++----------------- ext/fts5/test/fts5colset.test | 2 +- ext/fts5/test/fts5misc.test | 31 +++++++++++++++++++++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 58 insertions(+), 27 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index eca6db5728..0a272cccaa 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -533,10 +533,10 @@ static int fts5UsePatternMatch( ** This function ensures that there is at most one "r" or "=". And that if ** there exists an "=" then there is no "<" or ">". ** -** Costs are assigned as follows: +** If an unusable MATCH operator is present in the WHERE clause, then +** SQLITE_CONSTRAINT is returned. ** -** a) If an unusable MATCH operator is present in the WHERE clause, the -** cost is unconditionally set to 1e50 (a really big number). +** Costs are assigned as follows: ** ** a) If a MATCH operator is present, the cost depends on the other ** constraints also present. As follows: @@ -569,7 +569,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ int bSeenEq = 0; int bSeenGt = 0; int bSeenLt = 0; - int bSeenMatch = 0; + int nSeenMatch = 0; int bSeenRank = 0; @@ -600,18 +600,15 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ /* A MATCH operator or equivalent */ if( p->usable==0 || iCol<0 ){ /* As there exists an unusable MATCH constraint this is an - ** unusable plan. Set a prohibitively high cost. */ - pInfo->estimatedCost = 1e50; - assert( iIdxStr < pInfo->nConstraint*6 + 1 ); - idxStr[iIdxStr] = 0; - return SQLITE_OK; + ** unusable plan. Return SQLITE_CONSTRAINT. */ + return SQLITE_CONSTRAINT; }else{ if( iCol==nCol+1 ){ if( bSeenRank ) continue; idxStr[iIdxStr++] = 'r'; bSeenRank = 1; }else if( iCol>=0 ){ - bSeenMatch = 1; + nSeenMatch++; idxStr[iIdxStr++] = 'M'; sqlite3_snprintf(6, &idxStr[iIdxStr], "%d", iCol); idxStr += strlen(&idxStr[iIdxStr]); @@ -628,7 +625,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ idxStr += strlen(&idxStr[iIdxStr]); pInfo->aConstraintUsage[i].argvIndex = ++iCons; assert( idxStr[iIdxStr]=='\0' ); - bSeenMatch = 1; + nSeenMatch++; }else if( bSeenEq==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol<0 ){ idxStr[iIdxStr++] = '='; bSeenEq = 1; @@ -665,7 +662,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ */ if( pInfo->nOrderBy==1 ){ int iSort = pInfo->aOrderBy[0].iColumn; - if( iSort==(pConfig->nCol+1) && bSeenMatch ){ + if( iSort==(pConfig->nCol+1) && nSeenMatch>0 ){ idxFlags |= FTS5_BI_ORDER_RANK; }else if( iSort==-1 && (!pInfo->aOrderBy[0].desc || !pConfig->bTokendata) ){ idxFlags |= FTS5_BI_ORDER_ROWID; @@ -680,14 +677,17 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ /* Calculate the estimated cost based on the flags set in idxFlags. */ if( bSeenEq ){ - pInfo->estimatedCost = bSeenMatch ? 100.0 : 10.0; - if( bSeenMatch==0 ) fts5SetUniqueFlag(pInfo); + pInfo->estimatedCost = nSeenMatch ? 1000.0 : 10.0; + if( nSeenMatch==0 ) fts5SetUniqueFlag(pInfo); }else if( bSeenLt && bSeenGt ){ - pInfo->estimatedCost = bSeenMatch ? 500.0 : 250000.0; + pInfo->estimatedCost = nSeenMatch ? 5000.0 : 250000.0; }else if( bSeenLt || bSeenGt ){ - pInfo->estimatedCost = bSeenMatch ? 750.0 : 750000.0; + pInfo->estimatedCost = nSeenMatch ? 7500.0 : 750000.0; }else{ - pInfo->estimatedCost = bSeenMatch ? 1000.0 : 1000000.0; + pInfo->estimatedCost = nSeenMatch ? 10000.0 : 1000000.0; + } + for(i=1; iestimatedCost *= 0.4; } pInfo->idxNum = idxFlags; diff --git a/ext/fts5/test/fts5colset.test b/ext/fts5/test/fts5colset.test index 7243743b51..e5429572c5 100644 --- a/ext/fts5/test/fts5colset.test +++ b/ext/fts5/test/fts5colset.test @@ -79,7 +79,7 @@ foreach_detail_mode $::testprefix { do_catchsql_test 4.1 { SELECT * FROM t1 WHERE rowid MATCH 'a' - } {1 {unable to use function MATCH in the requested context}} + } {1 {no query solution}} } #------------------------------------------------------------------------- diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index 4e4fe4ba2d..e4903d067a 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -535,5 +535,36 @@ do_execsql_test 19.0 { COMMIT; } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 20.0 { + CREATE VIRTUAL TABLE x1 USING fts5(a); + INSERT INTO x1(rowid, a) VALUES + (1, 'a b c d'), + (2, 'x b c d'), + (3, 'x y z d'), + (4, 'a y c x'); +} + +do_execsql_test 20.1 { + SELECT rowid FROM x1 WHERE x1 MATCH 'a' AND x1 MATCH 'b'; +} {1} + +do_execsql_test 20.2 { + SELECT rowid FROM x1 WHERE x1 MATCH 'a' AND x1 MATCH 'y'; +} {4} + +do_execsql_test 20.3 { + SELECT rowid FROM x1 WHERE x1 MATCH 'a' OR x1 MATCH 'y'; +} {1 4 3} + +do_execsql_test 20.4 { + SELECT rowid FROM x1 WHERE x1 MATCH 'a' OR (x1 MATCH 'y' AND x1 MATCH 'd'); +} {1 4 3} + +do_execsql_test 20.5 { + SELECT rowid FROM x1 WHERE x1 MATCH 'z' OR (x1 MATCH 'a' AND x1 MATCH 'd'); +} {3 1} + finish_test diff --git a/manifest b/manifest index dc8a120397..2b36f7d4e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\stests\sfor\sOR\sconstraints\son\svirtual\stables. -D 2024-05-31T20:32:10.798 +C Have\sfts5.xBestIndex\sreturn\sSQLITE_CONSTRAINT,\sinstead\sof\sa\slarge\scost,\swhen\sno\susable\splan\scan\sbe\sfound. +D 2024-06-01T17:56:58.279 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 1ae512e7374caca6ab250055b3b29e46b007a27b098eafcc7ff4d13 F ext/fts5/fts5_expr.c 85789f6fb01995f2578b60a360057ed754335a890b1ab2e57e238b3670a9ae6c F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c ac3aaf0c885cf4e274c0c09ece632e17ff2fce01f2c9c0f4c50ffbbb3e267bde +F ext/fts5/fts5_main.c b1538b39182be8f2b6b1807c1ad426e0e5710e3ee2dcaeb7d0ae2b751103c237 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -133,7 +133,7 @@ F ext/fts5/test/fts5bigpl.test 6466c89b38439f0aba26ac09e232a6b963f29b1cbe1304f6a F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36 F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62 -F ext/fts5/test/fts5colset.test 7031ce84fb4d312df5a99fc4e7b324e660ccb513c97eccdef469bfd52d3d0f8f +F ext/fts5/test/fts5colset.test 544f4998cdbfe06a3123887fc0221612e8aa8192cdaff152872f1aadb10e6897 F ext/fts5/test/fts5columnsize.test 45459ce4dd9fd853b6044cdc9674921bff89e3d840f348ca8c1630f9edbf5482 F ext/fts5/test/fts5config.test 60094712debc59286c59aef0e6cf511c37d866802776a825ce437d26afe0817f F ext/fts5/test/fts5conflict.test bf6030a77dbb1bedfcc42e589ed7980846c995765d77460551e448b56d741244 @@ -186,7 +186,7 @@ F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fc F ext/fts5/test/fts5matchinfo.test 10c9a6f7fe61fb132299c4183c012770b10c4d5c2f2edb6df0b6607f683d737a F ext/fts5/test/fts5merge.test e92a8db28b45931e7a9c7b1bbd36101692759d00274df74d83fd29d25d53b3a6 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test 89dc46e37951b7f6653809f4abf6b1ca2f1fa62259efaf719339288f76fb6be9 +F ext/fts5/test/fts5misc.test b88aa28ff20238b394495b0795cddca1a62b98fa09b99e462a8abc572d04ee88 F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 211477940142d733ac04fad97cb24095513ab2507073a99c2765c3ddd2ef58bd @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4edd9b29f58621335b8a562280c991c34804bbba090f90c951261d043cff1965 -R 7e0b53e0bf1f5f31582edfc766b004d3 +P ff4a30056f8dbcbd045afdbee485f6671c3580b95187144aa9a77c97dfda2647 +R 884536d5c578ec6faaf09891deb9b65a U dan -Z 60bf1853e2bb5029309100d75a83bcc9 +Z 7e4839dea4a455e242c808d50043956b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4b2b009f72..3c6c28083e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff4a30056f8dbcbd045afdbee485f6671c3580b95187144aa9a77c97dfda2647 \ No newline at end of file +7c470945372dc98610f7c9840ce8cab18c19b655352f0187e4f31040cea77363 \ No newline at end of file From 0507e6e3884a74989fc89e8b4570d31eaeac91a9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 2 Jun 2024 10:52:35 +0000 Subject: [PATCH 0459/1030] Be more aggressive about freeing memory associated with the sqlite3_index_info.idxStr field. FossilOrigin-Name: 85dcd0a8479a658203833cfd75f22813faa26d4793ebfbb8843035d683bee105 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 24 ++++++++++++++++-------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 2b36f7d4e0..263f5193ed 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sfts5.xBestIndex\sreturn\sSQLITE_CONSTRAINT,\sinstead\sof\sa\slarge\scost,\swhen\sno\susable\splan\scan\sbe\sfound. -D 2024-06-01T17:56:58.279 +C Be\smore\saggressive\sabout\sfreeing\smemory\sassociated\swith\sthe\nsqlite3_index_info.idxStr\sfield. +D 2024-06-02T10:52:35.141 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c ddffcd89b1b794a3d7ce56ac31315ae7a5625313046f6aff3942a682b3fa0d48 +F src/where.c 233c668403a0afd83ad1211235f42601b62b95fbfd893f93bfeb0df6bf384245 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ff4a30056f8dbcbd045afdbee485f6671c3580b95187144aa9a77c97dfda2647 -R 884536d5c578ec6faaf09891deb9b65a -U dan -Z 7e4839dea4a455e242c808d50043956b +P 7c470945372dc98610f7c9840ce8cab18c19b655352f0187e4f31040cea77363 +R 63d264a5691dbac02e2f4fc53ea495d4 +U drh +Z 6b7afb3ccb4c7001ae92721661549344 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3c6c28083e..77e6354bb4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c470945372dc98610f7c9840ce8cab18c19b655352f0187e4f31040cea77363 \ No newline at end of file +85dcd0a8479a658203833cfd75f22813faa26d4793ebfbb8843035d683bee105 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 53be42888a..335d6a4e93 100644 --- a/src/where.c +++ b/src/where.c @@ -1564,6 +1564,17 @@ static sqlite3_index_info *allocateIndexInfo( return pIdxInfo; } +/* +** Free and zero the sqlite3_index_info.idxStr value if needed. +*/ +static void freeIdxStr(sqlite3_index_info *pIdxInfo){ + if( pIdxInfo->needToFreeIdxStr ){ + sqlite3_free(pIdxInfo->idxStr); + pIdxInfo->idxStr = 0; + pIdxInfo->needToFreeIdxStr = 0; + } +} + /* ** Free an sqlite3_index_info structure allocated by allocateIndexInfo() ** and possibly modified by xBestIndex methods. @@ -1579,6 +1590,7 @@ static void freeIndexInfo(sqlite3 *db, sqlite3_index_info *pIdxInfo){ sqlite3ValueFree(pHidden->aRhs[i]); /* IMP: R-14553-25174 */ pHidden->aRhs[i] = 0; } + freeIdxStr(pIdxInfo); sqlite3DbFree(db, pIdxInfo); } @@ -4210,6 +4222,7 @@ static int whereLoopAddVirtualOne( ** Make no entries in the loop table. */ WHERETRACE(0xffffffff, (" ^^^^--- non-viable plan rejected!\n")); + freeIdxStr(pIdxInfo); return SQLITE_OK; } return rc; @@ -4232,7 +4245,7 @@ static int whereLoopAddVirtualOne( || pIdxCons->usable==0 ){ sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName); - testcase( pIdxInfo->needToFreeIdxStr ); + freeIdxStr(pIdxInfo); return SQLITE_ERROR; } testcase( iTerm==nConstraint-1 ); @@ -4282,11 +4295,7 @@ static int whereLoopAddVirtualOne( ** the plan cannot be used. In these cases set variable *pbRetryLimit ** to true to tell the caller to retry with LIMIT and OFFSET ** disabled. */ - if( pIdxInfo->needToFreeIdxStr ){ - sqlite3_free(pIdxInfo->idxStr); - pIdxInfo->idxStr = 0; - pIdxInfo->needToFreeIdxStr = 0; - } + freeIdxStr(pIdxInfo); *pbRetryLimit = 1; return SQLITE_OK; } @@ -4299,7 +4308,7 @@ static int whereLoopAddVirtualOne( /* The non-zero argvIdx values must be contiguous. Raise an ** error if they are not */ sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName); - testcase( pIdxInfo->needToFreeIdxStr ); + freeIdxStr(pIdxInfo); return SQLITE_ERROR; } } @@ -4595,7 +4604,6 @@ static int whereLoopAddVirtual( } } - if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr); freeIndexInfo(pParse->db, p); WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc)); return rc; From e1b55a5af9d65aa33d6fcfb68e9a998bd2af0985 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 3 Jun 2024 07:22:28 +0000 Subject: [PATCH 0460/1030] Modify three #if checks in os_unix.c to improve handling of SQLITE_OMIT_WAL on WASI builds. Based on the discussion in/around [forum:57e918431735128a|forum post 57e918431735128a]. FossilOrigin-Name: 296eeb26c816bc734530cf446922f25be970b901c884df1a98083502f0d1e9f5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 8a3110d657..ba1bfaab11 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\seven\stry\sstar-schema\sdetection\sif\sthe\sjoin\shas\sfewer\sthan\s5\stables,\nsince\s5\sis\sthe\sminimum\sfor\sa\spositive\sdetection. -D 2024-05-31T15:39:00.555 +C Modify\sthree\s#if\schecks\sin\sos_unix.c\sto\simprove\shandling\sof\sSQLITE_OMIT_WAL\son\sWASI\sbuilds.\sBased\son\sthe\sdiscussion\sin/around\s[forum:57e918431735128a|forum\spost\s57e918431735128a]. +D 2024-06-03T07:22:28.518 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -739,7 +739,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c 6227cbc4ac93046f121436886cf3712da6f4e2082af6314f976eeae1d86b794a +F src/os_unix.c 08ca53844f4bf8eafb18b0a9076c84afac41da912315a5cfbe9e704d4c10c090 F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 996c46e61d9a53a54018672dd407b8ba8c480dd6795393428f9d5fcb81b47ab5 -R a2ca0792af2e5fd1149a2be149730242 -U drh -Z dd2c4dbd585f8635955a8cbd6ced885b +P a07ec16bbc056fbc23a7bd58e5e32ef691c13e9babeb542918cf9a01cac40c20 +R ec4b0ef096bbb322e89f9c8b12d64294 +U stephan +Z a28a63e6360f258a971f7c4657c7b09e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2b915c652e..8f3cb376e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a07ec16bbc056fbc23a7bd58e5e32ef691c13e9babeb542918cf9a01cac40c20 \ No newline at end of file +296eeb26c816bc734530cf446922f25be970b901c884df1a98083502f0d1e9f5 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 9e7ba05d68..c61b19060c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3987,7 +3987,7 @@ static void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){ /* Forward declaration */ static int unixGetTempname(int nBuf, char *zBuf); -#ifndef SQLITE_OMIT_WAL +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) static int unixFcntlExternalReader(unixFile*, int*); #endif @@ -4114,7 +4114,7 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ case SQLITE_FCNTL_EXTERNAL_READER: { -#ifndef SQLITE_OMIT_WAL +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) return unixFcntlExternalReader((unixFile*)id, (int*)pArg); #else *(int*)pArg = 0; @@ -4287,7 +4287,7 @@ static int unixGetpagesize(void){ #endif /* !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 */ -#ifndef SQLITE_OMIT_WAL +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) /* ** Object used to represent an shared memory buffer. From 586b2b2a540873f41c8b1581a5f2a0651b57743f Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 3 Jun 2024 12:36:43 +0000 Subject: [PATCH 0461/1030] Omit an unused #define. FossilOrigin-Name: 9c2de28a146e4cdfa4c05bf8dbd4ebb1156c71104001edf68e6dd5db21deb91f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ba1bfaab11..363a1881a4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthree\s#if\schecks\sin\sos_unix.c\sto\simprove\shandling\sof\sSQLITE_OMIT_WAL\son\sWASI\sbuilds.\sBased\son\sthe\sdiscussion\sin/around\s[forum:57e918431735128a|forum\spost\s57e918431735128a]. -D 2024-06-03T07:22:28.518 +C Omit\san\sunused\s#define. +D 2024-06-03T12:36:43.671 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/shell.c.in a4d5957a853d6065549a1f2d8f46ded9940f72835e0328bbad292560f36b4d4 F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 98ba756789b37f8d8217407ce077c31faf0b9b21d593b327c2b9667ad5bea1ac +F src/sqliteInt.h d66a1eab63dea318ad3f56df2b4d8c70ee9143aff25fbb1423c8234d6cf37787 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a07ec16bbc056fbc23a7bd58e5e32ef691c13e9babeb542918cf9a01cac40c20 -R ec4b0ef096bbb322e89f9c8b12d64294 -U stephan -Z a28a63e6360f258a971f7c4657c7b09e +P 296eeb26c816bc734530cf446922f25be970b901c884df1a98083502f0d1e9f5 +R c2b235abe104a50bb52435bc7dd8e30a +U drh +Z 6a462a5c042ea727edcd9a050ecce1bd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8f3cb376e3..f21948cf07 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -296eeb26c816bc734530cf446922f25be970b901c884df1a98083502f0d1e9f5 \ No newline at end of file +9c2de28a146e4cdfa4c05bf8dbd4ebb1156c71104001edf68e6dd5db21deb91f \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f4f8fc5e49..7d313e408a 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3460,7 +3460,7 @@ struct NameContext { #define NC_UUpsert 0x000200 /* True if uNC.pUpsert is used */ #define NC_UBaseReg 0x000400 /* True if uNC.iBaseReg is used */ #define NC_MinMaxAgg 0x001000 /* min/max aggregates seen. See note above */ -#define NC_Complex 0x002000 /* True if a function or subquery seen */ +/* 0x002000 // available for reuse */ #define NC_AllowWin 0x004000 /* Window functions are allowed here */ #define NC_HasWin 0x008000 /* One or more window functions seen */ #define NC_IsDDL 0x010000 /* Resolving names in a CREATE statement */ From 8741ca0819910e447d9637a4ecf8fcc7c0d556b7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 3 Jun 2024 18:04:10 +0000 Subject: [PATCH 0462/1030] Address a corner-case associated with the call-function-once optimization of check-in [663f5dd32d9db832] that was causing a (harmless) use of an uninitialized bytecode register. dbsqlfuzz 8a44f675401a8b1f68a43bf813c4f4f72ad8f0ea FossilOrigin-Name: b37ac2d020873b78efa164036db4056406a67330679f850775da520cd8027cb9 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 6 +++++- test/distinct2.test | 26 ++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 363a1881a4..cdd193c94a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\san\sunused\s#define. -D 2024-06-03T12:36:43.671 +C Address\sa\scorner-case\sassociated\swith\sthe\scall-function-once\soptimization\nof\scheck-in\s[663f5dd32d9db832]\sthat\swas\scausing\sa\s(harmless)\suse\sof\san\nuninitialized\sbytecode\sregister.\ndbsqlfuzz\s8a44f675401a8b1f68a43bf813c4f4f72ad8f0ea +D 2024-06-03T18:04:10.740 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -755,7 +755,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c cbdaf9cb2d9a697ee9ce1484f27d2e96762d33cc19259aedfb818a68b9d3be10 +F src/select.c 3b818d1b476c7108fdbbf6853c92fe4a933940474c77546f812e14f8aa2be03d F src/shell.c.in a4d5957a853d6065549a1f2d8f46ded9940f72835e0328bbad292560f36b4d45 F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1074,7 +1074,7 @@ F test/descidx2.test a0ba347037ff3b811f4c6ceca5fd0f9d5d72e74e59f2d9de346a9d2f6ad F test/descidx3.test 953c831df7ea219c73826dfbf2f6ee02d95040725aa88ccb4fa43d1a1999b926 F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e F test/distinct.test 691c9e850b0d0b56b66e7e235453198cb4cf0760e324b7403d3c5abbeab0a014 -F test/distinct2.test c936bb8652258c04bf066706284f5cd54ec693817399dbd6503c49d41ace626e +F test/distinct2.test 931a242fccaa05f17232e23acc9b2debe42901d90db723ddca038f7758951b5f F test/distinctagg.test 40d7169ae5846caaf62c6e307d2ca3c333daf9b6f7cde888956a339a97afe85f F test/e_blobbytes.test 4c01dfe4f12087b92b20705a3fdfded45dc4ed16d5a211fed4e1d2786ba68a52 F test/e_blobclose.test 692fc02a058476c2222a63d97e3f3b2b809c1842e5525ded7f854d540ac2e075 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 296eeb26c816bc734530cf446922f25be970b901c884df1a98083502f0d1e9f5 -R c2b235abe104a50bb52435bc7dd8e30a +P 9c2de28a146e4cdfa4c05bf8dbd4ebb1156c71104001edf68e6dd5db21deb91f +R d4496a035a38c25977bb772e3914abf4 U drh -Z 6a462a5c042ea727edcd9a050ecce1bd +Z 1c72e2560aacb242bc05d4316fc90305 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f21948cf07..cd909058cc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c2de28a146e4cdfa4c05bf8dbd4ebb1156c71104001edf68e6dd5db21deb91f \ No newline at end of file +b37ac2d020873b78efa164036db4056406a67330679f850775da520cd8027cb9 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 9ff5c6c536..4671dfa6d8 100644 --- a/src/select.c +++ b/src/select.c @@ -8331,7 +8331,11 @@ int sqlite3Select( } if( iOrderByCol ){ - sqlite3ExprToRegister(p->pEList->a[iOrderByCol-1].pExpr, iAMem+j); + Expr *pX = p->pEList->a[iOrderByCol-1].pExpr; + Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX); + if( ALWAYS(pBase!=0) && pBase->op!=TK_AGG_COLUMN ){ + sqlite3ExprToRegister(pX, iAMem+j); + } } } sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr, diff --git a/test/distinct2.test b/test/distinct2.test index ca88f5a285..023e2e3335 100644 --- a/test/distinct2.test +++ b/test/distinct2.test @@ -336,4 +336,30 @@ do_execsql_test 5040 { SELECT a FROM cnt WHERE a>45 GROUP BY 1; } {46 47 48 49 50} + +# 2024-06-03 dbsqlfuzz 8a44f675401a8b1f68a43bf813c4f4f72ad8f0ea +# Use of uninitialized bytecode register due to the call-function-once +# optimization at check-in 663f5dd32d9db832 +# +db null NULL +do_execsql_test 5050 { + CREATE TABLE t0(a TEXT); INSERT INTO t0 VALUES('abcd'); + CREATE TABLE t1(b TEXT); + CREATE TABLE t2(c TEXT); + CREATE TABLE t3(d TEXT); INSERT INTO t3 VALUES('wxyz'); + CREATE VIEW v4(e) AS SELECT (SELECT t2.c FROM t0, t1 GROUP BY 1) FROM t2; + SELECT v4.e FROM t3 LEFT JOIN v4 ON true GROUP BY 1; +} NULL +do_execsql_test 5060 { + DROP VIEW v4; + CREATE VIEW v4(e) AS SELECT (SELECT t2.c COLLATE nocase FROM t0, t1 GROUP BY 1) FROM t2; + SELECT v4.e FROM t3 LEFT JOIN v4 ON true GROUP BY 1; +} NULL + +do_execsql_test 5070 { + DROP VIEW v4; + CREATE VIEW v4(e) AS SELECT (SELECT unlikely(t2.c COLLATE nocase) FROM t0, t1 GROUP BY 1) FROM t2; + SELECT v4.e FROM t3 LEFT JOIN v4 ON true GROUP BY 1; +} NULL + finish_test From c5a0ed7b436525f900432a2f3b72bd72af876558 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 4 Jun 2024 14:32:31 +0000 Subject: [PATCH 0463/1030] Allow shell command "testctrl pending_byte" to be used in unsafe-testing mode only. FossilOrigin-Name: afa45c4f5afc9248ca4a1e775404a460280bb9a58a92eae508ae00fb2f675dc6 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index cdd193c94a..1eb63fc3a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Address\sa\scorner-case\sassociated\swith\sthe\scall-function-once\soptimization\nof\scheck-in\s[663f5dd32d9db832]\sthat\swas\scausing\sa\s(harmless)\suse\sof\san\nuninitialized\sbytecode\sregister.\ndbsqlfuzz\s8a44f675401a8b1f68a43bf813c4f4f72ad8f0ea -D 2024-06-03T18:04:10.740 +C Allow\sshell\scommand\s"testctrl\spending_byte"\sto\sbe\sused\sin\sunsafe-testing\smode\sonly. +D 2024-06-04T14:32:31.978 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -756,7 +756,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 3b818d1b476c7108fdbbf6853c92fe4a933940474c77546f812e14f8aa2be03d -F src/shell.c.in a4d5957a853d6065549a1f2d8f46ded9940f72835e0328bbad292560f36b4d45 +F src/shell.c.in eda43eacdf547cc810d1e88f1866b4f535a5467305c1851238a52d3960d86b9a F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9c2de28a146e4cdfa4c05bf8dbd4ebb1156c71104001edf68e6dd5db21deb91f -R d4496a035a38c25977bb772e3914abf4 -U drh -Z 1c72e2560aacb242bc05d4316fc90305 +P b37ac2d020873b78efa164036db4056406a67330679f850775da520cd8027cb9 +R 03b67338e4f76f19d1378076ba7adc4c +U dan +Z 20ef19e0c9f6862e4dab9e45e30fdc2a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cd909058cc..ac1beac57c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b37ac2d020873b78efa164036db4056406a67330679f850775da520cd8027cb9 \ No newline at end of file +afa45c4f5afc9248ca4a1e775404a460280bb9a58a92eae508ae00fb2f675dc6 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 6773b2b4ee..7a9aa032b9 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -10905,7 +10905,7 @@ static int do_meta_command(char *zLine, ShellState *p){ #ifdef YYCOVERAGE {"parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE,0,"" }, #endif - {"pending_byte", SQLITE_TESTCTRL_PENDING_BYTE,0, "OFFSET " }, + {"pending_byte", SQLITE_TESTCTRL_PENDING_BYTE,1, "OFFSET " }, {"prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE,0, "" }, {"prng_save", SQLITE_TESTCTRL_PRNG_SAVE, 0, "" }, {"prng_seed", SQLITE_TESTCTRL_PRNG_SEED, 0, "SEED ?db?" }, From 077f9b14f11c798e01def61f0e81c47859950d3a Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 4 Jun 2024 15:07:38 +0000 Subject: [PATCH 0464/1030] Fix a couple of memory leaks in the shell tool code that could occur when processing errors. FossilOrigin-Name: e84f09d469ee76a5b5e44baf6a69b90c69d4160fa4c32de04a96f868643acd96 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 10 ++++++---- test/shell3.test | 9 +++++++++ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 1eb63fc3a9..05ecb1a2f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sshell\scommand\s"testctrl\spending_byte"\sto\sbe\sused\sin\sunsafe-testing\smode\sonly. -D 2024-06-04T14:32:31.978 +C Fix\sa\scouple\sof\smemory\sleaks\sin\sthe\sshell\stool\scode\sthat\scould\soccur\swhen\sprocessing\serrors. +D 2024-06-04T15:07:38.217 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -756,7 +756,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 3b818d1b476c7108fdbbf6853c92fe4a933940474c77546f812e14f8aa2be03d -F src/shell.c.in eda43eacdf547cc810d1e88f1866b4f535a5467305c1851238a52d3960d86b9a +F src/shell.c.in 134db38064e038b6d3aec968a4a3eb302141b043808922961e34b333de1cff21 F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -1613,7 +1613,7 @@ F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 F test/shell1.test 17a5ca9c6f24f807b2f505b4b38fcbce143d96cd8664c06c34bbbe0672bf7c30 F test/shell2.test 56da24128304c9ab67da2964cc80beff7b35761c446ec6e6e98bff2775b15026 -F test/shell3.test 5ad4b2813717956414f2c0c8a2027895cd98ccf7dd54dbacbde4d4f5591ce5a1 +F test/shell3.test db1953a8e59d08e9240b7cc5948878e184f7eb2623591587f8fd1f1a5bd536d8 F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f807 F test/shell5.test 6a49440bddc33a132f856fb189e71228f8132963655d12a2c8b8a161263b9632 F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bdbb8 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b37ac2d020873b78efa164036db4056406a67330679f850775da520cd8027cb9 -R 03b67338e4f76f19d1378076ba7adc4c +P afa45c4f5afc9248ca4a1e775404a460280bb9a58a92eae508ae00fb2f675dc6 +R 332c194faf67e4e5d499e21ef0877039 U dan -Z 20ef19e0c9f6862e4dab9e45e30fdc2a +Z 25f8afeca77d9ed28a678ff29d2afdb8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ac1beac57c..b9aace0327 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -afa45c4f5afc9248ca4a1e775404a460280bb9a58a92eae508ae00fb2f675dc6 \ No newline at end of file +e84f09d469ee76a5b5e44baf6a69b90c69d4160fa4c32de04a96f868643acd96 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 7a9aa032b9..5461071389 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8955,6 +8955,7 @@ static int do_meta_command(char *zLine, ShellState *p){ eputf("%s: empty file\n", sCtx.zFile); import_cleanup(&sCtx); rc = 1; + sqlite3_free(zCreate); goto meta_command_exit; } zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs); @@ -12749,8 +12750,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ if( azCmd[i][0]=='.' ){ rc = do_meta_command(azCmd[i], &data); if( rc ){ - free(azCmd); - return rc==2 ? 0 : rc; + if( rc==2 ) rc = 0; + goto shell_main_exit; } }else{ open_db(&data, 0); @@ -12763,8 +12764,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ eputf("Error: unable to process SQL: %s\n", azCmd[i]); } sqlite3_free(zErrMsg); - free(azCmd); - return rc!=0 ? rc : 1; + if( rc==0 ) rc = 1; + goto shell_main_exit; } } } @@ -12824,6 +12825,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ expertFinish(&data, 1, 0); } #endif + shell_main_exit: free(azCmd); set_table_name(&data, 0); if( data.db ){ diff --git a/test/shell3.test b/test/shell3.test index c1ea9f6a75..ef3ea784ff 100644 --- a/test/shell3.test +++ b/test/shell3.test @@ -136,4 +136,13 @@ a["b"] .*/ x 'y}} 1} +do_test shell3-3.2 { + catchcmd "" { +.open xyz.db +SELECT ; + } +} {1 {Parse error near line 3: near ";": syntax error + SELECT ; + ^--- error here}} + finish_test From ecaa021759d5b581b62ae705c5a6617661aa14d1 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 4 Jun 2024 19:21:16 +0000 Subject: [PATCH 0465/1030] Fix harmless compiler warnings seen with MSVC. FossilOrigin-Name: 93ac8573eead9b785a24715239e71cd3ef730bf16332cf3b5e264a6491374cac --- ext/misc/compress.c | 2 +- ext/misc/zipfile.c | 4 +++- manifest | 17 ++++++++--------- manifest.uuid | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ext/misc/compress.c b/ext/misc/compress.c index 2e7a31636d..6b034eb45f 100644 --- a/ext/misc/compress.c +++ b/ext/misc/compress.c @@ -89,7 +89,7 @@ static void uncompressFunc( unsigned int nIn; unsigned long int nOut; int rc; - int i; + unsigned int i; pIn = sqlite3_value_blob(argv[0]); nIn = sqlite3_value_bytes(argv[0]); diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index db327809f8..fd6d13bc38 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -29,7 +29,9 @@ SQLITE_EXTENSION_INIT1 #include #include #include -#include +#ifndef SQLITE_NO_STDINT +# include +#endif #include diff --git a/manifest b/manifest index 54e6ae721c..a7b6d908e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Better\shandle\sWHERE\sterms\sthat\sare\scommon\sto\stwo\sor\smore\sOR\sbranches\swhen\splanning\svirtual\stable\squeries. -D 2024-06-04T17:26:15.006 +C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. +D 2024-06-04T19:21:16.009 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -385,7 +385,7 @@ F ext/misc/carray.h 503209952ccf2431c7fd899ebb92bf46bf7635b38aace42ec8aa1b8d7b6e F ext/misc/cksumvfs.c 3a7931dd30667be6348af919f3f9e6188dfd7646b42af8e399a499b327f5bd63 F ext/misc/closure.c 0e04f52d93e678dd6f950f195f365992edf3c380df246f3d80425cba4c13891e F ext/misc/completion.c ef78835483b43ac18c96be312b90b615d8368189909be03513ab7a9338131298 -F ext/misc/compress.c 3354c77a7c8e86e07d849916000cdac451ed96500bfb5bd83b20eb61eee012c9 +F ext/misc/compress.c 2c79a74330e0e0ba6cb3f7397f8ba5af12d46377ef5d3ee075e12dd8a6ed57f0 F ext/misc/csv.c 575c2c05fba0a451586a4d42c2c81e711780c41e797126f198d8d9e0a308dcdb F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f823e01 F ext/misc/decimal.c 172cf81a8634e6a0f0bedaf71a8372fee63348cf5a3c4e1b78bb233c35889fdc @@ -430,7 +430,7 @@ F ext/misc/vfsstat.c a85df08654743922a19410d7b1e3111de41bb7cd07d20dd16eda4e2b808 F ext/misc/vtablog.c 1100250ce8782db37c833e3a9a5c9a3ecf1af5e15b8325572b82e6e0a138ffb5 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 0fa0c082676b7868bf2fa918e911133f2b349bcdceabd1198bba5f65b4fc0668 -F ext/misc/zipfile.c 64cb3d98b6316586e6056d182051aa9d28fdedfbf4b908e6b7a7d70209b1db11 +F ext/misc/zipfile.c 5a3bf1b9cccb8e0da2389fe9e39e9c7f2b1351474b7e5090635f817d495eee3f F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64 F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8 F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255 @@ -2194,9 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e84f09d469ee76a5b5e44baf6a69b90c69d4160fa4c32de04a96f868643acd96 85dcd0a8479a658203833cfd75f22813faa26d4793ebfbb8843035d683bee105 -R ef252a4e30665afc837737e2dd6e6acf -T +closed 85dcd0a8479a658203833cfd75f22813faa26d4793ebfbb8843035d683bee105 -U dan -Z 63031e840e155842bdee98d1a8498c9b +P 1976c3f7e1fe77cf3367710e8ada230a3672ed374e316425164e42b2622526c7 +R d8eccf164f9724f23a05a76c65e3fbe6 +U mistachkin +Z 95140046d0f54cc6d678728b4fb9117c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1764cb4c85..fec3cc7aef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1976c3f7e1fe77cf3367710e8ada230a3672ed374e316425164e42b2622526c7 \ No newline at end of file +93ac8573eead9b785a24715239e71cd3ef730bf16332cf3b5e264a6491374cac \ No newline at end of file From e3eefe00dd907271a8d845b8e1565d5580d78364 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Jun 2024 11:36:58 +0000 Subject: [PATCH 0466/1030] Fix a very obscure issue where the name resolver could get confused if aliases like "sqlite_schema" or "sqlite_master" were used in a query involving the sqlite_temp_schema table. FossilOrigin-Name: a096eb7554952f8137c6e9330c328164719fb27e958787fbd503bcd1364e6ae4 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/resolve.c | 6 +++--- test/returning1.test | 13 +++++++++++++ 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index a7b6d908e0..8dc5bd618b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. -D 2024-06-04T19:21:16.009 +C Fix\sa\svery\sobscure\sissue\swhere\sthe\sname\sresolver\scould\sget\sconfused\sif\saliases\slike\s"sqlite_schema"\sor\s"sqlite_master"\swere\sused\sin\sa\squery\sinvolving\sthe\ssqlite_temp_schema\stable. +D 2024-06-05T11:36:58.559 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -753,7 +753,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 22f1fa3423b377c02ae78d451cfeb1c2d96dcf0389c0642cbdcd19d3bfd7ae01 +F src/resolve.c ae341d04d39de308e024649d6777dd015b6a94ddbfbe74d7fca2ee122fb1aea9 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 3b818d1b476c7108fdbbf6853c92fe4a933940474c77546f812e14f8aa2be03d F src/shell.c.in 134db38064e038b6d3aec968a4a3eb302141b043808922961e34b333de1cff21 @@ -1537,7 +1537,7 @@ F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed13 F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d F test/resetdb.test 54c06f18bc832ac6d6319e5ab23d5c8dd49fdbeec7c696d791682a8006bd5fc3 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb -F test/returning1.test 38eee9d07ac1dd4fbd4ce7373497f3783db86b9a76f13ea6a9f9afaf934f888b +F test/returning1.test 212cd4111bb941a60abf608f20250db666c21eb1bc4d49217e96c87ff3ab9d1a F test/returningfault.test ae4c4b5e8745813287a359d9ccdb9d5c883c2e68afb18fb0767937d5de5692a4 F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa F test/rollback2.test 3f3a4e20401825017df7e7671e9f31b6de5fae5620c2b9b49917f52f8c160a8f @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1976c3f7e1fe77cf3367710e8ada230a3672ed374e316425164e42b2622526c7 -R d8eccf164f9724f23a05a76c65e3fbe6 -U mistachkin -Z 95140046d0f54cc6d678728b4fb9117c +P 93ac8573eead9b785a24715239e71cd3ef730bf16332cf3b5e264a6491374cac +R b6d14e7c4a25ff2b09a3a3758c369a09 +U dan +Z 12e0d668b41198d3708456788f490098 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fec3cc7aef..3e0bbcdfb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -93ac8573eead9b785a24715239e71cd3ef730bf16332cf3b5e264a6491374cac \ No newline at end of file +a096eb7554952f8137c6e9330c328164719fb27e958787fbd503bcd1364e6ae4 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index bf8326aa64..40044a2204 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -228,7 +228,7 @@ static void extendFJMatch( static SQLITE_NOINLINE int isValidSchemaTableName( const char *zTab, /* Name as it appears in the SQL */ Table *pTab, /* The schema table we are trying to match */ - Schema *pSchema /* non-NULL if a database qualifier is present */ + const char *zDb /* non-NULL if a database qualifier is present */ ){ const char *zLegacy; assert( pTab!=0 ); @@ -239,7 +239,7 @@ static SQLITE_NOINLINE int isValidSchemaTableName( if( sqlite3StrICmp(zTab+7, &PREFERRED_TEMP_SCHEMA_TABLE[7])==0 ){ return 1; } - if( pSchema==0 ) return 0; + if( zDb==0 ) return 0; if( sqlite3StrICmp(zTab+7, &LEGACY_SCHEMA_TABLE[7])==0 ) return 1; if( sqlite3StrICmp(zTab+7, &PREFERRED_SCHEMA_TABLE[7])==0 ) return 1; }else{ @@ -422,7 +422,7 @@ static int lookupName( } }else if( sqlite3StrICmp(zTab, pTab->zName)!=0 ){ if( pTab->tnum!=1 ) continue; - if( !isValidSchemaTableName(zTab, pTab, pSchema) ) continue; + if( !isValidSchemaTableName(zTab, pTab, zDb) ) continue; } assert( ExprUseYTab(pExpr) ); if( IN_RENAME_OBJECT && pItem->zAlias ){ diff --git a/test/returning1.test b/test/returning1.test index 05bd445a2f..e7be7c65a3 100644 --- a/test/returning1.test +++ b/test/returning1.test @@ -531,4 +531,17 @@ do_execsql_test 21.1 { INSERT INTO sqlite_temp_schema DEFAULT VALUES RETURNING sqlite_temp_schema.name; } {{}} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 22.0 { + PRAGMA writable_schema=ON; + CREATE TABLE xyz (a); +} +do_catchsql_test 22.1 { + INSERT INTO sqlite_temp_schema DEFAULT VALUES + RETURNING + (SELECT * FROM xyz AS sqlite_master WHERE a=sqlite_master.name); +} {1 {no such column: sqlite_master.name}} + + finish_test From 6d98c55b565be6ee1347512cca2506da58c382ad Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Jun 2024 14:47:54 +0000 Subject: [PATCH 0467/1030] Fix an fts5 problem with secure-delete mode causing integrity-check to erroneously report a corrupt index. FossilOrigin-Name: 80bef4d60ba9e3679ea66655ca36fcfaa888775a3d1598d50e9649ad84a95b63 --- ext/fts5/fts5_main.c | 1 + ext/fts5/test/fts5secure8.test | 16 ++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 0a272cccaa..8d03e8e62c 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1703,6 +1703,7 @@ static int fts5UpdateMethod( rc = SQLITE_ERROR; }else{ rc = fts5SpecialDelete(pTab, apVal); + bUpdateOrDelete = 1; } }else{ rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]); diff --git a/ext/fts5/test/fts5secure8.test b/ext/fts5/test/fts5secure8.test index 8ceb9630aa..0216bb6ea1 100644 --- a/ext/fts5/test/fts5secure8.test +++ b/ext/fts5/test/fts5secure8.test @@ -42,6 +42,22 @@ do_execsql_test 1.2 { PRAGMA integrity_check; } {ok} +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE xyz USING fts5 ( + name, + content='' + ); + + INSERT INTO xyz(xyz, rank) VALUES('secure-delete', 1); + INSERT INTO xyz (rowid, name) VALUES(1, 'A'); + INSERT INTO xyz (rowid, name) VALUES(2, 'A'); + INSERT INTO xyz(xyz, rowid, name) VALUES('delete', 2, 'A'); +} + +do_execsql_test 2.1 { + pragma quick_check; +} {ok} + diff --git a/manifest b/manifest index 8dc5bd618b..dbbab100a5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\svery\sobscure\sissue\swhere\sthe\sname\sresolver\scould\sget\sconfused\sif\saliases\slike\s"sqlite_schema"\sor\s"sqlite_master"\swere\sused\sin\sa\squery\sinvolving\sthe\ssqlite_temp_schema\stable. -D 2024-06-05T11:36:58.559 +C Fix\san\sfts5\sproblem\swith\ssecure-delete\smode\scausing\sintegrity-check\sto\serroneously\sreport\sa\scorrupt\sindex. +D 2024-06-05T14:47:54.677 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 1ae512e7374caca6ab250055b3b29e46b007a27b098eafcc7ff4d13 F ext/fts5/fts5_expr.c 85789f6fb01995f2578b60a360057ed754335a890b1ab2e57e238b3670a9ae6c F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c b1538b39182be8f2b6b1807c1ad426e0e5710e3ee2dcaeb7d0ae2b751103c237 +F ext/fts5/fts5_main.c 21ddeb331ae6c9e990a18299c977156a9dac9ee92f372cfe7928d04433295042 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -218,7 +218,7 @@ F ext/fts5/test/fts5secure4.test 0d10a80590c07891478700af7793b232962042677432b98 F ext/fts5/test/fts5secure5.test c07a68ced5951567ac116c22f2d2aafae497e47fe9fcb6a335c22f9c7a4f2c3a F ext/fts5/test/fts5secure6.test 74bf04733cc523bccca519bb03d3b4e2ed6f6e3db7c59bf6be82c88a0ac857fd F ext/fts5/test/fts5secure7.test fd03d0868d64340a1db8615b02e5508fea409de13910114e4f19eaefc120777a -F ext/fts5/test/fts5secure8.test eb3579e9d58b0acad97e8082dee1f99b2d393198f03500b453c2b25761c0c298 +F ext/fts5/test/fts5secure8.test e68c0ac4447f415ff3e4e82531e99548289286f9f3a29c8cd53036113fe28602 F ext/fts5/test/fts5securefault.test dbca2b6a1c16700017f5051138991b705410889933f2a37c57ae8a23b296b10b F ext/fts5/test/fts5simple.test a298670508c1458b88ce6030440f26a30673931884eb5f4094ac1773b3ba217b F ext/fts5/test/fts5simple2.test 8dd2389ee75e21a1429fe87e5f8c7d9a97ad1470304a8a2d3ba4b8c3c345fecd @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 93ac8573eead9b785a24715239e71cd3ef730bf16332cf3b5e264a6491374cac -R b6d14e7c4a25ff2b09a3a3758c369a09 +P a096eb7554952f8137c6e9330c328164719fb27e958787fbd503bcd1364e6ae4 +R 0a424bef53f9d9c6999e5b99ba3f491f U dan -Z 12e0d668b41198d3708456788f490098 +Z bc999b30c47bb6a6c63f18a66f996a4c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3e0bbcdfb6..b490bc5112 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a096eb7554952f8137c6e9330c328164719fb27e958787fbd503bcd1364e6ae4 \ No newline at end of file +80bef4d60ba9e3679ea66655ca36fcfaa888775a3d1598d50e9649ad84a95b63 \ No newline at end of file From 0de7da199874653ab0b51c6851f28761aa51f9ca Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 5 Jun 2024 20:41:36 +0000 Subject: [PATCH 0468/1030] Small performance optimization in the codeEqualityTerm() routine of the code generator. FossilOrigin-Name: 8080c6eafd1280ea870a6ab1ba715ac5af67387e69771be6cbd46dda77c3eaa8 --- manifest | 14 +-- manifest.uuid | 2 +- src/wherecode.c | 259 ++++++++++++++++++++++++++---------------------- 3 files changed, 151 insertions(+), 124 deletions(-) diff --git a/manifest b/manifest index dbbab100a5..6bfc131267 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sfts5\sproblem\swith\ssecure-delete\smode\scausing\sintegrity-check\sto\serroneously\sreport\sa\scorrupt\sindex. -D 2024-06-05T14:47:54.677 +C Small\sperformance\soptimization\sin\sthe\scodeEqualityTerm()\sroutine\sof\sthe\ncode\sgenerator. +D 2024-06-05T20:41:36.552 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -842,7 +842,7 @@ F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 343e74d65856665f2aac59a9fcefecfc988e9af4aafa0bd1b8332a89c6c725b4 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 -F src/wherecode.c 5ad509221ebb4d3b35a8a6ef361f2c5b54129b8c273aa434dd3053d2e25d1794 +F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a096eb7554952f8137c6e9330c328164719fb27e958787fbd503bcd1364e6ae4 -R 0a424bef53f9d9c6999e5b99ba3f491f -U dan -Z bc999b30c47bb6a6c63f18a66f996a4c +P 80bef4d60ba9e3679ea66655ca36fcfaa888775a3d1598d50e9649ad84a95b63 +R 2c603113ce745efce0c45179f5a33586 +U drh +Z 49fdb8ccd67e18818e3ecc829cf527f5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b490bc5112..5ad548153f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -80bef4d60ba9e3679ea66655ca36fcfaa888775a3d1598d50e9649ad84a95b63 \ No newline at end of file +8080c6eafd1280ea870a6ab1ba715ac5af67387e69771be6cbd46dda77c3eaa8 \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index 80fbbfac4c..098af7375e 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -604,6 +604,147 @@ static Expr *removeUnindexableInClauseTerms( } +#ifndef SQLITE_OMIT_SUBQUERY +/* +** Generate code for a single X IN (....) term of the WHERE clause. +** +** This is a special-case of codeEqualityTerm() that works for IN operators +** only. It is broken out into a subroutine because this case is +** uncommon and by splitting it off into a subroutine, the common case +** runs faster. +** +** The current value for the constraint is left in register iTarget. +** This routine sets up a loop that will iterate over all values of X. +*/ +static SQLITE_NOINLINE void codeINTerm( + Parse *pParse, /* The parsing context */ + WhereTerm *pTerm, /* The term of the WHERE clause to be coded */ + WhereLevel *pLevel, /* The level of the FROM clause we are working on */ + int iEq, /* Index of the equality term within this level */ + int bRev, /* True for reverse-order IN operations */ + int iTarget /* Attempt to leave results in this register */ +){ + Expr *pX = pTerm->pExpr; + int eType = IN_INDEX_NOOP; + int iTab; + struct InLoop *pIn; + WhereLoop *pLoop = pLevel->pWLoop; + Vdbe *v = pParse->pVdbe; + int i; + int nEq = 0; + int *aiMap = 0; + + if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 + && pLoop->u.btree.pIndex!=0 + && pLoop->u.btree.pIndex->aSortOrder[iEq] + ){ + testcase( iEq==0 ); + testcase( bRev ); + bRev = !bRev; + } + assert( pX->op==TK_IN ); + + for(i=0; iaLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){ + disableTerm(pLevel, pTerm); + return; + } + } + for(i=iEq;inLTerm; i++){ + assert( pLoop->aLTerm[i]!=0 ); + if( pLoop->aLTerm[i]->pExpr==pX ) nEq++; + } + + iTab = 0; + if( !ExprUseXSelect(pX) || pX->x.pSelect->pEList->nExpr==1 ){ + eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab); + }else{ + Expr *pExpr = pTerm->pExpr; + if( pExpr->iTable==0 || !ExprHasProperty(pExpr, EP_Subrtn) ){ + sqlite3 *db = pParse->db; + pX = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX); + if( !db->mallocFailed ){ + aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq); + eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap,&iTab); + pExpr->iTable = iTab; + } + sqlite3ExprDelete(db, pX); + }else{ + int n = sqlite3ExprVectorSize(pX->pLeft); + aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*MAX(nEq,n)); + eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab); + } + pX = pExpr; + } + + if( eType==IN_INDEX_INDEX_DESC ){ + testcase( bRev ); + bRev = !bRev; + } + sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); + VdbeCoverageIf(v, bRev); + VdbeCoverageIf(v, !bRev); + + assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 ); + pLoop->wsFlags |= WHERE_IN_ABLE; + if( pLevel->u.in.nIn==0 ){ + pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse); + } + if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){ + pLoop->wsFlags |= WHERE_IN_EARLYOUT; + } + + i = pLevel->u.in.nIn; + pLevel->u.in.nIn += nEq; + pLevel->u.in.aInLoop = + sqlite3WhereRealloc(pTerm->pWC->pWInfo, + pLevel->u.in.aInLoop, + sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn); + pIn = pLevel->u.in.aInLoop; + if( pIn ){ + int iMap = 0; /* Index in aiMap[] */ + pIn += i; + for(i=iEq;inLTerm; i++){ + if( pLoop->aLTerm[i]->pExpr==pX ){ + int iOut = iTarget + i - iEq; + if( eType==IN_INDEX_ROWID ){ + pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iOut); + }else{ + int iCol = aiMap ? aiMap[iMap++] : 0; + pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut); + } + sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v); + if( i==iEq ){ + pIn->iCur = iTab; + pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next; + if( iEq>0 ){ + pIn->iBase = iTarget - i; + pIn->nPrefix = i; + }else{ + pIn->nPrefix = 0; + } + }else{ + pIn->eEndLoopOp = OP_Noop; + } + pIn++; + } + } + testcase( iEq>0 + && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 + && (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ); + if( iEq>0 + && (pLoop->wsFlags & (WHERE_IN_SEEKSCAN|WHERE_VIRTUALTABLE))==0 + ){ + sqlite3VdbeAddOp3(v, OP_SeekHit, pLevel->iIdxCur, 0, iEq); + } + }else{ + pLevel->u.in.nIn = 0; + } + sqlite3DbFree(pParse->db, aiMap); +} +#endif + + /* ** Generate code for a single equality term of the WHERE clause. An equality ** term can be either X=expr or X IN (...). pTerm is the term to be @@ -628,7 +769,6 @@ static int codeEqualityTerm( int iTarget /* Attempt to leave results in this register */ ){ Expr *pX = pTerm->pExpr; - Vdbe *v = pParse->pVdbe; int iReg; /* Register holding results */ assert( pLevel->pWLoop->aLTerm[iEq]==pTerm ); @@ -637,125 +777,12 @@ static int codeEqualityTerm( iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget); }else if( pX->op==TK_ISNULL ){ iReg = iTarget; - sqlite3VdbeAddOp2(v, OP_Null, 0, iReg); + sqlite3VdbeAddOp2(pParse->pVdbe, OP_Null, 0, iReg); #ifndef SQLITE_OMIT_SUBQUERY }else{ - int eType = IN_INDEX_NOOP; - int iTab; - struct InLoop *pIn; - WhereLoop *pLoop = pLevel->pWLoop; - int i; - int nEq = 0; - int *aiMap = 0; - - if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 - && pLoop->u.btree.pIndex!=0 - && pLoop->u.btree.pIndex->aSortOrder[iEq] - ){ - testcase( iEq==0 ); - testcase( bRev ); - bRev = !bRev; - } assert( pX->op==TK_IN ); iReg = iTarget; - - for(i=0; iaLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){ - disableTerm(pLevel, pTerm); - return iTarget; - } - } - for(i=iEq;inLTerm; i++){ - assert( pLoop->aLTerm[i]!=0 ); - if( pLoop->aLTerm[i]->pExpr==pX ) nEq++; - } - - iTab = 0; - if( !ExprUseXSelect(pX) || pX->x.pSelect->pEList->nExpr==1 ){ - eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab); - }else{ - Expr *pExpr = pTerm->pExpr; - if( pExpr->iTable==0 || !ExprHasProperty(pExpr, EP_Subrtn) ){ - sqlite3 *db = pParse->db; - pX = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX); - if( !db->mallocFailed ){ - aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq); - eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap,&iTab); - pExpr->iTable = iTab; - } - sqlite3ExprDelete(db, pX); - }else{ - int n = sqlite3ExprVectorSize(pX->pLeft); - aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*MAX(nEq,n)); - eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab); - } - pX = pExpr; - } - - if( eType==IN_INDEX_INDEX_DESC ){ - testcase( bRev ); - bRev = !bRev; - } - sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); - VdbeCoverageIf(v, bRev); - VdbeCoverageIf(v, !bRev); - - assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 ); - pLoop->wsFlags |= WHERE_IN_ABLE; - if( pLevel->u.in.nIn==0 ){ - pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse); - } - if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){ - pLoop->wsFlags |= WHERE_IN_EARLYOUT; - } - - i = pLevel->u.in.nIn; - pLevel->u.in.nIn += nEq; - pLevel->u.in.aInLoop = - sqlite3WhereRealloc(pTerm->pWC->pWInfo, - pLevel->u.in.aInLoop, - sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn); - pIn = pLevel->u.in.aInLoop; - if( pIn ){ - int iMap = 0; /* Index in aiMap[] */ - pIn += i; - for(i=iEq;inLTerm; i++){ - if( pLoop->aLTerm[i]->pExpr==pX ){ - int iOut = iReg + i - iEq; - if( eType==IN_INDEX_ROWID ){ - pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iOut); - }else{ - int iCol = aiMap ? aiMap[iMap++] : 0; - pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut); - } - sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v); - if( i==iEq ){ - pIn->iCur = iTab; - pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next; - if( iEq>0 ){ - pIn->iBase = iReg - i; - pIn->nPrefix = i; - }else{ - pIn->nPrefix = 0; - } - }else{ - pIn->eEndLoopOp = OP_Noop; - } - pIn++; - } - } - testcase( iEq>0 - && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 - && (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ); - if( iEq>0 - && (pLoop->wsFlags & (WHERE_IN_SEEKSCAN|WHERE_VIRTUALTABLE))==0 - ){ - sqlite3VdbeAddOp3(v, OP_SeekHit, pLevel->iIdxCur, 0, iEq); - } - }else{ - pLevel->u.in.nIn = 0; - } - sqlite3DbFree(pParse->db, aiMap); + codeINTerm(pParse, pTerm, pLevel, iEq, bRev, iTarget); #endif } From 6593b340ff6327dc150948753b9343057a9724a5 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 5 Jun 2024 20:50:39 +0000 Subject: [PATCH 0469/1030] Fix harmless compilation issues seen with MSVC. FossilOrigin-Name: 816d4749384c7f398912c905a16c83b88f4c55632050b4c6117c61301d1a53e1 --- ext/fts5/fts5_config.c | 2 +- ext/intck/test_intck.c | 3 ++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index a9a6c54380..01f40455a0 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -671,7 +671,7 @@ void sqlite3Fts5ConfigFree(Fts5Config *pConfig){ if( pConfig->t.pTok ){ pConfig->t.pTokApi->xDelete(pConfig->t.pTok); } - sqlite3_free(pConfig->t.azArg); + sqlite3_free((char*)pConfig->t.azArg); sqlite3_free(pConfig->zDb); sqlite3_free(pConfig->zName); for(i=0; inCol; i++){ diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c index 84008fb07f..412c9f201c 100644 --- a/ext/intck/test_intck.c +++ b/ext/intck/test_intck.c @@ -92,8 +92,9 @@ static int testIntckCmd( case 3: assert( 0==strcmp("error", aCmd[iIdx].zName) ); { const char *zErr = 0; + Tcl_Obj *pRes; rc = sqlite3_intck_error(p->intck, 0); - Tcl_Obj *pRes = Tcl_NewObj(); + pRes = Tcl_NewObj(); Tcl_ListObjAppendElement( interp, pRes, Tcl_NewStringObj(sqlite3ErrName(rc), -1) ); diff --git a/manifest b/manifest index 6bfc131267..9b693c0779 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\sperformance\soptimization\sin\sthe\scodeEqualityTerm()\sroutine\sof\sthe\ncode\sgenerator. -D 2024-06-05T20:41:36.552 +C Fix\sharmless\scompilation\sissues\sseen\swith\sMSVC. +D 2024-06-05T20:50:39.523 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -96,7 +96,7 @@ F ext/fts5/fts5.h 8856e11a5f0269cd346754cea0765efe8089635b80cad3222e8bfdb08cd534 F ext/fts5/fts5Int.h 407ee36addad0ae6df5d37a811f0bd509ab6708b29640884ed5c7509e5f75143 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 1ae512e7374caca6ab250055b3b29e46b007a27b098eafcc7ff4d13b06228cee +F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 F ext/fts5/fts5_expr.c 85789f6fb01995f2578b60a360057ed754335a890b1ab2e57e238b3670a9ae6c F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 @@ -258,7 +258,7 @@ F ext/intck/intckcorrupt.test f6c302792326fb3db9dcfc70b554c55369bc4b52882eaaf039 F ext/intck/intckfault.test cff3f75dff74abb3edfcb13f6aa53f6436746ab64b09fe5e2028f051e985efab F ext/intck/sqlite3intck.c 0d10df36e2b7b438aa80ecd3f5e584d41b747586b038258fe6b407f66b81e7c5 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 -F ext/intck/test_intck.c 34243458378a12d1356c79219a03f244800533b3ab65b4a02861f0403364df12 +F ext/intck/test_intck.c 6050ed1f3e11eb58c66ed20f75af43dec0e37c88c9089b98b8a0a26022735dc3 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 80bef4d60ba9e3679ea66655ca36fcfaa888775a3d1598d50e9649ad84a95b63 -R 2c603113ce745efce0c45179f5a33586 -U drh -Z 49fdb8ccd67e18818e3ecc829cf527f5 +P 8080c6eafd1280ea870a6ab1ba715ac5af67387e69771be6cbd46dda77c3eaa8 +R b1d29e4b163a20c9d9aadcb22bf1cdb9 +U mistachkin +Z 0cf3ec6bb41ed4737c063035dfa47552 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5ad548153f..c4650e9df3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8080c6eafd1280ea870a6ab1ba715ac5af67387e69771be6cbd46dda77c3eaa8 \ No newline at end of file +816d4749384c7f398912c905a16c83b88f4c55632050b4c6117c61301d1a53e1 \ No newline at end of file From b458cbb60182a8a86e897b0166e275f3d3e7572f Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 6 Jun 2024 00:49:36 +0000 Subject: [PATCH 0470/1030] Small performance optimization in the allowedOp() routine of the WHERE clause analysis code. FossilOrigin-Name: 4ba8be544711e07748e8dd3ca6b81f9897906061c0a1a1bb4fb3808dc27f734b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/whereexpr.c | 7 ++++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 9b693c0779..1062c51e50 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompilation\sissues\sseen\swith\sMSVC. -D 2024-06-05T20:50:39.523 +C Small\sperformance\soptimization\sin\sthe\sallowedOp()\sroutine\sof\sthe\sWHERE\nclause\sanalysis\scode. +D 2024-06-06T00:49:36.480 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -843,7 +843,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 343e74d65856665f2aac59a9fcefecfc988e9af4aafa0bd1b8332a89c6c725b4 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c -F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd +F src/whereexpr.c 6410cd2cd4f2d97c5c14bdd38650f0da712e75077d2014beff9a0bca93e2b893 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8080c6eafd1280ea870a6ab1ba715ac5af67387e69771be6cbd46dda77c3eaa8 -R b1d29e4b163a20c9d9aadcb22bf1cdb9 -U mistachkin -Z 0cf3ec6bb41ed4737c063035dfa47552 +P 816d4749384c7f398912c905a16c83b88f4c55632050b4c6117c61301d1a53e1 +R 19dca2cd3f6ce49e135153d860cdf2bd +U drh +Z 62188313bf6cfe2c21e1198d3cb7d57d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c4650e9df3..506b63edcf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -816d4749384c7f398912c905a16c83b88f4c55632050b4c6117c61301d1a53e1 \ No newline at end of file +4ba8be544711e07748e8dd3ca6b81f9897906061c0a1a1bb4fb3808dc27f734b \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 5465dc953b..7bb2fc643f 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -101,7 +101,12 @@ static int allowedOp(int op){ assert( TK_LT>TK_EQ && TK_LTTK_EQ && TK_LE=TK_EQ && op<=TK_GE) || op==TK_ISNULL || op==TK_IS; + assert( TK_INTK_GE ) return 0; + if( op>=TK_EQ ) return 1; + return op==TK_IN || op==TK_ISNULL || op==TK_IS; } /* From 48f5e527283d1f8a3811bd157a15d1ae34ad03d7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 6 Jun 2024 01:00:50 +0000 Subject: [PATCH 0471/1030] Small performance optimization in the operatorMask routine of the WHERE clause analysis logic. FossilOrigin-Name: 9d69fc1c87ae673356869ecd89eb19734fd126702c0f9fe595336ecd7be89e08 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 11 ++++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 1062c51e50..4e7f7a5c77 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\sperformance\soptimization\sin\sthe\sallowedOp()\sroutine\sof\sthe\sWHERE\nclause\sanalysis\scode. -D 2024-06-06T00:49:36.480 +C Small\sperformance\soptimization\sin\sthe\soperatorMask\sroutine\sof\sthe\sWHERE\nclause\sanalysis\slogic. +D 2024-06-06T01:00:50.319 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -843,7 +843,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 343e74d65856665f2aac59a9fcefecfc988e9af4aafa0bd1b8332a89c6c725b4 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c -F src/whereexpr.c 6410cd2cd4f2d97c5c14bdd38650f0da712e75077d2014beff9a0bca93e2b893 +F src/whereexpr.c 52a59e9252d5823ce2214093ad137af6e3b793d11d76491c41d9a3bac5eb591a F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 816d4749384c7f398912c905a16c83b88f4c55632050b4c6117c61301d1a53e1 -R 19dca2cd3f6ce49e135153d860cdf2bd +P 4ba8be544711e07748e8dd3ca6b81f9897906061c0a1a1bb4fb3808dc27f734b +R b3146f257e797db20c45e271ef1b262b U drh -Z 62188313bf6cfe2c21e1198d3cb7d57d +Z a340deed3f1e0f0688e4671428f60e91 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 506b63edcf..d88412a96b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ba8be544711e07748e8dd3ca6b81f9897906061c0a1a1bb4fb3808dc27f734b \ No newline at end of file +9d69fc1c87ae673356869ecd89eb19734fd126702c0f9fe595336ecd7be89e08 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 7bb2fc643f..41d6ac9f04 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -139,15 +139,16 @@ static u16 exprCommute(Parse *pParse, Expr *pExpr){ static u16 operatorMask(int op){ u16 c; assert( allowedOp(op) ); - if( op==TK_IN ){ + if( op>=TK_EQ ){ + assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff ); + c = (u16)(WO_EQ<<(op-TK_EQ)); + }else if( op==TK_IN ){ c = WO_IN; }else if( op==TK_ISNULL ){ c = WO_ISNULL; - }else if( op==TK_IS ){ - c = WO_IS; }else{ - assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff ); - c = (u16)(WO_EQ<<(op-TK_EQ)); + assert( op==TK_IS ); + c = WO_IS; } assert( op!=TK_ISNULL || c==WO_ISNULL ); assert( op!=TK_IN || c==WO_IN ); From fd6beda14be03cb0236a853128fa1cae8373eea3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 6 Jun 2024 01:21:57 +0000 Subject: [PATCH 0472/1030] Adjust the parser so that the value of TK_ISNOT is similar to the value of TK_IS. This helps the compiler generate faster switch() statements on the Expr.op fields when there are cases for TK_ISNOT and other common operators. FossilOrigin-Name: 34f05c3d89b2dd15e4b0d1ba292df7de3dfc54b505c0ba145cc3db52cf020845 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/parse.y | 6 ++++-- src/whereexpr.c | 7 +++++++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 4e7f7a5c77..1c2bc9f940 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\sperformance\soptimization\sin\sthe\soperatorMask\sroutine\sof\sthe\sWHERE\nclause\sanalysis\slogic. -D 2024-06-06T01:00:50.319 +C Adjust\sthe\sparser\sso\sthat\sthe\svalue\sof\sTK_ISNOT\sis\ssimilar\sto\sthe\svalue\sof\nTK_IS.\s\sThis\shelps\sthe\scompiler\sgenerate\sfaster\sswitch()\sstatements\son\sthe\nExpr.op\sfields\swhen\sthere\sare\scases\sfor\sTK_ISNOT\sand\sother\scommon\soperators. +D 2024-06-06T01:21:57.656 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -744,7 +744,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y de2da0ffd33f6532c1640e7c6a6c6d8ac5ae85b0dbb0b1d7c3194d243a4c1e6a +F src/parse.y 2bd540b3b1e79017eb41fca2396633a75e7dd430c05383c61fe52c6f4e97c6d8 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 @@ -843,7 +843,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 343e74d65856665f2aac59a9fcefecfc988e9af4aafa0bd1b8332a89c6c725b4 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c -F src/whereexpr.c 52a59e9252d5823ce2214093ad137af6e3b793d11d76491c41d9a3bac5eb591a +F src/whereexpr.c 66179e471119281a9073f836371ba3126de8d88f4c6bb71dec977058cc18d401 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4ba8be544711e07748e8dd3ca6b81f9897906061c0a1a1bb4fb3808dc27f734b -R b3146f257e797db20c45e271ef1b262b +P 9d69fc1c87ae673356869ecd89eb19734fd126702c0f9fe595336ecd7be89e08 +R 1f0dfeb1d1dd8a03591de2f7c0e39183 U drh -Z a340deed3f1e0f0688e4671428f60e91 +Z 36e5fa08b5b155e1eda8146da989c018 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d88412a96b..401127936d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d69fc1c87ae673356869ecd89eb19734fd126702c0f9fe595336ecd7be89e08 \ No newline at end of file +34f05c3d89b2dd15e4b0d1ba292df7de3dfc54b505c0ba145cc3db52cf020845 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 90277f9c0c..de8282e81f 100644 --- a/src/parse.y +++ b/src/parse.y @@ -236,11 +236,13 @@ columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,A,Y);} // improve performance and reduce the executable size. The goal here is // to get the "jump" operations in ISNULL through ESCAPE to have numeric // values that are early enough so that all jump operations are clustered -// at the beginning. +// at the beginning. Also, operators like NE and EQ need to be adjacent, +// and all of the comparison operators need to be clustered together. +// Various assert() statements throughout the code enforce these restrictions. // %token ABORT ACTION AFTER ANALYZE ASC ATTACH BEFORE BEGIN BY CASCADE CAST. %token CONFLICT DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL. -%token OR AND NOT IS MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ. +%token OR AND NOT IS ISNOT MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ. %token GT LE LT GE ESCAPE. // The following directive causes tokens ABORT, AFTER, ASC, etc. to diff --git a/src/whereexpr.c b/src/whereexpr.c index 41d6ac9f04..ae1c838c0d 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -435,6 +435,13 @@ static int isAuxiliaryVtabOperator( } } } + }else if( pExpr->op>=TK_EQ ){ + /* Comparison operators are a common case. Save a few comparisons for + ** that common case by terminating early. */ + assert( TK_NE < TK_EQ ); + assert( TK_ISNOT < TK_EQ ); + assert( TK_NOTNULL < TK_EQ ); + return 0; }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){ int res = 0; Expr *pLeft = pExpr->pLeft; From 404ddadbd421fd3754cab1a3e90bb2dd74467fbd Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 6 Jun 2024 12:22:19 +0000 Subject: [PATCH 0473/1030] Re-enable [dcc2bb2c562e97e090174], as [296eeb26c816bc73] corrects the wasi-sdk build problem the former check-in triggered. Reported in [forum:143e40d7f4e79c66|forum post 143e40d7f4e79c66]. FossilOrigin-Name: f66608bd356efe492d1003663c2e1ccd7cfbf2d40393d256f8720149904ad2d5 --- manifest | 15 ++++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 2 -- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1c2bc9f940..6f0e3724bc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sthe\sparser\sso\sthat\sthe\svalue\sof\sTK_ISNOT\sis\ssimilar\sto\sthe\svalue\sof\nTK_IS.\s\sThis\shelps\sthe\scompiler\sgenerate\sfaster\sswitch()\sstatements\son\sthe\nExpr.op\sfields\swhen\sthere\sare\scases\sfor\sTK_ISNOT\sand\sother\scommon\soperators. -D 2024-06-06T01:21:57.656 +C Re-enable\s[dcc2bb2c562e97e090174],\sas\s[296eeb26c816bc73]\scorrects\sthe\swasi-sdk\sbuild\sproblem\sthe\sformer\scheck-in\striggered.\sReported\sin\s[forum:143e40d7f4e79c66|forum\spost\s143e40d7f4e79c66]. +D 2024-06-06T12:22:19.122 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -757,7 +757,7 @@ F src/resolve.c ae341d04d39de308e024649d6777dd015b6a94ddbfbe74d7fca2ee122fb1aea9 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 3b818d1b476c7108fdbbf6853c92fe4a933940474c77546f812e14f8aa2be03d F src/shell.c.in 134db38064e038b6d3aec968a4a3eb302141b043808922961e34b333de1cff21 -F src/sqlite.h.in 892d0c427608ad7128a0fe44e972d6c4197225f5077f64f07792ffa44c6ecd77 +F src/sqlite.h.in cbd3e4177791a61c056fd81e37a5b21bb6c8cb2ea8cac558c625974673f50acf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h d66a1eab63dea318ad3f56df2b4d8c70ee9143aff25fbb1423c8234d6cf37787 @@ -2194,8 +2194,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9d69fc1c87ae673356869ecd89eb19734fd126702c0f9fe595336ecd7be89e08 -R 1f0dfeb1d1dd8a03591de2f7c0e39183 -U drh -Z 36e5fa08b5b155e1eda8146da989c018 +P 34f05c3d89b2dd15e4b0d1ba292df7de3dfc54b505c0ba145cc3db52cf020845 +Q +dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 +R f53e51c0f1aa91444bc8abb22e670610 +U stephan +Z eae0132379a01c18b0ddde39b41ec6d7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 401127936d..ae3efac03f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -34f05c3d89b2dd15e4b0d1ba292df7de3dfc54b505c0ba145cc3db52cf020845 \ No newline at end of file +f66608bd356efe492d1003663c2e1ccd7cfbf2d40393d256f8720149904ad2d5 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ae82088423..8cca648367 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -10832,8 +10832,6 @@ int sqlite3_deserialize( #if defined(__wasi__) # undef SQLITE_WASI # define SQLITE_WASI 1 -# undef SQLITE_OMIT_WAL -# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */ # ifndef SQLITE_OMIT_LOAD_EXTENSION # define SQLITE_OMIT_LOAD_EXTENSION # endif From 4703b7d0921291f96bb53a45f4ab49b99bfbd33c Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 6 Jun 2024 15:03:16 +0000 Subject: [PATCH 0474/1030] Better optimize queries that use parameters in the LIMIT clause. FossilOrigin-Name: e58cb304d1e0ec6e30260a165aaccc2cf096ce6c999efb06683c4ef600ee12ef --- manifest | 35 +++++++++++----------- manifest.uuid | 2 +- src/expr.c | 30 +++++++++++++++++-- src/resolve.c | 6 ++-- src/select.c | 4 +-- src/shell.c.in | 2 ++ src/sqliteInt.h | 2 +- src/where.c | 2 +- src/whereexpr.c | 2 +- src/window.c | 2 +- test/wherelimit2.test | 31 ++++++++++++++++++++ test/wherelimit3.test | 67 +++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 156 insertions(+), 29 deletions(-) create mode 100644 test/wherelimit3.test diff --git a/manifest b/manifest index 6f0e3724bc..994b8d39fa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Re-enable\s[dcc2bb2c562e97e090174],\sas\s[296eeb26c816bc73]\scorrects\sthe\swasi-sdk\sbuild\sproblem\sthe\sformer\scheck-in\striggered.\sReported\sin\s[forum:143e40d7f4e79c66|forum\spost\s143e40d7f4e79c66]. -D 2024-06-06T12:22:19.122 +C Better\soptimize\squeries\sthat\suse\sparameters\sin\sthe\sLIMIT\sclause. +D 2024-06-06T15:03:16.778 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 585109ab97149b2d484697e7469f28c91d495cd1330cc760d24711b7be8d22fb +F src/expr.c af9c9242be0df17280faf36c9810339de9df3d7a64ac8d33a5190a1400086ee5 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c f1f57c6863c1380f31ecf3d61732495bfff847a8e35a832c7e306e310db5a799 @@ -753,14 +753,14 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c ae341d04d39de308e024649d6777dd015b6a94ddbfbe74d7fca2ee122fb1aea9 +F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 3b818d1b476c7108fdbbf6853c92fe4a933940474c77546f812e14f8aa2be03d -F src/shell.c.in 134db38064e038b6d3aec968a4a3eb302141b043808922961e34b333de1cff21 +F src/select.c ea0b75fce45e1f2c22f50ed2b6e2ddd7f66640948d0fc79a397917b4236a74af +F src/shell.c.in 77d12a0dab8724819e64a14d5fbaad91a934be2b22ad329708fba9ba78993f04 F src/sqlite.h.in cbd3e4177791a61c056fd81e37a5b21bb6c8cb2ea8cac558c625974673f50acf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h d66a1eab63dea318ad3f56df2b4d8c70ee9143aff25fbb1423c8234d6cf37787 +F src/sqliteInt.h 0fec1cf17d9e4c93baf29bf74b7d03de9425299443d4abd6989a004d6eb53b60 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -840,11 +840,11 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 343e74d65856665f2aac59a9fcefecfc988e9af4aafa0bd1b8332a89c6c725b4 +F src/where.c c93a38b97ea1a953500c383040228d3b2a89fcf69afd0be2365e01bdbc0699bd F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c -F src/whereexpr.c 66179e471119281a9073f836371ba3126de8d88f4c6bb71dec977058cc18d401 -F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2 +F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 +F src/window.c 1e40ffc509bae21e466f6106382d238e91eb73edd4ba10e66ca4fd7af2b96896 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 F test/affinity3.test f094773025eddf31135c7ad4cde722b7696f8eb07b97511f98585addf2a510a9 @@ -2031,7 +2031,8 @@ F test/whereN.test 63a3584b71acfb6963416de82f26c6b1644abc5ca6080c76546b9246734c8 F test/wherefault.test 6cf2a9c5712952d463d3f45ebee7f6caf400984df51a195d884cfb7eb0e837a7 F test/wherelfault.test 9012e4ef5259058b771606616bd007af5d154e64cc25fa9fd4170f6411db44e3 F test/wherelimit.test afb46397c6d7e964e6e294ba3569864a0c570fe3807afc634236c2b752372f31 -F test/wherelimit2.test b9e4bfe7b4d7c2f85f99cf2bd2c51369378d04b1f3d1b60557423752003bfd90 +F test/wherelimit2.test 45051faca87204e00d999a3282eeea4263d7a7eb7a063c2fb9096e1ef359e9c5 +F test/wherelimit3.test 22d73e046870cf8bbe15573eda6b432b07ebe64a88711f9f849c6b3667c1fae6 F test/widetab1.test c296a98e123762de79917350e45fa33fdf88577a2571eb3a64c8bf7e44ef74d1 F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2aeee74 F test/win32lock.test e0924eb8daac02bf80e9da88930747bd44dd9b230b7759fed927b1655b467c9c @@ -2194,9 +2195,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 34f05c3d89b2dd15e4b0d1ba292df7de3dfc54b505c0ba145cc3db52cf020845 -Q +dcc2bb2c562e97e090174d4d0970bfa1551e5eb4db022e6d232c4dd786818e45 -R f53e51c0f1aa91444bc8abb22e670610 -U stephan -Z eae0132379a01c18b0ddde39b41ec6d7 +P f66608bd356efe492d1003663c2e1ccd7cfbf2d40393d256f8720149904ad2d5 +R 925869cddd08d7fffc1c9ed1ac68c360 +T *branch * var-in-limit +T *sym-var-in-limit * +T -sym-trunk * +U drh +Z 69f66afa464bc68dae7849bd1467273b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ae3efac03f..be3cbd5266 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f66608bd356efe492d1003663c2e1ccd7cfbf2d40393d256f8720149904ad2d5 \ No newline at end of file +e58cb304d1e0ec6e30260a165aaccc2cf096ce6c999efb06683c4ef600ee12ef \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 4bab383635..bda91df83d 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2789,8 +2789,12 @@ int sqlite3ExprContainsSubquery(Expr *p){ ** to fit in a 32-bit integer, return 1 and put the value of the integer ** in *pValue. If the expression is not an integer or if it is too big ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. +** +** If the pParse pointer is provided, then allow the expression p to be +** a parameter (TK_VARIABLE) that is bound to an integer. +** But if pParse is NULL, then p must be a pure integer literal. */ -int sqlite3ExprIsInteger(const Expr *p, int *pValue){ +int sqlite3ExprIsInteger(const Expr *p, int *pValue, Parse *pParse){ int rc = 0; if( NEVER(p==0) ) return 0; /* Used to only happen following on OOM */ @@ -2805,18 +2809,38 @@ int sqlite3ExprIsInteger(const Expr *p, int *pValue){ } switch( p->op ){ case TK_UPLUS: { - rc = sqlite3ExprIsInteger(p->pLeft, pValue); + rc = sqlite3ExprIsInteger(p->pLeft, pValue, 0); break; } case TK_UMINUS: { int v = 0; - if( sqlite3ExprIsInteger(p->pLeft, &v) ){ + if( sqlite3ExprIsInteger(p->pLeft, &v, 0) ){ assert( ((unsigned int)v)!=0x80000000 ); *pValue = -v; rc = 1; } break; } + case TK_VARIABLE: { + sqlite3_value *pVal; + if( pParse==0 ) break; + if( NEVER(pParse->pVdbe==0) ) break; + if( (pParse->db->flags & SQLITE_EnableQPSG)!=0 ) break; + sqlite3VdbeSetVarmask(pParse->pVdbe, p->iColumn); + pVal = sqlite3VdbeGetBoundValue(pParse->pReprepare, p->iColumn, + SQLITE_AFF_BLOB); + if( pVal ){ + if( sqlite3_value_type(pVal)==SQLITE_INTEGER ){ + sqlite3_int64 vv = sqlite3_value_int64(pVal); + if( vv == (vv & 0x7fffffff) ){ /* non-negative numbers only */ + *pValue = (int)vv; + rc = 1; + } + } + sqlite3ValueFree(pVal); + } + break; + } default: break; } return rc; diff --git a/src/resolve.c b/src/resolve.c index 40044a2204..d5c1515a74 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1505,7 +1505,7 @@ static int resolveOrderByTermToExprList( int rc; /* Return code from subprocedures */ u8 savedSuppErr; /* Saved value of db->suppressErr */ - assert( sqlite3ExprIsInteger(pE, &i)==0 ); + assert( sqlite3ExprIsInteger(pE, &i, 0)==0 ); pEList = pSelect->pEList; /* Resolve all names in the ORDER BY term expression @@ -1604,7 +1604,7 @@ static int resolveCompoundOrderBy( if( pItem->fg.done ) continue; pE = sqlite3ExprSkipCollateAndLikely(pItem->pExpr); if( NEVER(pE==0) ) continue; - if( sqlite3ExprIsInteger(pE, &iCol) ){ + if( sqlite3ExprIsInteger(pE, &iCol, 0) ){ if( iCol<=0 || iCol>pEList->nExpr ){ resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr, pE); return 1; @@ -1789,7 +1789,7 @@ static int resolveOrderGroupBy( continue; } } - if( sqlite3ExprIsInteger(pE2, &iCol) ){ + if( sqlite3ExprIsInteger(pE2, &iCol, 0) ){ /* The ORDER BY term is an integer constant. Again, set the column ** number so that sqlite3ResolveOrderGroupBy() will convert the ** order-by term to a copy of the result-set expression */ diff --git a/src/select.c b/src/select.c index 4671dfa6d8..9a0f2e40f5 100644 --- a/src/select.c +++ b/src/select.c @@ -2492,7 +2492,7 @@ static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){ p->iLimit = iLimit = ++pParse->nMem; v = sqlite3GetVdbe(pParse); assert( v!=0 ); - if( sqlite3ExprIsInteger(pLimit->pLeft, &n) ){ + if( sqlite3ExprIsInteger(pLimit->pLeft, &n, pParse) ){ sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit); VdbeComment((v, "LIMIT counter")); if( n==0 ){ @@ -2972,7 +2972,7 @@ static int multiSelect( p->pPrior = pPrior; p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow); if( p->pLimit - && sqlite3ExprIsInteger(p->pLimit->pLeft, &nLimit) + && sqlite3ExprIsInteger(p->pLimit->pLeft, &nLimit, pParse) && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) ){ p->nSelectRow = sqlite3LogEst((u64)nLimit); diff --git a/src/shell.c.in b/src/shell.c.in index 5461071389..a664e2cbc5 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4253,6 +4253,7 @@ static int shell_exec( sqlite3_reset(pExplain); rc = sqlite3_stmt_explain(pExplain, 2); if( rc==SQLITE_OK ){ + bind_prepared_stmt(pArg, pExplain); while( sqlite3_step(pExplain)==SQLITE_ROW ){ const char *zEQPLine = (const char*)sqlite3_column_text(pExplain,3); int iEqpId = sqlite3_column_int(pExplain, 0); @@ -4270,6 +4271,7 @@ static int shell_exec( if( rc==SQLITE_OK ){ pArg->cMode = MODE_Explain; assert( sqlite3_stmt_isexplain(pExplain)==1 ); + bind_prepared_stmt(pArg, pExplain); explain_data_prepare(pArg, pExplain); exec_prepared_stmt(pArg, pExplain); explain_data_delete(pArg); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 7d313e408a..8866b69ea5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -5088,7 +5088,7 @@ int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int,int); #ifdef SQLITE_ENABLE_CURSOR_HINTS int sqlite3ExprContainsSubquery(Expr*); #endif -int sqlite3ExprIsInteger(const Expr*, int*); +int sqlite3ExprIsInteger(const Expr*, int*, Parse*); int sqlite3ExprCanBeNull(const Expr*); int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); int sqlite3IsRowid(const char*); diff --git a/src/where.c b/src/where.c index 71a8241e35..a5cf63d713 100644 --- a/src/where.c +++ b/src/where.c @@ -2942,7 +2942,7 @@ static void whereLoopOutputAdjust( Expr *pRight = pTerm->pExpr->pRight; int k = 0; testcase( pTerm->pExpr->op==TK_IS ); - if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){ + if( sqlite3ExprIsInteger(pRight, &k, 0) && k>=(-1) && k<=1 ){ k = 10; }else{ k = 20; diff --git a/src/whereexpr.c b/src/whereexpr.c index ae1c838c0d..dcda75d264 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1583,7 +1583,7 @@ static void whereAddLimitExpr( Expr *pNew; int iVal = 0; - if( sqlite3ExprIsInteger(pExpr, &iVal) && iVal>=0 ){ + if( sqlite3ExprIsInteger(pExpr, &iVal, pParse) && iVal>=0 ){ Expr *pVal = sqlite3Expr(db, TK_INTEGER, 0); if( pVal==0 ) return; ExprSetProperty(pVal, EP_IntValue); diff --git a/src/window.c b/src/window.c index bcee65d924..e5a78e37d2 100644 --- a/src/window.c +++ b/src/window.c @@ -909,7 +909,7 @@ static ExprList *exprListAppendList( int iDummy; Expr *pSub; pSub = sqlite3ExprSkipCollateAndLikely(pDup); - if( sqlite3ExprIsInteger(pSub, &iDummy) ){ + if( sqlite3ExprIsInteger(pSub, &iDummy, 0) ){ pSub->op = TK_NULL; pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse); pSub->u.zToken = 0; diff --git a/test/wherelimit2.test b/test/wherelimit2.test index 57288bf64c..a8017f3c96 100644 --- a/test/wherelimit2.test +++ b/test/wherelimit2.test @@ -330,4 +330,35 @@ do_execsql_test 7.2 { SELECT * FROM t1; } {3} +# 2024-06-06 +# Use LIMIT if the argument is a variable. +# +reset_db +do_execsql_test 8.0 { + CREATE TABLE t1(a INT, b INT); + WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<1000) + INSERT INTO t1 SELECT n, n FROM c; + CREATE INDEX t1a ON t1(a); + CREATE INDEX t1b ON t1(b); + ANALYZE; +} +do_eqp_test 8.1 { + SELECT * FROM t1 WHERE a>=100 AND b<300 ORDER BY b LIMIT 5; +} { + QUERY PLAN + |--SEARCH t1 USING INDEX t1a (a>? AND a=100 AND b<300 ORDER BY b LIMIT -1; +} { + QUERY PLAN + |--SEARCH t1 USING INDEX t1a (a>? AND a=100 AND a<300 ORDER BY b LIMIT 5; +} { + QUERY PLAN + |--SEARCH t1 USING INDEX t1a (a>? AND a=100 AND a<300 ORDER BY b LIMIT -1; + } { + QUERY PLAN + `--SCAN t1 USING INDEX t1b + } +} + +set N [expr 5] +do_eqp_test 1.3 { + SELECT * FROM t1 WHERE a>=100 AND a<300 ORDER BY b LIMIT $::N; +} { + QUERY PLAN + |--SEARCH t1 USING INDEX t1a (a>? AND a=100 AND a<300 ORDER BY b LIMIT $::N; + } { + QUERY PLAN + `--SCAN t1 USING INDEX t1b + } +} + + + + + +finish_test From bd1402487b5e2efcf8d7efa439ab070cee8f8ee2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 6 Jun 2024 23:22:32 +0000 Subject: [PATCH 0475/1030] Omit bogus tests accidentally added by the privious commit. FossilOrigin-Name: e94dfe9928750dd98145d4d9920b298f7b0868703b487f86e0db77a41d53ccf9 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/wherelimit2.test | 31 ------------------------------- 3 files changed, 7 insertions(+), 41 deletions(-) diff --git a/manifest b/manifest index 994b8d39fa..96df2cce21 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Better\soptimize\squeries\sthat\suse\sparameters\sin\sthe\sLIMIT\sclause. -D 2024-06-06T15:03:16.778 +C Omit\sbogus\stests\saccidentally\sadded\sby\sthe\sprivious\scommit. +D 2024-06-06T23:22:32.539 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2031,7 +2031,7 @@ F test/whereN.test 63a3584b71acfb6963416de82f26c6b1644abc5ca6080c76546b9246734c8 F test/wherefault.test 6cf2a9c5712952d463d3f45ebee7f6caf400984df51a195d884cfb7eb0e837a7 F test/wherelfault.test 9012e4ef5259058b771606616bd007af5d154e64cc25fa9fd4170f6411db44e3 F test/wherelimit.test afb46397c6d7e964e6e294ba3569864a0c570fe3807afc634236c2b752372f31 -F test/wherelimit2.test 45051faca87204e00d999a3282eeea4263d7a7eb7a063c2fb9096e1ef359e9c5 +F test/wherelimit2.test b9e4bfe7b4d7c2f85f99cf2bd2c51369378d04b1f3d1b60557423752003bfd90 F test/wherelimit3.test 22d73e046870cf8bbe15573eda6b432b07ebe64a88711f9f849c6b3667c1fae6 F test/widetab1.test c296a98e123762de79917350e45fa33fdf88577a2571eb3a64c8bf7e44ef74d1 F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2aeee74 @@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f66608bd356efe492d1003663c2e1ccd7cfbf2d40393d256f8720149904ad2d5 -R 925869cddd08d7fffc1c9ed1ac68c360 -T *branch * var-in-limit -T *sym-var-in-limit * -T -sym-trunk * +P e58cb304d1e0ec6e30260a165aaccc2cf096ce6c999efb06683c4ef600ee12ef +R f3d6aba1cc68a2224dd6f7df935a2c23 U drh -Z 69f66afa464bc68dae7849bd1467273b +Z e624ae0f33850da22aad0ef54cd48e89 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index be3cbd5266..2d14883308 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e58cb304d1e0ec6e30260a165aaccc2cf096ce6c999efb06683c4ef600ee12ef \ No newline at end of file +e94dfe9928750dd98145d4d9920b298f7b0868703b487f86e0db77a41d53ccf9 \ No newline at end of file diff --git a/test/wherelimit2.test b/test/wherelimit2.test index a8017f3c96..57288bf64c 100644 --- a/test/wherelimit2.test +++ b/test/wherelimit2.test @@ -330,35 +330,4 @@ do_execsql_test 7.2 { SELECT * FROM t1; } {3} -# 2024-06-06 -# Use LIMIT if the argument is a variable. -# -reset_db -do_execsql_test 8.0 { - CREATE TABLE t1(a INT, b INT); - WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<1000) - INSERT INTO t1 SELECT n, n FROM c; - CREATE INDEX t1a ON t1(a); - CREATE INDEX t1b ON t1(b); - ANALYZE; -} -do_eqp_test 8.1 { - SELECT * FROM t1 WHERE a>=100 AND b<300 ORDER BY b LIMIT 5; -} { - QUERY PLAN - |--SEARCH t1 USING INDEX t1a (a>? AND a=100 AND b<300 ORDER BY b LIMIT -1; -} { - QUERY PLAN - |--SEARCH t1 USING INDEX t1a (a>? AND a Date: Sun, 9 Jun 2024 17:34:03 +0000 Subject: [PATCH 0476/1030] Disable the omit-noop-join optimization when there are 64 or more terms in the ORDER BY clause. FossilOrigin-Name: 40de3939792e17df25598b3e60d1cebcecde2b00832acd55604f14b21398a9a7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- src/where.c | 13 +++++++++---- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index f28f11b60c..eadf2cd345 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sthe\squery\splanner\saccess\sto\sthe\sargument\sof\sLIMIT\seven\sif\sthat\nargument\sis\sa\sbound\sparameter. -D 2024-06-06T23:56:36.923 +C Disable\sthe\somit-noop-join\soptimization\swhen\sthere\sare\s64\sor\smore\sterms\sin\nthe\sORDER\sBY\sclause. +D 2024-06-09T17:34:03.640 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/shell.c.in 77d12a0dab8724819e64a14d5fbaad91a934be2b22ad329708fba9ba78993f0 F src/sqlite.h.in cbd3e4177791a61c056fd81e37a5b21bb6c8cb2ea8cac558c625974673f50acf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 0fec1cf17d9e4c93baf29bf74b7d03de9425299443d4abd6989a004d6eb53b60 +F src/sqliteInt.h af50738edf6a6cf9aa974b98d75bd0cedce607948dd10885ac6ae6cf5abae23c F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c c93a38b97ea1a953500c383040228d3b2a89fcf69afd0be2365e01bdbc0699bd +F src/where.c 94c2ae6c3ef6173492c9b400635fca8f04316cf6bea8face1d425753aba31b85 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f66608bd356efe492d1003663c2e1ccd7cfbf2d40393d256f8720149904ad2d5 e94dfe9928750dd98145d4d9920b298f7b0868703b487f86e0db77a41d53ccf9 -R f3d6aba1cc68a2224dd6f7df935a2c23 +P c4a9dda2809c6e0e3d928e11e5553ead82cd9df551bcd35b11a7d869ef80ab8e +R 3c43b2ce12f159be8c966958fcb4055b U drh -Z b92cbf17475d91065d48b9fdd285839c +Z a3915588a6885a87c7d5fcd05fe5cf89 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a310670ce9..e6ead87e19 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c4a9dda2809c6e0e3d928e11e5553ead82cd9df551bcd35b11a7d869ef80ab8e \ No newline at end of file +40de3939792e17df25598b3e60d1cebcecde2b00832acd55604f14b21398a9a7 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8866b69ea5..69aeadb34b 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3388,7 +3388,7 @@ struct SrcList { #define WHERE_AGG_DISTINCT 0x0400 /* Query is "SELECT agg(DISTINCT ...)" */ #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ #define WHERE_RIGHT_JOIN 0x1000 /* Processing a RIGHT JOIN */ - /* 0x2000 not currently used */ +#define WHERE_KEEP_ALL_JOINS 0x2000 /* Do not do the omit-noop-join opt */ #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */ /* 0x8000 not currently used */ diff --git a/src/where.c b/src/where.c index a5cf63d713..4b9ee2c43b 100644 --- a/src/where.c +++ b/src/where.c @@ -6018,6 +6018,10 @@ static void showAllWhereLoops(WhereInfo *pWInfo, WhereClause *pWC){ ** the right-most table of a subquery that was flattened into the ** main query and that subquery was the right-hand operand of an ** inner join that held an ON or USING clause. +** 6) The ORDER BY clause has 63 or fewer terms +** 7) The omit-noop-join optimization is enabled. +** +** Items (1), (6), and (7) are checked by the caller. ** ** For example, given: ** @@ -6432,6 +6436,7 @@ WhereInfo *sqlite3WhereBegin( if( pOrderBy && pOrderBy->nExpr>=BMS ){ pOrderBy = 0; wctrlFlags &= ~WHERE_WANT_DISTINCT; + wctrlFlags |= WHERE_KEEP_ALL_JOINS; /* Disable omit-noop-join opt */ } /* The number of tables in the FROM clause is limited by the number of @@ -6732,10 +6737,10 @@ WhereInfo *sqlite3WhereBegin( ** in-line sqlite3WhereCodeOneLoopStart() for performance reasons. */ notReady = ~(Bitmask)0; - if( pWInfo->nLevel>=2 - && pResultSet!=0 /* these two combine to guarantee */ - && 0==(wctrlFlags & WHERE_AGG_DISTINCT) /* condition (1) above */ - && OptimizationEnabled(db, SQLITE_OmitNoopJoin) + if( pWInfo->nLevel>=2 /* Must be a join, or this opt8n is pointless */ + && pResultSet!=0 /* Condition (1) */ + && 0==(wctrlFlags & (WHERE_AGG_DISTINCT|WHERE_KEEP_ALL_JOINS)) /* (1),(6) */ + && OptimizationEnabled(db, SQLITE_OmitNoopJoin) /* (7) */ ){ notReady = whereOmitNoopJoin(pWInfo, notReady); nTabList = pWInfo->nLevel; From 34e4c6f732a6f9f3b702c931627d8af974a3d8eb Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 10 Jun 2024 12:43:03 +0000 Subject: [PATCH 0477/1030] Improved header comment on the sqlite3FpDecode() implementation. For the fpdecode() SQL function (available in debug builds only) limit the value of the third parameter (mxRound) to be positive. FossilOrigin-Name: 56af06fa12104a1fe119d7087746011183af053834eac72d0fb69f60d98054c6 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 1 + src/util.c | 13 +++++++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index eadf2cd345..074d16815b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\somit-noop-join\soptimization\swhen\sthere\sare\s64\sor\smore\sterms\sin\nthe\sORDER\sBY\sclause. -D 2024-06-09T17:34:03.640 +C Improved\sheader\scomment\son\sthe\ssqlite3FpDecode()\simplementation.\nFor\sthe\sfpdecode()\sSQL\sfunction\s(available\sin\sdebug\sbuilds\sonly)\slimit\nthe\svalue\sof\sthe\sthird\sparameter\s(mxRound)\sto\sbe\spositive. +D 2024-06-10T12:43:03.794 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -708,7 +708,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c af9c9242be0df17280faf36c9810339de9df3d7a64ac8d33a5190a1400086ee5 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a -F src/func.c f1f57c6863c1380f31ecf3d61732495bfff847a8e35a832c7e306e310db5a799 +F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -823,7 +823,7 @@ F src/trigger.c 0858f75818ed1580332db274f1032bcc5effe567cb132df5c5be8b1d800ca97f F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e -F src/util.c 4d6d7ebfe6772a1b950c97bbb1d1a72ad4874617ec498ab8aa73b7f5a43e44bb +F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c b05777c3ff2ed7b9dfc347e7cdee18e371aa6811cef1fe83454691b0dbe2cc9f F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c4a9dda2809c6e0e3d928e11e5553ead82cd9df551bcd35b11a7d869ef80ab8e -R 3c43b2ce12f159be8c966958fcb4055b +P 40de3939792e17df25598b3e60d1cebcecde2b00832acd55604f14b21398a9a7 +R 3798b5dfb33f66d6cffbf2ab99073009 U drh -Z a3915588a6885a87c7d5fcd05fe5cf89 +Z 6cba9a77bc527574a7f08d08f1d8739d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e6ead87e19..d58d474cbf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -40de3939792e17df25598b3e60d1cebcecde2b00832acd55604f14b21398a9a7 \ No newline at end of file +56af06fa12104a1fe119d7087746011183af053834eac72d0fb69f60d98054c6 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 058f71cb64..8fcda11dc0 100644 --- a/src/func.c +++ b/src/func.c @@ -2547,6 +2547,7 @@ static void fpdecodeFunc( x = sqlite3_value_double(argv[0]); y = sqlite3_value_int(argv[1]); z = sqlite3_value_int(argv[2]); + if( z<=0 ) z = 1; sqlite3FpDecode(&s, x, y, z); if( s.isSpecial==2 ){ sqlite3_snprintf(sizeof(zBuf), zBuf, "NaN"); diff --git a/src/util.c b/src/util.c index 3b10ba60ad..0cebb474a2 100644 --- a/src/util.c +++ b/src/util.c @@ -1015,10 +1015,13 @@ int sqlite3Atoi(const char *z){ ** Decode a floating-point value into an approximate decimal ** representation. ** -** Round the decimal representation to n significant digits if -** n is positive. Or round to -n signficant digits after the -** decimal point if n is negative. No rounding is performed if -** n is zero. +** If iRound<=0 then round to -iRound significant digits to the +** the left of the decimal point, or to a maximum of mxRound total +** significant digits. +** +** If iRound>0 round to min(iRound,mxRound) significant digits total. +** +** mxRound must be positive. ** ** The significant digits of the decimal representation are ** stored in p->z[] which is a often (but not always) a pointer @@ -1032,6 +1035,8 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ p->isSpecial = 0; p->z = p->zBuf; + assert( mxRound>0 ); + /* Convert negative numbers to positive. Deal with Infinity, 0.0, and ** NaN. */ if( r<0.0 ){ From 941602ae4fc7a68464882601f2f64d2385e32da9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 11 Jun 2024 14:36:56 +0000 Subject: [PATCH 0478/1030] Change constant expressions to pre-computed constants, because apparently MSVC on ARM requires that. [forum:/forumpost/4feb1685cced0a8e|Forum thread 4feb1685cced0a8e]. FossilOrigin-Name: 6c103aee6f146869a3e0c48694592f2e4c6b57ecdb4450f46e762c38b4e686f1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/date.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 074d16815b..13e49b6582 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sheader\scomment\son\sthe\ssqlite3FpDecode()\simplementation.\nFor\sthe\sfpdecode()\sSQL\sfunction\s(available\sin\sdebug\sbuilds\sonly)\slimit\nthe\svalue\sof\sthe\sthird\sparameter\s(mxRound)\sto\sbe\spositive. -D 2024-06-10T12:43:03.794 +C Change\sconstant\sexpressions\sto\spre-computed\sconstants,\sbecause\sapparently\nMSVC\son\sARM\srequires\sthat.\n[forum:/forumpost/4feb1685cced0a8e|Forum\sthread\s4feb1685cced0a8e]. +D 2024-06-11T14:36:56.096 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -701,7 +701,7 @@ F src/build.c 237ccc0290d131d646be722f418e92ee0a38043aee25e7dfdc75f8ce5b3abe4e F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 -F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875 +F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 40de3939792e17df25598b3e60d1cebcecde2b00832acd55604f14b21398a9a7 -R 3798b5dfb33f66d6cffbf2ab99073009 +P 56af06fa12104a1fe119d7087746011183af053834eac72d0fb69f60d98054c6 +R def5b52c86a78dc0bf7da94cc7c4fd06 U drh -Z 6cba9a77bc527574a7f08d08f1d8739d +Z d6a3d70e7ee8f5966f522c6fcbcbe498 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d58d474cbf..227fbc4795 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -56af06fa12104a1fe119d7087746011183af053834eac72d0fb69f60d98054c6 \ No newline at end of file +6c103aee6f146869a3e0c48694592f2e4c6b57ecdb4450f46e762c38b4e686f1 \ No newline at end of file diff --git a/src/date.c b/src/date.c index d74cecb1d9..8a609ae3cc 100644 --- a/src/date.c +++ b/src/date.c @@ -667,8 +667,8 @@ static const struct { /* 1 */ { 6, "minute", 7.7379e+12, 60.0 }, /* 2 */ { 4, "hour", 1.2897e+11, 3600.0 }, /* 3 */ { 3, "day", 5373485.0, 86400.0 }, - /* 4 */ { 5, "month", 176546.0, 30.0*86400.0 }, - /* 5 */ { 4, "year", 14713.0, 365.0*86400.0 }, + /* 4 */ { 5, "month", 176546.0, 2592000.0 }, + /* 5 */ { 4, "year", 14713.0, 31536000.0 }, }; /* From cf2710e0b61dbe5abd3b0017905dfc5cb6c21d8d Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 11 Jun 2024 17:04:02 +0000 Subject: [PATCH 0479/1030] When compiling shell.c in SQLITE_SHELL_FIDDLE mode, ensure that the shell_main_exit goto label is reachable. FossilOrigin-Name: 06e6f64533563ab9c059b773e5f0d78085df716f2624e547b7259f6789c3ffe0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 13e49b6582..939209fa63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sconstant\sexpressions\sto\spre-computed\sconstants,\sbecause\sapparently\nMSVC\son\sARM\srequires\sthat.\n[forum:/forumpost/4feb1685cced0a8e|Forum\sthread\s4feb1685cced0a8e]. -D 2024-06-11T14:36:56.096 +C When\scompiling\sshell.c\sin\sSQLITE_SHELL_FIDDLE\smode,\sensure\sthat\sthe\sshell_main_exit\sgoto\slabel\sis\sreachable. +D 2024-06-11T17:04:02.306 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -756,7 +756,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ea0b75fce45e1f2c22f50ed2b6e2ddd7f66640948d0fc79a397917b4236a74af -F src/shell.c.in 77d12a0dab8724819e64a14d5fbaad91a934be2b22ad329708fba9ba78993f04 +F src/shell.c.in ad27d1d990e9e5fb7ae8fc38a717e91f55233714f59723e5618baf4a2a3d2b65 F src/sqlite.h.in cbd3e4177791a61c056fd81e37a5b21bb6c8cb2ea8cac558c625974673f50acf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 56af06fa12104a1fe119d7087746011183af053834eac72d0fb69f60d98054c6 -R def5b52c86a78dc0bf7da94cc7c4fd06 -U drh -Z d6a3d70e7ee8f5966f522c6fcbcbe498 +P 6c103aee6f146869a3e0c48694592f2e4c6b57ecdb4450f46e762c38b4e686f1 +R 0476a0c13890d8b5c65d486f3c7c6f13 +U stephan +Z 3e50a8e3e5517fc31eec2359fe1a9a43 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 227fbc4795..1e83978cd4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c103aee6f146869a3e0c48694592f2e4c6b57ecdb4450f46e762c38b4e686f1 \ No newline at end of file +06e6f64533563ab9c059b773e5f0d78085df716f2624e547b7259f6789c3ffe0 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index a664e2cbc5..58475dd6da 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -12860,7 +12860,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ (unsigned int)(sqlite3_memory_used()-mem_main_enter)); } #endif -#endif /* !SQLITE_SHELL_FIDDLE */ +#else /* SQLITE_SHELL_FIDDLE... */ + shell_main_exit: +#endif return rc; } From e15d5de0a6e288dd2292b6ff3958cb4390bfe5a4 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 11 Jun 2024 17:04:43 +0000 Subject: [PATCH 0480/1030] Remove some dead JS code and update some JS docs. FossilOrigin-Name: 6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580 --- ext/wasm/api/sqlite3-api-worker1.js | 7 ------ ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 31 +++++++++++---------------- manifest | 14 ++++++------ manifest.uuid | 2 +- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-worker1.js b/ext/wasm/api/sqlite3-api-worker1.js index 2e597613e1..9918625459 100644 --- a/ext/wasm/api/sqlite3-api-worker1.js +++ b/ext/wasm/api/sqlite3-api-worker1.js @@ -571,7 +571,6 @@ sqlite3.initWorker1API = function(){ }); rc.version = sqlite3.version; rc.vfsList = sqlite3.capi.sqlite3_js_vfs_list(); - rc.opfsEnabled = !!sqlite3.opfs; return rc; }, @@ -598,12 +597,6 @@ sqlite3.initWorker1API = function(){ toss: function(ev){ toss("Testing worker exception"); - }, - - 'opfs-tree': async function(ev){ - if(!sqlite3.opfs) toss("OPFS support is unavailable."); - const response = await sqlite3.opfs.treeList(); - return response; } }/*wMsgHandler*/; diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index 4c654c3351..a2ad6ad3ed 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -38,10 +38,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Significant notes and limitations: - - As of this writing, OPFS is still very much in flux and only - available in bleeding-edge versions of Chrome (v102+, noting that - that number will increase as the OPFS API matures). - - The OPFS features used here are only available in dedicated Worker threads. This file tries to detect that case, resulting in a rejected Promise if those features do not seem to be available. @@ -62,15 +58,17 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ The argument may optionally be a plain object with the following configuration options: - - proxyUri: as described above + - proxyUri: name of the async proxy JS file. - verbose (=2): an integer 0-3. 0 disables all logging, 1 enables logging of errors. 2 enables logging of warnings and errors. 3 - additionally enables debugging info. + additionally enables debugging info. Logging is performed + via the sqlite3.config.{log|warn|error}() functions. - - sanityChecks (=false): if true, some basic sanity tests are - run on the OPFS VFS API after it's initialized, before the - returned Promise resolves. + - sanityChecks (=false): if true, some basic sanity tests are run on + the OPFS VFS API after it's initialized, before the returned + Promise resolves. This is only intended for testing and + development of the VFS, not client-side use. On success, the Promise resolves to the top-most sqlite3 namespace object and that object gets a new object installed in its @@ -994,7 +992,9 @@ const installOpfsVfs = function callee(options){ }; /** Checks whether the given OPFS filesystem entry exists, - returning true if it does, false if it doesn't. + returning true if it does, false if it doesn't or if an + exception is intercepted while trying to make the + determination. */ opfsUtil.entryExists = async function(fsEntryName){ try { @@ -1110,9 +1110,9 @@ const installOpfsVfs = function callee(options){ }; /** - Traverses the OPFS filesystem, calling a callback for each one. - The argument may be either a callback function or an options object - with any of the following properties: + Traverses the OPFS filesystem, calling a callback for each + entry. The argument may be either a callback function or an + options object with any of the following properties: - `callback`: function which gets called for each filesystem entry. It gets passed 3 arguments: 1) the @@ -1142,11 +1142,6 @@ const installOpfsVfs = function callee(options){ but that promise has no specific meaning: the traversal it performs is synchronous. The promise must be used to catch any exceptions propagated by the callback, however. - - TODO: add an option which specifies whether to traverse - depth-first or breadth-first. We currently do depth-first but - an incremental file browsing widget would benefit more from - breadth-first. */ opfsUtil.traverse = async function(opt){ const defaultOpt = { diff --git a/manifest b/manifest index 939209fa63..2724500b35 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scompiling\sshell.c\sin\sSQLITE_SHELL_FIDDLE\smode,\sensure\sthat\sthe\sshell_main_exit\sgoto\slabel\sis\sreachable. -D 2024-06-11T17:04:02.306 +C Remove\ssome\sdead\sJS\scode\sand\supdate\ssome\sJS\sdocs. +D 2024-06-11T17:04:43.812 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -613,12 +613,12 @@ F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b18817 F ext/wasm/api/sqlite3-api-glue.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d F ext/wasm/api/sqlite3-api-oo1.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 -F ext/wasm/api/sqlite3-api-worker1.js 9704b77b5eb9d0d498ceeaf3e7a837021b14c52ac15d6556c7f97e278ec725c3 +F ext/wasm/api/sqlite3-api-worker1.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 196ad83d36ca794e564044788c9d21b964679d63cad865f604da37c4afc9a285 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 3c72f1a0e6a7343c8c882d29d01bb440f10be12c844651605b486e76f3d6cc8c +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js ea5a6ca69d5fdf5f00f7ac1826990ce183fb191f6a6fab4d215b81910614b064 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6c103aee6f146869a3e0c48694592f2e4c6b57ecdb4450f46e762c38b4e686f1 -R 0476a0c13890d8b5c65d486f3c7c6f13 +P 06e6f64533563ab9c059b773e5f0d78085df716f2624e547b7259f6789c3ffe0 +R 79d342ace6fd539450d6954e121ef97a U stephan -Z 3e50a8e3e5517fc31eec2359fe1a9a43 +Z 878c1bfba19ab8a7570c53af656f275c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e83978cd4..214309359d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -06e6f64533563ab9c059b773e5f0d78085df716f2624e547b7259f6789c3ffe0 \ No newline at end of file +6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580 \ No newline at end of file From f6ec2b5946cc5dd80d56e162360d54baa35812c5 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 11 Jun 2024 20:03:32 +0000 Subject: [PATCH 0481/1030] Fix a problem with rolling back hot journals using the unix-dotfile VFS. FossilOrigin-Name: 4ae3300b79e03381fd7f1033bb7978bb6367369790f17c3bdacac51e205edaf9 --- manifest | 19 +++++++------ manifest.uuid | 2 +- src/os_unix.c | 25 ++++++----------- test/lock5.test | 71 +++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 86 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index 2724500b35..dbd86925eb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sdead\sJS\scode\sand\supdate\ssome\sJS\sdocs. -D 2024-06-11T17:04:43.812 +C Fix\sa\sproblem\swith\srolling\sback\shot\sjournals\susing\sthe\sunix-dotfile\sVFS. +D 2024-06-11T20:03:32.695 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -739,7 +739,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c 08ca53844f4bf8eafb18b0a9076c84afac41da912315a5cfbe9e704d4c10c090 +F src/os_unix.c 582eb7e4aa4fee66dd9475cf7325a6753890266020ba1670c36ed8b9babd5a46 F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56 @@ -1388,7 +1388,7 @@ F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00 F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8 -F test/lock5.test c6c5e0ebcb21c61a572870cc86c0cb9f14cede38 +F test/lock5.test 69d7991e39c3fade9b6e46403c1386bcd21a4808796c9c6f60f17d0fdcec266f F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413 @@ -2195,8 +2195,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 06e6f64533563ab9c059b773e5f0d78085df716f2624e547b7259f6789c3ffe0 -R 79d342ace6fd539450d6954e121ef97a -U stephan -Z 878c1bfba19ab8a7570c53af656f275c +P 6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580 +R a6be376671415b32f13dc00f1cf159ee +T *branch * unix-dotfile-fix +T *sym-unix-dotfile-fix * +T -sym-trunk * +U dan +Z 82729b2f1037b9035a8ecef1ba94fcd8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 214309359d..78f90430a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580 \ No newline at end of file +4ae3300b79e03381fd7f1033bb7978bb6367369790f17c3bdacac51e205edaf9 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index c61b19060c..45ba0c001d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2279,26 +2279,17 @@ static int nolockClose(sqlite3_file *id) { /* ** This routine checks if there is a RESERVED lock held on the specified -** file by this or any other process. If such a lock is held, set *pResOut -** to a non-zero value otherwise *pResOut is set to zero. The return value -** is set to SQLITE_OK unless an I/O error occurs during lock checking. -** -** In dotfile locking, either a lock exists or it does not. So in this -** variation of CheckReservedLock(), *pResOut is set to true if any lock -** is held on the file and false if the file is unlocked. +** file by this or any other process. The caller always holds a SHARED +** lock when it is called. This means that no other connection could +** hold a RESERVED lock, as unix-dotfile uses just a single exclusive lock - +** the presence of the dotfile - for all 4 VFS locks. So this function sets +** (*pResOut) to 0 (no other connection holds RESERVED) and returns SQLITE_OK. */ static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) { - int rc = SQLITE_OK; - int reserved = 0; - unixFile *pFile = (unixFile*)id; - SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; ); - - assert( pFile ); - reserved = osAccess((const char*)pFile->lockingContext, 0)==0; - OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved)); - *pResOut = reserved; - return rc; + assert( ((unixFile*)id)->eFileLock>=SHARED_LOCK ); + *pResOut = 0; + return SQLITE_OK; } /* diff --git a/test/lock5.test b/test/lock5.test index 99214afb19..6e26f9dd02 100644 --- a/test/lock5.test +++ b/test/lock5.test @@ -11,10 +11,10 @@ # This file implements regression tests for SQLite library. The # focus of this script is database locks. # -# $Id: lock5.test,v 1.6 2008/12/04 12:34:16 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix lock5 # This file is only run if using the unix backend compiled with the # SQLITE_ENABLE_LOCKING_STYLE macro. @@ -101,10 +101,7 @@ do_test lock5-dotfile.X { ##################################################################### forcedelete test.db -if {[catch {sqlite3 db test.db -vfs unix-flock} msg]} { - finish_test - return -} +if {0==[catch {sqlite3 db test.db -vfs unix-flock} msg]} { do_test lock5-flock.1 { sqlite3 db test.db -vfs unix-flock @@ -149,13 +146,19 @@ do_test lock5-flock.8 { db2 close } {} +} + ##################################################################### +reset_db + do_test lock5-none.1 { sqlite3 db test.db -vfs unix-none sqlite3 db2 test.db -vfs unix-none execsql { PRAGMA mmap_size = 0 } db2 execsql { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); BEGIN; INSERT INTO t1 VALUES(3, 4); } @@ -193,4 +196,62 @@ ifcapable lock_proxy_pragmas { set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy } +##################################################################### +reset_db + +# 1. Create a large database using the unix-dotfile VFS +# 2. Write a large transaction to the db, so that the cache spills, but do +# not commit it. +# 3. Make a copy of the database files on disk. +# 4. Try to read from the copy using unix-dotfile VFS. This fails because +# the dotfile still exists, so SQLite things the database is locked. +# 5. Remove the dotfile. +# 6. Try to read the db again. This time, the old transaction is rolled +# back and the read permitted. +# +do_test 2.dotfile.1 { + sqlite3 db test.db -vfs unix-dotfile + execsql { + PRAGMA cache_size = 10; + CREATE TABLE t1(x, y, z); + CREATE INDEX t1x ON t1(x); + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000 + ) + INSERT INTO t1 SELECT hex(randomblob(20)), hex(randomblob(500)), i FROM s; + } +} {} + +do_execsql_test 2.dotfile.2 { + BEGIN; + UPDATE t1 SET z=z+1, x=hex(randomblob(20)); +} + +do_test 2.dotfile.3 { + list \ + [file exists test.db] \ + [file exists test.db-journal] \ + [file exists test.db.lock] +} {1 1 1} + +do_test 2.dotfile.4 { + forcecopy test.db test.db2 + forcecopy test.db-journal test.db2-journal + file mkdir test.db2.lock + + sqlite3 db2 test.db2 -vfs unix-dotfile + catchsql { + SELECT count(*) FROM t1; + } db2 +} {1 {database is locked}} + +do_test 2.dotfile.5 { + file delete test.db2.lock + execsql { + PRAGMA integrity_check + } db2 +} {ok} + finish_test + + From 41caf1cdfa71e4c32aa441be900d422ad59676f2 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 11 Jun 2024 20:28:56 +0000 Subject: [PATCH 0482/1030] Handle the case where unix-dotfile is used with URI parameter nolock=1. FossilOrigin-Name: 3925a5b904e159d54455cfc73fe837a9c6ea3a6d60da63afde3242b4d6f67c90 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/os_unix.c | 19 ++++++++++++------- test/lock5.test | 12 ++++++++++++ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index dbd86925eb..cf3caa1cb2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\srolling\sback\shot\sjournals\susing\sthe\sunix-dotfile\sVFS. -D 2024-06-11T20:03:32.695 +C Handle\sthe\scase\swhere\sunix-dotfile\sis\sused\swith\sURI\sparameter\snolock=1. +D 2024-06-11T20:28:56.529 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -739,7 +739,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c 582eb7e4aa4fee66dd9475cf7325a6753890266020ba1670c36ed8b9babd5a46 +F src/os_unix.c 2ea8d3ed496b8d1f9332a9505653424e5464fd797ea9d91f8e2e62f9dd0298d0 F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56 @@ -1388,7 +1388,7 @@ F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00 F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8 -F test/lock5.test 69d7991e39c3fade9b6e46403c1386bcd21a4808796c9c6f60f17d0fdcec266f +F test/lock5.test e6d5a7dd3c3c2ad83b05dbd50d0bd8b2a98a13ce6b2f3297e0edfbebb3413de3 F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413 @@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580 -R a6be376671415b32f13dc00f1cf159ee -T *branch * unix-dotfile-fix -T *sym-unix-dotfile-fix * -T -sym-trunk * +P 4ae3300b79e03381fd7f1033bb7978bb6367369790f17c3bdacac51e205edaf9 +R f4ac66d6cce3f1556fd45b9db23cb700 U dan -Z 82729b2f1037b9035a8ecef1ba94fcd8 +Z 59b7d2f0f8fc06cadab577170f885282 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 78f90430a4..48f2de2bc7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ae3300b79e03381fd7f1033bb7978bb6367369790f17c3bdacac51e205edaf9 \ No newline at end of file +3925a5b904e159d54455cfc73fe837a9c6ea3a6d60da63afde3242b4d6f67c90 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 45ba0c001d..c94c0c111f 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2279,16 +2279,21 @@ static int nolockClose(sqlite3_file *id) { /* ** This routine checks if there is a RESERVED lock held on the specified -** file by this or any other process. The caller always holds a SHARED -** lock when it is called. This means that no other connection could -** hold a RESERVED lock, as unix-dotfile uses just a single exclusive lock - -** the presence of the dotfile - for all 4 VFS locks. So this function sets -** (*pResOut) to 0 (no other connection holds RESERVED) and returns SQLITE_OK. +** file by this or any other process. If the caller holds a SHARED +** or greater lock when it is called, then it is assumed that no other +** client may hold RESERVED. Or, if the caller holds no lock, then it +** is assumed another client holds RESERVED if the lock-file exists. */ static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) { + unixFile *pFile = (unixFile*)id; SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; ); - assert( ((unixFile*)id)->eFileLock>=SHARED_LOCK ); - *pResOut = 0; + + if( pFile->eFileLock>=SHARED_LOCK ){ + *pResOut = 0; + }else{ + *pResOut = osAccess((const char*)pFile->lockingContext, 0)==0; + } + OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, 0, *pResOut)); return SQLITE_OK; } diff --git a/test/lock5.test b/test/lock5.test index 6e26f9dd02..0e1669f1b1 100644 --- a/test/lock5.test +++ b/test/lock5.test @@ -252,6 +252,18 @@ do_test 2.dotfile.5 { } db2 } {ok} +db2 close + +do_test 2.dotfile.6 { + forcecopy test.db test.db2 + forcecopy test.db-journal test.db2-journal + + sqlite3 db2 file:test.db2?nolock=1 -vfs unix-dotfile -uri 1 + catchsql { + SELECT count(*) FROM t1; + } db2 +} {0 1000} + finish_test From 6975fc56f7b207cf22b8b011203fe042fae6ecb3 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 12 Jun 2024 11:39:29 +0000 Subject: [PATCH 0483/1030] Slight API doc tweak for xCheckReservedLock(), based on forum feedback. No code changes. FossilOrigin-Name: 2af7a96f6868a4529d689702926b350a4c00082f14da0ded5a8eaea295682d17 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2724500b35..089f6d8df7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sdead\sJS\scode\sand\supdate\ssome\sJS\sdocs. -D 2024-06-11T17:04:43.812 +C Slight\sAPI\sdoc\stweak\sfor\sxCheckReservedLock(),\sbased\son\sforum\sfeedback.\sNo\scode\schanges. +D 2024-06-12T11:39:29.122 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -757,7 +757,7 @@ F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ea0b75fce45e1f2c22f50ed2b6e2ddd7f66640948d0fc79a397917b4236a74af F src/shell.c.in ad27d1d990e9e5fb7ae8fc38a717e91f55233714f59723e5618baf4a2a3d2b65 -F src/sqlite.h.in cbd3e4177791a61c056fd81e37a5b21bb6c8cb2ea8cac558c625974673f50acf +F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h af50738edf6a6cf9aa974b98d75bd0cedce607948dd10885ac6ae6cf5abae23c @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 06e6f64533563ab9c059b773e5f0d78085df716f2624e547b7259f6789c3ffe0 -R 79d342ace6fd539450d6954e121ef97a +P 6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580 +R 6f00a87482c0b560181528a2ef901b80 U stephan -Z 878c1bfba19ab8a7570c53af656f275c +Z c3fe7f4acc9c5d5503f58267d83105e5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 214309359d..a649e33db8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580 \ No newline at end of file +2af7a96f6868a4529d689702926b350a4c00082f14da0ded5a8eaea295682d17 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8cca648367..183fb2a082 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -772,8 +772,8 @@ struct sqlite3_file { ** to xUnlock() is a no-op. ** The xCheckReservedLock() method checks whether any database connection, ** either in this process or in some other process, is holding a RESERVED, -** PENDING, or EXCLUSIVE lock on the file. It returns true -** if such a lock exists and false otherwise. +** PENDING, or EXCLUSIVE lock on the file. It returns, via its output +** pointer parameter, true if such a lock exists and false otherwise. ** ** The xFileControl() method is a generic interface that allows custom ** VFS implementations to directly control an open file using the From f8ed7db472f51b7dac3a220181bb5f6c2bae8b49 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 12 Jun 2024 11:41:18 +0000 Subject: [PATCH 0484/1030] Do not attempt to run hot journal rollback tests in lock5.test with the "inmemory_journal" permutation, which cannot generate hot journals. FossilOrigin-Name: 1e6fa95b88cace9e6cac476863d57cfd8de483f83c922ff964b77cbaee6e9ae4 --- manifest | 12 ++--- manifest.uuid | 2 +- test/lock5.test | 128 ++++++++++++++++++++++++------------------------ 3 files changed, 72 insertions(+), 70 deletions(-) diff --git a/manifest b/manifest index cf3caa1cb2..a103a7194a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Handle\sthe\scase\swhere\sunix-dotfile\sis\sused\swith\sURI\sparameter\snolock=1. -D 2024-06-11T20:28:56.529 +C Do\snot\sattempt\sto\srun\shot\sjournal\srollback\stests\sin\slock5.test\swith\sthe\s"inmemory_journal"\spermutation,\swhich\scannot\sgenerate\shot\sjournals. +D 2024-06-12T11:41:18.217 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1388,7 +1388,7 @@ F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00 F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8 -F test/lock5.test e6d5a7dd3c3c2ad83b05dbd50d0bd8b2a98a13ce6b2f3297e0edfbebb3413de3 +F test/lock5.test 02e00537ed5bea94d74e914a579cd94b9b52b342361d9ea270a8630e62bb131d F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4ae3300b79e03381fd7f1033bb7978bb6367369790f17c3bdacac51e205edaf9 -R f4ac66d6cce3f1556fd45b9db23cb700 +P 3925a5b904e159d54455cfc73fe837a9c6ea3a6d60da63afde3242b4d6f67c90 +R 78b8c4cb68d9ed22c3978516f0902770 U dan -Z 59b7d2f0f8fc06cadab577170f885282 +Z 84fe133e30abe6e15019a66820115796 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 48f2de2bc7..23427501e7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3925a5b904e159d54455cfc73fe837a9c6ea3a6d60da63afde3242b4d6f67c90 \ No newline at end of file +1e6fa95b88cace9e6cac476863d57cfd8de483f83c922ff964b77cbaee6e9ae4 \ No newline at end of file diff --git a/test/lock5.test b/test/lock5.test index 0e1669f1b1..0141cd74c0 100644 --- a/test/lock5.test +++ b/test/lock5.test @@ -198,72 +198,74 @@ ifcapable lock_proxy_pragmas { ##################################################################### reset_db - -# 1. Create a large database using the unix-dotfile VFS -# 2. Write a large transaction to the db, so that the cache spills, but do -# not commit it. -# 3. Make a copy of the database files on disk. -# 4. Try to read from the copy using unix-dotfile VFS. This fails because -# the dotfile still exists, so SQLite things the database is locked. -# 5. Remove the dotfile. -# 6. Try to read the db again. This time, the old transaction is rolled -# back and the read permitted. -# -do_test 2.dotfile.1 { - sqlite3 db test.db -vfs unix-dotfile - execsql { - PRAGMA cache_size = 10; - CREATE TABLE t1(x, y, z); - CREATE INDEX t1x ON t1(x); - WITH s(i) AS ( - SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000 - ) - INSERT INTO t1 SELECT hex(randomblob(20)), hex(randomblob(500)), i FROM s; +if {[permutation]!="inmemory_journal"} { + + # 1. Create a large database using the unix-dotfile VFS + # 2. Write a large transaction to the db, so that the cache spills, but do + # not commit it. + # 3. Make a copy of the database files on disk. + # 4. Try to read from the copy using unix-dotfile VFS. This fails because + # the dotfile still exists, so SQLite things the database is locked. + # 5. Remove the dotfile. + # 6. Try to read the db again. This time, the old transaction is rolled + # back and the read permitted. + # + do_test 2.dotfile.1 { + sqlite3 db test.db -vfs unix-dotfile + execsql { + PRAGMA cache_size = 10; + CREATE TABLE t1(x, y, z); + CREATE INDEX t1x ON t1(x); + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000 + ) + INSERT INTO t1 SELECT hex(randomblob(20)), hex(randomblob(500)), i FROM s; + } + } {} + + do_execsql_test 2.dotfile.2 { + BEGIN; + UPDATE t1 SET z=z+1, x=hex(randomblob(20)); } -} {} - -do_execsql_test 2.dotfile.2 { - BEGIN; - UPDATE t1 SET z=z+1, x=hex(randomblob(20)); + + do_test 2.dotfile.3 { + list \ + [file exists test.db] \ + [file exists test.db-journal] \ + [file exists test.db.lock] + } {1 1 1} + + do_test 2.dotfile.4 { + forcecopy test.db test.db2 + forcecopy test.db-journal test.db2-journal + file mkdir test.db2.lock + + sqlite3 db2 test.db2 -vfs unix-dotfile + catchsql { + SELECT count(*) FROM t1; + } db2 + } {1 {database is locked}} + + do_test 2.dotfile.5 { + file delete test.db2.lock + execsql { + PRAGMA integrity_check + } db2 + } {ok} + + db2 close + + do_test 2.dotfile.6 { + forcecopy test.db test.db2 + forcecopy test.db-journal test.db2-journal + + sqlite3 db2 file:test.db2?nolock=1 -vfs unix-dotfile -uri 1 + catchsql { + SELECT count(*) FROM t1; + } db2 + } {0 1000} } -do_test 2.dotfile.3 { - list \ - [file exists test.db] \ - [file exists test.db-journal] \ - [file exists test.db.lock] -} {1 1 1} - -do_test 2.dotfile.4 { - forcecopy test.db test.db2 - forcecopy test.db-journal test.db2-journal - file mkdir test.db2.lock - - sqlite3 db2 test.db2 -vfs unix-dotfile - catchsql { - SELECT count(*) FROM t1; - } db2 -} {1 {database is locked}} - -do_test 2.dotfile.5 { - file delete test.db2.lock - execsql { - PRAGMA integrity_check - } db2 -} {ok} - -db2 close - -do_test 2.dotfile.6 { - forcecopy test.db test.db2 - forcecopy test.db-journal test.db2-journal - - sqlite3 db2 file:test.db2?nolock=1 -vfs unix-dotfile -uri 1 - catchsql { - SELECT count(*) FROM t1; - } db2 -} {0 1000} - finish_test From 01f07a61e47fbafd4d89b9ab2ee728dae4938515 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 12 Jun 2024 12:17:03 +0000 Subject: [PATCH 0485/1030] Doc updates in JS code. No functional changes. FossilOrigin-Name: 587ed3a5d283898ad0e67ccee86a0a4ccc432fa292c0a3534e9e6ec70a7b7780 --- ext/wasm/api/sqlite3-opfs-async-proxy.js | 24 ++++++++++++++++++---- ext/wasm/common/whwasmutil.js | 26 ++++++++++++------------ manifest | 14 ++++++------- manifest.uuid | 2 +- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index e671094f04..48cddd7ef3 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -173,10 +173,10 @@ const installAsyncProxy = function(){ /** If the given file-holding object has a sync handle attached to it, - that handle is remove and asynchronously closed. Though it may + that handle is removed and asynchronously closed. Though it may sound sensible to continue work as soon as the close() returns (noting that it's asynchronous), doing so can cause operations - performed soon afterwards, e.g. a call to getSyncHandle() to fail + performed soon afterwards, e.g. a call to getSyncHandle(), to fail because they may happen out of order from the close(). OPFS does not guaranty that the actual order of operations is retained in such cases. i.e. always "await" on the result of this function. @@ -293,6 +293,20 @@ const installAsyncProxy = function(){ times. If acquisition still fails at that point it will give up and propagate the exception. Client-level code will see that as an I/O error. + + 2024-06-12: there is a rare race condition here which has been + reported a single time: + + https://sqlite.org/forum/forumpost/9ee7f5340802d600 + + What appears to be happening is that file we're waiting for a + lock on is deleted while we wait. What currently happens here is + that a locking exception is thrown but the exception type is + NotFoundError. In such cases, we very probably should attempt to + re-open/re-create the file an obtain the lock on it (noting that + there's another race condition there). That's easy to say but + creating a viable test for that condition has proven challenging + so far. */ const getSyncHandle = async (fh,opName)=>{ if(!fh.syncHandle){ @@ -674,8 +688,10 @@ const installAsyncProxy = function(){ mTimeStart('xUnlock'); let rc = 0; const fh = __openFiles[fid]; - if( state.sq3Codes.SQLITE_LOCK_NONE===lockType - && fh.syncHandle ){ + if( fh.syncHandle + && state.sq3Codes.SQLITE_LOCK_NONE===lockType + /* Note that we do not differentiate between lock types in + this VFS. We're either locked or unlocked. */ ){ wTimeStart('xUnlock'); try { await closeSyncHandle(fh) } catch(e){ diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index b8a2a87742..25400d48e3 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -156,8 +156,7 @@ - 'dealloc()` must behave like C's `free()`, accepting either a pointer returned from its allocation counterpart or the values - null/0 (for which it must be a no-op). allocating N bytes of - memory and returning its pointer. In Emscripten this is + null/0 (for which it must be a no-op). In Emscripten this is conventionally made available via `Module['_free']`. APIs which require allocation routines are explicitly documented as @@ -730,22 +729,23 @@ globalThis.WhWasmUtilInstaller = function(target){ }; /** - The counterpart of peek(), this sets a numeric value at - the given WASM heap address, using the type to define how many - bytes are written. Throws if given an invalid type. See - peek() for details about the type argument. If the 3rd - argument ends with `*` then it is treated as a pointer type and - this function behaves as if the 3rd argument were `i32`. + The counterpart of peek(), this sets a numeric value at the given + WASM heap address, using the 3rd argument to define how many + bytes are written. Throws if given an invalid type. See peek() + for details about the `type` argument. If the 3rd argument ends + with `*` then it is treated as a pointer type and this function + behaves as if the 3rd argument were `i32`. If the first argument is an array, it is treated like a list of pointers and the given value is written to each one. - Returns `this`. (Prior to 2022-12-09 it returns this function.) + Returns `this`. (Prior to 2022-12-09 it returned this function.) - ACHTUNG: calling this often, e.g. in a loop, can have a noticably - painful impact on performance. Rather than doing so, use - heapForSize() to fetch the heap object and assign directly to it - or use the heap's set() method. + ACHTUNG: calling this often, e.g. in a loop to populate a large + chunk of memory, can have a noticably painful impact on + performance. Rather than doing so, use heapForSize() to fetch the + heap object and assign directly to it or use the heap's set() + method. */ target.poke = function(ptr, value, type='i8'){ if (type.endsWith('*')) type = ptrIR; diff --git a/manifest b/manifest index 089f6d8df7..579deb8201 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Slight\sAPI\sdoc\stweak\sfor\sxCheckReservedLock(),\sbased\son\sforum\sfeedback.\sNo\scode\schanges. -D 2024-06-12T11:39:29.122 +C Doc\supdates\sin\sJS\scode.\sNo\sfunctional\schanges. +D 2024-06-12T12:17:03.078 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -615,7 +615,7 @@ F ext/wasm/api/sqlite3-api-oo1.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818 F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 -F ext/wasm/api/sqlite3-opfs-async-proxy.js 196ad83d36ca794e564044788c9d21b964679d63cad865f604da37c4afc9a285 +F ext/wasm/api/sqlite3-opfs-async-proxy.js a77fe462e87bb18dcf51574750db89bbec9b95b390dfd01e3b055e7a7813c93d F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js ea5a6ca69d5fdf5f00f7ac1826990ce183fb191f6a6fab4d215b81910614b064 @@ -631,7 +631,7 @@ F ext/wasm/c-pp.c 6d80d8569d85713effe8b0818a3cf51dc779e3f0bf8dc88771b8998552ee25 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f -F ext/wasm/common/whwasmutil.js f7b3461028899b923fb554029a5c980396b02800b742aabb44346dd8704fd11b +F ext/wasm/common/whwasmutil.js 6181f8cd958700f3723350bd4d76c7cc797db331a9aa14b25b42d121f12d6fee F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580 -R 6f00a87482c0b560181528a2ef901b80 +P 2af7a96f6868a4529d689702926b350a4c00082f14da0ded5a8eaea295682d17 +R 34d526d3b56e71d13df1133258f9533e U stephan -Z c3fe7f4acc9c5d5503f58267d83105e5 +Z c37fe2a3b7e5af6ccd199eaf757eabb9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a649e33db8..f04b8421f0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2af7a96f6868a4529d689702926b350a4c00082f14da0ded5a8eaea295682d17 \ No newline at end of file +587ed3a5d283898ad0e67ccee86a0a4ccc432fa292c0a3534e9e6ec70a7b7780 \ No newline at end of file From fd70ca40cc22ea901a5d9595fa7bf741a87c2176 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 12 Jun 2024 12:36:02 +0000 Subject: [PATCH 0486/1030] OPFS VFS: change the xCheckReservedLock() impl to always return false, as discussed in [forum:a2f573b00cda1372|forum thread a2f573b00cda1372]. This does not impact any current tests, and may have no direct impact at all because of how that VFS handles locking, but is hypothetically a more correct solution than the previous one. FossilOrigin-Name: c298b8ba2dcd01fa28b79a78bb4986fa0282755a0a36b7f38b93096ac31f521e --- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 18 ++++++++++++++---- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index a2ad6ad3ed..45e8c48890 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -715,12 +715,23 @@ const installOpfsVfs = function callee(options){ file. We have no way of checking whether any _other_ db connection has a lock except by trying to obtain and (on success) release a sync-handle for it, but doing so would - involve an inherent race condition. For the time being, + involve an inherent race condition and would require + waiting on the async proxy (which might be tied up for + arbitrarily long with unrelated work). For the time being, pending a better solution, we simply report whether the given pFile is open. + + Update 2024-06-12: based on forum discussions, this + function now always sets pOut to 0 (false): + + https://sqlite.org/forum/forumpost/a2f573b00cda1372 */ - const f = __openFiles[pFile]; - wasm.poke(pOut, f.lockType ? 1 : 0, 'i32'); + if(1){ + wasm.poke(pOut, 0, 'i32'); + }else{ + const f = __openFiles[pFile]; + wasm.poke(pOut, f.lockType ? 1 : 0, 'i32'); + } return 0; }, xClose: function(pFile){ @@ -736,7 +747,6 @@ const installOpfsVfs = function callee(options){ return rc; }, xDeviceCharacteristics: function(pFile){ - //debug("xDeviceCharacteristics(",pFile,")"); return capi.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN; }, xFileControl: function(pFile, opId, pArg){ diff --git a/manifest b/manifest index 579deb8201..bdac2abfff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Doc\supdates\sin\sJS\scode.\sNo\sfunctional\schanges. -D 2024-06-12T12:17:03.078 +C OPFS\sVFS:\schange\sthe\sxCheckReservedLock()\simpl\sto\salways\sreturn\sfalse,\sas\sdiscussed\sin\s[forum:a2f573b00cda1372|forum\sthread\sa2f573b00cda1372].\sThis\sdoes\snot\simpact\sany\scurrent\stests,\sand\smay\shave\sno\sdirect\simpact\sat\sall\sbecause\sof\show\sthat\sVFS\shandles\slocking,\sbut\sis\shypothetically\sa\smore\scorrect\ssolution\sthan\sthe\sprevious\sone. +D 2024-06-12T12:36:02.582 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -618,7 +618,7 @@ F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d299 F ext/wasm/api/sqlite3-opfs-async-proxy.js a77fe462e87bb18dcf51574750db89bbec9b95b390dfd01e3b055e7a7813c93d F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js ea5a6ca69d5fdf5f00f7ac1826990ce183fb191f6a6fab4d215b81910614b064 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js c38e5b372b9019e64bb3babda465c852cb6d59d4ffd3d7a186ed796596bcd9d5 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2af7a96f6868a4529d689702926b350a4c00082f14da0ded5a8eaea295682d17 -R 34d526d3b56e71d13df1133258f9533e +P 587ed3a5d283898ad0e67ccee86a0a4ccc432fa292c0a3534e9e6ec70a7b7780 +R 627383e1e012584141ebd74c98bd7f4d U stephan -Z c37fe2a3b7e5af6ccd199eaf757eabb9 +Z 9f8d8dcb26b9598cd7f1252d2913b583 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f04b8421f0..32caa3b9b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -587ed3a5d283898ad0e67ccee86a0a4ccc432fa292c0a3534e9e6ec70a7b7780 \ No newline at end of file +c298b8ba2dcd01fa28b79a78bb4986fa0282755a0a36b7f38b93096ac31f521e \ No newline at end of file From 9e72ea5ddcf8da7450185d136354c22956cc0845 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 12 Jun 2024 15:29:37 +0000 Subject: [PATCH 0487/1030] Omit tests that depend on sqlite3_release_memory() in lock5.test when running the memsubsys1 or memsubsys2 permutations. FossilOrigin-Name: 9d63033bf46ddf0f4d9d4ef06d56357fe6165f2370cd19cf81c2f7f61ce224fc --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/lock5.test | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index a103a7194a..f681404f14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sattempt\sto\srun\shot\sjournal\srollback\stests\sin\slock5.test\swith\sthe\s"inmemory_journal"\spermutation,\swhich\scannot\sgenerate\shot\sjournals. -D 2024-06-12T11:41:18.217 +C Omit\stests\sthat\sdepend\son\ssqlite3_release_memory()\sin\slock5.test\swhen\srunning\sthe\smemsubsys1\sor\smemsubsys2\spermutations. +D 2024-06-12T15:29:37.134 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1388,7 +1388,7 @@ F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00 F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8 -F test/lock5.test 02e00537ed5bea94d74e914a579cd94b9b52b342361d9ea270a8630e62bb131d +F test/lock5.test 626571313daef2c949ce002f861042d63d81119fa62a9e999721c8bbd85e1ec9 F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3925a5b904e159d54455cfc73fe837a9c6ea3a6d60da63afde3242b4d6f67c90 -R 78b8c4cb68d9ed22c3978516f0902770 +P 1e6fa95b88cace9e6cac476863d57cfd8de483f83c922ff964b77cbaee6e9ae4 +R 3a4a85834551db124c9a29a9adb094ef U dan -Z 84fe133e30abe6e15019a66820115796 +Z c34dc91d8750434d9c55abc5758418d0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 23427501e7..cc3da9aa52 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1e6fa95b88cace9e6cac476863d57cfd8de483f83c922ff964b77cbaee6e9ae4 \ No newline at end of file +9d63033bf46ddf0f4d9d4ef06d56357fe6165f2370cd19cf81c2f7f61ce224fc \ No newline at end of file diff --git a/test/lock5.test b/test/lock5.test index 0141cd74c0..d5950118ce 100644 --- a/test/lock5.test +++ b/test/lock5.test @@ -181,10 +181,12 @@ do_test lock5-none.5 { } {1 2} ifcapable memorymanage { - do_test lock5-none.6 { - sqlite3_release_memory 1000000 - execsql {SELECT * FROM t1} db2 - } {1 2 3 4} + if {[permutation]!="memsubsys1" && [permutation]!="memsubsys2"} { + do_test lock5-none.6 { + sqlite3_release_memory 1000000 + execsql {SELECT * FROM t1} db2 + } {1 2 3 4} + } } do_test lock5-none.X { From 063a2b338c8bf6c7dd4c156c629f26250c60ffe9 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 12 Jun 2024 21:01:44 +0000 Subject: [PATCH 0488/1030] Remove some JS docs which no longer apply. No code changes. FossilOrigin-Name: f253cab3359270045a3ae9f5e9eadc1cfc8844181db127165bfdf49d5f99efb1 --- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 4 +--- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index 45e8c48890..603a3e4747 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -715,9 +715,7 @@ const installOpfsVfs = function callee(options){ file. We have no way of checking whether any _other_ db connection has a lock except by trying to obtain and (on success) release a sync-handle for it, but doing so would - involve an inherent race condition and would require - waiting on the async proxy (which might be tied up for - arbitrarily long with unrelated work). For the time being, + involve an inherent race condition. For the time being, pending a better solution, we simply report whether the given pFile is open. diff --git a/manifest b/manifest index cdd2c6fe5c..6dd91dca87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\srolling\sback\shot\sjournals\susing\sthe\sunix-dotfile\sVFS. -D 2024-06-12T15:50:35.035 +C Remove\ssome\sJS\sdocs\swhich\sno\slonger\sapply.\sNo\scode\schanges. +D 2024-06-12T21:01:44.271 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -618,7 +618,7 @@ F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d299 F ext/wasm/api/sqlite3-opfs-async-proxy.js a77fe462e87bb18dcf51574750db89bbec9b95b390dfd01e3b055e7a7813c93d F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js c38e5b372b9019e64bb3babda465c852cb6d59d4ffd3d7a186ed796596bcd9d5 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 4672142c5ebde2f36cfb54ade66beff393c8ceba819fbe3e6d4d16ed28454314 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,9 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c298b8ba2dcd01fa28b79a78bb4986fa0282755a0a36b7f38b93096ac31f521e 9d63033bf46ddf0f4d9d4ef06d56357fe6165f2370cd19cf81c2f7f61ce224fc -R 0f0b01c177eceb54a303d16754d756ef -T +closed 9d63033bf46ddf0f4d9d4ef06d56357fe6165f2370cd19cf81c2f7f61ce224fc -U dan -Z 25990fbb14d7309dc028769ec3a0c054 +P a44703135e8dd3cc67e548e1aa3c42e71df127fb7b593ccfc06025ec42a501fd +R f8258a841d7785f7bd34691642a97b21 +U stephan +Z 80db9b86bc6469d927101c39e3244f61 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index eea7b3afed..8db54be45f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a44703135e8dd3cc67e548e1aa3c42e71df127fb7b593ccfc06025ec42a501fd \ No newline at end of file +f253cab3359270045a3ae9f5e9eadc1cfc8844181db127165bfdf49d5f99efb1 \ No newline at end of file From 709cb313cf7b2da986ec2c0ca6510147ac702538 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 12 Jun 2024 22:15:25 +0000 Subject: [PATCH 0489/1030] Remove some dead JS code. Improve the exception-to-C-result-code conversion to account for the case of a file disappearing while the OPFS VFS is waiting to acquire a lock on it. FossilOrigin-Name: 5bd9fd5f61e7cd1ed3b44c5cabc759c154c98eb40ad10d29e61f142aaa062ddf --- ext/wasm/api/sqlite3-opfs-async-proxy.js | 54 ++++++++++++------------ ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 1 + manifest | 14 +++--- manifest.uuid | 2 +- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index 48cddd7ef3..a2c052d32a 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -265,23 +265,34 @@ const installAsyncProxy = function(){ this.name = 'GetSyncHandleError'; } }; + + /** + Attempts to find a suitable SQLITE_xyz result code for Error + object e. Returns either such a translation or rc if if it does + not know how to translate the exception. + */ GetSyncHandleError.convertRc = (e,rc)=>{ - if(1){ - return ( - e instanceof GetSyncHandleError - && ((e.cause.name==='NoModificationAllowedError') - /* Inconsistent exception.name from Chrome/ium with the - same exception.message text: */ - || (e.cause.name==='DOMException' - && 0===e.cause.message.indexOf('Access Handles cannot'))) - ) ? ( - /*console.warn("SQLITE_BUSY",e),*/ - state.sq3Codes.SQLITE_BUSY - ) : rc; - }else{ - return rc; + if( e instanceof GetSyncHandleError ){ + if( e.cause.name==='NoModificationAllowedError' + /* Inconsistent exception.name from Chrome/ium with the + same exception.message text: */ + || (e.cause.name==='DOMException' + && 0===e.cause.message.indexOf('Access Handles cannot')) ){ + return state.sq3Codes.SQLITE_BUSY; + }else if( 'NotFoundError'===e.cause.name ){ + /** + Maintenance reminder: SQLITE_NOTFOUND, though it looks like + a good match, has different semantics than NotFoundError + and is not suitable here. + */ + return state.sq3Codes.SQLITE_CANTOPEN; + } + }else if( 'NotFoundError'===e?.name ){ + return state.sq3Codes.SQLITE_CANTOPEN; } - } + return rc; + }; + /** Returns the sync access handle associated with the given file handle object (which must be a valid handle object, as created by @@ -600,19 +611,6 @@ const installAsyncProxy = function(){ fh.releaseImplicitLocks = (opfsFlags & state.opfsFlags.OPFS_UNLOCK_ASAP) || state.opfsFlags.defaultUnlockAsap; - if(0 /* this block is modelled after something wa-sqlite - does but it leads to immediate contention on journal files. - Update: this approach reportedly only works for DELETE journal - mode. */ - && (0===(flags & state.sq3Codes.SQLITE_OPEN_MAIN_DB))){ - /* sqlite does not lock these files, so go ahead and grab an OPFS - lock. */ - fh.xLock = "xOpen"/* Truthy value to keep entry from getting - flagged as auto-locked. String value so - that we can easily distinguish is later - if needed. */; - await getSyncHandle(fh,'xOpen'); - } __openFiles[fid] = fh; storeAndNotify(opName, 0); }catch(e){ diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index 603a3e4747..ee6937c69d 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -390,6 +390,7 @@ const installOpfsVfs = function callee(options){ 'SQLITE_ACCESS_EXISTS', 'SQLITE_ACCESS_READWRITE', 'SQLITE_BUSY', + 'SQLITE_CANTOPEN', 'SQLITE_ERROR', 'SQLITE_IOERR', 'SQLITE_IOERR_ACCESS', diff --git a/manifest b/manifest index 6dd91dca87..55eed392ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sJS\sdocs\swhich\sno\slonger\sapply.\sNo\scode\schanges. -D 2024-06-12T21:01:44.271 +C Remove\ssome\sdead\sJS\scode.\sImprove\sthe\sexception-to-C-result-code\sconversion\sto\saccount\sfor\sthe\scase\sof\sa\sfile\sdisappearing\swhile\sthe\sOPFS\sVFS\sis\swaiting\sto\sacquire\sa\slock\son\sit. +D 2024-06-12T22:15:25.519 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -615,10 +615,10 @@ F ext/wasm/api/sqlite3-api-oo1.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818 F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 -F ext/wasm/api/sqlite3-opfs-async-proxy.js a77fe462e87bb18dcf51574750db89bbec9b95b390dfd01e3b055e7a7813c93d +F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 4672142c5ebde2f36cfb54ade66beff393c8ceba819fbe3e6d4d16ed28454314 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 9e7600f0e97dc4f5ec33089b60c6b931df73e347653bf273cf6864f9f9501d7d F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a44703135e8dd3cc67e548e1aa3c42e71df127fb7b593ccfc06025ec42a501fd -R f8258a841d7785f7bd34691642a97b21 +P f253cab3359270045a3ae9f5e9eadc1cfc8844181db127165bfdf49d5f99efb1 +R 63f255ea2e5c09516862fb8ffb235ee5 U stephan -Z 80db9b86bc6469d927101c39e3244f61 +Z 1022f5b3521399d57e698263f497769f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8db54be45f..f49af7d0df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f253cab3359270045a3ae9f5e9eadc1cfc8844181db127165bfdf49d5f99efb1 \ No newline at end of file +5bd9fd5f61e7cd1ed3b44c5cabc759c154c98eb40ad10d29e61f142aaa062ddf \ No newline at end of file From 9175b18226948b05c4a6ed9b8a1c3225d3547544 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 14 Jun 2024 23:13:54 +0000 Subject: [PATCH 0490/1030] Do not omit the ORDER BY clause from a recursive CTE just because the query that contains the CTE also contains an ORDER BY clause. Plus other changes imported from the recursive-cte-orderby-fix branch. FossilOrigin-Name: 13242289c5d412b706f50fc7e1553032ea3a52d41a3e34e155432adaf0551481 --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/select.c | 5 ++++- src/treeview.c | 12 +++++++++--- src/where.c | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 55eed392ac..e1de139027 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sdead\sJS\scode.\sImprove\sthe\sexception-to-C-result-code\sconversion\sto\saccount\sfor\sthe\scase\sof\sa\sfile\sdisappearing\swhile\sthe\sOPFS\sVFS\sis\swaiting\sto\sacquire\sa\slock\son\sit. -D 2024-06-12T22:15:25.519 +C Do\snot\somit\sthe\sORDER\sBY\sclause\sfrom\sa\srecursive\sCTE\sjust\sbecause\sthe\s\nquery\sthat\scontains\sthe\sCTE\salso\scontains\san\sORDER\sBY\sclause.\s\sPlus\nother\schanges\simported\sfrom\sthe\srecursive-cte-orderby-fix\sbranch. +D 2024-06-14T23:13:54.369 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -755,7 +755,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c ea0b75fce45e1f2c22f50ed2b6e2ddd7f66640948d0fc79a397917b4236a74af +F src/select.c d26ac0a13b4154cbd71a9a57ca024350cd73f0f6fcf0ca0cbb4537e2d5b3e257 F src/shell.c.in ad27d1d990e9e5fb7ae8fc38a717e91f55233714f59723e5618baf4a2a3d2b65 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -818,7 +818,7 @@ F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c 4b0e9131c33a08905bb56a424cd07d6146497f3277301962b4d3d997c2fd7d5f +F src/treeview.c e4f0c5ca871371d26ca6868554bd5b06b7bd9554023bbec834e26c2b45814b0c F src/trigger.c 0858f75818ed1580332db274f1032bcc5effe567cb132df5c5be8b1d800ca97f F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 94c2ae6c3ef6173492c9b400635fca8f04316cf6bea8face1d425753aba31b85 +F src/where.c 70e12796956949658d6adb85f22d0760f0c05829f2ce882e89752eb28147baeb F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -2195,8 +2195,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f253cab3359270045a3ae9f5e9eadc1cfc8844181db127165bfdf49d5f99efb1 -R 63f255ea2e5c09516862fb8ffb235ee5 -U stephan -Z 1022f5b3521399d57e698263f497769f +P 5bd9fd5f61e7cd1ed3b44c5cabc759c154c98eb40ad10d29e61f142aaa062ddf +Q +5e700f2cc22bafa51928084454b374858eee3e2b00b58454cb97948d1691d276 +Q +ca063802332eba9cb97d5e52c5889403bba7b57e421695929a49c1d381bdcb44 +Q +e87966cf63af78a8cc0188d9476a2003a0be1ca1be2b305af97add0428ace2c7 +R e25beacc80993e6730d8a9b60a6a3784 +U drh +Z 4bd7377f01b30167b6d338c1a711954b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f49af7d0df..e01bbca1a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5bd9fd5f61e7cd1ed3b44c5cabc759c154c98eb40ad10d29e61f142aaa062ddf \ No newline at end of file +13242289c5d412b706f50fc7e1553032ea3a52d41a3e34e155432adaf0551481 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 9a0f2e40f5..3bc5858f62 100644 --- a/src/select.c +++ b/src/select.c @@ -7535,13 +7535,16 @@ int sqlite3Select( ** (a) The outer query has a different ORDER BY clause ** (b) The subquery is part of a join ** See forum post 062d576715d277c8 + ** (6) The subquery is not a recursive CTE. ORDER BY has a different + ** meaning for recursive CTEs and this optimization does not + ** apply. ** ** Also retain the ORDER BY if the OmitOrderBy optimization is disabled. */ if( pSub->pOrderBy!=0 && (p->pOrderBy!=0 || pTabList->nSrc>1) /* Condition (5) */ && pSub->pLimit==0 /* Condition (1) */ - && (pSub->selFlags & SF_OrderByReqd)==0 /* Condition (2) */ + && (pSub->selFlags & (SF_OrderByReqd|SF_Recursive))==0 /* (2) and (6) */ && (p->selFlags & SF_OrderByReqd)==0 /* Condition (3) and (4) */ && OptimizationEnabled(db, SQLITE_OmitOrderBy) ){ diff --git a/src/treeview.c b/src/treeview.c index 4dcc130cde..054265338e 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -901,9 +901,10 @@ void sqlite3TreeViewBareExprList( sqlite3TreeViewLine(pView, "%s", zLabel); for(i=0; inExpr; i++){ int j = pList->a[i].u.x.iOrderByCol; + u8 sortFlags = pList->a[i].fg.sortFlags; char *zName = pList->a[i].zEName; int moreToFollow = inExpr - 1; - if( j || zName ){ + if( j || zName || sortFlags ){ sqlite3TreeViewPush(&pView, moreToFollow); moreToFollow = 0; sqlite3TreeViewLine(pView, 0); @@ -924,13 +925,18 @@ void sqlite3TreeViewBareExprList( } } if( j ){ - fprintf(stdout, "iOrderByCol=%d", j); + fprintf(stdout, "iOrderByCol=%d ", j); + } + if( sortFlags & KEYINFO_ORDER_DESC ){ + fprintf(stdout, "DESC "); + }else if( sortFlags & KEYINFO_ORDER_BIGNULL ){ + fprintf(stdout, "NULLS-LAST"); } fprintf(stdout, "\n"); fflush(stdout); } sqlite3TreeViewExpr(pView, pList->a[i].pExpr, moreToFollow); - if( j || zName ){ + if( j || zName || sortFlags ){ sqlite3TreeViewPop(&pView); } } diff --git a/src/where.c b/src/where.c index 4b9ee2c43b..ba4631c6c2 100644 --- a/src/where.c +++ b/src/where.c @@ -4980,7 +4980,7 @@ static i8 wherePathSatisfiesOrderBy( assert( pIndex->aiColumn[nColumn-1]==XN_ROWID || !HasRowid(pIndex->pTable)); /* All relevant terms of the index must also be non-NULL in order - ** for isOrderDistinct to be true. So the isOrderDistint value + ** for isOrderDistinct to be true. So the isOrderDistinct value ** computed here might be a false positive. Corrections will be ** made at tag-20210426-1 below */ isOrderDistinct = IsUniqueIndex(pIndex) From c7cbcfbbbd522c972527b92b9dfee63c82a97fbc Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 16 Jun 2024 17:06:50 +0000 Subject: [PATCH 0491/1030] Remove some dead JS code. FossilOrigin-Name: 754e6e059b740435475c1869feeaca39585b262d5c27210e0fbddbbcc202c4d5 --- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 7 +------ manifest | 17 +++++++---------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index ee6937c69d..fc0fb9db96 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -725,12 +725,7 @@ const installOpfsVfs = function callee(options){ https://sqlite.org/forum/forumpost/a2f573b00cda1372 */ - if(1){ - wasm.poke(pOut, 0, 'i32'); - }else{ - const f = __openFiles[pFile]; - wasm.poke(pOut, f.lockType ? 1 : 0, 'i32'); - } + wasm.poke(pOut, 0, 'i32'); return 0; }, xClose: function(pFile){ diff --git a/manifest b/manifest index e1de139027..12770afa82 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\somit\sthe\sORDER\sBY\sclause\sfrom\sa\srecursive\sCTE\sjust\sbecause\sthe\s\nquery\sthat\scontains\sthe\sCTE\salso\scontains\san\sORDER\sBY\sclause.\s\sPlus\nother\schanges\simported\sfrom\sthe\srecursive-cte-orderby-fix\sbranch. -D 2024-06-14T23:13:54.369 +C Remove\ssome\sdead\sJS\scode. +D 2024-06-16T17:06:50.289 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -618,7 +618,7 @@ F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d299 F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 9e7600f0e97dc4f5ec33089b60c6b931df73e347653bf273cf6864f9f9501d7d +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 0c3801a8e252944fdbaddbad698534316fde90d3db5eedae156e7774ab127710 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5bd9fd5f61e7cd1ed3b44c5cabc759c154c98eb40ad10d29e61f142aaa062ddf -Q +5e700f2cc22bafa51928084454b374858eee3e2b00b58454cb97948d1691d276 -Q +ca063802332eba9cb97d5e52c5889403bba7b57e421695929a49c1d381bdcb44 -Q +e87966cf63af78a8cc0188d9476a2003a0be1ca1be2b305af97add0428ace2c7 -R e25beacc80993e6730d8a9b60a6a3784 -U drh -Z 4bd7377f01b30167b6d338c1a711954b +P 13242289c5d412b706f50fc7e1553032ea3a52d41a3e34e155432adaf0551481 +R 31572d28985020c098637ffed52dc11c +U stephan +Z 406a2fb5260fa551d1298d2d9abdfe1c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e01bbca1a4..2cb7c49a0c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -13242289c5d412b706f50fc7e1553032ea3a52d41a3e34e155432adaf0551481 \ No newline at end of file +754e6e059b740435475c1869feeaca39585b262d5c27210e0fbddbbcc202c4d5 \ No newline at end of file From e9540e2881e2429c7030362e4197c7f3948862b7 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 18 Jun 2024 09:58:39 +0000 Subject: [PATCH 0492/1030] Internal doc typo fixes, as reported in the forum. No code changes. FossilOrigin-Name: ea16b286b4344c1833ca3d17b6d315fb4ddcb99bcc232ff6444debeb634881f2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 12770afa82..17ed7157ae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sdead\sJS\scode. -D 2024-06-16T17:06:50.289 +C Internal\sdoc\stypo\sfixes,\sas\sreported\sin\sthe\sforum.\sNo\scode\schanges. +D 2024-06-18T09:58:39.997 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/shell.c.in ad27d1d990e9e5fb7ae8fc38a717e91f55233714f59723e5618baf4a2a3d2b6 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h af50738edf6a6cf9aa974b98d75bd0cedce607948dd10885ac6ae6cf5abae23c +F src/sqliteInt.h 76f4bf5adce98a989bf9b792b962bc8f739e79636a63d841e567017370acd607 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 13242289c5d412b706f50fc7e1553032ea3a52d41a3e34e155432adaf0551481 -R 31572d28985020c098637ffed52dc11c +P 754e6e059b740435475c1869feeaca39585b262d5c27210e0fbddbbcc202c4d5 +R ae59ad0856c063c9c0ffaf75175671a5 U stephan -Z 406a2fb5260fa551d1298d2d9abdfe1c +Z c1ed72f7e9ae5b233f6d9d785940ed28 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2cb7c49a0c..149c09e99e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -754e6e059b740435475c1869feeaca39585b262d5c27210e0fbddbbcc202c4d5 \ No newline at end of file +ea16b286b4344c1833ca3d17b6d315fb4ddcb99bcc232ff6444debeb634881f2 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 69aeadb34b..736889868e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4122,7 +4122,7 @@ struct Returning { }; /* -** An objected used to accumulate the text of a string where we +** An object used to accumulate the text of a string where we ** do not necessarily know how big the string will be in the end. */ struct sqlite3_str { @@ -4136,7 +4136,7 @@ struct sqlite3_str { }; #define SQLITE_PRINTF_INTERNAL 0x01 /* Internal-use-only converters allowed */ #define SQLITE_PRINTF_SQLFUNC 0x02 /* SQL function arguments to VXPrintf */ -#define SQLITE_PRINTF_MALLOCED 0x04 /* True if xText is allocated space */ +#define SQLITE_PRINTF_MALLOCED 0x04 /* True if zText is allocated space */ #define isMalloced(X) (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0) From 99623a83aa5b9f30f824c3d52787b0f54ec4feaa Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 18 Jun 2024 12:19:13 +0000 Subject: [PATCH 0493/1030] Update sqlite3_analyzer to report on the number of WITHOUT ROWID tables and to provide separate aggregate statistics for WITHOUT and WITH ROWID tables. FossilOrigin-Name: 4152894433c3a292d983b1c196664a0c46e406eccd7e644a64fa443fdb204825 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/spaceanal.tcl | 10 ++++++++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 17ed7157ae..637f1bbbbd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Internal\sdoc\stypo\sfixes,\sas\sreported\sin\sthe\sforum.\sNo\scode\schanges. -D 2024-06-18T09:58:39.997 +C Update\ssqlite3_analyzer\sto\sreport\son\sthe\snumber\sof\sWITHOUT\sROWID\stables\sand\nto\sprovide\sseparate\saggregate\sstatistics\sfor\sWITHOUT\sand\sWITH\sROWID\stables. +D 2024-06-18T12:19:13.629 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2147,7 +2147,7 @@ F tool/showshm.c a0ab6ec32dd1f11218ca2a4018f8fb875b59414801ab8ceed8b2e69b7b45a80 F tool/showstat4.c 0682ebea7abf4d3657f53c4a243f2e7eab48eab344ed36a94bb75dcd19a5c2a1 F tool/showwal.c 11eca547980a066b081f512636151233350ac679f29ecf4ebfce7f4530230b3d F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe -F tool/spaceanal.tcl 70c87c04cfd2e77b3e6f21c33ca768296aa8f67d4ab4874786ac8fbb28433477 +F tool/spaceanal.tcl 3568b2b15b83dcaf789e787a4db0980da81eb6fa0e1e00783e4a927fdf584550 F tool/speed-check.sh e8d20cc2eb9c85ec1ba562226de144435456dcdff4ee618de49603c6958f6116 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 754e6e059b740435475c1869feeaca39585b262d5c27210e0fbddbbcc202c4d5 -R ae59ad0856c063c9c0ffaf75175671a5 -U stephan -Z c1ed72f7e9ae5b233f6d9d785940ed28 +P ea16b286b4344c1833ca3d17b6d315fb4ddcb99bcc232ff6444debeb634881f2 +R a7c3f049be65d235476058b7cf9b7ac3 +U drh +Z 301102884eb3249c2db98b7577b2bad4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 149c09e99e..56edd5ef2b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ea16b286b4344c1833ca3d17b6d315fb4ddcb99bcc232ff6444debeb634881f2 \ No newline at end of file +4152894433c3a292d983b1c196664a0c46e406eccd7e644a64fa443fdb204825 \ No newline at end of file diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl index 8fe72b99b1..abc1e7e98b 100644 --- a/tool/spaceanal.tcl +++ b/tool/spaceanal.tcl @@ -596,6 +596,7 @@ set nindex [db eval {SELECT count(*) FROM sqlite_schema WHERE type='index'}] set sql {SELECT count(*) FROM sqlite_schema WHERE name LIKE 'sqlite_autoindex%'} set nautoindex [db eval $sql] set nmanindex [expr {$nindex-$nautoindex}] +set nwithoutrowid [db eval {SELECT count(*) FROM pragma_table_list WHERE wr}] # set total_payload [mem eval "SELECT sum(payload) FROM space_used"] set user_payload [mem one {SELECT int(sum(payload)) FROM space_used @@ -614,6 +615,7 @@ statline {Pages on the freelist (per header)} $free_pgcnt2 $free_percent2 statline {Pages on the freelist (calculated)} $free_pgcnt $free_percent statline {Pages of auto-vacuum overhead} $av_pgcnt $av_percent statline {Number of tables in the database} $ntable +statline {Number of WITHOUT ROWID tables} $nwithoutrowid statline {Number of indices} $nindex statline {Number of defined indices} $nmanindex statline {Number of implied indices} $nautoindex @@ -672,6 +674,14 @@ if {$nindex>0} { subreport {All tables and indices} 1 0 } subreport {All tables} {NOT is_index} 0 +if {$nwithoutrowid>0} { + subreport {All WITHOUT ROWID tables} {is_without_rowid} 0 + set nrowidtab [db eval {SELECT count(*) FROM pragma_table_list + WHERE type='table' AND NOT wr}] + if {$nrowidtab>0} { + subreport {ALL rowid tables} {NOT is_without_rowid AND NOT is_index} 0 + } +} if {$nindex>0} { subreport {All indices} {is_index} 0 } From c98d42e802b24e0387b5efbdd5372a96716ef71e Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 18 Jun 2024 19:36:04 +0000 Subject: [PATCH 0494/1030] Add instructions for how to do debugging builds of the CLI on Windows. FossilOrigin-Name: abe81c18614b41c78cf3edeaaf8d85d5d2dbdcf331b580f1c98f80d3726d8189 --- doc/compile-for-windows.md | 8 ++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/compile-for-windows.md b/doc/compile-for-windows.md index b8a50afb32..5e6a2d1a25 100644 --- a/doc/compile-for-windows.md +++ b/doc/compile-for-windows.md @@ -59,8 +59,16 @@ canonical source on a new Windows 11 PC, as of 2023-11-01:
  • `nmake /f makefile.msc sqlite3.c`
  • `nmake /f makefile.msc devtest`
  • `nmake /f makefile.msc releasetest` +
  • `nmake /f makefile.msc sqlite3.exe` + 7. For a debugging build of the CLI, where the ".treetrace" and ".wheretrace" + commands work, add the DEBUG=3 argument to nmake. Like this: +
      +
    • `nmake /f makefile.msc DEBUG=3 clean sqlite3.exe` +
    + + ## 32-bit Builds Doing a 32-bit build is just like doing a 64-bit build with the diff --git a/manifest b/manifest index 637f1bbbbd..b20d89ac1d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\ssqlite3_analyzer\sto\sreport\son\sthe\snumber\sof\sWITHOUT\sROWID\stables\sand\nto\sprovide\sseparate\saggregate\sstatistics\sfor\sWITHOUT\sand\sWITH\sROWID\stables. -D 2024-06-18T12:19:13.629 +C Add\sinstructions\sfor\show\sto\sdo\sdebugging\sbuilds\sof\sthe\sCLI\son\sWindows. +D 2024-06-18T19:36:04.259 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -39,7 +39,7 @@ F configure 27d144c2edfa993ac155a2ad5e6b431e4ec811159598ef55a59f345bc2e5e533 x F configure.ac f25bd7843120f2c2b8bc9db5a92b0502bbdd28e68907415c3d42fc8e57c657b9 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd -F doc/compile-for-windows.md 50b27d77be96195c66031a3181cb8684ed822327ea834e07f9c014213e5e3bcf +F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ea16b286b4344c1833ca3d17b6d315fb4ddcb99bcc232ff6444debeb634881f2 -R a7c3f049be65d235476058b7cf9b7ac3 +P 4152894433c3a292d983b1c196664a0c46e406eccd7e644a64fa443fdb204825 +R 8045c7729a1141ba8ad2af416451a689 U drh -Z 301102884eb3249c2db98b7577b2bad4 +Z 07f793457b821df508d682a7ee6f3eb0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 56edd5ef2b..f02a6d22fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4152894433c3a292d983b1c196664a0c46e406eccd7e644a64fa443fdb204825 \ No newline at end of file +abe81c18614b41c78cf3edeaaf8d85d5d2dbdcf331b580f1c98f80d3726d8189 \ No newline at end of file From bb6d32ae714e3d2b0efad316c6d1321797b1c61e Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 18 Jun 2024 20:40:11 +0000 Subject: [PATCH 0495/1030] Add fiddle-debug make target to ext/wasm. It builds the same target files as a non-debug build, as opposed to a new copy, but adds various debug-related flags. FossilOrigin-Name: 993143c5c39fb6ee15b0661cec8fed436ff04543b528a3796534f5e3a44799f5 --- ext/wasm/fiddle.make | 9 ++++++++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index 496e518de6..2eb2df3d98 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -45,6 +45,12 @@ fiddle.emcc-flags = \ -DSQLITE_SHELL_FIDDLE # -D_POSIX_C_SOURCE is needed for strdup() with emcc +# Flags specifically for debug builds of fiddle. Performance suffers +# greatly with these enabled. +fiddle.emcc-flags.debug := -DSQLITE_DEBUG \ + -DSQLITE_ENABLE_SELECTTRACE \ + -DSQLITE_ENABLE_WHERETRACE + fiddle.EXPORTED_FUNCTIONS.in := \ EXPORTED_FUNCTIONS.fiddle.in \ $(EXPORTED_FUNCTIONS.api) @@ -82,7 +88,8 @@ clean-fiddle: $(dir.fiddle)/fiddle-module.worker.js \ EXPORTED_FUNCTIONS.fiddle .PHONY: fiddle -fiddle: $(fiddle-module.js) $(dir.fiddle)/fiddle.js.gz +fiddle-debug fiddle: $(fiddle-module.js) $(dir.fiddle)/fiddle.js.gz +fiddle-debug: fiddle.emcc-flags+=$(fiddle.emcc-flags.debug) all: fiddle ######################################################################## diff --git a/manifest b/manifest index b20d89ac1d..7562a60f77 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sinstructions\sfor\show\sto\sdo\sdebugging\sbuilds\sof\sthe\sCLI\son\sWindows. -D 2024-06-18T19:36:04.259 +C Add\sfiddle-debug\smake\starget\sto\sext/wasm.\sIt\sbuilds\sthe\ssame\starget\sfiles\sas\sa\snon-debug\sbuild,\sas\sopposed\sto\sa\snew\scopy,\sbut\sadds\svarious\sdebug-related\sflags. +D 2024-06-18T20:40:11.522 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -643,7 +643,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make 3c2eace29255d6ddd219f5d8cc2728cb28b9fe717ea80b6062c2a6178947a16b +F ext/wasm/fiddle.make 03525afe7f31be004c3b255524c411ee921549f3003f5b30277dad55b5fdef80 F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4152894433c3a292d983b1c196664a0c46e406eccd7e644a64fa443fdb204825 -R 8045c7729a1141ba8ad2af416451a689 -U drh -Z 07f793457b821df508d682a7ee6f3eb0 +P abe81c18614b41c78cf3edeaaf8d85d5d2dbdcf331b580f1c98f80d3726d8189 +R f176d62d38b807625da21142121f534a +U stephan +Z 03eb928d7727220c4344a95c0a62444a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f02a6d22fb..27e086c119 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -abe81c18614b41c78cf3edeaaf8d85d5d2dbdcf331b580f1c98f80d3726d8189 \ No newline at end of file +993143c5c39fb6ee15b0661cec8fed436ff04543b528a3796534f5e3a44799f5 \ No newline at end of file From 98526f906eee48b942689d24f9c73e7ce4b8c521 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 18 Jun 2024 20:47:05 +0000 Subject: [PATCH 0496/1030] Remove an extraneous CSS file and import its CSS into the one HTML file which uses it. FossilOrigin-Name: 66085ca42388e8de741712150541a3e0afb06b3e23e738aa9ff687e9fc494c50 --- ext/wasm/fiddle/emscripten.css | 24 ------------------------ ext/wasm/fiddle/index.html | 25 +++++++++++++++++++++++++ manifest | 13 ++++++------- manifest.uuid | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 ext/wasm/fiddle/emscripten.css diff --git a/ext/wasm/fiddle/emscripten.css b/ext/wasm/fiddle/emscripten.css deleted file mode 100644 index 7e3dc811d0..0000000000 --- a/ext/wasm/fiddle/emscripten.css +++ /dev/null @@ -1,24 +0,0 @@ -/* emcscript-related styling, used during the module load/intialization processes... */ -.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } -div.emscripten { text-align: center; } -div.emscripten_border { border: 1px solid black; } -#module-spinner { overflow: visible; } -#module-spinner > * { - margin-top: 1em; -} -.spinner { - height: 50px; - width: 50px; - margin: 0px auto; - animation: rotation 0.8s linear infinite; - border-left: 10px solid rgb(0,150,240); - border-right: 10px solid rgb(0,150,240); - border-bottom: 10px solid rgb(0,150,240); - border-top: 10px solid rgb(100,0,200); - border-radius: 100%; - background-color: rgb(200,100,250); -} -@keyframes rotation { - from {transform: rotate(0deg);} - to {transform: rotate(360deg);} -} diff --git a/ext/wasm/fiddle/index.html b/ext/wasm/fiddle/index.html index 272f1aca76..5f8647b036 100644 --- a/ext/wasm/fiddle/index.html +++ b/ext/wasm/fiddle/index.html @@ -171,6 +171,31 @@ display: flex; flex-direction: column-reverse; } + + /* emcscript-related styling, used during the module load/intialization processes... */ + .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } + div.emscripten { text-align: center; } + div.emscripten_border { border: 1px solid black; } + #module-spinner { overflow: visible; } + #module-spinner > * { + margin-top: 1em; + } + .spinner { + height: 50px; + width: 50px; + margin: 0px auto; + animation: rotation 0.8s linear infinite; + border-left: 10px solid rgb(0,150,240); + border-right: 10px solid rgb(0,150,240); + border-bottom: 10px solid rgb(0,150,240); + border-top: 10px solid rgb(100,0,200); + border-radius: 100%; + background-color: rgb(200,100,250); + } + @keyframes rotation { + from {transform: rotate(0deg);} + to {transform: rotate(360deg);} + } diff --git a/manifest b/manifest index 7562a60f77..0bdb53ac82 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfiddle-debug\smake\starget\sto\sext/wasm.\sIt\sbuilds\sthe\ssame\starget\sfiles\sas\sa\snon-debug\sbuild,\sas\sopposed\sto\sa\snew\scopy,\sbut\sadds\svarious\sdebug-related\sflags. -D 2024-06-18T20:40:11.522 +C Remove\san\sextraneous\sCSS\sfile\sand\simport\sits\sCSS\sinto\sthe\sone\sHTML\sfile\swhich\suses\sit. +D 2024-06-18T20:47:05.584 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -644,10 +644,9 @@ F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737 F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle.make 03525afe7f31be004c3b255524c411ee921549f3003f5b30277dad55b5fdef80 -F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 -F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2 +F ext/wasm/fiddle/index.html 739e0b75bc592679665d25e2f7649d2b8b2db678f3b41a772a8720b609b8482d F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29aeff8507511f F ext/wasm/index.html 4337f495416756802669f69f9f9f3df9f87ee4c1918e6718719b4b5718e4713a F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 @@ -2195,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P abe81c18614b41c78cf3edeaaf8d85d5d2dbdcf331b580f1c98f80d3726d8189 -R f176d62d38b807625da21142121f534a +P 993143c5c39fb6ee15b0661cec8fed436ff04543b528a3796534f5e3a44799f5 +R 15117f26846a9682ffbdf9b7ee938975 U stephan -Z 03eb928d7727220c4344a95c0a62444a +Z a251c09b46a94a1c05b9b48034b8d67a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 27e086c119..3a762601c7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -993143c5c39fb6ee15b0661cec8fed436ff04543b528a3796534f5e3a44799f5 \ No newline at end of file +66085ca42388e8de741712150541a3e0afb06b3e23e738aa9ff687e9fc494c50 \ No newline at end of file From e042988dc0015c314279b5c903ed077e6959a3f8 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 18 Jun 2024 21:50:30 +0000 Subject: [PATCH 0497/1030] Rework the fiddle build to build separate debug and non-debug bundles, with the latter in ./fiddle-debug. FossilOrigin-Name: a9f1758f1cbe7b7d0c87dfb060f52d03c6ea0e066c079891a8ff354073997f9e --- ext/wasm/GNUmakefile | 4 ++- ext/wasm/fiddle.make | 62 ++++++++++++++++++++++++++++---------------- manifest | 14 +++++----- manifest.uuid | 2 +- 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 115374e623..82c5e199ec 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -139,8 +139,10 @@ dir.api := api dir.jacc := jaccwabyt dir.common := common dir.fiddle := fiddle +dir.fiddle-debug := fiddle-debug dir.tool := $(dir.top)/tool -CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ +CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ \ + $(dir.fiddle-debug)/* ######################################################################## # dir.dout = output dir for deliverables. diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index 2eb2df3d98..c23a79fe01 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -46,8 +46,10 @@ fiddle.emcc-flags = \ # -D_POSIX_C_SOURCE is needed for strdup() with emcc # Flags specifically for debug builds of fiddle. Performance suffers -# greatly with these enabled. -fiddle.emcc-flags.debug := -DSQLITE_DEBUG \ +# greatly in debug builds. +fiddle.emcc-flags.debug := $(fiddle.emcc-flags) \ + -O0 -g \ + -DSQLITE_DEBUG \ -DSQLITE_ENABLE_SELECTTRACE \ -DSQLITE_ENABLE_WHERETRACE @@ -58,27 +60,42 @@ fiddle.EXPORTED_FUNCTIONS.in := \ $(EXPORTED_FUNCTIONS.fiddle): $(fiddle.EXPORTED_FUNCTIONS.in) $(MAKEFILE.fiddle) sort -u $(fiddle.EXPORTED_FUNCTIONS.in) > $@ -fiddle-module.js := $(dir.fiddle)/fiddle-module.js -fiddle-module.wasm := $(subst .js,.wasm,$(fiddle-module.js)) fiddle.cses := $(dir.top)/shell.c $(sqlite3-wasm.c) - -fiddle.SOAP.js := $(dir.fiddle)/$(notdir $(SOAP.js)) -$(fiddle.SOAP.js): $(SOAP.js) - cp $< $@ - $(eval $(call call-make-pre-post,fiddle-module,vanilla)) -$(fiddle-module.js): $(MAKEFILE) $(MAKEFILE.fiddle) \ - $(EXPORTED_FUNCTIONS.fiddle) \ - $(fiddle.cses) $(pre-post-fiddle-module-vanilla.deps) $(fiddle.SOAP.js) - $(emcc.bin) -o $@ $(fiddle.emcc-flags) \ - $(pre-post-fiddle-module-vanilla.flags) \ - $(fiddle.cses) - $(maybe-wasm-strip) $(fiddle-module.wasm) - gzip < $@ > $@.gz - gzip < $(fiddle-module.wasm) > $(fiddle-module.wasm).gz -$(dir.fiddle)/fiddle.js.gz: $(dir.fiddle)/fiddle.js - gzip < $< > $@ +######################################################################## +# emit rules for one of the two fiddle builds. $1 must be +# either $(dir.fiddle) or $(dir.fiddle-debug). $2 must be empty +# in the former case and .debug in the latter. +define make-fiddle-rules +fiddle-module.js$(2) := $(1)/fiddle-module.js +fiddle-module.wasm$(2) := $$(subst .js,.wasm,$$(fiddle-module.js$(2))) +$(1): + @test -d "$$@" || mkdir -p "$$@" + @if [[ x.debug = x$(2) ]]; then \ + cp -p $$(dir.fiddle)/index.html \ + $$(dir.fiddle)/fiddle.js \ + $$(dir.fiddle)/fiddle-worker.js \ + $$@/.; \ + fi +$$(fiddle-module.js$(2)): $(1) $$(MAKEFILE) $$(MAKEFILE.fiddle) \ + $$(EXPORTED_FUNCTIONS.fiddle) \ + $$(fiddle.cses) $$(pre-post-fiddle-module-vanilla.deps) $$(fiddle.SOAP.js$(2)) + $$(emcc.bin) -o $$@ $$(fiddle.emcc-flags$(2)) \ + $$(pre-post-fiddle-module-vanilla.flags) \ + $$(fiddle.cses) + $$(maybe-wasm-strip) $$(fiddle-module.wasm$(2)) + cp -p $$(SOAP.js) $$(dir $$@) + gzip < $$@ > $$@.gz + gzip < $$(fiddle-module.wasm$(2)) > $$(fiddle-module.wasm$(2)).gz + gzip < $(1)/fiddle.js > $(1)/fiddle.js.gz +fiddle$(2): $$(fiddle-module.js$(2)) $(1)/fiddle.js.gz +endef + +$(eval $(call make-fiddle-rules,$(dir.fiddle))) +$(eval $(call make-fiddle-rules,$(dir.fiddle-debug),.debug)) +fiddle: $(fiddle-module.js) $(fiddle-module.js.debug) +fiddle.debug: $(fiddle-module.js.debug) clean: clean-fiddle clean-fiddle: @@ -87,9 +104,8 @@ clean-fiddle: $(dir.fiddle)/$(SOAP.js) \ $(dir.fiddle)/fiddle-module.worker.js \ EXPORTED_FUNCTIONS.fiddle -.PHONY: fiddle -fiddle-debug fiddle: $(fiddle-module.js) $(dir.fiddle)/fiddle.js.gz -fiddle-debug: fiddle.emcc-flags+=$(fiddle.emcc-flags.debug) + rm -fr $(dir.fiddle-debug) +.PHONY: fiddle fiddle.debug all: fiddle ######################################################################## diff --git a/manifest b/manifest index 0bdb53ac82..3cbdf663f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sextraneous\sCSS\sfile\sand\simport\sits\sCSS\sinto\sthe\sone\sHTML\sfile\swhich\suses\sit. -D 2024-06-18T20:47:05.584 +C Rework\sthe\sfiddle\sbuild\sto\sbuild\sseparate\sdebug\sand\snon-debug\sbundles,\swith\sthe\slatter\sin\s./fiddle-debug. +D 2024-06-18T21:50:30.081 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -592,7 +592,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 21f015f342e4ed9b7ff632c10750512259d26c836a34f4f535673fae9a7c9fcc +F ext/wasm/GNUmakefile e0848c0031a075fc1393fffc4e6d8c1bb876df5d346502c647edeca09cf42ae0 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -643,7 +643,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make 03525afe7f31be004c3b255524c411ee921549f3003f5b30277dad55b5fdef80 +F ext/wasm/fiddle.make a0428f0b124e21e1d2a1203dfdccf5b24de084e8a60ad2dfdf01a68ebea877b7 F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 F ext/wasm/fiddle/index.html 739e0b75bc592679665d25e2f7649d2b8b2db678f3b41a772a8720b609b8482d @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 993143c5c39fb6ee15b0661cec8fed436ff04543b528a3796534f5e3a44799f5 -R 15117f26846a9682ffbdf9b7ee938975 +P 66085ca42388e8de741712150541a3e0afb06b3e23e738aa9ff687e9fc494c50 +R 2f95eba5ca33d5fa3d5622563a8162c0 U stephan -Z a251c09b46a94a1c05b9b48034b8d67a +Z 0e4370bc081e0a8227520f51d6156dfb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3a762601c7..1e48be88fd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -66085ca42388e8de741712150541a3e0afb06b3e23e738aa9ff687e9fc494c50 \ No newline at end of file +a9f1758f1cbe7b7d0c87dfb060f52d03c6ea0e066c079891a8ff354073997f9e \ No newline at end of file From 68ba3980d5c5fd8ddc0738e2eb53e8f616803d33 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 18 Jun 2024 22:03:28 +0000 Subject: [PATCH 0498/1030] Minor cleanups in the new fiddle build code. FossilOrigin-Name: d356aebdd450bedc1ecbbdd266effe53c7badbd74ed7e6db8d0c31318d99a35f --- ext/wasm/fiddle.make | 21 +++++++++++---------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index c23a79fe01..396e4dbedc 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -72,12 +72,6 @@ fiddle-module.js$(2) := $(1)/fiddle-module.js fiddle-module.wasm$(2) := $$(subst .js,.wasm,$$(fiddle-module.js$(2))) $(1): @test -d "$$@" || mkdir -p "$$@" - @if [[ x.debug = x$(2) ]]; then \ - cp -p $$(dir.fiddle)/index.html \ - $$(dir.fiddle)/fiddle.js \ - $$(dir.fiddle)/fiddle-worker.js \ - $$@/.; \ - fi $$(fiddle-module.js$(2)): $(1) $$(MAKEFILE) $$(MAKEFILE.fiddle) \ $$(EXPORTED_FUNCTIONS.fiddle) \ $$(fiddle.cses) $$(pre-post-fiddle-module-vanilla.deps) $$(fiddle.SOAP.js$(2)) @@ -85,10 +79,17 @@ $$(fiddle-module.js$(2)): $(1) $$(MAKEFILE) $$(MAKEFILE.fiddle) \ $$(pre-post-fiddle-module-vanilla.flags) \ $$(fiddle.cses) $$(maybe-wasm-strip) $$(fiddle-module.wasm$(2)) - cp -p $$(SOAP.js) $$(dir $$@) - gzip < $$@ > $$@.gz - gzip < $$(fiddle-module.wasm$(2)) > $$(fiddle-module.wasm$(2)).gz - gzip < $(1)/fiddle.js > $(1)/fiddle.js.gz + @cp -p $$(SOAP.js) $$(dir $$@) + @if [[ x.debug = x$(2) ]]; then \ + cp -p $$(dir.fiddle)/index.html \ + $$(dir.fiddle)/fiddle.js \ + $$(dir.fiddle)/fiddle-worker.js \ + $$(dir $$@)/.; \ + fi + @for i in $(1)/*.*js $(1)/*.html $(1)/*.wasm; do \ + test -f $$$${i} || continue; \ + gzip < $$$${i} > $$$${i}.gz; \ + done fiddle$(2): $$(fiddle-module.js$(2)) $(1)/fiddle.js.gz endef diff --git a/manifest b/manifest index 3cbdf663f1..1f1d75d54f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rework\sthe\sfiddle\sbuild\sto\sbuild\sseparate\sdebug\sand\snon-debug\sbundles,\swith\sthe\slatter\sin\s./fiddle-debug. -D 2024-06-18T21:50:30.081 +C Minor\scleanups\sin\sthe\snew\sfiddle\sbuild\scode. +D 2024-06-18T22:03:28.064 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -643,7 +643,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make a0428f0b124e21e1d2a1203dfdccf5b24de084e8a60ad2dfdf01a68ebea877b7 +F ext/wasm/fiddle.make 86b8fcb1b1ff582a98e5913c84fa2ca39f0ad9e62bff019ab503dfad63874b98 F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 F ext/wasm/fiddle/index.html 739e0b75bc592679665d25e2f7649d2b8b2db678f3b41a772a8720b609b8482d @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 66085ca42388e8de741712150541a3e0afb06b3e23e738aa9ff687e9fc494c50 -R 2f95eba5ca33d5fa3d5622563a8162c0 +P a9f1758f1cbe7b7d0c87dfb060f52d03c6ea0e066c079891a8ff354073997f9e +R f25de9701b74b5cd8f8845c6dfa8833e U stephan -Z 0e4370bc081e0a8227520f51d6156dfb +Z 8c7f0a1de8acc9ed8f46178ab3ee4afe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e48be88fd..49b16b1cd3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a9f1758f1cbe7b7d0c87dfb060f52d03c6ea0e066c079891a8ff354073997f9e \ No newline at end of file +d356aebdd450bedc1ecbbdd266effe53c7badbd74ed7e6db8d0c31318d99a35f \ No newline at end of file From d8295c86749ec89c68e9df47fb9b8f03f6032c52 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 19 Jun 2024 11:08:58 +0000 Subject: [PATCH 0499/1030] Remove some extraneous flags from the fiddle-debug build. Internal doc tweaks in the main wasm makefile. FossilOrigin-Name: afae2c9e6fba0820c9be8d06a2e301a74167e4457bada45fe57b5fd9287d2e8b --- ext/wasm/GNUmakefile | 4 ++-- ext/wasm/fiddle.make | 1 - manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 82c5e199ec..d9508e8d7a 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -388,8 +388,8 @@ emcc_opt_full := $(emcc_opt) -g3 # ^^^ -flto improves runtime speed at -O0 considerably but doubles # build time. # -# ^^^^ -O3, -Oz, -Os minify symbol names and there appears to be no -# way around that except to use -g3, but -g3 causes the binary file +# ^^^^ (-O3, -Oz, -Os) all minify symbol names and there appears to be +# no way around that except to use -g3, but -g3 causes the binary file # size to absolutely explode (approx. 5x larger). This minification # utterly breaks the resulting module, making it unsable except as # self-contained/self-referential-only code, as ALL of the exported diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index 396e4dbedc..97cf189b03 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -48,7 +48,6 @@ fiddle.emcc-flags = \ # Flags specifically for debug builds of fiddle. Performance suffers # greatly in debug builds. fiddle.emcc-flags.debug := $(fiddle.emcc-flags) \ - -O0 -g \ -DSQLITE_DEBUG \ -DSQLITE_ENABLE_SELECTTRACE \ -DSQLITE_ENABLE_WHERETRACE diff --git a/manifest b/manifest index 1f1d75d54f..0cd7ed0276 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\scleanups\sin\sthe\snew\sfiddle\sbuild\scode. -D 2024-06-18T22:03:28.064 +C Remove\ssome\sextraneous\sflags\sfrom\sthe\sfiddle-debug\sbuild.\sInternal\sdoc\stweaks\sin\sthe\smain\swasm\smakefile. +D 2024-06-19T11:08:58.746 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -592,7 +592,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile e0848c0031a075fc1393fffc4e6d8c1bb876df5d346502c647edeca09cf42ae0 +F ext/wasm/GNUmakefile 05727be716879b1345892ce8c61dd093aefe26ccc48ad9467f3864b85475993b F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -643,7 +643,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make 86b8fcb1b1ff582a98e5913c84fa2ca39f0ad9e62bff019ab503dfad63874b98 +F ext/wasm/fiddle.make 828c6f3e45ba2541e61fd79c3d8b07a5be4cf13f9acb6430b562bcab3f251496 F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 F ext/wasm/fiddle/index.html 739e0b75bc592679665d25e2f7649d2b8b2db678f3b41a772a8720b609b8482d @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a9f1758f1cbe7b7d0c87dfb060f52d03c6ea0e066c079891a8ff354073997f9e -R f25de9701b74b5cd8f8845c6dfa8833e +P d356aebdd450bedc1ecbbdd266effe53c7badbd74ed7e6db8d0c31318d99a35f +R 1b8d65863430b0c79a5aa023031c20e8 U stephan -Z 8c7f0a1de8acc9ed8f46178ab3ee4afe +Z 118e38e2ad35e8a787c1871b213cd619 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 49b16b1cd3..6a8d4a438c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d356aebdd450bedc1ecbbdd266effe53c7badbd74ed7e6db8d0c31318d99a35f \ No newline at end of file +afae2c9e6fba0820c9be8d06a2e301a74167e4457bada45fe57b5fd9287d2e8b \ No newline at end of file From 199f091a9508ff117326e0f81dc6e4573be1ac6c Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 19 Jun 2024 16:38:17 +0000 Subject: [PATCH 0500/1030] Enhance lemon.c so that when it shows the compile-time options in the header comment of the generated output file, it shows all options, even those not used, and it shows them in sorted order. FossilOrigin-Name: eed76e6698eabe47c6bf9696599ce1c2f7aa428cf60f39d0566fbd0d1f6c4c62 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/lemon.c | 12 +++++++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 0cd7ed0276..a2c27c9e63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sextraneous\sflags\sfrom\sthe\sfiddle-debug\sbuild.\sInternal\sdoc\stweaks\sin\sthe\smain\swasm\smakefile. -D 2024-06-19T11:08:58.746 +C Enhance\slemon.c\sso\sthat\swhen\sit\sshows\sthe\scompile-time\soptions\sin\sthe\sheader\ncomment\sof\sthe\sgenerated\soutput\sfile,\sit\sshows\sall\soptions,\seven\sthose\snot\nused,\sand\sit\sshows\sthem\sin\ssorted\sorder. +D 2024-06-19T16:38:17.988 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2105,7 +2105,7 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c 2eaee61479f9b97056950741c8f671a13281c819b94246698264a322360319a9 +F tool/lemon.c d2506bae870ad1abc0175cd492e4c58395642929e8ad1ed5aa0a3f14ff5fdcce F tool/lempar.c e6b649778e5c027c8365ff01d7ef39297cd7285fa1f881cce31792689541e79f F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d356aebdd450bedc1ecbbdd266effe53c7badbd74ed7e6db8d0c31318d99a35f -R 1b8d65863430b0c79a5aa023031c20e8 -U stephan -Z 118e38e2ad35e8a787c1871b213cd619 +P afae2c9e6fba0820c9be8d06a2e301a74167e4457bada45fe57b5fd9287d2e8b +R 7241db8bc0d5de33af5ed78e8ba69ac8 +U drh +Z f352912aeb1aedd183fd5feefa03cacc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6a8d4a438c..285757f51f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -afae2c9e6fba0820c9be8d06a2e301a74167e4457bada45fe57b5fd9287d2e8b \ No newline at end of file +eed76e6698eabe47c6bf9696599ce1c2f7aa428cf60f39d0566fbd0d1f6c4c62 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 06b9109a1d..a919f447c0 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -1709,6 +1709,15 @@ static void stats_line(const char *zLabel, int iValue){ iValue); } +/* +** Comparison function used by qsort() to sort the azDefine[] array. +*/ +static int defineCmp(const void *pA, const void *pB){ + const char *zA = *(const char**)pA; + const char *zB = *(const char**)pB; + return strcmp(zA,zB); +} + /* The main program. Parse the command line and do it... */ int main(int argc, char **argv){ static int version = 0; @@ -1764,6 +1773,7 @@ int main(int argc, char **argv){ } memset(&lem, 0, sizeof(lem)); lem.errorcnt = 0; + qsort(azDefine, nDefine, sizeof(azDefine[0]), defineCmp); /* Initialize the machine */ Strsafe_init(); @@ -4498,7 +4508,7 @@ void ReportTable( }else{ fprintf(out, " with these options:\n**\n"); lineno += 2; for(i=0; i Date: Wed, 19 Jun 2024 18:46:44 +0000 Subject: [PATCH 0501/1030] In lemon, show all the -D options in the generated header, even if none of them are used. FossilOrigin-Name: 2aa009c38bb207ac59b9bbd6f8e0d7315697b3fd6a01f9431f29a3c7ccad53e7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a2c27c9e63..046bf01b74 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\slemon.c\sso\sthat\swhen\sit\sshows\sthe\scompile-time\soptions\sin\sthe\sheader\ncomment\sof\sthe\sgenerated\soutput\sfile,\sit\sshows\sall\soptions,\seven\sthose\snot\nused,\sand\sit\sshows\sthem\sin\ssorted\sorder. -D 2024-06-19T16:38:17.988 +C In\slemon,\sshow\sall\sthe\s-D\soptions\sin\sthe\sgenerated\sheader,\seven\sif\snone\sof\sthem\nare\sused. +D 2024-06-19T18:46:44.752 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2105,7 +2105,7 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c d2506bae870ad1abc0175cd492e4c58395642929e8ad1ed5aa0a3f14ff5fdcce +F tool/lemon.c 11a76a312591ad4d2d11a664960d14791e6a3698490c2330f8f217d37defb29d F tool/lempar.c e6b649778e5c027c8365ff01d7ef39297cd7285fa1f881cce31792689541e79f F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P afae2c9e6fba0820c9be8d06a2e301a74167e4457bada45fe57b5fd9287d2e8b -R 7241db8bc0d5de33af5ed78e8ba69ac8 +P eed76e6698eabe47c6bf9696599ce1c2f7aa428cf60f39d0566fbd0d1f6c4c62 +R 7ee122c11f32e2edad2a0b78a30e5cda U drh -Z f352912aeb1aedd183fd5feefa03cacc +Z 43a86ba5dbf2c4560b6460986e5be6a3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 285757f51f..e588a3add1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eed76e6698eabe47c6bf9696599ce1c2f7aa428cf60f39d0566fbd0d1f6c4c62 \ No newline at end of file +2aa009c38bb207ac59b9bbd6f8e0d7315697b3fd6a01f9431f29a3c7ccad53e7 diff --git a/tool/lemon.c b/tool/lemon.c index a919f447c0..767dab323a 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4503,7 +4503,7 @@ void ReportTable( fprintf(out, "/* This file is automatically generated by Lemon from input grammar\n" "** source file \"%s\"", lemp->filename); lineno++; - if( nDefineUsed==0 ){ + if( nDefine==0 ){ fprintf(out, ".\n*/\n"); lineno += 2; }else{ fprintf(out, " with these options:\n**\n"); lineno += 2; From 51b3b402c49c2535749c7e790fb52a017e3f5674 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 19 Jun 2024 18:54:04 +0000 Subject: [PATCH 0502/1030] Revert Lemon so that it only shows -D options that are actually used. Though the change to display the options in sorted order is retained. FossilOrigin-Name: e54eb217c9508c19aee085b111a1323c9009f014ba4db6019918e27002c4ca8c --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 046bf01b74..50a39b8487 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\slemon,\sshow\sall\sthe\s-D\soptions\sin\sthe\sgenerated\sheader,\seven\sif\snone\sof\sthem\nare\sused. -D 2024-06-19T18:46:44.752 +C Revert\sLemon\sso\sthat\sit\sonly\sshows\s-D\soptions\sthat\sare\sactually\sused.\s\sThough\nthe\schange\sto\sdisplay\sthe\soptions\sin\ssorted\sorder\sis\sretained. +D 2024-06-19T18:54:04.609 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2105,7 +2105,7 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c 11a76a312591ad4d2d11a664960d14791e6a3698490c2330f8f217d37defb29d +F tool/lemon.c d048516b2c3ad4119b1c1154a73f4f9435b275fea076318959f817effe23b827 F tool/lempar.c e6b649778e5c027c8365ff01d7ef39297cd7285fa1f881cce31792689541e79f F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eed76e6698eabe47c6bf9696599ce1c2f7aa428cf60f39d0566fbd0d1f6c4c62 -R 7ee122c11f32e2edad2a0b78a30e5cda +P 2aa009c38bb207ac59b9bbd6f8e0d7315697b3fd6a01f9431f29a3c7ccad53e7 +R 3281f4b2c4a24316e0e2a5cf40f57c6f U drh -Z 43a86ba5dbf2c4560b6460986e5be6a3 +Z 4a8e9f1737e4d24d9c6b904079fd66cf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e588a3add1..fb56f9dd79 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2aa009c38bb207ac59b9bbd6f8e0d7315697b3fd6a01f9431f29a3c7ccad53e7 +e54eb217c9508c19aee085b111a1323c9009f014ba4db6019918e27002c4ca8c diff --git a/tool/lemon.c b/tool/lemon.c index 767dab323a..d92df2a1a7 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4503,12 +4503,12 @@ void ReportTable( fprintf(out, "/* This file is automatically generated by Lemon from input grammar\n" "** source file \"%s\"", lemp->filename); lineno++; - if( nDefine==0 ){ + if( nDefineUsed==0 ){ fprintf(out, ".\n*/\n"); lineno += 2; }else{ fprintf(out, " with these options:\n**\n"); lineno += 2; for(i=0; i Date: Mon, 24 Jun 2024 14:53:14 +0000 Subject: [PATCH 0503/1030] Enhance the output of ".scanstats vm" to include the absolute number of ticks for each VM instruction, instead of just the percentage of the total. FossilOrigin-Name: 1535828335d2b0eccebae952ed2bc70cc0cd893bd4b079d26b80deff9b5f752b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 10 ++++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 50a39b8487..31df82fc57 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revert\sLemon\sso\sthat\sit\sonly\sshows\s-D\soptions\sthat\sare\sactually\sused.\s\sThough\nthe\schange\sto\sdisplay\sthe\soptions\sin\ssorted\sorder\sis\sretained. -D 2024-06-19T18:54:04.609 +C Enhance\sthe\soutput\sof\s".scanstats\svm"\sto\sinclude\sthe\sabsolute\snumber\sof\sticks\sfor\seach\sVM\sinstruction,\sinstead\sof\sjust\sthe\spercentage\sof\sthe\stotal. +D 2024-06-24T14:53:14.332 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -755,7 +755,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c d26ac0a13b4154cbd71a9a57ca024350cd73f0f6fcf0ca0cbb4537e2d5b3e257 -F src/shell.c.in ad27d1d990e9e5fb7ae8fc38a717e91f55233714f59723e5618baf4a2a3d2b65 +F src/shell.c.in 2ccbed6a9fd451399b0f378aafa323ad2286fa9de54ae0cd28f32907cd94d18d F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2aa009c38bb207ac59b9bbd6f8e0d7315697b3fd6a01f9431f29a3c7ccad53e7 -R 3281f4b2c4a24316e0e2a5cf40f57c6f -U drh -Z 4a8e9f1737e4d24d9c6b904079fd66cf +P e54eb217c9508c19aee085b111a1323c9009f014ba4db6019918e27002c4ca8c +R 30630076c85e61c873cb3b13f5a0b068 +U dan +Z b12244e4fa7e207039bd118f17022633 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fb56f9dd79..a2632ca445 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e54eb217c9508c19aee085b111a1323c9009f014ba4db6019918e27002c4ca8c +1535828335d2b0eccebae952ed2bc70cc0cd893bd4b079d26b80deff9b5f752b diff --git a/src/shell.c.in b/src/shell.c.in index 58475dd6da..a5bfab589b 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -2420,7 +2420,7 @@ static int shell_callback( case MODE_Explain: { static const int aExplainWidth[] = {4, 13, 4, 4, 4, 13, 2, 13}; static const int aExplainMap[] = {0, 1, 2, 3, 4, 5, 6, 7 }; - static const int aScanExpWidth[] = {4, 6, 6, 13, 4, 4, 4, 13, 2, 13}; + static const int aScanExpWidth[] = {4, 15, 6, 13, 4, 4, 4, 13, 2, 13}; static const int aScanExpMap[] = {0, 9, 8, 1, 2, 3, 4, 5, 6, 7 }; const int *aWidth = aExplainWidth; @@ -3430,7 +3430,13 @@ static void display_scanstats( if( pArg->scanstatsOn==3 ){ const char *zSql = " SELECT addr, opcode, p1, p2, p3, p4, p5, comment, nexec," - " round(ncycle*100.0 / (sum(ncycle) OVER ()), 2)||'%' AS cycles" + " format('% 6s (%.2f%%)'," + " CASE WHEN ncycle<100_000 THEN ncycle || ' '" + " WHEN ncycle<100_000_000 THEN (ncycle/1_000) || 'K'" + " WHEN ncycle<100_000_000_000 THEN (ncycle/1_000_000) || 'M'" + " ELSE (ncycle/1000_000_000) || 'G' END," + " ncycle*100.0/(sum(ncycle) OVER ())" + " ) AS cycles" " FROM bytecode(?)"; int rc = SQLITE_OK; From fdda1cbe0c210a394baf59fcb44b2c982fea812f Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 24 Jun 2024 16:08:01 +0000 Subject: [PATCH 0504/1030] Fix some problems with calling fts5 api functions from within non-full-text queries. FossilOrigin-Name: 56d265f956fe6433b625c6d732e55f387af3f643e705316f5a6f709d63731669 --- ext/fts5/fts5_expr.c | 2 +- ext/fts5/fts5_main.c | 23 ++++------- ext/fts5/test/fts5_common.tcl | 5 +++ ext/fts5/test/fts5aux2.test | 71 ++++++++++++++++++++++++++++++++ ext/fts5/test/fts5matchinfo.test | 2 +- manifest | 19 +++++---- manifest.uuid | 2 +- 7 files changed, 98 insertions(+), 26 deletions(-) create mode 100644 ext/fts5/test/fts5aux2.test diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index b8958ba74e..3c70603568 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -1894,7 +1894,7 @@ int sqlite3Fts5ExprClonePhrase( Fts5ExprPhrase *pOrig = 0; /* The phrase extracted from pExpr */ Fts5Expr *pNew = 0; /* Expression to return via *ppNew */ TokenCtx sCtx = {0,0,0}; /* Context object for fts5ParseTokenize */ - if( iPhrase<0 || iPhrase>=pExpr->nPhrase ){ + if( !pExpr || iPhrase<0 || iPhrase>=pExpr->nPhrase ){ rc = SQLITE_RANGE; }else{ pOrig = pExpr->apExprPhrase[iPhrase]; diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 8d03e8e62c..b0072268e2 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -963,6 +963,7 @@ static int fts5NextMethod(sqlite3_vtab_cursor *pCursor){ } }else{ rc = SQLITE_OK; + CsrFlagSet(pCsr, FTS5CSR_REQUIRE_DOCSIZE); } break; } @@ -1436,9 +1437,13 @@ static i64 fts5CursorRowid(Fts5Cursor *pCsr){ assert( pCsr->ePlan==FTS5_PLAN_MATCH || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH || pCsr->ePlan==FTS5_PLAN_SOURCE + || pCsr->ePlan==FTS5_PLAN_SCAN + || pCsr->ePlan==FTS5_PLAN_ROWID ); if( pCsr->pSorter ){ return pCsr->pSorter->iRowid; + }else if( pCsr->ePlan>=FTS5_PLAN_SCAN ){ + return sqlite3_column_int64(pCsr->pStmt, 0); }else{ return sqlite3Fts5ExprRowid(pCsr->pExpr); } @@ -1455,20 +1460,10 @@ static int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ int ePlan = pCsr->ePlan; assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 ); - switch( ePlan ){ - case FTS5_PLAN_SPECIAL: - *pRowid = 0; - break; - - case FTS5_PLAN_SOURCE: - case FTS5_PLAN_MATCH: - case FTS5_PLAN_SORTED_MATCH: - *pRowid = fts5CursorRowid(pCsr); - break; - - default: - *pRowid = sqlite3_column_int64(pCsr->pStmt, 0); - break; + if( ePlan==FTS5_PLAN_SPECIAL ){ + *pRowid = 0; + }else{ + *pRowid = fts5CursorRowid(pCsr); } return SQLITE_OK; diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index fda388a6fb..7076a52bbf 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -114,6 +114,10 @@ proc fts5_test_rowcount {cmd} { $cmd xRowCount } +proc fts5_test_rowid {cmd} { + $cmd xRowid +} + proc test_queryphrase_cb {cnt cmd} { upvar $cnt L for {set i 0} {$i < [$cmd xInstCount]} {incr i} { @@ -167,6 +171,7 @@ proc fts5_aux_test_functions {db} { fts5_test_collist fts5_test_tokenize fts5_test_rowcount + fts5_test_rowid fts5_test_all fts5_test_queryphrase diff --git a/ext/fts5/test/fts5aux2.test b/ext/fts5/test/fts5aux2.test new file mode 100644 index 0000000000..d31ae04ea4 --- /dev/null +++ b/ext/fts5/test/fts5aux2.test @@ -0,0 +1,71 @@ +# 2024 June 24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Tests focusing on the auxiliary function APIs. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5aux + +# If SQLITE_ENABLE_FTS5 is defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE x1 USING fts5(a, b); + INSERT INTO x1 VALUES('a b', 'c d'); + INSERT INTO x1 VALUES('d e', 'a b'); + INSERT INTO x1 VALUES('a b', 'e f'); + INSERT INTO x1 VALUES('d e', 'c d'); +} + +fts5_aux_test_functions db +do_execsql_test 1.1 { + SELECT fts5_test_all(x1) FROM x1 WHERE rowid=2 +} [list [list {*}{ + columnsize {2 2} + columntext {{d e} {a b}} + columntotalsize {8 8} + poslist {} + tokenize {{d e} {a b}} + rowcount 4 +}]] + +do_execsql_test 1.2 { + SELECT fts5_test_columntext(x1) FROM x1 +} { + {{a b} {c d}} + {{d e} {a b}} + {{a b} {e f}} + {{d e} {c d}} +} + +do_execsql_test 1.3 { + SELECT fts5_test_rowid(x1) FROM x1 +} { + 1 2 3 4 +} +do_execsql_test 1.4 { + SELECT fts5_test_phrasecount(x1) FROM x1 +} { + 0 0 0 0 +} +do_catchsql_test 1.5 { + SELECT fts5_queryphrase(x1, 0) FROM x1 +} {1 SQLITE_RANGE} +do_execsql_test 1.6 { + SELECT fts5_test_rowcount(x1) FROM x1 +} {4 4 4 4} + + +finish_test diff --git a/ext/fts5/test/fts5matchinfo.test b/ext/fts5/test/fts5matchinfo.test index 570693373f..93361a5fe7 100644 --- a/ext/fts5/test/fts5matchinfo.test +++ b/ext/fts5/test/fts5matchinfo.test @@ -517,7 +517,7 @@ fts5_aux_test_functions db do_execsql_test 15.3 { SELECT fts5_test_all(t1) FROM t1 LIMIT 1; } { - {columnsize {0 0} columntext {c d} columntotalsize {2 2} poslist {} tokenize {c d} rowcount 2} + {columnsize {1 1} columntext {c d} columntotalsize {2 2} poslist {} tokenize {c d} rowcount 2} } finish_test diff --git a/manifest b/manifest index 31df82fc57..e2ceb7d6b3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\soutput\sof\s".scanstats\svm"\sto\sinclude\sthe\sabsolute\snumber\sof\sticks\sfor\seach\sVM\sinstruction,\sinstead\sof\sjust\sthe\spercentage\sof\sthe\stotal. -D 2024-06-24T14:53:14.332 +C Fix\ssome\sproblems\swith\scalling\sfts5\sapi\sfunctions\sfrom\swithin\snon-full-text\squeries. +D 2024-06-24T16:08:01.650 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -97,10 +97,10 @@ F ext/fts5/fts5Int.h 407ee36addad0ae6df5d37a811f0bd509ab6708b29640884ed5c7509e5f F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 -F ext/fts5/fts5_expr.c 85789f6fb01995f2578b60a360057ed754335a890b1ab2e57e238b3670a9ae6c +F ext/fts5/fts5_expr.c fb26894f8dd1081afefb70f0baa36a6e80b40d89df90140bc713d27194dc6dd9 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c 21ddeb331ae6c9e990a18299c977156a9dac9ee92f372cfe7928d04433295042 +F ext/fts5/fts5_main.c 1d8bd88240f4ece62645c93df2a09162607e3b3d33838107bb711e8ad1f7cf14 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -111,7 +111,7 @@ F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d0988 F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl 3378732aae2a7d9a4b9b5c40bde678d4259ca16bd490883325aecc4747bcb384 +F ext/fts5/test/fts5_common.tcl bc33c6cc65e5d390f28a68aeeb3a526dadd2c3a947d2466ee1986c1a4002df56 F ext/fts5/test/fts5aa.test 4db81519863244a3cab35795fe65ab6b592e7970c7409eba098b23ebbfc08d95 F ext/fts5/test/fts5ab.test bd932720c748383277456b81f91bc00453de2174f9762cd05f95d0495dc50390 F ext/fts5/test/fts5ac.test a7aa7e1fefc6e1918aa4d3111d5c44a09177168e962c5fd2cca9620de8a7ed6d @@ -127,6 +127,7 @@ F ext/fts5/test/fts5al.test 00c4c1c6a1366b73aa48ce2068c634520867c3cf7f5d1676ebbb F ext/fts5/test/fts5alter.test 5565f7e4605512b69171ac18ca84398603f9f6456dbe377beeca97e83cc242cd F ext/fts5/test/fts5auto.test 78989e6527ce69c9eddbef7392fea5c10b0010cd2b2ae68eec7bc869c471e691 F ext/fts5/test/fts5aux.test f3b4aa403cb672b0d79af1a87519e5896b309ab026de6425fa179589da55d7a5 +F ext/fts5/test/fts5aux2.test baa1b32f152384378d40d8ed40922e91e37eccbca72471c85e1d8b3f541c3e84 F ext/fts5/test/fts5auxdata.test eacc97ff04892f1a5f3d4df5a73f8bcbc3955ea1d12c9f24137eb1fc079e7611 F ext/fts5/test/fts5bigid.test 2860854c2561a57594192b00c33a29f91cb85e25f3d6c03b5c2b8f62708f39dd F ext/fts5/test/fts5bigpl.test 6466c89b38439f0aba26ac09e232a6b963f29b1cbe1304f6a664fe1e7a8f5fd3 @@ -183,7 +184,7 @@ F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fd F ext/fts5/test/fts5lastrowid.test be98fe3e03235296585b72daad7aed5717ba0062bae5e5c18dd6e04e194c6b28 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5matchinfo.test 10c9a6f7fe61fb132299c4183c012770b10c4d5c2f2edb6df0b6607f683d737a +F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test e92a8db28b45931e7a9c7b1bbd36101692759d00274df74d83fd29d25d53b3a6 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 F ext/fts5/test/fts5misc.test b88aa28ff20238b394495b0795cddca1a62b98fa09b99e462a8abc572d04ee88 @@ -2194,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e54eb217c9508c19aee085b111a1323c9009f014ba4db6019918e27002c4ca8c -R 30630076c85e61c873cb3b13f5a0b068 +P 1535828335d2b0eccebae952ed2bc70cc0cd893bd4b079d26b80deff9b5f752b +R 533ea7a7dd358b4ef85ffe0b89a8a342 U dan -Z b12244e4fa7e207039bd118f17022633 +Z 115082379d887d07e03d9d2d6d25a1bf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a2632ca445..1b128a6fe5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1535828335d2b0eccebae952ed2bc70cc0cd893bd4b079d26b80deff9b5f752b +56d265f956fe6433b625c6d732e55f387af3f643e705316f5a6f709d63731669 From 105c20648e1b05839fd0638686b95f2e3998abcb Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 24 Jun 2024 18:06:15 +0000 Subject: [PATCH 0505/1030] Fix an incorrect tcl comment that appeared in many fts5 test files. FossilOrigin-Name: d07085e2035b52a7edd27980523225e59c5bf851fb4a6de975f03e653b937c9c --- ext/fts5/test/fts5ab.test | 2 +- ext/fts5/test/fts5ac.test | 2 +- ext/fts5/test/fts5ad.test | 2 +- ext/fts5/test/fts5ae.test | 2 +- ext/fts5/test/fts5af.test | 2 +- ext/fts5/test/fts5ag.test | 2 +- ext/fts5/test/fts5ah.test | 2 +- ext/fts5/test/fts5ai.test | 2 +- ext/fts5/test/fts5aj.test | 2 +- ext/fts5/test/fts5ak.test | 2 +- ext/fts5/test/fts5al.test | 2 +- ext/fts5/test/fts5alter.test | 2 +- ext/fts5/test/fts5auto.test | 2 +- ext/fts5/test/fts5aux.test | 2 +- ext/fts5/test/fts5aux2.test | 2 +- ext/fts5/test/fts5auxdata.test | 2 +- ext/fts5/test/fts5bigpl.test | 2 +- ext/fts5/test/fts5columnsize.test | 2 +- ext/fts5/test/fts5config.test | 2 +- ext/fts5/test/fts5content.test | 2 +- ext/fts5/test/fts5contentless.test | 2 +- ext/fts5/test/fts5contentless2.test | 2 +- ext/fts5/test/fts5contentless3.test | 2 +- ext/fts5/test/fts5contentless4.test | 2 +- ext/fts5/test/fts5contentless5.test | 2 +- ext/fts5/test/fts5corrupt.test | 2 +- ext/fts5/test/fts5corrupt2.test | 2 +- ext/fts5/test/fts5corrupt3.test | 2 +- ext/fts5/test/fts5corrupt4.test | 2 +- ext/fts5/test/fts5corrupt5.test | 2 +- ext/fts5/test/fts5corrupt6.test | 2 +- ext/fts5/test/fts5corrupt7.test | 2 +- ext/fts5/test/fts5dlidx.test | 2 +- ext/fts5/test/fts5doclist.test | 2 +- ext/fts5/test/fts5ea.test | 2 +- ext/fts5/test/fts5eb.test | 2 +- ext/fts5/test/fts5fault6.test | 2 +- ext/fts5/test/fts5faultG.test | 2 +- ext/fts5/test/fts5faultH.test | 2 +- ext/fts5/test/fts5full.test | 2 +- ext/fts5/test/fts5hash.test | 2 +- ext/fts5/test/fts5integrity.test | 2 +- ext/fts5/test/fts5lastrowid.test | 2 +- ext/fts5/test/fts5merge.test | 2 +- ext/fts5/test/fts5near.test | 2 +- ext/fts5/test/fts5optimize.test | 2 +- ext/fts5/test/fts5optimize2.test | 2 +- ext/fts5/test/fts5optimize3.test | 2 +- ext/fts5/test/fts5origintext.test | 2 +- ext/fts5/test/fts5origintext2.test | 2 +- ext/fts5/test/fts5origintext3.test | 2 +- ext/fts5/test/fts5origintext4.test | 2 +- ext/fts5/test/fts5origintext5.test | 2 +- ext/fts5/test/fts5phrase.test | 2 +- ext/fts5/test/fts5plan.test | 2 +- ext/fts5/test/fts5porter.test | 2 +- ext/fts5/test/fts5porter2.test | 2 +- ext/fts5/test/fts5prefix.test | 2 +- ext/fts5/test/fts5prefix2.test | 2 +- ext/fts5/test/fts5query.test | 2 +- ext/fts5/test/fts5rank.test | 2 +- ext/fts5/test/fts5rebuild.test | 2 +- ext/fts5/test/fts5restart.test | 2 +- ext/fts5/test/fts5rowid.test | 2 +- ext/fts5/test/fts5savepoint.test | 2 +- ext/fts5/test/fts5securefault.test | 2 +- ext/fts5/test/fts5simple.test | 2 +- ext/fts5/test/fts5simple2.test | 2 +- ext/fts5/test/fts5simple3.test | 2 +- ext/fts5/test/fts5synonym.test | 2 +- ext/fts5/test/fts5synonym2.test | 2 +- ext/fts5/test/fts5tokenizer.test | 2 +- ext/fts5/test/fts5tokenizer2.test | 2 +- ext/fts5/test/fts5ubsan.test | 2 +- ext/fts5/test/fts5unicode.test | 2 +- ext/fts5/test/fts5unicode2.test | 2 +- ext/fts5/test/fts5unicode3.test | 2 +- ext/fts5/test/fts5unicode4.test | 2 +- ext/fts5/test/fts5unindexed.test | 2 +- ext/fts5/test/fts5version.test | 2 +- ext/fts5/test/fts5vocab.test | 2 +- ext/fts5/test/fts5vocab2.test | 2 +- manifest | 174 ++++++++++++++-------------- manifest.uuid | 2 +- 84 files changed, 170 insertions(+), 170 deletions(-) diff --git a/ext/fts5/test/fts5ab.test b/ext/fts5/test/fts5ab.test index 5aa7456586..7e312286f3 100644 --- a/ext/fts5/test/fts5ab.test +++ b/ext/fts5/test/fts5ab.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ab -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ac.test b/ext/fts5/test/fts5ac.test index f3a914653f..4628e909c1 100644 --- a/ext/fts5/test/fts5ac.test +++ b/ext/fts5/test/fts5ac.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ac -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ad.test b/ext/fts5/test/fts5ad.test index 524da6deae..27806a4c0c 100644 --- a/ext/fts5/test/fts5ad.test +++ b/ext/fts5/test/fts5ad.test @@ -18,7 +18,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ad -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ae.test b/ext/fts5/test/fts5ae.test index d9f132ca97..205a59a69f 100644 --- a/ext/fts5/test/fts5ae.test +++ b/ext/fts5/test/fts5ae.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ae -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5af.test b/ext/fts5/test/fts5af.test index 3d79295092..9c95ef2daa 100644 --- a/ext/fts5/test/fts5af.test +++ b/ext/fts5/test/fts5af.test @@ -18,7 +18,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5af -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ag.test b/ext/fts5/test/fts5ag.test index 9ead957c9d..42cd913784 100644 --- a/ext/fts5/test/fts5ag.test +++ b/ext/fts5/test/fts5ag.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ag -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ah.test b/ext/fts5/test/fts5ah.test index 0004351375..bc80057833 100644 --- a/ext/fts5/test/fts5ah.test +++ b/ext/fts5/test/fts5ah.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ah -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ai.test b/ext/fts5/test/fts5ai.test index 20e1069398..a6576d3afc 100644 --- a/ext/fts5/test/fts5ai.test +++ b/ext/fts5/test/fts5ai.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ai -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5aj.test b/ext/fts5/test/fts5aj.test index 50dae20162..e802306b38 100644 --- a/ext/fts5/test/fts5aj.test +++ b/ext/fts5/test/fts5aj.test @@ -19,7 +19,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5aj -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ak.test b/ext/fts5/test/fts5ak.test index e248f2a328..253f14fc79 100644 --- a/ext/fts5/test/fts5ak.test +++ b/ext/fts5/test/fts5ak.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ak -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5al.test b/ext/fts5/test/fts5al.test index 842d991a37..b344e0d2ea 100644 --- a/ext/fts5/test/fts5al.test +++ b/ext/fts5/test/fts5al.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5al -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5alter.test b/ext/fts5/test/fts5alter.test index 67f948cbbe..bb5f78dc86 100644 --- a/ext/fts5/test/fts5alter.test +++ b/ext/fts5/test/fts5alter.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5alter -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5auto.test b/ext/fts5/test/fts5auto.test index 79d432b812..b771af912e 100644 --- a/ext/fts5/test/fts5auto.test +++ b/ext/fts5/test/fts5auto.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5auto -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5aux.test b/ext/fts5/test/fts5aux.test index 2a623e78bd..960dbc5117 100644 --- a/ext/fts5/test/fts5aux.test +++ b/ext/fts5/test/fts5aux.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5aux -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5aux2.test b/ext/fts5/test/fts5aux2.test index d31ae04ea4..2352970ec7 100644 --- a/ext/fts5/test/fts5aux2.test +++ b/ext/fts5/test/fts5aux2.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5aux -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5auxdata.test b/ext/fts5/test/fts5auxdata.test index a2a41704c5..7f99fed316 100644 --- a/ext/fts5/test/fts5auxdata.test +++ b/ext/fts5/test/fts5auxdata.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5auxdata -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5bigpl.test b/ext/fts5/test/fts5bigpl.test index 2c9df11b1f..9e3d86c0e6 100644 --- a/ext/fts5/test/fts5bigpl.test +++ b/ext/fts5/test/fts5bigpl.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5bigpl -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5columnsize.test b/ext/fts5/test/fts5columnsize.test index 2b03d575aa..7af49184b8 100644 --- a/ext/fts5/test/fts5columnsize.test +++ b/ext/fts5/test/fts5columnsize.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5columnsize -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5config.test b/ext/fts5/test/fts5config.test index 35894c6bb0..28f3146ea3 100644 --- a/ext/fts5/test/fts5config.test +++ b/ext/fts5/test/fts5config.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5config -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5content.test b/ext/fts5/test/fts5content.test index 986d7f3311..5d5d8f9191 100644 --- a/ext/fts5/test/fts5content.test +++ b/ext/fts5/test/fts5content.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5content -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5contentless.test b/ext/fts5/test/fts5contentless.test index 48cfd10ffa..eb6b928ab8 100644 --- a/ext/fts5/test/fts5contentless.test +++ b/ext/fts5/test/fts5contentless.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5contentless -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5contentless2.test b/ext/fts5/test/fts5contentless2.test index fdd7a60fce..248534bce4 100644 --- a/ext/fts5/test/fts5contentless2.test +++ b/ext/fts5/test/fts5contentless2.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5contentless2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5contentless3.test b/ext/fts5/test/fts5contentless3.test index 76119dc592..693840da82 100644 --- a/ext/fts5/test/fts5contentless3.test +++ b/ext/fts5/test/fts5contentless3.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5contentless3 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5contentless4.test b/ext/fts5/test/fts5contentless4.test index 702b33a9de..7fdf8c4b01 100644 --- a/ext/fts5/test/fts5contentless4.test +++ b/ext/fts5/test/fts5contentless4.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5contentless4 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5contentless5.test b/ext/fts5/test/fts5contentless5.test index a20134d1e7..b08f810a63 100644 --- a/ext/fts5/test/fts5contentless5.test +++ b/ext/fts5/test/fts5contentless5.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5contentless5 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5corrupt.test b/ext/fts5/test/fts5corrupt.test index 9aa84a0ef2..1c7a1a6d0b 100644 --- a/ext/fts5/test/fts5corrupt.test +++ b/ext/fts5/test/fts5corrupt.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5corrupt -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5corrupt2.test b/ext/fts5/test/fts5corrupt2.test index 06e2e74258..51141adf0d 100644 --- a/ext/fts5/test/fts5corrupt2.test +++ b/ext/fts5/test/fts5corrupt2.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5corrupt2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5corrupt3.test b/ext/fts5/test/fts5corrupt3.test index f9a95665c4..b76a9b794e 100644 --- a/ext/fts5/test/fts5corrupt3.test +++ b/ext/fts5/test/fts5corrupt3.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5corrupt3 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5corrupt4.test b/ext/fts5/test/fts5corrupt4.test index b31f4d96e9..0505250c2f 100644 --- a/ext/fts5/test/fts5corrupt4.test +++ b/ext/fts5/test/fts5corrupt4.test @@ -14,7 +14,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5corrupt4 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5corrupt5.test b/ext/fts5/test/fts5corrupt5.test index 1588d8d69e..19f0538418 100644 --- a/ext/fts5/test/fts5corrupt5.test +++ b/ext/fts5/test/fts5corrupt5.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5corrupt5 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5corrupt6.test b/ext/fts5/test/fts5corrupt6.test index 6403d3a406..6570871e3f 100644 --- a/ext/fts5/test/fts5corrupt6.test +++ b/ext/fts5/test/fts5corrupt6.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5corrupt6 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5corrupt7.test b/ext/fts5/test/fts5corrupt7.test index ae7f9da7d9..41e359f422 100644 --- a/ext/fts5/test/fts5corrupt7.test +++ b/ext/fts5/test/fts5corrupt7.test @@ -13,7 +13,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5corrupt7 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5dlidx.test b/ext/fts5/test/fts5dlidx.test index 1fb95a9004..db82db1c2b 100644 --- a/ext/fts5/test/fts5dlidx.test +++ b/ext/fts5/test/fts5dlidx.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5dlidx -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5doclist.test b/ext/fts5/test/fts5doclist.test index 08b773f6f5..5b1becb514 100644 --- a/ext/fts5/test/fts5doclist.test +++ b/ext/fts5/test/fts5doclist.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5doclist -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ea.test b/ext/fts5/test/fts5ea.test index 3ccbd7d7a2..49c2f2753a 100644 --- a/ext/fts5/test/fts5ea.test +++ b/ext/fts5/test/fts5ea.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ea -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5eb.test b/ext/fts5/test/fts5eb.test index 0c775791fa..b704cf4eca 100644 --- a/ext/fts5/test/fts5eb.test +++ b/ext/fts5/test/fts5eb.test @@ -13,7 +13,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5eb -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5fault6.test b/ext/fts5/test/fts5fault6.test index a39063a356..1aacddce9f 100644 --- a/ext/fts5/test/fts5fault6.test +++ b/ext/fts5/test/fts5fault6.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] source $testdir/malloc_common.tcl set testprefix fts5fault6 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5faultG.test b/ext/fts5/test/fts5faultG.test index 33a41dcb38..9110c6336d 100644 --- a/ext/fts5/test/fts5faultG.test +++ b/ext/fts5/test/fts5faultG.test @@ -14,7 +14,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] source $testdir/malloc_common.tcl set testprefix fts5faultG -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5faultH.test b/ext/fts5/test/fts5faultH.test index df430f20fa..0cbbf7f5ef 100644 --- a/ext/fts5/test/fts5faultH.test +++ b/ext/fts5/test/fts5faultH.test @@ -14,7 +14,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] source $testdir/malloc_common.tcl set testprefix fts5faultG -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5full.test b/ext/fts5/test/fts5full.test index 751e874c3b..76fdc0288f 100644 --- a/ext/fts5/test/fts5full.test +++ b/ext/fts5/test/fts5full.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5full -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5hash.test b/ext/fts5/test/fts5hash.test index 5df55f226f..b3d8b562c8 100644 --- a/ext/fts5/test/fts5hash.test +++ b/ext/fts5/test/fts5hash.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5hash -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5integrity.test b/ext/fts5/test/fts5integrity.test index 7936729340..d1365a47a1 100644 --- a/ext/fts5/test/fts5integrity.test +++ b/ext/fts5/test/fts5integrity.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5integrity -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5lastrowid.test b/ext/fts5/test/fts5lastrowid.test index d152a8f09b..75866139d3 100644 --- a/ext/fts5/test/fts5lastrowid.test +++ b/ext/fts5/test/fts5lastrowid.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5lastrowid -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5merge.test b/ext/fts5/test/fts5merge.test index 3b86167b0d..c57c21ded3 100644 --- a/ext/fts5/test/fts5merge.test +++ b/ext/fts5/test/fts5merge.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5merge -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5near.test b/ext/fts5/test/fts5near.test index bbe144a898..318a169488 100644 --- a/ext/fts5/test/fts5near.test +++ b/ext/fts5/test/fts5near.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5near -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5optimize.test b/ext/fts5/test/fts5optimize.test index e0f0fd7242..610bf439c9 100644 --- a/ext/fts5/test/fts5optimize.test +++ b/ext/fts5/test/fts5optimize.test @@ -14,7 +14,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5optimize -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5optimize2.test b/ext/fts5/test/fts5optimize2.test index b0b28874c3..57f4e96b99 100644 --- a/ext/fts5/test/fts5optimize2.test +++ b/ext/fts5/test/fts5optimize2.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5optimize2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5optimize3.test b/ext/fts5/test/fts5optimize3.test index 7b11b9402d..79e62f9f22 100644 --- a/ext/fts5/test/fts5optimize3.test +++ b/ext/fts5/test/fts5optimize3.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5optimize2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5origintext.test b/ext/fts5/test/fts5origintext.test index 9752f35d34..cc9d99e2d9 100644 --- a/ext/fts5/test/fts5origintext.test +++ b/ext/fts5/test/fts5origintext.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5origintext -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5origintext2.test b/ext/fts5/test/fts5origintext2.test index a8c5d4eb50..a8c7172344 100644 --- a/ext/fts5/test/fts5origintext2.test +++ b/ext/fts5/test/fts5origintext2.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5origintext2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5origintext3.test b/ext/fts5/test/fts5origintext3.test index 834844595d..9dda2a5748 100644 --- a/ext/fts5/test/fts5origintext3.test +++ b/ext/fts5/test/fts5origintext3.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5origintext3 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5origintext4.test b/ext/fts5/test/fts5origintext4.test index c4ae350117..3b907ba2cc 100644 --- a/ext/fts5/test/fts5origintext4.test +++ b/ext/fts5/test/fts5origintext4.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5origintext4 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5origintext5.test b/ext/fts5/test/fts5origintext5.test index 03d5bee215..848cc15b5c 100644 --- a/ext/fts5/test/fts5origintext5.test +++ b/ext/fts5/test/fts5origintext5.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5origintext -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5phrase.test b/ext/fts5/test/fts5phrase.test index 10598ccf43..ea425a4dd6 100644 --- a/ext/fts5/test/fts5phrase.test +++ b/ext/fts5/test/fts5phrase.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5phrase -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5plan.test b/ext/fts5/test/fts5plan.test index 6862acf179..57d5254a35 100644 --- a/ext/fts5/test/fts5plan.test +++ b/ext/fts5/test/fts5plan.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5plan -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5porter.test b/ext/fts5/test/fts5porter.test index c7b1ce6f3f..de1c3e15a3 100644 --- a/ext/fts5/test/fts5porter.test +++ b/ext/fts5/test/fts5porter.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5porter -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5porter2.test b/ext/fts5/test/fts5porter2.test index 6e81b2d310..556060baa3 100644 --- a/ext/fts5/test/fts5porter2.test +++ b/ext/fts5/test/fts5porter2.test @@ -18,7 +18,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5porter2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5prefix.test b/ext/fts5/test/fts5prefix.test index 279f312f22..7a29628ea1 100644 --- a/ext/fts5/test/fts5prefix.test +++ b/ext/fts5/test/fts5prefix.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5prefix -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5prefix2.test b/ext/fts5/test/fts5prefix2.test index 29744c86bf..0860b3cddd 100644 --- a/ext/fts5/test/fts5prefix2.test +++ b/ext/fts5/test/fts5prefix2.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5prefix2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5query.test b/ext/fts5/test/fts5query.test index 5237e8e250..4e8bab8cf7 100644 --- a/ext/fts5/test/fts5query.test +++ b/ext/fts5/test/fts5query.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5query -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5rank.test b/ext/fts5/test/fts5rank.test index 8cf223f44b..7a700cb97f 100644 --- a/ext/fts5/test/fts5rank.test +++ b/ext/fts5/test/fts5rank.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5rank -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5rebuild.test b/ext/fts5/test/fts5rebuild.test index ae881c02f0..d74b148fb1 100644 --- a/ext/fts5/test/fts5rebuild.test +++ b/ext/fts5/test/fts5rebuild.test @@ -14,7 +14,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5rebuild -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5restart.test b/ext/fts5/test/fts5restart.test index db2c62b675..411433600d 100644 --- a/ext/fts5/test/fts5restart.test +++ b/ext/fts5/test/fts5restart.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5restart -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5rowid.test b/ext/fts5/test/fts5rowid.test index 8935ecfea7..e4e4f6b844 100644 --- a/ext/fts5/test/fts5rowid.test +++ b/ext/fts5/test/fts5rowid.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5rowid -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5savepoint.test b/ext/fts5/test/fts5savepoint.test index 1126222750..fdb0a25ba5 100644 --- a/ext/fts5/test/fts5savepoint.test +++ b/ext/fts5/test/fts5savepoint.test @@ -13,7 +13,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5savepoint -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5securefault.test b/ext/fts5/test/fts5securefault.test index 63874ece5d..2959ab65ce 100644 --- a/ext/fts5/test/fts5securefault.test +++ b/ext/fts5/test/fts5securefault.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] source $testdir/malloc_common.tcl set testprefix fts5securefault -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. return_if_no_fts5 do_execsql_test 1.0 { diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 936bbb2549..6384095067 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -13,7 +13,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5simple -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5simple2.test b/ext/fts5/test/fts5simple2.test index 6c0e0e1662..01c590c9f7 100644 --- a/ext/fts5/test/fts5simple2.test +++ b/ext/fts5/test/fts5simple2.test @@ -13,7 +13,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5simple2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5simple3.test b/ext/fts5/test/fts5simple3.test index 0d4972b372..680448081d 100644 --- a/ext/fts5/test/fts5simple3.test +++ b/ext/fts5/test/fts5simple3.test @@ -13,7 +13,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5simple3 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5synonym.test b/ext/fts5/test/fts5synonym.test index 86610ee9eb..55e2f186a9 100644 --- a/ext/fts5/test/fts5synonym.test +++ b/ext/fts5/test/fts5synonym.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5synonym -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5synonym2.test b/ext/fts5/test/fts5synonym2.test index 9fdf757693..ec8b750c57 100644 --- a/ext/fts5/test/fts5synonym2.test +++ b/ext/fts5/test/fts5synonym2.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5synonym2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5tokenizer.test b/ext/fts5/test/fts5tokenizer.test index 7497024dca..a828e3a22b 100644 --- a/ext/fts5/test/fts5tokenizer.test +++ b/ext/fts5/test/fts5tokenizer.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5tokenizer -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5tokenizer2.test b/ext/fts5/test/fts5tokenizer2.test index bdabd53127..0017046baf 100644 --- a/ext/fts5/test/fts5tokenizer2.test +++ b/ext/fts5/test/fts5tokenizer2.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5tokenizer2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5ubsan.test b/ext/fts5/test/fts5ubsan.test index 2dc0aa7bd4..76382a1e15 100644 --- a/ext/fts5/test/fts5ubsan.test +++ b/ext/fts5/test/fts5ubsan.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5ubsan -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5unicode.test b/ext/fts5/test/fts5unicode.test index e2d0f60124..d7fb9670f0 100644 --- a/ext/fts5/test/fts5unicode.test +++ b/ext/fts5/test/fts5unicode.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5unicode -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5unicode2.test b/ext/fts5/test/fts5unicode2.test index 662b9dd87b..48daf4f100 100644 --- a/ext/fts5/test/fts5unicode2.test +++ b/ext/fts5/test/fts5unicode2.test @@ -17,7 +17,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5unicode2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5unicode3.test b/ext/fts5/test/fts5unicode3.test index 30eb3c4166..ddb61a9997 100644 --- a/ext/fts5/test/fts5unicode3.test +++ b/ext/fts5/test/fts5unicode3.test @@ -14,7 +14,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5unicode4.test b/ext/fts5/test/fts5unicode4.test index dfd7f5a254..dc225cb5e2 100644 --- a/ext/fts5/test/fts5unicode4.test +++ b/ext/fts5/test/fts5unicode4.test @@ -14,7 +14,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5unicode4 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5unindexed.test b/ext/fts5/test/fts5unindexed.test index 8b72c4c776..5099a89693 100644 --- a/ext/fts5/test/fts5unindexed.test +++ b/ext/fts5/test/fts5unindexed.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5unindexed -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5version.test b/ext/fts5/test/fts5version.test index 79fd94e6bc..a92c0dc9f4 100644 --- a/ext/fts5/test/fts5version.test +++ b/ext/fts5/test/fts5version.test @@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5version -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5vocab.test b/ext/fts5/test/fts5vocab.test index c457c5c210..9e20180c89 100644 --- a/ext/fts5/test/fts5vocab.test +++ b/ext/fts5/test/fts5vocab.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5vocab -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/ext/fts5/test/fts5vocab2.test b/ext/fts5/test/fts5vocab2.test index ecacc50dab..7b3c3b0d6a 100644 --- a/ext/fts5/test/fts5vocab2.test +++ b/ext/fts5/test/fts5vocab2.test @@ -15,7 +15,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5vocab2 -# If SQLITE_ENABLE_FTS5 is defined, omit this file. +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test return diff --git a/manifest b/manifest index e2ceb7d6b3..83472c33cf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sproblems\swith\scalling\sfts5\sapi\sfunctions\sfrom\swithin\snon-full-text\squeries. -D 2024-06-24T16:08:01.650 +C Fix\san\sincorrect\stcl\scomment\sthat\sappeared\sin\smany\sfts5\stest\sfiles. +D 2024-06-24T18:06:15.031 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -113,58 +113,58 @@ F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl bc33c6cc65e5d390f28a68aeeb3a526dadd2c3a947d2466ee1986c1a4002df56 F ext/fts5/test/fts5aa.test 4db81519863244a3cab35795fe65ab6b592e7970c7409eba098b23ebbfc08d95 -F ext/fts5/test/fts5ab.test bd932720c748383277456b81f91bc00453de2174f9762cd05f95d0495dc50390 -F ext/fts5/test/fts5ac.test a7aa7e1fefc6e1918aa4d3111d5c44a09177168e962c5fd2cca9620de8a7ed6d -F ext/fts5/test/fts5ad.test e8cf959dfcd57c8e46d6f5f25665686f3b6627130a9a981371dafdf6482790de -F ext/fts5/test/fts5ae.test 1142d16d9cc193894dc13cc8f9c7a8a21411ac61b5567a878514df6f9f0d7bb7 -F ext/fts5/test/fts5af.test 2329b6c6e6e9243371022dd9439892ff1850b590ae9ce073e3a83eefaf993a81 -F ext/fts5/test/fts5ag.test 7816f25a0707578f08145ab539fc0ca025f8951e788b28a6a18a06b2099469dd -F ext/fts5/test/fts5ah.test 2f047dfe89dc8611fa53e3d8bfc453b79cff037aa423c8d171e91e645745aa2c -F ext/fts5/test/fts5ai.test bc97e4758cc93e06bf851d61c98fdf4e8b8f8315ee28a84fb15f916360856414 -F ext/fts5/test/fts5aj.test 745020852d85f5dd49d11cb7ad11d3cc6dafc4fe6d6d24bc0875ac8f43ee4149 -F ext/fts5/test/fts5ak.test f459a64c9d38698af72a7c657ab6349bca96150241dd69fcce752634b2742d41 -F ext/fts5/test/fts5al.test 00c4c1c6a1366b73aa48ce2068c634520867c3cf7f5d1676ebbb775ee1f35734 -F ext/fts5/test/fts5alter.test 5565f7e4605512b69171ac18ca84398603f9f6456dbe377beeca97e83cc242cd -F ext/fts5/test/fts5auto.test 78989e6527ce69c9eddbef7392fea5c10b0010cd2b2ae68eec7bc869c471e691 -F ext/fts5/test/fts5aux.test f3b4aa403cb672b0d79af1a87519e5896b309ab026de6425fa179589da55d7a5 -F ext/fts5/test/fts5aux2.test baa1b32f152384378d40d8ed40922e91e37eccbca72471c85e1d8b3f541c3e84 -F ext/fts5/test/fts5auxdata.test eacc97ff04892f1a5f3d4df5a73f8bcbc3955ea1d12c9f24137eb1fc079e7611 +F ext/fts5/test/fts5ab.test 4bdb619fee409e11417e8827e320b857e42e926a01a0408fc9f143ec870a6ced +F ext/fts5/test/fts5ac.test 4a73626de86f3d17c95738034880c4f0de8d54741fb943d819b528373657e59b +F ext/fts5/test/fts5ad.test 058e616612964e61d19f70295f0e6eaedceb4b29b1fbf4f859615ef7e779dc22 +F ext/fts5/test/fts5ae.test 3d49edbd50bb0684199a2e7568aeb30d1d29718f5c0f61751983740fa836d15f +F ext/fts5/test/fts5af.test ae81f08b8da4c5f9b3ec1ef538a4ab6b7c278e92fa9058d6dc5d842c5d9771b9 +F ext/fts5/test/fts5ag.test 6667807b5d3fbf460892e756763fbe3d87a2fffe345a06514ba010ca6f6641f7 +F ext/fts5/test/fts5ah.test ac327281c8910cf9b85738a2655003fd0c6a8a76189ef34f3d086b8f9e54263b +F ext/fts5/test/fts5ai.test cbe26d78030998f535bc103f37915350b137a822c71a9db439a077d7666a3539 +F ext/fts5/test/fts5aj.test 53c8508dab4acca3e691a4c51eca4b3b018319ab8635e540103d5bbdc91543c9 +F ext/fts5/test/fts5ak.test 25e2f8afdcff30d98ca9dee8c5cacca2f26db17501c9401f16d99ee036f70e8d +F ext/fts5/test/fts5al.test 842c50fd9b287e3fa988dfcab436b27c432866f7406a56aaf3c67f316952cc02 +F ext/fts5/test/fts5alter.test ebbee06419c2d3cee5ef7ebb5ba6a9996f1aa374035361c0acd37368cc5f64f3 +F ext/fts5/test/fts5auto.test 2278de323172ced485d2844cb1357d00036ac1665f27e70fa1a48ce57bf31c2c +F ext/fts5/test/fts5aux.test 27210687338133b1e9bc0dd669322fca59fd432439f40b126895e2d7c2f899d6 +F ext/fts5/test/fts5aux2.test 4f59ac5e7c06c430a9f4890877e10f7b4708e46897422ee6743d27b0a8d01497 +F ext/fts5/test/fts5auxdata.test 372549088ff792655f73e62b9dfaf4863ce74f5e604c06cffec0b37ce4624161 F ext/fts5/test/fts5bigid.test 2860854c2561a57594192b00c33a29f91cb85e25f3d6c03b5c2b8f62708f39dd -F ext/fts5/test/fts5bigpl.test 6466c89b38439f0aba26ac09e232a6b963f29b1cbe1304f6a664fe1e7a8f5fd3 +F ext/fts5/test/fts5bigpl.test 8f09858aab866c33593560e6480b2b6975ae7ff29ca32ad7b77e2da61402f8ef F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36 F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62 F ext/fts5/test/fts5colset.test 544f4998cdbfe06a3123887fc0221612e8aa8192cdaff152872f1aadb10e6897 -F ext/fts5/test/fts5columnsize.test 45459ce4dd9fd853b6044cdc9674921bff89e3d840f348ca8c1630f9edbf5482 -F ext/fts5/test/fts5config.test 60094712debc59286c59aef0e6cf511c37d866802776a825ce437d26afe0817f +F ext/fts5/test/fts5columnsize.test 0af91d63985afdf663455d4b572b935238380140d74079eac362760866d3297b +F ext/fts5/test/fts5config.test 017daf10d2642496e97402baa0134de8b5b46b9c37e53c229cd9ab711d21522c F ext/fts5/test/fts5conflict.test bf6030a77dbb1bedfcc42e589ed7980846c995765d77460551e448b56d741244 F ext/fts5/test/fts5connect.test 08030168fc96fc278fa81f28654fb7e90566f33aff269c073e19b3ae9126b2f4 -F ext/fts5/test/fts5content.test 282b373c58c8e798568ec2ced18b23f29bffa8d61317a0e51a035000ad6cd731 -F ext/fts5/test/fts5contentless.test 1cd1237894eeff11feb1ff8180044eac0b17dde22c181f7a722f2dcbfdb3377c -F ext/fts5/test/fts5contentless2.test 14c83bdacf8230f5f7ca74ecf2926b87d8a7cb788a69ce9937020428ac4fe192 -F ext/fts5/test/fts5contentless3.test 353d871c5ea08992aed3e2ebda0b1bdc35116cd24fe330fe7cf05be1e2b49fd7 -F ext/fts5/test/fts5contentless4.test dd33ead36b048c9447b81ec358bd4a27166c49ffaac65a54e95eabf59f338947 -F ext/fts5/test/fts5contentless5.test 96041cbf5ef781a68a5d0f0d18a88030c47a52b156b17876ed6ce36e80e27a7e -F ext/fts5/test/fts5corrupt.test b6d4034b682bb3387bc44c510c71b3c67d4349e4df139490fc0b69e6a972b99f -F ext/fts5/test/fts5corrupt2.test 99e7e23a58b4d89eb7167c6de1669cbc595cd3c79ab333e0eb56405473319e77 -F ext/fts5/test/fts5corrupt3.test 7da9895dafa404efd20728f66ff4b94399788bdc042c36fe2689801bba2ccd78 -F ext/fts5/test/fts5corrupt4.test f4c08e2182a48d8b70975fd869ee5391855c06d8a0ff87b6a2529e7c5a88a1d3 -F ext/fts5/test/fts5corrupt5.test 0a33d1028837aaf37e55a0538060a8a0cc2e47fee112d1e09b52d50bde03c37d -F ext/fts5/test/fts5corrupt6.test bf8eeae07825b088b9665d9d8e4accbd8dc9bf3cb85b6c64cf6c9e18ccc420a4 -F ext/fts5/test/fts5corrupt7.test 80ad7f683a8bda2404731bb77e8c3dbbb620c1f6cc583cca8239f6accd6338c0 +F ext/fts5/test/fts5content.test 84aa36c6c8b6cebc2b7be3a1e502e2b85c27c58b98614d7cc0fe9d3acf402601 +F ext/fts5/test/fts5contentless.test b107465f8cd27dde6313b9c60b61d7158a7753b9c663c5c553695f826bb3c0a5 +F ext/fts5/test/fts5contentless2.test 70ffe6c611d8f278240da56734df8a77948f04e2739b358439e9bdcf56ced35f +F ext/fts5/test/fts5contentless3.test 75eaae5ad6b284ee447788943974d323228f27cc35a1681da997135cff95bc6a +F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b05ea89964c863833b6eff8 +F ext/fts5/test/fts5contentless5.test ceb53fcd635f726458fdee2e4482a37966e6b328fe94521ed02d04048f02dac5 +F ext/fts5/test/fts5corrupt.test 6d2143d2a30b2bd2795223f0c941457ae194b8f09fa490e0205ec670a68dea64 +F ext/fts5/test/fts5corrupt2.test a524eaa861aebecb33db919f065c8d2212f4871217446db3e5e79c1c4b49c798 +F ext/fts5/test/fts5corrupt3.test 12df0beb4b3e270d40dff3237b73e2dd2e9577404e1eca3f0847015ebe4f03ae +F ext/fts5/test/fts5corrupt4.test dc08d19f5b8943e95a7778a7d8da592042504faf18dd93f68f7d7a0d7d7dd733 +F ext/fts5/test/fts5corrupt5.test 11b47126f5772cc37b67e3e8b2ed05895c4d07c05338bc07e4eea225bfe32c76 +F ext/fts5/test/fts5corrupt6.test 2d72db743db7b5d9c9a6d0cfef24d799ed1aa5e8192b66c40e871a37ed9eed06 +F ext/fts5/test/fts5corrupt7.test 4e830875c33b9ea3c4cf1ba71e692b63893cbb4faae8c69b1071889dc26e211c F ext/fts5/test/fts5delete.test 619295b20dbc1d840b403ee07c878f52378849c3c02e44f2ee143b3e978a0aa7 F ext/fts5/test/fts5detail.test 54015e9c43ec4ba542cfb93268abdf280e0300f350efd08ee411284b03595cc4 F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3bf76a2c82b1c788d11 -F ext/fts5/test/fts5dlidx.test b90852c55881b29dbac6380b274de27beae623ac4b6d567c6c8fb9cdc315a86e -F ext/fts5/test/fts5doclist.test faa9e9cc3c0645fa6203667cb5f007c359447c6ee66753f71a58175c2497cacd -F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0 -F ext/fts5/test/fts5eb.test 5f0a86e9fe4715912e6bfa556368aae96d13c61a481373f24daa40429d5d5ca1 +F ext/fts5/test/fts5dlidx.test a7c42b0a74dc7c8aa1a46d586e0aadda4b6cc42c24450f8d3774b21166e93159 +F ext/fts5/test/fts5doclist.test b7cb84758504519746957802db9cd31187bb4e0028b89d9087ba06e26cc4155f +F ext/fts5/test/fts5ea.test cefdf66024550fa7920c03395c71ce5046235ed1a1a7a469d79b19e7aad5afb5 +F ext/fts5/test/fts5eb.test a7bd20ef7f5d37defb7eda93c8a7e65cba4a5aae95177df37020adca99600f76 F ext/fts5/test/fts5fault1.test d28a65caee75db6897c3cf1358c5230d3bb2a3bf7fb31062c19c7e5382b3d2bd F ext/fts5/test/fts5fault2.test 69c8fdbef830cd0d450908d4504d5bb86609e255af99c421c20a0756251fe344 F ext/fts5/test/fts5fault3.test da2f9e3e56ff5740d68ebdd6877c97089e7ed28ddff28a0da87a6afea27e5522 F ext/fts5/test/fts5fault4.test 87a10d0caee57da587c7588b0c8d25d2930197399b4812ad1e4d574c75324cee F ext/fts5/test/fts5fault5.test a336e4e11847de24c9497f80cce18e00bb3fab7fb11f97d04eb9af898900a762 -F ext/fts5/test/fts5fault6.test a0fc0a8f99e4b16500c31dfc7e38e1defe0f1693ac47650517ac7b723b1956f8 +F ext/fts5/test/fts5fault6.test 40f49976c6ca8927bf7d65d0b8df46009d7ea172e1d4050b294610e7ea0a2979 F ext/fts5/test/fts5fault7.test 0acbec416edb24b8881f154e99c31e9ccf73f539cfcd164090be139e9e97ed4c F ext/fts5/test/fts5fault8.test 9353fe6a2a993c3231e09c49b0f4a12c8d306319555ff2ca6672b5b86fe9b0dd F ext/fts5/test/fts5fault9.test 098e6b894bbdf9b2192f994a30f4043673fb3f338b6b8ab1624c704422f39119 @@ -173,45 +173,45 @@ F ext/fts5/test/fts5faultB.test d606bdb8e81aaeb6f41de3fc9fc7ae315733f0903fbff05c F ext/fts5/test/fts5faultD.test e7ed7895abfe6bc98a5e853826f6b74956e7ba7f594f1860bbf9e504b9647996 F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e4710c77eb8ce7075 F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 -F ext/fts5/test/fts5faultG.test d2e5a4d9a34e08dcaadcaeafef74d10cbc2abdd11aa2659a18af0294bf2812d3 -F ext/fts5/test/fts5faultH.test b5c3b62642b7d321504a0a4f424eb80b4f6927969173334c8ca20df388557622 +F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 +F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d F ext/fts5/test/fts5first.test 3fcf2365c00a15fc9704233674789a3b95131d12de18a9b996159f6909dc8079 -F ext/fts5/test/fts5full.test e1701a112354e0ff9a1fdffb0c940c576530c33732ee20ac5e8361777070d717 +F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e -F ext/fts5/test/fts5hash.test dc7bc7e0cdeb42cfce31294ad2f8fcf43192bfd0145bb7f3ecc5465d8c72696f -F ext/fts5/test/fts5integrity.test e1af628af123669d018e84a649283ca41944429dfeb279ceaed9f3f480597153 +F ext/fts5/test/fts5hash.test fd3e0367fbf0b0944d6936fdb22696350f57b9871069c6766251578a103e8a14 +F ext/fts5/test/fts5integrity.test 4c26d4663d002f90388d364a52827ae8729c232fbb6469bff1853b0e64a5c9aa F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fdde7ea00e78ea283d227 -F ext/fts5/test/fts5lastrowid.test be98fe3e03235296585b72daad7aed5717ba0062bae5e5c18dd6e04e194c6b28 +F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 -F ext/fts5/test/fts5merge.test e92a8db28b45931e7a9c7b1bbd36101692759d00274df74d83fd29d25d53b3a6 +F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 F ext/fts5/test/fts5misc.test b88aa28ff20238b394495b0795cddca1a62b98fa09b99e462a8abc572d04ee88 F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 -F ext/fts5/test/fts5near.test 211477940142d733ac04fad97cb24095513ab2507073a99c2765c3ddd2ef58bd +F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 F ext/fts5/test/fts5onepass.test f9b7d9b2c334900c6542a869760290e2ab5382af8fbd618834bf1fcc3e7b84da -F ext/fts5/test/fts5optimize.test 36a752d24c818792032e4ff502936fc9cc5ef938721696396fdc79214b2717f1 -F ext/fts5/test/fts5optimize2.test 93e742c36b487d8874621360af5b1ce4d39b04fb9e71ce9bc34015c5fc811785 -F ext/fts5/test/fts5optimize3.test bf9c91bb927d0fb2b9a06318a217a0419183ac5913842e062c7e0b98ea5d0fca -F ext/fts5/test/fts5origintext.test d2796fa08ee7aecfabdc0c45bb8a2fb16a00ea8757e63fbc153b718dbe430a39 -F ext/fts5/test/fts5origintext2.test f3b9436de540828d01f0672df855b09ebc0863e126d5b56234701d71dfa73634 -F ext/fts5/test/fts5origintext3.test 0d25933506600452a5ab3873cbb418ed5f2de2446c3672b9997b1ea104b0e7f0 -F ext/fts5/test/fts5origintext4.test 0c4e4514b68d9ddb15e5a538d9d234da85747a3fd62432265dbdba5c8708e457 -F ext/fts5/test/fts5origintext5.test a037bdf7235a22033c4663837bdb12d9738245464a3ac2f60c71fc40d07ede7d -F ext/fts5/test/fts5phrase.test 13e5d8e9083077b3d9c74315b3c92ec723cc6eb37c8155e0bfe1bba00559f07b -F ext/fts5/test/fts5plan.test b65cfcca9ddd6fdaa118c61e17aeec8e8433bc5b6bb307abd116514f79c49c5a -F ext/fts5/test/fts5porter.test 8d08010c28527db66bc3feebd2b8767504aaeb9b101a986342fa7833d49d0d15 -F ext/fts5/test/fts5porter2.test 0d251a673f02fa13ca7f011654873b3add20745f7402f108600a23e52d8c7457 -F ext/fts5/test/fts5prefix.test a0fa67b06650f2deaa7bf27745899d94e0fb547ad9ecbd08bfad98c04912c056 -F ext/fts5/test/fts5prefix2.test ad751d4a5b029726ee908a7664e27d27bde7584218b8d7944c2a323afd381432 -F ext/fts5/test/fts5query.test ac363b17a442620bb0780e93c24f16a5f963dfe2f23dc85647b869efcfada728 -F ext/fts5/test/fts5rank.test 30f29e278cd7fb8831ba4f082feb74d8eb90c463bf07113ae200afc2b467ef32 -F ext/fts5/test/fts5rebuild.test 55d6f17715cddbf825680dd6551efbc72ed916d8cf1cde40a46fc5d785b451e7 -F ext/fts5/test/fts5restart.test 835ecc8f449e3919f72509ab58056d0cedca40d1fe04108ccf8ac4c2ba41f415 -F ext/fts5/test/fts5rowid.test b8790ec170a8dc1942a15aef3db926a5f3061b1ff171013003d8297203a20ad6 -F ext/fts5/test/fts5savepoint.test 050796b24929325cdbbb2fbfe2794816ae95d298e940ae15032200c2f4a73725 +F ext/fts5/test/fts5optimize.test 264b9101721c17d06d1d174feb743fda3ddc89fad41dee980fef821428258e47 +F ext/fts5/test/fts5optimize2.test 795d4ae5f66a7239cf8d5aef4c2ea96aeb8bcd907bd9be0cfe22064fc71a44ed +F ext/fts5/test/fts5optimize3.test 1653029284e10e0715246819893ba30565c4ead0d0fc470adae92c353ea857d3 +F ext/fts5/test/fts5origintext.test 87c34c78f201b1e22ac93ac6bbe6196dde59f0a7266b1aeb938604a0eb9d5552 +F ext/fts5/test/fts5origintext2.test f4505ff79bf7369f2b8b10b9cef7476049d844e20b37f29cad3a8b8d5ac6f9ba +F ext/fts5/test/fts5origintext3.test 45c33cf0c91a9ca0e36d298462db3edc7c8fe45fd185649a9dbfd66bb670058b +F ext/fts5/test/fts5origintext4.test 0d3ef0a8038f471dbc83001c34fe5f7ae39b571bfc209670771eb28bc0fc50e8 +F ext/fts5/test/fts5origintext5.test ee12b440ec335e5b422d1668aca0051b52ff28b6ee67073e8bbc29f509fd562b +F ext/fts5/test/fts5phrase.test 6260b8be40d51ec287992cd983a5e58a9be92e5dc6e01d48cbce1ad0e95a99d8 +F ext/fts5/test/fts5plan.test f8b0d752a818059a934cdc96c0f77de058a67a0a57bb3a8181d28307ab5b1626 +F ext/fts5/test/fts5porter.test 15b514fac8690b58e99c330efe5bf5615bc43f2fae4a3cca3f923dbaff55a0c0 +F ext/fts5/test/fts5porter2.test 94f0e4351e2c99b4e74f1fae05a4ddf1cb5b926620a8c14554160d075ddc7a59 +F ext/fts5/test/fts5prefix.test c0b7842f1a2d830c0b146cd438a95ea4c5a25635719ed0d973ffe41907338b83 +F ext/fts5/test/fts5prefix2.test a5bb43b8a2687efafa7ac4e5ccff6812015cf8cf18e3086bb0eb3126f30fbbf6 +F ext/fts5/test/fts5query.test 0320a7a4b58a6e3e50ec8910b301649da90ace675001f9e0bf6392750ad4591d +F ext/fts5/test/fts5rank.test 47c1e8e5d84754ff18e012fdd629776088b5a15de41bdd24957581cf084d8a00 +F ext/fts5/test/fts5rebuild.test 83e72d77636378833233fadc7cb7517a2fa446ea7d1f94dd526ba3e7e104b9f5 +F ext/fts5/test/fts5restart.test ee7b40ac3f4ea027ea7d5f5422eddbcdaa14944ec4cc5791cfc1b796c71ae2a5 +F ext/fts5/test/fts5rowid.test 8632829fec04996832a4cfb4f0bd89721ba65b7e398c1731741bdb63f070e1a3 +F ext/fts5/test/fts5savepoint.test 7f373184cf2d6c1c472d2bc732e1fce62211ffe023f13e381db0f5e4fd06e41d F ext/fts5/test/fts5secure.test a02f771742fb2b1b9bdcb4bf523bcf2d0aa1ff597831d40fe3e72aaa6d0ec40f F ext/fts5/test/fts5secure2.test 2e961d7eef939f294c56b5d895cac7f1c3a60b934ee2cfd5e5e620bdf1ba6bbc F ext/fts5/test/fts5secure3.test 6d066828d225b0dbe5db818d4d6165df7bb70210e68a577e858e8762400d5a23 @@ -220,29 +220,29 @@ F ext/fts5/test/fts5secure5.test c07a68ced5951567ac116c22f2d2aafae497e47fe9fcb6a F ext/fts5/test/fts5secure6.test 74bf04733cc523bccca519bb03d3b4e2ed6f6e3db7c59bf6be82c88a0ac857fd F ext/fts5/test/fts5secure7.test fd03d0868d64340a1db8615b02e5508fea409de13910114e4f19eaefc120777a F ext/fts5/test/fts5secure8.test e68c0ac4447f415ff3e4e82531e99548289286f9f3a29c8cd53036113fe28602 -F ext/fts5/test/fts5securefault.test dbca2b6a1c16700017f5051138991b705410889933f2a37c57ae8a23b296b10b -F ext/fts5/test/fts5simple.test a298670508c1458b88ce6030440f26a30673931884eb5f4094ac1773b3ba217b -F ext/fts5/test/fts5simple2.test 8dd2389ee75e21a1429fe87e5f8c7d9a97ad1470304a8a2d3ba4b8c3c345fecd -F ext/fts5/test/fts5simple3.test d5c74a9d3ca71bd5dd5cacb7c55b86ea12cdddfc8b1910e3de2995206898380f -F ext/fts5/test/fts5synonym.test 1651815b8008de170e8e600dcacc17521d765482ea8f074ae82cfa870d8bb7fb -F ext/fts5/test/fts5synonym2.test e2f6ff68c4fbe12a866a3a87510f553d9dac99bcb74c10b56487c4c0a562fcf5 +F ext/fts5/test/fts5securefault.test c34a28c7cd2f31a8b8907563889e1329a97da975c08df2d951422bcef8e2ebc5 +F ext/fts5/test/fts5simple.test 847fb828262328744733847dc76d6b5d4a6bd4c5d9b282cb819f6504340e061a +F ext/fts5/test/fts5simple2.test d10d963a357b8ec77b99032e4c816459b4dbdb1f6eee25eada7ef3ed245cb2dc +F ext/fts5/test/fts5simple3.test 146ec3dc8f5763d6212641c9f0a2f1cba41679353d2add7b963beceb115dc7f4 +F ext/fts5/test/fts5synonym.test becc8cea6cfc958a50b30c572c68cbfdf7455971d0fe988202ce67638d2c6cf6 +F ext/fts5/test/fts5synonym2.test 58f357b997cf2fedeeb9d0de4db9f880fa96fa2fe27a743bfe7d7b96895bdd87 F ext/fts5/test/fts5tok1.test 1f7817499f5971450d8c4a652114b3d833393c8134e32422d0af27884ffe9cef F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 -F ext/fts5/test/fts5tokenizer.test abeb8b2d00415e5c8eae48d2dcb91357b7f7e1fddbb2b650f00b589a7bea9659 -F ext/fts5/test/fts5tokenizer2.test cb5428c7cfb3b6a74b7adfcde65506e329112003e8dffa7501d01c2d18d02569 +F ext/fts5/test/fts5tokenizer.test 7937cec672b148223fff8746d21d3e7ed0965fd7caf35ccdc888a005bb452f98 +F ext/fts5/test/fts5tokenizer2.test 9c1ad8ef0465076cbc9ff5c764782594329b3bce3e0f6a931a026902d006f495 F ext/fts5/test/fts5trigram.test 6c4e37864f3e7d90673db5563d9736d7e40080ab94d10ebdffa94c1b77941da0 F ext/fts5/test/fts5trigram2.test c91f0a94f7e1ff859682228646abeab4c0eba2effc46af2cbc8f0f48b05a0566 -F ext/fts5/test/fts5ubsan.test 783d5a8d13ebfa169e634940228db54540780e3ba7a87ad1e4510e61440bf64b +F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 -F ext/fts5/test/fts5unicode.test 17056f4efe6b0a5d4f41fdf7a7dc9af2873004562eaa899d40633b93dc95f5a9 -F ext/fts5/test/fts5unicode2.test 9b3df486de05fb4bde4aa7ee8de2e6dae1df6eb90e3f2e242c9383b95d314e3e -F ext/fts5/test/fts5unicode3.test 590c72e18195bda2446133f9d82d04a4e89d094bba58c75ae10f4afc6faa0744 -F ext/fts5/test/fts5unicode4.test 6463301d669f963c83988017aa354108be0b947d325aef58d3abddf27147b687 -F ext/fts5/test/fts5unindexed.test 9021af86a0fb9fc616f7a69a996db0116e7936d0db63892db6bafabbec21af4d +F ext/fts5/test/fts5unicode.test 625f4ccd2fc4f480ca7af29349c1dea9d510aaca66bb8ec3aa90593b1e9e885b +F ext/fts5/test/fts5unicode2.test c7f5b338dc40c7f0480a94baf1a6ad0dc55ad7aefe51ba4655ffa9d4cf3dde19 +F ext/fts5/test/fts5unicode3.test f4891a3dac3b49c3d7c0fdb29566e9eb0ecff35263370c89f9661b1952b20818 +F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8df04eff87923c74b4d0 +F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc -F ext/fts5/test/fts5version.test d6e5a5897550afeccc2f8531d87404dc1c289ee89385dd4318dbdd75e71d7a67 -F ext/fts5/test/fts5vocab.test 7ed80d9af1ddaaa1637da05e406327b5aac250848bc604c1c1cc667908b87760 -F ext/fts5/test/fts5vocab2.test 1b1f0059f762ffb404213d35dac013e010621f08128589b6ec7bec59d9a710f3 +F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e +F ext/fts5/test/fts5vocab.test 03a2e0b7fd6134a33fef7701076d8a3d4971afd324621abdac1c9c4f0019d63f +F ext/fts5/test/fts5vocab2.test bbba149c254375d00055930c1a501c9a51e80b0d20bf7b98f3e9fa3b03786373 F ext/fts5/tool/fts5speed.tcl b0056f91a55b2d1a3684ec05729de92b042e2f85 F ext/fts5/tool/fts5txt2db.tcl c0d43c8590656f8240e622b00957b3a0facc49482411a9fdc2870b45c0c82f9f F ext/fts5/tool/loadfts5.tcl 95b03429ee6b138645703c6ca192c3ac96eaf093 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1535828335d2b0eccebae952ed2bc70cc0cd893bd4b079d26b80deff9b5f752b -R 533ea7a7dd358b4ef85ffe0b89a8a342 +P 56d265f956fe6433b625c6d732e55f387af3f643e705316f5a6f709d63731669 +R 5ad9950c3d8fa87fe57068f06313a6c9 U dan -Z 115082379d887d07e03d9d2d6d25a1bf +Z 3992b6a75558611778f9237da672a1e0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1b128a6fe5..73edec88bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -56d265f956fe6433b625c6d732e55f387af3f643e705316f5a6f709d63731669 +d07085e2035b52a7edd27980523225e59c5bf851fb4a6de975f03e653b937c9c From 076bd5758b7a7e06cd2de9677ea9ba077d9dba2f Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 28 Jun 2024 17:14:00 +0000 Subject: [PATCH 0506/1030] Do not convert an expression node that is already TK_REGISTER into a new TK_REGISTER. This is a follow-up to [663f5dd32d9db832] that fixes a bug discovered by dbsqlfuzz. FossilOrigin-Name: fcb669cfaa8a59ca710504d5aaa1936f65a6da8ff13473ad84458f97a6fd1f49 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 5 ++++- test/distinct2.test | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 83472c33cf..5cef5b150e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sincorrect\stcl\scomment\sthat\sappeared\sin\smany\sfts5\stest\sfiles. -D 2024-06-24T18:06:15.031 +C Do\snot\sconvert\san\sexpression\snode\sthat\sis\salready\sTK_REGISTER\sinto\sa\nnew\sTK_REGISTER.\s\sThis\sis\sa\sfollow-up\sto\s[663f5dd32d9db832]\sthat\sfixes\sa\nbug\sdiscovered\sby\sdbsqlfuzz. +D 2024-06-28T17:14:00.360 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -755,7 +755,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c d26ac0a13b4154cbd71a9a57ca024350cd73f0f6fcf0ca0cbb4537e2d5b3e257 +F src/select.c a1c8fadd45d0843b14793db2af49809a5327db5cca9d87d507b57aa748ee6ee2 F src/shell.c.in 2ccbed6a9fd451399b0f378aafa323ad2286fa9de54ae0cd28f32907cd94d18d F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1074,7 +1074,7 @@ F test/descidx2.test a0ba347037ff3b811f4c6ceca5fd0f9d5d72e74e59f2d9de346a9d2f6ad F test/descidx3.test 953c831df7ea219c73826dfbf2f6ee02d95040725aa88ccb4fa43d1a1999b926 F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e F test/distinct.test 691c9e850b0d0b56b66e7e235453198cb4cf0760e324b7403d3c5abbeab0a014 -F test/distinct2.test 931a242fccaa05f17232e23acc9b2debe42901d90db723ddca038f7758951b5f +F test/distinct2.test 4d6316b6487a0aa5a90bee111575c957e2a5ba5a9be9156febe9533ce78876e8 F test/distinctagg.test 40d7169ae5846caaf62c6e307d2ca3c333daf9b6f7cde888956a339a97afe85f F test/e_blobbytes.test 4c01dfe4f12087b92b20705a3fdfded45dc4ed16d5a211fed4e1d2786ba68a52 F test/e_blobclose.test 692fc02a058476c2222a63d97e3f3b2b809c1842e5525ded7f854d540ac2e075 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 56d265f956fe6433b625c6d732e55f387af3f643e705316f5a6f709d63731669 -R 5ad9950c3d8fa87fe57068f06313a6c9 -U dan -Z 3992b6a75558611778f9237da672a1e0 +P d07085e2035b52a7edd27980523225e59c5bf851fb4a6de975f03e653b937c9c +R 6b4e371b1a6983b6d20bf6bb77f15e3d +U drh +Z 1da9b70811e2736c2416513d2f56f791 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 73edec88bb..c1825bf1d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d07085e2035b52a7edd27980523225e59c5bf851fb4a6de975f03e653b937c9c +fcb669cfaa8a59ca710504d5aaa1936f65a6da8ff13473ad84458f97a6fd1f49 diff --git a/src/select.c b/src/select.c index 3bc5858f62..b43861cef2 100644 --- a/src/select.c +++ b/src/select.c @@ -8336,7 +8336,10 @@ int sqlite3Select( if( iOrderByCol ){ Expr *pX = p->pEList->a[iOrderByCol-1].pExpr; Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX); - if( ALWAYS(pBase!=0) && pBase->op!=TK_AGG_COLUMN ){ + if( ALWAYS(pBase!=0) + && pBase->op!=TK_AGG_COLUMN + && pBase->op!=TK_REGISTER + ){ sqlite3ExprToRegister(pX, iAMem+j); } } diff --git a/test/distinct2.test b/test/distinct2.test index 023e2e3335..980b0b1e3a 100644 --- a/test/distinct2.test +++ b/test/distinct2.test @@ -362,4 +362,22 @@ do_execsql_test 5070 { SELECT v4.e FROM t3 LEFT JOIN v4 ON true GROUP BY 1; } NULL +# 2024-06-28 dbsqlfuzz 46343912848a603e32c6072cae792eb056bac897 +# Do not call sqlite3ExprToRegister() on an expression that is already +# a register. +# +do_execsql_test 5080 { + CREATE TABLE dual(dummy TEXT); + INSERT INTO dual VALUES('X'); + SELECT 11 = ( + SELECT b + FROM ( + SELECT a AS b + FROM dual + LEFT JOIN (SELECT 22 AS a FROM dual) + ) + GROUP BY b, b + ); +} 0 + finish_test From f13e2d22fe27b04d83b6f3f9232782e347bfb8e1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 28 Jun 2024 18:07:10 +0000 Subject: [PATCH 0507/1030] Additional steps to make sure calls to sqlite3ExprToRegister() are sane. FossilOrigin-Name: 1c42d7176b228791f99bc9971d92a9ab67b1e2956ca4f8d934bd1a3e596d6c80 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 12 ++++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 5cef5b150e..a4a944b879 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sconvert\san\sexpression\snode\sthat\sis\salready\sTK_REGISTER\sinto\sa\nnew\sTK_REGISTER.\s\sThis\sis\sa\sfollow-up\sto\s[663f5dd32d9db832]\sthat\sfixes\sa\nbug\sdiscovered\sby\sdbsqlfuzz. -D 2024-06-28T17:14:00.360 +C Additional\ssteps\sto\smake\ssure\scalls\sto\ssqlite3ExprToRegister()\sare\ssane. +D 2024-06-28T18:07:10.142 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c af9c9242be0df17280faf36c9810339de9df3d7a64ac8d33a5190a1400086ee5 +F src/expr.c 02652ae4e3d7147d252ae4dd16642251b09289e10ec7cb5e977c7185457e17f0 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d07085e2035b52a7edd27980523225e59c5bf851fb4a6de975f03e653b937c9c -R 6b4e371b1a6983b6d20bf6bb77f15e3d +P fcb669cfaa8a59ca710504d5aaa1936f65a6da8ff13473ad84458f97a6fd1f49 +R f2da2caf7ab4dc74d519b7306af82cc5 U drh -Z 1da9b70811e2736c2416513d2f56f791 +Z 0d34565772917324f2bd7f30087daf88 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c1825bf1d1..1ebdaf03c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fcb669cfaa8a59ca710504d5aaa1936f65a6da8ff13473ad84458f97a6fd1f49 +1c42d7176b228791f99bc9971d92a9ab67b1e2956ca4f8d934bd1a3e596d6c80 diff --git a/src/expr.c b/src/expr.c index bda91df83d..b7dbc721e2 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4270,10 +4270,14 @@ void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){ void sqlite3ExprToRegister(Expr *pExpr, int iReg){ Expr *p = sqlite3ExprSkipCollateAndLikely(pExpr); if( NEVER(p==0) ) return; - p->op2 = p->op; - p->op = TK_REGISTER; - p->iTable = iReg; - ExprClearProperty(p, EP_Skip); + if( p->op==TK_REGISTER ){ + assert( p->iTable==iReg ); + }else{ + p->op2 = p->op; + p->op = TK_REGISTER; + p->iTable = iReg; + ExprClearProperty(p, EP_Skip); + } } /* From 75bdf00e8980610223acf865245b7052292a1102 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 28 Jun 2024 18:21:30 +0000 Subject: [PATCH 0508/1030] Update fts5 comment/docs to include the order matches are visited in by the xPhraseFirst/xPhraseNext API. FossilOrigin-Name: e41930ef5b883c0f2a6b7eb9606021d14a3df145bc94cb0d508af22b4db7f168 --- ext/fts5/fts5.h | 4 ++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 551618e718..d3042fcb8c 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -238,6 +238,10 @@ struct Fts5PhraseIter { ** (i.e. if it is a contentless table), then this API always iterates ** through an empty set (all calls to xPhraseFirst() set iCol to -1). ** +** In all cases, matches are visited in (column ASC, offset ASC) order. +** i.e. all those in column 0, sorted by offset, followed by those in +** column 1, etc. +** ** xPhraseNext() ** See xPhraseFirst above. ** diff --git a/manifest b/manifest index a4a944b879..d49630461f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\ssteps\sto\smake\ssure\scalls\sto\ssqlite3ExprToRegister()\sare\ssane. -D 2024-06-28T18:07:10.142 +C Update\sfts5\scomment/docs\sto\sinclude\sthe\sorder\smatches\sare\svisited\sin\sby\sthe\sxPhraseFirst/xPhraseNext\sAPI. +D 2024-06-28T18:21:30.421 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,7 +92,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h 8856e11a5f0269cd346754cea0765efe8089635b80cad3222e8bfdb08cd5348a +F ext/fts5/fts5.h 6b49ce6eb2e395e7fd84557b21d32f5de8041f2fada4c617e481e99427e24b6e F ext/fts5/fts5Int.h 407ee36addad0ae6df5d37a811f0bd509ab6708b29640884ed5c7509e5f75143 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fcb669cfaa8a59ca710504d5aaa1936f65a6da8ff13473ad84458f97a6fd1f49 -R f2da2caf7ab4dc74d519b7306af82cc5 -U drh -Z 0d34565772917324f2bd7f30087daf88 +P 1c42d7176b228791f99bc9971d92a9ab67b1e2956ca4f8d934bd1a3e596d6c80 +R 8aac64293a0fbce2c9e9758f351712c1 +U dan +Z 933e4e495e086faeb6352900a4c7ab76 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1ebdaf03c4..496983f4f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c42d7176b228791f99bc9971d92a9ab67b1e2956ca4f8d934bd1a3e596d6c80 +e41930ef5b883c0f2a6b7eb9606021d14a3df145bc94cb0d508af22b4db7f168 From 6adbdac6764c179b9921e4b3534a05cafa7230ef Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 29 Jun 2024 12:22:32 +0000 Subject: [PATCH 0509/1030] Add a NEVER() around a branch in sqlite3ExprAffinity() that is designed to prevent an infinite loop, but which can now never be reached due to recent changes. FossilOrigin-Name: da0b794852f8ccba5bd30395892044ec71b148075608406867785395e1f50b31 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d49630461f..6f2719b768 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sfts5\scomment/docs\sto\sinclude\sthe\sorder\smatches\sare\svisited\sin\sby\sthe\sxPhraseFirst/xPhraseNext\sAPI. -D 2024-06-28T18:21:30.421 +C Add\sa\sNEVER()\saround\sa\sbranch\sin\ssqlite3ExprAffinity()\sthat\sis\sdesigned\sto\nprevent\san\sinfinite\sloop,\sbut\swhich\scan\snow\snever\sbe\sreached\sdue\sto\srecent\nchanges. +D 2024-06-29T12:22:32.074 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 02652ae4e3d7147d252ae4dd16642251b09289e10ec7cb5e977c7185457e17f0 +F src/expr.c 2b72d352a2917fe8d2cd8f84e0acd0140c6ba769b0cd7bcfd86eb9ba0c9c50e8 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c42d7176b228791f99bc9971d92a9ab67b1e2956ca4f8d934bd1a3e596d6c80 -R 8aac64293a0fbce2c9e9758f351712c1 -U dan -Z 933e4e495e086faeb6352900a4c7ab76 +P e41930ef5b883c0f2a6b7eb9606021d14a3df145bc94cb0d508af22b4db7f168 +R a8bad0dfb59bfd3d7574dd38a5f03ea3 +U drh +Z af9d587fdd1c2ab0ac6a540d9280d767 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 496983f4f1..2818078912 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e41930ef5b883c0f2a6b7eb9606021d14a3df145bc94cb0d508af22b4db7f168 +da0b794852f8ccba5bd30395892044ec71b148075608406867785395e1f50b31 diff --git a/src/expr.c b/src/expr.c index b7dbc721e2..6d2b6d1339 100644 --- a/src/expr.c +++ b/src/expr.c @@ -85,7 +85,9 @@ char sqlite3ExprAffinity(const Expr *pExpr){ op = pExpr->op; continue; } - if( op!=TK_REGISTER || (op = pExpr->op2)==TK_REGISTER ) break; + if( op!=TK_REGISTER ) break; + op = pExpr->op2; + if( NEVER( op==TK_REGISTER ) ) break; } return pExpr->affExpr; } From f1bf103e4e6a7735d05b902554a73909d22ca123 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 29 Jun 2024 15:57:55 +0000 Subject: [PATCH 0510/1030] Fix a typo in a comment in a test case. No changes to code. FossilOrigin-Name: f501166de4f967b7e2e895f180308630e3c88b12bc51823a0a124ee5089eae4f --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/lock5.test | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6f2719b768..f8bd5288b2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sNEVER()\saround\sa\sbranch\sin\ssqlite3ExprAffinity()\sthat\sis\sdesigned\sto\nprevent\san\sinfinite\sloop,\sbut\swhich\scan\snow\snever\sbe\sreached\sdue\sto\srecent\nchanges. -D 2024-06-29T12:22:32.074 +C Fix\sa\stypo\sin\sa\scomment\sin\sa\stest\scase.\s\sNo\schanges\sto\scode. +D 2024-06-29T15:57:55.444 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1388,7 +1388,7 @@ F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00 F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8 -F test/lock5.test 626571313daef2c949ce002f861042d63d81119fa62a9e999721c8bbd85e1ec9 +F test/lock5.test 24693e40a805f71d80836f720d1f2034684a39b64f1e1990989002c7968c11ee F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e41930ef5b883c0f2a6b7eb9606021d14a3df145bc94cb0d508af22b4db7f168 -R a8bad0dfb59bfd3d7574dd38a5f03ea3 +P da0b794852f8ccba5bd30395892044ec71b148075608406867785395e1f50b31 +R acae33f3c288c2d7bdec5a362a7f8ce0 U drh -Z af9d587fdd1c2ab0ac6a540d9280d767 +Z f94fafdb74ae77978d771c3157233349 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2818078912..b7862f6d86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -da0b794852f8ccba5bd30395892044ec71b148075608406867785395e1f50b31 +f501166de4f967b7e2e895f180308630e3c88b12bc51823a0a124ee5089eae4f diff --git a/test/lock5.test b/test/lock5.test index d5950118ce..e0c88aedcf 100644 --- a/test/lock5.test +++ b/test/lock5.test @@ -207,7 +207,7 @@ if {[permutation]!="inmemory_journal"} { # not commit it. # 3. Make a copy of the database files on disk. # 4. Try to read from the copy using unix-dotfile VFS. This fails because - # the dotfile still exists, so SQLite things the database is locked. + # the dotfile still exists, so SQLite thinks the database is locked. # 5. Remove the dotfile. # 6. Try to read the db again. This time, the old transaction is rolled # back and the read permitted. @@ -269,5 +269,3 @@ if {[permutation]!="inmemory_journal"} { } finish_test - - From 2143714d9fdaa8301c4fd6c6838980ffffa90d23 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 2 Jul 2024 11:30:10 +0000 Subject: [PATCH 0511/1030] In the CLI, if the XDG_CONFIG_HOME environment variable is not set, then also search in ~/.config/sqlite3/sqliterc for the initialization file. See [forum:/forumpost/5cc6d059e9e092ed|forum thread 5cc6d059e9e092ed]. FossilOrigin-Name: 33841c9c3cb57beeb3884d4b0715d26199926b7d3e4d3dd1ab6f5603b5a62591 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 26 ++++++++++++++------------ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index f8bd5288b2..2be01ec469 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sa\scomment\sin\sa\stest\scase.\s\sNo\schanges\sto\scode. -D 2024-06-29T15:57:55.444 +C In\sthe\sCLI,\sif\sthe\sXDG_CONFIG_HOME\senvironment\svariable\sis\snot\sset,\sthen\salso\nsearch\sin\s~/.config/sqlite3/sqliterc\sfor\sthe\sinitialization\sfile.\nSee\s[forum:/forumpost/5cc6d059e9e092ed|forum\sthread\s5cc6d059e9e092ed]. +D 2024-07-02T11:30:10.110 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -756,7 +756,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c a1c8fadd45d0843b14793db2af49809a5327db5cca9d87d507b57aa748ee6ee2 -F src/shell.c.in 2ccbed6a9fd451399b0f378aafa323ad2286fa9de54ae0cd28f32907cd94d18d +F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee13 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P da0b794852f8ccba5bd30395892044ec71b148075608406867785395e1f50b31 -R acae33f3c288c2d7bdec5a362a7f8ce0 +P f501166de4f967b7e2e895f180308630e3c88b12bc51823a0a124ee5089eae4f +R 6a28d98f3f498767724b2d1e90b19ed7 U drh -Z f94fafdb74ae77978d771c3157233349 +Z 57777f6769e0082451e1ca7f15cd46db # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b7862f6d86..7699a334b7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f501166de4f967b7e2e895f180308630e3c88b12bc51823a0a124ee5089eae4f +33841c9c3cb57beeb3884d4b0715d26199926b7d3e4d3dd1ab6f5603b5a62591 diff --git a/src/shell.c.in b/src/shell.c.in index a5bfab589b..ec7e7ce44e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -11974,27 +11974,29 @@ static char *find_home_dir(int clearFlag){ /* ** On non-Windows platforms, look for $XDG_CONFIG_HOME. ** If ${XDG_CONFIG_HOME}/sqlite3/sqliterc is found, return -** the path to it, else return 0. The result is cached for -** subsequent calls. +** the path to it. If there is no $(XDG_CONFIG_HOME) then +** look for $(HOME)/.config/sqlite3/sqliterc and if found +** return that. If none of these are found, return 0. +** +** The string returned is obtained from sqlite3_malloc() and +** should be freed by the caller. */ -static const char *find_xdg_config(void){ +static char *find_xdg_config(void){ #if defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE) \ || defined(__RTP__) || defined(_WRS_KERNEL) return 0; #else - static int alreadyTried = 0; - static char *zConfig = 0; + char *zConfig = 0; const char *zXdgHome; - if( alreadyTried!=0 ){ - return zConfig; - } - alreadyTried = 1; zXdgHome = getenv("XDG_CONFIG_HOME"); if( zXdgHome==0 ){ - return 0; + const char *zHome = getenv("HOME"); + if( zHome==0 ) return 0; + zConfig = sqlite3_mprintf("%s/.config/sqlite3/sqliterc", zHome); + }else{ + zConfig = sqlite3_mprintf("%s/sqlite3/sqliterc", zXdgHome); } - zConfig = sqlite3_mprintf("%s/sqlite3/sqliterc", zXdgHome); shell_check_oom(zConfig); if( access(zConfig,0)!=0 ){ sqlite3_free(zConfig); @@ -12022,7 +12024,7 @@ static void process_sqliterc( int savedLineno = p->lineno; if( sqliterc == NULL ){ - sqliterc = find_xdg_config(); + sqliterc = zBuf = find_xdg_config(); } if( sqliterc == NULL ){ home_dir = find_home_dir(0); From 8960c02b916e08aab29fe4ed9fd48ee0d50ded35 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 2 Jul 2024 12:16:29 +0000 Subject: [PATCH 0512/1030] Reword the deliberate_fall_through macro along the lines suggested by [forum:/forumpost/7ec11023dd|forum post 7ec11023dd] so that it works better with LLVM, while preserving compatibility with MSVC and older GCCs. FossilOrigin-Name: fc248a4a0a232a95a79e24e57faedb5d824c3bf0aa62054b72339257dc9c18b3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 11 +++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 2be01ec469..16e36001d3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sCLI,\sif\sthe\sXDG_CONFIG_HOME\senvironment\svariable\sis\snot\sset,\sthen\salso\nsearch\sin\s~/.config/sqlite3/sqliterc\sfor\sthe\sinitialization\sfile.\nSee\s[forum:/forumpost/5cc6d059e9e092ed|forum\sthread\s5cc6d059e9e092ed]. -D 2024-07-02T11:30:10.110 +C Reword\sthe\sdeliberate_fall_through\smacro\salong\sthe\slines\ssuggested\sby\n[forum:/forumpost/7ec11023dd|forum\spost\s7ec11023dd]\sso\sthat\sit\sworks\sbetter\nwith\sLLVM,\swhile\spreserving\scompatibility\swith\sMSVC\sand\solder\sGCCs. +D 2024-07-02T12:16:29.921 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee1 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 76f4bf5adce98a989bf9b792b962bc8f739e79636a63d841e567017370acd607 +F src/sqliteInt.h 86cbef26e285786dfd6dc7b33cfed0210095eb3ce9b38047229b03eb795b2edd F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f501166de4f967b7e2e895f180308630e3c88b12bc51823a0a124ee5089eae4f -R 6a28d98f3f498767724b2d1e90b19ed7 +P 33841c9c3cb57beeb3884d4b0715d26199926b7d3e4d3dd1ab6f5603b5a62591 +R 6d0ab08fc854e246f36e42b260e205ea U drh -Z 57777f6769e0082451e1ca7f15cd46db +Z 68a54013a359b4e420c53cf740e0539d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7699a334b7..a3bc805345 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -33841c9c3cb57beeb3884d4b0715d26199926b7d3e4d3dd1ab6f5603b5a62591 +fc248a4a0a232a95a79e24e57faedb5d824c3bf0aa62054b72339257dc9c18b3 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 736889868e..fd9faf6b43 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -143,10 +143,13 @@ /* ** Macro to disable warnings about missing "break" at the end of a "case". */ -#if GCC_VERSION>=7000000 -# define deliberate_fall_through __attribute__((fallthrough)); -#else -# define deliberate_fall_through +#if defined(__has_attribute) +# if __has_attribute(fallthrough) +# define deliberate_fall_through __attribute__((fallthrough)); +# endif +#endif +#if !defined(deliberate_fall_through) +# define deliberate_fall_through #endif /* From 3d24637325188c1ed9db46e5bb23ab5d747ad29f Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 2 Jul 2024 13:54:46 +0000 Subject: [PATCH 0513/1030] Add assert() statements to FTS5 to hush-up warnings from scan-build. FossilOrigin-Name: 77a76654e64c05f2c67be120f579fc60924ff51a9d0fa2cf9eb158f40171b5f5 --- ext/fts5/fts5_expr.c | 3 +++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 3c70603568..732d4cf893 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -1875,6 +1875,7 @@ Fts5ExprPhrase *sqlite3Fts5ParseTerm( }else if( sCtx.pPhrase->nTerm ){ sCtx.pPhrase->aTerm[sCtx.pPhrase->nTerm-1].bPrefix = (u8)bPrefix; } + assert( pParse->apPhrase!=0 ); pParse->apPhrase[pParse->nPhrase-1] = sCtx.pPhrase; } @@ -2469,6 +2470,8 @@ Fts5ExprNode *sqlite3Fts5ParseImplicitAnd( ); if( pRight->eType==FTS5_EOF ){ + assert( pParse->apPhrase!=0 ); + assert( pParse->nPhrase>0 ); assert( pParse->apPhrase[pParse->nPhrase-1]==pRight->pNear->apPhrase[0] ); sqlite3Fts5ParseNodeFree(pRight); pRet = pLeft; diff --git a/manifest b/manifest index 16e36001d3..d24ae82c79 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reword\sthe\sdeliberate_fall_through\smacro\salong\sthe\slines\ssuggested\sby\n[forum:/forumpost/7ec11023dd|forum\spost\s7ec11023dd]\sso\sthat\sit\sworks\sbetter\nwith\sLLVM,\swhile\spreserving\scompatibility\swith\sMSVC\sand\solder\sGCCs. -D 2024-07-02T12:16:29.921 +C Add\sassert()\sstatements\sto\sFTS5\sto\shush-up\swarnings\sfrom\sscan-build. +D 2024-07-02T13:54:46.151 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -97,7 +97,7 @@ F ext/fts5/fts5Int.h 407ee36addad0ae6df5d37a811f0bd509ab6708b29640884ed5c7509e5f F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 -F ext/fts5/fts5_expr.c fb26894f8dd1081afefb70f0baa36a6e80b40d89df90140bc713d27194dc6dd9 +F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 F ext/fts5/fts5_main.c 1d8bd88240f4ece62645c93df2a09162607e3b3d33838107bb711e8ad1f7cf14 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 33841c9c3cb57beeb3884d4b0715d26199926b7d3e4d3dd1ab6f5603b5a62591 -R 6d0ab08fc854e246f36e42b260e205ea +P fc248a4a0a232a95a79e24e57faedb5d824c3bf0aa62054b72339257dc9c18b3 +R f55a5b83388b86278f89f11080405f1e U drh -Z 68a54013a359b4e420c53cf740e0539d +Z dda9ed678e9e469573614b965067e0d5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a3bc805345..632f9e6c54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc248a4a0a232a95a79e24e57faedb5d824c3bf0aa62054b72339257dc9c18b3 +77a76654e64c05f2c67be120f579fc60924ff51a9d0fa2cf9eb158f40171b5f5 From 6172e4355fed92aa2fba670acf0275922b449a39 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 3 Jul 2024 17:51:48 +0000 Subject: [PATCH 0514/1030] Use a Bloom filter to improve performance of IN operators when the RHS of the IN operator is a subquery. FossilOrigin-Name: 1933496539c19cbf429a39d6b0b1c6b1b2af50733a3c4aea4920990ced652f6a --- manifest | 19 +++++++++++-------- manifest.uuid | 2 +- src/expr.c | 26 +++++++++++++++++++++++++- src/select.c | 9 +++++++++ src/sqliteInt.h | 6 +++++- 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index d24ae82c79..054fab72aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sassert()\sstatements\sto\sFTS5\sto\shush-up\swarnings\sfrom\sscan-build. -D 2024-07-02T13:54:46.151 +C Use\sa\sBloom\sfilter\sto\simprove\sperformance\sof\sIN\soperators\swhen\sthe\sRHS\sof\nthe\sIN\soperator\sis\sa\ssubquery. +D 2024-07-03T17:51:48.915 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 2b72d352a2917fe8d2cd8f84e0acd0140c6ba769b0cd7bcfd86eb9ba0c9c50e8 +F src/expr.c d6f614d0c90cf8d72bbd54dbae96040e7feb495a77991fdc1b1c67db68eeb326 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -755,12 +755,12 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c a1c8fadd45d0843b14793db2af49809a5327db5cca9d87d507b57aa748ee6ee2 +F src/select.c ca249242cf6c8762f505b30d93915ee61a21de30fd69fbfcf04a7ea8dda6b334 F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee13 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 86cbef26e285786dfd6dc7b33cfed0210095eb3ce9b38047229b03eb795b2edd +F src/sqliteInt.h 039b5309b49399340f260ad3d1e6b6fa13e04a7b587b9daa1e694ce0f13a04a3 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2195,8 +2195,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fc248a4a0a232a95a79e24e57faedb5d824c3bf0aa62054b72339257dc9c18b3 -R f55a5b83388b86278f89f11080405f1e +P 77a76654e64c05f2c67be120f579fc60924ff51a9d0fa2cf9eb158f40171b5f5 +R 4c7ee9fc9c8b7335da98fdebc409f26a +T *branch * in-bloom +T *sym-in-bloom * +T -sym-trunk * U drh -Z dda9ed678e9e469573614b965067e0d5 +Z e24cefbcb7cf0e7de9d7a748b98704bf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 632f9e6c54..bee2a32214 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -77a76654e64c05f2c67be120f579fc60924ff51a9d0fa2cf9eb158f40171b5f5 +1933496539c19cbf429a39d6b0b1c6b1b2af50733a3c4aea4920990ced652f6a diff --git a/src/expr.c b/src/expr.c index 6d2b6d1339..6d67d77f68 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3536,19 +3536,34 @@ void sqlite3CodeRhsOfIN( SelectDest dest; int i; int rc; + int addrBloom = 0; sqlite3SelectDestInit(&dest, SRT_Set, iTab); dest.zAffSdst = exprINAffinity(pParse, pExpr); pSelect->iLimit = 0; + if( addrOnce && OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ){ + int regBloom = ++pParse->nMem; + addrBloom = sqlite3VdbeAddOp2(v, OP_Blob, 10000, regBloom); + VdbeComment((v, "Bloom filter")); + dest.iSDParm2 = regBloom; + } testcase( pSelect->selFlags & SF_Distinct ); testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ pCopy = sqlite3SelectDup(pParse->db, pSelect, 0); rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest); sqlite3SelectDelete(pParse->db, pCopy); sqlite3DbFree(pParse->db, dest.zAffSdst); + if( addrBloom ){ + sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2; + if( dest.iSDParm2==0 ){ + sqlite3VdbeChangeToNoop(v, addrBloom); + }else{ + sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2; + } + } if( rc ){ sqlite3KeyInfoUnref(pKeyInfo); return; - } + } assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ assert( pEList!=0 ); assert( pEList->nExpr>0 ); @@ -3987,6 +4002,15 @@ static void sqlite3ExprCodeIN( sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector); if( destIfFalse==destIfNull ){ /* Combine Step 3 and Step 5 into a single opcode */ + if( ExprHasProperty(pExpr, EP_Subrtn) ){ + const VdbeOp *pOp = sqlite3VdbeGetOp(v, pExpr->y.sub.iAddr); + assert( pOp->opcode==OP_Once || pParse->nErr ); + if( pOp->opcode==OP_Once && pOp->p3>0 ){ + assert( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ); + sqlite3VdbeAddOp4Int(v, OP_Filter, pOp->p3, destIfFalse, + rLhs, nVector); VdbeCoverage(v); + } + } sqlite3VdbeAddOp4Int(v, OP_NotFound, iTab, destIfFalse, rLhs, nVector); VdbeCoverage(v); goto sqlite3ExprCodeIN_finished; diff --git a/src/select.c b/src/select.c index b43861cef2..a1da3f51be 100644 --- a/src/select.c +++ b/src/select.c @@ -1377,12 +1377,17 @@ static void selectInnerLoop( ** case the order does matter */ pushOntoSorter( pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg); + pDest->iSDParm2 = 0; /* Signal that any Bloom filter is unpopulated */ }else{ int r1 = sqlite3GetTempReg(pParse); assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol ); sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol, r1, pDest->zAffSdst, nResultCol); sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol); + if( pDest->iSDParm2 ){ + sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pDest->iSDParm2, 0, + regResult, nResultCol); + } sqlite3ReleaseTempReg(pParse, r1); } break; @@ -3316,6 +3321,10 @@ static int generateOutputSubroutine( r1, pDest->zAffSdst, pIn->nSdst); sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pDest->iSDParm, r1, pIn->iSdst, pIn->nSdst); + if( pDest->iSDParm2>0 ){ + sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pDest->iSDParm2, 0, + pIn->iSdst, pIn->nSdst); + } sqlite3ReleaseTempReg(pParse, r1); break; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index fd9faf6b43..df6774aefd 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3622,7 +3622,11 @@ struct Select { ** SRT_Set The result must be a single column. Store each ** row of result as the key in table pDest->iSDParm. ** Apply the affinity pDest->affSdst before storing -** results. Used to implement "IN (SELECT ...)". +** results. if pDest->iSDParm2 is positive, then it is +** a regsiter holding a Bloom filter for the IN operator +** that should be populated in addition to the +** pDest->iSDParm table. This SRT is used to +** implement "IN (SELECT ...)". ** ** SRT_EphemTab Create an temporary table pDest->iSDParm and store ** the result there. The cursor is left open after From c4c2589ff0b7b9cff2dd50b79a63b226717c4c5f Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 3 Jul 2024 18:56:56 +0000 Subject: [PATCH 0515/1030] Add a new sqlite3FaultSim() call to OP_NotFound to use for testing purposes. FossilOrigin-Name: 84fd275bfd8afada50d3a5ac491d2b866671f8f0d2496bd240cf4bfdd74e7399 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/vdbe.c | 1 + 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 054fab72aa..e43198b751 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sa\sBloom\sfilter\sto\simprove\sperformance\sof\sIN\soperators\swhen\sthe\sRHS\sof\nthe\sIN\soperator\sis\sa\ssubquery. -D 2024-07-03T17:51:48.915 +C Add\sa\snew\ssqlite3FaultSim()\scall\sto\sOP_NotFound\sto\suse\sfor\stesting\spurposes. +D 2024-07-03T18:56:56.464 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -825,7 +825,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c b05777c3ff2ed7b9dfc347e7cdee18e371aa6811cef1fe83454691b0dbe2cc9f +F src/vdbe.c f941fd8dbd1a9e073866a941e7fbb553f1de2d25b249611005d8c27d5eac8995 F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 77a76654e64c05f2c67be120f579fc60924ff51a9d0fa2cf9eb158f40171b5f5 -R 4c7ee9fc9c8b7335da98fdebc409f26a -T *branch * in-bloom -T *sym-in-bloom * -T -sym-trunk * +P 1933496539c19cbf429a39d6b0b1c6b1b2af50733a3c4aea4920990ced652f6a +R 9c9e7e3ddb9d61c25f83c8cc55bade8c U drh -Z e24cefbcb7cf0e7de9d7a748b98704bf +Z fe58adb4deb8e6161fd0f3d3e1a34948 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bee2a32214..5b13d8922d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1933496539c19cbf429a39d6b0b1c6b1b2af50733a3c4aea4920990ced652f6a +84fd275bfd8afada50d3a5ac491d2b866671f8f0d2496bd240cf4bfdd74e7399 diff --git a/src/vdbe.c b/src/vdbe.c index 28f12e0542..4ece26d03e 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -5308,6 +5308,7 @@ case OP_Found: { /* jump, in3, ncycle */ r.pKeyInfo = pC->pKeyInfo; r.default_rc = 0; #ifdef SQLITE_DEBUG + (void)sqlite3FaultSim(50); /* For use by --counter in TH3 */ for(ii=0; ii Date: Wed, 3 Jul 2024 20:10:42 +0000 Subject: [PATCH 0516/1030] Show the creation of IN-operator Bloom filters in the EXPLAIN QUERY PLAN output. FossilOrigin-Name: c10a1b99d47a4c93bdb16e646f6a21add570d6dbb34fd91a32f8abacdb28712b --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/select.c | 2 ++ test/autoindex1.test | 3 ++- test/eqp.test | 3 ++- test/pushdown.test | 27 ++++++++++++++++++--------- test/rowvalue4.test | 6 ++++-- 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index e43198b751..8d6cef5918 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\ssqlite3FaultSim()\scall\sto\sOP_NotFound\sto\suse\sfor\stesting\spurposes. -D 2024-07-03T18:56:56.464 +C Show\sthe\screation\sof\sIN-operator\sBloom\sfilters\sin\sthe\sEXPLAIN\sQUERY\sPLAN\soutput. +D 2024-07-03T20:10:42.192 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -755,7 +755,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c ca249242cf6c8762f505b30d93915ee61a21de30fd69fbfcf04a7ea8dda6b334 +F src/select.c c448e2c0670ac590e5af53ef91e84a188bedb3d80d486e54948bf40d4dc4204b F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee13 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -908,7 +908,7 @@ F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1 F test/auth3.test 76d20a7fa136d63bcfcf8bcb65c0b1455ed71078d81f22bcd0550d3eb18594ab F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec F test/autoinc.test 997d6f185f138229dc4251583a1d04816423dddc2fc034871a01aeb1d728cb39 -F test/autoindex1.test d34caffb0384003ee28eae87679214c029e9be4b332d9649a79e0b94ab70502c +F test/autoindex1.test 714cac6e60beeb5a26ed346dd46505ba60b5a5597e9122c9ed3a55f89a922aa4 F test/autoindex2.test 12ef578928102baaa0dc23ad397601a2f4ecb0df F test/autoindex3.test ca502c8050166ac6107a7b4fe4e951f4d3270a23a958af02b14f1b962b83c4b6 F test/autoindex4.test 3c2105e9172920e26f950ba3c5823e4972190e022c1e6f260ba476b0af24c593 @@ -1106,7 +1106,7 @@ F test/enc.test 9a7be5479da985381d740b15f432800f65e2c87029ee57a318f42cb2eb43763a F test/enc2.test 848bf05f15b011719f478dddb7b5e9aea35e39e457493cba4c4eef75d849a5ec F test/enc3.test 55ef64416d72975c66167310a51dc9fc544ba3ae4858b8d5ab22f4cb6500b087 F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020 -F test/eqp.test 3302598f611220a6c61e29d9b7bb62fd4a43504509b978dbabdb0b3e56ae3bc0 +F test/eqp.test 815418b69f6be3a27037b1736c54699c72cc3e2e6b0bc878c01464d1dcec65fe F test/eqp2.test 6e8996148de88f0e7670491e92e712a2920a369b4406f21a27c3c9b6a46b68dd F test/errmsg.test eae9f091eb39ce7e20305de45d8e5d115b68fa856fba4ea6757b6ca3705ff7f9 F test/eval.test 73969a2d43a511bf44080c44485a8c4d796b6a4f038d19e491867081155692c0 @@ -1518,7 +1518,7 @@ F test/printf.test 685fec5a0c5af2490ab0632775a301554361d674211d690f5bee0a97b0533 F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224cce60 F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc -F test/pushdown.test 3330746a897ea271b1021bc1e7e57c6f8d49bcb8ca7d58a823d01aa64a303cc7 +F test/pushdown.test 9e655df51bc6559608dcc7af89a36f727eff520b4860261ed15a5f95a5ebbcd8 F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quickcheck.test a4b7e878cd97e46108291c409b0bf8214f29e18fddd68a42bc5c1375ad1fb80a @@ -1549,7 +1549,7 @@ F test/rowid.test d27191b5ce794c05bf61081e8b2c546a1844c1641321dcaf7fb785234256cc F test/rowvalue.test baf4fa3ec1a8c1c920c3faa5fd25959cb454bbd99ac8960397c34549d9fc4abe F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b F test/rowvalue3.test 1347e25ca11c547c5a6ff0cc5626f95aa9740e9275bfaec096029f57cb2130ce -F test/rowvalue4.test 441e7e366ac6d939a3a95a574031c56ec2a854077a91d66eee5ff1d86cb5be58 +F test/rowvalue4.test bac9326d1e886656650f67c0ec484eb5f452244a8209c6af508e9a862ace08ed F test/rowvalue5.test 00740304ea6a53a8704640c7405690f0045d5d2a6b4b04dde7bccc14c3068ea7 F test/rowvalue6.test d19b54feb604d5601f8614b15e214e0774c01087 F test/rowvalue7.test c1cbdbf407029db01f87764097c6ac02a1c5a37efd2776eff32a9cdfdf6f2dba @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1933496539c19cbf429a39d6b0b1c6b1b2af50733a3c4aea4920990ced652f6a -R 9c9e7e3ddb9d61c25f83c8cc55bade8c +P 84fd275bfd8afada50d3a5ac491d2b866671f8f0d2496bd240cf4bfdd74e7399 +R c969cbcf973aa6019e666c5feff1eff5 U drh -Z fe58adb4deb8e6161fd0f3d3e1a34948 +Z 44737a16c63fa6671a6e6fd4c06cf1bb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5b13d8922d..a20252c7f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -84fd275bfd8afada50d3a5ac491d2b866671f8f0d2496bd240cf4bfdd74e7399 +c10a1b99d47a4c93bdb16e646f6a21add570d6dbb34fd91a32f8abacdb28712b diff --git a/src/select.c b/src/select.c index a1da3f51be..b5b5198290 100644 --- a/src/select.c +++ b/src/select.c @@ -1387,6 +1387,7 @@ static void selectInnerLoop( if( pDest->iSDParm2 ){ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pDest->iSDParm2, 0, regResult, nResultCol); + ExplainQueryPlan((pParse, 0, "CREATE BLOOM FILTER")); } sqlite3ReleaseTempReg(pParse, r1); } @@ -3324,6 +3325,7 @@ static int generateOutputSubroutine( if( pDest->iSDParm2>0 ){ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pDest->iSDParm2, 0, pIn->iSdst, pIn->nSdst); + ExplainQueryPlan((pParse, 0, "CREATE BLOOM FILTER")); } sqlite3ReleaseTempReg(pParse, r1); break; diff --git a/test/autoindex1.test b/test/autoindex1.test index 08bd9f74e6..b294a2721f 100644 --- a/test/autoindex1.test +++ b/test/autoindex1.test @@ -185,7 +185,8 @@ do_eqp_test autoindex1-500.1 { QUERY PLAN |--SEARCH t501 USING INTEGER PRIMARY KEY (rowid=?) `--LIST SUBQUERY xxxxxx - `--SCAN t502 + |--SCAN t502 + `--CREATE BLOOM FILTER } do_eqp_test autoindex1-501 { SELECT b FROM t501 diff --git a/test/eqp.test b/test/eqp.test index cd441c271d..7da78665a9 100644 --- a/test/eqp.test +++ b/test/eqp.test @@ -311,7 +311,8 @@ det 3.3.1 { QUERY PLAN |--SCAN t1 `--LIST SUBQUERY xxxxxx - `--SCAN t2 + |--SCAN t2 + `--CREATE BLOOM FILTER } det 3.3.2 { SELECT * FROM t1 WHERE y IN (SELECT y FROM t2 WHERE t1.x!=t2.x) diff --git a/test/pushdown.test b/test/pushdown.test index 5c3e8182d1..b3663bd6f5 100644 --- a/test/pushdown.test +++ b/test/pushdown.test @@ -275,14 +275,17 @@ do_eqp_test 6.1 { | | `--LIST SUBQUERY xxxxxx | | |--MATERIALIZE k | | | `--SCAN 3 CONSTANT ROWS - | | `--SCAN k + | | |--SCAN k + | | `--CREATE BLOOM FILTER | `--UNION ALL | |--SEARCH t02 USING INDEX t02x (w=? AND x=? AND y>? AND y? AND y? AND y? AND y Date: Thu, 4 Jul 2024 09:45:23 +0000 Subject: [PATCH 0517/1030] For shell completion, use pragma_table_xinfo instead of pragma_table_info, so that generated columns are handled, as reported in [forum:f0735e05d8d7e857|forum post f0735e05d8d7e857]. FossilOrigin-Name: a204ffc06b468c2edf8f11ccf3de639edd4f8282e69a44ceeb68a4d3a43e77ea --- ext/misc/completion.c | 2 +- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ext/misc/completion.c b/ext/misc/completion.c index 987595a3d6..54abc0ae15 100644 --- a/ext/misc/completion.c +++ b/ext/misc/completion.c @@ -251,7 +251,7 @@ static int completionNext(sqlite3_vtab_cursor *cur){ zSql = sqlite3_mprintf( "%z%s" "SELECT pti.name FROM \"%w\".sqlite_schema AS sm" - " JOIN pragma_table_info(sm.name,%Q) AS pti" + " JOIN pragma_table_xinfo(sm.name,%Q) AS pti" " WHERE sm.type='table'", zSql, zSep, zDb, zDb ); diff --git a/manifest b/manifest index 28d5d1aa47..0cd37e6293 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sconstructing\san\sephermeral\stable\sto\suse\sas\sthe\sright-hand\sside\sof\nan\sIN\soperator,\salso\sconstruct\sa\sBloom\sfilter\sto\sspeed\smembership\stesting. -D 2024-07-03T20:19:33.270 +C For\sshell\scompletion,\suse\spragma_table_xinfo\sinstead\sof\spragma_table_info,\sso\sthat\sgenerated\scolumns\sare\shandled,\sas\sreported\sin\s[forum:f0735e05d8d7e857|forum\spost\sf0735e05d8d7e857]. +D 2024-07-04T09:45:23.225 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -385,7 +385,7 @@ F ext/misc/carray.c 34fac63770971611c5285de0a9f0ac67d504eaf66be891f637add9290f1c F ext/misc/carray.h 503209952ccf2431c7fd899ebb92bf46bf7635b38aace42ec8aa1b8d7b6e98a5 F ext/misc/cksumvfs.c 3a7931dd30667be6348af919f3f9e6188dfd7646b42af8e399a499b327f5bd63 F ext/misc/closure.c 0e04f52d93e678dd6f950f195f365992edf3c380df246f3d80425cba4c13891e -F ext/misc/completion.c ef78835483b43ac18c96be312b90b615d8368189909be03513ab7a9338131298 +F ext/misc/completion.c cb978c88d5577821323617a8ea775ce1b920e02dcdb593858f02044a4d008eea F ext/misc/compress.c 2c79a74330e0e0ba6cb3f7397f8ba5af12d46377ef5d3ee075e12dd8a6ed57f0 F ext/misc/csv.c 575c2c05fba0a451586a4d42c2c81e711780c41e797126f198d8d9e0a308dcdb F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f823e01 @@ -2195,9 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 77a76654e64c05f2c67be120f579fc60924ff51a9d0fa2cf9eb158f40171b5f5 c10a1b99d47a4c93bdb16e646f6a21add570d6dbb34fd91a32f8abacdb28712b -R c969cbcf973aa6019e666c5feff1eff5 -T +closed c10a1b99d47a4c93bdb16e646f6a21add570d6dbb34fd91a32f8abacdb28712b -U drh -Z f6a0a26b000fa84938a7a16f1457134d +P baa83b460c677c210c7fa3f20314d7e05f305aed8a69026bc5fa106a3de4ea38 +R b6b0f6bf3a9f29c3d04a87244b6b7008 +U stephan +Z 2e9a155351b52e0d45346f29a516cf2e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 519e638d14..61813da18b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -baa83b460c677c210c7fa3f20314d7e05f305aed8a69026bc5fa106a3de4ea38 +a204ffc06b468c2edf8f11ccf3de639edd4f8282e69a44ceeb68a4d3a43e77ea From 6357d35da9860ac5494d4653440fb913bdd66b0c Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 4 Jul 2024 11:15:32 +0000 Subject: [PATCH 0518/1030] Add comment using the name "predicate push-down optimization" to what we have also called "WHERE-clause push down". No changes to code. FossilOrigin-Name: be77fe701c7b7d3407800e1ed6a4c8be14035831790419cc99362bff41c65b60 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 0cd37e6293..e9c314df02 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sshell\scompletion,\suse\spragma_table_xinfo\sinstead\sof\spragma_table_info,\sso\sthat\sgenerated\scolumns\sare\shandled,\sas\sreported\sin\s[forum:f0735e05d8d7e857|forum\spost\sf0735e05d8d7e857]. -D 2024-07-04T09:45:23.225 +C Add\scomment\susing\sthe\sname\s"predicate\spush-down\soptimization"\sto\swhat\swe\shave\nalso\scalled\s"WHERE-clause\spush\sdown".\s\sNo\schanges\sto\scode. +D 2024-07-04T11:15:32.292 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -755,7 +755,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c c448e2c0670ac590e5af53ef91e84a188bedb3d80d486e54948bf40d4dc4204b +F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee13 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P baa83b460c677c210c7fa3f20314d7e05f305aed8a69026bc5fa106a3de4ea38 -R b6b0f6bf3a9f29c3d04a87244b6b7008 -U stephan -Z 2e9a155351b52e0d45346f29a516cf2e +P a204ffc06b468c2edf8f11ccf3de639edd4f8282e69a44ceeb68a4d3a43e77ea +R 7ddaa7e2074acfdf6d0130f12e8505c2 +U drh +Z 940dec88e4e92fbd5a212ce2f1e6eedc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 61813da18b..3c3a8a5560 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a204ffc06b468c2edf8f11ccf3de639edd4f8282e69a44ceeb68a4d3a43e77ea +be77fe701c7b7d3407800e1ed6a4c8be14035831790419cc99362bff41c65b60 diff --git a/src/select.c b/src/select.c index b5b5198290..4b0b554295 100644 --- a/src/select.c +++ b/src/select.c @@ -5077,7 +5077,8 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){ ** ** NAME AMBIGUITY ** -** This optimization is called the "WHERE-clause push-down optimization". +** This optimization is called the "WHERE-clause push-down optimization" +** or sometimes the "predicate push-down optimization". ** ** Do not confuse this optimization with another unrelated optimization ** with a similar name: The "MySQL push-down optimization" causes WHERE From 0cf237c5b0954aee3da991f8d1fb69e24cccfbaa Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 4 Jul 2024 16:57:11 +0000 Subject: [PATCH 0519/1030] Be more aggressive about reusing subqueries that appear on the RHS of IN operators that have been replicated due to the predicate push-down optimization. FossilOrigin-Name: 2accf32b6e45a396503c29eecc14a103bcc7b4c313cde921b26b489704060177 --- manifest | 21 +++++++------ manifest.uuid | 2 +- src/expr.c | 78 +++++++++++++++++++++++++++++++++++++++++++--- src/vdbe.h | 15 +++++++++ src/vdbeaux.c | 9 ++++++ test/pushdown.test | 28 ++++------------- 6 files changed, 116 insertions(+), 37 deletions(-) diff --git a/manifest b/manifest index e9c314df02..bca1e660ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\scomment\susing\sthe\sname\s"predicate\spush-down\soptimization"\sto\swhat\swe\shave\nalso\scalled\s"WHERE-clause\spush\sdown".\s\sNo\schanges\sto\scode. -D 2024-07-04T11:15:32.292 +C Be\smore\saggressive\sabout\sreusing\ssubqueries\sthat\sappear\son\sthe\sRHS\sof\sIN\noperators\sthat\shave\sbeen\sreplicated\sdue\sto\sthe\spredicate\spush-down\soptimization. +D 2024-07-04T16:57:11.632 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c d6f614d0c90cf8d72bbd54dbae96040e7feb495a77991fdc1b1c67db68eeb326 +F src/expr.c 06c1d1a0f8b5025f001bc8219ac63fded7c33494a1863afdc78032ed1085ffef F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -826,10 +826,10 @@ F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 F src/vdbe.c f941fd8dbd1a9e073866a941e7fbb553f1de2d25b249611005d8c27d5eac8995 -F src/vdbe.h c2d78d15112c3fc5ab87f5e8e0b75d2db1c624409de2e858c3d1aafb1650bb4f +F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df -F src/vdbeaux.c 6e37cb918506c28fe7657454fcbc2e01e66bfba4164f306c2f075fd5c5fef609 +F src/vdbeaux.c 8d522d012c0545035be52e46b4cc5dfa752e376e17137816e558b3ab6bec9e5d F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 831a244831eaa45335f9ae276b50a7a82ee10d8c46c2c72492d4eb8c98d94d89 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 @@ -1518,7 +1518,7 @@ F test/printf.test 685fec5a0c5af2490ab0632775a301554361d674211d690f5bee0a97b0533 F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224cce60 F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc -F test/pushdown.test 9e655df51bc6559608dcc7af89a36f727eff520b4860261ed15a5f95a5ebbcd8 +F test/pushdown.test 84b525767442b3695d671f9df59dd91cf0ed8fb24cbbcdc55959f0dadeee8b39 F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quickcheck.test a4b7e878cd97e46108291c409b0bf8214f29e18fddd68a42bc5c1375ad1fb80a @@ -2195,8 +2195,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a204ffc06b468c2edf8f11ccf3de639edd4f8282e69a44ceeb68a4d3a43e77ea -R 7ddaa7e2074acfdf6d0130f12e8505c2 +P be77fe701c7b7d3407800e1ed6a4c8be14035831790419cc99362bff41c65b60 +R 53a737f2af23a108773b1a9f30c846b8 +T *branch * reuse-subqueries +T *sym-reuse-subqueries * +T -sym-trunk * U drh -Z 940dec88e4e92fbd5a212ce2f1e6eedc +Z 375183e5bacb7ab157909f081f98b1e8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3c3a8a5560..2a35b48263 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -be77fe701c7b7d3407800e1ed6a4c8be14035831790419cc99362bff41c65b60 +2accf32b6e45a396503c29eecc14a103bcc7b4c313cde921b26b489704060177 diff --git a/src/expr.c b/src/expr.c index 6d67d77f68..9ab1905050 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3420,6 +3420,46 @@ void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){ } } +#ifndef SQLITE_OMIT_SUBQUERY +/* +** Scan all previously generated bytecode looking for an OP_BeginSubrtn +** that is compatible with pExpr. If found, add the y.sub values +** to pExpr and return true. If not found, return false. +*/ +static int findCompatibleInRhsSubrtn( + Parse *pParse, /* Parsing context */ + Expr *pExpr, /* IN operator with RHS that we want to reuse */ + SubrtnSig *pNewSig /* Signature for the IN operator */ +){ + VdbeOp *pOp, *pEnd; + SubrtnSig *pSig; + Vdbe *v; + + if( pNewSig==0 ) return 0; + assert( pExpr->op==TK_IN ); + assert( !ExprUseYSub(pExpr) ); + assert( ExprUseXSelect(pExpr) ); + v = pParse->pVdbe; + assert( v!=0 ); + pOp = sqlite3VdbeGetOp(v, 1); + pEnd = sqlite3VdbeGetLastOp(v); + for(; pOpopcode!=OP_BeginSubrtn ) continue; + if( pOp->p4type!=P4_SUBRTNSIG ) continue; + pSig = pOp->p4.pSubrtnSig; + assert( pSig!=0 ); + if( pNewSig->selId!=pSig->selId ) continue; + if( strcmp(pNewSig->zAff,pSig->zAff)!=0 ) continue; + pExpr->y.sub.iAddr = pSig->iAddr; + pExpr->y.sub.regReturn = pSig->regReturn; + pExpr->iTable = pSig->iTable; + ExprSetProperty(pExpr, EP_Subrtn); + return 1; + } + return 0; +} +#endif /* SQLITE_OMIT_SUBQUERY */ + #ifndef SQLITE_OMIT_SUBQUERY /* ** Generate code that will construct an ephemeral table containing all terms @@ -3469,11 +3509,30 @@ void sqlite3CodeRhsOfIN( ** and reuse it many names. */ if( !ExprHasProperty(pExpr, EP_VarSelect) && pParse->iSelfTab==0 ){ - /* Reuse of the RHS is allowed */ - /* If this routine has already been coded, but the previous code - ** might not have been invoked yet, so invoke it now as a subroutine. + /* Reuse of the RHS is allowed + ** + ** Compute a signature for the RHS of the IN operator to facility + ** finding and reusing prior instances of the same IN operator. + */ + SubrtnSig *pSig; + if( !ExprUseXSelect(pExpr) ){ + pSig = 0; + }else{ + assert( pExpr->x.pSelect!=0 ); + pSig = sqlite3DbMallocRawNN(pParse->db, sizeof(pSig[0])); + if( pSig ){ + pSig->selId = pExpr->x.pSelect->selId; + pSig->zAff = exprINAffinity(pParse, pExpr); + } + } + + /* Check to see if there is a prior materialization of the RHS of + ** this IN operator. If there is, then make use of that prior + ** materialization rather than recomputing it. */ - if( ExprHasProperty(pExpr, EP_Subrtn) ){ + if( ExprHasProperty(pExpr, EP_Subrtn) + || findCompatibleInRhsSubrtn(pParse, pExpr, pSig) + ){ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); if( ExprUseXSelect(pExpr) ){ ExplainQueryPlan((pParse, 0, "REUSE LIST SUBQUERY %d", @@ -3485,6 +3544,10 @@ void sqlite3CodeRhsOfIN( assert( iTab!=pExpr->iTable ); sqlite3VdbeAddOp2(v, OP_OpenDup, iTab, pExpr->iTable); sqlite3VdbeJumpHere(v, addrOnce); + if( pSig ){ + sqlite3DbFree(pParse->db, pSig->zAff); + sqlite3DbFree(pParse->db, pSig); + } return; } @@ -3495,7 +3558,12 @@ void sqlite3CodeRhsOfIN( pExpr->y.sub.regReturn = ++pParse->nMem; pExpr->y.sub.iAddr = sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1; - + if( pSig ){ + pSig->iAddr = pExpr->y.sub.iAddr; + pSig->regReturn = pExpr->y.sub.regReturn; + pSig->iTable = iTab; + sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG); + } addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); } diff --git a/src/vdbe.h b/src/vdbe.h index 9001ace2ee..f40f68d24b 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -32,6 +32,19 @@ typedef struct Vdbe Vdbe; */ typedef struct sqlite3_value Mem; typedef struct SubProgram SubProgram; +typedef struct SubrtnSig SubrtnSig; + +/* +** A signature for a reusable subroutine that materializes the RHS of +** an IN operator. +*/ +struct SubrtnSig { + int selId; /* SELECT-id for the SELECT statement on the RHS */ + char *zAff; /* Affinity of the overall IN expression */ + int iTable; /* Ephemeral table generated by the subroutine */ + int iAddr; /* Subroutine entry address */ + int regReturn; /* Register used to hold return address */ +}; /* ** A single instruction of the virtual machine has an opcode @@ -60,6 +73,7 @@ struct VdbeOp { u32 *ai; /* Used when p4type is P4_INTARRAY */ SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ Table *pTab; /* Used when p4type is P4_TABLE */ + SubrtnSig *pSubrtnSig; /* Used when p4type is P4_SUBRTNSIG */ #ifdef SQLITE_ENABLE_CURSOR_HINTS Expr *pExpr; /* Used when p4type is P4_EXPR */ #endif @@ -127,6 +141,7 @@ typedef struct VdbeOpList VdbeOpList; #define P4_INTARRAY (-14) /* P4 is a vector of 32-bit integers */ #define P4_FUNCCTX (-15) /* P4 is a pointer to an sqlite3_context object */ #define P4_TABLEREF (-16) /* Like P4_TABLE, but reference counted */ +#define P4_SUBRTNSIG (-17) /* P4 is a SubrtnSig pointer */ /* Error message codes for OP_Halt */ #define P5_ConstraintNotNull 1 diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 665f6cd17a..745d3eaba6 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1413,6 +1413,12 @@ static void freeP4(sqlite3 *db, int p4type, void *p4){ if( db->pnBytesFreed==0 ) sqlite3DeleteTable(db, (Table*)p4); break; } + case P4_SUBRTNSIG: { + SubrtnSig *pSig = (SubrtnSig*)p4; + sqlite3DbFree(db, pSig->zAff); + sqlite3DbFree(db, pSig); + break; + } } } @@ -1992,6 +1998,9 @@ char *sqlite3VdbeDisplayP4(sqlite3 *db, Op *pOp){ zP4 = pOp->p4.pTab->zName; break; } + case P4_SUBRTNSIG: { + break; + } default: { zP4 = pOp->p4.z; } diff --git a/test/pushdown.test b/test/pushdown.test index b3663bd6f5..271d412e7e 100644 --- a/test/pushdown.test +++ b/test/pushdown.test @@ -279,13 +279,9 @@ do_eqp_test 6.1 { | | `--CREATE BLOOM FILTER | `--UNION ALL | |--SEARCH t02 USING INDEX t02x (w=? AND x=? AND y>? AND y? AND y? AND y Date: Thu, 4 Jul 2024 17:49:34 +0000 Subject: [PATCH 0520/1030] Update EXPLAIN output to include P4_SUBRTNSIG. FossilOrigin-Name: 61e56923c80d72d6467ec703b4946b251abf591649fa9e8e579667d7cbd25682 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/vdbeaux.c | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index bca1e660ac..c77a3ad9e8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Be\smore\saggressive\sabout\sreusing\ssubqueries\sthat\sappear\son\sthe\sRHS\sof\sIN\noperators\sthat\shave\sbeen\sreplicated\sdue\sto\sthe\spredicate\spush-down\soptimization. -D 2024-07-04T16:57:11.632 +C Update\sEXPLAIN\soutput\sto\sinclude\sP4_SUBRTNSIG. +D 2024-07-04T17:49:34.845 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -829,7 +829,7 @@ F src/vdbe.c f941fd8dbd1a9e073866a941e7fbb553f1de2d25b249611005d8c27d5eac8995 F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df -F src/vdbeaux.c 8d522d012c0545035be52e46b4cc5dfa752e376e17137816e558b3ab6bec9e5d +F src/vdbeaux.c 25d685cafe119ff890c94345e884ea558a6b5d823bfa52ba708eb8ff3c70aa71 F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 831a244831eaa45335f9ae276b50a7a82ee10d8c46c2c72492d4eb8c98d94d89 F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 @@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P be77fe701c7b7d3407800e1ed6a4c8be14035831790419cc99362bff41c65b60 -R 53a737f2af23a108773b1a9f30c846b8 -T *branch * reuse-subqueries -T *sym-reuse-subqueries * -T -sym-trunk * -U drh -Z 375183e5bacb7ab157909f081f98b1e8 +P 2accf32b6e45a396503c29eecc14a103bcc7b4c313cde921b26b489704060177 +R cc0b42021fc412ee4ab07a9997d10b3f +U dan +Z 6dc43e94d75155dfb066f57a2c862429 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2a35b48263..99fd14fa87 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2accf32b6e45a396503c29eecc14a103bcc7b4c313cde921b26b489704060177 +61e56923c80d72d6467ec703b4946b251abf591649fa9e8e579667d7cbd25682 diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 745d3eaba6..f1e0cccdc1 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1999,6 +1999,8 @@ char *sqlite3VdbeDisplayP4(sqlite3 *db, Op *pOp){ break; } case P4_SUBRTNSIG: { + SubrtnSig *pSig = pOp->p4.pSubrtnSig; + sqlite3_str_appendf(&x, "subrtnsig:%d,%s", pSig->selId, pSig->zAff); break; } default: { From 42305fc126ace326056cca073d4a3bc1661098b7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 4 Jul 2024 18:26:41 +0000 Subject: [PATCH 0521/1030] Disable the reuse of IN-clause subqueries if the subquery is an explicit "SELECT ALL". The ALL keyword is almost never used in actual practice (most developers don't even know it can be used) so this should not interfere with the optimization, but it does give us a convenient way to turn it off for testing purposes. FossilOrigin-Name: a81299be2ce203dcc28e7d0ba24791cbfba80e1ee3e1564469a226cac8adb17d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index c77a3ad9e8..f034199d31 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sEXPLAIN\soutput\sto\sinclude\sP4_SUBRTNSIG. -D 2024-07-04T17:49:34.845 +C Disable\sthe\sreuse\sof\sIN-clause\ssubqueries\sif\sthe\ssubquery\sis\san\sexplicit\n"SELECT\sALL".\s\sThe\sALL\skeyword\sis\salmost\snever\sused\sin\sactual\spractice\s(most\ndevelopers\sdon't\seven\sknow\sit\scan\sbe\sused)\sso\sthis\sshould\snot\sinterfere\swith\nthe\soptimization,\sbut\sit\sdoes\sgive\sus\sa\sconvenient\sway\sto\sturn\sit\soff\sfor\ntesting\spurposes. +D 2024-07-04T18:26:41.697 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 06c1d1a0f8b5025f001bc8219ac63fded7c33494a1863afdc78032ed1085ffef +F src/expr.c dd797fc96a5be012283ea1a42d8444dd97e12300769007c242fb5ed48f90d7e3 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2accf32b6e45a396503c29eecc14a103bcc7b4c313cde921b26b489704060177 -R cc0b42021fc412ee4ab07a9997d10b3f -U dan -Z 6dc43e94d75155dfb066f57a2c862429 +P 61e56923c80d72d6467ec703b4946b251abf591649fa9e8e579667d7cbd25682 +R 038e67018e45d309cbfa350b0e65e1eb +U drh +Z 639a0b5da2cedf3c0b33a56e08aa9e79 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 99fd14fa87..bc7e68b109 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -61e56923c80d72d6467ec703b4946b251abf591649fa9e8e579667d7cbd25682 +a81299be2ce203dcc28e7d0ba24791cbfba80e1ee3e1564469a226cac8adb17d diff --git a/src/expr.c b/src/expr.c index 9ab1905050..636cbd0fed 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3439,6 +3439,8 @@ static int findCompatibleInRhsSubrtn( assert( pExpr->op==TK_IN ); assert( !ExprUseYSub(pExpr) ); assert( ExprUseXSelect(pExpr) ); + assert( pExpr->x.pSelect!=0 ); + assert( (pExpr->x.pSelect->selFlags & SF_All)==0 ); v = pParse->pVdbe; assert( v!=0 ); pOp = sqlite3VdbeGetOp(v, 1); @@ -3514,11 +3516,9 @@ void sqlite3CodeRhsOfIN( ** Compute a signature for the RHS of the IN operator to facility ** finding and reusing prior instances of the same IN operator. */ - SubrtnSig *pSig; - if( !ExprUseXSelect(pExpr) ){ - pSig = 0; - }else{ - assert( pExpr->x.pSelect!=0 ); + SubrtnSig *pSig = 0; + assert( !ExprUseXSelect(pExpr) || pExpr->x.pSelect!=0 ); + if( ExprUseXSelect(pExpr) && (pExpr->x.pSelect->selFlags & SF_All)==0 ){ pSig = sqlite3DbMallocRawNN(pParse->db, sizeof(pSig[0])); if( pSig ){ pSig->selId = pExpr->x.pSelect->selId; From a61f11f3074962fe4efb9a1e3478176829397961 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 4 Jul 2024 18:56:26 +0000 Subject: [PATCH 0522/1030] Add test cases to in7.test. FossilOrigin-Name: 07817efc10a6ab59dcb18ad218a3bb5a5d49a724c51296d5c8d7e386b0e0c789 --- manifest | 14 ++++++------- manifest.uuid | 2 +- test/in7.test | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f034199d31..50a6cde27e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\sreuse\sof\sIN-clause\ssubqueries\sif\sthe\ssubquery\sis\san\sexplicit\n"SELECT\sALL".\s\sThe\sALL\skeyword\sis\salmost\snever\sused\sin\sactual\spractice\s(most\ndevelopers\sdon't\seven\sknow\sit\scan\sbe\sused)\sso\sthis\sshould\snot\sinterfere\swith\nthe\soptimization,\sbut\sit\sdoes\sgive\sus\sa\sconvenient\sway\sto\sturn\sit\soff\sfor\ntesting\spurposes. -D 2024-07-04T18:26:41.697 +C Add\stest\scases\sto\sin7.test. +D 2024-07-04T18:56:26.443 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1283,7 +1283,7 @@ F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test bb767ec1cfd1730256f0a83219f0acda36bc251b63f8b8bb7d8c7cff17875a4f F test/in5.test 4fd79c70dfa0681313e8cdca07f5ff0400bdc0e20f808a5c59eaef1e4b48082a F test/in6.test f5f40d6816a8bb7c784424b58a10ac38efb76ab29127a2c17399e0cbeeda0e4b -F test/in7.test 742b18c284cd9a9cd1347d3a8affeee44b8de11e875e91a1d40498c18ba16441 +F test/in7.test 9256cdb30dc487f2078bb4bb30f43f2c1ff4d277a9c7c9a14bd1c9510c9c8cae F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822 F test/incrblob2.test a494c9e848560039a23974b9119cfc2cf3ad3bd15cc2694ee6367ae537ef8f1f F test/incrblob3.test 67621a04b3084113bf38ce03797d70eca012d9d8f948193b8f655df577b0da6f @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 61e56923c80d72d6467ec703b4946b251abf591649fa9e8e579667d7cbd25682 -R 038e67018e45d309cbfa350b0e65e1eb -U drh -Z 639a0b5da2cedf3c0b33a56e08aa9e79 +P a81299be2ce203dcc28e7d0ba24791cbfba80e1ee3e1564469a226cac8adb17d +R a61b5910f9609e6e5a91fd0bf5827217 +U dan +Z 8485818c0bde0eca893245330444d4fb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bc7e68b109..68909b2521 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a81299be2ce203dcc28e7d0ba24791cbfba80e1ee3e1564469a226cac8adb17d +07817efc10a6ab59dcb18ad218a3bb5a5d49a724c51296d5c8d7e386b0e0c789 diff --git a/test/in7.test b/test/in7.test index 099f75c5f7..29013ff593 100644 --- a/test/in7.test +++ b/test/in7.test @@ -137,5 +137,61 @@ do_execsql_test 2.1 { SELECT b FROM t1 WHERE a IN (1,2,3) ORDER BY b ASC NULLS LAST; } {one three {}} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 3.0 { + CREATE TABLE x1(a); + INSERT INTO x1 VALUES(1), (2), (3); + + CREATE TABLE x2(b); + INSERT INTO x2 VALUES(4), (5), (6); + + CREATE TABLE t1(u); + INSERT INTO t1 VALUES(1), (2), (3), (4), (5), (6); + + CREATE VIEW v1 AS SELECT u FROM t1 WHERE u IN ( + SELECT a FROM x1 + ); + CREATE VIEW v2 AS SELECT u FROM t1 WHERE u IN ( + SELECT b FROM x2 + ); +} + +do_execsql_test 3.1 { + SELECT * FROM v1 +} { + 1 2 3 +} + +do_execsql_test 3.2 { + SELECT * FROM v2 +} { + 4 5 6 +} + +do_execsql_test 3.3 { + SELECT * FROM v2 + UNION ALL + SELECT * FROM v1 +} { + 4 5 6 + 1 2 3 +} + +do_execsql_test 3.4 { + WITH w1 AS ( + SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 + ), + w2 AS ( + SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 + ) + SELECT * FROM v1 WHERE u IN w1 + UNION ALL + SELECT * FROM v2 WHERE u IN w2 +} { + 1 2 3 4 5 6 +} + + finish_test From 615fc1f0831c2910aac4c943d0dc33e8ed108c6b Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 5 Jul 2024 01:05:34 +0000 Subject: [PATCH 0523/1030] Small performance optimizations. FossilOrigin-Name: 99fd34b58a9b09af20f1f1a3c37137ae55159310c8af97806550eeee6adc4fc5 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 4 +++- src/sqliteInt.h | 1 + 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 50a6cde27e..f10a9394b1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sto\sin7.test. -D 2024-07-04T18:56:26.443 +C Small\sperformance\soptimizations. +D 2024-07-05T01:05:34.326 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c dd797fc96a5be012283ea1a42d8444dd97e12300769007c242fb5ed48f90d7e3 +F src/expr.c 4d76a31f37302d11c89dd5184a0e1a80a95bd3f8c97e72fa2a18b64cc8672603 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -760,7 +760,7 @@ F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee1 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 039b5309b49399340f260ad3d1e6b6fa13e04a7b587b9daa1e694ce0f13a04a3 +F src/sqliteInt.h 5f940c22e14a7434b2fbefa53407372be2eed47b43cb9f4f98c5054c565d63b2 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a81299be2ce203dcc28e7d0ba24791cbfba80e1ee3e1564469a226cac8adb17d -R a61b5910f9609e6e5a91fd0bf5827217 -U dan -Z 8485818c0bde0eca893245330444d4fb +P 07817efc10a6ab59dcb18ad218a3bb5a5d49a724c51296d5c8d7e386b0e0c789 +R c2554732fd5d00a4bc9161c1ecfc2ecd +U drh +Z 928bbdf1e85848abd4aedfefb3089955 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 68909b2521..52d551e6bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -07817efc10a6ab59dcb18ad218a3bb5a5d49a724c51296d5c8d7e386b0e0c789 +99fd34b58a9b09af20f1f1a3c37137ae55159310c8af97806550eeee6adc4fc5 diff --git a/src/expr.c b/src/expr.c index 636cbd0fed..d012c3d5e6 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3436,6 +3436,7 @@ static int findCompatibleInRhsSubrtn( Vdbe *v; if( pNewSig==0 ) return 0; + if( pParse->bHasSubrtn==0 ) return 0; assert( pExpr->op==TK_IN ); assert( !ExprUseYSub(pExpr) ); assert( ExprUseXSelect(pExpr) ); @@ -3446,8 +3447,8 @@ static int findCompatibleInRhsSubrtn( pOp = sqlite3VdbeGetOp(v, 1); pEnd = sqlite3VdbeGetLastOp(v); for(; pOpopcode!=OP_BeginSubrtn ) continue; if( pOp->p4type!=P4_SUBRTNSIG ) continue; + assert( pOp->opcode==OP_BeginSubrtn ); pSig = pOp->p4.pSubrtnSig; assert( pSig!=0 ); if( pNewSig->selId!=pSig->selId ) continue; @@ -3563,6 +3564,7 @@ void sqlite3CodeRhsOfIN( pSig->regReturn = pExpr->y.sub.regReturn; pSig->iTable = iTab; sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG); + pParse->bHasSubrtn = 1; } addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index df6774aefd..323a257f6c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3834,6 +3834,7 @@ struct Parse { u8 prepFlags; /* SQLITE_PREPARE_* flags */ u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */ u8 bHasWith; /* True if statement contains WITH */ + u8 bHasSubrtn; /* True if any P4_SUBRTNSIG has been set */ #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */ #endif From 42123a294d38c5e25d2960f9f06e70b5850f39a0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 5 Jul 2024 13:55:59 +0000 Subject: [PATCH 0524/1030] Use a mini Bloom filter to help reduce the number of pointless searches for prior SubrtnSig objects when generating code for IN operators with subqueries as their right operand. FossilOrigin-Name: d8cedbe055b40a0ea4e5d47845b535162e9fcb0d0f88c03211797ab64d2d56fb --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/expr.c | 4 ++-- src/sqliteInt.h | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 70b8f686e3..92ab769f65 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sreuse\sof\ssubqueries\sassociated\swith\sIN\soperators,\sespecially\swhen\nthe\sIN\soperator\sis\sduplicated\sdue\sto\spredicate\spush-down. -D 2024-07-05T09:56:11.351 +C Use\sa\smini\sBloom\sfilter\sto\shelp\sreduce\sthe\snumber\sof\spointless\ssearches\sfor\nprior\sSubrtnSig\sobjects\swhen\sgenerating\scode\sfor\sIN\soperators\swith\ssubqueries\nas\stheir\sright\soperand. +D 2024-07-05T13:55:59.179 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 4d76a31f37302d11c89dd5184a0e1a80a95bd3f8c97e72fa2a18b64cc8672603 +F src/expr.c e8e5c5b2e2bf3d3d4b575c71e8fdd19caed20712afef6ad9fde735f9a210e08d F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -760,7 +760,7 @@ F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee1 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 5f940c22e14a7434b2fbefa53407372be2eed47b43cb9f4f98c5054c565d63b2 +F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955ac1 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2195,9 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P be77fe701c7b7d3407800e1ed6a4c8be14035831790419cc99362bff41c65b60 99fd34b58a9b09af20f1f1a3c37137ae55159310c8af97806550eeee6adc4fc5 -R c2554732fd5d00a4bc9161c1ecfc2ecd -T +closed 99fd34b58a9b09af20f1f1a3c37137ae55159310c8af97806550eeee6adc4fc5 +P c9a3498113074bbcd9a8c8d30286fef6c6a49ad2c84b90ec0f5a148389d6245c +R 048647da7489fe3c22ba97fe98be7560 U drh -Z 4e117d1a68420f4abee82559a7eb0fa4 +Z a8545f3061897f51fd0152659e811cae # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 38e9ad1c61..e68869204e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c9a3498113074bbcd9a8c8d30286fef6c6a49ad2c84b90ec0f5a148389d6245c +d8cedbe055b40a0ea4e5d47845b535162e9fcb0d0f88c03211797ab64d2d56fb diff --git a/src/expr.c b/src/expr.c index d012c3d5e6..e7df61c869 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3436,7 +3436,7 @@ static int findCompatibleInRhsSubrtn( Vdbe *v; if( pNewSig==0 ) return 0; - if( pParse->bHasSubrtn==0 ) return 0; + if( (pParse->mSubrtnSig & (1<<(pNewSig->selId&7)))==0 ) return 0; assert( pExpr->op==TK_IN ); assert( !ExprUseYSub(pExpr) ); assert( ExprUseXSelect(pExpr) ); @@ -3564,7 +3564,7 @@ void sqlite3CodeRhsOfIN( pSig->regReturn = pExpr->y.sub.regReturn; pSig->iTable = iTab; sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG); - pParse->bHasSubrtn = 1; + pParse->mSubrtnSig = 1 << (pSig->selId&7); } addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 323a257f6c..6a92befe0f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3834,7 +3834,7 @@ struct Parse { u8 prepFlags; /* SQLITE_PREPARE_* flags */ u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */ u8 bHasWith; /* True if statement contains WITH */ - u8 bHasSubrtn; /* True if any P4_SUBRTNSIG has been set */ + u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */ #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */ #endif From bee10b987cc67b736223f4cb9e110b3e678c211e Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 Jul 2024 16:01:49 +0000 Subject: [PATCH 0525/1030] Improve the error message returned when fts5 finds a row is missing from its content table. FossilOrigin-Name: 9b1afd4acb8cf9738154e921dcb074d895bbcc4742bf1016ef9f045a0da78bc8 --- ext/fts5/fts5_main.c | 35 ++++++++++++++++++++----------- ext/fts5/test/fts5content.test | 37 +++++++++++++++++++++++++++++++++ ext/fts5/test/fts5corrupt.test | 2 +- ext/fts5/test/fts5corrupt3.test | 2 +- manifest | 20 +++++++++--------- manifest.uuid | 2 +- 6 files changed, 73 insertions(+), 25 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index b0072268e2..c6e7e346aa 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1217,6 +1217,18 @@ static i64 fts5GetRowidLimit(sqlite3_value *pVal, i64 iDefault){ return iDefault; } +/* +** Set the error message on the virtual table passed as the first argument. +*/ +static void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){ + va_list ap; /* ... printf arguments */ + va_start(ap, zFormat); + sqlite3_free(p->p.base.zErrMsg); + p->p.base.zErrMsg = sqlite3_vmprintf(zFormat, ap); + va_end(ap); +} + + /* ** This is the xFilter interface for the virtual table. See ** the virtual table xFilter method documentation for additional @@ -1392,9 +1404,7 @@ static int fts5FilterMethod( } } }else if( pConfig->zContent==0 ){ - *pConfig->pzErrmsg = sqlite3_mprintf( - "%s: table does not support scanning", pConfig->zName - ); + fts5SetVtabError(pTab,"%s: table does not support scanning",pConfig->zName); rc = SQLITE_ERROR; }else{ /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup @@ -1469,6 +1479,7 @@ static int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ return SQLITE_OK; } + /* ** If the cursor requires seeking (bSeekRequired flag is set), seek it. ** Return SQLITE_OK if no error occurs, or an SQLite error code otherwise. @@ -1505,8 +1516,13 @@ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){ rc = sqlite3_reset(pCsr->pStmt); if( rc==SQLITE_OK ){ rc = FTS5_CORRUPT; + fts5SetVtabError((Fts5FullTable*)pTab, + "fts5: missing row %lld from content table %s", + fts5CursorRowid(pCsr), + pTab->pConfig->zContent + ); }else if( pTab->pConfig->pzErrmsg ){ - *pTab->pConfig->pzErrmsg = sqlite3_mprintf( + fts5SetVtabError((Fts5FullTable*)pTab, "%s", sqlite3_errmsg(pTab->pConfig->db) ); } @@ -1515,14 +1531,6 @@ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){ return rc; } -static void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){ - va_list ap; /* ... printf arguments */ - va_start(ap, zFormat); - assert( p->p.base.zErrMsg==0 ); - p->p.base.zErrMsg = sqlite3_vmprintf(zFormat, ap); - va_end(ap); -} - /* ** This function is called to handle an FTS INSERT command. In other words, ** an INSERT statement of the form: @@ -2496,7 +2504,10 @@ static void fts5ApiCallback( sqlite3_result_error(context, zErr, -1); sqlite3_free(zErr); }else{ + sqlite3_vtab *pTab = pCsr->base.pVtab; fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]); + sqlite3_free(pTab->zErrMsg); + pTab->zErrMsg = 0; } } diff --git a/ext/fts5/test/fts5content.test b/ext/fts5/test/fts5content.test index 5d5d8f9191..05b5cc6113 100644 --- a/ext/fts5/test/fts5content.test +++ b/ext/fts5/test/fts5content.test @@ -328,4 +328,41 @@ do_execsql_test 8.3.2 { INSERT INTO t1(t1) VALUES('rebuild') } do_execsql_test 8.3.3 { SELECT * FROM t1 WHERE rowid=1 } {one} do_execsql_test 8.3.4 { SELECT rowid FROM t1('two') } {2} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 9.1 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + INSERT INTO t1 VALUES(1, 'one two three'); + INSERT INTO t1 VALUES(2, 'one two three'); + + CREATE VIRTUAL TABLE ft USING fts5(b, content=t1, content_rowid=a); + INSERT INTO ft(ft) VALUES('rebuild'); +} + +do_execsql_test 9.2 { + SELECT rowid, b FROM ft('two'); +} { + 1 {one two three} + 2 {one two three} +} + +do_execsql_test 9.3 { + DELETE FROM t1 WHERE a=2; +} + +do_catchsql_test 9.4 { + SELECT rowid FROM ft('two'); +} {0 {1 2}} + +do_catchsql_test 9.5 { + SELECT * FROM ft('two'); +} {1 {fts5: missing row 2 from content table 'main'.'t1'}} + +fts5_aux_test_functions db + +do_catchsql_test 9.6 { + SELECT rowid, fts5_columntext(ft, 0) FROM ft('two'); +} {1 SQLITE_CORRUPT_VTAB} + finish_test + diff --git a/ext/fts5/test/fts5corrupt.test b/ext/fts5/test/fts5corrupt.test index 1c7a1a6d0b..ae07383b23 100644 --- a/ext/fts5/test/fts5corrupt.test +++ b/ext/fts5/test/fts5corrupt.test @@ -99,6 +99,6 @@ sqlite3_db_config db DEFENSIVE 0 do_catchsql_test 3.1 { DELETE FROM t3_content WHERE rowid = 3; SELECT * FROM t3 WHERE t3 MATCH 'o'; -} {1 {database disk image is malformed}} +} {1 {fts5: missing row 3 from content table 'main'.'t3_content'}} finish_test diff --git a/ext/fts5/test/fts5corrupt3.test b/ext/fts5/test/fts5corrupt3.test index b76a9b794e..e2a91e51ef 100644 --- a/ext/fts5/test/fts5corrupt3.test +++ b/ext/fts5/test/fts5corrupt3.test @@ -4267,7 +4267,7 @@ do_test 35.0 { do_catchsql_test 35.1 { SELECT * FROM t1 WHERE t1 MATCH 'e*'; -} {1 {database disk image is malformed}} +} {1 {fts5: missing row 14 from content table 'main'.'t1_content'}} #------------------------------------------------------------------------- reset_db diff --git a/manifest b/manifest index 92ab769f65..c40d0dcd37 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sa\smini\sBloom\sfilter\sto\shelp\sreduce\sthe\snumber\sof\spointless\ssearches\sfor\nprior\sSubrtnSig\sobjects\swhen\sgenerating\scode\sfor\sIN\soperators\swith\ssubqueries\nas\stheir\sright\soperand. -D 2024-07-05T13:55:59.179 +C Improve\sthe\serror\smessage\sreturned\swhen\sfts5\sfinds\sa\srow\sis\smissing\sfrom\sits\scontent\stable. +D 2024-07-08T16:01:49.563 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 -F ext/fts5/fts5_main.c 1d8bd88240f4ece62645c93df2a09162607e3b3d33838107bb711e8ad1f7cf14 +F ext/fts5/fts5_main.c 77fefb37e7931095a5ff271a28fbe4f73ec46d5492ef1f35d405d98e137ad8ed F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -139,15 +139,15 @@ F ext/fts5/test/fts5columnsize.test 0af91d63985afdf663455d4b572b935238380140d740 F ext/fts5/test/fts5config.test 017daf10d2642496e97402baa0134de8b5b46b9c37e53c229cd9ab711d21522c F ext/fts5/test/fts5conflict.test bf6030a77dbb1bedfcc42e589ed7980846c995765d77460551e448b56d741244 F ext/fts5/test/fts5connect.test 08030168fc96fc278fa81f28654fb7e90566f33aff269c073e19b3ae9126b2f4 -F ext/fts5/test/fts5content.test 84aa36c6c8b6cebc2b7be3a1e502e2b85c27c58b98614d7cc0fe9d3acf402601 +F ext/fts5/test/fts5content.test d5c0c2142e64cb305f0968de70c01f8e59dbc3ecc56520c22e739e5dd99ea3bb F ext/fts5/test/fts5contentless.test b107465f8cd27dde6313b9c60b61d7158a7753b9c663c5c553695f826bb3c0a5 F ext/fts5/test/fts5contentless2.test 70ffe6c611d8f278240da56734df8a77948f04e2739b358439e9bdcf56ced35f F ext/fts5/test/fts5contentless3.test 75eaae5ad6b284ee447788943974d323228f27cc35a1681da997135cff95bc6a F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b05ea89964c863833b6eff8 F ext/fts5/test/fts5contentless5.test ceb53fcd635f726458fdee2e4482a37966e6b328fe94521ed02d04048f02dac5 -F ext/fts5/test/fts5corrupt.test 6d2143d2a30b2bd2795223f0c941457ae194b8f09fa490e0205ec670a68dea64 +F ext/fts5/test/fts5corrupt.test a9bda1ded5112ebf1ee85c5381bd1fe8974952e2523cede4d5072804d2011503 F ext/fts5/test/fts5corrupt2.test a524eaa861aebecb33db919f065c8d2212f4871217446db3e5e79c1c4b49c798 -F ext/fts5/test/fts5corrupt3.test 12df0beb4b3e270d40dff3237b73e2dd2e9577404e1eca3f0847015ebe4f03ae +F ext/fts5/test/fts5corrupt3.test 3cbb18b8970c66ed4d741eb3eecf42c986bd4c430572a5050350a72030de66cf F ext/fts5/test/fts5corrupt4.test dc08d19f5b8943e95a7778a7d8da592042504faf18dd93f68f7d7a0d7d7dd733 F ext/fts5/test/fts5corrupt5.test 11b47126f5772cc37b67e3e8b2ed05895c4d07c05338bc07e4eea225bfe32c76 F ext/fts5/test/fts5corrupt6.test 2d72db743db7b5d9c9a6d0cfef24d799ed1aa5e8192b66c40e871a37ed9eed06 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c9a3498113074bbcd9a8c8d30286fef6c6a49ad2c84b90ec0f5a148389d6245c -R 048647da7489fe3c22ba97fe98be7560 -U drh -Z a8545f3061897f51fd0152659e811cae +P d8cedbe055b40a0ea4e5d47845b535162e9fcb0d0f88c03211797ab64d2d56fb +R 94dba3784e751a9ba9bcb5baa59e9879 +U dan +Z a1c389616ef05340b174d47447289b9e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e68869204e..00d333fbd1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d8cedbe055b40a0ea4e5d47845b535162e9fcb0d0f88c03211797ab64d2d56fb +9b1afd4acb8cf9738154e921dcb074d895bbcc4742bf1016ef9f045a0da78bc8 From 68d700cac6a99535655e3afd82a5f935dd123588 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 Jul 2024 17:39:52 +0000 Subject: [PATCH 0526/1030] Fix a use-after-free that could occur following an OOM introduced by [d8cedbe0]. FossilOrigin-Name: 4fabfacfcf38e129949d3e4e2c3ffde3da3cd40d9d12c97ca29bc7c3604db6ed --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c40d0dcd37..255ba7ac07 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sthe\serror\smessage\sreturned\swhen\sfts5\sfinds\sa\srow\sis\smissing\sfrom\sits\scontent\stable. -D 2024-07-08T16:01:49.563 +C Fix\sa\suse-after-free\sthat\scould\soccur\sfollowing\san\sOOM\sintroduced\sby\s[d8cedbe0]. +D 2024-07-08T17:39:52.184 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c e8e5c5b2e2bf3d3d4b575c71e8fdd19caed20712afef6ad9fde735f9a210e08d +F src/expr.c 1119a2cbb1ade3ee249c7eb18916174385219a7e4f0f5ad26d22fed6607903b0 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d8cedbe055b40a0ea4e5d47845b535162e9fcb0d0f88c03211797ab64d2d56fb -R 94dba3784e751a9ba9bcb5baa59e9879 +P 9b1afd4acb8cf9738154e921dcb074d895bbcc4742bf1016ef9f045a0da78bc8 +R 572ce10240355ed2f88bbf920eee8899 U dan -Z a1c389616ef05340b174d47447289b9e +Z de9768796b5b05d843e990250379b518 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 00d333fbd1..101aa9fe3a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b1afd4acb8cf9738154e921dcb074d895bbcc4742bf1016ef9f045a0da78bc8 +4fabfacfcf38e129949d3e4e2c3ffde3da3cd40d9d12c97ca29bc7c3604db6ed diff --git a/src/expr.c b/src/expr.c index e7df61c869..b9310fb396 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3563,8 +3563,8 @@ void sqlite3CodeRhsOfIN( pSig->iAddr = pExpr->y.sub.iAddr; pSig->regReturn = pExpr->y.sub.regReturn; pSig->iTable = iTab; - sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG); pParse->mSubrtnSig = 1 << (pSig->selId&7); + sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG); } addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); } From 64ef4582c2018dac671282c3432c72a998549d24 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 10 Jul 2024 08:33:52 +0000 Subject: [PATCH 0527/1030] Rename some JS files for consistency. This affects only the build process, not the deliverables. FossilOrigin-Name: bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 --- ext/wasm/GNUmakefile | 16 +++++++-------- ...3-api-glue.js => sqlite3-api-glue.c-pp.js} | 0 ...te3-api-oo1.js => sqlite3-api-oo1.c-pp.js} | 0 ...worker1.js => sqlite3-api-worker1.c-pp.js} | 0 manifest | 20 +++++++++---------- manifest.uuid | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) rename ext/wasm/api/{sqlite3-api-glue.js => sqlite3-api-glue.c-pp.js} (100%) rename ext/wasm/api/{sqlite3-api-oo1.js => sqlite3-api-oo1.c-pp.js} (100%) rename ext/wasm/api/{sqlite3-api-worker1.js => sqlite3-api-worker1.c-pp.js} (100%) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index d9508e8d7a..63d04e28e9 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -441,21 +441,21 @@ sqlite3-api.jses += $(dir.api)/sqlite3-api-prologue.js # Emscripten glue: sqlite3-api.jses += $(dir.common)/whwasmutil.js sqlite3-api.jses += $(dir.jacc)/jaccwabyt.js -# sqlite3-api-glue.js Glues the previous part together: -sqlite3-api.jses += $(dir.api)/sqlite3-api-glue.js +# sqlite3-api-glue Glues the previous part together with sqlite: +sqlite3-api.jses += $(dir.api)/sqlite3-api-glue.c-pp.js # $(sqlite3-api-build-version.js) = library version info sqlite3-api.jses += $(sqlite3-api-build-version.js) -# sqlite3-api-oo1.js = the oo1 API: -sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.js -# sqlite3-api-worker.js = the Worker1 API: -sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.js +# sqlite3-api-oo1 = the oo1 API: +sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js +# sqlite3-api-worker = the Worker1 API: +sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js # sqlite3-vfs-helper = helper APIs for VFSes: sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js # sqlite3-vtab-helper = helper APIs for VTABLEs: sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js -# sqlite3-vfs-opfs.c-pp.js = the first OPFS VFS: +# sqlite3-vfs-opfs = the first OPFS VFS: sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js -# sqlite3-vfs-opfs-sahpool.c-pp.js = the second OPFS VFS: +# sqlite3-vfs-opfs-sahpool = the second OPFS VFS: sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js # sqlite3-api-cleanup.js = "finalizes" the build and cleans up # any extraneous global symbols which are needed temporarily diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js similarity index 100% rename from ext/wasm/api/sqlite3-api-glue.js rename to ext/wasm/api/sqlite3-api-glue.c-pp.js diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.c-pp.js similarity index 100% rename from ext/wasm/api/sqlite3-api-oo1.js rename to ext/wasm/api/sqlite3-api-oo1.c-pp.js diff --git a/ext/wasm/api/sqlite3-api-worker1.js b/ext/wasm/api/sqlite3-api-worker1.c-pp.js similarity index 100% rename from ext/wasm/api/sqlite3-api-worker1.js rename to ext/wasm/api/sqlite3-api-worker1.c-pp.js diff --git a/manifest b/manifest index 255ba7ac07..199166eacb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\suse-after-free\sthat\scould\soccur\sfollowing\san\sOOM\sintroduced\sby\s[d8cedbe0]. -D 2024-07-08T17:39:52.184 +C Rename\ssome\sJS\sfiles\sfor\sconsistency.\sThis\saffects\sonly\sthe\sbuild\sprocess,\snot\sthe\sdeliverables. +D 2024-07-10T08:33:52.381 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -593,7 +593,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 05727be716879b1345892ce8c61dd093aefe26ccc48ad9467f3864b85475993b +F ext/wasm/GNUmakefile 6128465c4790ee345ab50d8ec37277d9dc714e5b5814a49f47286ba7d6231a32 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -611,10 +611,10 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d -F ext/wasm/api/sqlite3-api-oo1.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e +F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d w ext/wasm/api/sqlite3-api-glue.js +F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e w ext/wasm/api/sqlite3-api-oo1.js F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 -F ext/wasm/api/sqlite3-api-worker1.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d +F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d w ext/wasm/api/sqlite3-api-worker1.js F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9b1afd4acb8cf9738154e921dcb074d895bbcc4742bf1016ef9f045a0da78bc8 -R 572ce10240355ed2f88bbf920eee8899 -U dan -Z de9768796b5b05d843e990250379b518 +P 4fabfacfcf38e129949d3e4e2c3ffde3da3cd40d9d12c97ca29bc7c3604db6ed +R 17978dd3bf223faafed22d410cc29d02 +U stephan +Z 142ed91ad13db298a1bd21c7dac4cd24 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 101aa9fe3a..325f829c8b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4fabfacfcf38e129949d3e4e2c3ffde3da3cd40d9d12c97ca29bc7c3604db6ed +bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 From 9958c51a5d9b151aab4b5e6c1dd18188e94e99b6 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jul 2024 11:04:17 +0000 Subject: [PATCH 0528/1030] Add an option to force the opfs-sahpool VFS init to re-run after it fails on a first attempt, as a workaround for flaky environments where initial access to OPFS sync access handles is rejected but then permitted on a second attempt. Reported and discussed in [https://github.com/sqlite/sqlite-wasm/issues/79|issue #79 of the npm distribution]. FossilOrigin-Name: 5286e0f654d91a4ebee51fcabaab696e17ff07bb18990b401a31bd3d1213e695 --- ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js | 45 +++++++++++++------ ext/wasm/tester1.c-pp.js | 24 +++++++--- manifest | 23 +++++----- manifest.uuid | 2 +- 4 files changed, 64 insertions(+), 30 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 3f4182dacc..199ac7d617 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -102,7 +102,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ clearOnInit: false, /* Logging verbosity 3+ == everything, 2 == warnings+errors, 1 == errors only. */ - verbosity: 2 + verbosity: 2, + forceReinitIfFailed: false }); /** Logging routines, from most to least serious. */ @@ -1004,9 +1005,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return true; }; - /** Only for testing a rejection case. */ - let instanceCounter = 0; - /** installOpfsSAHPoolVfs() asynchronously initializes the OPFS SyncAccessHandle (a.k.a. SAH) Pool VFS. It returns a Promise which @@ -1081,12 +1079,26 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ the default directory. If no directory is explicitly provided then a directory name is synthesized from the `name` option. - Peculiarities of this VFS: + + - `forceReinitIfFailed`: (default=`false`) Is a fallback option + to assist in working around certain flaky environments which may + mysteriously fail to permit access to OPFS sync access handles on + an initial attempt but permit it on a second attemp. This option + should never be used but is provided for those who choose to + throw caution to the wind and trust such environments. If this + option is truthy _and_ the previous attempt to initialize this + VFS with the same `name` failed, the VFS will attempt to + initialize a second time instead of returning the cached + failure. See discussion at: + + + + Peculiarities of this VFS vis a vis other SQLite VFSes: - Paths given to it _must_ be absolute. Relative paths will not be properly recognized. This is arguably a bug but correcting it requires some hoop-jumping in routines which have no business - doing tricks. + doing such tricks. - It is possible to install multiple instances under different names, each sandboxed from one another inside their own private @@ -1207,13 +1219,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ handles are currently in use, e.g. by an sqlite3 db. */ sqlite3.installOpfsSAHPoolVfs = async function(options=Object.create(null)){ - const vfsName = options.name || optionDefaults.name; - if(0 && 2===++instanceCounter){ - throw new Error("Just testing rejection."); + options = Object.assign(Object.create(null), optionDefaults, (options||{})); + const vfsName = options.name; + if(options.$testThrowPhase1){ + throw options.$testThrowPhase1; } if(initPromises[vfsName]){ - //console.warn("Returning same OpfsSAHPool result",options,vfsName,initPromises[vfsName]); - return initPromises[vfsName]; + const p = initPromises[vfsName]; + if( (p instanceof OpfsSAHPool) || !options.forceReinitIfFailed ){ + //log("Returning cached installOpfsSAHPoolVfs() result",options,vfsName,initPromises[vfsName]); + return p; + } + delete initPromises[vfsName]; + /* Fall through and try again. */ } if(!globalThis.FileSystemHandle || !globalThis.FileSystemDirectoryHandle || @@ -1238,8 +1256,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ensues. */ return initPromises[vfsName] = apiVersionCheck().then(async function(){ - if(options.$testThrowInInit){ - throw options.$testThrowInInit; + if(options.$testThrowPhase2){ + throw options.$testThrowPhase2; } const thePool = new OpfsSAHPool(options); return thePool.isReady.then(async()=>{ @@ -1255,7 +1273,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ oo1.DB.dbCtorHelper.call(this, opt); }; OpfsSAHPoolDb.prototype = Object.create(oo1.DB.prototype); - // yes or no? OpfsSAHPoolDb.PoolUtil = poolUtil; poolUtil.OpfsSAHPoolDb = OpfsSAHPoolDb; oo1.DB.dbCtorHelper.setVfsPostOpenSql( theVfs.pointer, diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index fe5bdc8372..b1e05a24f6 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2824,7 +2824,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; name: 'Session API sanity checks', predicate: ()=>!!capi.sqlite3changegroup_add, test: function(sqlite3){ - warn("The session API tests could use some expansion."); + //warn("The session API tests could use some expansion."); const db1 = new sqlite3.oo1.DB(), db2 = new sqlite3.oo1.DB(); const sqlInit = [ "create table t(rowid INTEGER PRIMARY KEY,a,b); ", @@ -2859,7 +2859,9 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert('b4' === db1.selectValue('select b from t where rowid=4')) .assert(3 === db1.selectValue('select count(*) from t')); - const testSessionEnable = false; + const testSessionEnable = + false /* it's not yet clear whether these test failures are + broken tests or broken bindings. */; if(testSessionEnable){ rc = capi.sqlite3session_enable(pSession, 0); T.assert( 0 === rc ) @@ -2870,7 +2872,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert( capi.sqlite3session_enable(pSession, -1) > 0 ) .assert(undefined === db1.selectValue('select a from t where rowid=2')); }else{ - warn("sqlite3session_enable() tests are currently disabled."); + //warn("sqlite3session_enable() tests are currently disabled."); } let db1Count = db1.selectValue("select count(*) from t"); T.assert( db1Count === (testSessionEnable ? 2 : 3) ); @@ -3177,13 +3179,25 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert(!sqlite3.capi.sqlite3_vfs_find(sahPoolConfig.name)); let cErr, u3; - conf2.$testThrowInInit = new Error("Testing throwing during init."); + conf2.$testThrowPhase2 = new Error("Testing throwing during init."); conf2.name = sahPoolConfig.name+'-err'; const P3 = await inst(conf2).then(u=>u3 = u).catch((e)=>cErr=e); - T.assert(P3 === conf2.$testThrowInInit) + T.assert(P3 === conf2.$testThrowPhase2) .assert(cErr === P3) .assert(undefined === u3) .assert(!sqlite3.capi.sqlite3_vfs_find(conf2.name)); + delete conf2.$testThrowPhase2; + T.assert(cErr === await inst(conf2).catch(e=>e), + "Init result is cached even if it failed"); + + /* Ensure that the forceReinitIfFailed fallback bypasses the VFS init cache... */ + cErr = u3 = undefined; + conf2.forceReinitIfFailed = true; + const P3b = await inst(conf2).then(u=>u3 = u).catch((e)=>cErr=e); + T.assert(undefined === cErr) + .assert(P3b === u3) + .assert(true === await u3.removeVfs()) + .assert(false === await u3.removeVfs()); } }/*OPFS SAH Pool sanity checks*/) diff --git a/manifest b/manifest index 199166eacb..d3cbd7fdcd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\ssome\sJS\sfiles\sfor\sconsistency.\sThis\saffects\sonly\sthe\sbuild\sprocess,\snot\sthe\sdeliverables. -D 2024-07-10T08:33:52.381 +C Add\san\soption\sto\sforce\sthe\sopfs-sahpool\sVFS\sinit\sto\sre-run\safter\sit\sfails\son\sa\sfirst\sattempt,\sas\sa\sworkaround\sfor\sflaky\senvironments\swhere\sinitial\saccess\sto\sOPFS\ssync\saccess\shandles\sis\srejected\sbut\sthen\spermitted\son\sa\ssecond\sattempt.\sReported\sand\sdiscussed\sin\s[https://github.com/sqlite/sqlite-wasm/issues/79|issue\s#79\sof\sthe\snpm\sdistribution]. +D 2024-07-11T11:04:17.881 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -611,14 +611,14 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d w ext/wasm/api/sqlite3-api-glue.js -F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e w ext/wasm/api/sqlite3-api-oo1.js +F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d +F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 -F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d w ext/wasm/api/sqlite3-api-worker1.js +F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js ddfe875d5fe84338fe0e8369c3d48015dd62b5bf706cfbd60ab71da6ac7a5dc9 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 0c3801a8e252944fdbaddbad698534316fde90d3db5eedae156e7774ab127710 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 6d0a9aa44a97b4aadd582e0999ce45a2671b854a12ea3205d1c908da6bd4bdef +F ext/wasm/tester1.c-pp.js e680b03be25fe65abf4e69c63a9037eba0ff0e26f0c322bd6d3e6221883f2ace F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4fabfacfcf38e129949d3e4e2c3ffde3da3cd40d9d12c97ca29bc7c3604db6ed -R 17978dd3bf223faafed22d410cc29d02 +P bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 +R 363618acc9527dfc44058e319871c4df +T *branch * sahpool-reinit-fallback +T *sym-sahpool-reinit-fallback * +T -sym-trunk * Cancelled\sby\sbranch. U stephan -Z 142ed91ad13db298a1bd21c7dac4cd24 +Z a0a1183624d3cfcdd58bad41e9c9ff1e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 325f829c8b..d4b1a32bb7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 +5286e0f654d91a4ebee51fcabaab696e17ff07bb18990b401a31bd3d1213e695 From d3bb31b93152362123243806378edb1af3a5ce5d Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jul 2024 12:36:28 +0000 Subject: [PATCH 0529/1030] Proposed workaround for the "errant op" case in the OPFS VFS, as discussed in [https://github.com/sqlite/sqlite-wasm/issues/12 | issue #12 of the npm distribution]. FossilOrigin-Name: 64f4f3cd878b1a723caa0cd54b21f10fdb27d4e2ecb19fc233cbc8dd9d06f259 --- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 4 +++- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index fc0fb9db96..da556224a6 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -470,7 +470,9 @@ const installOpfsVfs = function callee(options){ Atomics.notify(state.sabOPView, state.opIds.whichOp) /* async thread will take over here */; const t = performance.now(); - Atomics.wait(state.sabOPView, state.opIds.rc, -1) + while('not-equal'!==Atomics.wait(state.sabOPView, state.opIds.rc, -1)){ + /* See discussion at https://github.com/sqlite/sqlite-wasm/issues/12 */ + } /* When this wait() call returns, the async half will have completed the operation and reported its results. */; const rc = Atomics.load(state.sabOPView, state.opIds.rc); diff --git a/manifest b/manifest index 199166eacb..5f957dd3c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\ssome\sJS\sfiles\sfor\sconsistency.\sThis\saffects\sonly\sthe\sbuild\sprocess,\snot\sthe\sdeliverables. -D 2024-07-10T08:33:52.381 +C Proposed\sworkaround\sfor\sthe\s"errant\sop"\scase\sin\sthe\sOPFS\sVFS,\sas\sdiscussed\sin\s[https://github.com/sqlite/sqlite-wasm/issues/12\s|\sissue\s#12\sof\sthe\snpm\sdistribution]. +D 2024-07-11T12:36:28.840 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -611,15 +611,15 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d w ext/wasm/api/sqlite3-api-glue.js -F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e w ext/wasm/api/sqlite3-api-oo1.js +F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d +F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 -F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d w ext/wasm/api/sqlite3-api-worker1.js +F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 0c3801a8e252944fdbaddbad698534316fde90d3db5eedae156e7774ab127710 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 594b977dd78b0f1908acb21c8dcd29484182a243c5c43ecc4ca381a0a957c046 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,8 +2195,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4fabfacfcf38e129949d3e4e2c3ffde3da3cd40d9d12c97ca29bc7c3604db6ed -R 17978dd3bf223faafed22d410cc29d02 +P bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 +R 6ee8d5e65620ff8ee09c10bb2590f6a1 +T *branch * opfs-errant-op +T *sym-opfs-errant-op * +T -sym-trunk * Cancelled\sby\sbranch. U stephan -Z 142ed91ad13db298a1bd21c7dac4cd24 +Z d907f5fbcee0cc87b9f95edf029b0756 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 325f829c8b..60a129ff46 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 +64f4f3cd878b1a723caa0cd54b21f10fdb27d4e2ecb19fc233cbc8dd9d06f259 From 9b183a234c2adec1bcade207a793867797d8f68f Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jul 2024 12:57:58 +0000 Subject: [PATCH 0530/1030] Add some docs explaining [64f4f3cd878b1a72]. FossilOrigin-Name: 4fdf9a322fccf7d68b03d07a42a526f18f951e2e19228b7d41e01121b667cc86 --- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 18 +++++++++++++++--- manifest | 15 ++++++--------- manifest.uuid | 2 +- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index da556224a6..a5af548faa 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -471,10 +471,22 @@ const installOpfsVfs = function callee(options){ /* async thread will take over here */; const t = performance.now(); while('not-equal'!==Atomics.wait(state.sabOPView, state.opIds.rc, -1)){ - /* See discussion at https://github.com/sqlite/sqlite-wasm/issues/12 */ + /* + The reason for this loop is burried in the details of + a long discussion at: + + https://github.com/sqlite/sqlite-wasm/issues/12 + + Summary: in at least one browser flavor, under high loads, + this wait() call can, on rare occasion, end up returning + 'ok', which indicates that it's returning _without_ the + other half of the proxy having called Atomics.notify(). When + this happens, we just wait() again. + */ } - /* When this wait() call returns, the async half will have - completed the operation and reported its results. */; + /* When the above wait() call returns 'not-equal', the async + half will have completed the operation and reported its results + in the state.opIds.rc slot of the SAB. */ const rc = Atomics.load(state.sabOPView, state.opIds.rc); metrics[op].wait += performance.now() - t; if(rc && state.asyncS11nExceptions){ diff --git a/manifest b/manifest index 5f957dd3c4..bc736fbdec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Proposed\sworkaround\sfor\sthe\s"errant\sop"\scase\sin\sthe\sOPFS\sVFS,\sas\sdiscussed\sin\s[https://github.com/sqlite/sqlite-wasm/issues/12\s|\sissue\s#12\sof\sthe\snpm\sdistribution]. -D 2024-07-11T12:36:28.840 +C Add\ssome\sdocs\sexplaining\s[64f4f3cd878b1a72]. +D 2024-07-11T12:57:58.720 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -619,7 +619,7 @@ F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d299 F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 594b977dd78b0f1908acb21c8dcd29484182a243c5c43ecc4ca381a0a957c046 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 1d0a2d9d9c8b1eb0126e1abd00ef26a9be9d348786d7e415556ecc345832eabe F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 -R 6ee8d5e65620ff8ee09c10bb2590f6a1 -T *branch * opfs-errant-op -T *sym-opfs-errant-op * -T -sym-trunk * Cancelled\sby\sbranch. +P 64f4f3cd878b1a723caa0cd54b21f10fdb27d4e2ecb19fc233cbc8dd9d06f259 +R 14a1d62c6182eceaa22bb6feac58e8ac U stephan -Z d907f5fbcee0cc87b9f95edf029b0756 +Z d0a56f821b38fd7e590974af97a06665 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 60a129ff46..df72f89949 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -64f4f3cd878b1a723caa0cd54b21f10fdb27d4e2ecb19fc233cbc8dd9d06f259 +4fdf9a322fccf7d68b03d07a42a526f18f951e2e19228b7d41e01121b667cc86 From 20ff50ad10145b5c6843c0a4da48138db3413260 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jul 2024 14:07:46 +0000 Subject: [PATCH 0531/1030] Remove the timing and counter metrics from the OPFS VFS, as they're long-since unused so are just wasted CPU cycles. FossilOrigin-Name: 67c035c34fb916e66bfe115a132660771e8fa2921e6d46756975c5df3ebcd73c --- ext/wasm/api/sqlite3-opfs-async-proxy.js | 133 +---------------------- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 2 +- manifest | 14 +-- manifest.uuid | 2 +- 4 files changed, 10 insertions(+), 141 deletions(-) diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index a2c052d32a..ca5583971e 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -87,35 +87,6 @@ const installAsyncProxy = function(){ const log = (...args)=>logImpl(2, ...args); const warn = (...args)=>logImpl(1, ...args); const error = (...args)=>logImpl(0, ...args); - const metrics = Object.create(null); - metrics.reset = ()=>{ - let k; - const r = (m)=>(m.count = m.time = m.wait = 0); - for(k in state.opIds){ - r(metrics[k] = Object.create(null)); - } - let s = metrics.s11n = Object.create(null); - s = s.serialize = Object.create(null); - s.count = s.time = 0; - s = metrics.s11n.deserialize = Object.create(null); - s.count = s.time = 0; - }; - metrics.dump = ()=>{ - let k, n = 0, t = 0, w = 0; - for(k in state.opIds){ - const m = metrics[k]; - n += m.count; - t += m.time; - w += m.wait; - m.avgTime = (m.count && m.time) ? (m.time / m.count) : 0; - } - console.log(globalThis?.location?.href, - "metrics for",globalThis?.location?.href,":\n", - metrics, - "\nTotal of",n,"op(s) for",t,"ms", - "approx",w,"ms spent waiting on OPFS APIs."); - console.log("Serialization metrics:",metrics.s11n); - }; /** __openFiles is a map of sqlite3_file pointers (integers) to @@ -372,37 +343,6 @@ const installAsyncProxy = function(){ if(fh.readOnly) toss(opName+"(): File is read-only: "+fh.filenameAbs); }; - /** - We track 2 different timers: the "metrics" timer records how much - time we spend performing work. The "wait" timer records how much - time we spend waiting on the underlying OPFS timer. See the calls - to mTimeStart(), mTimeEnd(), wTimeStart(), and wTimeEnd() - throughout this file to see how they're used. - */ - const __mTimer = Object.create(null); - __mTimer.op = undefined; - __mTimer.start = undefined; - const mTimeStart = (op)=>{ - __mTimer.start = performance.now(); - __mTimer.op = op; - //metrics[op] || toss("Maintenance required: missing metrics for",op); - ++metrics[op].count; - }; - const mTimeEnd = ()=>( - metrics[__mTimer.op].time += performance.now() - __mTimer.start - ); - const __wTimer = Object.create(null); - __wTimer.op = undefined; - __wTimer.start = undefined; - const wTimeStart = (op)=>{ - __wTimer.start = performance.now(); - __wTimer.op = op; - //metrics[op] || toss("Maintenance required: missing metrics for",op); - }; - const wTimeEnd = ()=>( - metrics[__wTimer.op].wait += performance.now() - __wTimer.start - ); - /** Gets set to true by the 'opfs-async-shutdown' command to quit the wait loop. This is only intended for debugging purposes: we cannot @@ -413,37 +353,24 @@ const installAsyncProxy = function(){ /** Asynchronous wrappers for sqlite3_vfs and sqlite3_io_methods - methods, as well as helpers like mkdir(). Maintenance reminder: - members are in alphabetical order to simplify finding them. + methods, as well as helpers like mkdir(). */ const vfsAsyncImpls = { - 'opfs-async-metrics': async ()=>{ - mTimeStart('opfs-async-metrics'); - metrics.dump(); - storeAndNotify('opfs-async-metrics', 0); - mTimeEnd(); - }, 'opfs-async-shutdown': async ()=>{ flagAsyncShutdown = true; storeAndNotify('opfs-async-shutdown', 0); }, mkdir: async (dirname)=>{ - mTimeStart('mkdir'); let rc = 0; - wTimeStart('mkdir'); try { await getDirForFilename(dirname+"/filepart", true); }catch(e){ state.s11n.storeException(2,e); rc = state.sq3Codes.SQLITE_IOERR; - }finally{ - wTimeEnd(); } storeAndNotify('mkdir', rc); - mTimeEnd(); }, xAccess: async (filename)=>{ - mTimeStart('xAccess'); /* OPFS cannot support the full range of xAccess() queries sqlite3 calls for. We can essentially just tell if the file is accessible, but if it is then it's automatically writable @@ -456,26 +383,20 @@ const installAsyncProxy = function(){ accessible, non-0 means not accessible. */ let rc = 0; - wTimeStart('xAccess'); try{ const [dh, fn] = await getDirForFilename(filename); await dh.getFileHandle(fn); }catch(e){ state.s11n.storeException(2,e); rc = state.sq3Codes.SQLITE_IOERR; - }finally{ - wTimeEnd(); } storeAndNotify('xAccess', rc); - mTimeEnd(); }, xClose: async function(fid/*sqlite3_file pointer*/){ const opName = 'xClose'; - mTimeStart(opName); __implicitLocks.delete(fid); const fh = __openFiles[fid]; let rc = 0; - wTimeStart(opName); if(fh){ delete __openFiles[fid]; await closeSyncHandle(fh); @@ -487,15 +408,11 @@ const installAsyncProxy = function(){ state.s11n.serialize(); rc = state.sq3Codes.SQLITE_NOTFOUND; } - wTimeEnd(); storeAndNotify(opName, rc); - mTimeEnd(); }, xDelete: async function(...args){ - mTimeStart('xDelete'); const rc = await vfsAsyncImpls.xDeleteNoWait(...args); storeAndNotify('xDelete', rc); - mTimeEnd(); }, xDeleteNoWait: async function(filename, syncDir = 0, recursive = false){ /* The syncDir flag is, for purposes of the VFS API's semantics, @@ -511,7 +428,6 @@ const installAsyncProxy = function(){ is false. */ let rc = 0; - wTimeStart('xDelete'); try { while(filename){ const [hDir, filenamePart] = await getDirForFilename(filename, false); @@ -527,14 +443,11 @@ const installAsyncProxy = function(){ state.s11n.storeException(2,e); rc = state.sq3Codes.SQLITE_IOERR_DELETE; } - wTimeEnd(); return rc; }, xFileSize: async function(fid/*sqlite3_file pointer*/){ - mTimeStart('xFileSize'); const fh = __openFiles[fid]; let rc = 0; - wTimeStart('xFileSize'); try{ const sz = await (await getSyncHandle(fh,'xFileSize')).getSize(); state.s11n.serialize(Number(sz)); @@ -543,19 +456,15 @@ const installAsyncProxy = function(){ rc = GetSyncHandleError.convertRc(e,state.sq3Codes.SQLITE_IOERR); } await releaseImplicitLock(fh); - wTimeEnd(); storeAndNotify('xFileSize', rc); - mTimeEnd(); }, xLock: async function(fid/*sqlite3_file pointer*/, lockType/*SQLITE_LOCK_...*/){ - mTimeStart('xLock'); const fh = __openFiles[fid]; let rc = 0; const oldLockType = fh.xLock; fh.xLock = lockType; if( !fh.syncHandle ){ - wTimeStart('xLock'); try { await getSyncHandle(fh,'xLock'); __implicitLocks.delete(fid); @@ -564,18 +473,14 @@ const installAsyncProxy = function(){ rc = GetSyncHandleError.convertRc(e,state.sq3Codes.SQLITE_IOERR_LOCK); fh.xLock = oldLockType; } - wTimeEnd(); } storeAndNotify('xLock',rc); - mTimeEnd(); }, xOpen: async function(fid/*sqlite3_file pointer*/, filename, flags/*SQLITE_OPEN_...*/, opfsFlags/*OPFS_...*/){ const opName = 'xOpen'; - mTimeStart(opName); const create = (state.sq3Codes.SQLITE_OPEN_CREATE & flags); - wTimeStart('xOpen'); try{ let hDir, filenamePart; try { @@ -583,8 +488,6 @@ const installAsyncProxy = function(){ }catch(e){ state.s11n.storeException(1,e); storeAndNotify(opName, state.sq3Codes.SQLITE_NOTFOUND); - mTimeEnd(); - wTimeEnd(); return; } if( state.opfsFlags.OPFS_UNLINK_BEFORE_OPEN & opfsFlags ){ @@ -596,7 +499,6 @@ const installAsyncProxy = function(){ } } const hFile = await hDir.getFileHandle(filenamePart, {create}); - wTimeEnd(); const fh = Object.assign(Object.create(null),{ fid: fid, filenameAbs: filename, @@ -614,60 +516,47 @@ const installAsyncProxy = function(){ __openFiles[fid] = fh; storeAndNotify(opName, 0); }catch(e){ - wTimeEnd(); error(opName,e); state.s11n.storeException(1,e); storeAndNotify(opName, state.sq3Codes.SQLITE_IOERR); } - mTimeEnd(); }, xRead: async function(fid/*sqlite3_file pointer*/,n,offset64){ - mTimeStart('xRead'); let rc = 0, nRead; const fh = __openFiles[fid]; try{ - wTimeStart('xRead'); nRead = (await getSyncHandle(fh,'xRead')).read( fh.sabView.subarray(0, n), {at: Number(offset64)} ); - wTimeEnd(); if(nRead < n){/* Zero-fill remaining bytes */ fh.sabView.fill(0, nRead, n); rc = state.sq3Codes.SQLITE_IOERR_SHORT_READ; } }catch(e){ - if(undefined===nRead) wTimeEnd(); error("xRead() failed",e,fh); state.s11n.storeException(1,e); rc = GetSyncHandleError.convertRc(e,state.sq3Codes.SQLITE_IOERR_READ); } await releaseImplicitLock(fh); storeAndNotify('xRead',rc); - mTimeEnd(); }, xSync: async function(fid/*sqlite3_file pointer*/,flags/*ignored*/){ - mTimeStart('xSync'); const fh = __openFiles[fid]; let rc = 0; if(!fh.readOnly && fh.syncHandle){ try { - wTimeStart('xSync'); await fh.syncHandle.flush(); }catch(e){ state.s11n.storeException(2,e); rc = state.sq3Codes.SQLITE_IOERR_FSYNC; } - wTimeEnd(); } storeAndNotify('xSync',rc); - mTimeEnd(); }, xTruncate: async function(fid/*sqlite3_file pointer*/,size){ - mTimeStart('xTruncate'); let rc = 0; const fh = __openFiles[fid]; - wTimeStart('xTruncate'); try{ affirmNotRO('xTruncate', fh); await (await getSyncHandle(fh,'xTruncate')).truncate(size); @@ -677,35 +566,27 @@ const installAsyncProxy = function(){ rc = GetSyncHandleError.convertRc(e,state.sq3Codes.SQLITE_IOERR_TRUNCATE); } await releaseImplicitLock(fh); - wTimeEnd(); storeAndNotify('xTruncate',rc); - mTimeEnd(); }, xUnlock: async function(fid/*sqlite3_file pointer*/, lockType/*SQLITE_LOCK_...*/){ - mTimeStart('xUnlock'); let rc = 0; const fh = __openFiles[fid]; if( fh.syncHandle && state.sq3Codes.SQLITE_LOCK_NONE===lockType /* Note that we do not differentiate between lock types in this VFS. We're either locked or unlocked. */ ){ - wTimeStart('xUnlock'); try { await closeSyncHandle(fh) } catch(e){ state.s11n.storeException(1,e); rc = state.sq3Codes.SQLITE_IOERR_UNLOCK; } - wTimeEnd(); } storeAndNotify('xUnlock',rc); - mTimeEnd(); }, xWrite: async function(fid/*sqlite3_file pointer*/,n,offset64){ - mTimeStart('xWrite'); let rc; const fh = __openFiles[fid]; - wTimeStart('xWrite'); try{ affirmNotRO('xWrite', fh); rc = ( @@ -719,9 +600,7 @@ const installAsyncProxy = function(){ rc = GetSyncHandleError.convertRc(e,state.sq3Codes.SQLITE_IOERR_WRITE); } await releaseImplicitLock(fh); - wTimeEnd(); storeAndNotify('xWrite',rc); - mTimeEnd(); } }/*vfsAsyncImpls*/; @@ -755,8 +634,6 @@ const installAsyncProxy = function(){ } }; state.s11n.deserialize = function(clear=false){ - ++metrics.s11n.deserialize.count; - const t = performance.now(); const argc = viewU8[0]; const rc = argc ? [] : null; if(argc){ @@ -781,12 +658,9 @@ const installAsyncProxy = function(){ } if(clear) viewU8[0] = 0; //log("deserialize:",argc, rc); - metrics.s11n.deserialize.time += performance.now() - t; return rc; }; state.s11n.serialize = function(...args){ - const t = performance.now(); - ++metrics.s11n.serialize.count; if(args.length){ //log("serialize():",args); const typeIds = []; @@ -817,7 +691,6 @@ const installAsyncProxy = function(){ }else{ viewU8[0] = 0; } - metrics.s11n.serialize.time += performance.now() - t; }; state.s11n.storeException = state.asyncS11nExceptions @@ -899,7 +772,6 @@ const installAsyncProxy = function(){ } }); initS11n(); - metrics.reset(); log("init state",state); wPost('opfs-async-inited'); waitLoop(); @@ -912,9 +784,6 @@ const installAsyncProxy = function(){ waitLoop(); } break; - case 'opfs-async-metrics': - metrics.dump(); - break; } }; wPost('opfs-async-loaded'); diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index a5af548faa..59a07aac78 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -443,7 +443,7 @@ const installOpfsVfs = function callee(options){ OPFS_UNLINK_BEFORE_OPEN: 0x02, /** If true, any async routine which implicitly acquires a sync - access handle (i.e. an OPFS lock) will release that locks at + access handle (i.e. an OPFS lock) will release that lock at the end of the call which acquires it. If false, such "autolocks" are not released until the VFS is idle for some brief amount of time. diff --git a/manifest b/manifest index bc736fbdec..59dcb4695b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssome\sdocs\sexplaining\s[64f4f3cd878b1a72]. -D 2024-07-11T12:57:58.720 +C Remove\sthe\stiming\sand\scounter\smetrics\sfrom\sthe\sOPFS\sVFS,\sas\sthey're\slong-since\sunused\sso\sare\sjust\swasted\sCPU\scycles. +D 2024-07-11T14:07:46.554 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -616,10 +616,10 @@ F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda62 F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 -F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a +F ext/wasm/api/sqlite3-opfs-async-proxy.js e8f1df56e97a29004a95a2eddd26778f52c33b3e797d32d4b1b668a38e6493dd F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 1d0a2d9d9c8b1eb0126e1abd00ef26a9be9d348786d7e415556ecc345832eabe +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 258a0d7c2a952ee360c13d7e4551b11d3f4fbe6dec1df6162866eca4d54e8443 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 64f4f3cd878b1a723caa0cd54b21f10fdb27d4e2ecb19fc233cbc8dd9d06f259 -R 14a1d62c6182eceaa22bb6feac58e8ac +P 4fdf9a322fccf7d68b03d07a42a526f18f951e2e19228b7d41e01121b667cc86 +R 5866522ad6fbcc120fd61fe54902049d U stephan -Z d0a56f821b38fd7e590974af97a06665 +Z c3a08dde48aa22cdaaa7d36ef45af62c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index df72f89949..71fc5f25a6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4fdf9a322fccf7d68b03d07a42a526f18f951e2e19228b7d41e01121b667cc86 +67c035c34fb916e66bfe115a132660771e8fa2921e6d46756975c5df3ebcd73c From 8ee747dda55887775417e13882ffed29868a0865 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 11 Jul 2024 19:50:17 +0000 Subject: [PATCH 0532/1030] Reformulate the forceReinitIfFailed handling based on feedback, to correct the type-checking and resolve a potential race condition. FossilOrigin-Name: c4f468309158f9b951137461213fb269d96d15c331256cf392a56c9bed231460 --- ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js | 16 +++++++++++----- ext/wasm/tester1.c-pp.js | 4 +++- manifest | 17 +++++++---------- manifest.uuid | 2 +- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 199ac7d617..2a0471e250 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -1225,13 +1225,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ throw options.$testThrowPhase1; } if(initPromises[vfsName]){ - const p = initPromises[vfsName]; - if( (p instanceof OpfsSAHPool) || !options.forceReinitIfFailed ){ - //log("Returning cached installOpfsSAHPoolVfs() result",options,vfsName,initPromises[vfsName]); + try { + const p = await initPromises[vfsName]; + //log("installOpfsSAHPoolVfs() returning cached result",options,vfsName,p); return p; + }catch(e){ + //log("installOpfsSAHPoolVfs() got cached failure",options,vfsName,e); + if( options.forceReinitIfFailed ){ + delete initPromises[vfsName]; + /* Fall through and try again. */ + }else{ + throw e; + } } - delete initPromises[vfsName]; - /* Fall through and try again. */ } if(!globalThis.FileSystemHandle || !globalThis.FileSystemDirectoryHandle || diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index b1e05a24f6..5d24daf152 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3193,11 +3193,13 @@ globalThis.sqlite3InitModule = sqlite3InitModule; /* Ensure that the forceReinitIfFailed fallback bypasses the VFS init cache... */ cErr = u3 = undefined; conf2.forceReinitIfFailed = true; + conf2.verbosity = 3; const P3b = await inst(conf2).then(u=>u3 = u).catch((e)=>cErr=e); T.assert(undefined === cErr) .assert(P3b === u3) + .assert(P3b === await inst(conf2)) .assert(true === await u3.removeVfs()) - .assert(false === await u3.removeVfs()); + .assert(false === await P3b.removeVfs()); } }/*OPFS SAH Pool sanity checks*/) diff --git a/manifest b/manifest index d3cbd7fdcd..d8e33f5d15 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\soption\sto\sforce\sthe\sopfs-sahpool\sVFS\sinit\sto\sre-run\safter\sit\sfails\son\sa\sfirst\sattempt,\sas\sa\sworkaround\sfor\sflaky\senvironments\swhere\sinitial\saccess\sto\sOPFS\ssync\saccess\shandles\sis\srejected\sbut\sthen\spermitted\son\sa\ssecond\sattempt.\sReported\sand\sdiscussed\sin\s[https://github.com/sqlite/sqlite-wasm/issues/79|issue\s#79\sof\sthe\snpm\sdistribution]. -D 2024-07-11T11:04:17.881 +C Reformulate\sthe\sforceReinitIfFailed\shandling\sbased\son\sfeedback,\sto\scorrect\sthe\stype-checking\sand\sresolve\sa\spotential\srace\scondition. +D 2024-07-11T19:50:17.794 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -618,7 +618,7 @@ F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d2 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js ddfe875d5fe84338fe0e8369c3d48015dd62b5bf706cfbd60ab71da6ac7a5dc9 +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e7b8c70c9a239eee2b571b5cd60e2a1d677312b83ad7e6395629c2954d0f26d3 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 0c3801a8e252944fdbaddbad698534316fde90d3db5eedae156e7774ab127710 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js e680b03be25fe65abf4e69c63a9037eba0ff0e26f0c322bd6d3e6221883f2ace +F ext/wasm/tester1.c-pp.js e231a9ae8b5ad6c3697339178e2e801edfb13cedcbd4a1e98bc5915646cc357d F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 -R 363618acc9527dfc44058e319871c4df -T *branch * sahpool-reinit-fallback -T *sym-sahpool-reinit-fallback * -T -sym-trunk * Cancelled\sby\sbranch. +P 5286e0f654d91a4ebee51fcabaab696e17ff07bb18990b401a31bd3d1213e695 +R 1edb9efa72844191061bd673c33c8081 U stephan -Z a0a1183624d3cfcdd58bad41e9c9ff1e +Z fea5c63c4f659006bc6ce3b8cbda987f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d4b1a32bb7..92f03b4a19 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5286e0f654d91a4ebee51fcabaab696e17ff07bb18990b401a31bd3d1213e695 +c4f468309158f9b951137461213fb269d96d15c331256cf392a56c9bed231460 From 74d5faec938ed149de77ce5de1e20d608806af93 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 12 Jul 2024 13:45:15 +0000 Subject: [PATCH 0533/1030] sqldiff: if the first db argument does not exist, fail instead of creating an empty db. Resolving that for the second argument is trickier, as discussed in [forum:ec2d429e32 | forum post ec2d429e32]. FossilOrigin-Name: 0547ccf776c6054732437bffb8b2fe2ed5194ef817c2593f8cec4a3e2b749720 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- tool/sqldiff.c | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 199166eacb..5dd10b3bf3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\ssome\sJS\sfiles\sfor\sconsistency.\sThis\saffects\sonly\sthe\sbuild\sprocess,\snot\sthe\sdeliverables. -D 2024-07-10T08:33:52.381 +C sqldiff:\sif\sthe\sfirst\sdb\sargument\sdoes\snot\sexist,\sfail\sinstead\sof\screating\san\sempty\sdb.\sResolving\sthat\sfor\sthe\ssecond\sargument\sis\strickier,\sas\sdiscussed\sin\s[forum:ec2d429e32\s|\sforum\spost\sec2d429e32]. +D 2024-07-12T13:45:15.768 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -611,10 +611,10 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d w ext/wasm/api/sqlite3-api-glue.js -F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e w ext/wasm/api/sqlite3-api-oo1.js +F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d +F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 -F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d w ext/wasm/api/sqlite3-api-worker1.js +F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d @@ -2156,7 +2156,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 -F tool/sqldiff.c 1e0a2c264c2ad5aca745d35deee3c7715cb00c703839cfb0b85be079db55194c +F tool/sqldiff.c 7cba849010303618a37c62ec918ff34bd033a4e921eedf60b9f6a0fcd0f95441 F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4fabfacfcf38e129949d3e4e2c3ffde3da3cd40d9d12c97ca29bc7c3604db6ed -R 17978dd3bf223faafed22d410cc29d02 +P bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 +R 9d7013b8e4d60155076223efca13a01e U stephan -Z 142ed91ad13db298a1bd21c7dac4cd24 +Z 4529059c7c801563043334f808abcdd3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 325f829c8b..1776aed301 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bcef3f71a2f68768819d9f716f2c29e752fb173df1506469c8669d95ecc2ff50 +0547ccf776c6054732437bffb8b2fe2ed5194ef817c2593f8cec4a3e2b749720 diff --git a/tool/sqldiff.c b/tool/sqldiff.c index a213a67041..96d3b6eab7 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -31,7 +31,7 @@ ** correctly on Windows: ** ** fprintf() -> Wfprintf() -** +** */ #if defined(_WIN32) # include "console_io.h" @@ -65,7 +65,7 @@ struct GlobalVars { static void strFree(sqlite3_str *pStr){ sqlite3_free(sqlite3_str_finish(pStr)); } - + /* ** Print an error resulting from faulting command-line arguments and ** abort the program. @@ -1998,7 +1998,7 @@ int main(int argc, char **argv){ if( g.bSchemaOnly && g.bSchemaCompare ){ cmdlineError("The --schema option is useless with --table %s .", zTab); } - rc = sqlite3_open(zDb1, &g.db); + rc = sqlite3_open_v2(zDb1, &g.db, SQLITE_OPEN_READONLY, 0); if( rc ){ cmdlineError("cannot open database file \"%s\"", zDb1); } From 2e32cbc4a589fb80a0423e4d7917eb7e56db3ca7 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 12 Jul 2024 14:41:16 +0000 Subject: [PATCH 0534/1030] sqldiff: fail if the 2nd db argument cannot be opened read-only. FossilOrigin-Name: e8b33525fc2b4d609a7be9acc43fbc66638effaa7b092b48568ded6c53c4f4db --- manifest | 13 ++++++------- manifest.uuid | 2 +- tool/sqldiff.c | 7 +++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index bc92c6df7c..3b0e6c0226 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Work\saround\sa\sdifficult-to-trigger\sAtomics\sAPI\smessage-passing\squirk\sin\sthe\sOPFS\sVFS\swhich\sappears\sin\srare\sinstances\sin\ssome\sbrowsers\swhen\srunning\shigh\sI/O\sloads.\sThis\sresolves\s[https://github.com/sqlite/sqlite-wasm/issues/12\s|\sissue\s#12\sof\sthe\snpm\sdistribution]. -D 2024-07-12T13:49:54.280 +C sqldiff:\sfail\sif\sthe\s2nd\sdb\sargument\scannot\sbe\sopened\sread-only. +D 2024-07-12T14:41:16.904 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2156,7 +2156,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 -F tool/sqldiff.c 7cba849010303618a37c62ec918ff34bd033a4e921eedf60b9f6a0fcd0f95441 +F tool/sqldiff.c 847fc8fcfddf5ce4797b7394cad6372f2f5dc17d8186e2ef8fb44d50fae4f44a F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 @@ -2195,9 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0547ccf776c6054732437bffb8b2fe2ed5194ef817c2593f8cec4a3e2b749720 67c035c34fb916e66bfe115a132660771e8fa2921e6d46756975c5df3ebcd73c -R 179c3e545823f2d4971c80b2ae104e8e -T +closed 67c035c34fb916e66bfe115a132660771e8fa2921e6d46756975c5df3ebcd73c Closed\sby\sintegrate-merge. +P af41a1e6fc8b36e9bf65a5bb0154e1ce7eb99903cb5a3e4779322527c29d8780 +R cd90730c86cb7f967c489fb04ff854ed U stephan -Z 23b39834751894d8f222eb1e85ba81f7 +Z 00ecf88c93499ce80acd271f6ea6acd0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 59ad5dc72a..c881672595 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -af41a1e6fc8b36e9bf65a5bb0154e1ce7eb99903cb5a3e4779322527c29d8780 +e8b33525fc2b4d609a7be9acc43fbc66638effaa7b092b48568ded6c53c4f4db diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 96d3b6eab7..8b2293cafd 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -2006,6 +2006,13 @@ int main(int argc, char **argv){ if( rc || zErrMsg ){ cmdlineError("\"%s\" does not appear to be a valid SQLite database", zDb1); } + { + sqlite3 *db2 = 0; + if( sqlite3_open_v2(zDb2, &db2, SQLITE_OPEN_READONLY, 0) ){ + cmdlineError("cannot open database file \"%s\"", zDb2); + } + sqlite3_close(db2); + } #ifndef SQLITE_OMIT_LOAD_EXTENSION sqlite3_enable_load_extension(g.db, 1); for(i=0; i Date: Sat, 13 Jul 2024 00:55:55 +0000 Subject: [PATCH 0535/1030] Rename the new opfs-sahpool init-retry flag to the suitably descriptive, and suitably onerous, forceReinitIfPreviouslyFailed, based on feedback. FossilOrigin-Name: c9f0a6090258534a3d81066df5610229183a8457fc60d5034b4b94d9a29796e4 --- ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js | 6 +++--- ext/wasm/tester1.c-pp.js | 5 +++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 2a0471e250..86ba3add8e 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -103,7 +103,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ /* Logging verbosity 3+ == everything, 2 == warnings+errors, 1 == errors only. */ verbosity: 2, - forceReinitIfFailed: false + forceReinitIfPreviouslyFailed: false }); /** Logging routines, from most to least serious. */ @@ -1080,7 +1080,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ then a directory name is synthesized from the `name` option. - - `forceReinitIfFailed`: (default=`false`) Is a fallback option + - `forceReinitIfPreviouslyFailed`: (default=`false`) Is a fallback option to assist in working around certain flaky environments which may mysteriously fail to permit access to OPFS sync access handles on an initial attempt but permit it on a second attemp. This option @@ -1231,7 +1231,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return p; }catch(e){ //log("installOpfsSAHPoolVfs() got cached failure",options,vfsName,e); - if( options.forceReinitIfFailed ){ + if( options.forceReinitIfPreviouslyFailed ){ delete initPromises[vfsName]; /* Fall through and try again. */ }else{ diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 5d24daf152..1fcc9ae7c2 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3190,9 +3190,10 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.assert(cErr === await inst(conf2).catch(e=>e), "Init result is cached even if it failed"); - /* Ensure that the forceReinitIfFailed fallback bypasses the VFS init cache... */ + /* Ensure that the forceReinitIfPreviouslyFailed fallback bypasses + the VFS init cache... */ cErr = u3 = undefined; - conf2.forceReinitIfFailed = true; + conf2.forceReinitIfPreviouslyFailed = true; conf2.verbosity = 3; const P3b = await inst(conf2).then(u=>u3 = u).catch((e)=>cErr=e); T.assert(undefined === cErr) diff --git a/manifest b/manifest index d8e33f5d15..e062403efa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reformulate\sthe\sforceReinitIfFailed\shandling\sbased\son\sfeedback,\sto\scorrect\sthe\stype-checking\sand\sresolve\sa\spotential\srace\scondition. -D 2024-07-11T19:50:17.794 +C Rename\sthe\snew\sopfs-sahpool\sinit-retry\sflag\sto\sthe\ssuitably\sdescriptive,\sand\ssuitably\sonerous,\sforceReinitIfPreviouslyFailed,\sbased\son\sfeedback. +D 2024-07-13T00:55:55.226 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -618,7 +618,7 @@ F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d2 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e7b8c70c9a239eee2b571b5cd60e2a1d677312b83ad7e6395629c2954d0f26d3 +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8c59ff35224adbe926b85d0c6debedc63c3c949d4cee761b3a74867b56155341 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 0c3801a8e252944fdbaddbad698534316fde90d3db5eedae156e7774ab127710 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js e231a9ae8b5ad6c3697339178e2e801edfb13cedcbd4a1e98bc5915646cc357d +F ext/wasm/tester1.c-pp.js 74ade5f0d61db790b4e403f6bf7c0d346e19ec876cdee109c22ae4214aa89f4e F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5286e0f654d91a4ebee51fcabaab696e17ff07bb18990b401a31bd3d1213e695 -R 1edb9efa72844191061bd673c33c8081 +P c4f468309158f9b951137461213fb269d96d15c331256cf392a56c9bed231460 +R 6ea3913d20dc04cfbb6567303894df42 U stephan -Z fea5c63c4f659006bc6ce3b8cbda987f +Z dab1e381b46a819e9c939e93f18cc9e7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 92f03b4a19..dc7e05ee3b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c4f468309158f9b951137461213fb269d96d15c331256cf392a56c9bed231460 +c9f0a6090258534a3d81066df5610229183a8457fc60d5034b4b94d9a29796e4 From db8939f481acdebce5f9b54a86ffb1153f463012 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 13 Jul 2024 01:40:36 +0000 Subject: [PATCH 0536/1030] Add several convenience links to the OPFS VFS concurrency tester app for launching it with various combinations of options. FossilOrigin-Name: 397d6a18f173a46b60a867fc45611045c76316d6602a3df8b4dc4ba45e1348ce --- ext/wasm/tests/opfs/concurrency/index.html | 3 +++ ext/wasm/tests/opfs/concurrency/test.js | 25 ++++++++++++++++++++++ manifest | 15 ++++++------- manifest.uuid | 2 +- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/ext/wasm/tests/opfs/concurrency/index.html b/ext/wasm/tests/opfs/concurrency/index.html index 595ab24529..54ed04a4f6 100644 --- a/ext/wasm/tests/opfs/concurrency/index.html +++ b/ext/wasm/tests/opfs/concurrency/index.html @@ -35,6 +35,9 @@

    re-opening the tab usually resolves it, but sometimes restarting the browser is required.

    +

    + Links for various testing options:

    +

    diff --git a/ext/wasm/tests/opfs/concurrency/test.js b/ext/wasm/tests/opfs/concurrency/test.js index 14cd6f514f..1848901afe 100644 --- a/ext/wasm/tests/opfs/concurrency/test.js +++ b/ext/wasm/tests/opfs/concurrency/test.js @@ -113,6 +113,31 @@ } }; + /* Set up links to launch this tool with various combinations of + flags... */ + const eTestLinks = document.querySelector('#testlinks'); + const optArgs = function(obj){ + const li = []; + for(const k of ['interval','iterations','workers','verbose','unlock-asap']){ + if( obj.hasOwnProperty(k) ) li.push(k+'='+obj[k]); + } + return li.join('&'); + }; + for(const opt of [ + {interval: 1000, workers: 5, iterations: 30}, + {interval: 500, workers: 5, iterations: 30}, + {interval: 250, workers: 3, iterations: 30}, + {interval: 600, workers: 5, iterations: 100} + ]){ + const li = document.createElement('li'); + eTestLinks.appendChild(li); + const a = document.createElement('a'); + li.appendChild(a); + const args = optArgs(opt); + a.setAttribute('href', '?'+args); + a.innerText = args; + } + stdout("Launching",options.workerCount,"workers. Options:",options); workers.uri = ( 'worker.js?' diff --git a/manifest b/manifest index 268853ab92..bccbdd21d1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\soption\sto\sthe\sopfs-sahpool\sVFS\swhich\stells\sit\sto\signore\sa\sprevious\sinit\sfailure\sand\sretry,\sas\san\sopt-in\sworkaround\sfor\sa\sbrowser\squirk\swhich\soccasionally\sdenies\sOPFS\saccess\son\sthe\sfirst\sattempt\sand\spermits\sit\son\ssubsequent\sattempts.\sThis\sresolves\s[https://github.com/sqlite/sqlite-wasm/issues/79|issue\s#79\sof\sthe\snpm\sdistribution]. -D 2024-07-13T01:02:57.267 +C Add\sseveral\sconvenience\slinks\sto\sthe\sOPFS\sVFS\sconcurrency\stester\sapp\sfor\slaunching\sit\swith\svarious\scombinations\sof\soptions. +D 2024-07-13T01:40:36.950 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -668,8 +668,8 @@ F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f80 F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 F ext/wasm/tester1.c-pp.js 74ade5f0d61db790b4e403f6bf7c0d346e19ec876cdee109c22ae4214aa89f4e -F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1 -F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d +F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e +F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966f1bc16a F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x @@ -2195,9 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e8b33525fc2b4d609a7be9acc43fbc66638effaa7b092b48568ded6c53c4f4db c9f0a6090258534a3d81066df5610229183a8457fc60d5034b4b94d9a29796e4 -R 674df08c7c71be5b7a456e9edf4c5bff -T +closed c9f0a6090258534a3d81066df5610229183a8457fc60d5034b4b94d9a29796e4 Closed\sby\sintegrate-merge. +P fbf3948a4ba27c6ebf55b24e7463b20026439f04d1974bafe78df5c5bc958f59 +R 17ad9e555acf9a71bf586f6402e9a39a U stephan -Z 46da404de8b55901677e43a878b084be +Z 3c72ba5f810e193ef72ed570a9a2bd8b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 78bb83eb1b..59f1f8b963 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fbf3948a4ba27c6ebf55b24e7463b20026439f04d1974bafe78df5c5bc958f59 +397d6a18f173a46b60a867fc45611045c76316d6602a3df8b4dc4ba45e1348ce From c636e124df6a7746b2004a35c11d12c72704b5c5 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 13 Jul 2024 11:47:44 +0000 Subject: [PATCH 0537/1030] Remove a stray/harmless duplicate wasm function export entry. FossilOrigin-Name: 5402e4fb1cbd7a2c3dee6ebfb492a076d05daa66f747d18602338874405829df --- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api | 1 - manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api index 57cd61eb9d..d4ecf5b9d0 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api @@ -23,7 +23,6 @@ _sqlite3_collation_needed _sqlite3_column_blob _sqlite3_column_bytes _sqlite3_column_count -_sqlite3_column_count _sqlite3_column_double _sqlite3_column_int _sqlite3_column_int64 diff --git a/manifest b/manifest index bccbdd21d1..85747bc284 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sseveral\sconvenience\slinks\sto\sthe\sOPFS\sVFS\sconcurrency\stester\sapp\sfor\slaunching\sit\swith\svarious\scombinations\sof\soptions. -D 2024-07-13T01:40:36.950 +C Remove\sa\sstray/harmless\sduplicate\swasm\sfunction\sexport\sentry. +D 2024-07-13T11:47:44.216 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -601,7 +601,7 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api f442460ed9a109e637dd3ea1caa4489553ad9414e8988118b208bb7a4bbece6b +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 00a1ce656f31b0d168ace7e50faa9d9366793848318077b379c74e91f06b9041 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fbf3948a4ba27c6ebf55b24e7463b20026439f04d1974bafe78df5c5bc958f59 -R 17ad9e555acf9a71bf586f6402e9a39a +P 397d6a18f173a46b60a867fc45611045c76316d6602a3df8b4dc4ba45e1348ce +R 8d1b4d875aa4428b36547df3364516ee U stephan -Z 3c72ba5f810e193ef72ed570a9a2bd8b +Z 977e101f8c18c7f8d4990fad09aea47e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 59f1f8b963..51bb9808e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -397d6a18f173a46b60a867fc45611045c76316d6602a3df8b4dc4ba45e1348ce +5402e4fb1cbd7a2c3dee6ebfb492a076d05daa66f747d18602338874405829df From 6f9b37b35bf31ee3bc9158c9309cf205efab8d90 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 13 Jul 2024 12:50:42 +0000 Subject: [PATCH 0538/1030] Add JS bindings and tests for sqlite3_interrupted(), is_interrupted(), and db_readonly(). FossilOrigin-Name: 5589ba5651d80479ae555429340fc74390ff07d3e05ba770bb7d82490211e00d --- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api | 3 +++ ext/wasm/api/sqlite3-api-glue.c-pp.js | 7 +++---- ext/wasm/tester1.c-pp.js | 20 +++++++++++++++++++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api index d4ecf5b9d0..c2dedfd579 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api @@ -46,6 +46,7 @@ _sqlite3_data_count _sqlite3_db_filename _sqlite3_db_handle _sqlite3_db_name +_sqlite3_db_readonly _sqlite3_db_status _sqlite3_declare_vtab _sqlite3_deserialize @@ -64,6 +65,8 @@ _sqlite3_free _sqlite3_get_auxdata _sqlite3_get_autocommit _sqlite3_initialize +_sqlite3_interrupt +_sqlite3_is_interrupted _sqlite3_keyword_count _sqlite3_keyword_name _sqlite3_keyword_check diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index 83b2ee1721..d3ea8a35a3 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -152,6 +152,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_db_filename", "string", "sqlite3*", "string"], ["sqlite3_db_handle", "sqlite3*", "sqlite3_stmt*"], ["sqlite3_db_name", "string", "sqlite3*", "int"], + ["sqlite3_db_readonly", "int", "sqlite3*", "string"], ["sqlite3_db_status", "int", "sqlite3*", "int", "*", "*", "int"], ["sqlite3_errcode", "int", "sqlite3*"], ["sqlite3_errmsg", "string", "sqlite3*"], @@ -192,10 +193,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_get_autocommit", "int", "sqlite3*"], ["sqlite3_get_auxdata", "*", "sqlite3_context*", "int"], ["sqlite3_initialize", undefined], - /*["sqlite3_interrupt", undefined, "sqlite3*" - ^^^ we cannot actually currently support this because JS is - single-threaded and we don't have a portable way to access a DB - from 2 SharedWorkers concurrently. ],*/ + ["sqlite3_interrupt", undefined, "sqlite3*"], + ["sqlite3_is_interrupted", "int", "sqlite3*"], ["sqlite3_keyword_count", "int"], ["sqlite3_keyword_name", "int", ["int", "**", "*"]], ["sqlite3_keyword_check", "int", ["string", "int"]], diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 1fcc9ae7c2..4ebe8f83aa 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -461,7 +461,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; try{ sqlite3.SQLite3Error.toss("resultCode check") } catch(e){ T.assert(capi.SQLITE_ERROR === e.resultCode) - .assert('resultCode check' === e.message); + .assert('resultCode check' === e.message); } }) //////////////////////////////////////////////////////////////////// @@ -2063,6 +2063,24 @@ globalThis.sqlite3InitModule = sqlite3InitModule; "Because foo is no longer attached."); }) + //////////////////////////////////////////////////////////////////// + .t("Interrupt", function(sqlite3){ + const db = new sqlite3.oo1.DB(); + T.assert( 0===capi.sqlite3_is_interrupted(db) ); + capi.sqlite3_interrupt(db); + T.assert( 0!==capi.sqlite3_is_interrupted(db) ); + db.close(); + }) + + //////////////////////////////////////////////////////////////////// + .t("Read-only", function(sqlite3){ + T.assert( 0===capi.sqlite3_db_readonly(this.db, "main") ); + const db = new sqlite3.oo1.DB('file://'+this.db.filename+'?mode=ro'); + T.assert( 1===capi.sqlite3_db_readonly(db, "main") ); + T.assert( -1===capi.sqlite3_db_readonly(db, "nope") ); + db.close(); + }) + //////////////////////////////////////////////////////////////////// .t({ name: 'C-side WASM tests', diff --git a/manifest b/manifest index 85747bc284..1a78d18fb8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\sstray/harmless\sduplicate\swasm\sfunction\sexport\sentry. -D 2024-07-13T11:47:44.216 +C Add\sJS\sbindings\sand\stests\sfor\ssqlite3_interrupted(),\sis_interrupted(),\sand\sdb_readonly(). +D 2024-07-13T12:50:42.416 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -601,7 +601,7 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 00a1ce656f31b0d168ace7e50faa9d9366793848318077b379c74e91f06b9041 +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 79c97e7d1eae1c5c4ac785a41a59f212299ec1465235e62351bed85f14f7de40 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 @@ -611,7 +611,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d +F ext/wasm/api/sqlite3-api-glue.c-pp.js 76797cabedaed1b18ef8f613b7bd33a67d42ca10584a7173beff1fec311c808d F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 74ade5f0d61db790b4e403f6bf7c0d346e19ec876cdee109c22ae4214aa89f4e +F ext/wasm/tester1.c-pp.js 8c5f84262c6a1b5444cbd572557502042c771ec8ccefc265382f488866896872 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 397d6a18f173a46b60a867fc45611045c76316d6602a3df8b4dc4ba45e1348ce -R 8d1b4d875aa4428b36547df3364516ee +P 5402e4fb1cbd7a2c3dee6ebfb492a076d05daa66f747d18602338874405829df +R 755e2e812676ba0fd928fedbc3fc5e9e U stephan -Z 977e101f8c18c7f8d4990fad09aea47e +Z 8d9b29289853fb56a82fa2045fc5a771 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 51bb9808e8..0862d9bc28 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5402e4fb1cbd7a2c3dee6ebfb492a076d05daa66f747d18602338874405829df +5589ba5651d80479ae555429340fc74390ff07d3e05ba770bb7d82490211e00d From 0b9efaffd7eaf7881196b9d443670809f949be60 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 13 Jul 2024 13:22:32 +0000 Subject: [PATCH 0539/1030] Add missing sqlite3_bind_parameter_name() binding to JS. FossilOrigin-Name: 6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0 --- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api | 1 + ext/wasm/api/sqlite3-api-glue.c-pp.js | 1 + ext/wasm/api/sqlite3-api-oo1.c-pp.js | 13 ++++++++ ext/wasm/tester1.c-pp.js | 37 ++++++++++++++++----- manifest | 18 +++++----- manifest.uuid | 2 +- 6 files changed, 53 insertions(+), 19 deletions(-) diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api index c2dedfd579..dc6211ccb5 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api @@ -10,6 +10,7 @@ _sqlite3_bind_int64 _sqlite3_bind_null _sqlite3_bind_parameter_count _sqlite3_bind_parameter_index +_sqlite3_bind_parameter_name _sqlite3_bind_pointer _sqlite3_bind_text _sqlite3_busy_handler diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index d3ea8a35a3..2c40f2100d 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -95,6 +95,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_bind_null",undefined, "sqlite3_stmt*", "int"], ["sqlite3_bind_parameter_count", "int", "sqlite3_stmt*"], ["sqlite3_bind_parameter_index","int", "sqlite3_stmt*", "string"], + ["sqlite3_bind_parameter_name", "string", "sqlite3_stmt*", "int"], ["sqlite3_bind_pointer", "int", "sqlite3_stmt*", "int", "*", "string:static", "*"], ["sqlite3_busy_handler","int", [ diff --git a/ext/wasm/api/sqlite3-api-oo1.c-pp.js b/ext/wasm/api/sqlite3-api-oo1.c-pp.js index e557cbd578..0b9bbbbca8 100644 --- a/ext/wasm/api/sqlite3-api-oo1.c-pp.js +++ b/ext/wasm/api/sqlite3-api-oo1.c-pp.js @@ -2030,6 +2030,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return (affirmStmtOpen(this).parameterCount ? capi.sqlite3_bind_parameter_index(this.pointer, name) : undefined); + }, + /** + If this statement has named bindable parameters and the given + index refers to one, its name is returned, else null is + returned. If this statement has no bound parameters, undefined + is returned. + + Added in 3.47. + */ + getParamName: function(ndx){ + return (affirmStmtOpen(this).parameterCount + ? capi.sqlite3_bind_parameter_name(this.pointer, ndx) + : undefined); } }/*Stmt.prototype*/; diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 4ebe8f83aa..a6befb54eb 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2063,15 +2063,6 @@ globalThis.sqlite3InitModule = sqlite3InitModule; "Because foo is no longer attached."); }) - //////////////////////////////////////////////////////////////////// - .t("Interrupt", function(sqlite3){ - const db = new sqlite3.oo1.DB(); - T.assert( 0===capi.sqlite3_is_interrupted(db) ); - capi.sqlite3_interrupt(db); - T.assert( 0!==capi.sqlite3_is_interrupted(db) ); - db.close(); - }) - //////////////////////////////////////////////////////////////////// .t("Read-only", function(sqlite3){ T.assert( 0===capi.sqlite3_db_readonly(this.db, "main") ); @@ -3222,6 +3213,34 @@ globalThis.sqlite3InitModule = sqlite3InitModule; } }/*OPFS SAH Pool sanity checks*/) + //////////////////////////////////////////////////////////////////////// + T.g('Misc. APIs') + .t('bind_parameter', function(sqlite3){ + const db = new sqlite3.oo1.DB(); + db.exec("create table t(a)"); + const stmt = db.prepare("insert into t(a) values($a)"); + T.assert( 1===capi.sqlite3_bind_parameter_count(stmt) ) + .assert( 1===capi.sqlite3_bind_parameter_index(stmt, "$a") ) + .assert( 0===capi.sqlite3_bind_parameter_index(stmt, ":a") ) + .assert( 1===stmt.getParamIndex("$a") ) + .assert( 0===stmt.getParamIndex(":a") ) + .assert( "$a"===capi.sqlite3_bind_parameter_name(stmt, 1) ) + .assert( null===capi.sqlite3_bind_parameter_name(stmt, 0) ) + .assert( "$a"===stmt.getParamName(1) ) + .assert( null===stmt.getParamName(0) ); + stmt.finalize(); + db.close(); + }) + + //////////////////////////////////////////////////////////////////// + .t("interrupt", function(sqlite3){ + const db = new sqlite3.oo1.DB(); + T.assert( 0===capi.sqlite3_is_interrupted(db) ); + capi.sqlite3_interrupt(db); + T.assert( 0!==capi.sqlite3_is_interrupted(db) ); + db.close(); + }) + //////////////////////////////////////////////////////////////////////// T.g('Bug Reports') .t({ diff --git a/manifest b/manifest index 1a78d18fb8..21db2c85cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sJS\sbindings\sand\stests\sfor\ssqlite3_interrupted(),\sis_interrupted(),\sand\sdb_readonly(). -D 2024-07-13T12:50:42.416 +C Add\smissing\ssqlite3_bind_parameter_name()\sbinding\sto\sJS. +D 2024-07-13T13:22:32.806 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -601,7 +601,7 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 79c97e7d1eae1c5c4ac785a41a59f212299ec1465235e62351bed85f14f7de40 +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api f75b562296c43f9027c4959e98b813e7a4eee415d3d2b33649a64d67a1a40b5e F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 @@ -611,8 +611,8 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 76797cabedaed1b18ef8f613b7bd33a67d42ca10584a7173beff1fec311c808d -F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e +F ext/wasm/api/sqlite3-api-glue.c-pp.js 3aca0971febf2cf29e54f379e0c5816b68cbc1fd9a9c3df4450abc537cda94c7 +F ext/wasm/api/sqlite3-api-oo1.c-pp.js 9e11c4338ca400b2a05e5ec7909dd757b8c4d42e48cf57f5b827d040d4a2bb9a F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 8c5f84262c6a1b5444cbd572557502042c771ec8ccefc265382f488866896872 +F ext/wasm/tester1.c-pp.js 24485ade77e62345d0bfddc5f2863c0dad6c1f707e826ecae41f2957ae4e9007 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5402e4fb1cbd7a2c3dee6ebfb492a076d05daa66f747d18602338874405829df -R 755e2e812676ba0fd928fedbc3fc5e9e +P 5589ba5651d80479ae555429340fc74390ff07d3e05ba770bb7d82490211e00d +R 9649259c83d18c7f11703ab2ef66367d U stephan -Z 8d9b29289853fb56a82fa2045fc5a771 +Z 60c9d132eb4de729d4902cab9b5f025e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0862d9bc28..5f9bcedf49 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5589ba5651d80479ae555429340fc74390ff07d3e05ba770bb7d82490211e00d +6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0 From 55a4bea72a63412f9cecb78b208794d00e9e8a83 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 13 Jul 2024 14:07:47 +0000 Subject: [PATCH 0540/1030] Add JS bindings for sqlite3_stmt_busy() and sqlite3_stmt_explain(). FossilOrigin-Name: b772edfb44143107d4993bde600d0f4c45184f29a4deee403105c64748c36523 --- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api | 2 ++ ext/wasm/api/sqlite3-api-glue.c-pp.js | 6 ++-- ext/wasm/api/sqlite3-api-oo1.c-pp.js | 20 ++++++++++++ ext/wasm/tester1.c-pp.js | 34 +++++++++++++++++++-- manifest | 18 +++++------ manifest.uuid | 2 +- 6 files changed, 68 insertions(+), 14 deletions(-) diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api index dc6211ccb5..c8632c4e4f 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api @@ -120,6 +120,8 @@ _sqlite3_sql _sqlite3_status _sqlite3_status64 _sqlite3_step +_sqlite3_stmt_busy +_sqlite3_stmt_explain _sqlite3_stmt_isexplain _sqlite3_stmt_readonly _sqlite3_stmt_status diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index 2c40f2100d..f9e9c96074 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -276,8 +276,10 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_sql", "string", "sqlite3_stmt*"], ["sqlite3_status", "int", "int", "*", "*", "int"], ["sqlite3_step", "int", "sqlite3_stmt*"], - ["sqlite3_stmt_isexplain", "int", ["sqlite3_stmt*"]], - ["sqlite3_stmt_readonly", "int", ["sqlite3_stmt*"]], + ["sqlite3_stmt_busy", "int", "sqlite3_stmt*"], + ["sqlite3_stmt_explain", "int", "sqlite3_stmt*", "int"], + ["sqlite3_stmt_isexplain", "int", "sqlite3_stmt*"], + ["sqlite3_stmt_readonly", "int", "sqlite3_stmt*"], ["sqlite3_stmt_status", "int", "sqlite3_stmt*", "int", "int"], ["sqlite3_strglob", "int", "string","string"], ["sqlite3_stricmp", "int", "string", "string"], diff --git a/ext/wasm/api/sqlite3-api-oo1.c-pp.js b/ext/wasm/api/sqlite3-api-oo1.c-pp.js index 0b9bbbbca8..c07ecfcc26 100644 --- a/ext/wasm/api/sqlite3-api-oo1.c-pp.js +++ b/ext/wasm/api/sqlite3-api-oo1.c-pp.js @@ -2043,6 +2043,26 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return (affirmStmtOpen(this).parameterCount ? capi.sqlite3_bind_parameter_name(this.pointer, ndx) : undefined); + }, + + /** + Behaves like sqlite3_stmt_busy() but throws if this statement + is closed and returns a value of type boolean instead of integer. + + Added in 3.47. + */ + isBusy: function(){ + return 0!==capi.sqlite3_stmt_busy(affirmStmtOpen(this)); + }, + + /** + Behaves like sqlite3_stmt_readonly() but throws if this statement + is closed and returns a value of type boolean instead of integer. + + Added in 3.47. + */ + isReadOnly: function(){ + return 0!==capi.sqlite3_stmt_readonly(affirmStmtOpen(this)); } }/*Stmt.prototype*/; diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index a6befb54eb..68a1ab89c0 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -1475,7 +1475,8 @@ globalThis.sqlite3InitModule = sqlite3InitModule; let st = db.prepare("update t set b=:b where a='blob'"); try { - T.assert(0===st.columnCount); + T.assert(0===st.columnCount) + .assert( false===st.isReadOnly() ); const ndx = st.getParamIndex(':b'); T.assert(1===ndx); st.bindAsBlob(ndx, "ima blob") @@ -3215,7 +3216,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////////// T.g('Misc. APIs') - .t('bind_parameter', function(sqlite3){ + .t('bind_parameter_...', function(sqlite3){ const db = new sqlite3.oo1.DB(); db.exec("create table t(a)"); const stmt = db.prepare("insert into t(a) values($a)"); @@ -3232,6 +3233,35 @@ globalThis.sqlite3InitModule = sqlite3InitModule; db.close(); }) + //////////////////////////////////////////////////////////////////// + .t("Misc. stmt_...", function(sqlite3){ + const db = new sqlite3.oo1.DB(); + db.exec(["create table t(a);","insert into t(a) values(123)"]); + const stmt = db.prepare("select a from t"); + T.assert( stmt.isReadOnly() ) + .assert( 0===capi.sqlite3_stmt_isexplain(stmt) ) + .assert( 0===capi.sqlite3_stmt_explain(stmt, 1) ) + .assert( 0!==capi.sqlite3_stmt_isexplain(stmt) ) + .assert( 0===capi.sqlite3_stmt_explain(stmt, 2) ) + .assert( 0!==capi.sqlite3_stmt_isexplain(stmt) ) + .assert( 0===capi.sqlite3_stmt_explain(stmt, 0) ) + .assert( 0===capi.sqlite3_stmt_isexplain(stmt) ); + while( capi.SQLITE_ROW === capi.sqlite3_step(stmt) ){ + T.assert( 0!==capi.sqlite3_stmt_explain(stmt, 1), + "Because stmt is busy" ) + .assert( capi.sqlite3_stmt_busy(stmt) ) + .assert( stmt.isBusy() ) + .assert( 0!==capi.sqlite3_stmt_readonly(stmt) ) + .assert( true===stmt.isReadOnly() ); + const sv = capi.sqlite3_column_value(stmt, 0); + T.assert( 123===capi.sqlite3_value_int(sv) ); + } + T.assert( 0===capi.sqlite3_stmt_busy(stmt) ) + .assert( !stmt.isBusy() ); + stmt.finalize(); + db.close(); + }) + //////////////////////////////////////////////////////////////////// .t("interrupt", function(sqlite3){ const db = new sqlite3.oo1.DB(); diff --git a/manifest b/manifest index 21db2c85cc..2fcb0e24bb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smissing\ssqlite3_bind_parameter_name()\sbinding\sto\sJS. -D 2024-07-13T13:22:32.806 +C Add\sJS\sbindings\sfor\ssqlite3_stmt_busy()\sand\ssqlite3_stmt_explain(). +D 2024-07-13T14:07:47.157 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -601,7 +601,7 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api f75b562296c43f9027c4959e98b813e7a4eee415d3d2b33649a64d67a1a40b5e +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 31a200d34fcb4eec52f8a1ab4093583ddfe051cbd3bf478dcc2b838accddea0b F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 @@ -611,8 +611,8 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 3aca0971febf2cf29e54f379e0c5816b68cbc1fd9a9c3df4450abc537cda94c7 -F ext/wasm/api/sqlite3-api-oo1.c-pp.js 9e11c4338ca400b2a05e5ec7909dd757b8c4d42e48cf57f5b827d040d4a2bb9a +F ext/wasm/api/sqlite3-api-glue.c-pp.js b16c62712da2451dd978fecd6a552a8617a47daf58c4297a3d35af099b7738fd +F ext/wasm/api/sqlite3-api-oo1.c-pp.js cec37fb3084635bf396a445848fb07361a68ae66dd473057326b22502a2ba67e F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 24485ade77e62345d0bfddc5f2863c0dad6c1f707e826ecae41f2957ae4e9007 +F ext/wasm/tester1.c-pp.js 734d84ce74c8f043f58f4135d92668d0f4e6189e8c68b600127cdec67fd65031 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5589ba5651d80479ae555429340fc74390ff07d3e05ba770bb7d82490211e00d -R 9649259c83d18c7f11703ab2ef66367d +P 6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0 +R 02fee3213cf3b10ca74033e64620f4e9 U stephan -Z 60c9d132eb4de729d4902cab9b5f025e +Z 595eefd86f8667df252210da82cc7b14 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5f9bcedf49..1122aff014 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0 +b772edfb44143107d4993bde600d0f4c45184f29a4deee403105c64748c36523 From 7052c67c36f2963ea06900fe8cd55964753fe8a5 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 13 Jul 2024 15:21:35 +0000 Subject: [PATCH 0541/1030] JS doc touchups. No code changes. FossilOrigin-Name: a8e240495ff7e0cd38301ef2de215a7cc10fea832311bd19ca2592858ee4e6ff --- ext/wasm/api/sqlite3-api-oo1.c-pp.js | 28 +++++++++++++++++----------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-oo1.c-pp.js b/ext/wasm/api/sqlite3-api-oo1.c-pp.js index c07ecfcc26..c579b5ddf7 100644 --- a/ext/wasm/api/sqlite3-api-oo1.c-pp.js +++ b/ext/wasm/api/sqlite3-api-oo1.c-pp.js @@ -482,6 +482,10 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ statement's preparation and when it is stepped may invalidate it. - `parameterCount`: the number of bindable parameters in the query. + + As a general rule, most methods of this class will throw if + called on an instance which has been finalized. For brevity's + sake, the method docs do not all repeat this warning. */ const Stmt = function(){ if(BindTypes!==arguments[2]){ @@ -1686,12 +1690,11 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ integer 0 or 1. It is not expected the distinction of binding doubles which have no fractional parts and integers is significant for the majority of clients due to sqlite3's data - typing model. If [BigInt] support is enabled then this - routine will bind BigInt values as 64-bit integers if they'll - fit in 64 bits. If that support disabled, it will store the - BigInt as an int32 or a double if it can do so without loss - of precision. If the BigInt is _too BigInt_ then it will - throw. + typing model. If BigInt support is enabled then this routine + will bind BigInt values as 64-bit integers if they'll fit in + 64 bits. If that support disabled, it will store the BigInt + as an int32 or a double if it can do so without loss of + precision. If the BigInt is _too BigInt_ then it will throw. - Strings are bound as strings (use bindAsBlob() to force blob binding). @@ -1797,9 +1800,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }, /** Steps the statement one time. If the result indicates that a - row of data is available, a truthy value is returned. - If no row of data is available, a falsy - value is returned. Throws on error. + row of data is available, a truthy value is returned. If no + row of data is available, a falsy value is returned. Throws on + error. */ step: function(){ affirmNotLockedByExec(this, 'step()'); @@ -1819,6 +1822,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Functions exactly like step() except that... 1) On success, it calls this.reset() and returns this object. + 2) On error, it throws and does not call reset(). This is intended to simplify constructs like: @@ -1842,7 +1846,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ throws. On success, it returns true if the step indicated that a row of - data was available, else it returns false. + data was available, else it returns a falsy value. This is intended to simplify use cases such as: @@ -1860,6 +1864,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ catch(e){/*ignored*/} } }, + /** Fetches the value from the given 0-based column index of the current data row, throwing if index is out of range. @@ -1884,7 +1889,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ If ndx is a plain object, this function behaves even differentlier: it assigns the properties of the object to - the values of their corresponding result columns. + the values of their corresponding result columns and returns + that object. Blobs are returned as Uint8Array instances. diff --git a/manifest b/manifest index 2fcb0e24bb..79eb0307ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sJS\sbindings\sfor\ssqlite3_stmt_busy()\sand\ssqlite3_stmt_explain(). -D 2024-07-13T14:07:47.157 +C JS\sdoc\stouchups.\sNo\scode\schanges. +D 2024-07-13T15:21:35.136 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -612,7 +612,7 @@ F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.c-pp.js b16c62712da2451dd978fecd6a552a8617a47daf58c4297a3d35af099b7738fd -F ext/wasm/api/sqlite3-api-oo1.c-pp.js cec37fb3084635bf396a445848fb07361a68ae66dd473057326b22502a2ba67e +F ext/wasm/api/sqlite3-api-oo1.c-pp.js aba93e986b141454af2be42f37dfcfaaa981434a3801af3e48f621b620e43061 F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0 -R 02fee3213cf3b10ca74033e64620f4e9 +P b772edfb44143107d4993bde600d0f4c45184f29a4deee403105c64748c36523 +R ca0529b1c1f8382ec63447f4dfbe9ccc U stephan -Z 595eefd86f8667df252210da82cc7b14 +Z 491715458459b2b75d340b7778b590f0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1122aff014..ceb23b6da2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b772edfb44143107d4993bde600d0f4c45184f29a4deee403105c64748c36523 +a8e240495ff7e0cd38301ef2de215a7cc10fea832311bd19ca2592858ee4e6ff From 441993200ed7131baf5062d2e5bbabc1bf67d923 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 13 Jul 2024 15:42:30 +0000 Subject: [PATCH 0542/1030] Add JS binding for sqlite3_column_decltype(). FossilOrigin-Name: 5252d292b14f6ed99b09f6330b19effd488c2b23ff6ea33311321a065d3f6ce2 --- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api | 1 + ext/wasm/api/sqlite3-api-glue.c-pp.js | 1 + ext/wasm/tester1.c-pp.js | 8 +++++--- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api index c8632c4e4f..42231c8a2a 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api @@ -24,6 +24,7 @@ _sqlite3_collation_needed _sqlite3_column_blob _sqlite3_column_bytes _sqlite3_column_count +_sqlite3_column_decltype _sqlite3_column_double _sqlite3_column_int _sqlite3_column_int64 diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index f9e9c96074..93a8398ab7 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -116,6 +116,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_column_blob","*", "sqlite3_stmt*", "int"], ["sqlite3_column_bytes","int", "sqlite3_stmt*", "int"], ["sqlite3_column_count", "int", "sqlite3_stmt*"], + ["sqlite3_column_decltype", "string", "sqlite3_stmt*", "int"], ["sqlite3_column_double","f64", "sqlite3_stmt*", "int"], ["sqlite3_column_int","int", "sqlite3_stmt*", "int"], ["sqlite3_column_name","string", "sqlite3_stmt*", "int"], diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 68a1ab89c0..c756ffc207 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3236,8 +3236,8 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////// .t("Misc. stmt_...", function(sqlite3){ const db = new sqlite3.oo1.DB(); - db.exec(["create table t(a);","insert into t(a) values(123)"]); - const stmt = db.prepare("select a from t"); + db.exec("create table t(a doggiebiscuits); insert into t(a) values(123)"); + const stmt = db.prepare("select a, a+1 from t"); T.assert( stmt.isReadOnly() ) .assert( 0===capi.sqlite3_stmt_isexplain(stmt) ) .assert( 0===capi.sqlite3_stmt_explain(stmt, 1) ) @@ -3254,7 +3254,9 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert( 0!==capi.sqlite3_stmt_readonly(stmt) ) .assert( true===stmt.isReadOnly() ); const sv = capi.sqlite3_column_value(stmt, 0); - T.assert( 123===capi.sqlite3_value_int(sv) ); + T.assert( 123===capi.sqlite3_value_int(sv) ) + .assert( "doggiebiscuits"===capi.sqlite3_column_decltype(stmt,0) ) + .assert( null===capi.sqlite3_column_decltype(stmt,1) ); } T.assert( 0===capi.sqlite3_stmt_busy(stmt) ) .assert( !stmt.isBusy() ); diff --git a/manifest b/manifest index 79eb0307ac..81d3ed590a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C JS\sdoc\stouchups.\sNo\scode\schanges. -D 2024-07-13T15:21:35.136 +C Add\sJS\sbinding\sfor\ssqlite3_column_decltype(). +D 2024-07-13T15:42:30.730 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -601,7 +601,7 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 31a200d34fcb4eec52f8a1ab4093583ddfe051cbd3bf478dcc2b838accddea0b +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 5265b1f090d232a4402425f5307f389ab51830c02d91c8c2ce6208647f242164 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 @@ -611,7 +611,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js b16c62712da2451dd978fecd6a552a8617a47daf58c4297a3d35af099b7738fd +F ext/wasm/api/sqlite3-api-glue.c-pp.js 21a0f8c1e4b4675b6563759c74bef954ac36aa99acce79c56802b661429f43d0 F ext/wasm/api/sqlite3-api-oo1.c-pp.js aba93e986b141454af2be42f37dfcfaaa981434a3801af3e48f621b620e43061 F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 734d84ce74c8f043f58f4135d92668d0f4e6189e8c68b600127cdec67fd65031 +F ext/wasm/tester1.c-pp.js 0bd834813bc4bdc6e937e3471958f9a785ab1e693dc077e82e3a94a5e1f599b6 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b772edfb44143107d4993bde600d0f4c45184f29a4deee403105c64748c36523 -R ca0529b1c1f8382ec63447f4dfbe9ccc +P a8e240495ff7e0cd38301ef2de215a7cc10fea832311bd19ca2592858ee4e6ff +R c5a5e70a4e892b71184d9fce5f0e5d25 U stephan -Z 491715458459b2b75d340b7778b590f0 +Z 10dd5738496713d89aa3166513a074e0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ceb23b6da2..df09b7bfdf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a8e240495ff7e0cd38301ef2de215a7cc10fea832311bd19ca2592858ee4e6ff +5252d292b14f6ed99b09f6330b19effd488c2b23ff6ea33311321a065d3f6ce2 From 7acf972c5946fb95d510ecc18f46f9a8b5d1cbd5 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 13 Jul 2024 16:53:56 +0000 Subject: [PATCH 0543/1030] Fixes for platforms with 32-bit pointers that require 64-bit values to be aligned. FossilOrigin-Name: 2212d7488ed4ec2839ffa45cb9567056b36519434834634e4ecc441c330694d7 --- ext/fts3/fts3_term.c | 16 ++++++++++++---- ext/fts5/fts5_index.c | 5 +++-- manifest | 25 ++++++++++++++----------- manifest.uuid | 2 +- src/pcache1.c | 4 ++-- src/test_pcache.c | 3 ++- src/vdbe.c | 18 ++++++++++++++---- 7 files changed, 48 insertions(+), 25 deletions(-) diff --git a/ext/fts3/fts3_term.c b/ext/fts3/fts3_term.c index f3a9746a09..655dd9f35a 100644 --- a/ext/fts3/fts3_term.c +++ b/ext/fts3/fts3_term.c @@ -78,6 +78,8 @@ static int fts3termConnectMethod( iIndex = atoi(argv[4]); argc--; } + + *ppVtab = 0; /* The user should specify a single argument - the name of an fts3 table. */ if( argc!=4 ){ @@ -95,12 +97,17 @@ static int fts3termConnectMethod( rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA); if( rc!=SQLITE_OK ) return rc; - nByte = sizeof(Fts3termTable) + sizeof(Fts3Table) + nDb + nFts3 + 2; - p = (Fts3termTable *)sqlite3_malloc64(nByte); + nByte = sizeof(Fts3termTable); + p = (Fts3termTable *)sqlite3Fts3MallocZero(nByte); if( !p ) return SQLITE_NOMEM; - memset(p, 0, (size_t)nByte); - p->pFts3Tab = (Fts3Table *)&p[1]; + p->pFts3Tab = (Fts3Table*)sqlite3Fts3MallocZero( + sizeof(Fts3Table) + nDb + nFts3 + 2 + ); + if( p->pFts3Tab==0 ){ + sqlite3_free(p); + return SQLITE_NOMEM; + } p->pFts3Tab->zDb = (char *)&p->pFts3Tab[1]; p->pFts3Tab->zName = &p->pFts3Tab->zDb[nDb+1]; p->pFts3Tab->db = db; @@ -130,6 +137,7 @@ static int fts3termDisconnectMethod(sqlite3_vtab *pVtab){ sqlite3_finalize(pFts3->aStmt[i]); } sqlite3_free(pFts3->zSegmentsTbl); + sqlite3_free(pFts3); sqlite3_free(p); return SQLITE_OK; } diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 333fefa2d3..5685f14438 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -831,11 +831,12 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){ if( rc==SQLITE_OK ){ u8 *aOut = 0; /* Read blob data into this buffer */ int nByte = sqlite3_blob_bytes(p->pReader); - sqlite3_int64 nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING; + int szData = (sizeof(Fts5Data) + 7) & ~7; + sqlite3_int64 nAlloc = szData + nByte + FTS5_DATA_PADDING; pRet = (Fts5Data*)sqlite3_malloc64(nAlloc); if( pRet ){ pRet->nn = nByte; - aOut = pRet->p = (u8*)&pRet[1]; + aOut = pRet->p = (u8*)pRet + szData; }else{ rc = SQLITE_NOMEM; } diff --git a/manifest b/manifest index 21db2c85cc..b2914f4032 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smissing\ssqlite3_bind_parameter_name()\sbinding\sto\sJS. -D 2024-07-13T13:22:32.806 +C Fixes\sfor\splatforms\swith\s32-bit\spointers\sthat\srequire\s64-bit\svalues\sto\sbe\saligned. +D 2024-07-13T16:53:56.369 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -75,7 +75,7 @@ F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c 305ce7fb6036484085b5556a9c8e62acdc7763f0f4cdf5fd538212a9f3720116 F ext/fts3/fts3_porter.c e19807ce0ae31c1c6e9898e89ecc93183d7ec224ea101af039722a4f49e5f2b8 F ext/fts3/fts3_snippet.c 610328fe128c047c6b0eba77768982ccf3933daae095d497949a75c9dfd47409 -F ext/fts3/fts3_term.c 845f0e2456b1be42f7f1bec1da1dfc05bc347531eff90775ffc6698902c281de +F ext/fts3/fts3_term.c 6a96027ad364001432545fe43322b6af04ed28bb5619ec51af1f59d0710d6d69 F ext/fts3/fts3_test.c d8d7b2734f894e8a489987447658e374cdd3a3bc8575c401decf1911cb7c6454 F ext/fts3/fts3_tokenize_vtab.c 7fd9ef364f257b97218b9c331f2378e307375c592f70fd541f714e747d944962 F ext/fts3/fts3_tokenizer.c 6d8fc150c48238955d5182bf661498db0dd473c8a2a80e00c16994a646fa96e7 @@ -99,7 +99,7 @@ F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70 F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 -F ext/fts5/fts5_index.c ee0f4d50bc0c58a7c5ef7d645e7e38e1e59315b8ea9d722ae00c5f949ee65379 +F ext/fts5/fts5_index.c 7c674d147def32de069f42b0c79b7bd1c8bdbd2b6fdd7607ff7cc5a4278f57dd F ext/fts5/fts5_main.c 77fefb37e7931095a5ff271a28fbe4f73ec46d5492ef1f35d405d98e137ad8ed F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 @@ -747,7 +747,7 @@ F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a F src/parse.y 2bd540b3b1e79017eb41fca2396633a75e7dd430c05383c61fe52c6f4e97c6d8 F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 -F src/pcache1.c 602acb23c471bb8d557a6f0083cc2be641d6cafcafa19e481eba7ef4c9ca0f00 +F src/pcache1.c a5d9c258021fb0ab9a47c4ff9d177cca138e0c0a09ff0384a94954a935c4d11a F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce @@ -798,7 +798,7 @@ F src/test_multiplex.h f0ff5b6f4462bfd46dac165d6375b9530d08089b7bcbe75e88e092611 F src/test_mutex.c cd5bac43f2fd168f43c4326b1febe0966439217fac52afb270a6b8215f94cb40 F src/test_onefile.c f31e52e891c5fef6709b9fcef54ce660648a34172423a9cbdf4cbce3ba0049f4 F src/test_osinst.c 8e11faf10f5d4df10d3450ecee0b8f4cfa2b62e0f341fafbeb480a08cefeaec4 -F src/test_pcache.c 3960cd2c1350adc992c4bf7adcfb0d1ac0574733012bd1a5f94e195928577599 +F src/test_pcache.c 496da3f7e2ca66aefbc36bbf22138b1eff43ba0dff175c228b760fa020a37bd0 F src/test_quota.c ea44c05f29b995bdb71c55eb0c602604884e55681d59b7736e604bbcc68b0464 F src/test_quota.h 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d F src/test_rtree.c 671f3fae50ff116ef2e32a3bf1fe21b5615b4b7b @@ -825,7 +825,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c f941fd8dbd1a9e073866a941e7fbb553f1de2d25b249611005d8c27d5eac8995 +F src/vdbe.c 1de6780bfff80c58cae19b926efd9b8df971eac08aa482497a93a5e61b92e2f7 F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -2195,8 +2195,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5589ba5651d80479ae555429340fc74390ff07d3e05ba770bb7d82490211e00d -R 9649259c83d18c7f11703ab2ef66367d -U stephan -Z 60c9d132eb4de729d4902cab9b5f025e +P 6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0 +R 72be5f41531861618cfe126b36dd6698 +T *branch * alignment-fixes +T *sym-alignment-fixes * +T -sym-trunk * +U dan +Z b9169a304c4bea3372bed518e2910d85 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5f9bcedf49..e88199e310 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0 +2212d7488ed4ec2839ffa45cb9567056b36519434834634e4ecc441c330694d7 diff --git a/src/pcache1.c b/src/pcache1.c index 1591f014c5..a1f8a1dbb4 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -320,7 +320,7 @@ static int pcache1InitBulk(PCache1 *pCache){ do{ PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage]; pX->page.pBuf = zBulk; - pX->page.pExtra = &pX[1]; + pX->page.pExtra = (u8*)pX + ROUND8(sizeof(*pX)); pX->isBulkLocal = 1; pX->isAnchor = 0; pX->pNext = pCache->pFree; @@ -457,7 +457,7 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){ if( pPg==0 ) return 0; p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; p->page.pBuf = pPg; - p->page.pExtra = &p[1]; + p->page.pExtra = (u8*)p + ROUND8(sizeof(*p)); p->isBulkLocal = 0; p->isAnchor = 0; p->pLruPrev = 0; /* Initializing this saves a valgrind error */ diff --git a/src/test_pcache.c b/src/test_pcache.c index 5266d67694..ceefa13e57 100644 --- a/src/test_pcache.c +++ b/src/test_pcache.c @@ -99,7 +99,7 @@ static void testpcacheShutdown(void *pArg){ */ typedef struct testpcache testpcache; struct testpcache { - int szPage; /* Size of each page. Multiple of 8. */ + sqlite3_int64 szPage; /* Size of each page. Multiple of 8. */ int szExtra; /* Size of extra data that accompanies each page */ int bPurgeable; /* True if the page cache is purgeable */ int nFree; /* Number of unused slots in a[] */ @@ -141,6 +141,7 @@ static sqlite3_pcache *testpcacheCreate( int i; assert( testpcacheGlobal.pDummy!=0 ); szPage = (szPage+7)&~7; + szExtra = (szPage+7)&~7; nMem = sizeof(testpcache) + TESTPCACHE_NPAGE*(szPage+szExtra); p = sqlite3_malloc( nMem ); if( p==0 ) return 0; diff --git a/src/vdbe.c b/src/vdbe.c index 4ece26d03e..79368fd06b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -7671,18 +7671,28 @@ case OP_AggInverse: case OP_AggStep: { int n; sqlite3_context *pCtx; + u64 nAlloc; assert( pOp->p4type==P4_FUNCDEF ); n = pOp->p5; assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) ); assert( pOp->p3p2 || pOp->p3>=pOp->p2+n ); - pCtx = sqlite3DbMallocRawNN(db, n*sizeof(sqlite3_value*) + - (sizeof(pCtx[0]) + sizeof(Mem) - sizeof(sqlite3_value*))); + + /* Allocate space for (a) the context object and (n-1) extra pointers + ** to append to the sqlite3_context.argv[1] array, and (b) a memory + ** cell in which to store the accumulation. Be careful that the memory + ** cell is 8-byte aligned, even on platforms where a pointer is 32-bits. + ** + ** Note: We could avoid this by using a regular memory cell from aMem[] for + ** the accumulator, instead of allocating one here. */ + nAlloc = ROUND8P( sizeof(pCtx[0]) + (n-1)*sizeof(sqlite3_value*) ); + pCtx = sqlite3DbMallocRawNN(db, nAlloc + sizeof(Mem)); if( pCtx==0 ) goto no_mem; - pCtx->pMem = 0; - pCtx->pOut = (Mem*)&(pCtx->argv[n]); + pCtx->pOut = (Mem*)((u8*)pCtx + nAlloc); + sqlite3VdbeMemInit(pCtx->pOut, db, MEM_Null); + pCtx->pMem = 0; pCtx->pFunc = pOp->p4.pFunc; pCtx->iOp = (int)(pOp - aOp); pCtx->pVdbe = p; From a0a1fb876fa66297a85c112a8933c321e78e6715 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 13 Jul 2024 18:16:40 +0000 Subject: [PATCH 0544/1030] Improve one of the JS test cases. FossilOrigin-Name: 3767d8bef2dfa661b56c1bfaa4695e32ce26874154e4a322f0d599c257c6fc70 --- ext/wasm/tester1.c-pp.js | 5 ++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index c756ffc207..d99d56fa96 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3246,7 +3246,9 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert( 0!==capi.sqlite3_stmt_isexplain(stmt) ) .assert( 0===capi.sqlite3_stmt_explain(stmt, 0) ) .assert( 0===capi.sqlite3_stmt_isexplain(stmt) ); + let n = 0; while( capi.SQLITE_ROW === capi.sqlite3_step(stmt) ){ + ++n; T.assert( 0!==capi.sqlite3_stmt_explain(stmt, 1), "Because stmt is busy" ) .assert( capi.sqlite3_stmt_busy(stmt) ) @@ -3258,7 +3260,8 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert( "doggiebiscuits"===capi.sqlite3_column_decltype(stmt,0) ) .assert( null===capi.sqlite3_column_decltype(stmt,1) ); } - T.assert( 0===capi.sqlite3_stmt_busy(stmt) ) + T.assert( 1===n ) + .assert( 0===capi.sqlite3_stmt_busy(stmt) ) .assert( !stmt.isBusy() ); stmt.finalize(); db.close(); diff --git a/manifest b/manifest index 81d3ed590a..aa99aff2ab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sJS\sbinding\sfor\ssqlite3_column_decltype(). -D 2024-07-13T15:42:30.730 +C Improve\sone\sof\sthe\sJS\stest\scases. +D 2024-07-13T18:16:40.902 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 0bd834813bc4bdc6e937e3471958f9a785ab1e693dc077e82e3a94a5e1f599b6 +F ext/wasm/tester1.c-pp.js 619964ecb359f5385ed0724f43e0eaee218daceaebc27997a230687dd7333499 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a8e240495ff7e0cd38301ef2de215a7cc10fea832311bd19ca2592858ee4e6ff -R c5a5e70a4e892b71184d9fce5f0e5d25 +P 5252d292b14f6ed99b09f6330b19effd488c2b23ff6ea33311321a065d3f6ce2 +R be27b278ae03e13eb30fe8c9d5be1c4f U stephan -Z 10dd5738496713d89aa3166513a074e0 +Z 81be0686fa504cc9ca1d02ad0cbe7edc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index df09b7bfdf..a1f92c76f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5252d292b14f6ed99b09f6330b19effd488c2b23ff6ea33311321a065d3f6ce2 +3767d8bef2dfa661b56c1bfaa4695e32ce26874154e4a322f0d599c257c6fc70 From 1ffd7ed54ff340039fbc0e809a784789048bdf8c Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 15 Jul 2024 10:11:21 +0000 Subject: [PATCH 0545/1030] Slight doc touchup for [af41a1e6fc8b36e9bf65] based on feedback. No code changes. FossilOrigin-Name: be7b1fc0c5d8cda971b471dfcb4637212bfff4f42b1e074077a381cc493d877a --- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 11 +++++------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index 59a07aac78..ef36b60626 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -472,16 +472,15 @@ const installOpfsVfs = function callee(options){ const t = performance.now(); while('not-equal'!==Atomics.wait(state.sabOPView, state.opIds.rc, -1)){ /* - The reason for this loop is burried in the details of - a long discussion at: + The reason for this loop is buried in the details of a long + discussion at: https://github.com/sqlite/sqlite-wasm/issues/12 Summary: in at least one browser flavor, under high loads, - this wait() call can, on rare occasion, end up returning - 'ok', which indicates that it's returning _without_ the - other half of the proxy having called Atomics.notify(). When - this happens, we just wait() again. + the wait()/notify() pairings can get out of sync. Calling + wait() here until it returns 'not-equal' gets them back in + sync. */ } /* When the above wait() call returns 'not-equal', the async diff --git a/manifest b/manifest index aa99aff2ab..ef67844ed8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sone\sof\sthe\sJS\stest\scases. -D 2024-07-13T18:16:40.902 +C Slight\sdoc\stouchup\sfor\s[af41a1e6fc8b36e9bf65]\sbased\son\sfeedback.\sNo\scode\schanges. +D 2024-07-15T10:11:21.870 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -619,7 +619,7 @@ F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d299 F ext/wasm/api/sqlite3-opfs-async-proxy.js e8f1df56e97a29004a95a2eddd26778f52c33b3e797d32d4b1b668a38e6493dd F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8c59ff35224adbe926b85d0c6debedc63c3c949d4cee761b3a74867b56155341 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 258a0d7c2a952ee360c13d7e4551b11d3f4fbe6dec1df6162866eca4d54e8443 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 5868293eda205e74f2f5d1ada0077a6afca6981c7eba9f147736c31cde165e8b F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5252d292b14f6ed99b09f6330b19effd488c2b23ff6ea33311321a065d3f6ce2 -R be27b278ae03e13eb30fe8c9d5be1c4f +P 3767d8bef2dfa661b56c1bfaa4695e32ce26874154e4a322f0d599c257c6fc70 +R 7c157ce147fdc76c4abe482cc074ceeb U stephan -Z 81be0686fa504cc9ca1d02ad0cbe7edc +Z f1dea9fae27527eb90a0f3185face166 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a1f92c76f9..2f318233eb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3767d8bef2dfa661b56c1bfaa4695e32ce26874154e4a322f0d599c257c6fc70 +be7b1fc0c5d8cda971b471dfcb4637212bfff4f42b1e074077a381cc493d877a From a592883d8713b017fbda7c9866846de99879d091 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Jul 2024 16:27:36 +0000 Subject: [PATCH 0546/1030] Add extra assert() statements to the fixes on this branch. FossilOrigin-Name: 81b6360050eea95e4367de1b41b5864a640b4d1c5c8fc3bea3b96ed770cb0325 --- ext/fts5/fts5Int.h | 16 ++++++++++++++++ ext/fts5/fts5_index.c | 1 + manifest | 27 ++++++++++++--------------- manifest.uuid | 2 +- src/analyze.c | 1 + src/pager.c | 1 + src/pcache.c | 1 + src/pcache1.c | 2 ++ src/vdbe.c | 1 + 9 files changed, 36 insertions(+), 16 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 0ed291c955..4311faceb5 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -59,6 +59,22 @@ typedef sqlite3_uint64 u64; # define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) # define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) +/* The uptr type is an unsigned integer large enough to hold a pointer +*/ +#if defined(HAVE_STDINT_H) + typedef uintptr_t uptr; +#elif SQLITE_PTRSIZE==4 + typedef u32 uptr; +#else + typedef u64 uptr; +#endif + +#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC +# define EIGHT_BYTE_ALIGNMENT(X) ((((uptr)(X) - (uptr)0)&3)==0) +#else +# define EIGHT_BYTE_ALIGNMENT(X) ((((uptr)(X) - (uptr)0)&7)==0) +#endif + #endif /* Truncate very long tokens to this many bytes. Hard limit is diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 5685f14438..1f0a68d3eb 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -859,6 +859,7 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){ } assert( (pRet==0)==(p->rc!=SQLITE_OK) ); + assert( pRet==0 || EIGHT_BYTE_ALIGNMENT( pRet->p ) ); return pRet; } diff --git a/manifest b/manifest index b2914f4032..c16b3fa0d4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sfor\splatforms\swith\s32-bit\spointers\sthat\srequire\s64-bit\svalues\sto\sbe\saligned. -D 2024-07-13T16:53:56.369 +C Add\sextra\sassert()\sstatements\sto\sthe\sfixes\son\sthis\sbranch. +D 2024-07-17T16:27:36.667 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,13 +93,13 @@ F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6d F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h 6b49ce6eb2e395e7fd84557b21d32f5de8041f2fada4c617e481e99427e24b6e -F ext/fts5/fts5Int.h 407ee36addad0ae6df5d37a811f0bd509ab6708b29640884ed5c7509e5f75143 +F ext/fts5/fts5Int.h 41fb3a2dd40e818cc96c6f4176dbdf2aaa8f57043cfc9a8f2676e7e6a72ad764 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 -F ext/fts5/fts5_index.c 7c674d147def32de069f42b0c79b7bd1c8bdbd2b6fdd7607ff7cc5a4278f57dd +F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 77fefb37e7931095a5ff271a28fbe4f73ec46d5492ef1f35d405d98e137ad8ed F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 @@ -688,7 +688,7 @@ F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 F src/alter.c e1b6782b85dd758f89e5c588e4e3eb82638c2dafc0c857b79a43bb8ec1746fca -F src/analyze.c a3df28274e2565ba5656577d7e3fd262169a213e6eb0bd47890e0f0729a4031c +F src/analyze.c 5c4e2bfd0aa8e5157f7fb91a17d86905510a74397326dc5767ec4e0588a4eea5 F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39 F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 @@ -742,12 +742,12 @@ F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d87210 F src/os_unix.c 2ea8d3ed496b8d1f9332a9505653424e5464fd797ea9d91f8e2e62f9dd0298d0 F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56 +F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a F src/parse.y 2bd540b3b1e79017eb41fca2396633a75e7dd430c05383c61fe52c6f4e97c6d8 -F src/pcache.c 040b165f30622a21b7a9a77c6f2e4877a32fb7f22d4c7f0d2a6fa6833a156a75 +F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 -F src/pcache1.c a5d9c258021fb0ab9a47c4ff9d177cca138e0c0a09ff0384a94954a935c4d11a +F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce @@ -825,7 +825,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c 1de6780bfff80c58cae19b926efd9b8df971eac08aa482497a93a5e61b92e2f7 +F src/vdbe.c de13de572eccb688b2b7cf50e2f9005c44bf9ae89e35245ef8eadfc60dfd2764 F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0 -R 72be5f41531861618cfe126b36dd6698 -T *branch * alignment-fixes -T *sym-alignment-fixes * -T -sym-trunk * +P 2212d7488ed4ec2839ffa45cb9567056b36519434834634e4ecc441c330694d7 +R 4685bc0dc8bcecbaad259957ed39b003 U dan -Z b9169a304c4bea3372bed518e2910d85 +Z 08ec31b4265ce331614f6c37f02cc9dd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e88199e310..44074d6865 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2212d7488ed4ec2839ffa45cb9567056b36519434834634e4ecc441c330694d7 +81b6360050eea95e4367de1b41b5864a640b4d1c5c8fc3bea3b96ed770cb0325 diff --git a/src/analyze.c b/src/analyze.c index 8c48a8ff2a..774eeeed26 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1832,6 +1832,7 @@ static int loadStatTbl( return SQLITE_NOMEM_BKPT; } pSpace = (tRowcnt*)&pIdx->aSample[nSample]; + assert( EIGHT_BYTE_ALIGNMENT( pSpace ) ); pIdx->aAvgEq = pSpace; pSpace += nIdxCol; pIdx->pTable->tabFlags |= TF_HasStat4; for(i=0; ipExtra = (void *)&p[1]; + assert( EIGHT_BYTE_ALIGNMENT( p->pExtra ) ); p->flags = PGHDR_MMAP; p->nRef = 1; p->pPager = pPager; diff --git a/src/pcache.c b/src/pcache.c index 2974b0810a..3429284dc9 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -512,6 +512,7 @@ static SQLITE_NOINLINE PgHdr *pcacheFetchFinishWithInit( pPgHdr->pData = pPage->pBuf; pPgHdr->pExtra = (void *)&pPgHdr[1]; memset(pPgHdr->pExtra, 0, 8); + assert( EIGHT_BYTE_ALIGNMENT( pPgHdr->pExtra ) ); pPgHdr->pCache = pCache; pPgHdr->pgno = pgno; pPgHdr->flags = PGHDR_CLEAN; diff --git a/src/pcache1.c b/src/pcache1.c index a1f8a1dbb4..a0a8c7e28c 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -321,6 +321,7 @@ static int pcache1InitBulk(PCache1 *pCache){ PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage]; pX->page.pBuf = zBulk; pX->page.pExtra = (u8*)pX + ROUND8(sizeof(*pX)); + assert( EIGHT_BYTE_ALIGNMENT( pX->page.pExtra ) ); pX->isBulkLocal = 1; pX->isAnchor = 0; pX->pNext = pCache->pFree; @@ -458,6 +459,7 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){ p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; p->page.pBuf = pPg; p->page.pExtra = (u8*)p + ROUND8(sizeof(*p)); + assert( EIGHT_BYTE_ALIGNMENT( p->page.pExtra ) ); p->isBulkLocal = 0; p->isAnchor = 0; p->pLruPrev = 0; /* Initializing this saves a valgrind error */ diff --git a/src/vdbe.c b/src/vdbe.c index 79368fd06b..d097bfd8b9 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -7690,6 +7690,7 @@ case OP_AggStep: { pCtx = sqlite3DbMallocRawNN(db, nAlloc + sizeof(Mem)); if( pCtx==0 ) goto no_mem; pCtx->pOut = (Mem*)((u8*)pCtx + nAlloc); + assert( EIGHT_BYTE_ALIGNMENT(pCtx->pOut) ); sqlite3VdbeMemInit(pCtx->pOut, db, MEM_Null); pCtx->pMem = 0; From d109de8f84637e6900dc65e299d982487a62166d Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 18 Jul 2024 18:44:44 +0000 Subject: [PATCH 0547/1030] Fix a problem in FTS5 where it reports the wrong error code following an OOM. FossilOrigin-Name: 0c1cc4071edcd3e465779bbb17ea3ee6ddaa7c93c4fde55e5f3e07aa4b45783b --- ext/fts5/fts5_storage.c | 2 +- ext/fts5/test/fts5contentless5.test | 1 + manifest | 17 ++++++++--------- manifest.uuid | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index a04b152fb0..0b676e6b4f 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -447,7 +447,7 @@ static int fts5StorageDeleteFromIndex( zText, nText, (void*)&ctx, fts5StorageInsertCallback ); p->aTotalSize[iCol-1] -= (i64)ctx.szCol; - if( p->aTotalSize[iCol-1]<0 ){ + if( p->aTotalSize[iCol-1]<0 && rc==SQLITE_OK ){ rc = FTS5_CORRUPT; } } diff --git a/ext/fts5/test/fts5contentless5.test b/ext/fts5/test/fts5contentless5.test index b08f810a63..3563678868 100644 --- a/ext/fts5/test/fts5contentless5.test +++ b/ext/fts5/test/fts5contentless5.test @@ -20,6 +20,7 @@ ifcapable !fts5 { finish_test return } +unset -nocomplain res do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, content='', contentless_delete=1); diff --git a/manifest b/manifest index fce7384488..1cd7b287e5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sfor\splatforms\swith\s32-bit\spointers\sthat\srequire\s64-bit\svalues\sto\sbe\saligned. -D 2024-07-17T18:38:34.280 +C Fix\sa\sproblem\sin\sFTS5\swhere\sit\sreports\sthe\swrong\serror\scode\sfollowing\san\sOOM. +D 2024-07-18T18:44:44.089 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -101,7 +101,7 @@ F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac62232 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 77fefb37e7931095a5ff271a28fbe4f73ec46d5492ef1f35d405d98e137ad8ed -F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934 +F ext/fts5/fts5_storage.c 1d7e08d4331da2f3f7e78e70eef2ed6a013d91ba16175c651adbc5ad672235aa F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -144,7 +144,7 @@ F ext/fts5/test/fts5contentless.test b107465f8cd27dde6313b9c60b61d7158a7753b9c66 F ext/fts5/test/fts5contentless2.test 70ffe6c611d8f278240da56734df8a77948f04e2739b358439e9bdcf56ced35f F ext/fts5/test/fts5contentless3.test 75eaae5ad6b284ee447788943974d323228f27cc35a1681da997135cff95bc6a F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b05ea89964c863833b6eff8 -F ext/fts5/test/fts5contentless5.test ceb53fcd635f726458fdee2e4482a37966e6b328fe94521ed02d04048f02dac5 +F ext/fts5/test/fts5contentless5.test 40cdcb4fe751672450829c5a96bd32c25fc2f6076279dd2ce5c58ac9a390132a F ext/fts5/test/fts5corrupt.test a9bda1ded5112ebf1ee85c5381bd1fe8974952e2523cede4d5072804d2011503 F ext/fts5/test/fts5corrupt2.test a524eaa861aebecb33db919f065c8d2212f4871217446db3e5e79c1c4b49c798 F ext/fts5/test/fts5corrupt3.test 3cbb18b8970c66ed4d741eb3eecf42c986bd4c430572a5050350a72030de66cf @@ -2195,9 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P be7b1fc0c5d8cda971b471dfcb4637212bfff4f42b1e074077a381cc493d877a 81b6360050eea95e4367de1b41b5864a640b4d1c5c8fc3bea3b96ed770cb0325 -R e8f0f381288545d0b462c5da079020a8 -T +closed 81b6360050eea95e4367de1b41b5864a640b4d1c5c8fc3bea3b96ed770cb0325 -U dan -Z 0fedf6ae76e03999b959269b7dd628da +P 539e4f661767ef90aef8d995f1f75fd5f550703bba1517cd3caff84a4afe2b37 +R d285e93214830b74056e2a4ecbb359a5 +U drh +Z 3f8dd91a6ce59263706bd9a44c24d85e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d455ca210b..85e7795833 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -539e4f661767ef90aef8d995f1f75fd5f550703bba1517cd3caff84a4afe2b37 +0c1cc4071edcd3e465779bbb17ea3ee6ddaa7c93c4fde55e5f3e07aa4b45783b From f73912694bd1671a664e3455524fc2821681c920 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 18 Jul 2024 19:17:29 +0000 Subject: [PATCH 0548/1030] Minor typo fixes in test-script-interpreter.md. FossilOrigin-Name: bf54b26092ded2e6acc779acfb960364f05c665c7626c38ffae61caae5636184 --- .../src/org/sqlite/jni/test-script-interpreter.md | 11 ++++++----- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ext/jni/src/org/sqlite/jni/test-script-interpreter.md b/ext/jni/src/org/sqlite/jni/test-script-interpreter.md index a51d64d107..939f77e1be 100644 --- a/ext/jni/src/org/sqlite/jni/test-script-interpreter.md +++ b/ext/jni/src/org/sqlite/jni/test-script-interpreter.md @@ -4,7 +4,7 @@ The purpose of the Test Script Interpreter is to read and interpret script files that contain SQL commands and desired results. The -interpreter will check results and report an discrepencies found. +interpreter will check results and report any discrepencies found. The test script files are ASCII text files. The filename always ends with ".test". Each script is evaluated independently; context does not carry @@ -87,6 +87,7 @@ Each command looks like an SQL comment. The command begins at the left margin (no leading space) and starts with exactly 2 minus signs ("-"). The command name consists of lowercase letters and maybe a "-" or two. Some commands have arguments. + The arguments are separated from the command name by one or more spaces. Commands have access to the input buffer and might reset the input buffer. @@ -159,9 +160,9 @@ the result buffer. This distinction does not matter for the --result command itself, but it is important for related commands like --glob and --notglob. Sometimes test cases will contains a bunch of SQL followed by multiple --glob and/or --notglob statements. All of the -globs should be evaluted agains the result buffer correct, but the SQL -should only be run once. This is accomplished by resetting the input -buffer but not the result buffer. +globs should be evaluated agains the result buffer, but the SQL should +only be run once. This is accomplished by resetting the input buffer +but not the result buffer. ### The --glob command @@ -187,7 +188,7 @@ The TEST-GLOB pattern is slightly different for a standard GLOB: ### The --notglob command The --notglob command works just like --glob except that it reports an -error if the GLOB does match, rather than if the GLOB does not matches. +error if the GLOB does match, rather than if the GLOB does not match. ### The --oom command diff --git a/manifest b/manifest index 1cd7b287e5..88ad236403 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sFTS5\swhere\sit\sreports\sthe\swrong\serror\scode\sfollowing\san\sOOM. -D 2024-07-18T18:44:44.089 +C Minor\stypo\sfixes\sin\stest-script-interpreter.md. +D 2024-07-18T19:17:29.793 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -315,7 +315,7 @@ F ext/jni/src/org/sqlite/jni/fts5/XTokenizeCallback.java 1efd1220ea328a32f2d2a1b F ext/jni/src/org/sqlite/jni/fts5/fts5_api.java a8e88c3783d21cec51b0748568a96653fead88f8f4953376178d9c7385b197ea F ext/jni/src/org/sqlite/jni/fts5/fts5_extension_function.java 9e2b954d210d572552b28aca523b272fae14bd41e318921b22f65b728d5bf978 F ext/jni/src/org/sqlite/jni/fts5/fts5_tokenizer.java 92bdaa3893bd684533004d64ade23d329843f809cd0d0f4f1a2856da6e6b4d90 -F ext/jni/src/org/sqlite/jni/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e +F ext/jni/src/org/sqlite/jni/test-script-interpreter.md 9bf7e9cab1183287b048bb77baee4b266f0c15baf1b624feec12fbf00cfa7e94 F ext/jni/src/org/sqlite/jni/wrapper1/AggregateFunction.java d5c108b02afd3c63c9e5e53f71f85273c1bfdc461ae526e0a0bb2b25e4df6483 F ext/jni/src/org/sqlite/jni/wrapper1/ScalarFunction.java 43c43adfb7866098aadaaca1620028a6ec82d5193149970019b1cce9eb59fb03 F ext/jni/src/org/sqlite/jni/wrapper1/SqlFunction.java 27b141f5914c7cb0e40e90a301d5e05b77f3bd42236834a68031b7086381fafd @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 539e4f661767ef90aef8d995f1f75fd5f550703bba1517cd3caff84a4afe2b37 -R d285e93214830b74056e2a4ecbb359a5 -U drh -Z 3f8dd91a6ce59263706bd9a44c24d85e +P 0c1cc4071edcd3e465779bbb17ea3ee6ddaa7c93c4fde55e5f3e07aa4b45783b +R aae1e75c8b917e7c82d70094db31bce4 +U stephan +Z 4b6c3f65da8d1d26380cf3c9e0c046bc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 85e7795833..0d74c4156a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c1cc4071edcd3e465779bbb17ea3ee6ddaa7c93c4fde55e5f3e07aa4b45783b +bf54b26092ded2e6acc779acfb960364f05c665c7626c38ffae61caae5636184 From aecfb0a3b34894ddf9bc7411b89cc749f000d0b5 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 20 Jul 2024 16:11:12 +0000 Subject: [PATCH 0549/1030] Fix an oversized allocation in sqlite3ExprCodeIN(). FossilOrigin-Name: d7be326a80e7b3aa8fd6e5e059c04e6ad3feaffcb20b1e3c251d7195ddc1be8b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 4 +--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 88ad236403..a0bb28e9b6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\stypo\sfixes\sin\stest-script-interpreter.md. -D 2024-07-18T19:17:29.793 +C Fix\san\soversized\sallocation\sin\ssqlite3ExprCodeIN(). +D 2024-07-20T16:11:12.048 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -705,7 +705,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c 1119a2cbb1ade3ee249c7eb18916174385219a7e4f0f5ad26d22fed6607903b0 +F src/expr.c fe958028b36af640b70b2174354c044f75b8c4a4645c921592122aa2a022083a F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0c1cc4071edcd3e465779bbb17ea3ee6ddaa7c93c4fde55e5f3e07aa4b45783b -R aae1e75c8b917e7c82d70094db31bce4 -U stephan -Z 4b6c3f65da8d1d26380cf3c9e0c046bc +P bf54b26092ded2e6acc779acfb960364f05c665c7626c38ffae61caae5636184 +R 7ef2615cb760c2eea892196d92897a4d +U dan +Z 97c1b7e0a30256a0a7866702bab37888 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0d74c4156a..c9fad50878 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf54b26092ded2e6acc779acfb960364f05c665c7626c38ffae61caae5636184 +d7be326a80e7b3aa8fd6e5e059c04e6ad3feaffcb20b1e3c251d7195ddc1be8b diff --git a/src/expr.c b/src/expr.c index b9310fb396..53b0170ab4 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3927,9 +3927,7 @@ static void sqlite3ExprCodeIN( if( sqlite3ExprCheckIN(pParse, pExpr) ) return; zAff = exprINAffinity(pParse, pExpr); nVector = sqlite3ExprVectorSize(pExpr->pLeft); - aiMap = (int*)sqlite3DbMallocZero( - pParse->db, nVector*(sizeof(int) + sizeof(char)) + 1 - ); + aiMap = (int*)sqlite3DbMallocZero(pParse->db, nVector*sizeof(int)); if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error; /* Attempt to compute the RHS. After this step, if anything other than From c855df67a471d1dde75bda25aca8f440dde815fe Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 21 Jul 2024 23:10:55 +0000 Subject: [PATCH 0550/1030] Improved debugging output when using PRAGMA vdbe_addoptrace: Show the range of opcodes being checked for Column-to-Copy conversion. FossilOrigin-Name: 2c122026db979a099a3d1a14ae1e01a0a64a559905ea414b2d80ed7dc3e04846 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 6 ++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a0bb28e9b6..501fea95d8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\soversized\sallocation\sin\ssqlite3ExprCodeIN(). -D 2024-07-20T16:11:12.048 +C Improved\sdebugging\soutput\swhen\susing\sPRAGMA\svdbe_addoptrace:\nShow\sthe\srange\sof\sopcodes\sbeing\schecked\sfor\sColumn-to-Copy\sconversion. +D 2024-07-21T23:10:55.079 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 70e12796956949658d6adb85f22d0760f0c05829f2ce882e89752eb28147baeb +F src/where.c d87a4160e26a7a96a2f7ca283b147b1b283b54ba545c46acb14cfcc6ec37ae9e F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bf54b26092ded2e6acc779acfb960364f05c665c7626c38ffae61caae5636184 -R 7ef2615cb760c2eea892196d92897a4d -U dan -Z 97c1b7e0a30256a0a7866702bab37888 +P d7be326a80e7b3aa8fd6e5e059c04e6ad3feaffcb20b1e3c251d7195ddc1be8b +R 9ae7ec0fe10c689e0f0ef5a3a2113d67 +U drh +Z 501b27f7af7c0d47afe601f333f1b3b4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c9fad50878..4eab7a2b6f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d7be326a80e7b3aa8fd6e5e059c04e6ad3feaffcb20b1e3c251d7195ddc1be8b +2c122026db979a099a3d1a14ae1e01a0a64a559905ea414b2d80ed7dc3e04846 diff --git a/src/where.c b/src/where.c index ba4631c6c2..a9a2589956 100644 --- a/src/where.c +++ b/src/where.c @@ -719,6 +719,12 @@ static void translateColumnToCopy( VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart); int iEnd = sqlite3VdbeCurrentAddr(v); if( pParse->db->mallocFailed ) return; +#ifdef SQLITE_DEBUG + if( pParse->db->flags & SQLITE_VdbeAddopTrace ){ + printf("CHECKING for column-to-copy on cursor %d for %d..%d\n", + iTabCur, iStart, iEnd); + } +#endif for(; iStartp1!=iTabCur ) continue; if( pOp->opcode==OP_Column ){ From 6326e30f86287d49091e922d880260ffbd8bdfbd Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 21 Jul 2024 23:34:52 +0000 Subject: [PATCH 0551/1030] Fixes to TreeView debugging output for VALUES clauses. FossilOrigin-Name: b6aed8bcb06edc7f0221fd707d5adc227856fe62dbcaae5ffe1fb4faa5c542e1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/treeview.c | 6 ++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 501fea95d8..ff73ecba3b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sdebugging\soutput\swhen\susing\sPRAGMA\svdbe_addoptrace:\nShow\sthe\srange\sof\sopcodes\sbeing\schecked\sfor\sColumn-to-Copy\sconversion. -D 2024-07-21T23:10:55.079 +C Fixes\sto\sTreeView\sdebugging\soutput\sfor\sVALUES\sclauses. +D 2024-07-21T23:34:52.362 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -818,7 +818,7 @@ F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c e4f0c5ca871371d26ca6868554bd5b06b7bd9554023bbec834e26c2b45814b0c +F src/treeview.c 774838df4e25956ca34ff79bef150266412cfc2640620d04e22d5c8a55a98992 F src/trigger.c 0858f75818ed1580332db274f1032bcc5effe567cb132df5c5be8b1d800ca97f F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d7be326a80e7b3aa8fd6e5e059c04e6ad3feaffcb20b1e3c251d7195ddc1be8b -R 9ae7ec0fe10c689e0f0ef5a3a2113d67 +P 2c122026db979a099a3d1a14ae1e01a0a64a559905ea414b2d80ed7dc3e04846 +R 7c78963f5a281763614d42345d62144d U drh -Z 501b27f7af7c0d47afe601f333f1b3b4 +Z e31a6d3bd1a00f1e50f69b067433df28 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4eab7a2b6f..d6b1dc535a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2c122026db979a099a3d1a14ae1e01a0a64a559905ea414b2d80ed7dc3e04846 +b6aed8bcb06edc7f0221fd707d5adc227856fe62dbcaae5ffe1fb4faa5c542e1 diff --git a/src/treeview.c b/src/treeview.c index 054265338e..3960d2859e 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -237,14 +237,12 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ sqlite3TreeViewIdList(pView, pItem->u3.pUsing, (--n)>0, "USING"); } if( pItem->pSelect ){ - sqlite3TreeViewPush(&pView, i+1nSrc); if( pItem->pTab ){ Table *pTab = pItem->pTab; sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1); } assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); sqlite3TreeViewSelect(pView, pItem->pSelect, (--n)>0); - sqlite3TreeViewPop(&pView); } if( pItem->fg.isTabFunc ){ sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); @@ -286,7 +284,7 @@ void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){ n = 1000; }else{ n = 0; - if( p->pSrc && p->pSrc->nSrc ) n++; + if( p->pSrc && p->pSrc->nSrc && p->pSrc->nAlloc ) n++; if( p->pWhere ) n++; if( p->pGroupBy ) n++; if( p->pHaving ) n++; @@ -312,7 +310,7 @@ void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){ sqlite3TreeViewPop(&pView); } #endif - if( p->pSrc && p->pSrc->nSrc ){ + if( p->pSrc && p->pSrc->nSrc && p->pSrc->nAlloc ){ sqlite3TreeViewPush(&pView, (n--)>0); sqlite3TreeViewLine(pView, "FROM"); sqlite3TreeViewSrcList(pView, p->pSrc); From 04416ddc519d89ca6263f269dbb3c3944a40ed3f Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 22 Jul 2024 19:52:02 +0000 Subject: [PATCH 0552/1030] wasm build: resolve a circular dep and do some minor tidying up. FossilOrigin-Name: 9df3f1f24c6346dc94695bf533501c54379bb6e3cf492b67dda8a64a6a1eb495 --- ext/wasm/GNUmakefile | 3 ++- ext/wasm/fiddle.make | 15 +++++++-------- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 63d04e28e9..35742d54d4 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -1184,7 +1184,7 @@ endif # Push files to public wasm-testing.sqlite.org server wasm-testing.include = *.js *.mjs *.html \ ./tests \ - $(dir.dout) $(dir.common) $(dir.fiddle) $(dir.jacc) + $(dir.dout) $(dir.common) $(dir.fiddle) $(dir.fiddle-debug) $(dir.jacc) wasm-testing.exclude = sql/speedtest1.sql wasm-testing.dir = /jail/sites/wasm-testing wasm-testing.dest ?= wasm-testing:$(wasm-testing.dir) @@ -1233,3 +1233,4 @@ endif # Run local web server for the test/demo pages. httpd: althttpd -max-age 1 -enable-sab 1 -page index.html + diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index 97cf189b03..42df139296 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -69,11 +69,10 @@ $(eval $(call call-make-pre-post,fiddle-module,vanilla)) define make-fiddle-rules fiddle-module.js$(2) := $(1)/fiddle-module.js fiddle-module.wasm$(2) := $$(subst .js,.wasm,$$(fiddle-module.js$(2))) -$(1): - @test -d "$$@" || mkdir -p "$$@" -$$(fiddle-module.js$(2)): $(1) $$(MAKEFILE) $$(MAKEFILE.fiddle) \ +$$(fiddle-module.js$(2)): $$(MAKEFILE) $$(MAKEFILE.fiddle) \ $$(EXPORTED_FUNCTIONS.fiddle) \ - $$(fiddle.cses) $$(pre-post-fiddle-module-vanilla.deps) $$(fiddle.SOAP.js$(2)) + $$(fiddle.cses) $$(pre-post-fiddle-module-vanilla.deps) $$(SOAP.js) + @test -d "$$(dir $$@)" || mkdir -p "$$(dir $$@)" $$(emcc.bin) -o $$@ $$(fiddle.emcc-flags$(2)) \ $$(pre-post-fiddle-module-vanilla.flags) \ $$(fiddle.cses) @@ -99,10 +98,10 @@ fiddle.debug: $(fiddle-module.js.debug) clean: clean-fiddle clean-fiddle: - rm -f $(fiddle-module.js) $(fiddle-module.js).gz \ - $(fiddle-module.wasm) $(fiddle-module.wasm).gz \ - $(dir.fiddle)/$(SOAP.js) \ - $(dir.fiddle)/fiddle-module.worker.js \ + rm -f $(fiddle-module.js) \ + $(fiddle-module.wasm) \ + $(dir.fiddle)/sqlite3-opfs-*.js \ + $(dir.fiddle)/*.gz \ EXPORTED_FUNCTIONS.fiddle rm -fr $(dir.fiddle-debug) .PHONY: fiddle fiddle.debug diff --git a/manifest b/manifest index ff73ecba3b..1c9ec496eb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sto\sTreeView\sdebugging\soutput\sfor\sVALUES\sclauses. -D 2024-07-21T23:34:52.362 +C wasm\sbuild:\sresolve\sa\scircular\sdep\sand\sdo\ssome\sminor\stidying\sup. +D 2024-07-22T19:52:02.340 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -593,7 +593,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 6128465c4790ee345ab50d8ec37277d9dc714e5b5814a49f47286ba7d6231a32 +F ext/wasm/GNUmakefile 2c801a86137734683966c0fe7e29d2317fdd14b8de8a24289085324213119d3f F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -644,7 +644,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make 828c6f3e45ba2541e61fd79c3d8b07a5be4cf13f9acb6430b562bcab3f251496 +F ext/wasm/fiddle.make 42b18ba889c103aa072c6193b135953b1808d1a7aa9930644dae44682da7592b F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 F ext/wasm/fiddle/index.html 739e0b75bc592679665d25e2f7649d2b8b2db678f3b41a772a8720b609b8482d @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2c122026db979a099a3d1a14ae1e01a0a64a559905ea414b2d80ed7dc3e04846 -R 7c78963f5a281763614d42345d62144d -U drh -Z e31a6d3bd1a00f1e50f69b067433df28 +P b6aed8bcb06edc7f0221fd707d5adc227856fe62dbcaae5ffe1fb4faa5c542e1 +R 202e5ba85a746eaa1bad2f1008edf0f0 +U stephan +Z 9b5070ff548645dbd81801cffcf25f1a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d6b1dc535a..8c46cfc11a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b6aed8bcb06edc7f0221fd707d5adc227856fe62dbcaae5ffe1fb4faa5c542e1 +9df3f1f24c6346dc94695bf533501c54379bb6e3cf492b67dda8a64a6a1eb495 From 71e2bdb2b45c03d4ed5b8cfe3998a18881afbd76 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 22 Jul 2024 20:58:51 +0000 Subject: [PATCH 0553/1030] OPFS VFSes: remove the on-open() pragma calls, as those (A) already reflected the build-time default settings and (B) they made it illegal to run locking_mode=exclusive, which is a requirement for WAL mode without shared memory. Modify part of the test suite to demonstrate that the SAHPool VFS can run in WAL mode so long as locking_mode=exclusive is used. FossilOrigin-Name: 19cd8e2b056d7842ee39afb7160c901c9dc55a5bac8049cb0b5246210f6b920d --- ext/wasm/api/sqlite3-api-oo1.c-pp.js | 50 ++++++++++++------- ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js | 13 +---- ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 29 +---------- ext/wasm/tester1.c-pp.js | 19 ++++++- manifest | 18 +++---- manifest.uuid | 2 +- 6 files changed, 60 insertions(+), 71 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-oo1.c-pp.js b/ext/wasm/api/sqlite3-api-oo1.c-pp.js index c579b5ddf7..55d7356e25 100644 --- a/ext/wasm/api/sqlite3-api-oo1.c-pp.js +++ b/ext/wasm/api/sqlite3-api-oo1.c-pp.js @@ -79,14 +79,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } }.bind({counter: 0})); - /** - A map of sqlite3_vfs pointers to SQL code or a callback function - to run when the DB constructor opens a database with the given - VFS. In the latter case, the call signature is (theDbObject,sqlite3Namespace) - and the callback is expected to throw on error. - */ - const __vfsPostOpenSql = Object.create(null); - //#if enable-see /** Converts ArrayBuffer or Uint8Array ba into a string of hex @@ -279,7 +271,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ // Check for per-VFS post-open SQL/callback... const pVfs = capi.sqlite3_js_db_vfs(pDb) || toss3("Internal error: cannot get VFS for new db handle."); - const postInitSql = __vfsPostOpenSql[pVfs]; + const postInitSql = __vfsPostOpenCallback[pVfs]; if(postInitSql){ /** Reminder: if this db is encrypted and the client did _not_ pass @@ -302,19 +294,39 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } }; + /** - Sets SQL which should be exec()'d on a DB instance after it is - opened with the given VFS pointer. The SQL may be any type - supported by the "string:flexible" function argument conversion. - Alternately, the 2nd argument may be a function, in which case it - is called with (theOo1DbObject,sqlite3Namespace) at the end of - the DB() constructor. The function must throw on error, in which - case the db is closed and the exception is propagated. This - function is intended only for use by DB subclasses or sqlite3_vfs + A map of sqlite3_vfs pointers to SQL code or a callback function + to run when the DB constructor opens a database with the given + VFS. In the latter case, the call signature is + (theDbObject,sqlite3Namespace) and the callback is expected to + throw on error. + */ + const __vfsPostOpenCallback = Object.create(null); + + /** + Sets a callback which should be called after a db is opened with + the given sqlite3_vfs pointer. The 2nd argument must be a + function, which gets called with + (theOo1DbObject,sqlite3Namespace) at the end of the DB() + constructor. The function must throw on error, in which case the + db is closed and the exception is propagated. This function is + intended only for use by DB subclasses or sqlite3_vfs implementations. + + Prior to 2024-07-22, it was legal to pass SQL code as the second + argument, but that can interfere with a client's ability to run + pragmas which must be run before anything else, namely (pragma + locking_mode=exclusive) for use with WAL mode. That capability + had only ever been used as an internal detail of the two OPFS + VFSes, and they no longer use it that way. */ - dbCtorHelper.setVfsPostOpenSql = function(pVfs, sql){ - __vfsPostOpenSql[pVfs] = sql; + dbCtorHelper.setVfsPostOpenCallback = function(pVfs, callback){ + if( !(callback instanceof Function)){ + toss3("dbCtorHelper.setVfsPostOpenCallback() should not be used with "+ + "a non-function argument.",arguments); + } + __vfsPostOpenCallback[pVfs] = callback; }; /** diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 86ba3add8e..d423bb0bbc 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -78,8 +78,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ capi.SQLITE_OPEN_MAIN_DB | capi.SQLITE_OPEN_MAIN_JOURNAL | capi.SQLITE_OPEN_SUPER_JOURNAL | - capi.SQLITE_OPEN_WAL /* noting that WAL support is - unavailable in the WASM build.*/; + capi.SQLITE_OPEN_WAL; /** Subdirectory of the VFS's space where "opaque" (randomly-named) files are stored. Changing this effectively invalidates the data @@ -1280,16 +1279,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }; OpfsSAHPoolDb.prototype = Object.create(oo1.DB.prototype); poolUtil.OpfsSAHPoolDb = OpfsSAHPoolDb; - oo1.DB.dbCtorHelper.setVfsPostOpenSql( - theVfs.pointer, - function(oo1Db, sqlite3){ - sqlite3.capi.sqlite3_exec(oo1Db, [ - /* See notes in sqlite3-vfs-opfs.js */ - "pragma journal_mode=DELETE;", - "pragma cache_size=-16384;" - ], 0, 0, 0); - } - ); }/*extend sqlite3.oo1*/ thePool.log("VFS initialized."); return poolUtil; diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index ef36b60626..2d11b35831 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -1288,40 +1288,13 @@ const installOpfsVfs = function callee(options){ OpfsDb.prototype = Object.create(sqlite3.oo1.DB.prototype); sqlite3.oo1.OpfsDb = OpfsDb; OpfsDb.importDb = opfsUtil.importDb; - sqlite3.oo1.DB.dbCtorHelper.setVfsPostOpenSql( + sqlite3.oo1.DB.dbCtorHelper.setVfsPostOpenCallback( opfsVfs.pointer, function(oo1Db, sqlite3){ /* Set a relatively high default busy-timeout handler to help OPFS dbs deal with multi-tab/multi-worker contention. */ sqlite3.capi.sqlite3_busy_timeout(oo1Db, 10000); - sqlite3.capi.sqlite3_exec(oo1Db, [ - /* As of July 2023, the PERSIST journal mode on OPFS is - somewhat slower than DELETE or TRUNCATE (it was faster - before Chrome version 108 or 109). TRUNCATE and DELETE - have very similar performance on OPFS. - - Roy Hashimoto notes that TRUNCATE and PERSIST modes may - decrease OPFS concurrency because multiple connections - can open the journal file in those modes: - - https://github.com/rhashimoto/wa-sqlite/issues/68 - - Given that, and the fact that testing has not revealed - any appreciable difference between performance of - TRUNCATE and DELETE modes on OPFS, we currently (as of - 2023-07-13) default to DELETE mode. - */ - "pragma journal_mode=DELETE;", - /* - This vfs benefits hugely from cache on moderate/large - speedtest1 --size 50 and --size 100 workloads. We - currently rely on setting a non-default cache size when - building sqlite3.wasm. If that policy changes, the cache - can be set here. - */ - "pragma cache_size=-16384;" - ], 0, 0, 0); } ); }/*extend sqlite3.oo1*/ diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index d99d56fa96..b5125b0d8e 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3113,11 +3113,25 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.assert(db instanceof sqlite3.oo1.DB) .assert(1 === u1.getFileCount()); db.exec([ + 'pragma locking_mode=exclusive;', + 'pragma journal_mode=wal;' + /* WAL mode only works in this VFS if locking_mode=exclusive + is invoked prior to the first db access, as this build + does not have the shared-memory APIs needed for WAL without + exclusive-mode locking. See: + + https://sqlite.org/wal.html#use_of_wal_without_shared_memory + + Note that WAL mode here DOES NOT add any concurrency capabilities + to this VFS, but it MAY provide slightly improved performance + over the other journaling modes. + */, 'create table t(a);', 'insert into t(a) values(1),(2),(3)' ]); - T.assert(1 === u1.getFileCount()); - T.assert(3 === db.selectValue('select count(*) from t')); + T.assert(2 === u1.getFileCount() /* one is the journal file */) + .assert(3 === db.selectValue('select count(*) from t')) + .assert('wal'===db.selectValue('pragma journal_mode')); db.close(); T.assert(1 === u1.getFileCount()); db = new u2.OpfsSAHPoolDb(dbName); @@ -3137,6 +3151,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert( dbytes.byteLength == nWrote ); let db2 = new u1.OpfsSAHPoolDb(dbName2); T.assert(db2 instanceof sqlite3.oo1.DB) + //.assert('wal' == db2.selectValue("pragma journal_mode=WAL")) .assert(3 === db2.selectValue('select count(*) from t')); db2.close(); T.assert(true === u1.unlink(dbName2)) diff --git a/manifest b/manifest index 1c9ec496eb..16a34220e3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C wasm\sbuild:\sresolve\sa\scircular\sdep\sand\sdo\ssome\sminor\stidying\sup. -D 2024-07-22T19:52:02.340 +C OPFS\sVFSes:\sremove\sthe\son-open()\spragma\scalls,\sas\sthose\s(A)\salready\sreflected\sthe\sbuild-time\sdefault\ssettings\sand\s(B)\sthey\smade\sit\sillegal\sto\srun\slocking_mode=exclusive,\swhich\sis\sa\srequirement\sfor\sWAL\smode\swithout\sshared\smemory.\sModify\spart\sof\sthe\stest\ssuite\sto\sdemonstrate\sthat\sthe\sSAHPool\sVFS\scan\srun\sin\sWAL\smode\sso\slong\sas\slocking_mode=exclusive\sis\sused. +D 2024-07-22T20:58:51.797 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -612,14 +612,14 @@ F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.c-pp.js 21a0f8c1e4b4675b6563759c74bef954ac36aa99acce79c56802b661429f43d0 -F ext/wasm/api/sqlite3-api-oo1.c-pp.js aba93e986b141454af2be42f37dfcfaaa981434a3801af3e48f621b620e43061 +F ext/wasm/api/sqlite3-api-oo1.c-pp.js 2e6ac2fc9cf77f7a77980a71930ce0b3e0469b0c87da7a161abd3bc365e4e3ec F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js e8f1df56e97a29004a95a2eddd26778f52c33b3e797d32d4b1b668a38e6493dd F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8c59ff35224adbe926b85d0c6debedc63c3c949d4cee761b3a74867b56155341 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 5868293eda205e74f2f5d1ada0077a6afca6981c7eba9f147736c31cde165e8b +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 619964ecb359f5385ed0724f43e0eaee218daceaebc27997a230687dd7333499 +F ext/wasm/tester1.c-pp.js 4f68682b64d5cd3e956803c0ee90457a3c47af4eecda4775e7fa4e66fde4a183 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b6aed8bcb06edc7f0221fd707d5adc227856fe62dbcaae5ffe1fb4faa5c542e1 -R 202e5ba85a746eaa1bad2f1008edf0f0 +P 9df3f1f24c6346dc94695bf533501c54379bb6e3cf492b67dda8a64a6a1eb495 +R 1a7770728d958b8cba816bd7bdd2e0a2 U stephan -Z 9b5070ff548645dbd81801cffcf25f1a +Z ad279efb20ab2e4ae7b776e5a3c20df2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8c46cfc11a..e7add708c5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9df3f1f24c6346dc94695bf533501c54379bb6e3cf492b67dda8a64a6a1eb495 +19cd8e2b056d7842ee39afb7160c901c9dc55a5bac8049cb0b5246210f6b920d From faf10c521fd79975c6dd66e79457eb4b6966c0ef Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 22 Jul 2024 21:21:25 +0000 Subject: [PATCH 0554/1030] Move a block of JS code which was inadvertently (and harmlessly) moved in the previous checkin. Clarify the semantics of an internal-use-only API. Add another WAL-related JS test. FossilOrigin-Name: 6cd9f55a975b5237efee8776efce7e7836b41905ca750f82be3b90aa04c1dff2 --- ext/wasm/api/sqlite3-api-oo1.c-pp.js | 25 +++++++++++++------------ ext/wasm/tester1.c-pp.js | 6 +++++- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-oo1.c-pp.js b/ext/wasm/api/sqlite3-api-oo1.c-pp.js index 55d7356e25..3d6a24c77b 100644 --- a/ext/wasm/api/sqlite3-api-oo1.c-pp.js +++ b/ext/wasm/api/sqlite3-api-oo1.c-pp.js @@ -79,6 +79,15 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } }.bind({counter: 0})); + /** + A map of sqlite3_vfs pointers to SQL code or a callback function + to run when the DB constructor opens a database with the given + VFS. In the latter case, the call signature is + (theDbObject,sqlite3Namespace) and the callback is expected to + throw on error. + */ + const __vfsPostOpenCallback = Object.create(null); + //#if enable-see /** Converts ArrayBuffer or Uint8Array ba into a string of hex @@ -108,7 +117,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ are set. It throws if more than one is set or if any are set to values of an invalid type. - Returns true if it applies the key, else an unspecified falsy value. + Returns true if it applies the key, else an unspecified falsy + value. Note that applying the key does not imply that the key is + correct, only that it was passed on to the db. */ const dbCtorApplySEEKey = function(db,opt){ if( !capi.sqlite3_key_v2 ) return; @@ -170,10 +181,10 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ try{ stmt = db.prepare("PRAGMA "+keytype+"="+util.sqlite3__wasm_qfmt_token(key, 1)); stmt.step(); + return true; }finally{ if(stmt) stmt.finalize(); } - return true; }; //#endif enable-see @@ -294,16 +305,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } }; - - /** - A map of sqlite3_vfs pointers to SQL code or a callback function - to run when the DB constructor opens a database with the given - VFS. In the latter case, the call signature is - (theDbObject,sqlite3Namespace) and the callback is expected to - throw on error. - */ - const __vfsPostOpenCallback = Object.create(null); - /** Sets a callback which should be called after a db is opened with the given sqlite3_vfs pointer. The 2nd argument must be a diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index b5125b0d8e..6cdd0bddd5 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3151,7 +3151,11 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert( dbytes.byteLength == nWrote ); let db2 = new u1.OpfsSAHPoolDb(dbName2); T.assert(db2 instanceof sqlite3.oo1.DB) - //.assert('wal' == db2.selectValue("pragma journal_mode=WAL")) + .assert('wal' !== db2.selectValue("pragma journal_mode") + /* importDb() unsets the WAL-mode header for + historical reasons. Because clients must + explicitly enable pragma locking_mode=exclusive + before using WAL, that behavior is retained. */) .assert(3 === db2.selectValue('select count(*) from t')); db2.close(); T.assert(true === u1.unlink(dbName2)) diff --git a/manifest b/manifest index 16a34220e3..fa7b7726aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C OPFS\sVFSes:\sremove\sthe\son-open()\spragma\scalls,\sas\sthose\s(A)\salready\sreflected\sthe\sbuild-time\sdefault\ssettings\sand\s(B)\sthey\smade\sit\sillegal\sto\srun\slocking_mode=exclusive,\swhich\sis\sa\srequirement\sfor\sWAL\smode\swithout\sshared\smemory.\sModify\spart\sof\sthe\stest\ssuite\sto\sdemonstrate\sthat\sthe\sSAHPool\sVFS\scan\srun\sin\sWAL\smode\sso\slong\sas\slocking_mode=exclusive\sis\sused. -D 2024-07-22T20:58:51.797 +C Move\sa\sblock\sof\sJS\scode\swhich\swas\sinadvertently\s(and\sharmlessly)\smoved\sin\sthe\sprevious\scheckin.\sClarify\sthe\ssemantics\sof\san\sinternal-use-only\sAPI.\sAdd\sanother\sWAL-related\sJS\stest. +D 2024-07-22T21:21:25.705 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -612,7 +612,7 @@ F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.c-pp.js 21a0f8c1e4b4675b6563759c74bef954ac36aa99acce79c56802b661429f43d0 -F ext/wasm/api/sqlite3-api-oo1.c-pp.js 2e6ac2fc9cf77f7a77980a71930ce0b3e0469b0c87da7a161abd3bc365e4e3ec +F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 @@ -667,7 +667,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 4f68682b64d5cd3e956803c0ee90457a3c47af4eecda4775e7fa4e66fde4a183 +F ext/wasm/tester1.c-pp.js 052b0c7c1039a2ae787d8c447d782182ed6e2807d0b0ee975c396c911d42e7fc F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9df3f1f24c6346dc94695bf533501c54379bb6e3cf492b67dda8a64a6a1eb495 -R 1a7770728d958b8cba816bd7bdd2e0a2 +P 19cd8e2b056d7842ee39afb7160c901c9dc55a5bac8049cb0b5246210f6b920d +R b502e866357d881b35350114c29dafaa U stephan -Z ad279efb20ab2e4ae7b776e5a3c20df2 +Z e6ea2bdde368ad9cd0c547c3fbd25648 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e7add708c5..d95b10722f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19cd8e2b056d7842ee39afb7160c901c9dc55a5bac8049cb0b5246210f6b920d +6cd9f55a975b5237efee8776efce7e7836b41905ca750f82be3b90aa04c1dff2 From 8bd5ff4f328a5d274a884f9e99c03b7dd7cebd27 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 22 Jul 2024 21:46:55 +0000 Subject: [PATCH 0555/1030] Doc typo fix. No code changes. FossilOrigin-Name: 8d558ad25bfbdea04de87616d4e3f664b5749a7d23643d1a0238e991b4bb337e --- ext/wasm/api/sqlite3-api-prologue.js | 5 +++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index 689c79ae34..c8db3698c1 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -1278,9 +1278,10 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( option is not available on the client. Though the mount point name returned by this function is intended - to remain stable, clients should not hard-coded it anywhere. Always call this function to get the path. + to remain stable, clients should not hard-coded it + anywhere. Always call this function to get the path. - Note that this function is a no-op in must builds of this + Note that this function is a no-op in most builds of this library, as the WASMFS capability requires a custom build. */ diff --git a/manifest b/manifest index fa7b7726aa..d00f89cfcc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\sa\sblock\sof\sJS\scode\swhich\swas\sinadvertently\s(and\sharmlessly)\smoved\sin\sthe\sprevious\scheckin.\sClarify\sthe\ssemantics\sof\san\sinternal-use-only\sAPI.\sAdd\sanother\sWAL-related\sJS\stest. -D 2024-07-22T21:21:25.705 +C Doc\stypo\sfix.\sNo\scode\schanges. +D 2024-07-22T21:46:55.078 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -613,7 +613,7 @@ F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057af F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e F ext/wasm/api/sqlite3-api-glue.c-pp.js 21a0f8c1e4b4675b6563759c74bef954ac36aa99acce79c56802b661429f43d0 F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f -F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 +F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js e8f1df56e97a29004a95a2eddd26778f52c33b3e797d32d4b1b668a38e6493dd @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 19cd8e2b056d7842ee39afb7160c901c9dc55a5bac8049cb0b5246210f6b920d -R b502e866357d881b35350114c29dafaa +P 6cd9f55a975b5237efee8776efce7e7836b41905ca750f82be3b90aa04c1dff2 +R 61b15192d04959d281e94594e02bce6a U stephan -Z e6ea2bdde368ad9cd0c547c3fbd25648 +Z aae0cc74fee2d9ed676d7939f647c2b8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d95b10722f..f3de54cfb0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6cd9f55a975b5237efee8776efce7e7836b41905ca750f82be3b90aa04c1dff2 +8d558ad25bfbdea04de87616d4e3f664b5749a7d23643d1a0238e991b4bb337e From 171c944345ac9f11711679f3c68e3d792cb529cd Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 23 Jul 2024 16:23:46 +0000 Subject: [PATCH 0556/1030] Enhance the percentile() extension function to include the median() variant. Update the implementation to implement its own sorting algorithm, so that the extension no longer depends on qsort(). FossilOrigin-Name: 6e31b1bab1f014933c671a12a5930c1e88d611cfe68d389e9ce888bd8842addd --- ext/misc/percentile.c | 86 ++++++++++++++++++++++++++++++++++--------- manifest | 16 ++++---- manifest.uuid | 2 +- test/percentile.test | 3 ++ 4 files changed, 80 insertions(+), 27 deletions(-) diff --git a/ext/misc/percentile.c b/ext/misc/percentile.c index d83bc5b838..9a586eafbc 100644 --- a/ext/misc/percentile.c +++ b/ext/misc/percentile.c @@ -57,6 +57,8 @@ ** (12) The percentile(Y,P) is implemented as a single C99 source-code ** file that compiles into a shared-library or DLL that can be loaded ** into SQLite using the sqlite3_load_extension() interface. +** +** (13) A separate median(Y) function is the equivalent percentile(Y,50). */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 @@ -103,16 +105,21 @@ static void percentStep(sqlite3_context *pCtx, int argc, sqlite3_value **argv){ double rPct; int eType; double y; - assert( argc==2 ); - - /* Requirement 3: P must be a number between 0 and 100 */ - eType = sqlite3_value_numeric_type(argv[1]); - rPct = sqlite3_value_double(argv[1]); - if( (eType!=SQLITE_INTEGER && eType!=SQLITE_FLOAT) - || rPct<0.0 || rPct>100.0 ){ - sqlite3_result_error(pCtx, "2nd argument to percentile() is not " - "a number between 0.0 and 100.0", -1); - return; + assert( argc==2 || argc==1 ); + + if( argc==1 ){ + /* Requirement 13: median(Y) is the same as percentile(Y,50). */ + rPct = 50.0; + }else{ + /* Requirement 3: P must be a number between 0 and 100 */ + eType = sqlite3_value_numeric_type(argv[1]); + rPct = sqlite3_value_double(argv[1]); + if( (eType!=SQLITE_INTEGER && eType!=SQLITE_FLOAT) + || rPct<0.0 || rPct>100.0 ){ + sqlite3_result_error(pCtx, "2nd argument to percentile() is not " + "a number between 0.0 and 100.0", -1); + return; + } } /* Allocate the session context. */ @@ -165,14 +172,52 @@ static void percentStep(sqlite3_context *pCtx, int argc, sqlite3_value **argv){ } /* -** Compare to doubles for sorting using qsort() +** Sort an array of doubles. */ -static int SQLITE_CDECL doubleCmp(const void *pA, const void *pB){ - double a = *(double*)pA; - double b = *(double*)pB; - if( a==b ) return 0; - if( a5 ){ + rPivot = (a[0] + a[n/2] + a[n-1])/3.0; + }else{ + rPivot = a[n/2]; + } + iLt = i = 0; + iGt = n; + while( iiLt ){ + rTmp = a[i]; + a[i] = a[iLt]; + a[iLt] = rTmp; + } + iLt++; + i++; + }else if( a[i]>rPivot ){ + do{ + iGt--; + }while( iGt>i && a[iGt]>rPivot ); + rTmp = a[i]; + a[i] = a[iGt]; + a[iGt] = rTmp; + }else{ + i++; + } + } + if( iLt>=2 ) sortDoubles(a, iLt); + if( n-iGt>=2 ) sortDoubles(a+iGt, n-iGt); + +/* Uncomment for testing */ +#if 0 + for(i=0; ia==0 ) return; if( p->nUsed ){ - qsort(p->a, p->nUsed, sizeof(double), doubleCmp); + sortDoubles(p->a, p->nUsed); ix = (p->rPct-1.0)*(p->nUsed-1)*0.01; i1 = (unsigned)ix; i2 = ix==(double)i1 || i1==p->nUsed-1 ? i1 : i1+1; @@ -216,5 +261,10 @@ int sqlite3_percentile_init( rc = sqlite3_create_function(db, "percentile", 2, SQLITE_UTF8|SQLITE_INNOCUOUS, 0, 0, percentStep, percentFinal); + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "median", 1, + SQLITE_UTF8|SQLITE_INNOCUOUS, 0, + 0, percentStep, percentFinal); + } return rc; } diff --git a/manifest b/manifest index d00f89cfcc..7ec408ed08 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Doc\stypo\sfix.\sNo\scode\schanges. -D 2024-07-22T21:46:55.078 +C Enhance\sthe\spercentile()\sextension\sfunction\sto\sinclude\sthe\smedian()\nvariant.\s\sUpdate\sthe\simplementation\sto\simplement\sits\sown\ssorting\nalgorithm,\sso\sthat\sthe\sextension\sno\slonger\sdepends\son\sqsort(). +D 2024-07-23T16:23:46.925 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -404,7 +404,7 @@ F ext/misc/nextchar.c 7877914c2a80c2f181dd04c3dbef550dfb54c93495dc03da2403b5dd58 F ext/misc/noop.c f1a21cc9b7a4e667e5c8458d80ba680b8bd4315a003f256006046879f679c5a0 F ext/misc/normalize.c bd84355c118e297522aba74de34a4fd286fc775524e0499b14473918d09ea61f F ext/misc/pcachetrace.c f4227ce03fb16aa8d6f321b72dd051097419d7a028a9853af048bee7645cb405 -F ext/misc/percentile.c b9086e223d583bdaf8cb73c98a6539d501a2fc4282654adbfea576453d82e691 +F ext/misc/percentile.c f15eb0fb0c2a95a482382b41415b9d1ae66eabf857ecac8e1e0eb3aa6b44e4d8 F ext/misc/prefixes.c 82645f79229877afab08c8b08ca1e7fa31921280906b90a61c294e4f540cd2a6 F ext/misc/qpvtab.c fc189e127f68f791af90a487f4460ec91539a716daf45a0c357e963fd47cc06c F ext/misc/randomjson.c ef835fc64289e76ac4873b85fe12f9463a036168d7683cf2b773e36e6262c4ed @@ -1503,7 +1503,7 @@ F test/parser1.test 6ccdf5e459a5dc4673d3273dc311a7e9742ca952dd0551a6a6320d27035c F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/pendingrace.test 6aa33756b950c4529f79c4f3817a9a1e4025bd0d9961571a05c0279bd183d9c6 -F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff +F test/percentile.test 16fa70efabac459223d4886604abc629cacfb5f00ca7c3160da47fbeac870674 F test/permutations.test 405542f1d659942994a6b38a9e024cf5cfd23eaa68c806aeb24a72d7c9186e80 F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f F test/pragma.test 11cb9310c42f921918f7f563e3c0b6e70f9f9c3a6a1cf12af8fccb6c574f3882 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6cd9f55a975b5237efee8776efce7e7836b41905ca750f82be3b90aa04c1dff2 -R 61b15192d04959d281e94594e02bce6a -U stephan -Z aae0cc74fee2d9ed676d7939f647c2b8 +P 8d558ad25bfbdea04de87616d4e3f664b5749a7d23643d1a0238e991b4bb337e +R 6164638135694f2a60de1effceddb452 +U drh +Z a2b6c7a02bd489d715da4964c630a442 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f3de54cfb0..e1c8d42a87 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8d558ad25bfbdea04de87616d4e3f664b5749a7d23643d1a0238e991b4bb337e +6e31b1bab1f014933c671a12a5930c1e88d611cfe68d389e9ce888bd8842addd diff --git a/test/percentile.test b/test/percentile.test index b2bd061e86..a54248e6da 100644 --- a/test/percentile.test +++ b/test/percentile.test @@ -38,6 +38,9 @@ foreach {in out} { execsql {SELECT percentile(x,$in) FROM t1} } $out } +do_execsql_test percentile-1.1.median { + SELECT median(x) FROM t1; +} 8.0 # Add some NULL values. # From 4eabec5b18090c8b54218bea4453a0e5f4ebd040 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 24 Jul 2024 12:12:11 +0000 Subject: [PATCH 0557/1030] JNI SQLTester: fix --new command to force-replace db if it already exists. Add no-op impls for --stmt-cache and --jsonglob commands. FossilOrigin-Name: f1185dc349d076a6b8ea22f9b5cd527bfd60e9afd55eaec754c0e2b4d7edd5d4 --- .../src/org/sqlite/jni/capi/SQLTester.java | 19 ++++++++++++++++++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ext/jni/src/org/sqlite/jni/capi/SQLTester.java b/ext/jni/src/org/sqlite/jni/capi/SQLTester.java index 81d6106be7..c68785e2c3 100644 --- a/ext/jni/src/org/sqlite/jni/capi/SQLTester.java +++ b/ext/jni/src/org/sqlite/jni/capi/SQLTester.java @@ -851,11 +851,26 @@ class JsonBlockCommand extends TableResultCommand { //! --new command class NewDbCommand extends OpenDbCommand { public NewDbCommand(){ super(true); } + public void process(SQLTester t, TestScript ts, String[] argv) throws Exception{ + if(argv.length>1){ + Util.unlink(argv[1]); + } + super.process(t, ts, argv); + } + } -//! Placeholder dummy/no-op commands +//! Placeholder dummy/no-op/unimplemented commands class NoopCommand extends Command { + private boolean verbose = false; + public NoopCommand(boolean verbose){ + this.verbose = verbose; + } + public NoopCommand(){} public void process(SQLTester t, TestScript ts, String[] argv) throws Exception{ + if( this.verbose ){ + t.outln("Skipping unhandled command: "+argv[0]); + } } } @@ -1021,6 +1036,7 @@ static Command getCommandByName(String name){ case "db": rv = new DbCommand(); break; case "glob": rv = new GlobCommand(); break; case "json": rv = new JsonCommand(); break; + case "jsonglob": rv = new NoopCommand(true); break; case "json-block": rv = new JsonBlockCommand(); break; case "new": rv = new NewDbCommand(); break; case "notglob": rv = new NotGlobCommand(); break; @@ -1030,6 +1046,7 @@ static Command getCommandByName(String name){ case "print": rv = new PrintCommand(); break; case "result": rv = new ResultCommand(); break; case "run": rv = new RunCommand(); break; + case "stmt-cache": rv = new NoopCommand(); break; case "tableresult": rv = new TableResultCommand(); break; case "testcase": rv = new TestCaseCommand(); break; case "verbosity": rv = new VerbosityCommand(); break; diff --git a/manifest b/manifest index 7ec408ed08..c53d8f44f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\spercentile()\sextension\sfunction\sto\sinclude\sthe\smedian()\nvariant.\s\sUpdate\sthe\simplementation\sto\simplement\sits\sown\ssorting\nalgorithm,\sso\sthat\sthe\sextension\sno\slonger\sdepends\son\sqsort(). -D 2024-07-23T16:23:46.925 +C JNI\sSQLTester:\sfix\s--new\scommand\sto\sforce-replace\sdb\sif\sit\salready\sexists.\sAdd\sno-op\simpls\sfor\s--stmt-cache\sand\s--jsonglob\scommands. +D 2024-07-24T12:12:11.773 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -289,7 +289,7 @@ F ext/jni/src/org/sqlite/jni/capi/ProgressHandlerCallback.java 01bc0c238eed2d5f9 F ext/jni/src/org/sqlite/jni/capi/ResultCode.java 8141171f1bcf9f46eef303b9d3c5dc2537a25ad1628f3638398d8a60cacefa7f F ext/jni/src/org/sqlite/jni/capi/RollbackHookCallback.java e172210a2080e851ebb694c70e9f0bf89284237795e38710a7f5f1b61e3f6787 F ext/jni/src/org/sqlite/jni/capi/SQLFunction.java 0d1e9afc9ff8a2adb94a155b72385155fa3b8011a5cca0bb3c28468c7131c1a5 -F ext/jni/src/org/sqlite/jni/capi/SQLTester.java 09bee15aa0eedac68d767ae21d9a6a62a31ade59182a3ccbf036d6463d9e30b1 +F ext/jni/src/org/sqlite/jni/capi/SQLTester.java 0b25cde8c5fa77f3e7ad92368acf195c5c64fb1c5273b8ee71b2d7ab812aab34 F ext/jni/src/org/sqlite/jni/capi/ScalarFunction.java 93b9700fca4c68075ccab12fe0fbbc76c91cafc9f368e835b9bd7cd7732c8615 F ext/jni/src/org/sqlite/jni/capi/TableColumnMetadata.java addf120e0e76e5be1ff2260daa7ce305ff9b5fafd64153a7a28e9d8f000a815f F ext/jni/src/org/sqlite/jni/capi/Tester1.java e5fa17301b7266c1cbe4bcce67788e08e45871c7c72c153d515abb37e501de0a @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8d558ad25bfbdea04de87616d4e3f664b5749a7d23643d1a0238e991b4bb337e -R 6164638135694f2a60de1effceddb452 -U drh -Z a2b6c7a02bd489d715da4964c630a442 +P 6e31b1bab1f014933c671a12a5930c1e88d611cfe68d389e9ce888bd8842addd +R 9fff1942fcabca82c9428b463cd9f75c +U stephan +Z 85b41f77db581220e66c2d5ad0a7d9f1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e1c8d42a87..e0d3a5a1bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6e31b1bab1f014933c671a12a5930c1e88d611cfe68d389e9ce888bd8842addd +f1185dc349d076a6b8ea22f9b5cd527bfd60e9afd55eaec754c0e2b4d7edd5d4 From b18d851119c880eba4a3fda1b21be83a723ff1d5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 24 Jul 2024 13:41:09 +0000 Subject: [PATCH 0558/1030] Add the percentile_cont(Y,P) variant of percentile() to the percentile extension. FossilOrigin-Name: 095c22e62248f8ef50cd8531171827f50a7bdd4fc1128bf0e616a3eb2dce980e --- ext/misc/percentile.c | 21 ++++++++++++++++++++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/percentile.test | 20 ++++++++++++++++++++ 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/ext/misc/percentile.c b/ext/misc/percentile.c index 9a586eafbc..cccbaf0253 100644 --- a/ext/misc/percentile.c +++ b/ext/misc/percentile.c @@ -59,6 +59,9 @@ ** into SQLite using the sqlite3_load_extension() interface. ** ** (13) A separate median(Y) function is the equivalent percentile(Y,50). +** +** (14) A separate percentile_cond(Y,X) function is the equivalent of +** percentile(Y,X*100.0). */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 @@ -110,7 +113,7 @@ static void percentStep(sqlite3_context *pCtx, int argc, sqlite3_value **argv){ if( argc==1 ){ /* Requirement 13: median(Y) is the same as percentile(Y,50). */ rPct = 50.0; - }else{ + }else if( sqlite3_user_data(pCtx)==0 ){ /* Requirement 3: P must be a number between 0 and 100 */ eType = sqlite3_value_numeric_type(argv[1]); rPct = sqlite3_value_double(argv[1]); @@ -120,6 +123,17 @@ static void percentStep(sqlite3_context *pCtx, int argc, sqlite3_value **argv){ "a number between 0.0 and 100.0", -1); return; } + }else{ + /* Requirement 3: P must be a number between 0 and 1 */ + eType = sqlite3_value_numeric_type(argv[1]); + rPct = sqlite3_value_double(argv[1]); + if( (eType!=SQLITE_INTEGER && eType!=SQLITE_FLOAT) + || rPct<0.0 || rPct>1.0 ){ + sqlite3_result_error(pCtx, "2nd argument to percentile_cont() is not " + "a number between 0.0 and 1.0", -1); + return; + } + rPct *= 100.0; } /* Allocate the session context. */ @@ -266,5 +280,10 @@ int sqlite3_percentile_init( SQLITE_UTF8|SQLITE_INNOCUOUS, 0, 0, percentStep, percentFinal); } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "percentile_cont", 2, + SQLITE_UTF8|SQLITE_INNOCUOUS, &percentStep, + 0, percentStep, percentFinal); + } return rc; } diff --git a/manifest b/manifest index c53d8f44f4..a401fd88e7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C JNI\sSQLTester:\sfix\s--new\scommand\sto\sforce-replace\sdb\sif\sit\salready\sexists.\sAdd\sno-op\simpls\sfor\s--stmt-cache\sand\s--jsonglob\scommands. -D 2024-07-24T12:12:11.773 +C Add\sthe\spercentile_cont(Y,P)\svariant\sof\spercentile()\sto\sthe\spercentile\nextension. +D 2024-07-24T13:41:09.099 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -404,7 +404,7 @@ F ext/misc/nextchar.c 7877914c2a80c2f181dd04c3dbef550dfb54c93495dc03da2403b5dd58 F ext/misc/noop.c f1a21cc9b7a4e667e5c8458d80ba680b8bd4315a003f256006046879f679c5a0 F ext/misc/normalize.c bd84355c118e297522aba74de34a4fd286fc775524e0499b14473918d09ea61f F ext/misc/pcachetrace.c f4227ce03fb16aa8d6f321b72dd051097419d7a028a9853af048bee7645cb405 -F ext/misc/percentile.c f15eb0fb0c2a95a482382b41415b9d1ae66eabf857ecac8e1e0eb3aa6b44e4d8 +F ext/misc/percentile.c af1941dc87d45dd0c2698a3087fbfe9ee0d157e5e72da521430c4b784abcbe81 F ext/misc/prefixes.c 82645f79229877afab08c8b08ca1e7fa31921280906b90a61c294e4f540cd2a6 F ext/misc/qpvtab.c fc189e127f68f791af90a487f4460ec91539a716daf45a0c357e963fd47cc06c F ext/misc/randomjson.c ef835fc64289e76ac4873b85fe12f9463a036168d7683cf2b773e36e6262c4ed @@ -1503,7 +1503,7 @@ F test/parser1.test 6ccdf5e459a5dc4673d3273dc311a7e9742ca952dd0551a6a6320d27035c F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/pendingrace.test 6aa33756b950c4529f79c4f3817a9a1e4025bd0d9961571a05c0279bd183d9c6 -F test/percentile.test 16fa70efabac459223d4886604abc629cacfb5f00ca7c3160da47fbeac870674 +F test/percentile.test 74e383216a075251512d6ba98beb9dccd6da465e3f73817fc438379e3a628de7 F test/permutations.test 405542f1d659942994a6b38a9e024cf5cfd23eaa68c806aeb24a72d7c9186e80 F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f F test/pragma.test 11cb9310c42f921918f7f563e3c0b6e70f9f9c3a6a1cf12af8fccb6c574f3882 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6e31b1bab1f014933c671a12a5930c1e88d611cfe68d389e9ce888bd8842addd -R 9fff1942fcabca82c9428b463cd9f75c -U stephan -Z 85b41f77db581220e66c2d5ad0a7d9f1 +P f1185dc349d076a6b8ea22f9b5cd527bfd60e9afd55eaec754c0e2b4d7edd5d4 +R 3c3a23f8bfc329ad379bd8e32b882636 +U drh +Z 74cc206d7bf9e16b26dee128329dd3d6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e0d3a5a1bf..a919ff6f08 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f1185dc349d076a6b8ea22f9b5cd527bfd60e9afd55eaec754c0e2b4d7edd5d4 +095c22e62248f8ef50cd8531171827f50a7bdd4fc1128bf0e616a3eb2dce980e diff --git a/test/percentile.test b/test/percentile.test index a54248e6da..ab5b4883fd 100644 --- a/test/percentile.test +++ b/test/percentile.test @@ -42,6 +42,20 @@ do_execsql_test percentile-1.1.median { SELECT median(x) FROM t1; } 8.0 +foreach {in out} { + 1.0 11.0 + 0.5 8.0 + 0.125 4.0 + 0.15 4.4 + 0.2 5.2 + 0.8 11.0 + 0.89 11.0 +} { + do_test percentile-1.1b-$in { + execsql {SELECT percentile_cont(x,$in) FROM t1} + } $out +} + # Add some NULL values. # do_test percentile-1.2 { @@ -112,6 +126,9 @@ do_test percentile-1.11 { do_test percentile-1.12 { catchsql {SELECT percentile(x,x'3530') FROM t1} } {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}} +do_test percentile-1.12b { + catchsql {SELECT percentile_cont(x,x'3530') FROM t1} +} {1 {2nd argument to percentile_cont() is not a number between 0.0 and 1.0}} # Second argument is out of range # @@ -121,6 +138,9 @@ do_test percentile-1.13 { do_test percentile-1.14 { catchsql {SELECT percentile(x,100.0000001) FROM t1} } {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}} +do_test percentile-1.14b { + catchsql {SELECT percentile_cont(x,1.0000001) FROM t1} +} {1 {2nd argument to percentile_cont() is not a number between 0.0 and 1.0}} # First argument is not NULL and is not NUMERIC # From 4f2144dac0119044f36de618fae1a5ed24046a3a Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 24 Jul 2024 13:53:51 +0000 Subject: [PATCH 0559/1030] Add the percentile extension to the CLI by default. FossilOrigin-Name: bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index a401fd88e7..bccfb3c0a2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\spercentile_cont(Y,P)\svariant\sof\spercentile()\sto\sthe\spercentile\nextension. -D 2024-07-24T13:41:09.099 +C Add\sthe\spercentile\sextension\sto\sthe\sCLI\sby\sdefault. +D 2024-07-24T13:53:51.649 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -756,7 +756,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e -F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee13 +F src/shell.c.in 44c02fd1581d95e066b479241e081f37dc95c98452badd03627ef2a1c21bdc80 F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f1185dc349d076a6b8ea22f9b5cd527bfd60e9afd55eaec754c0e2b4d7edd5d4 -R 3c3a23f8bfc329ad379bd8e32b882636 +P 095c22e62248f8ef50cd8531171827f50a7bdd4fc1128bf0e616a3eb2dce980e +R 76e7f4761efc98a28727d2a1442d8c13 U drh -Z 74cc206d7bf9e16b26dee128329dd3d6 +Z 956d236c4ff2c748d10dde2ade86c2ae # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a919ff6f08..c7d267a281 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -095c22e62248f8ef50cd8531171827f50a7bdd4fc1128bf0e616a3eb2dce980e +bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04 diff --git a/src/shell.c.in b/src/shell.c.in index ec7e7ce44e..f389c1f475 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1200,6 +1200,7 @@ INCLUDE ../ext/misc/pcachetrace.c INCLUDE ../ext/misc/shathree.c INCLUDE ../ext/misc/uint.c INCLUDE ../ext/misc/decimal.c +INCLUDE ../ext/misc/percentile.c #undef sqlite3_base_init #define sqlite3_base_init sqlite3_base64_init INCLUDE ../ext/misc/base64.c @@ -5374,6 +5375,7 @@ static void open_db(ShellState *p, int openFlags){ sqlite3_uint_init(p->db, 0, 0); sqlite3_stmtrand_init(p->db, 0, 0); sqlite3_decimal_init(p->db, 0, 0); + sqlite3_percentile_init(p->db, 0, 0); sqlite3_base64_init(p->db, 0, 0); sqlite3_base85_init(p->db, 0, 0); sqlite3_regexp_init(p->db, 0, 0); From fe225745fcff95e9de8e745daedfd3dc2a30bf61 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 24 Jul 2024 22:07:18 +0000 Subject: [PATCH 0560/1030] Restructuring of the wasm build to support an experimental 'minimal' build mode which elides all non-core APIs. FossilOrigin-Name: ee2191f7302210100fa0b29ace8156531ad995bf61aa2642e526e0901d0c6862 --- ext/wasm/GNUmakefile | 26 ++++++++-- ...e3-api => EXPORTED_FUNCTIONS.sqlite3-core} | 48 ----------------- .../api/EXPORTED_FUNCTIONS.sqlite3-preupdate | 6 +++ .../api/EXPORTED_FUNCTIONS.sqlite3-session | 42 +++++++++++++++ ext/wasm/api/sqlite3-api-glue.c-pp.js | 52 +++++++++++-------- ext/wasm/api/sqlite3-wasm.c | 25 +++++++-- ext/wasm/fiddle.make | 1 + ext/wasm/tester1.c-pp.js | 15 +++++- manifest | 26 +++++----- manifest.uuid | 2 +- 10 files changed, 151 insertions(+), 92 deletions(-) rename ext/wasm/api/{EXPORTED_FUNCTIONS.sqlite3-api => EXPORTED_FUNCTIONS.sqlite3-core} (73%) create mode 100644 ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate create mode 100644 ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 35742d54d4..d9ca75d0a5 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -233,6 +233,14 @@ SQLITE_OPT = \ # can be used to find errant uses of sqlite3_js_vfs_create_file() # in client code. +######################################################################## +# minimal=1 disables all "extraneous" stuff from sqlite3-wasm.c, the +# goal being to create a WASM file with only the core APIs. +minimal ?= 0 +ifeq (1,$(minimal)) + SQLITE_OPT += -DSQLITE_WASM_MINIMAL +endif + ########################################################################@ # It's important that sqlite3.h be built to completion before any # other parts of the build run, thus we use .NOTPARALLEL to disable @@ -413,11 +421,20 @@ emcc_opt_full := $(emcc_opt) -g3 ######################################################################## # EXPORTED_FUNCTIONS.* = files for use with Emscripten's # -sEXPORTED_FUNCTION flag. -EXPORTED_FUNCTIONS.api.main := $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-api) -EXPORTED_FUNCTIONS.api.in := $(EXPORTED_FUNCTIONS.api.main) +EXPORTED_FUNCTIONS.api.core := $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-core) +EXPORTED_FUNCTIONS.api.in := $(EXPORTED_FUNCTIONS.api.core) ifeq (1,$(SQLITE_C_IS_SEE)) EXPORTED_FUNCTIONS.api.in += $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-see) endif +ifeq (0,$(minimal)) + EXPORTED_FUNCTIONS.api.in += \ + $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-session) \ + $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-preupdate) +else + $(info ========================================) + $(info This is a minimal-mode build) + $(info ========================================) +endif EXPORTED_FUNCTIONS.api := $(dir.tmp)/EXPORTED_FUNCTIONS.api $(EXPORTED_FUNCTIONS.api): $(EXPORTED_FUNCTIONS.api.in) $(sqlite3.c) $(MAKEFILE) cat $(EXPORTED_FUNCTIONS.api.in) > $@ @@ -1059,9 +1076,9 @@ speedtest1.exit-runtime1 := -sEXIT_RUNTIME=1 # -sEXIT_RUNTIME=1 but we need EXIT_RUNTIME=0 for the worker-based app # which runs speedtest1 multiple times. -$(EXPORTED_FUNCTIONS.speedtest1): $(EXPORTED_FUNCTIONS.api.main) +$(EXPORTED_FUNCTIONS.speedtest1): $(EXPORTED_FUNCTIONS.api.core) @echo "Making $@ ..." - @{ echo _wasm_main; cat $(EXPORTED_FUNCTIONS.api.main); } > $@ + @{ echo _wasm_main; cat $(EXPORTED_FUNCTIONS.api.core); } > $@ speedtest1.js := $(dir.dout)/speedtest1.js speedtest1.wasm := $(dir.dout)/speedtest1.wasm emcc.flags.speedtest1-vanilla := $(cflags.common) -DSQLITE_SPEEDTEST1_WASM @@ -1077,6 +1094,7 @@ $(speedtest1.js): $(MAKEFILE) $(speedtest1.cfiles) \ $(emcc.speedtest1.common) \ $(emcc.flags.speedtest1-vanilla) $(pre-post-speedtest1-vanilla.flags) \ $(SQLITE_OPT) \ + -USQLITE_WASM_MINIMAL \ -USQLITE_C -DSQLITE_C=$(sqlite3.canonical.c) \ $(speedtest1.exit-runtime0) \ -o $@ $(speedtest1.cfiles) -lm diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core similarity index 73% rename from ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api rename to ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core index 42231c8a2a..ce703666fe 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core @@ -84,12 +84,6 @@ _sqlite3_open_v2 _sqlite3_overload_function _sqlite3_prepare_v2 _sqlite3_prepare_v3 -_sqlite3_preupdate_blobwrite -_sqlite3_preupdate_count -_sqlite3_preupdate_depth -_sqlite3_preupdate_hook -_sqlite3_preupdate_new -_sqlite3_preupdate_old _sqlite3_progress_handler _sqlite3_randomness _sqlite3_realloc @@ -166,45 +160,3 @@ _sqlite3_vtab_in_next _sqlite3_vtab_nochange _sqlite3_vtab_on_conflict _sqlite3_vtab_rhs_value -_sqlite3changegroup_add -_sqlite3changegroup_add_strm -_sqlite3changegroup_delete -_sqlite3changegroup_new -_sqlite3changegroup_output -_sqlite3changegroup_output_strm -_sqlite3changeset_apply -_sqlite3changeset_apply_strm -_sqlite3changeset_apply_v2 -_sqlite3changeset_apply_v2_strm -_sqlite3changeset_concat -_sqlite3changeset_concat_strm -_sqlite3changeset_conflict -_sqlite3changeset_finalize -_sqlite3changeset_fk_conflicts -_sqlite3changeset_invert -_sqlite3changeset_invert_strm -_sqlite3changeset_new -_sqlite3changeset_next -_sqlite3changeset_old -_sqlite3changeset_op -_sqlite3changeset_pk -_sqlite3changeset_start -_sqlite3changeset_start_strm -_sqlite3changeset_start_v2 -_sqlite3changeset_start_v2_strm -_sqlite3session_attach -_sqlite3session_changeset -_sqlite3session_changeset_size -_sqlite3session_changeset_strm -_sqlite3session_config -_sqlite3session_create -_sqlite3session_delete -_sqlite3session_diff -_sqlite3session_enable -_sqlite3session_indirect -_sqlite3session_isempty -_sqlite3session_memory_used -_sqlite3session_object_config -_sqlite3session_patchset -_sqlite3session_patchset_strm -_sqlite3session_table_filter diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate new file mode 100644 index 0000000000..5c57a76b60 --- /dev/null +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate @@ -0,0 +1,6 @@ +_sqlite3_preupdate_blobwrite +_sqlite3_preupdate_count +_sqlite3_preupdate_depth +_sqlite3_preupdate_hook +_sqlite3_preupdate_new +_sqlite3_preupdate_old diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session new file mode 100644 index 0000000000..5b7b53f952 --- /dev/null +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session @@ -0,0 +1,42 @@ +_sqlite3changegroup_add +_sqlite3changegroup_add_strm +_sqlite3changegroup_delete +_sqlite3changegroup_new +_sqlite3changegroup_output +_sqlite3changegroup_output_strm +_sqlite3changeset_apply +_sqlite3changeset_apply_strm +_sqlite3changeset_apply_v2 +_sqlite3changeset_apply_v2_strm +_sqlite3changeset_concat +_sqlite3changeset_concat_strm +_sqlite3changeset_conflict +_sqlite3changeset_finalize +_sqlite3changeset_fk_conflicts +_sqlite3changeset_invert +_sqlite3changeset_invert_strm +_sqlite3changeset_new +_sqlite3changeset_next +_sqlite3changeset_old +_sqlite3changeset_op +_sqlite3changeset_pk +_sqlite3changeset_start +_sqlite3changeset_start_strm +_sqlite3changeset_start_v2 +_sqlite3changeset_start_v2_strm +_sqlite3session_attach +_sqlite3session_changeset +_sqlite3session_changeset_size +_sqlite3session_changeset_strm +_sqlite3session_config +_sqlite3session_create +_sqlite3session_delete +_sqlite3session_diff +_sqlite3session_enable +_sqlite3session_indirect +_sqlite3session_isempty +_sqlite3session_memory_used +_sqlite3session_object_config +_sqlite3session_patchset +_sqlite3session_patchset_strm +_sqlite3session_table_filter diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index 93a8398ab7..3e8643ad30 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -385,26 +385,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_malloc64", "*","i64"], ["sqlite3_msize", "i64", "*"], ["sqlite3_overload_function", "int", ["sqlite3*","string","int"]], - ["sqlite3_preupdate_blobwrite", "int", "sqlite3*"], - ["sqlite3_preupdate_count", "int", "sqlite3*"], - ["sqlite3_preupdate_depth", "int", "sqlite3*"], - ["sqlite3_preupdate_hook", "*", [ - "sqlite3*", - new wasm.xWrap.FuncPtrAdapter({ - name: 'sqlite3_preupdate_hook', - signature: "v(ppippjj)", - contextKey: (argv)=>argv[0/* sqlite3* */], - callProxy: (callback)=>{ - return (p,db,op,zDb,zTbl,iKey1,iKey2)=>{ - callback(p, db, op, wasm.cstrToJs(zDb), wasm.cstrToJs(zTbl), - iKey1, iKey2); - }; - } - }), - "*" - ]], - ["sqlite3_preupdate_new", "int", ["sqlite3*", "int", "**"]], - ["sqlite3_preupdate_old", "int", ["sqlite3*", "int", "**"]], ["sqlite3_realloc64", "*","*", "i64"], ["sqlite3_result_int64", undefined, "*", "i64"], ["sqlite3_result_zeroblob64", "int", "*", "i64"], @@ -440,8 +420,36 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_vtab_rhs_value","int", "sqlite3_index_info*", "int", "**"] ]; + if(wasm.bigIntEnabled && !!wasm.exports.sqlite3_preupdate_hook){ + wasm.bindingSignatures.int64.push( + ["sqlite3_preupdate_blobwrite", "int", "sqlite3*"], + ["sqlite3_preupdate_count", "int", "sqlite3*"], + ["sqlite3_preupdate_depth", "int", "sqlite3*"], + ["sqlite3_preupdate_hook", "*", [ + "sqlite3*", + new wasm.xWrap.FuncPtrAdapter({ + name: 'sqlite3_preupdate_hook', + signature: "v(ppippjj)", + contextKey: (argv)=>argv[0/* sqlite3* */], + callProxy: (callback)=>{ + return (p,db,op,zDb,zTbl,iKey1,iKey2)=>{ + callback(p, db, op, wasm.cstrToJs(zDb), wasm.cstrToJs(zTbl), + iKey1, iKey2); + }; + } + }), + "*" + ]], + ["sqlite3_preupdate_new", "int", ["sqlite3*", "int", "**"]], + ["sqlite3_preupdate_old", "int", ["sqlite3*", "int", "**"]] + ); + } /* preupdate API */ + // Add session/changeset APIs... - if(wasm.bigIntEnabled && !!wasm.exports.sqlite3changegroup_add){ + if(wasm.bigIntEnabled + && !!wasm.exports.sqlite3changegroup_add + && !!wasm.exports.sqlite3session_create + && !!wasm.exports.sqlite3_preupdate_hook /* required by the session API */){ /** FuncPtrAdapter options for session-related callbacks with the native signature "i(ps)". This proxy converts the 2nd argument @@ -1079,7 +1087,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }; }/*sqlite3_close_v2()*/ - if(capi.sqlite3session_table_filter){ + if(capi.sqlite3session_create){ const __sqlite3SessionDelete = wasm.xWrap( 'sqlite3session_delete', undefined, ['sqlite3_session*'] ); diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index 48ae2297ad..c755662791 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -104,8 +104,8 @@ #ifndef SQLITE_ENABLE_EXPLAIN_COMMENTS # define SQLITE_ENABLE_EXPLAIN_COMMENTS 1 #endif -#ifndef SQLITE_ENABLE_FTS4 -# define SQLITE_ENABLE_FTS4 1 +#ifndef SQLITE_ENABLE_FTS5 +# define SQLITE_ENABLE_FTS5 1 #endif #ifndef SQLITE_ENABLE_MATH_FUNCTIONS # define SQLITE_ENABLE_MATH_FUNCTIONS 1 @@ -129,6 +129,22 @@ # define SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION #endif +/* +** If SQLITE_WASM_MINIMAL is defined, undefine most of the ENABLE +** macros. +*/ +#ifdef SQLITE_WASM_MINIMAL +# undef SQLITE_ENABLE_DBPAGE_VTAB +# undef SQLITE_ENABLE_DBSTAT_VTAB +# undef SQLITE_ENABLE_EXPLAIN_COMMENTS +# undef SQLITE_ENABLE_FTS5 +# undef SQLITE_ENABLE_OFFSET_SQL_FUNC +# undef SQLITE_ENABLE_PREUPDATE_HOOK +# undef SQLITE_ENABLE_RTREE +# undef SQLITE_ENABLE_SESSION +# undef SQLITE_ENABLE_STMTVTAB +#endif + /**********************************************************************/ /* SQLITE_O... */ #ifndef SQLITE_OMIT_DEPRECATED @@ -499,6 +515,7 @@ const char * sqlite3__wasm_enum_json(void){ } _DefGroup; DefGroup(changeset){ +#ifdef SQLITE_CHANGESETSTART_INVERT DefInt(SQLITE_CHANGESETSTART_INVERT); DefInt(SQLITE_CHANGESETAPPLY_NOSAVEPOINT); DefInt(SQLITE_CHANGESETAPPLY_INVERT); @@ -513,6 +530,7 @@ const char * sqlite3__wasm_enum_json(void){ DefInt(SQLITE_CHANGESET_OMIT); DefInt(SQLITE_CHANGESET_REPLACE); DefInt(SQLITE_CHANGESET_ABORT); +#endif } _DefGroup; DefGroup(config){ @@ -564,7 +582,6 @@ const char * sqlite3__wasm_enum_json(void){ DefInt(SQLITE_DBCONFIG_LOOKASIDE); DefInt(SQLITE_DBCONFIG_ENABLE_FKEY); DefInt(SQLITE_DBCONFIG_ENABLE_TRIGGER); - DefInt(SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER); DefInt(SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION); DefInt(SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE); DefInt(SQLITE_DBCONFIG_ENABLE_QPSG); @@ -859,8 +876,10 @@ const char * sqlite3__wasm_enum_json(void){ } _DefGroup; DefGroup(session){ +#ifdef SQLITE_SESSION_CONFIG_STRMSIZE DefInt(SQLITE_SESSION_CONFIG_STRMSIZE); DefInt(SQLITE_SESSION_OBJCONFIG_SIZE); +#endif } _DefGroup; DefGroup(sqlite3Status){ diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index 42df139296..1f0d9e2ad0 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -42,6 +42,7 @@ fiddle.emcc-flags = \ -sEXPORTED_FUNCTIONS=@$(abspath $(EXPORTED_FUNCTIONS.fiddle)) \ -sEXPORTED_RUNTIME_METHODS=FS,wasmMemory \ $(SQLITE_OPT) $(SHELL_OPT) \ + -USQLITE_WASM_MINIMAL \ -DSQLITE_SHELL_FIDDLE # -D_POSIX_C_SOURCE is needed for strdup() with emcc diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 6cdd0bddd5..cf97208b99 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2761,7 +2761,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; })/* commit/rollback/update hooks */ .t({ name: "sqlite3_preupdate_hook()", - predicate: ()=>wasm.bigIntEnabled || "Pre-update hook requires int64", + predicate: ()=>capi.sqlite3_preupdate_hook || "Missing pre-update hook API", test: function(sqlite3){ const db = new sqlite3.oo1.DB(':memory:', 1 ? 'c' : 'ct'); const countHook = Object.create(null); @@ -2832,7 +2832,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.g('Session API') .t({ name: 'Session API sanity checks', - predicate: ()=>!!capi.sqlite3changegroup_add, + predicate: ()=>!!capi.sqlite3changegroup_add || "Missing session API", test: function(sqlite3){ //warn("The session API tests could use some expansion."); const db1 = new sqlite3.oo1.DB(), db2 = new sqlite3.oo1.DB(); @@ -3299,6 +3299,17 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.g('Bug Reports') .t({ name: 'Delete via bound parameter in subquery', + predicate: function(sqlite3){ + const d = new sqlite3.oo1.DB(); + try{ + d.exec("create virtual table f using fts5(x)"); + return true; + }catch(e){ + return "FTS5 is not available"; + }finally{ + d.close(); + } + }, test: function(sqlite3){ // Testing https://sqlite.org/forum/forumpost/40ce55bdf5 // with the exception that that post uses "external content" diff --git a/manifest b/manifest index bccfb3c0a2..c5b9997bdc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\spercentile\sextension\sto\sthe\sCLI\sby\sdefault. -D 2024-07-24T13:53:51.649 +C Restructuring\sof\sthe\swasm\sbuild\sto\ssupport\san\sexperimental\s'minimal'\sbuild\smode\swhich\selides\sall\snon-core\sAPIs. +D 2024-07-24T22:07:18.372 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -593,7 +593,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 2c801a86137734683966c0fe7e29d2317fdd14b8de8a24289085324213119d3f +F ext/wasm/GNUmakefile 3940f4e685f8a8b521afaed02bb9dbc9058540a918b7d37ba02bd35c6e359765 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -601,8 +601,10 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 5265b1f090d232a4402425f5307f389ab51830c02d91c8c2ce6208647f242164 +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 8f5f661fbe853cf830337c549d81dfafc7836e4d3cf1c042a4262c1627866c06 w ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate d1d62a2212099f2c0782d730beb8cb84a7a52d99c15ead2cb9b1411fff5fd6b1 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session 213b6c04267cb9bd760172db011eb1650732805fb3d01f9395478a8ceec18eb0 F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 F ext/wasm/api/extern-post-js.c-pp.js c4154a7f90c2d7e51fd6738273908152036c3457fdc0b6523f1be3ef51105aac @@ -611,7 +613,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 21a0f8c1e4b4675b6563759c74bef954ac36aa99acce79c56802b661429f43d0 +F ext/wasm/api/sqlite3-api-glue.c-pp.js ba759315ee7a7cf8e60d8fb0c1a4ce2bb735d54e19d8797b5afd13237784101c F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -621,7 +623,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 -F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c +F ext/wasm/api/sqlite3-wasm.c 2f795a9689e7c28616a74969be84f567f59a641ba08e5ade0697faf1ba3dad48 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -644,7 +646,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make 42b18ba889c103aa072c6193b135953b1808d1a7aa9930644dae44682da7592b +F ext/wasm/fiddle.make 2406b02473878a99fb6a2eaff0923277017adc45eb041b2afb2d7707bf7b375c F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 F ext/wasm/fiddle/index.html 739e0b75bc592679665d25e2f7649d2b8b2db678f3b41a772a8720b609b8482d @@ -667,7 +669,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 052b0c7c1039a2ae787d8c447d782182ed6e2807d0b0ee975c396c911d42e7fc +F ext/wasm/tester1.c-pp.js dd5f9cefd5d99cca5c5f415c0f6b6afafb40a0aa6cf544aa0d167c5928f41056 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2195,8 +2197,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 095c22e62248f8ef50cd8531171827f50a7bdd4fc1128bf0e616a3eb2dce980e -R 76e7f4761efc98a28727d2a1442d8c13 -U drh -Z 956d236c4ff2c748d10dde2ade86c2ae +P bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04 +R f16b6030874c752d822201bd54acf1fe +U stephan +Z b5a8cea365fa73a1ac2818f134bd3edc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c7d267a281..29c8b9a12e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04 +ee2191f7302210100fa0b29ace8156531ad995bf61aa2642e526e0901d0c6862 From b16c2980b37006f433341dd4d726fcf3e1e64808 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 24 Jul 2024 23:58:28 +0000 Subject: [PATCH 0561/1030] wasm minimal build: strip authorizers and JSON support (saves approx 35kb). Strip vtab support from the JS bits but cannot yet strip it from the C bits because that requires a custom-configured sqlite3.c. FossilOrigin-Name: eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0 --- ext/wasm/GNUmakefile | 4 +- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth | 1 + ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core | 4 - ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab | 11 ++ ext/wasm/api/sqlite3-api-glue.c-pp.js | 112 +++++++++++-------- ext/wasm/api/sqlite3-vtab-helper.c-pp.js | 6 +- ext/wasm/api/sqlite3-wasm.c | 65 ++++++++--- ext/wasm/tester1.c-pp.js | 5 +- manifest | 24 ++-- manifest.uuid | 2 +- 10 files changed, 153 insertions(+), 81 deletions(-) create mode 100644 ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth create mode 100644 ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index d9ca75d0a5..51531627b9 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -428,8 +428,10 @@ ifeq (1,$(SQLITE_C_IS_SEE)) endif ifeq (0,$(minimal)) EXPORTED_FUNCTIONS.api.in += \ + $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-auth) \ + $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-preupdate) \ $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-session) \ - $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-preupdate) + $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-vtab) else $(info ========================================) $(info This is a minimal-mode build) diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth new file mode 100644 index 0000000000..085090821b --- /dev/null +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth @@ -0,0 +1 @@ +_sqlite3_set_authorizer diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core index ce703666fe..db47ee7db1 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core @@ -41,8 +41,6 @@ _sqlite3_create_collation _sqlite3_create_collation_v2 _sqlite3_create_function _sqlite3_create_function_v2 -_sqlite3_create_module -_sqlite3_create_module_v2 _sqlite3_create_window_function _sqlite3_data_count _sqlite3_db_filename @@ -50,7 +48,6 @@ _sqlite3_db_handle _sqlite3_db_name _sqlite3_db_readonly _sqlite3_db_status -_sqlite3_declare_vtab _sqlite3_deserialize _sqlite3_drop_modules _sqlite3_errcode @@ -106,7 +103,6 @@ _sqlite3_result_zeroblob _sqlite3_result_zeroblob64 _sqlite3_rollback_hook _sqlite3_serialize -_sqlite3_set_authorizer _sqlite3_set_auxdata _sqlite3_set_last_insert_rowid _sqlite3_shutdown diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab new file mode 100644 index 0000000000..1f6de96823 --- /dev/null +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab @@ -0,0 +1,11 @@ +_sqlite3_create_module +_sqlite3_create_module_v2 +_sqlite3_declare_vtab +_sqlite3_vtab_collation +_sqlite3_vtab_distinct +_sqlite3_vtab_in +_sqlite3_vtab_in_first +_sqlite3_vtab_in_next +_sqlite3_vtab_nochange +_sqlite3_vtab_on_conflict +_sqlite3_vtab_rhs_value diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index 3e8643ad30..e5eb0cfeb6 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -244,26 +244,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }), '*' ]], - ["sqlite3_set_authorizer", "int", [ - "sqlite3*", - new wasm.xWrap.FuncPtrAdapter({ - name: "sqlite3_set_authorizer::xAuth", - signature: "i(pi"+"ssss)", - contextKey: (argv, argIndex)=>argv[0/*(sqlite3*)*/], - callProxy: (callback)=>{ - return (pV, iCode, s0, s1, s2, s3)=>{ - try{ - s0 = s0 && wasm.cstrToJs(s0); s1 = s1 && wasm.cstrToJs(s1); - s2 = s2 && wasm.cstrToJs(s2); s3 = s3 && wasm.cstrToJs(s3); - return callback(pV, iCode, s0, s1, s2, s3) || 0; - }catch(e){ - return e.resultCode || capi.SQLITE_ERROR; - } - } - } - }), - "*"/*pUserData*/ - ]], ["sqlite3_set_auxdata", undefined, [ "sqlite3_context*", "int", "*", new wasm.xWrap.FuncPtrAdapter({ @@ -278,8 +258,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_status", "int", "int", "*", "*", "int"], ["sqlite3_step", "int", "sqlite3_stmt*"], ["sqlite3_stmt_busy", "int", "sqlite3_stmt*"], - ["sqlite3_stmt_explain", "int", "sqlite3_stmt*", "int"], - ["sqlite3_stmt_isexplain", "int", "sqlite3_stmt*"], ["sqlite3_stmt_readonly", "int", "sqlite3_stmt*"], ["sqlite3_stmt_status", "int", "sqlite3_stmt*", "int", "int"], ["sqlite3_strglob", "int", "string","string"], @@ -325,6 +303,38 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_vfs_unregister", "int", "sqlite3_vfs*"] ]/*wasm.bindingSignatures*/; + if( !!wasm.exports.sqlite3_stmt_explain ){ + wasm.bindingSignatures.push( + ["sqlite3_stmt_explain", "int", "sqlite3_stmt*", "int"], + ["sqlite3_stmt_isexplain", "int", "sqlite3_stmt*"] + ); + } + + if( !!wasm.exports.sqlite3_set_authorizer ){ + wasm.bindingSignatures.push( + ["sqlite3_set_authorizer", "int", [ + "sqlite3*", + new wasm.xWrap.FuncPtrAdapter({ + name: "sqlite3_set_authorizer::xAuth", + signature: "i(pi"+"ssss)", + contextKey: (argv, argIndex)=>argv[0/*(sqlite3*)*/], + callProxy: (callback)=>{ + return (pV, iCode, s0, s1, s2, s3)=>{ + try{ + s0 = s0 && wasm.cstrToJs(s0); s1 = s1 && wasm.cstrToJs(s1); + s2 = s2 && wasm.cstrToJs(s2); s3 = s3 && wasm.cstrToJs(s3); + return callback(pV, iCode, s0, s1, s2, s3) || 0; + }catch(e){ + return e.resultCode || capi.SQLITE_ERROR; + } + } + } + }), + "*"/*pUserData*/ + ]] + ); + }/* sqlite3_set_authorizer() */ + if(false && wasm.compileOptionUsed('SQLITE_ENABLE_NORMALIZE')){ /* ^^^ "the problem" is that this is an option feature and the build-time function-export list does not currently take @@ -367,11 +377,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_bind_int64","int", ["sqlite3_stmt*", "int", "i64"]], ["sqlite3_changes64","i64", ["sqlite3*"]], ["sqlite3_column_int64","i64", ["sqlite3_stmt*", "int"]], - ["sqlite3_create_module", "int", - ["sqlite3*","string","sqlite3_module*","*"]], - ["sqlite3_create_module_v2", "int", - ["sqlite3*","string","sqlite3_module*","*","*"]], - ["sqlite3_declare_vtab", "int", ["sqlite3*", "string:flexible"]], ["sqlite3_deserialize", "int", "sqlite3*", "string", "*", "i64", "i64", "int"] /* Careful! Short version: de/serialize() are problematic because they might use a different allocator than the user for managing the @@ -407,19 +412,29 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ "*" ]], ["sqlite3_uri_int64", "i64", ["sqlite3_filename", "string", "i64"]], - ["sqlite3_value_int64","i64", "sqlite3_value*"], - ["sqlite3_vtab_collation","string","sqlite3_index_info*","int"], - ["sqlite3_vtab_distinct","int", "sqlite3_index_info*"], - ["sqlite3_vtab_in","int", "sqlite3_index_info*", "int", "int"], - ["sqlite3_vtab_in_first", "int", "sqlite3_value*", "**"], - ["sqlite3_vtab_in_next", "int", "sqlite3_value*", "**"], - /*["sqlite3_vtab_config" is variadic and requires a hand-written - proxy.] */ - ["sqlite3_vtab_nochange","int", "sqlite3_context*"], - ["sqlite3_vtab_on_conflict","int", "sqlite3*"], - ["sqlite3_vtab_rhs_value","int", "sqlite3_index_info*", "int", "**"] + ["sqlite3_value_int64","i64", "sqlite3_value*"] ]; + if( wasm.bigIntEnabled && !!wasm.exports.sqlite3_declare_vtab ){ + wasm.bindingSignatures.int64.push( + ["sqlite3_create_module", "int", + ["sqlite3*","string","sqlite3_module*","*"]], + ["sqlite3_create_module_v2", "int", + ["sqlite3*","string","sqlite3_module*","*","*"]], + ["sqlite3_declare_vtab", "int", ["sqlite3*", "string:flexible"]], + ["sqlite3_vtab_collation","string","sqlite3_index_info*","int"], + ["sqlite3_vtab_distinct","int", "sqlite3_index_info*"], + ["sqlite3_vtab_in","int", "sqlite3_index_info*", "int", "int"], + ["sqlite3_vtab_in_first", "int", "sqlite3_value*", "**"], + ["sqlite3_vtab_in_next", "int", "sqlite3_value*", "**"], + /*["sqlite3_vtab_config" is variadic and requires a hand-written + proxy.] */ + ["sqlite3_vtab_nochange","int", "sqlite3_context*"], + ["sqlite3_vtab_on_conflict","int", "sqlite3*"], + ["sqlite3_vtab_rhs_value","int", "sqlite3_index_info*", "int", "**"] + ); + }/* virtual table APIs */ + if(wasm.bigIntEnabled && !!wasm.exports.sqlite3_preupdate_hook){ wasm.bindingSignatures.int64.push( ["sqlite3_preupdate_blobwrite", "int", "sqlite3*"], @@ -725,12 +740,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ('sqlite3*', (v)=> __xArgPtr((v instanceof (sqlite3?.oo1?.DB || nilType)) ? v.pointer : v)) - ('sqlite3_index_info*', (v)=> - __xArgPtr((v instanceof (capi.sqlite3_index_info || nilType)) - ? v.pointer : v)) - ('sqlite3_module*', (v)=> - __xArgPtr((v instanceof (capi.sqlite3_module || nilType)) - ? v.pointer : v)) /** `sqlite3_vfs*`: @@ -753,6 +762,15 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return __xArgPtr((v instanceof (capi.sqlite3_vfs || nilType)) ? v.pointer : v); }); + if( wasm.exports.sqlite3_declare_vtab ){ + wasm.xWrap.argAdapter('sqlite3_index_info*', (v)=> + __xArgPtr((v instanceof (capi.sqlite3_index_info || nilType)) + ? v.pointer : v)) + ('sqlite3_module*', (v)=> + __xArgPtr((v instanceof (capi.sqlite3_module || nilType)) + ? v.pointer : v) + ); + } const __xRcPtr = wasm.xWrap.resultAdapter('*'); wasm.xWrap.resultAdapter('sqlite3*', __xRcPtr) @@ -1031,12 +1049,16 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ 'sqlite3_update_hook' ]) { const x = wasm.exports[name]; + if( !x ){ + /* assume it was built without this API */ + continue; + } closeArgs.length = x.length/*==argument count*/ /* recall that undefined entries translate to 0 when passed to WASM. */; try{ capi[name](...closeArgs) } catch(e){ - console.warn("close-time call of",name+"(",closeArgs,") threw:",e); + sqlite3.config.warn("close-time call of",name+"(",closeArgs,") threw:",e); } } const m = __dbCleanupMap(pDb, 0); diff --git a/ext/wasm/api/sqlite3-vtab-helper.c-pp.js b/ext/wasm/api/sqlite3-vtab-helper.c-pp.js index 7359ea39aa..d78fbdbf37 100644 --- a/ext/wasm/api/sqlite3-vtab-helper.c-pp.js +++ b/ext/wasm/api/sqlite3-vtab-helper.c-pp.js @@ -11,10 +11,14 @@ /** This file installs sqlite3.vtab, a namespace of helpers for use in - the creation of JavaScript implementations virtual tables. + the creation of JavaScript implementations virtual tables. If built + without virtual table support then this function does nothing. */ 'use strict'; globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ + if( !sqlite3.wasm.exports.sqlite3_declare_vtab ){ + return; + } const wasm = sqlite3.wasm, capi = sqlite3.capi, toss = sqlite3.util.toss3; const vtab = Object.create(null); sqlite3.vtab = vtab; diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index c755662791..7f7e696899 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -129,22 +129,6 @@ # define SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION #endif -/* -** If SQLITE_WASM_MINIMAL is defined, undefine most of the ENABLE -** macros. -*/ -#ifdef SQLITE_WASM_MINIMAL -# undef SQLITE_ENABLE_DBPAGE_VTAB -# undef SQLITE_ENABLE_DBSTAT_VTAB -# undef SQLITE_ENABLE_EXPLAIN_COMMENTS -# undef SQLITE_ENABLE_FTS5 -# undef SQLITE_ENABLE_OFFSET_SQL_FUNC -# undef SQLITE_ENABLE_PREUPDATE_HOOK -# undef SQLITE_ENABLE_RTREE -# undef SQLITE_ENABLE_SESSION -# undef SQLITE_ENABLE_STMTVTAB -#endif - /**********************************************************************/ /* SQLITE_O... */ #ifndef SQLITE_OMIT_DEPRECATED @@ -188,6 +172,48 @@ # define SQLITE_EXTRA_INIT sqlite3_wasm_extra_init #endif +/* +** If SQLITE_WASM_MINIMAL is defined, undefine most of the ENABLE +** macros. +*/ +#ifdef SQLITE_WASM_MINIMAL +# undef SQLITE_ENABLE_DBPAGE_VTAB +# undef SQLITE_ENABLE_DBSTAT_VTAB +# undef SQLITE_ENABLE_EXPLAIN_COMMENTS +# undef SQLITE_ENABLE_FTS5 +# undef SQLITE_ENABLE_OFFSET_SQL_FUNC +# undef SQLITE_ENABLE_PREUPDATE_HOOK +# undef SQLITE_ENABLE_RTREE +# undef SQLITE_ENABLE_SESSION +# undef SQLITE_ENABLE_STMTVTAB +# undef SQLITE_OMIT_AUTHORIZATION +# define SQLITE_OMIT_AUTHORIZATION +/*Reminder re. custom sqlite3.c: + + fossil clean -x + ./configure + OPTS='-DSQLITE_OMIT_VIRTUALTABLE -DSQLITE_OMIT_EXPLAIN -DSQLITE_OMIT_TRIGGER' make -e sqlite3 +*/ +/*Requires a custom sqlite3.c +# undef SQLITE_OMIT_TRIGGER +# define SQLITE_OMIT_TRIGGER +*/ +/*TODO (requires build tweaks) +# undef SQLITE_OMIT_WINDOWFUNC +# define SQLITE_OMIT_WINDOWFUNC +*/ +/*Requires a custom sqlite3.c +# undef SQLITE_OMIT_EXPLAIN +# define SQLITE_OMIT_EXPLAIN +*/ +/*Requires a custom sqlite3.c +# undef SQLITE_OMIT_VIRTUALTABLE +# define SQLITE_OMIT_VIRTUALTABLE +*/ +# undef SQLITE_OMIT_JSON +# define SQLITE_OMIT_JSON +#endif + #include /* @@ -941,6 +967,7 @@ const char * sqlite3__wasm_enum_json(void){ } _DefGroup; DefGroup(vtab) { +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL) DefInt(SQLITE_INDEX_SCAN_UNIQUE); DefInt(SQLITE_INDEX_CONSTRAINT_EQ); DefInt(SQLITE_INDEX_CONSTRAINT_GT); @@ -968,6 +995,7 @@ const char * sqlite3__wasm_enum_json(void){ DefInt(SQLITE_FAIL); //DefInt(SQLITE_ABORT); // Also an error code DefInt(SQLITE_REPLACE); +#endif /*!SQLITE_OMIT_VIRTUALTABLE*/ } _DefGroup; #undef DefGroup @@ -1127,6 +1155,7 @@ const char * sqlite3__wasm_enum_json(void){ } _StructBinder; #undef CurrentStruct +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL) /** ** Workaround: in order to map the various inner structs from ** sqlite3_index_info, we have to uplift those into constructs we @@ -1203,6 +1232,8 @@ const char * sqlite3__wasm_enum_json(void){ } _StructBinder; #undef CurrentStruct +#endif /*!SQLITE_OMIT_VIRTUALTABLE*/ + #if SQLITE_WASM_TESTS #define CurrentStruct WasmTestStruct StructBinder { @@ -1572,6 +1603,7 @@ sqlite3_kvvfs_methods * sqlite3__wasm_kvvfs_methods(void){ return &sqlite3KvvfsMethods; } +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL) /* ** This function is NOT part of the sqlite3 public API. It is strictly ** for use by the sqlite project's own JS/WASM bindings. @@ -1594,6 +1626,7 @@ int sqlite3__wasm_vtab_config(sqlite3 *pDb, int op, int arg){ return SQLITE_MISUSE; } } +#endif /*!SQLITE_OMIT_VIRTUALTABLE*/ /* ** This function is NOT part of the sqlite3 public API. It is strictly diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index cf97208b99..c49a82d36e 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -1510,6 +1510,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////// .t({ name: "sqlite3_set_authorizer()", + predicate: ()=>!!wasm.exports.sqlite3_set_authorizer || "Missing sqlite3_set_authorizer()", test:function(sqlite3){ T.assert(capi.SQLITE_IGNORE>0) .assert(capi.SQLITE_DENY>0); @@ -2152,7 +2153,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////////// .t({ name: 'virtual table #1: eponymous w/ manual exception handling', - predicate: ()=>!!capi.sqlite3_index_info, + predicate: ()=>!!capi.sqlite3_create_module || "Missing vtab support", test: function(sqlite3){ const VT = sqlite3.vtab; const tmplCols = Object.assign(Object.create(null),{ @@ -2349,7 +2350,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////////// .t({ name: 'virtual table #2: non-eponymous w/ automated exception wrapping', - predicate: ()=>!!capi.sqlite3_index_info, + predicate: ()=>!!capi.sqlite3_create_module || "Missing vtab support", test: function(sqlite3){ const VT = sqlite3.vtab; const tmplCols = Object.assign(Object.create(null),{ diff --git a/manifest b/manifest index c5b9997bdc..608c658c9e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Restructuring\sof\sthe\swasm\sbuild\sto\ssupport\san\sexperimental\s'minimal'\sbuild\smode\swhich\selides\sall\snon-core\sAPIs. -D 2024-07-24T22:07:18.372 +C wasm\sminimal\sbuild:\sstrip\sauthorizers\sand\sJSON\ssupport\s(saves\sapprox\s35kb).\sStrip\svtab\ssupport\sfrom\sthe\sJS\sbits\sbut\scannot\syet\sstrip\sit\sfrom\sthe\sC\sbits\sbecause\sthat\srequires\sa\scustom-configured\ssqlite3.c. +D 2024-07-24T23:58:28.415 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -593,7 +593,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 3940f4e685f8a8b521afaed02bb9dbc9058540a918b7d37ba02bd35c6e359765 +F ext/wasm/GNUmakefile d4f6586d9a36ee2869a8c7f77227a8b7f42b6c4623f3be594beafb1554ab20d9 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -601,10 +601,12 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 8f5f661fbe853cf830337c549d81dfafc7836e4d3cf1c042a4262c1627866c06 w ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth 7ac80cc3b6a6d52e041bb295e85555ce797be78c15ef2008a64ae58815014080 +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 400213eb52a7e5ad5f448053d375cacf4dac2cf45d134f3edfe485ae4a49a183 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate d1d62a2212099f2c0782d730beb8cb84a7a52d99c15ead2cb9b1411fff5fd6b1 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session 213b6c04267cb9bd760172db011eb1650732805fb3d01f9395478a8ceec18eb0 +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab fd57af1f4502a052be27d8402df74be1dc60fcb6a687d372972abd90e424120a F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 F ext/wasm/api/extern-post-js.c-pp.js c4154a7f90c2d7e51fd6738273908152036c3457fdc0b6523f1be3ef51105aac @@ -613,7 +615,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js ba759315ee7a7cf8e60d8fb0c1a4ce2bb735d54e19d8797b5afd13237784101c +F ext/wasm/api/sqlite3-api-glue.c-pp.js 54b32b5321105a72d6f3d3e8b77f28f162d0367b08c63184263d3f85f3d7dbed F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -622,8 +624,8 @@ F ext/wasm/api/sqlite3-opfs-async-proxy.js e8f1df56e97a29004a95a2eddd26778f52c33 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 -F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 -F ext/wasm/api/sqlite3-wasm.c 2f795a9689e7c28616a74969be84f567f59a641ba08e5ade0697faf1ba3dad48 +F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 +F ext/wasm/api/sqlite3-wasm.c 09a938fc570f282e602acd111147c7b74b5332da72540c512a79b916ab57882a F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -669,7 +671,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js dd5f9cefd5d99cca5c5f415c0f6b6afafb40a0aa6cf544aa0d167c5928f41056 +F ext/wasm/tester1.c-pp.js a88b9c669715adc1c5e76750ca8c0994ae33d04572e3bf295b6f4f5870f3bdf3 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2197,8 +2199,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04 -R f16b6030874c752d822201bd54acf1fe +P ee2191f7302210100fa0b29ace8156531ad995bf61aa2642e526e0901d0c6862 +R 72e8c79f1e4399a95154f130ea5870d2 U stephan -Z b5a8cea365fa73a1ac2818f134bd3edc +Z 427f56307156eafbb2685aac023af7a2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 29c8b9a12e..01abe9750d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ee2191f7302210100fa0b29ace8156531ad995bf61aa2642e526e0901d0c6862 +eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0 From cc65612e35a677dc7252229dadaba92b6d3997b0 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 25 Jul 2024 10:50:45 +0000 Subject: [PATCH 0562/1030] Start work on an overhaul of the wasm build process, with an eye towards less over-engineering. FossilOrigin-Name: ed746b3dd3248b68cb91de50ac5ba5fd3a7c2fcbde76324e86b88edbfecd896b --- ext/wasm/GNUmakefile | 140 +++++------------- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth | 1 - ...sion => EXPORTED_FUNCTIONS.sqlite3-extras} | 18 +++ .../api/EXPORTED_FUNCTIONS.sqlite3-preupdate | 6 - ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab | 11 -- ext/wasm/api/sqlite3-api-glue.c-pp.js | 2 +- ext/wasm/make-make.sh | 84 +++++++++++ ext/wasm/tester1.c-pp.js | 12 +- ext/wasm/wasmfs.make | 7 - manifest | 27 ++-- manifest.uuid | 2 +- 11 files changed, 158 insertions(+), 152 deletions(-) delete mode 100644 ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth rename ext/wasm/api/{EXPORTED_FUNCTIONS.sqlite3-session => EXPORTED_FUNCTIONS.sqlite3-extras} (72%) delete mode 100644 ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate delete mode 100644 ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab create mode 100755 ext/wasm/make-make.sh diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 51531627b9..2d5abebc46 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -54,6 +54,7 @@ MAKEFILE := $(lastword $(MAKEFILE_LIST)) CLEAN_FILES := DISTCLEAN_FILES := ./--dummy-- release: oz +MAKING_CLEAN := $(if $(filter %clean,$(MAKECMDGOALS)),1,0) ######################################################################## # JS_BUILD_NAMES exists for documentation purposes only. It enumerates @@ -86,46 +87,6 @@ JS_BUILD_NAMES := sqlite3 sqlite3-wasmfs # JS_BUILD_MODES := vanilla esm bunder-friendly node -######################################################################## -# Emscripten SDK home dir and related binaries... -EMSDK_HOME ?= $(word 1,$(wildcard $(HOME)/emsdk $(HOME)/src/emsdk)) -emcc.bin ?= $(word 1,$(wildcard $(EMSDK_HOME)/upstream/emscripten/emcc) $(shell which emcc)) -ifeq (,$(emcc.bin)) - $(error Cannot find emcc.) -endif -emcc.version := $(shell "$(emcc.bin)" --version | sed -n 1p \ - | sed -e 's/^.* \([3-9][^ ]*\) .*$$/\1/;') -ifeq (,$(emcc.version)) - $(warning Cannot determine emcc version. This might unduly impact build flags.) -else - $(info using emcc version [$(emcc.version)]) -endif - -wasm-strip ?= $(shell which wasm-strip 2>/dev/null) -ifeq (,$(filter clean,$(MAKECMDGOALS))) -ifeq (,$(wasm-strip)) - $(info WARNING: *******************************************************************) - $(info WARNING: builds using -O2/-O3/-Os/-Oz will minify WASM-exported names,) - $(info WARNING: breaking _All The Things_. The workaround for that is to build) - $(info WARNING: with -g3 (which explodes the file size) and then strip the debug) - $(info WARNING: info after compilation, using wasm-strip, to shrink the wasm file.) - $(info WARNING: wasm-strip was not found in the PATH so we cannot strip those.) - $(info WARNING: If this build uses any optimization level higher than -O1 then) - $(info WARNING: the ***resulting JS code WILL NOT BE USABLE***.) - $(info WARNING: wasm-strip is part of the wabt package:) - $(info WARNING: https://github.com/WebAssembly/wabt) - $(info WARNING: on Ubuntu-like systems it can be installed with:) - $(info WARNING: sudo apt install wabt) - $(info WARNING: *******************************************************************) -endif -endif # 'make clean' check - -ifeq (,$(wasm-strip)) - maybe-wasm-strip = echo "not wasm-stripping" -else - maybe-wasm-strip = $(wasm-strip) -endif - ######################################################################## # dir.top = the top dir of the canonical build tree, where # sqlite3.[ch] live. @@ -141,41 +102,16 @@ dir.common := common dir.fiddle := fiddle dir.fiddle-debug := fiddle-debug dir.tool := $(dir.top)/tool -CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ \ - $(dir.fiddle-debug)/* - -######################################################################## -# dir.dout = output dir for deliverables. -# -# MAINTENANCE REMINDER: the output .js and .wasm files of certain emcc -# buildables must be in _this_ dir, rather than a subdir, or else -# parts of the generated code get confused and cannot load -# property. Specifically, when X.js loads X.wasm, whether or not X.js -# uses the correct path for X.wasm depends on how it's loaded: an HTML -# script tag will resolve it intuitively, whereas a Worker's call to -# importScripts() will not. That's a fundamental incompatibility with -# how URL resolution in JS happens between those two contexts. See: -# -# https://zzz.buzz/2017/03/14/relative-uris-in-web-development/ -# -# We unfortunately have no way, from Worker-initiated code, to -# automatically resolve the path from X.js to X.wasm. -# -# We have an "only slightly unsightly" solution for our main builds -# but it does not work for the WASMFS builds, so those builds have to -# be built to _this_ directory and can only run when the client app is -# loaded from the same directory. -dir.dout := $(dir.wasm)/jswasm +# Maintenance reminder: the names of $(dir.dout) and $(dir.tmp) must +# stay in sync with make-make.sh +# # dir.tmp = output dir for intermediary build files, as opposed to # end-user deliverables. +dir.dout := $(dir.wasm)/jswasm +# dir.dout = output dir for deliverables dir.tmp := $(dir.wasm)/bld -CLEAN_FILES += $(dir.tmp)/* $(dir.dout)/* -ifeq (,$(wildcard $(dir.dout))) - dir._tmp := $(shell mkdir -p $(dir.dout)) -endif -ifeq (,$(wildcard $(dir.tmp))) - dir._tmp := $(shell mkdir -p $(dir.tmp)) -endif +CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ \ + $(dir.fiddle-debug)/* $(dir.dout)/* $(dir.tmp)/* ######################################################################## # Set up sqlite3.c and sqlite3.h... @@ -197,18 +133,33 @@ endif sqlite3.canonical.c := $(dir.top)/sqlite3.c sqlite3.c ?= $(firstword $(wildcard $(dir.top)/sqlite3-see.c) $(sqlite3.canonical.c)) sqlite3.h := $(dir.top)/sqlite3.h -ifeq (,$(shell grep sqlite3_activate_see $(sqlite3.c) 2>/dev/null)) - SQLITE_C_IS_SEE := 0 -else - SQLITE_C_IS_SEE := 1 - $(info This is an SEE build.) + +########################################################################@ +# It's important that sqlite3.h be built to completion before any +# other parts of the build run, thus we use .NOTPARALLEL to disable +# parallel build of that file and its dependants. +.NOTPARALLEL: $(sqlite3.h) +$(sqlite3.h): + $(MAKE) -C $(dir.top) sqlite3.c +$(sqlite3.c): $(sqlite3.h) + +# .cache.make is generated by a shell script and holds certain parts +# of the makefile, some of which are relatively expensive to calculate +# on each run (that is, they can take a human-visible amount of time). +ifeq (0,$(MAKING_CLEAN)) +.cache.make: $(sqlite3.c) $(sqlite3.canonical.c) $(MAKEFILE) make-make.sh + rm -f $@ + $(SHELL) make-make.sh "$(sqlite3.c)" > $@ + chmod -w $@ +-include .cache.make +.cache.make: $(emcc.bin) endif -# Most SQLITE_OPT flags are set in sqlite3-wasm.c but we need them -# made explicit here for building speedtest1.c. +CLEAN_FILES += .cache.make + +# Common options for building sqlite3-wasm.c and speedtest1.c. SQLITE_OPT = \ -DSQLITE_ENABLE_FTS5 \ -DSQLITE_ENABLE_RTREE \ - -DSQLITE_ENABLE_EXPLAIN_COMMENTS \ -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION \ -DSQLITE_ENABLE_STMTVTAB \ -DSQLITE_ENABLE_DBPAGE_VTAB \ @@ -241,15 +192,6 @@ ifeq (1,$(minimal)) SQLITE_OPT += -DSQLITE_WASM_MINIMAL endif -########################################################################@ -# It's important that sqlite3.h be built to completion before any -# other parts of the build run, thus we use .NOTPARALLEL to disable -# parallel build of that file and its dependants. -.NOTPARALLEL: $(sqlite3.h) -$(sqlite3.h): - $(MAKE) -C $(dir.top) sqlite3.c -$(sqlite3.c): $(sqlite3.h) - .PHONY: clean distclean clean: -rm -f $(CLEAN_FILES) @@ -371,7 +313,7 @@ define C-PP.FILTER # $3 = optional c-pp -D... flags $(2): $(1) $$(MAKEFILE) $$(bin.c-pp) $$(bin.c-pp) -f $(1) -o $$@ $(3) $(C-PP.FILTER.global) -CLEAN_FILES += $(2) +#CLEAN_FILES += $(2) endef # /end C-PP.FILTER ######################################################################## @@ -421,17 +363,13 @@ emcc_opt_full := $(emcc_opt) -g3 ######################################################################## # EXPORTED_FUNCTIONS.* = files for use with Emscripten's # -sEXPORTED_FUNCTION flag. -EXPORTED_FUNCTIONS.api.core := $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-core) +EXPORTED_FUNCTIONS.api.core := $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-core EXPORTED_FUNCTIONS.api.in := $(EXPORTED_FUNCTIONS.api.core) ifeq (1,$(SQLITE_C_IS_SEE)) - EXPORTED_FUNCTIONS.api.in += $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-see) + EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-see endif ifeq (0,$(minimal)) - EXPORTED_FUNCTIONS.api.in += \ - $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-auth) \ - $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-preupdate) \ - $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-session) \ - $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-vtab) + EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-extras else $(info ========================================) $(info This is a minimal-mode build) @@ -906,7 +844,7 @@ $(5): $(4) $$(MAKEFILE) $$(sqlite3-wasm.cfiles) $$(EXPORTED_FUNCTIONS.api) $$(pr ls -la $$$$dotwasm $$@ all: $(5) #quick: $(5) -CLEAN_FILES += $(4) $(5) +#CLEAN_FILES += $(4) $(5) endef # ^^^ /SETUP_LIB_BUILD_MODE ######################################################################## @@ -962,7 +900,7 @@ $(sqlite3.wasm): $(sqlite3.js) $(sqlite3.mjs): $(sqlite3.js) $(sqlite3-bundler-friendly.mjs): $(sqlite3.mjs) $(sqlite3-node.mjs): $(sqlite3.mjs) -CLEAN_FILES += $(sqlite3.wasm) +#CLEAN_FILES += $(sqlite3.wasm) ######################################################################## # We need separate copies of certain supplementary JS files for the @@ -1106,7 +1044,7 @@ $(speedtest1.js): $(MAKEFILE) $(speedtest1.cfiles) \ speedtest1: $(speedtest1.js) all: speedtest1 -CLEAN_FILES += $(speedtest1.js) $(speedtest1.wasm) +#CLEAN_FILES += $(speedtest1.js) $(speedtest1.wasm) # end speedtest1.js ######################################################################## @@ -1174,7 +1112,7 @@ wasmfs.enable ?= 1 else # Unconditionally enable wasmfs for [dist]clean so that the wasmfs # sub-make can clean up. -wasmfs.enable ?= $(if $(filter %clean,$(MAKECMDGOALS)),1,0) +wasmfs.enable ?= $(MAKING_CLEAN) endif ifeq (1,$(wasmfs.enable)) # wasmfs build disabled 2022-10-19 per /chat discussion. diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth deleted file mode 100644 index 085090821b..0000000000 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth +++ /dev/null @@ -1 +0,0 @@ -_sqlite3_set_authorizer diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras similarity index 72% rename from ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session rename to ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras index 5b7b53f952..f8af685ed7 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras @@ -1,3 +1,10 @@ +_sqlite3_set_authorizer +_sqlite3_preupdate_blobwrite +_sqlite3_preupdate_count +_sqlite3_preupdate_depth +_sqlite3_preupdate_hook +_sqlite3_preupdate_new +_sqlite3_preupdate_old _sqlite3changegroup_add _sqlite3changegroup_add_strm _sqlite3changegroup_delete @@ -40,3 +47,14 @@ _sqlite3session_object_config _sqlite3session_patchset _sqlite3session_patchset_strm _sqlite3session_table_filter +_sqlite3_create_module +_sqlite3_create_module_v2 +_sqlite3_declare_vtab +_sqlite3_vtab_collation +_sqlite3_vtab_distinct +_sqlite3_vtab_in +_sqlite3_vtab_in_first +_sqlite3_vtab_in_next +_sqlite3_vtab_nochange +_sqlite3_vtab_on_conflict +_sqlite3_vtab_rhs_value diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate deleted file mode 100644 index 5c57a76b60..0000000000 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate +++ /dev/null @@ -1,6 +0,0 @@ -_sqlite3_preupdate_blobwrite -_sqlite3_preupdate_count -_sqlite3_preupdate_depth -_sqlite3_preupdate_hook -_sqlite3_preupdate_new -_sqlite3_preupdate_old diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab deleted file mode 100644 index 1f6de96823..0000000000 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab +++ /dev/null @@ -1,11 +0,0 @@ -_sqlite3_create_module -_sqlite3_create_module_v2 -_sqlite3_declare_vtab -_sqlite3_vtab_collation -_sqlite3_vtab_distinct -_sqlite3_vtab_in -_sqlite3_vtab_in_first -_sqlite3_vtab_in_next -_sqlite3_vtab_nochange -_sqlite3_vtab_on_conflict -_sqlite3_vtab_rhs_value diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index e5eb0cfeb6..55dd300d74 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -336,7 +336,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }/* sqlite3_set_authorizer() */ if(false && wasm.compileOptionUsed('SQLITE_ENABLE_NORMALIZE')){ - /* ^^^ "the problem" is that this is an option feature and the + /* ^^^ "the problem" is that this is an optional feature and the build-time function-export list does not currently take optional features into account. */ wasm.bindingSignatures.push(["sqlite3_normalized_sql", "string", "sqlite3_stmt*"]); diff --git a/ext/wasm/make-make.sh b/ext/wasm/make-make.sh new file mode 100755 index 0000000000..e5b81b3d12 --- /dev/null +++ b/ext/wasm/make-make.sh @@ -0,0 +1,84 @@ +#!/usr/bin/bash +######################################################################## +# Emits the makefile code for .cache.make. Any makefile bits which are +# potentially expensive to calculate on every build but rarely change +# should be emitted from here. +# +# Arguments: +# +# $1 = path to sqlite3.c. Default: ../../sqlite3.c +# +######################################################################## + +function die(){ + local rc=$1 + shift + echo "\$(error $0 failed: $@)" + # ^^^ Ensure that if this output is being redirected, the + # resulting makefile will fail loudly instead of just being + # truncated. + echo "Error: $@" 1>&2 + exit $rc +} + +SQLITE3_C="${1-../../sqlite3.c}" + +echo "# GENERATED makefile code. DO NOT EDIT." + +if grep sqlite3_activate_see "$SQLITE3_C" &>/dev/null; then + echo 'SQLITE_C_IS_SEE := 1' + echo '$(info This is an SEE build)' +else + echo 'SQLITE_C_IS_SEE := 0' +fi + +######################################################################## +# Locate the emcc (Emscripten) binary... +EMCC_BIN=$(which emcc) +if [[ x = "x${EMCC_BIN}" ]]; then + if [[ x != "x${EMSDK_HOME}" ]]; then + EMCC_BIN="${EMSDK_HOME}/upstream/emscripten/emcc" + fi +fi +if [[ x = "x${EMCC_BIN}" ]]; then + die 1 "Cannot find emcc binary in PATH or EMSDK_HOME." +fi +[[ -x "${EMCC_BIN}" ]] || die 1 "emcc is not executable" +echo "emcc.bin := ${EMCC_BIN}" +echo "emcc.version :=" $("${EMCC_BIN}" --version | sed -n 1p \ + | sed -e 's/^.* \([3-9][^ ]*\) .*$/\1/;') +echo '$(info using emcc version [$(emcc.version)])' + +######################################################################### +# wasm-strip binary... +WASM_STRIP_BIN=$(which wasm-strip 2>/dev/null) +echo "wasm-strip ?= ${WASM_STRIP_BIN}" +if [[ x = "x${WASM_STRIP_BIN}" ]]; then +cat <wasm.compileOptionUsed('ENABLE_FTS5') || "FTS5 is not available", test: function(sqlite3){ // Testing https://sqlite.org/forum/forumpost/40ce55bdf5 // with the exception that that post uses "external content" diff --git a/ext/wasm/wasmfs.make b/ext/wasm/wasmfs.make index 71c0fe75a8..2bd7a0700b 100644 --- a/ext/wasm/wasmfs.make +++ b/ext/wasm/wasmfs.make @@ -14,11 +14,6 @@ sqlite3-wasmfs.js := $(dir.wasmfs)/sqlite3-wasmfs.js sqlite3-wasmfs.mjs := $(dir.wasmfs)/sqlite3-wasmfs.mjs sqlite3-wasmfs.wasm := $(dir.wasmfs)/sqlite3-wasmfs.wasm -CLEAN_FILES += $(sqlite3-wasmfs.js) $(sqlite3-wasmfs.wasm) \ - $(subst .js,.worker.js,$(sqlite3-wasmfs.js)) \ - $(sqlite3-wasmfs.mjs) \ - $(subst .mjs,.worker.mjs,$(sqlite3-wasmfs.mjs)) - ######################################################################## # emcc flags for .c/.o. cflags.sqlite3-wasmfs := @@ -109,7 +104,5 @@ $(speedtest1-wasmfs.mjs): $(speedtest1.cfiles) $(sqlite3-wasmfs.js) \ ls -la $@ $(speedtest1-wasmfs.wasm) wasmfs: $(speedtest1-wasmfs.mjs) -CLEAN_FILES += $(speedtest1-wasmfs.mjs) $(speedtest1-wasmfs.wasm) \ - $(subst .js,.worker.js,$(speedtest1-wasmfs.mjs)) # end speedtest1.js ######################################################################## diff --git a/manifest b/manifest index 608c658c9e..f53748e088 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C wasm\sminimal\sbuild:\sstrip\sauthorizers\sand\sJSON\ssupport\s(saves\sapprox\s35kb).\sStrip\svtab\ssupport\sfrom\sthe\sJS\sbits\sbut\scannot\syet\sstrip\sit\sfrom\sthe\sC\sbits\sbecause\sthat\srequires\sa\scustom-configured\ssqlite3.c. -D 2024-07-24T23:58:28.415 +C Start\swork\son\san\soverhaul\sof\sthe\swasm\sbuild\sprocess,\swith\san\seye\stowards\sless\sover-engineering. +D 2024-07-25T10:50:45.547 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -593,7 +593,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile d4f6586d9a36ee2869a8c7f77227a8b7f42b6c4623f3be594beafb1554ab20d9 +F ext/wasm/GNUmakefile 2037399f1a33f8c0bab52e5aba78d4c6b6d9fb8d905ddf5fc3dd10f2a6fdb494 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -601,12 +601,9 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth 7ac80cc3b6a6d52e041bb295e85555ce797be78c15ef2008a64ae58815014080 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 400213eb52a7e5ad5f448053d375cacf4dac2cf45d134f3edfe485ae4a49a183 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate d1d62a2212099f2c0782d730beb8cb84a7a52d99c15ead2cb9b1411fff5fd6b1 +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras e9a42a86d1e09cfd46fd22438e0cb9449e6eae2eff39597cdc834c183775286a w ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session 213b6c04267cb9bd760172db011eb1650732805fb3d01f9395478a8ceec18eb0 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab fd57af1f4502a052be27d8402df74be1dc60fcb6a687d372972abd90e424120a F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 F ext/wasm/api/extern-post-js.c-pp.js c4154a7f90c2d7e51fd6738273908152036c3457fdc0b6523f1be3ef51105aac @@ -615,7 +612,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 54b32b5321105a72d6f3d3e8b77f28f162d0367b08c63184263d3f85f3d7dbed +F ext/wasm/api/sqlite3-api-glue.c-pp.js 30abfbb9ed4b6732e2fd78dbfedee5f8d7a395a6d38f140f8df19bd9c30b4191 F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -656,6 +653,7 @@ F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29a F ext/wasm/index.html 4337f495416756802669f69f9f9f3df9f87ee4c1918e6718719b4b5718e4713a F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 +F ext/wasm/make-make.sh 93fa6d00f0ffa3481badd068b8da8ed5825cf74999d5e54b2a0c9b90579a3056 x F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -671,11 +669,11 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js a88b9c669715adc1c5e76750ca8c0994ae33d04572e3bf295b6f4f5870f3bdf3 +F ext/wasm/tester1.c-pp.js b5a126b7ae3f3b5628e74ca806f65394f309326dd518831b2186f88850439be2 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 -F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966f1bc16a +F ext/wasm/wasmfs.make e508db7fb82653a9c9d3c7f4e2c75010abfdefa5c413a9603a2c59547bec8709 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 @@ -2199,8 +2197,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ee2191f7302210100fa0b29ace8156531ad995bf61aa2642e526e0901d0c6862 -R 72e8c79f1e4399a95154f130ea5870d2 +P eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0 +R 5dcb0158c3e9e326c7d4eacaa8552ecf +T *branch * wasm-build-rework +T *sym-wasm-build-rework * +T -sym-trunk * Cancelled\sby\sbranch. U stephan -Z 427f56307156eafbb2685aac023af7a2 +Z 6b2b2a8483fc393f764799aae3eb47aa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 01abe9750d..9d68627d41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0 +ed746b3dd3248b68cb91de50ac5ba5fd3a7c2fcbde76324e86b88edbfecd896b From 520d1a84867fa59e063b66a276471cbfc9f6cef5 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 25 Jul 2024 14:00:26 +0000 Subject: [PATCH 0563/1030] More work on the minimal-mode wasm build (now 603kb uncompressed). Remove the hard-coded feature-enable flags from sqlite3-wasm.c and rely on the build to provide them. Some wasm build cleanup, but attempts to completely overhaul it have been thwarted by my inability to make script-generated makefile code more legible/maintainable than the current eval spaghetti. FossilOrigin-Name: b029c4067943e366a9b25b8303136fab10822bd771ea4658ac4cd716ff4a0d8f --- ext/wasm/GNUmakefile | 93 +++++++++++-------- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core | 1 - .../api/EXPORTED_FUNCTIONS.sqlite3-extras | 1 + ext/wasm/api/sqlite3-api-glue.c-pp.js | 2 +- ext/wasm/api/sqlite3-wasm.c | 79 ++++++---------- ext/wasm/make-make.sh | 26 ++++-- ext/wasm/tester1.c-pp.js | 6 +- manifest | 27 +++--- manifest.uuid | 2 +- 9 files changed, 120 insertions(+), 117 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 2d5abebc46..785d501f39 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -15,8 +15,9 @@ # by the target name. Rebuild is necessary for all components to get # the desired optimization level. # -# quick, q = do just a minimal build (sqlite3.js/wasm, tester1) for -# faster development-mode turnaround. +# quick, q = do just build the essentials for testing +# (sqlite3.js/wasm, tester1) for faster development-mode +# turnaround. # # dist = create end user deliverables. Add dist.build=oX to build # with a specific optimization level, where oX is one of the @@ -45,16 +46,24 @@ # related to each build variant $(JS_BUILD_MODES). (Update: an # external script was attempted but generating properly-escaped # makefile code from within a shell script is even less legible -# than the $(eval) indirection going on in this file.) +# than the $(eval) indirection going on in this file.) (Update 2: +# a second attempt at that make yet another mess of it.) # default: all #default: quick -SHELL := $(shell which bash 2>/dev/null) +SHELL := $(firstword $(wildcard /usr/local/bin/bash /usr/bin/bash /bin/bash)) +ifeq (,$(SHELL)) + $(error Cannot find the bash shell) +endif MAKEFILE := $(lastword $(MAKEFILE_LIST)) -CLEAN_FILES := +CLEAN_FILES := .gen.make DISTCLEAN_FILES := ./--dummy-- -release: oz MAKING_CLEAN := $(if $(filter %clean,$(MAKECMDGOALS)),1,0) +.PHONY: clean distclean +clean: + -rm -f $(CLEAN_FILES) +distclean: clean + -rm -f $(DISTCLEAN_FILES) ######################################################################## # JS_BUILD_NAMES exists for documentation purposes only. It enumerates @@ -143,33 +152,49 @@ $(sqlite3.h): $(MAKE) -C $(dir.top) sqlite3.c $(sqlite3.c): $(sqlite3.h) -# .cache.make is generated by a shell script and holds certain parts +######################################################################## +# .gen.make is generated by a shell script and holds certain parts # of the makefile, some of which are relatively expensive to calculate # on each run (that is, they can take a human-visible amount of time). +# +# .gen.make is also home to make-side vars which are needed for +# generating makefile code via shell code. ifeq (0,$(MAKING_CLEAN)) -.cache.make: $(sqlite3.c) $(sqlite3.canonical.c) $(MAKEFILE) make-make.sh +.gen.make: $(MAKEFILE) $(sqlite3.c) rm -f $@ - $(SHELL) make-make.sh "$(sqlite3.c)" > $@ + $(SHELL) make-make.sh $(sqlite3.c) > $@ chmod -w $@ --include .cache.make -.cache.make: $(emcc.bin) +-include .gen.make +endif + +ifeq (,$(filter release snapshot,$(MAKECMDGOALS))) + $(info Development build. Use 'release' or 'snapshot' target for a smaller release build.) endif -CLEAN_FILES += .cache.make # Common options for building sqlite3-wasm.c and speedtest1.c. +# Explicit ENABLEs... SQLITE_OPT = \ - -DSQLITE_ENABLE_FTS5 \ - -DSQLITE_ENABLE_RTREE \ - -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION \ - -DSQLITE_ENABLE_STMTVTAB \ + -DSQLITE_ENABLE_BYTECODE_VTAB \ -DSQLITE_ENABLE_DBPAGE_VTAB \ -DSQLITE_ENABLE_DBSTAT_VTAB \ - -DSQLITE_ENABLE_BYTECODE_VTAB \ + -DSQLITE_ENABLE_FTS5 \ + -DSQLITE_ENABLE_MATH_FUNCTIONS \ -DSQLITE_ENABLE_OFFSET_SQL_FUNC \ + -DSQLITE_ENABLE_PREUPDATE_HOOK \ + -DSQLITE_ENABLE_RTREE \ + -DSQLITE_ENABLE_SESSION \ + -DSQLITE_ENABLE_STMTVTAB \ + -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION + +# Explicit OMITs... +SQLITE_OPT += \ -DSQLITE_OMIT_LOAD_EXTENSION \ -DSQLITE_OMIT_DEPRECATED \ -DSQLITE_OMIT_UTF16 \ - -DSQLITE_OMIT_SHARED_CACHE \ + -DSQLITE_OMIT_SHARED_CACHE + +# Misc. build-time config options... +SQLITE_OPT += \ -DSQLITE_THREADSAFE=0 \ -DSQLITE_TEMP_STORE=2 \ -DSQLITE_OS_KV_OPTIONAL=1 \ @@ -177,6 +202,7 @@ SQLITE_OPT = \ -DSQLITE_USE_URI=1 \ -DSQLITE_WASM_ENABLE_C_TESTS \ -DSQLITE_C=$(sqlite3.c) + #SQLITE_OPT += -DSQLITE_DEBUG # Enabling SQLITE_DEBUG will break sqlite3_wasm_vfs_create_file() # (and thus sqlite3_js_vfs_create_file()). Those functions are @@ -187,25 +213,16 @@ SQLITE_OPT = \ ######################################################################## # minimal=1 disables all "extraneous" stuff from sqlite3-wasm.c, the # goal being to create a WASM file with only the core APIs. -minimal ?= 0 ifeq (1,$(minimal)) SQLITE_OPT += -DSQLITE_WASM_MINIMAL -endif - -.PHONY: clean distclean -clean: - -rm -f $(CLEAN_FILES) -distclean: clean - -rm -f $(DISTCLEAN_FILES) - -ifeq (release,$(filter release,$(MAKECMDGOALS))) - ifeq (,$(wasm-strip)) - $(error Cannot make release-quality binary because wasm-strip is not available. \ - See notes in the warning above) - endif + # SQLITE_WASM_MINIMAL tells sqlite3-wasm.c to explicitly omit + # a bunch of stuff, in the interest of keeping the wasm file size + # down. + wasm-minimal := 1 else - $(info Development build. Use '$(MAKE) release' for a smaller release build.) + wasm-minimal := 0 endif +undefine minimal ######################################################################## # Adding custom C code via sqlite3_wasm_extra_init.c: @@ -368,11 +385,11 @@ EXPORTED_FUNCTIONS.api.in := $(EXPORTED_FUNCTIONS.api.core) ifeq (1,$(SQLITE_C_IS_SEE)) EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-see endif -ifeq (0,$(minimal)) +ifeq (0,$(wasm-minimal)) EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-extras else $(info ========================================) - $(info This is a minimal-mode build) + $(info This is a minimal-mode build. It is missing many features.) $(info ========================================) endif EXPORTED_FUNCTIONS.api := $(dir.tmp)/EXPORTED_FUNCTIONS.api @@ -408,8 +425,10 @@ sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js # sqlite3-vfs-helper = helper APIs for VFSes: sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js -# sqlite3-vtab-helper = helper APIs for VTABLEs: -sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js +ifeq (0,$(wasm-minimal)) + # sqlite3-vtab-helper = helper APIs for VTABLEs: + sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js +endif # sqlite3-vfs-opfs = the first OPFS VFS: sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js # sqlite3-vfs-opfs-sahpool = the second OPFS VFS: diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core index db47ee7db1..263542bc94 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core @@ -49,7 +49,6 @@ _sqlite3_db_name _sqlite3_db_readonly _sqlite3_db_status _sqlite3_deserialize -_sqlite3_drop_modules _sqlite3_errcode _sqlite3_errmsg _sqlite3_error_offset diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras index f8af685ed7..2e831447dd 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras @@ -50,6 +50,7 @@ _sqlite3session_table_filter _sqlite3_create_module _sqlite3_create_module_v2 _sqlite3_declare_vtab +_sqlite3_drop_modules _sqlite3_vtab_collation _sqlite3_vtab_distinct _sqlite3_vtab_in diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index 55dd300d74..3c4bf582d1 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -385,7 +385,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ of this, the canonical builds of sqlite3.wasm/js guarantee that sqlite3.wasm.alloc() and friends use those allocators. Custom builds may not guarantee that, however. */, - ["sqlite3_drop_modules", "int", ["sqlite3*", "**"]], ["sqlite3_last_insert_rowid", "i64", ["sqlite3*"]], ["sqlite3_malloc64", "*","i64"], ["sqlite3_msize", "i64", "*"], @@ -422,6 +421,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_create_module_v2", "int", ["sqlite3*","string","sqlite3_module*","*","*"]], ["sqlite3_declare_vtab", "int", ["sqlite3*", "string:flexible"]], + ["sqlite3_drop_modules", "int", ["sqlite3*", "**"]], ["sqlite3_vtab_collation","string","sqlite3_index_info*","int"], ["sqlite3_vtab_distinct","int", "sqlite3_index_info*"], ["sqlite3_vtab_in","int", "sqlite3_index_info*", "int", "int"], diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index 7f7e696899..c0da2c623d 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -14,16 +14,17 @@ */ #define SQLITE_WASM #ifdef SQLITE_WASM_ENABLE_C_TESTS +# undef SQLITE_WASM_ENABLE_C_TESTS +# define SQLITE_WASM_ENABLE_C_TESTS 1 /* -** Code blocked off by SQLITE_WASM_TESTS is intended solely for use in -** unit/regression testing. They may be safely omitted from +** Code blocked off by SQLITE_WASM_ENABLE_C_TESTS is intended solely +** for use in unit/regression testing. They may be safely omitted from ** client-side builds. The main unit test script, tester1.js, will ** skip related tests if it doesn't find the corresponding functions ** in the WASM exports. */ -# define SQLITE_WASM_TESTS 1 #else -# define SQLITE_WASM_TESTS 0 +# define SQLITE_WASM_ENABLE_C_TESTS 0 #endif /* @@ -92,43 +93,6 @@ #undef SQLITE_ENABLE_API_ARMOR #define SQLITE_ENABLE_API_ARMOR 1 -#ifndef SQLITE_ENABLE_BYTECODE_VTAB -# define SQLITE_ENABLE_BYTECODE_VTAB 1 -#endif -#ifndef SQLITE_ENABLE_DBPAGE_VTAB -# define SQLITE_ENABLE_DBPAGE_VTAB 1 -#endif -#ifndef SQLITE_ENABLE_DBSTAT_VTAB -# define SQLITE_ENABLE_DBSTAT_VTAB 1 -#endif -#ifndef SQLITE_ENABLE_EXPLAIN_COMMENTS -# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1 -#endif -#ifndef SQLITE_ENABLE_FTS5 -# define SQLITE_ENABLE_FTS5 1 -#endif -#ifndef SQLITE_ENABLE_MATH_FUNCTIONS -# define SQLITE_ENABLE_MATH_FUNCTIONS 1 -#endif -#ifndef SQLITE_ENABLE_OFFSET_SQL_FUNC -# define SQLITE_ENABLE_OFFSET_SQL_FUNC 1 -#endif -#ifndef SQLITE_ENABLE_PREUPDATE_HOOK -# define SQLITE_ENABLE_PREUPDATE_HOOK 1 /*required by session extension*/ -#endif -#ifndef SQLITE_ENABLE_RTREE -# define SQLITE_ENABLE_RTREE 1 -#endif -#ifndef SQLITE_ENABLE_SESSION -# define SQLITE_ENABLE_SESSION 1 -#endif -#ifndef SQLITE_ENABLE_STMTVTAB -# define SQLITE_ENABLE_STMTVTAB 1 -#endif -#ifndef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION -# define SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION -#endif - /**********************************************************************/ /* SQLITE_O... */ #ifndef SQLITE_OMIT_DEPRECATED @@ -214,6 +178,12 @@ # define SQLITE_OMIT_JSON #endif +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL) +# define SQLITE_WASM_HAS_VTAB 1 +#else +# define SQLITE_WASM_HAS_VTAB 0 +#endif + #include /* @@ -412,7 +382,7 @@ int sqlite3__wasm_db_error(sqlite3*db, int err_code, const char *zMsg){ return err_code; } -#if SQLITE_WASM_TESTS +#if SQLITE_WASM_ENABLE_C_TESTS struct WasmTestStruct { int v4; void * ppV; @@ -432,7 +402,7 @@ void sqlite3__wasm_test_struct(WasmTestStruct * s){ } return; } -#endif /* SQLITE_WASM_TESTS */ +#endif /* SQLITE_WASM_ENABLE_C_TESTS */ /* ** This function is NOT part of the sqlite3 public API. It is strictly @@ -967,7 +937,7 @@ const char * sqlite3__wasm_enum_json(void){ } _DefGroup; DefGroup(vtab) { -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL) +#if SQLITE_WASM_HAS_VTAB DefInt(SQLITE_INDEX_SCAN_UNIQUE); DefInt(SQLITE_INDEX_CONSTRAINT_EQ); DefInt(SQLITE_INDEX_CONSTRAINT_GT); @@ -995,7 +965,7 @@ const char * sqlite3__wasm_enum_json(void){ DefInt(SQLITE_FAIL); //DefInt(SQLITE_ABORT); // Also an error code DefInt(SQLITE_REPLACE); -#endif /*!SQLITE_OMIT_VIRTUALTABLE*/ +#endif /*SQLITE_WASM_HAS_VTAB*/ } _DefGroup; #undef DefGroup @@ -1110,6 +1080,7 @@ const char * sqlite3__wasm_enum_json(void){ #undef CurrentStruct +#if SQLITE_WASM_HAS_VTAB #define CurrentStruct sqlite3_vtab StructBinder { M(pModule, "p"); @@ -1155,7 +1126,6 @@ const char * sqlite3__wasm_enum_json(void){ } _StructBinder; #undef CurrentStruct -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL) /** ** Workaround: in order to map the various inner structs from ** sqlite3_index_info, we have to uplift those into constructs we @@ -1232,9 +1202,9 @@ const char * sqlite3__wasm_enum_json(void){ } _StructBinder; #undef CurrentStruct -#endif /*!SQLITE_OMIT_VIRTUALTABLE*/ +#endif /*SQLITE_WASM_HAS_VTAB*/ -#if SQLITE_WASM_TESTS +#if SQLITE_WASM_ENABLE_C_TESTS #define CurrentStruct WasmTestStruct StructBinder { M(v4, "i"); @@ -1244,7 +1214,7 @@ const char * sqlite3__wasm_enum_json(void){ M(xFunc, "v(p)"); } _StructBinder; #undef CurrentStruct -#endif +#endif /*SQLITE_WASM_ENABLE_C_TESTS*/ } out( "]"/*structs*/); @@ -1603,7 +1573,7 @@ sqlite3_kvvfs_methods * sqlite3__wasm_kvvfs_methods(void){ return &sqlite3KvvfsMethods; } -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL) +#if SQLITE_WASM_HAS_VTAB /* ** This function is NOT part of the sqlite3 public API. It is strictly ** for use by the sqlite project's own JS/WASM bindings. @@ -1626,7 +1596,7 @@ int sqlite3__wasm_vtab_config(sqlite3 *pDb, int op, int arg){ return SQLITE_MISUSE; } } -#endif /*!SQLITE_OMIT_VIRTUALTABLE*/ +#endif /*SQLITE_WASM_HAS_VTAB*/ /* ** This function is NOT part of the sqlite3 public API. It is strictly @@ -1801,7 +1771,7 @@ int sqlite3__wasm_init_wasmfs(const char *zUnused){ } #endif /* __EMSCRIPTEN__ && SQLITE_ENABLE_WASMFS */ -#if SQLITE_WASM_TESTS +#if SQLITE_WASM_ENABLE_C_TESTS SQLITE_WASM_EXPORT int sqlite3__wasm_test_intptr(int * p){ @@ -1967,6 +1937,9 @@ int sqlite3__wasm_SQLTester_strglob(const char *zGlob, const char *z){ return !sqlite3__wasm_SQLTester_strnotglob(zGlob, z); } -#endif /* SQLITE_WASM_TESTS */ +#endif /* SQLITE_WASM_ENABLE_C_TESTS */ #undef SQLITE_WASM_EXPORT +#undef SQLITE_WASM_HAS_VTAB +#undef SQLITE_WASM_MINIMAL +#undef SQLITE_WASM_ENABLE_C_TESTS diff --git a/ext/wasm/make-make.sh b/ext/wasm/make-make.sh index e5b81b3d12..6f93d88835 100755 --- a/ext/wasm/make-make.sh +++ b/ext/wasm/make-make.sh @@ -23,7 +23,14 @@ function die(){ SQLITE3_C="${1-../../sqlite3.c}" -echo "# GENERATED makefile code. DO NOT EDIT." +separator='########################################################################' + +cat </dev/null; then echo 'SQLITE_C_IS_SEE := 1' @@ -34,6 +41,7 @@ fi ######################################################################## # Locate the emcc (Emscripten) binary... +echo $separator EMCC_BIN=$(which emcc) if [[ x = "x${EMCC_BIN}" ]]; then if [[ x != "x${EMSDK_HOME}" ]]; then @@ -51,6 +59,7 @@ echo '$(info using emcc version [$(emcc.version)])' ######################################################################### # wasm-strip binary... +echo $separator WASM_STRIP_BIN=$(which wasm-strip 2>/dev/null) echo "wasm-strip ?= ${WASM_STRIP_BIN}" if [[ x = "x${WASM_STRIP_BIN}" ]]; then @@ -71,14 +80,19 @@ ifeq (,\$(filter clean,\$(MAKECMDGOALS)))' \$(info WARNING: sudo apt install wabt) \$(info WARNING: *******************************************************************) endif +ifneq (,\$(filter release snapshot,\$(MAKECMDGOALS))) + \$(error Cannot make release-quality binary because wasm-strip is not available.) +endif EOF else - echo 'maybe-wasm-strip = $(wasm-strip)' +echo 'maybe-wasm-strip = $(wasm-strip)' fi +# /$(wasm-strip) +######################################################################## - -dir_dout=jswasm -dir_tmp=bld -for d in $dir_dout $dir_tmp; do +######################################################################## +# Make necessary dirs. Note that these need to align with their names +# in the main makefile. +for d in jswasm bld; do [ -d $d ] || mkdir -p $d done diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 3338bbb2a1..b8db1a59b2 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2153,7 +2153,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////////// .t({ name: 'virtual table #1: eponymous w/ manual exception handling', - predicate: ()=>!!capi.sqlite3_create_module || "Missing vtab support", + predicate: (sqlite3)=>!!sqlite3.capi.sqlite3_vtab || "Missing vtab support", test: function(sqlite3){ const VT = sqlite3.vtab; const tmplCols = Object.assign(Object.create(null),{ @@ -2350,7 +2350,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////////// .t({ name: 'virtual table #2: non-eponymous w/ automated exception wrapping', - predicate: ()=>!!capi.sqlite3_create_module || "Missing vtab support", + predicate: (sqlite3)=>!!sqlite3.capi.sqlite3_vtab || "Missing vtab support", test: function(sqlite3){ const VT = sqlite3.vtab; const tmplCols = Object.assign(Object.create(null),{ @@ -3300,7 +3300,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.g('Bug Reports') .t({ name: 'Delete via bound parameter in subquery', - predicate: ()=>wasm.compileOptionUsed('ENABLE_FTS5') || "FTS5 is not available", + predicate: ()=>wasm.compileOptionUsed('ENABLE_FTS5') || "Missing FTS5", test: function(sqlite3){ // Testing https://sqlite.org/forum/forumpost/40ce55bdf5 // with the exception that that post uses "external content" diff --git a/manifest b/manifest index f53748e088..6b6d0243f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Start\swork\son\san\soverhaul\sof\sthe\swasm\sbuild\sprocess,\swith\san\seye\stowards\sless\sover-engineering. -D 2024-07-25T10:50:45.547 +C More\swork\son\sthe\sminimal-mode\swasm\sbuild\s(now\s603kb\suncompressed).\sRemove\sthe\shard-coded\sfeature-enable\sflags\sfrom\ssqlite3-wasm.c\sand\srely\son\sthe\sbuild\sto\sprovide\sthem.\sSome\swasm\sbuild\scleanup,\sbut\sattempts\sto\scompletely\soverhaul\sit\shave\sbeen\sthwarted\sby\smy\sinability\sto\smake\sscript-generated\smakefile\scode\smore\slegible/maintainable\sthan\sthe\scurrent\seval\sspaghetti. +D 2024-07-25T14:00:26.899 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -593,7 +593,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 2037399f1a33f8c0bab52e5aba78d4c6b6d9fb8d905ddf5fc3dd10f2a6fdb494 +F ext/wasm/GNUmakefile c89b6d0e7f969de03cfcbd5d5f64985ee9ba823a7be6b150fb9c2976c7adb0d6 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -601,8 +601,8 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 400213eb52a7e5ad5f448053d375cacf4dac2cf45d134f3edfe485ae4a49a183 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras e9a42a86d1e09cfd46fd22438e0cb9449e6eae2eff39597cdc834c183775286a w ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 38f85e6ec5f9c776087bc38aef9ef35eeb7e54942ddb1dd04e9ac0122958b741 +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras 2a8c9f7d865cc6e5661b2cd40a45e963a1f8070a88def6ead4c40d4fa0c91998 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 @@ -612,7 +612,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 30abfbb9ed4b6732e2fd78dbfedee5f8d7a395a6d38f140f8df19bd9c30b4191 +F ext/wasm/api/sqlite3-api-glue.c-pp.js 12f6f3840afdf8ff7a4374dc1a96a26bcc369e17853e0fe917c38f4d66c6e2d8 F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -622,7 +622,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 -F ext/wasm/api/sqlite3-wasm.c 09a938fc570f282e602acd111147c7b74b5332da72540c512a79b916ab57882a +F ext/wasm/api/sqlite3-wasm.c 79335b70d4d404b33fb485a4f65422a1ded0977c38e3b1a0cd8e26b49d3c9fba F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -653,7 +653,7 @@ F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29a F ext/wasm/index.html 4337f495416756802669f69f9f9f3df9f87ee4c1918e6718719b4b5718e4713a F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 -F ext/wasm/make-make.sh 93fa6d00f0ffa3481badd068b8da8ed5825cf74999d5e54b2a0c9b90579a3056 x +F ext/wasm/make-make.sh 3c1964f5ed80af79c21e583abb9adac2eb11141c98c1cf57eba7ebcb210f1025 x F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -669,7 +669,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js b5a126b7ae3f3b5628e74ca806f65394f309326dd518831b2186f88850439be2 +F ext/wasm/tester1.c-pp.js 7d0eba1496286338770133356488b4415de7970f4ee2c08f7f587bb18d8b6b0b F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2197,11 +2197,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0 -R 5dcb0158c3e9e326c7d4eacaa8552ecf -T *branch * wasm-build-rework -T *sym-wasm-build-rework * -T -sym-trunk * Cancelled\sby\sbranch. +P ed746b3dd3248b68cb91de50ac5ba5fd3a7c2fcbde76324e86b88edbfecd896b +R acaefae7f2493e8276236de40774aafc U stephan -Z 6b2b2a8483fc393f764799aae3eb47aa +Z 2f4bcd240a0ced338bed244e56f0f58c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9d68627d41..930c8e1a51 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ed746b3dd3248b68cb91de50ac5ba5fd3a7c2fcbde76324e86b88edbfecd896b +b029c4067943e366a9b25b8303136fab10822bd771ea4658ac4cd716ff4a0d8f From e7840ce6810174625ae9ec116610bb987d252aef Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 25 Jul 2024 16:21:19 +0000 Subject: [PATCH 0564/1030] Strip progress handlers and window functions from the wasm bare-bones (formerly 'minimal') JS bits, noting that we can't yet use OMIT_WINDOWFUNC (for the C parts) without a custom amalgamation. Currently at 604kb. FossilOrigin-Name: ec02e9237e1ef81c4196fa630822cb109eab926143ad09593a24273eb0668601 --- ext/wasm/GNUmakefile | 120 +++-- ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core | 2 - .../api/EXPORTED_FUNCTIONS.sqlite3-extras | 2 + ext/wasm/api/sqlite3-api-glue.c-pp.js | 153 +++--- ext/wasm/api/sqlite3-wasm.c | 103 ++-- ext/wasm/fiddle.make | 10 +- ext/wasm/tester1.c-pp.js | 473 +++++++++--------- manifest | 24 +- manifest.uuid | 2 +- 9 files changed, 491 insertions(+), 398 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 785d501f39..18f8ffc22d 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -157,8 +157,9 @@ $(sqlite3.c): $(sqlite3.h) # of the makefile, some of which are relatively expensive to calculate # on each run (that is, they can take a human-visible amount of time). # -# .gen.make is also home to make-side vars which are needed for -# generating makefile code via shell code. +# Sidebar: three attempts have been made to move much of the +# $(eval)-generated makefile code into make-make.sh but the result is +# even less legible/maintainable than make-side $(eval). ifeq (0,$(MAKING_CLEAN)) .gen.make: $(MAKEFILE) $(sqlite3.c) rm -f $@ @@ -171,9 +172,39 @@ ifeq (,$(filter release snapshot,$(MAKECMDGOALS))) $(info Development build. Use 'release' or 'snapshot' target for a smaller release build.) endif +######################################################################## +# minimal=1 disables all "extraneous" stuff from sqlite3-wasm.c, the +# goal being to create a WASM file with only the core APIs. +ifeq (1,$(minimal)) + wasm-bare-bones := 1 +else + wasm-bare-bones := 0 +endif +undefine minimal + # Common options for building sqlite3-wasm.c and speedtest1.c. # Explicit ENABLEs... -SQLITE_OPT = \ +SQLITE_OPT.common := \ + -DSQLITE_THREADSAFE=0 \ + -DSQLITE_TEMP_STORE=2 \ + -DSQLITE_ENABLE_MATH_FUNCTIONS \ + -DSQLITE_OS_KV_OPTIONAL=1 \ + '-DSQLITE_DEFAULT_UNIX_VFS="unix-none"' \ + -DSQLITE_USE_URI=1 \ + -DSQLITE_C=$(sqlite3.c) \ + -DSQLITE_OMIT_DEPRECATED \ + -DSQLITE_OMIT_UTF16 \ + -DSQLITE_OMIT_LOAD_EXTENSION \ + -DSQLITE_OMIT_SHARED_CACHE +# ^^^ These particular OMITs are hard-coded in sqlite3-wasm.c and +# removing them from this list will serve only to break the speedtest1 +# builds. + +# Currently always needed but TODO is paring tester1.c-pp.js down +# to be able to run without this: +SQLITE_OPT.common += -DSQLITE_WASM_ENABLE_C_TESTS + +SQLITE_OPT.full-featured := \ -DSQLITE_ENABLE_BYTECODE_VTAB \ -DSQLITE_ENABLE_DBPAGE_VTAB \ -DSQLITE_ENABLE_DBSTAT_VTAB \ @@ -186,22 +217,45 @@ SQLITE_OPT = \ -DSQLITE_ENABLE_STMTVTAB \ -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION -# Explicit OMITs... -SQLITE_OPT += \ - -DSQLITE_OMIT_LOAD_EXTENSION \ - -DSQLITE_OMIT_DEPRECATED \ - -DSQLITE_OMIT_UTF16 \ - -DSQLITE_OMIT_SHARED_CACHE - -# Misc. build-time config options... -SQLITE_OPT += \ - -DSQLITE_THREADSAFE=0 \ - -DSQLITE_TEMP_STORE=2 \ - -DSQLITE_OS_KV_OPTIONAL=1 \ - '-DSQLITE_DEFAULT_UNIX_VFS="unix-none"' \ - -DSQLITE_USE_URI=1 \ - -DSQLITE_WASM_ENABLE_C_TESTS \ - -DSQLITE_C=$(sqlite3.c) +ifeq (0,$(wasm-bare-bones)) + # The so-called canonical build is full-featured: + SQLITE_OPT := \ + $(SQLITE_OPT.common) \ + $(SQLITE_OPT.full-featured) +else + # The so-called bare-bones build is exactly that: + SQLITE_OPT := \ + $(SQLITE_OPT.common) \ + -DSQLITE_WASM_BARE_BONES + # SQLITE_WASM_BARE_BONES tells sqlite3-wasm.c to explicitly omit + # a bunch of stuff, in the interest of keeping the wasm file size + # down. As of this writing it equates to: + # + # -USQLITE_ENABLE_DBPAGE_VTAB + # -USQLITE_ENABLE_DBSTAT_VTAB + # -USQLITE_ENABLE_EXPLAIN_COMMENTS + # -USQLITE_ENABLE_FTS5 + # -USQLITE_ENABLE_OFFSET_SQL_FUNC + # -USQLITE_ENABLE_PREUPDATE_HOOK + # -USQLITE_ENABLE_RTREE + # -USQLITE_ENABLE_SESSION + # -USQLITE_ENABLE_STMTVTAB + # -DSQLITE_OMIT_AUTHORIZATION + # -DSQLITE_OMIT_GET_TABLE + # -DSQLITE_OMIT_INCRBLOB + # -DSQLITE_OMIT_INTROSPECTION_PRAGMAS + # -DSQLITE_OMIT_JSON + # -DSQLITE_OMIT_PROGRESS_CALLBACK + # -DSQLITE_OMIT_WAL + # + # There are others we want here but which require explicit OMIT when + # creating their amalgamation, and that step is TODO: + # + # -DSQLITE_OMIT_EXPLAIN + # -DSQLITE_OMIT_TRIGGER + # -DSQLITE_OMIT_VIRTUALTABLE + # -DSQLITE_OMIT_WINDOWFUNC +endif #SQLITE_OPT += -DSQLITE_DEBUG # Enabling SQLITE_DEBUG will break sqlite3_wasm_vfs_create_file() @@ -211,18 +265,16 @@ SQLITE_OPT += \ # in client code. ######################################################################## -# minimal=1 disables all "extraneous" stuff from sqlite3-wasm.c, the -# goal being to create a WASM file with only the core APIs. -ifeq (1,$(minimal)) - SQLITE_OPT += -DSQLITE_WASM_MINIMAL - # SQLITE_WASM_MINIMAL tells sqlite3-wasm.c to explicitly omit - # a bunch of stuff, in the interest of keeping the wasm file size - # down. - wasm-minimal := 1 -else - wasm-minimal := 0 -endif -undefine minimal +# The following flags are hard-coded into sqlite3-wasm.c and cannot be +# modified via the build process: +# +# SQLITE_ENABLE_API_ARMOR +# SQLITE_OMIT_LOAD_EXTENSION +# SQLITE_OMIT_DEPRECATED +# SQLITE_OMIT_UTF16 +# SQLITE_OMIT_SHARED_CACHE +######################################################################## + ######################################################################## # Adding custom C code via sqlite3_wasm_extra_init.c: @@ -385,7 +437,7 @@ EXPORTED_FUNCTIONS.api.in := $(EXPORTED_FUNCTIONS.api.core) ifeq (1,$(SQLITE_C_IS_SEE)) EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-see endif -ifeq (0,$(wasm-minimal)) +ifeq (0,$(wasm-bare-bones)) EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-extras else $(info ========================================) @@ -425,7 +477,7 @@ sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js # sqlite3-vfs-helper = helper APIs for VFSes: sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js -ifeq (0,$(wasm-minimal)) +ifeq (0,$(wasm-bare-bones)) # sqlite3-vtab-helper = helper APIs for VTABLEs: sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js endif @@ -1053,7 +1105,7 @@ $(speedtest1.js): $(MAKEFILE) $(speedtest1.cfiles) \ $(emcc.speedtest1.common) \ $(emcc.flags.speedtest1-vanilla) $(pre-post-speedtest1-vanilla.flags) \ $(SQLITE_OPT) \ - -USQLITE_WASM_MINIMAL \ + -USQLITE_WASM_BARE_BONES \ -USQLITE_C -DSQLITE_C=$(sqlite3.canonical.c) \ $(speedtest1.exit-runtime0) \ -o $@ $(speedtest1.cfiles) -lm diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core index 263542bc94..2578002ce4 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core @@ -41,7 +41,6 @@ _sqlite3_create_collation _sqlite3_create_collation_v2 _sqlite3_create_function _sqlite3_create_function_v2 -_sqlite3_create_window_function _sqlite3_data_count _sqlite3_db_filename _sqlite3_db_handle @@ -80,7 +79,6 @@ _sqlite3_open_v2 _sqlite3_overload_function _sqlite3_prepare_v2 _sqlite3_prepare_v3 -_sqlite3_progress_handler _sqlite3_randomness _sqlite3_realloc _sqlite3_realloc64 diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras index 2e831447dd..e635d93b32 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras @@ -1,3 +1,5 @@ +_sqlite3_create_window_function +_sqlite3_progress_handler _sqlite3_set_authorizer _sqlite3_preupdate_blobwrite _sqlite3_preupdate_count diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index 3c4bf582d1..680218370a 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -136,20 +136,12 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_compileoption_used", "int", "string"], ["sqlite3_complete", "int", "string:flexible"], ["sqlite3_context_db_handle", "sqlite3*", "sqlite3_context*"], - + /* sqlite3_create_collation() and sqlite3_create_collation_v2() + use hand-written bindings to simplify passing of the callback + function. */ /* sqlite3_create_function(), sqlite3_create_function_v2(), and sqlite3_create_window_function() use hand-written bindings to simplify handling of their function-type arguments. */ - /* sqlite3_create_collation() and sqlite3_create_collation_v2() - use hand-written bindings to simplify passing of the callback - function. - ["sqlite3_create_collation", "int", - "sqlite3*", "string", "int",//SQLITE_UTF8 is the only legal value - "*", "*"], - ["sqlite3_create_collation_v2", "int", - "sqlite3*", "string", "int",//SQLITE_UTF8 is the only legal value - "*", "*", "*"], - */ ["sqlite3_data_count", "int", "sqlite3_stmt*"], ["sqlite3_db_filename", "string", "sqlite3*", "string"], ["sqlite3_db_handle", "sqlite3*", "sqlite3_stmt*"], @@ -211,14 +203,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ for those, depending on how their SQL argument is provided. */ /* sqlite3_randomness() uses a hand-written wrapper to extend the range of supported argument types. */ - ["sqlite3_progress_handler", undefined, [ - "sqlite3*", "int", new wasm.xWrap.FuncPtrAdapter({ - name: 'xProgressHandler', - signature: 'i(p)', - bindScope: 'context', - contextKey: (argv,argIndex)=>argv[0/* sqlite3* */] - }), "*" - ]], ["sqlite3_realloc", "*","*","int"], ["sqlite3_reset", "int", "sqlite3_stmt*"], /* sqlite3_reset_auto_extension() has a hand-written binding. */ @@ -303,6 +287,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_vfs_unregister", "int", "sqlite3_vfs*"] ]/*wasm.bindingSignatures*/; + if( !!wasm.exports.sqlite3_progress_handler ){ + wasm.bindingSignatures.push( + ["sqlite3_progress_handler", undefined, [ + "sqlite3*", "int", new wasm.xWrap.FuncPtrAdapter({ + name: 'xProgressHandler', + signature: 'i(p)', + bindScope: 'context', + contextKey: (argv,argIndex)=>argv[0/* sqlite3* */] + }), "*" + ]] + ); + } + if( !!wasm.exports.sqlite3_stmt_explain ){ wasm.bindingSignatures.push( ["sqlite3_stmt_explain", "int", "sqlite3_stmt*", "int"], @@ -950,7 +947,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ /** Code duplication reducer for functions which take an encoding argument and require SQLITE_UTF8. Sets the db error code to - SQLITE_FORMAT and returns that code. */ + SQLITE_FORMAT, installs a descriptive error message, + and returns SQLITE_FORMAT. */ const __errEncoding = (pDb)=>{ return util.sqlite3__wasm_db_error( pDb, capi.SQLITE_FORMAT, "SQLITE_UTF8 is the only supported encoding." @@ -1000,11 +998,13 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ this._addUDF(pDb, name, arity, m.udf); }; - __dbCleanupMap.addWindowFunc = function(pDb, name, arity){ - const m = __dbCleanupMap(pDb, 1); - if(!m.wudf) m.wudf = new Map; - this._addUDF(pDb, name, arity, m.wudf); - }; + if( wasm.exports.sqlite3_create_window_function ){ + __dbCleanupMap.addWindowFunc = function(pDb, name, arity){ + const m = __dbCleanupMap(pDb, 1); + if(!m.wudf) m.wudf = new Map; + this._addUDF(pDb, name, arity, m.wudf); + }; + } /** Intended to be called _only_ from sqlite3_close_v2(), @@ -1273,17 +1273,20 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ] ); - const __sqlite3CreateWindowFunction = wasm.xWrap( - "sqlite3_create_window_function", "int", [ - "sqlite3*", "string"/*funcName*/, "int"/*nArg*/, - "int"/*eTextRep*/, "*"/*pApp*/, - new wasm.xWrap.FuncPtrAdapter({name: 'xStep', ...__cfProxy.xInverseAndStep}), - new wasm.xWrap.FuncPtrAdapter({name: 'xFinal', ...__cfProxy.xFinalAndValue}), - new wasm.xWrap.FuncPtrAdapter({name: 'xValue', ...__cfProxy.xFinalAndValue}), - new wasm.xWrap.FuncPtrAdapter({name: 'xInverse', ...__cfProxy.xInverseAndStep}), - new wasm.xWrap.FuncPtrAdapter({name: 'xDestroy', ...__cfProxy.xDestroy}) - ] - ); + const __sqlite3CreateWindowFunction = + wasm.exports.sqlite3_create_window_function + ? wasm.xWrap( + "sqlite3_create_window_function", "int", [ + "sqlite3*", "string"/*funcName*/, "int"/*nArg*/, + "int"/*eTextRep*/, "*"/*pApp*/, + new wasm.xWrap.FuncPtrAdapter({name: 'xStep', ...__cfProxy.xInverseAndStep}), + new wasm.xWrap.FuncPtrAdapter({name: 'xFinal', ...__cfProxy.xFinalAndValue}), + new wasm.xWrap.FuncPtrAdapter({name: 'xValue', ...__cfProxy.xFinalAndValue}), + new wasm.xWrap.FuncPtrAdapter({name: 'xInverse', ...__cfProxy.xInverseAndStep}), + new wasm.xWrap.FuncPtrAdapter({name: 'xDestroy', ...__cfProxy.xDestroy}) + ] + ) + : undefined; /* Documented in the api object's initializer. */ capi.sqlite3_create_function_v2 = function f( @@ -1328,61 +1331,71 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }; /* Documented in the api object's initializer. */ - capi.sqlite3_create_window_function = function f( - pDb, funcName, nArg, eTextRep, pApp, - xStep, //void (*xStep)(sqlite3_context*,int,sqlite3_value**) - xFinal, //void (*xFinal)(sqlite3_context*) - xValue, //void (*xValue)(sqlite3_context*) - xInverse,//void (*xInverse)(sqlite3_context*,int,sqlite3_value**) - xDestroy //void (*xDestroy)(void*) - ){ - if( f.length!==arguments.length ){ - return __dbArgcMismatch(pDb,"sqlite3_create_window_function",f.length); - }else if( 0 === (eTextRep & 0xf) ){ - eTextRep |= capi.SQLITE_UTF8; - }else if( capi.SQLITE_UTF8 !== (eTextRep & 0xf) ){ - return __errEncoding(pDb); - } - try{ - const rc = __sqlite3CreateWindowFunction(pDb, funcName, nArg, eTextRep, - pApp, xStep, xFinal, xValue, - xInverse, xDestroy); - if(0===rc && (xStep instanceof Function - || xFinal instanceof Function - || xValue instanceof Function - || xInverse instanceof Function - || xDestroy instanceof Function)){ - __dbCleanupMap.addWindowFunc(pDb, funcName, nArg); + if( __sqlite3CreateWindowFunction ){ + capi.sqlite3_create_window_function = function f( + pDb, funcName, nArg, eTextRep, pApp, + xStep, //void (*xStep)(sqlite3_context*,int,sqlite3_value**) + xFinal, //void (*xFinal)(sqlite3_context*) + xValue, //void (*xValue)(sqlite3_context*) + xInverse,//void (*xInverse)(sqlite3_context*,int,sqlite3_value**) + xDestroy //void (*xDestroy)(void*) + ){ + if( f.length!==arguments.length ){ + return __dbArgcMismatch(pDb,"sqlite3_create_window_function",f.length); + }else if( 0 === (eTextRep & 0xf) ){ + eTextRep |= capi.SQLITE_UTF8; + }else if( capi.SQLITE_UTF8 !== (eTextRep & 0xf) ){ + return __errEncoding(pDb); } - return rc; - }catch(e){ - console.error("sqlite3_create_window_function() setup threw:",e); - return util.sqlite3__wasm_db_error(pDb, e, "Creation of UDF threw: "+e); - } - }; + try{ + const rc = __sqlite3CreateWindowFunction(pDb, funcName, nArg, eTextRep, + pApp, xStep, xFinal, xValue, + xInverse, xDestroy); + if(0===rc && (xStep instanceof Function + || xFinal instanceof Function + || xValue instanceof Function + || xInverse instanceof Function + || xDestroy instanceof Function)){ + __dbCleanupMap.addWindowFunc(pDb, funcName, nArg); + } + return rc; + }catch(e){ + console.error("sqlite3_create_window_function() setup threw:",e); + return util.sqlite3__wasm_db_error(pDb, e, "Creation of UDF threw: "+e); + } + }; + }else{ + delete capi.sqlite3_create_window_function; + } /** A _deprecated_ alias for capi.sqlite3_result_js() which predates the addition of that function in the public API. */ capi.sqlite3_create_function_v2.udfSetResult = - capi.sqlite3_create_function.udfSetResult = + capi.sqlite3_create_function.udfSetResult = capi.sqlite3_result_js; + if(capi.sqlite3_create_window_function){ capi.sqlite3_create_window_function.udfSetResult = capi.sqlite3_result_js; + } /** A _deprecated_ alias for capi.sqlite3_values_to_js() which predates the addition of that function in the public API. */ capi.sqlite3_create_function_v2.udfConvertArgs = - capi.sqlite3_create_function.udfConvertArgs = + capi.sqlite3_create_function.udfConvertArgs = capi.sqlite3_values_to_js; + if(capi.sqlite3_create_window_function){ capi.sqlite3_create_window_function.udfConvertArgs = capi.sqlite3_values_to_js; + } /** A _deprecated_ alias for capi.sqlite3_result_error_js() which predates the addition of that function in the public API. */ capi.sqlite3_create_function_v2.udfSetError = - capi.sqlite3_create_function.udfSetError = + capi.sqlite3_create_function.udfSetError = capi.sqlite3_result_error_js; + if(capi.sqlite3_create_window_function){ capi.sqlite3_create_window_function.udfSetError = capi.sqlite3_result_error_js; + } }/*sqlite3_create_function_v2() and sqlite3_create_window_function() proxies*/; diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index c0da2c623d..c5dd495e54 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -95,21 +95,16 @@ /**********************************************************************/ /* SQLITE_O... */ -#ifndef SQLITE_OMIT_DEPRECATED -# define SQLITE_OMIT_DEPRECATED 1 -#endif -#ifndef SQLITE_OMIT_LOAD_EXTENSION -# define SQLITE_OMIT_LOAD_EXTENSION 1 -#endif -#ifndef SQLITE_OMIT_SHARED_CACHE -# define SQLITE_OMIT_SHARED_CACHE 1 -#endif -#ifndef SQLITE_OMIT_UTF16 -# define SQLITE_OMIT_UTF16 1 -#endif -#ifndef SQLITE_OS_KV_OPTIONAL -# define SQLITE_OS_KV_OPTIONAL 1 -#endif +#undef SQLITE_OMIT_DEPRECATED +#define SQLITE_OMIT_DEPRECATED 1 +#undef SQLITE_OMIT_LOAD_EXTENSION +#define SQLITE_OMIT_LOAD_EXTENSION 1 +#undef SQLITE_OMIT_SHARED_CACHE +#define SQLITE_OMIT_SHARED_CACHE 1 +#undef SQLITE_OMIT_UTF16 +#define SQLITE_OMIT_UTF16 1 +#undef SQLITE_OS_KV_OPTIONAL +#define SQLITE_OS_KV_OPTIONAL 1 /**********************************************************************/ /* SQLITE_S... */ @@ -137,48 +132,61 @@ #endif /* -** If SQLITE_WASM_MINIMAL is defined, undefine most of the ENABLE +** If SQLITE_WASM_BARE_BONES is defined, undefine most of the ENABLE ** macros. */ -#ifdef SQLITE_WASM_MINIMAL -# undef SQLITE_ENABLE_DBPAGE_VTAB -# undef SQLITE_ENABLE_DBSTAT_VTAB -# undef SQLITE_ENABLE_EXPLAIN_COMMENTS -# undef SQLITE_ENABLE_FTS5 -# undef SQLITE_ENABLE_OFFSET_SQL_FUNC -# undef SQLITE_ENABLE_PREUPDATE_HOOK -# undef SQLITE_ENABLE_RTREE -# undef SQLITE_ENABLE_SESSION -# undef SQLITE_ENABLE_STMTVTAB -# undef SQLITE_OMIT_AUTHORIZATION +#ifdef SQLITE_WASM_BARE_BONES +# undef SQLITE_ENABLE_DBPAGE_VTAB +# undef SQLITE_ENABLE_DBSTAT_VTAB +# undef SQLITE_ENABLE_EXPLAIN_COMMENTS +# undef SQLITE_ENABLE_FTS5 +# undef SQLITE_ENABLE_OFFSET_SQL_FUNC +# undef SQLITE_ENABLE_PREUPDATE_HOOK +# undef SQLITE_ENABLE_RTREE +# undef SQLITE_ENABLE_SESSION +# undef SQLITE_ENABLE_STMTVTAB +# undef SQLITE_OMIT_AUTHORIZATION # define SQLITE_OMIT_AUTHORIZATION -/*Reminder re. custom sqlite3.c: +# undef SQLITE_OMIT_GET_TABLE +# define SQLITE_OMIT_GET_TABLE +# undef SQLITE_OMIT_INCRBLOB +# define SQLITE_OMIT_INCRBLOB +# undef SQLITE_OMIT_INTROSPECTION_PRAGMAS +# define SQLITE_OMIT_INTROSPECTION_PRAGMAS +# undef SQLITE_OMIT_JSON +# define SQLITE_OMIT_JSON +# undef SQLITE_OMIT_PROGRESS_CALLBACK +# define SQLITE_OMIT_PROGRESS_CALLBACK +# undef SQLITE_OMIT_WAL +# define SQLITE_OMIT_WAL +/* + The following OMITs do not work with the standard amalgamation, so + require a custom build: fossil clean -x ./configure - OPTS='-DSQLITE_OMIT_VIRTUALTABLE -DSQLITE_OMIT_EXPLAIN -DSQLITE_OMIT_TRIGGER' make -e sqlite3 -*/ -/*Requires a custom sqlite3.c -# undef SQLITE_OMIT_TRIGGER -# define SQLITE_OMIT_TRIGGER -*/ -/*TODO (requires build tweaks) -# undef SQLITE_OMIT_WINDOWFUNC -# define SQLITE_OMIT_WINDOWFUNC -*/ -/*Requires a custom sqlite3.c + OPTS='...' make -e sqlite3 + + where ... has a -D... for each of the following OMIT flags: + # undef SQLITE_OMIT_EXPLAIN # define SQLITE_OMIT_EXPLAIN -*/ -/*Requires a custom sqlite3.c + +# undef SQLITE_OMIT_TRIGGER +# define SQLITE_OMIT_TRIGGER + # undef SQLITE_OMIT_VIRTUALTABLE # define SQLITE_OMIT_VIRTUALTABLE + +# undef SQLITE_OMIT_WINDOWFUNC +# define SQLITE_OMIT_WINDOWFUNC + + As of this writing (2024-07-25), such a build fails in various ways + for as-yet-unknown reasons. */ -# undef SQLITE_OMIT_JSON -# define SQLITE_OMIT_JSON #endif -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL) +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_BARE_BONES) # define SQLITE_WASM_HAS_VTAB 1 #else # define SQLITE_WASM_HAS_VTAB 0 @@ -234,10 +242,6 @@ #undef INC__STRINGIFY #undef SQLITE_C -#if defined(__EMSCRIPTEN__) -# include -#endif - #if 0 /* ** An EXPERIMENT in implementing a stack-based allocator analog to @@ -1720,6 +1724,7 @@ char * sqlite3__wasm_qfmt_token(char *z, int addQuotes){ } #if defined(__EMSCRIPTEN__) && defined(SQLITE_ENABLE_WASMFS) +#include #include /* @@ -1941,5 +1946,5 @@ int sqlite3__wasm_SQLTester_strglob(const char *zGlob, const char *z){ #undef SQLITE_WASM_EXPORT #undef SQLITE_WASM_HAS_VTAB -#undef SQLITE_WASM_MINIMAL +#undef SQLITE_WASM_BARE_BONES #undef SQLITE_WASM_ENABLE_C_TESTS diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index 1f0d9e2ad0..b081d25155 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -41,10 +41,11 @@ fiddle.emcc-flags = \ $(emcc.exportedRuntimeMethods) \ -sEXPORTED_FUNCTIONS=@$(abspath $(EXPORTED_FUNCTIONS.fiddle)) \ -sEXPORTED_RUNTIME_METHODS=FS,wasmMemory \ - $(SQLITE_OPT) $(SHELL_OPT) \ - -USQLITE_WASM_MINIMAL \ + $(SQLITE_OPT.full-featured) \ + $(SQLITE_OPT.common) \ + $(SHELL_OPT) \ + -USQLITE_WASM_BARE_BONES \ -DSQLITE_SHELL_FIDDLE -# -D_POSIX_C_SOURCE is needed for strdup() with emcc # Flags specifically for debug builds of fiddle. Performance suffers # greatly in debug builds. @@ -55,7 +56,8 @@ fiddle.emcc-flags.debug := $(fiddle.emcc-flags) \ fiddle.EXPORTED_FUNCTIONS.in := \ EXPORTED_FUNCTIONS.fiddle.in \ - $(EXPORTED_FUNCTIONS.api) + $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-core \ + $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-extras $(EXPORTED_FUNCTIONS.fiddle): $(fiddle.EXPORTED_FUNCTIONS.in) $(MAKEFILE.fiddle) sort -u $(fiddle.EXPORTED_FUNCTIONS.in) > $@ diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index b8db1a59b2..6023069bc4 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -848,171 +848,176 @@ globalThis.sqlite3InitModule = sqlite3InitModule; }/*WhWasmUtil*/) //////////////////////////////////////////////////////////////////// - .t('sqlite3.StructBinder (jaccwabyt🐇)', function(sqlite3){ - const S = sqlite3, W = S.wasm; - const MyStructDef = { - sizeof: 16, - members: { - p4: {offset: 0, sizeof: 4, signature: "i"}, - pP: {offset: 4, sizeof: 4, signature: "P"}, - ro: {offset: 8, sizeof: 4, signature: "i", readOnly: true}, - cstr: {offset: 12, sizeof: 4, signature: "s"} + .t({ + name: 'sqlite3.StructBinder (jaccwabyt🐇)', + predicate: (sqlite3)=>!!sqlite3.wasm.exports.sqlite3__wasm_test_struct + || "Built without SQLITE_WASM_ENABLE_C_TESTS", + test: function(sqlite3){ + const S = sqlite3, W = S.wasm; + const MyStructDef = { + sizeof: 16, + members: { + p4: {offset: 0, sizeof: 4, signature: "i"}, + pP: {offset: 4, sizeof: 4, signature: "P"}, + ro: {offset: 8, sizeof: 4, signature: "i", readOnly: true}, + cstr: {offset: 12, sizeof: 4, signature: "s"} + } + }; + if(W.bigIntEnabled){ + const m = MyStructDef; + m.members.p8 = {offset: m.sizeof, sizeof: 8, signature: "j"}; + m.sizeof += m.members.p8.sizeof; } - }; - if(W.bigIntEnabled){ - const m = MyStructDef; - m.members.p8 = {offset: m.sizeof, sizeof: 8, signature: "j"}; - m.sizeof += m.members.p8.sizeof; - } - const StructType = S.StructBinder.StructType; - const K = S.StructBinder('my_struct',MyStructDef); - T.mustThrowMatching(()=>K(), /via 'new'/). - mustThrowMatching(()=>new K('hi'), /^Invalid pointer/); - const k1 = new K(), k2 = new K(); - try { - T.assert(k1.constructor === K). - assert(K.isA(k1)). - assert(k1 instanceof K). - assert(K.prototype.lookupMember('p4').key === '$p4'). - assert(K.prototype.lookupMember('$p4').name === 'p4'). - mustThrowMatching(()=>K.prototype.lookupMember('nope'), /not a mapped/). - assert(undefined === K.prototype.lookupMember('nope',false)). - assert(k1 instanceof StructType). - assert(StructType.isA(k1)). - mustThrowMatching(()=>k1.$ro = 1, /read-only/); - Object.keys(MyStructDef.members).forEach(function(key){ - key = K.memberKey(key); - T.assert(0 == k1[key], - "Expecting allocation to zero the memory "+ - "for "+key+" but got: "+k1[key]+ - " from "+k1.memoryDump()); - }); - T.assert('number' === typeof k1.pointer). - mustThrowMatching(()=>k1.pointer = 1, /pointer/); - k1.$p4 = 1; k1.$pP = 2; - T.assert(1 === k1.$p4).assert(2 === k1.$pP); - if(MyStructDef.members.$p8){ - k1.$p8 = 1/*must not throw despite not being a BigInt*/; - k1.$p8 = BigInt(Number.MAX_SAFE_INTEGER * 2); - T.assert(BigInt(2 * Number.MAX_SAFE_INTEGER) === k1.$p8); + const StructType = S.StructBinder.StructType; + const K = S.StructBinder('my_struct',MyStructDef); + T.mustThrowMatching(()=>K(), /via 'new'/). + mustThrowMatching(()=>new K('hi'), /^Invalid pointer/); + const k1 = new K(), k2 = new K(); + try { + T.assert(k1.constructor === K). + assert(K.isA(k1)). + assert(k1 instanceof K). + assert(K.prototype.lookupMember('p4').key === '$p4'). + assert(K.prototype.lookupMember('$p4').name === 'p4'). + mustThrowMatching(()=>K.prototype.lookupMember('nope'), /not a mapped/). + assert(undefined === K.prototype.lookupMember('nope',false)). + assert(k1 instanceof StructType). + assert(StructType.isA(k1)). + mustThrowMatching(()=>k1.$ro = 1, /read-only/); + Object.keys(MyStructDef.members).forEach(function(key){ + key = K.memberKey(key); + T.assert(0 == k1[key], + "Expecting allocation to zero the memory "+ + "for "+key+" but got: "+k1[key]+ + " from "+k1.memoryDump()); + }); + T.assert('number' === typeof k1.pointer). + mustThrowMatching(()=>k1.pointer = 1, /pointer/); + k1.$p4 = 1; k1.$pP = 2; + T.assert(1 === k1.$p4).assert(2 === k1.$pP); + if(MyStructDef.members.$p8){ + k1.$p8 = 1/*must not throw despite not being a BigInt*/; + k1.$p8 = BigInt(Number.MAX_SAFE_INTEGER * 2); + T.assert(BigInt(2 * Number.MAX_SAFE_INTEGER) === k1.$p8); + } + T.assert(!k1.ondispose); + k1.setMemberCString('cstr', "A C-string."); + T.assert(Array.isArray(k1.ondispose)). + assert(k1.ondispose[0] === k1.$cstr). + assert('number' === typeof k1.$cstr). + assert('A C-string.' === k1.memberToJsString('cstr')); + k1.$pP = k2; + T.assert(k1.$pP === k2.pointer); + k1.$pP = null/*null is special-cased to 0.*/; + T.assert(0===k1.$pP); + let ptr = k1.pointer; + k1.dispose(); + T.assert(undefined === k1.pointer). + mustThrowMatching(()=>{k1.$pP=1}, /disposed instance/); + }finally{ + k1.dispose(); + k2.dispose(); } - T.assert(!k1.ondispose); - k1.setMemberCString('cstr', "A C-string."); - T.assert(Array.isArray(k1.ondispose)). - assert(k1.ondispose[0] === k1.$cstr). - assert('number' === typeof k1.$cstr). - assert('A C-string.' === k1.memberToJsString('cstr')); - k1.$pP = k2; - T.assert(k1.$pP === k2.pointer); - k1.$pP = null/*null is special-cased to 0.*/; - T.assert(0===k1.$pP); - let ptr = k1.pointer; - k1.dispose(); - T.assert(undefined === k1.pointer). - mustThrowMatching(()=>{k1.$pP=1}, /disposed instance/); - }finally{ - k1.dispose(); - k2.dispose(); - } - if(!W.bigIntEnabled){ - log("Skipping WasmTestStruct tests: BigInt not enabled."); - return; - } + if(!W.bigIntEnabled){ + log("Skipping WasmTestStruct tests: BigInt not enabled."); + return; + } - const WTStructDesc = - W.ctype.structs.filter((e)=>'WasmTestStruct'===e.name)[0]; - const autoResolvePtr = true /* EXPERIMENTAL */; - if(autoResolvePtr){ - WTStructDesc.members.ppV.signature = 'P'; - } - const WTStruct = S.StructBinder(WTStructDesc); - //log(WTStruct.structName, WTStruct.structInfo); - const wts = new WTStruct(); - //log("WTStruct.prototype keys:",Object.keys(WTStruct.prototype)); - try{ - T.assert(wts.constructor === WTStruct). - assert(WTStruct.memberKeys().indexOf('$ppV')>=0). - assert(wts.memberKeys().indexOf('$v8')>=0). - assert(!K.isA(wts)). - assert(WTStruct.isA(wts)). - assert(wts instanceof WTStruct). - assert(wts instanceof StructType). - assert(StructType.isA(wts)). - assert(wts.pointer>0).assert(0===wts.$v4).assert(0n===wts.$v8). - assert(0===wts.$ppV).assert(0===wts.$xFunc); - const testFunc = - W.xGet('sqlite3__wasm_test_struct'/*name gets mangled in -O3 builds!*/); - let counter = 0; - //log("wts.pointer =",wts.pointer); - const wtsFunc = function(arg){ - /*log("This from a JS function called from C, "+ + const WTStructDesc = + W.ctype.structs.filter((e)=>'WasmTestStruct'===e.name)[0]; + const autoResolvePtr = true /* EXPERIMENTAL */; + if(autoResolvePtr){ + WTStructDesc.members.ppV.signature = 'P'; + } + const WTStruct = S.StructBinder(WTStructDesc); + //log(WTStruct.structName, WTStruct.structInfo); + const wts = new WTStruct(); + //log("WTStruct.prototype keys:",Object.keys(WTStruct.prototype)); + try{ + T.assert(wts.constructor === WTStruct). + assert(WTStruct.memberKeys().indexOf('$ppV')>=0). + assert(wts.memberKeys().indexOf('$v8')>=0). + assert(!K.isA(wts)). + assert(WTStruct.isA(wts)). + assert(wts instanceof WTStruct). + assert(wts instanceof StructType). + assert(StructType.isA(wts)). + assert(wts.pointer>0).assert(0===wts.$v4).assert(0n===wts.$v8). + assert(0===wts.$ppV).assert(0===wts.$xFunc); + const testFunc = + W.xGet('sqlite3__wasm_test_struct'/*name gets mangled in -O3 builds!*/); + let counter = 0; + //log("wts.pointer =",wts.pointer); + const wtsFunc = function(arg){ + /*log("This from a JS function called from C, "+ "which itself was called from JS. arg =",arg);*/ - ++counter; - if(3===counter){ - tossQuietly("Testing exception propagation."); + ++counter; + if(3===counter){ + tossQuietly("Testing exception propagation."); + } } + wts.$v4 = 10; wts.$v8 = 20; + wts.$xFunc = W.installFunction(wtsFunc, wts.memberSignature('xFunc')) + T.assert(0===counter).assert(10 === wts.$v4).assert(20n === wts.$v8) + .assert(0 === wts.$ppV).assert('number' === typeof wts.$xFunc) + .assert(0 === wts.$cstr) + .assert(wts.memberIsString('$cstr')) + .assert(!wts.memberIsString('$v4')) + .assert(null === wts.memberToJsString('$cstr')) + .assert(W.functionEntry(wts.$xFunc) instanceof Function); + /* It might seem silly to assert that the values match + what we just set, but recall that all of those property + reads and writes are, via property interceptors, + actually marshaling their data to/from a raw memory + buffer, so merely reading them back is actually part of + testing the struct-wrapping API. */ + + testFunc(wts.pointer); + //log("wts.pointer, wts.$ppV",wts.pointer, wts.$ppV); + T.assert(1===counter).assert(20 === wts.$v4).assert(40n === wts.$v8) + .assert(wts.$ppV === wts.pointer) + .assert('string' === typeof wts.memberToJsString('cstr')) + .assert(wts.memberToJsString('cstr') === wts.memberToJsString('$cstr')) + .mustThrowMatching(()=>wts.memberToJsString('xFunc'), + /Invalid member type signature for C-string/) + ; + testFunc(wts.pointer); + T.assert(2===counter).assert(40 === wts.$v4).assert(80n === wts.$v8) + .assert(wts.$ppV === wts.pointer); + /** The 3rd call to wtsFunc throw from JS, which is called + from C, which is called from JS. Let's ensure that + that exception propagates back here... */ + T.mustThrowMatching(()=>testFunc(wts.pointer),/^Testing/); + W.uninstallFunction(wts.$xFunc); + wts.$xFunc = 0; + wts.$ppV = 0; + T.assert(!wts.$ppV); + //WTStruct.debugFlags(0x03); + wts.$ppV = wts; + T.assert(wts.pointer === wts.$ppV) + wts.setMemberCString('cstr', "A C-string."); + T.assert(Array.isArray(wts.ondispose)). + assert(wts.ondispose[0] === wts.$cstr). + assert('A C-string.' === wts.memberToJsString('cstr')); + const ptr = wts.pointer; + wts.dispose(); + T.assert(ptr).assert(undefined === wts.pointer); + }finally{ + wts.dispose(); } - wts.$v4 = 10; wts.$v8 = 20; - wts.$xFunc = W.installFunction(wtsFunc, wts.memberSignature('xFunc')) - T.assert(0===counter).assert(10 === wts.$v4).assert(20n === wts.$v8) - .assert(0 === wts.$ppV).assert('number' === typeof wts.$xFunc) - .assert(0 === wts.$cstr) - .assert(wts.memberIsString('$cstr')) - .assert(!wts.memberIsString('$v4')) - .assert(null === wts.memberToJsString('$cstr')) - .assert(W.functionEntry(wts.$xFunc) instanceof Function); - /* It might seem silly to assert that the values match - what we just set, but recall that all of those property - reads and writes are, via property interceptors, - actually marshaling their data to/from a raw memory - buffer, so merely reading them back is actually part of - testing the struct-wrapping API. */ - - testFunc(wts.pointer); - //log("wts.pointer, wts.$ppV",wts.pointer, wts.$ppV); - T.assert(1===counter).assert(20 === wts.$v4).assert(40n === wts.$v8) - .assert(wts.$ppV === wts.pointer) - .assert('string' === typeof wts.memberToJsString('cstr')) - .assert(wts.memberToJsString('cstr') === wts.memberToJsString('$cstr')) - .mustThrowMatching(()=>wts.memberToJsString('xFunc'), - /Invalid member type signature for C-string/) - ; - testFunc(wts.pointer); - T.assert(2===counter).assert(40 === wts.$v4).assert(80n === wts.$v8) - .assert(wts.$ppV === wts.pointer); - /** The 3rd call to wtsFunc throw from JS, which is called - from C, which is called from JS. Let's ensure that - that exception propagates back here... */ - T.mustThrowMatching(()=>testFunc(wts.pointer),/^Testing/); - W.uninstallFunction(wts.$xFunc); - wts.$xFunc = 0; - wts.$ppV = 0; - T.assert(!wts.$ppV); - //WTStruct.debugFlags(0x03); - wts.$ppV = wts; - T.assert(wts.pointer === wts.$ppV) - wts.setMemberCString('cstr', "A C-string."); - T.assert(Array.isArray(wts.ondispose)). - assert(wts.ondispose[0] === wts.$cstr). - assert('A C-string.' === wts.memberToJsString('cstr')); - const ptr = wts.pointer; - wts.dispose(); - T.assert(ptr).assert(undefined === wts.pointer); - }finally{ - wts.dispose(); - } - if(1){ // ondispose of other struct instances - const s1 = new WTStruct, s2 = new WTStruct, s3 = new WTStruct; - T.assert(s1.lookupMember instanceof Function) - .assert(s1.addOnDispose instanceof Function); - s1.addOnDispose(s2,"testing variadic args"); - T.assert(2===s1.ondispose.length); - s2.addOnDispose(s3); - s1.dispose(); - T.assert(!s2.pointer,"Expecting s2 to be ondispose'd by s1."); - T.assert(!s3.pointer,"Expecting s3 to be ondispose'd by s2."); + if(1){ // ondispose of other struct instances + const s1 = new WTStruct, s2 = new WTStruct, s3 = new WTStruct; + T.assert(s1.lookupMember instanceof Function) + .assert(s1.addOnDispose instanceof Function); + s1.addOnDispose(s2,"testing variadic args"); + T.assert(2===s1.ondispose.length); + s2.addOnDispose(s3); + s1.dispose(); + T.assert(!s2.pointer,"Expecting s2 to be ondispose'd by s1."); + T.assert(!s3.pointer,"Expecting s3 to be ondispose'd by s2."); + } } }/*StructBinder*/) @@ -1126,75 +1131,84 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////////// T.g('sqlite3.oo1') - .t('Create db', function(sqlite3){ - const dbFile = '/tester1.db'; - sqlite3.util.sqlite3__wasm_vfs_unlink(0, dbFile); - const db = this.db = new sqlite3.oo1.DB(dbFile, 0 ? 'ct' : 'c'); - db.onclose = { - disposeAfter: [], - disposeBefore: [ - (db)=>{ - //console.debug("db.onclose.before dropping modules"); - //sqlite3.capi.sqlite3_drop_modules(db.pointer, 0); - } - ], - before: function(db){ - while(this.disposeBefore.length){ - const v = this.disposeBefore.shift(); - console.debug("db.onclose.before cleaning up:",v); - if(wasm.isPtr(v)) wasm.dealloc(v); - else if(v instanceof sqlite3.StructBinder.StructType){ - v.dispose(); - }else if(v instanceof Function){ - try{ v(db) } catch(e){ - console.warn("beforeDispose() callback threw:",e); + .t({ + name:'Create db', + //predicate: (sqlite3)=> + test: function(sqlite3){ + const dbFile = '/tester1.db'; + sqlite3.util.sqlite3__wasm_vfs_unlink(0, dbFile); + const db = this.db = new sqlite3.oo1.DB(dbFile, 0 ? 'ct' : 'c'); + db.onclose = { + disposeAfter: [], + disposeBefore: [ + (db)=>{ + //console.debug("db.onclose.before dropping modules"); + //sqlite3.capi.sqlite3_drop_modules(db.pointer, 0); + } + ], + before: function(db){ + while(this.disposeBefore.length){ + const v = this.disposeBefore.shift(); + console.debug("db.onclose.before cleaning up:",v); + if(wasm.isPtr(v)) wasm.dealloc(v); + else if(v instanceof sqlite3.StructBinder.StructType){ + v.dispose(); + }else if(v instanceof Function){ + try{ v(db) } catch(e){ + console.warn("beforeDispose() callback threw:",e); + } } } - } - }, - after: function(){ - while(this.disposeAfter.length){ - const v = this.disposeAfter.shift(); - console.debug("db.onclose.after cleaning up:",v); - if(wasm.isPtr(v)) wasm.dealloc(v); - else if(v instanceof sqlite3.StructBinder.StructType){ - v.dispose(); - }else if(v instanceof Function){ - try{v()} catch(e){/*ignored*/} + }, + after: function(){ + while(this.disposeAfter.length){ + const v = this.disposeAfter.shift(); + console.debug("db.onclose.after cleaning up:",v); + if(wasm.isPtr(v)) wasm.dealloc(v); + else if(v instanceof sqlite3.StructBinder.StructType){ + v.dispose(); + }else if(v instanceof Function){ + try{v()} catch(e){/*ignored*/} + } } } - } - }; - - T.assert(wasm.isPtr(db.pointer)) - .mustThrowMatching(()=>db.pointer=1, /read-only/) - .assert(0===sqlite3.capi.sqlite3_extended_result_codes(db.pointer,1)) - .assert('main'===db.dbName(0)) - .assert('string' === typeof db.dbVfsName()) - .assert(db.pointer === wasm.xWrap.testConvertArg('sqlite3*',db)); - // Custom db error message handling via sqlite3_prepare_v2/v3() - let rc = capi.sqlite3_prepare_v3(db.pointer, {/*invalid*/}, -1, 0, null, null); - T.assert(capi.SQLITE_MISUSE === rc) - .assert(0 === capi.sqlite3_errmsg(db.pointer).indexOf("Invalid SQL")) - .assert(dbFile === db.dbFilename()) - .assert(!db.dbFilename('nope')); - //Sanity check DB.checkRc()... - let ex; - try{db.checkRc(rc)} - catch(e){ex = e} - T.assert(ex instanceof sqlite3.SQLite3Error) - .assert(capi.SQLITE_MISUSE===ex.resultCode) - .assert(0===ex.message.indexOf("SQLITE_MISUSE: sqlite3 result code")) - .assert(ex.message.indexOf("Invalid SQL")>0); - T.assert(db === db.checkRc(0)) - .assert(db === sqlite3.oo1.DB.checkRc(db,0)) - .assert(null === sqlite3.oo1.DB.checkRc(null,0)); + }; - this.progressHandlerCount = 0; - capi.sqlite3_progress_handler(db, 5, (p)=>{ - ++this.progressHandlerCount; - return 0; - }, 0); + T.assert(wasm.isPtr(db.pointer)) + .mustThrowMatching(()=>db.pointer=1, /read-only/) + .assert(0===sqlite3.capi.sqlite3_extended_result_codes(db.pointer,1)) + .assert('main'===db.dbName(0)) + .assert('string' === typeof db.dbVfsName()) + .assert(db.pointer === wasm.xWrap.testConvertArg('sqlite3*',db)); + // Custom db error message handling via sqlite3_prepare_v2/v3() + let rc = capi.sqlite3_prepare_v3(db.pointer, {/*invalid*/}, -1, 0, null, null); + T.assert(capi.SQLITE_MISUSE === rc) + .assert(0 === capi.sqlite3_errmsg(db.pointer).indexOf("Invalid SQL")) + .assert(dbFile === db.dbFilename()) + .assert(!db.dbFilename('nope')); + //Sanity check DB.checkRc()... + let ex; + try{db.checkRc(rc)} + catch(e){ex = e} + T.assert(ex instanceof sqlite3.SQLite3Error) + .assert(capi.SQLITE_MISUSE===ex.resultCode) + .assert(0===ex.message.indexOf("SQLITE_MISUSE: sqlite3 result code")) + .assert(ex.message.indexOf("Invalid SQL")>0); + T.assert(db === db.checkRc(0)) + .assert(db === sqlite3.oo1.DB.checkRc(db,0)) + .assert(null === sqlite3.oo1.DB.checkRc(null,0)); + + this.progressHandlerCount = 0; + if( wasm.compileOptionUsed('OMIT_PROGRESS_CALLBACK') ){ + T.assert( !capi.sqlite3_progress_handler ); + }else{ + T.assert( capi.sqlite3_progress_handler ); + capi.sqlite3_progress_handler(db, 5, (p)=>{ + ++this.progressHandlerCount; + return 0; + }, 0); + } + } }) //////////////////////////////////////////////////////////////////// .t('sqlite3_db_config() and sqlite3_db_status()', function(sqlite3){ @@ -1236,7 +1250,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; new TextEncoder('utf-8').encode("select 3 as a") ); //debug("statement =",st); - this.progressHandlerCount = 0; + T.assert( !this.progressHandlerCount ); let rc; try { T.assert(wasm.isPtr(st.pointer)) @@ -1278,7 +1292,8 @@ globalThis.sqlite3InitModule = sqlite3InitModule; st, capi.SQLITE_STMTSTATUS_RUN, 0 ) > 0); - T.assert(this.progressHandlerCount > 0, + T.assert(this.progressHandlerCount>0 + || wasm.compileOptionUsed('OMIT_PROGRESS_CALLBACK'), "Expecting progress callback."). assert(0===capi.sqlite3_strglob("*.txt", "foo.txt")). assert(0!==capi.sqlite3_strglob("*.txt", "foo.xtx")). @@ -1363,7 +1378,8 @@ globalThis.sqlite3InitModule = sqlite3InitModule; .assert(2 === list.length) .assert('string'===typeof list[1]) .assert(3===db.changes()) - .assert(this.progressHandlerCount > 0, + .assert(this.progressHandlerCount > 0 + || wasm.compileOptionUsed('OMIT_PROGRESS_CALLBACK'), "Expecting progress callback.") if(wasm.bigIntEnabled){ T.assert(3n===db.changes(false,true)); @@ -1904,7 +1920,9 @@ globalThis.sqlite3InitModule = sqlite3InitModule; //////////////////////////////////////////////////////////////////// .t({ name: 'Window UDFs', - //predicate: ()=>false, + predicate: (sqlite3)=>!!sqlite3.wasm.exports.sqlite3_create_window_function + /*!sqlite3.wasm.compileOptionUsed('OMIT_WINDOWFUNC')*/ + || "Missing window functions", test: function(){ /* Example window function, table, and results taken from: https://sqlite.org/windowfunctions.html#udfwinfunc */ @@ -3132,7 +3150,10 @@ globalThis.sqlite3InitModule = sqlite3InitModule; ]); T.assert(2 === u1.getFileCount() /* one is the journal file */) .assert(3 === db.selectValue('select count(*) from t')) - .assert('wal'===db.selectValue('pragma journal_mode')); + .assert( + 'wal'===db.selectValue('pragma journal_mode') + || wasm.compileOptionUsed('OMIT_WAL') + ); db.close(); T.assert(1 === u1.getFileCount()); db = new u2.OpfsSAHPoolDb(dbName); diff --git a/manifest b/manifest index 6b6d0243f4..1df2fad795 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\swork\son\sthe\sminimal-mode\swasm\sbuild\s(now\s603kb\suncompressed).\sRemove\sthe\shard-coded\sfeature-enable\sflags\sfrom\ssqlite3-wasm.c\sand\srely\son\sthe\sbuild\sto\sprovide\sthem.\sSome\swasm\sbuild\scleanup,\sbut\sattempts\sto\scompletely\soverhaul\sit\shave\sbeen\sthwarted\sby\smy\sinability\sto\smake\sscript-generated\smakefile\scode\smore\slegible/maintainable\sthan\sthe\scurrent\seval\sspaghetti. -D 2024-07-25T14:00:26.899 +C Strip\sprogress\shandlers\sand\swindow\sfunctions\sfrom\sthe\swasm\sbare-bones\s(formerly\s'minimal')\sJS\sbits,\snoting\sthat\swe\scan't\syet\suse\sOMIT_WINDOWFUNC\s(for\sthe\sC\sparts)\swithout\sa\scustom\samalgamation.\sCurrently\sat\s604kb. +D 2024-07-25T16:21:19.087 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -593,7 +593,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile c89b6d0e7f969de03cfcbd5d5f64985ee9ba823a7be6b150fb9c2976c7adb0d6 +F ext/wasm/GNUmakefile 1857ad71bfdc780019639f49dc054fee491b4ddba2669898b8acfd4ffba50030 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -601,8 +601,8 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26 F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 38f85e6ec5f9c776087bc38aef9ef35eeb7e54942ddb1dd04e9ac0122958b741 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras 2a8c9f7d865cc6e5661b2cd40a45e963a1f8070a88def6ead4c40d4fa0c91998 +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 2bcbbfe3b95c043ed6037e2708a2ee078d212dd1612c364f93588d8dc97300fe +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras fe40d6d758646e38f8b15f709044951e10884214f5453d35502100179c388c13 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 @@ -612,7 +612,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 12f6f3840afdf8ff7a4374dc1a96a26bcc369e17853e0fe917c38f4d66c6e2d8 +F ext/wasm/api/sqlite3-api-glue.c-pp.js fb6dbfe692cc23000a65a4cd95a1a47ed5eb592dc9d8b55363b3c2952a787244 F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -622,7 +622,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 -F ext/wasm/api/sqlite3-wasm.c 79335b70d4d404b33fb485a4f65422a1ded0977c38e3b1a0cd8e26b49d3c9fba +F ext/wasm/api/sqlite3-wasm.c 83f5e9f998e9fa4261eb84e9f092210e3ffe03895119f5ded0429eb34ab9d2be F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -645,7 +645,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make 2406b02473878a99fb6a2eaff0923277017adc45eb041b2afb2d7707bf7b375c +F ext/wasm/fiddle.make b3b118516ed581cdf2c16de8eb1672427320e67ff19d710a09c891e895883644 F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 F ext/wasm/fiddle/index.html 739e0b75bc592679665d25e2f7649d2b8b2db678f3b41a772a8720b609b8482d @@ -669,7 +669,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js 7d0eba1496286338770133356488b4415de7970f4ee2c08f7f587bb18d8b6b0b +F ext/wasm/tester1.c-pp.js eb56110cd1959fc72c4001decc066ac7978912304e08aa402ca76527007cea5a F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2197,8 +2197,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ed746b3dd3248b68cb91de50ac5ba5fd3a7c2fcbde76324e86b88edbfecd896b -R acaefae7f2493e8276236de40774aafc +P b029c4067943e366a9b25b8303136fab10822bd771ea4658ac4cd716ff4a0d8f +R 4aba6600c1b56bb40f0e32cfcacb9fbe U stephan -Z 2f4bcd240a0ced338bed244e56f0f58c +Z c6f1d9cf14c3543f4f2774a34de2bf76 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 930c8e1a51..6de85ff0e9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b029c4067943e366a9b25b8303136fab10822bd771ea4658ac4cd716ff4a0d8f +ec02e9237e1ef81c4196fa630822cb109eab926143ad09593a24273eb0668601 From d35a69a8da0a5a5c54823df540f0217c1601816b Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 25 Jul 2024 16:28:55 +0000 Subject: [PATCH 0565/1030] Fix a non-bare-bones-mode test case broken by the previous checkin. FossilOrigin-Name: 3be729493b76a8b51c19d81543dea2dcb1fc718f81d4f2d9c6e1381789217687 --- ext/wasm/tester1.c-pp.js | 3 +-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 6023069bc4..fd67dc01c3 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -1197,12 +1197,11 @@ globalThis.sqlite3InitModule = sqlite3InitModule; T.assert(db === db.checkRc(0)) .assert(db === sqlite3.oo1.DB.checkRc(db,0)) .assert(null === sqlite3.oo1.DB.checkRc(null,0)); - this.progressHandlerCount = 0; if( wasm.compileOptionUsed('OMIT_PROGRESS_CALLBACK') ){ T.assert( !capi.sqlite3_progress_handler ); }else{ - T.assert( capi.sqlite3_progress_handler ); + T.assert( !!capi.sqlite3_progress_handler ); capi.sqlite3_progress_handler(db, 5, (p)=>{ ++this.progressHandlerCount; return 0; diff --git a/manifest b/manifest index 1df2fad795..c392f70d94 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Strip\sprogress\shandlers\sand\swindow\sfunctions\sfrom\sthe\swasm\sbare-bones\s(formerly\s'minimal')\sJS\sbits,\snoting\sthat\swe\scan't\syet\suse\sOMIT_WINDOWFUNC\s(for\sthe\sC\sparts)\swithout\sa\scustom\samalgamation.\sCurrently\sat\s604kb. -D 2024-07-25T16:21:19.087 +C Fix\sa\snon-bare-bones-mode\stest\scase\sbroken\sby\sthe\sprevious\scheckin. +D 2024-07-25T16:28:55.294 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -669,7 +669,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js eb56110cd1959fc72c4001decc066ac7978912304e08aa402ca76527007cea5a +F ext/wasm/tester1.c-pp.js bb8c41a56ca0eabb945ca2e8f06324a7b63ad91630959d714b071bee88322019 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2197,8 +2197,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b029c4067943e366a9b25b8303136fab10822bd771ea4658ac4cd716ff4a0d8f -R 4aba6600c1b56bb40f0e32cfcacb9fbe +P ec02e9237e1ef81c4196fa630822cb109eab926143ad09593a24273eb0668601 +R 72c1b5abda53d89da6a43993db19cd53 U stephan -Z c6f1d9cf14c3543f4f2774a34de2bf76 +Z 8d08c3414a4f5b6a65c45fd3dc3ee076 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6de85ff0e9..5054a64027 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec02e9237e1ef81c4196fa630822cb109eab926143ad09593a24273eb0668601 +3be729493b76a8b51c19d81543dea2dcb1fc718f81d4f2d9c6e1381789217687 From 2ec78c0e4bab11ce288a830c3a13fe34a9224c4a Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 26 Jul 2024 20:50:33 +0000 Subject: [PATCH 0566/1030] Add the fts5_locale() function, and begin adding the related functionality to fts5. FossilOrigin-Name: 8839ef7cfb49239e7f1c4812a53a93a672827c88d6921408b1d5062b352c87cc --- ext/fts5/fts5.h | 44 ++++- ext/fts5/fts5Int.h | 16 +- ext/fts5/fts5_config.c | 32 ++++ ext/fts5/fts5_main.c | 316 ++++++++++++++++++++++++++++++---- ext/fts5/fts5_storage.c | 105 +++++++---- ext/fts5/fts5_tcl.c | 99 ++++++++++- ext/fts5/test/fts5locale.test | 176 +++++++++++++++++++ manifest | 28 +-- manifest.uuid | 2 +- 9 files changed, 725 insertions(+), 93 deletions(-) create mode 100644 ext/fts5/test/fts5locale.test diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index d3042fcb8c..ccdebbe1ab 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -570,6 +570,29 @@ struct fts5_tokenizer { ); }; +typedef struct fts5_tokenizer_v2 fts5_tokenizer_v2; +struct fts5_tokenizer_v2 { + int iVersion; /* Currently always 2 */ + + int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); + void (*xDelete)(Fts5Tokenizer*); + int (*xTokenize)(Fts5Tokenizer*, + void *pCtx, + int flags, /* Mask of FTS5_TOKENIZE_* flags */ + const char *pText, int nText, + int (*xToken)( + void *pCtx, /* Copy of 2nd argument to xTokenize() */ + int tflags, /* Mask of FTS5_TOKEN_* flags */ + const char *pToken, /* Pointer to buffer containing token */ + int nToken, /* Size of token in bytes */ + int iStart, /* Byte offset of token within input text */ + int iEnd /* Byte offset of end of token within input text */ + ) + ); + + int (*xSetLocale)(Fts5Tokenizer*, const char *pLocale, int nLocale); +}; + /* Flags that may be passed as the third argument to xTokenize() */ #define FTS5_TOKENIZE_QUERY 0x0001 #define FTS5_TOKENIZE_PREFIX 0x0002 @@ -589,7 +612,7 @@ struct fts5_tokenizer { */ typedef struct fts5_api fts5_api; struct fts5_api { - int iVersion; /* Currently always set to 2 */ + int iVersion; /* Currently 3, was once 2 */ /* Create a new tokenizer */ int (*xCreateTokenizer)( @@ -616,6 +639,25 @@ struct fts5_api { fts5_extension_function xFunction, void (*xDestroy)(void*) ); + + /* APIs below this point are only available if iVersion>=3 */ + + /* Create a new tokenizer */ + int (*xCreateTokenizer_v2)( + fts5_api *pApi, + const char *zName, + void *pUserData, + fts5_tokenizer_v2 *pTokenizer, + void (*xDestroy)(void*) + ); + + /* Find an existing tokenizer */ + int (*xFindTokenizer_v2)( + fts5_api *pApi, + const char *zName, + void **ppUserData, + fts5_tokenizer_v2 **ppTokenizer + ); }; /* diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 4311faceb5..e8fdd8a4fa 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -162,7 +162,7 @@ typedef struct Fts5TokenizerConfig Fts5TokenizerConfig; struct Fts5TokenizerConfig { Fts5Tokenizer *pTok; - fts5_tokenizer *pTokApi; + fts5_tokenizer_v2 *pTokApi; const char **azArg; int nArg; int ePattern; /* FTS_PATTERN_XXX constant */ @@ -223,6 +223,7 @@ struct Fts5Config { char *zContentRowid; /* "content_rowid=" option value */ int bColumnsize; /* "columnsize=" option value (dflt==1) */ int bTokendata; /* "tokendata=" option value (dflt==0) */ + int bLocale; /* "locale=" option value (dflt==0) */ int eDetail; /* FTS5_DETAIL_XXX value */ char *zContentExprlist; Fts5TokenizerConfig t; @@ -292,6 +293,8 @@ int sqlite3Fts5ConfigSetValue(Fts5Config*, const char*, sqlite3_value*, int*); int sqlite3Fts5ConfigParseRank(const char*, char**, char**); +void sqlite3Fts5ConfigErrmsg(Fts5Config *pConfig, const char *zFmt, ...); + /* ** End of interface to code in fts5_config.c. **************************************************************************/ @@ -627,6 +630,17 @@ Fts5Table *sqlite3Fts5TableFromCsrid(Fts5Global*, i64); int sqlite3Fts5FlushToDisk(Fts5Table*); +int sqlite3Fts5ExtractText( + Fts5Config *pConfig, + int bContent, /* Loaded from content table */ + sqlite3_value *pVal, /* Value to extract text from */ + int *pbResetTokenizer, /* OUT: True if xSetLocale(NULL) required */ + const char **ppText, /* OUT: Pointer to text buffer */ + int *pnText /* OUT: Size of (*ppText) in bytes */ +); + +void sqlite3Fts5ClearLocale(Fts5Config *pConfig); + /* ** End of interface to code in fts5.c. **************************************************************************/ diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 01f40455a0..3736f8685f 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -380,6 +380,16 @@ static int fts5ConfigParseSpecial( return rc; } + if( sqlite3_strnicmp("locale", zCmd, nCmd)==0 ){ + if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\0' ){ + *pzErr = sqlite3_mprintf("malformed locale=... directive"); + rc = SQLITE_ERROR; + }else{ + pConfig->bLocale = (zArg[0]=='1'); + } + return rc; + } + if( sqlite3_strnicmp("detail", zCmd, nCmd)==0 ){ const Fts5Enum aDetail[] = { { "none", FTS5_DETAIL_NONE }, @@ -605,6 +615,11 @@ int sqlite3Fts5ConfigParse( sqlite3_free(zTwo); } + /* If this is not an FTS5_CONTENT_NORMAL table, set bLocale */ + if( pRet->eContent!=FTS5_CONTENT_NORMAL ){ + pRet->bLocale = 1; + } + /* We only allow contentless_delete=1 if the table is indeed contentless. */ if( rc==SQLITE_OK && pRet->bContentlessDelete @@ -1027,3 +1042,20 @@ int sqlite3Fts5ConfigLoad(Fts5Config *pConfig, int iCookie){ } return rc; } + +void sqlite3Fts5ConfigErrmsg(Fts5Config *pConfig, const char *zFmt, ...){ + va_list ap; /* ... printf arguments */ + char *zMsg = 0; + + va_start(ap, zFmt); + zMsg = sqlite3_vmprintf(zFmt, ap); + if( pConfig->pzErrmsg ){ + *pConfig->pzErrmsg = zMsg; + }else{ + sqlite3_free(zMsg); + } + + va_end(ap); +} + + diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index c6e7e346aa..06bbd820c6 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -107,7 +107,7 @@ struct Fts5Auxiliary { struct Fts5TokenizerModule { char *zName; /* Name of tokenizer */ void *pUserData; /* User pointer passed to xCreate() */ - fts5_tokenizer x; /* Tokenizer functions */ + fts5_tokenizer_v2 x; /* Tokenizer functions */ void (*xDestroy)(void*); /* Destructor function */ Fts5TokenizerModule *pNext; /* Next registered tokenizer module */ }; @@ -230,6 +230,8 @@ struct Fts5Cursor { #define BitFlagAllTest(x,y) (((x) & (y))==(y)) #define BitFlagTest(x,y) (((x) & (y))!=0) +#define FTS5_LOCALE_SUBTYPE ((unsigned int)'L') + /* ** Macros to Set(), Clear() and Test() cursor flags. @@ -1229,6 +1231,116 @@ static void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){ } +static int fts5SetLocale( + Fts5Config *pConfig, + const char *zLocale, + int nLocale +){ + Fts5TokenizerConfig *pT = &pConfig->t; + int rc = SQLITE_OK; + if( pT->pTokApi->xSetLocale ){ + rc = pT->pTokApi->xSetLocale(pT->pTok, zLocale, nLocale); + } + return rc; +} + +void sqlite3Fts5ClearLocale(Fts5Config *pConfig){ + fts5SetLocale(pConfig, 0, 0); +} + +int sqlite3Fts5ExtractText( + Fts5Config *pConfig, + int bContent, + sqlite3_value *pVal, /* Value to extract text from */ + int *pbResetTokenizer, /* OUT: True if xSetLocale(NULL) required */ + const char **ppText, /* OUT: Pointer to text buffer */ + int *pnText /* OUT: Size of (*ppText) in bytes */ +){ + const char *pText = 0; + int nText = 0; + int bResetTokenizer = 0; + int rc = SQLITE_OK; + + int bDecodeBlob = 0; + if( sqlite3_value_type(pVal)==SQLITE_BLOB ){ + if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE + || (bContent && pConfig->bLocale && pConfig->eContent==FTS5_CONTENT_NORMAL) + ){ + bDecodeBlob = 1; + } + } + + if( bDecodeBlob ){ + const u8 *pBlob = sqlite3_value_blob(pVal); + int nBlob = sqlite3_value_bytes(pVal); + int nLocale = 0; + + for(nLocale=0; nLocalep.pConfig, 0, pVal, &bReset, &zText,&nText); + if( rc==SQLITE_OK ){ + if( bReset ){ + *pzText = sqlite3Fts5Mprintf(&rc, "%.*s", nText, zText); + if( rc!=SQLITE_OK ){ + sqlite3Fts5ClearLocale(pTab->p.pConfig); + }else{ + *pbFreeAndReset = 1; + } + }else{ + *pzText = (char*)zText; + } + } + + return rc; +} + + /* ** This is the xFilter interface for the virtual table. See ** the virtual table xFilter method documentation for additional @@ -1293,8 +1405,13 @@ static int fts5FilterMethod( pRank = apVal[i]; break; case 'M': { - const char *zText = (const char*)sqlite3_value_text(apVal[i]); + char *zText = 0; + int bFreeAndReset = 0; + + rc = fts5ExtractExprText(pTab, apVal[i], &zText, &bFreeAndReset); + if( rc!=SQLITE_OK ) goto filter_out; if( zText==0 ) zText = ""; + iCol = 0; do{ iCol = iCol*10 + (idxStr[iIdxStr]-'0'); @@ -1306,7 +1423,6 @@ static int fts5FilterMethod( ** indicates that the MATCH expression is not a full text query, ** but a request for an internal parameter. */ rc = fts5SpecialMatch(pTab, pCsr, &zText[1]); - goto filter_out; }else{ char **pzErr = &pTab->p.base.zErrMsg; rc = sqlite3Fts5ExprNew(pConfig, 0, iCol, zText, &pExpr, pzErr); @@ -1314,9 +1430,15 @@ static int fts5FilterMethod( rc = sqlite3Fts5ExprAnd(&pCsr->pExpr, pExpr); pExpr = 0; } - if( rc!=SQLITE_OK ) goto filter_out; } + if( bFreeAndReset ){ + sqlite3_free(zText); + sqlite3Fts5ClearLocale(pConfig); + } + + if( zText[0]=='*' || rc!=SQLITE_OK ) goto filter_out; + break; } case 'L': @@ -2596,6 +2718,35 @@ static int fts5PoslistBlob(sqlite3_context *pCtx, Fts5Cursor *pCsr){ return rc; } +static void fts5ExtractValueFromColumn( + sqlite3_context *pCtx, + Fts5Config *pConfig, + sqlite3_value *pVal +){ + if( sqlite3_value_type(pVal)==SQLITE_BLOB ){ + if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE + || (pConfig->bLocale && pConfig->eContent==FTS5_CONTENT_NORMAL) + ){ + const u8 *pBlob = sqlite3_value_blob(pVal); + int nBlob = sqlite3_value_bytes(pVal); + + if( nBlob>=4 && memcmp(pBlob, "\0\0\0\0", 4)==0 ){ + sqlite3_result_blob(pCtx, &pBlob[4], nBlob-4, SQLITE_TRANSIENT); + }else{ + int ii; + for(ii=0; iipzErrmsg = &pTab->p.base.zErrMsg; rc = fts5SeekCursor(pCsr, 1); if( rc==SQLITE_OK ){ - sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1)); + sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); + fts5ExtractValueFromColumn(pCtx, pConfig, pVal); } pConfig->pzErrmsg = 0; }else if( pConfig->bContentlessDelete && sqlite3_vtab_nochange(pCtx) ){ @@ -2791,43 +2943,66 @@ static int fts5CreateAux( /* ** Register a new tokenizer. This is the implementation of the -** fts5_api.xCreateTokenizer() method. +** fts5_api.xCreateTokenizer_v2() method. */ -static int fts5CreateTokenizer( +static int fts5CreateTokenizer_v2( fts5_api *pApi, /* Global context (one per db handle) */ const char *zName, /* Name of new function */ void *pUserData, /* User data for aux. function */ - fts5_tokenizer *pTokenizer, /* Tokenizer implementation */ + fts5_tokenizer_v2 *pTokenizer, /* Tokenizer implementation */ void(*xDestroy)(void*) /* Destructor for pUserData */ ){ Fts5Global *pGlobal = (Fts5Global*)pApi; - Fts5TokenizerModule *pNew; - sqlite3_int64 nName; /* Size of zName and its \0 terminator */ - sqlite3_int64 nByte; /* Bytes of space to allocate */ int rc = SQLITE_OK; - nName = strlen(zName) + 1; - nByte = sizeof(Fts5TokenizerModule) + nName; - pNew = (Fts5TokenizerModule*)sqlite3_malloc64(nByte); - if( pNew ){ - memset(pNew, 0, (size_t)nByte); - pNew->zName = (char*)&pNew[1]; - memcpy(pNew->zName, zName, nName); - pNew->pUserData = pUserData; - pNew->x = *pTokenizer; - pNew->xDestroy = xDestroy; - pNew->pNext = pGlobal->pTok; - pGlobal->pTok = pNew; - if( pNew->pNext==0 ){ - pGlobal->pDfltTok = pNew; - } + if( pTokenizer->iVersion>2 ){ + rc = SQLITE_ERROR; }else{ - rc = SQLITE_NOMEM; + Fts5TokenizerModule *pNew; + sqlite3_int64 nName; /* Size of zName and its \0 terminator */ + sqlite3_int64 nByte; /* Bytes of space to allocate */ + + nName = strlen(zName) + 1; + nByte = sizeof(Fts5TokenizerModule) + nName; + pNew = (Fts5TokenizerModule*)sqlite3Fts5MallocZero(&rc, nByte); + if( pNew ){ + pNew->zName = (char*)&pNew[1]; + memcpy(pNew->zName, zName, nName); + pNew->pUserData = pUserData; + pNew->x = *pTokenizer; + pNew->xDestroy = xDestroy; + pNew->pNext = pGlobal->pTok; + pGlobal->pTok = pNew; + if( pNew->pNext==0 ){ + pGlobal->pDfltTok = pNew; + } + } } return rc; } +/* +** The fts5_api.xCreateTokenizer() method. +*/ +static int fts5CreateTokenizer( + fts5_api *pApi, /* Global context (one per db handle) */ + const char *zName, /* Name of new function */ + void *pUserData, /* User data for aux. function */ + fts5_tokenizer *pTokenizer, /* Tokenizer implementation */ + void(*xDestroy)(void*) /* Destructor for pUserData */ +){ + fts5_tokenizer_v2 tok; + + memset(&tok, 0, sizeof(tok)); + tok.iVersion = 2; + tok.xCreate = pTokenizer->xCreate; + tok.xTokenize = pTokenizer->xTokenize; + tok.xDelete = pTokenizer->xDelete; + + return fts5CreateTokenizer_v2(pApi, zName, pUserData, &tok, xDestroy); +} + static Fts5TokenizerModule *fts5LocateTokenizer( Fts5Global *pGlobal, const char *zName @@ -2847,29 +3022,53 @@ static Fts5TokenizerModule *fts5LocateTokenizer( /* ** Find a tokenizer. This is the implementation of the -** fts5_api.xFindTokenizer() method. +** fts5_api.xFindTokenizer_v2() method. */ -static int fts5FindTokenizer( +static int fts5FindTokenizer_v2( fts5_api *pApi, /* Global context (one per db handle) */ - const char *zName, /* Name of new function */ + const char *zName, /* Name of tokenizer */ void **ppUserData, - fts5_tokenizer *pTokenizer /* Populate this object */ + fts5_tokenizer_v2 **ppTokenizer /* Populate this object */ ){ int rc = SQLITE_OK; Fts5TokenizerModule *pMod; pMod = fts5LocateTokenizer((Fts5Global*)pApi, zName); if( pMod ){ - *pTokenizer = pMod->x; + *ppTokenizer = &pMod->x; *ppUserData = pMod->pUserData; }else{ - memset(pTokenizer, 0, sizeof(fts5_tokenizer)); + *ppTokenizer = 0; + *ppUserData = 0; rc = SQLITE_ERROR; } return rc; } +/* +** Find a tokenizer. This is the implementation of the +** fts5_api.xFindTokenizer() method. +*/ +static int fts5FindTokenizer( + fts5_api *pApi, /* Global context (one per db handle) */ + const char *zName, /* Name of new function */ + void **ppUserData, + fts5_tokenizer *pTokenizer /* Populate this object */ +){ + fts5_tokenizer_v2 *pV2 = 0; + int rc = SQLITE_OK; + + rc = fts5FindTokenizer_v2(pApi, zName, ppUserData, &pV2); + if( rc==SQLITE_OK ){ + pTokenizer->xCreate = pV2->xCreate; + pTokenizer->xDelete = pV2->xDelete; + pTokenizer->xTokenize = pV2->xTokenize; + } + + return rc; +} + int fts5GetTokenizer( Fts5Global *pGlobal, const char **azArg, @@ -2966,6 +3165,46 @@ static void fts5SourceIdFunc( sqlite3_result_text(pCtx, "--FTS5-SOURCE-ID--", -1, SQLITE_TRANSIENT); } +/* +** Implementation of fts5_locale() function. +*/ +static void fts5LocaleFunc( + sqlite3_context *pCtx, /* Function call context */ + int nArg, /* Number of args */ + sqlite3_value **apArg /* Function arguments */ +){ + u8 *pBlob = 0; + int nBlob = 0; + + const char *zLocale = 0; + int nLocale = 0; + const char *zText = 0; + int nText = 0; + + assert( nArg==2 ); + UNUSED_PARAM(nArg); + + zLocale = (const char*)sqlite3_value_text(apArg[0]); + nLocale = sqlite3_value_bytes(apArg[0]); + + zText = (const char*)sqlite3_value_text(apArg[1]); + nText = sqlite3_value_bytes(apArg[1]); + + nBlob = nLocale + 1 + nText; + pBlob = (u8*)sqlite3_malloc(nBlob); + if( pBlob==0 ){ + sqlite3_result_error_nomem(pCtx); + return; + } + + if( zLocale ) memcpy(pBlob, zLocale, nLocale); + pBlob[nLocale] = 0x00; + if( zText ) memcpy(&pBlob[nLocale+1], zText, nText); + + sqlite3_result_blob(pCtx, pBlob, nBlob, sqlite3_free); + sqlite3_result_subtype(pCtx, FTS5_LOCALE_SUBTYPE); +} + /* ** Return true if zName is the extension on one of the shadow tables used ** by this module. @@ -3058,10 +3297,12 @@ static int fts5Init(sqlite3 *db){ void *p = (void*)pGlobal; memset(pGlobal, 0, sizeof(Fts5Global)); pGlobal->db = db; - pGlobal->api.iVersion = 2; + pGlobal->api.iVersion = 3; pGlobal->api.xCreateFunction = fts5CreateAux; pGlobal->api.xCreateTokenizer = fts5CreateTokenizer; pGlobal->api.xFindTokenizer = fts5FindTokenizer; + pGlobal->api.xCreateTokenizer_v2 = fts5CreateTokenizer_v2; + pGlobal->api.xFindTokenizer_v2 = fts5FindTokenizer_v2; rc = sqlite3_create_module_v2(db, "fts5", &fts5Mod, p, fts5ModuleDestroy); if( rc==SQLITE_OK ) rc = sqlite3Fts5IndexInit(db); if( rc==SQLITE_OK ) rc = sqlite3Fts5ExprInit(pGlobal, db); @@ -3080,6 +3321,13 @@ static int fts5Init(sqlite3 *db){ p, fts5SourceIdFunc, 0, 0 ); } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function( + db, "fts5_locale", 2, + SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE, + p, fts5LocaleFunc, 0, 0 + ); + } } /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 0b676e6b4f..5d7f3f055e 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -429,26 +429,30 @@ static int fts5StorageDeleteFromIndex( ctx.iCol = -1; for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){ if( pConfig->abUnindexed[iCol-1]==0 ){ - const char *zText; - int nText; + sqlite3_value *pVal = 0; + const char *pText = 0; + int nText = 0; + int bReset = 0; + assert( pSeek==0 || apVal==0 ); assert( pSeek!=0 || apVal!=0 ); if( pSeek ){ - zText = (const char*)sqlite3_column_text(pSeek, iCol); - nText = sqlite3_column_bytes(pSeek, iCol); - }else if( ALWAYS(apVal) ){ - zText = (const char*)sqlite3_value_text(apVal[iCol-1]); - nText = sqlite3_value_bytes(apVal[iCol-1]); + pVal = sqlite3_column_value(pSeek, iCol); }else{ - continue; + pVal = apVal[iCol-1]; } - ctx.szCol = 0; - rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, - zText, nText, (void*)&ctx, fts5StorageInsertCallback - ); - p->aTotalSize[iCol-1] -= (i64)ctx.szCol; - if( p->aTotalSize[iCol-1]<0 && rc==SQLITE_OK ){ - rc = FTS5_CORRUPT; + + rc = sqlite3Fts5ExtractText(pConfig,pSeek!=0,pVal,&bReset,&pText,&nText); + if( rc==SQLITE_OK ){ + ctx.szCol = 0; + rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, + pText, nText, (void*)&ctx, fts5StorageInsertCallback + ); + p->aTotalSize[iCol-1] -= (i64)ctx.szCol; + if( p->aTotalSize[iCol-1]<0 && rc==SQLITE_OK ){ + rc = FTS5_CORRUPT; + } + if( bReset ) sqlite3Fts5ClearLocale(pConfig); } } } @@ -684,14 +688,22 @@ int sqlite3Fts5StorageRebuild(Fts5Storage *p){ for(ctx.iCol=0; rc==SQLITE_OK && ctx.iColnCol; ctx.iCol++){ ctx.szCol = 0; if( pConfig->abUnindexed[ctx.iCol]==0 ){ - const char *zText = (const char*)sqlite3_column_text(pScan, ctx.iCol+1); - int nText = sqlite3_column_bytes(pScan, ctx.iCol+1); - rc = sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, - zText, nText, - (void*)&ctx, - fts5StorageInsertCallback + int bReset = 0; + int nText = 0; + const char *pText = 0; + rc = sqlite3Fts5ExtractText(pConfig, 1, + sqlite3_column_value(pScan, ctx.iCol+1), &bReset, &pText, &nText ); + + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5Tokenize(pConfig, + FTS5_TOKENIZE_DOCUMENT, + pText, nText, + (void*)&ctx, + fts5StorageInsertCallback + ); + if( bReset ) sqlite3Fts5ClearLocale(pConfig); + } } sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol); p->aTotalSize[ctx.iCol] += (i64)ctx.szCol; @@ -810,14 +822,26 @@ int sqlite3Fts5StorageIndexInsert( for(ctx.iCol=0; rc==SQLITE_OK && ctx.iColnCol; ctx.iCol++){ ctx.szCol = 0; if( pConfig->abUnindexed[ctx.iCol]==0 ){ - const char *zText = (const char*)sqlite3_value_text(apVal[ctx.iCol+2]); - int nText = sqlite3_value_bytes(apVal[ctx.iCol+2]); - rc = sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, - zText, nText, - (void*)&ctx, - fts5StorageInsertCallback + int bReset = 0; + int nText = 0; + const char *pText = 0; + rc = sqlite3Fts5ExtractText( + pConfig, 0, apVal[ctx.iCol+2], &bReset, &pText, &nText ); + if( rc==SQLITE_OK ){ + if( bReset && pConfig->bLocale==0 ){ + rc = SQLITE_ERROR; + sqlite3Fts5ConfigErrmsg(pConfig, + "fts5_locale() may not be used without locale=1" + ); + }else{ + rc = sqlite3Fts5Tokenize(pConfig, + FTS5_TOKENIZE_DOCUMENT, pText, nText, (void*)&ctx, + fts5StorageInsertCallback + ); + } + if( bReset ) sqlite3Fts5ClearLocale(pConfig); + } } sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol); p->aTotalSize[ctx.iCol] += (i64)ctx.szCol; @@ -988,14 +1012,23 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg){ rc = sqlite3Fts5TermsetNew(&ctx.pTermset); } if( rc==SQLITE_OK ){ - const char *zText = (const char*)sqlite3_column_text(pScan, i+1); - int nText = sqlite3_column_bytes(pScan, i+1); - rc = sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, - zText, nText, - (void*)&ctx, - fts5StorageIntegrityCallback + const char *pText = 0; + int nText = 0; + int bReset = 0; + + rc = sqlite3Fts5ExtractText(pConfig, 1, + sqlite3_column_value(pScan, i+1), &bReset, &pText, &nText ); + + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5Tokenize(pConfig, + FTS5_TOKENIZE_DOCUMENT, + pText, nText, + (void*)&ctx, + fts5StorageIntegrityCallback + ); + if( bReset ) sqlite3Fts5ClearLocale(pConfig); + } } if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){ rc = FTS5_CORRUPT; diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index c5b5f41f83..c1fc7f82ae 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -801,6 +801,7 @@ typedef struct F5tTokenizerInstance F5tTokenizerInstance; struct F5tTokenizerContext { void *pCtx; int (*xToken)(void*, int, const char*, int, int, int); + F5tTokenizerInstance *pInst; }; struct F5tTokenizerModule { @@ -809,12 +810,37 @@ struct F5tTokenizerModule { F5tTokenizerContext *pContext; }; +/* +** zLocale: +** Buffer zLocale contains the current locale, as configured by the most +** recent call to xSetLocale(). A NULL (default) locale is represented as +** a 0 byte string - "\0". +** +** This can be retrieved by a Tcl tokenize script using [sqlite3_fts5_locale]. +*/ struct F5tTokenizerInstance { Tcl_Interp *interp; Tcl_Obj *pScript; F5tTokenizerContext *pContext; + char zLocale[128]; }; +static int f5tTokenizerSetLocale( + Fts5Tokenizer *pTokenizer, + const char *pLocale, + int nLocale +){ + F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)pTokenizer; + if( nLocale>=sizeof(pInst->zLocale) ){ + return SQLITE_ERROR; + } + + memset(pInst->zLocale, 0, sizeof(pInst->zLocale)); + memcpy(pInst->zLocale, pLocale, nLocale); + + return SQLITE_OK; +} + static int f5tTokenizerCreate( void *pCtx, const char **azArg, @@ -867,6 +893,7 @@ static int f5tTokenizerTokenize( int (*xToken)(void*, int, const char*, int, int, int) ){ F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)p; + F5tTokenizerInstance *pOldInst = 0; void *pOldCtx; int (*xOldToken)(void*, int, const char*, int, int, int); Tcl_Obj *pEval; @@ -875,9 +902,11 @@ static int f5tTokenizerTokenize( pOldCtx = pInst->pContext->pCtx; xOldToken = pInst->pContext->xToken; + pOldInst = pInst->pContext->pInst; pInst->pContext->pCtx = pCtx; pInst->pContext->xToken = xToken; + pInst->pContext->pInst = pInst; assert( flags==FTS5_TOKENIZE_DOCUMENT @@ -913,9 +942,37 @@ static int f5tTokenizerTokenize( pInst->pContext->pCtx = pOldCtx; pInst->pContext->xToken = xOldToken; + pInst->pContext->pInst = pOldInst; return rc; } +/* +** sqlite3_fts5_locale +*/ +static int SQLITE_TCLAPI f5tTokenizerLocale( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + F5tTokenizerContext *p = (F5tTokenizerContext*)clientData; + + if( objc!=1 ){ + Tcl_WrongNumArgs(interp, 1, objv, ""); + return TCL_ERROR; + } + + if( p->xToken==0 ){ + Tcl_AppendResult(interp, + "sqlite3_fts5_locale may only be used by tokenizer callback", 0 + ); + return TCL_ERROR; + } + + Tcl_SetObjResult(interp, Tcl_NewStringObj(p->pInst->zLocale, -1)); + return TCL_OK; +} + /* ** sqlite3_fts5_token ?-colocated? TEXT START END */ @@ -1001,12 +1058,21 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( fts5_api *pApi; char *zName; Tcl_Obj *pScript; - fts5_tokenizer t; F5tTokenizerModule *pMod; int rc; + int bV2 = 0; /* True to use _v2 API */ + + if( objc==5 ){ + const char *zArg = Tcl_GetString(objv[1]); + if( 0==strcmp(zArg, "-v2") ){ + objv++; + objc--; + bV2 = 1; + } + } if( objc!=4 ){ - Tcl_WrongNumArgs(interp, 1, objv, "DB NAME SCRIPT"); + Tcl_WrongNumArgs(interp, 1, objv, "?-v2? DB NAME SCRIPT"); return TCL_ERROR; } if( f5tDbAndApi(interp, objv[1], &db, &pApi) ){ @@ -1015,18 +1081,34 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( zName = Tcl_GetString(objv[2]); pScript = objv[3]; - t.xCreate = f5tTokenizerCreate; - t.xTokenize = f5tTokenizerTokenize; - t.xDelete = f5tTokenizerDelete; - pMod = (F5tTokenizerModule*)ckalloc(sizeof(F5tTokenizerModule)); pMod->interp = interp; pMod->pScript = pScript; pMod->pContext = pContext; Tcl_IncrRefCount(pScript); - rc = pApi->xCreateTokenizer(pApi, zName, (void*)pMod, &t, f5tDelTokenizer); + + if( bV2==0 ){ + fts5_tokenizer t; + t.xCreate = f5tTokenizerCreate; + t.xTokenize = f5tTokenizerTokenize; + t.xDelete = f5tTokenizerDelete; + rc = pApi->xCreateTokenizer(pApi, zName, (void*)pMod, &t, f5tDelTokenizer); + }else{ + fts5_tokenizer_v2 t2; + memset(&t2, 0, sizeof(t2)); + t2.iVersion = 2; + t2.xCreate = f5tTokenizerCreate; + t2.xTokenize = f5tTokenizerTokenize; + t2.xDelete = f5tTokenizerDelete; + t2.xSetLocale = f5tTokenizerSetLocale; + rc = pApi->xCreateTokenizer_v2(pApi, zName,(void*)pMod,&t2,f5tDelTokenizer); + } + if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, "error in fts5_api.xCreateTokenizer()", 0); + Tcl_AppendResult(interp, ( + bV2 ? "error in fts5_api.xCreateTokenizer_v2()" + : "error in fts5_api.xCreateTokenizer()" + ), 0); return TCL_ERROR; } @@ -1333,6 +1415,7 @@ int Fts5tcl_Init(Tcl_Interp *interp){ } aCmd[] = { { "sqlite3_fts5_create_tokenizer", f5tCreateTokenizer, 1 }, { "sqlite3_fts5_token", f5tTokenizerReturn, 1 }, + { "sqlite3_fts5_locale", f5tTokenizerLocale, 1 }, { "sqlite3_fts5_tokenize", f5tTokenize, 0 }, { "sqlite3_fts5_create_function", f5tCreateFunction, 0 }, { "sqlite3_fts5_may_be_corrupt", f5tMayBeCorrupt, 0 }, diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test new file mode 100644 index 0000000000..923990f5a9 --- /dev/null +++ b/ext/fts5/test/fts5locale.test @@ -0,0 +1,176 @@ +# 2014 Dec 20 +# +# 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. +# +#*********************************************************************** +# +# Tests focusing on the built-in fts5 tokenizers. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5locale + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +proc transform_token {locale token} { + switch -- $locale { + reverse { + set ret "" + foreach c [split $token ""] { + set ret "$c$ret" + } + set token $ret + } + + default { + # no-op + } + } + + set token +} + +proc tcl_create {args} { return "tcl_tokenize" } +proc tcl_tokenize {tflags text} { + foreach {w iStart iEnd} [fts5_tokenize_split $text] { + set w [transform_token [sqlite3_fts5_locale] $w] + sqlite3_fts5_token $w $iStart $iEnd + } +} + +#------------------------------------------------------------------------- +# Check that queries can have a locale attached to them. +# +reset_db +sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, tokenize=tcl); + INSERT INTO t1 VALUES('abc'); + INSERT INTO t1 VALUES('cba'); +} {} + +do_execsql_test 1.1 { + SELECT rowid, a FROM t1( fts5_locale('en_US', 'abc') ); +} {1 abc} + +do_execsql_test 1.2 { + SELECT rowid, a FROM t1( fts5_locale('reverse', 'abc') ); +} {2 cba} + +#------------------------------------------------------------------------- +# Test that the locale= option exists and seems to accept values. And +# that fts5_locale() values may only be inserted into an internal-content +# table if the locale=1 option was specified. +# +reset_db +sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create + +do_execsql_test 2.1 { + CREATE VIRTUAL TABLE b1 USING fts5(x, y, locale=1, tokenize=tcl); + CREATE VIRTUAL TABLE b2 USING fts5(x, y, locale=0, tokenize=tcl); + + CREATE VIRTUAL TABLE ttt USING fts5vocab('b1', instance); +} + +do_catchsql_test 2.2 { + CREATE VIRTUAL TABLE b3 USING fts5(x, y, locale=2); +} {1 {malformed locale=... directive}} + +do_catchsql_test 2.3 { + INSERT INTO b1(b1, rank) VALUES('locale', 0); +} {1 {SQL logic error}} + +do_execsql_test 2.4 { + INSERT INTO b1 VALUES('abc', 'one two three'); + INSERT INTO b1 VALUES('def', fts5_locale('reverse', 'four five six')); +} + +do_execsql_test 2.5 { + INSERT INTO b2 VALUES('abc', 'one two three'); +} + +do_catchsql_test 2.6 { + INSERT INTO b2 VALUES('def', fts5_locale('reverse', 'four five six')); +} {1 {fts5_locale() may not be used without locale=1}} + +do_execsql_test 2.7 { SELECT rowid FROM b1('one') } {1} +do_execsql_test 2.8 { SELECT rowid FROM b1('four') } {} +do_execsql_test 2.9 { SELECT rowid FROM b1('ruof') } 2 +do_execsql_test 2.10 { SELECT rowid FROM b1(fts5_locale('reverse', 'five'))} 2 + +do_execsql_test 2.11 { + SELECT x, quote(y) FROM b1 +} { + abc {'one two three'} + def {'four five six'} +} + +do_execsql_test 2.12 { SELECT quote(y) FROM b1('ruof') } { + {'four five six'} +} + +do_execsql_test 2.13 { + INSERT INTO b1(b1) VALUES('integrity-check'); +} +do_execsql_test 2.14 { + INSERT INTO b1(b1) VALUES('rebuild'); +} +do_execsql_test 2.15 { + INSERT INTO b1(b1) VALUES('integrity-check'); +} + +do_execsql_test 2.16 { + DELETE FROM b1 WHERE rowid=2 +} +do_execsql_test 2.17 { + INSERT INTO b1(b1) VALUES('integrity-check'); +} + +#------------------------------------------------------------------------- +# Test the 'delete' command with contentless tables. +# +reset_db +sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create + +do_execsql_test 3.1 { + CREATE VIRTUAL TABLE c1 USING fts5(x, content=, tokenize=tcl); + CREATE VIRTUAL TABLE c2 USING fts5vocab('c1', instance); + + INSERT INTO c1 VALUES('hello world'); + INSERT INTO c1 VALUES( fts5_locale('reverse', 'one two three') ); +} + +do_execsql_test 3.2 { + SELECT DISTINCT term FROM c2 ORDER BY 1 +} { + eerht eno hello owt world +} + +do_execsql_test 3.3 { + INSERT INTO c1(c1, rowid, x) + VALUES('delete', 2, fts5_locale('reverse', 'one two three') ); +} + +do_execsql_test 3.4 { + SELECT DISTINCT term FROM c2 ORDER BY 1 +} { + hello world +} + + + +# execsql_pp { SELECT * FROM ttt } + +finish_test + + diff --git a/manifest b/manifest index bccfb3c0a2..6f223ff085 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\spercentile\sextension\sto\sthe\sCLI\sby\sdefault. -D 2024-07-24T13:53:51.649 +C Add\sthe\sfts5_locale()\sfunction,\sand\sbegin\sadding\sthe\srelated\sfunctionality\sto\sfts5. +D 2024-07-26T20:50:33.303 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,17 +92,17 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h 6b49ce6eb2e395e7fd84557b21d32f5de8041f2fada4c617e481e99427e24b6e -F ext/fts5/fts5Int.h 41fb3a2dd40e818cc96c6f4176dbdf2aaa8f57043cfc9a8f2676e7e6a72ad764 +F ext/fts5/fts5.h 38a9553791828b3cf677b9347735fc531d54015ce4f5229d5cf1e2a5c1d3955a +F ext/fts5/fts5Int.h b4a5ed934cb3da55737c4d75cb5f26a39b17470fca67c06c7fe6878992998c99 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 +F ext/fts5/fts5_config.c 0c96490fbad746b3780174f38b2ee5e3d719f2f81ee6b58ca828772871e0f680 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 77fefb37e7931095a5ff271a28fbe4f73ec46d5492ef1f35d405d98e137ad8ed -F ext/fts5/fts5_storage.c 1d7e08d4331da2f3f7e78e70eef2ed6a013d91ba16175c651adbc5ad672235aa -F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 +F ext/fts5/fts5_main.c 5b6f85aae5f25ee4e8762f26eb8c998c9c53443bb56483ebf712aca591bcb41e +F ext/fts5/fts5_storage.c 1d7b358af3d4a7a4c5a7258a847229ca54c1b26d4f1b9e971ea5f2539631c3d4 +F ext/fts5/fts5_tcl.c a1c307785bb505735a8d914fff7d08881e64ba28c40c406b218c591010d1bc9e F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be @@ -184,6 +184,7 @@ F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fd F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c +F ext/fts5/test/fts5locale.test 92c6ae79df0aa57b379c50e400151f4a9a36d292819beefc31019c749249844a F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2195,8 +2196,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 095c22e62248f8ef50cd8531171827f50a7bdd4fc1128bf0e616a3eb2dce980e -R 76e7f4761efc98a28727d2a1442d8c13 -U drh -Z 956d236c4ff2c748d10dde2ade86c2ae +P bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04 +R f9f51b6d625a93fd57b76dfee17ab828 +T *branch * fts5-locale +T *sym-fts5-locale * +T -sym-trunk * +U dan +Z 2b42cc25153434047e86f4740a226c4e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c7d267a281..64398355c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04 +8839ef7cfb49239e7f1c4812a53a93a672827c88d6921408b1d5062b352c87cc From 53bef48fbed08188030db5265f01ff504b6985f2 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 27 Jul 2024 19:46:10 +0000 Subject: [PATCH 0567/1030] Ensure that an fts5 UPDATE does not strip the locale from columns that it does not write to. FossilOrigin-Name: 69205264debd829573b1c777a5a493cfeb6083c4cdec106b1f819989f859ac75 --- ext/fts5/fts5Int.h | 5 +- ext/fts5/fts5_main.c | 78 ++++++++++++++++--------- ext/fts5/fts5_storage.c | 105 ++++++++++++++++++++++++++-------- ext/fts5/test/fts5locale.test | 47 ++++++++++++++- ext/fts5/test/fts5simple.test | 1 + manifest | 23 ++++---- manifest.uuid | 2 +- 7 files changed, 193 insertions(+), 68 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index e8fdd8a4fa..1cc25ae7e0 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -720,7 +720,7 @@ int sqlite3Fts5StorageRename(Fts5Storage*, const char *zName); int sqlite3Fts5DropAll(Fts5Config*); int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **); -int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**); +int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**, int); int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*); int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64); @@ -746,6 +746,9 @@ int sqlite3Fts5StorageOptimize(Fts5Storage *p); int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge); int sqlite3Fts5StorageReset(Fts5Storage *p); +void sqlite3Fts5StorageReleaseDeleteRow(Fts5Storage*); +int sqlite3Fts5StorageFindDeleteRow(Fts5Storage *p, i64 iDel); + /* ** End of interface to code in fts5_storage.c. **************************************************************************/ diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 06bbd820c6..611c08a57e 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1746,7 +1746,7 @@ static int fts5SpecialDelete( int eType1 = sqlite3_value_type(apVal[1]); if( eType1==SQLITE_INTEGER ){ sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]); - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, &apVal[2]); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, &apVal[2], 0); } return rc; } @@ -1870,7 +1870,7 @@ static int fts5UpdateMethod( /* DELETE */ else if( nArg==1 ){ i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0); bUpdateOrDelete = 1; } @@ -1878,16 +1878,18 @@ static int fts5UpdateMethod( else{ int eType1 = sqlite3_value_numeric_type(apVal[1]); - if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){ + if( (eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL) + || (eType0==SQLITE_INTEGER && eType1==SQLITE_NULL) + ){ rc = SQLITE_MISMATCH; } - else if( eType0!=SQLITE_INTEGER ){ + else if( eType0!=SQLITE_INTEGER ){ /* An INSERT statement. If the conflict-mode is REPLACE, first remove ** the current entry (if any). */ if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0); bUpdateOrDelete = 1; } fts5StorageInsert(&rc, pTab, apVal, pRowid); @@ -1897,28 +1899,34 @@ static int fts5UpdateMethod( else{ i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */ i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */ - if( eType1==SQLITE_INTEGER && iOld!=iNew ){ + assert( eType1==SQLITE_INTEGER ); + if( iOld!=iNew ){ if( eConflict==SQLITE_REPLACE ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1); if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0); } fts5StorageInsert(&rc, pTab, apVal, pRowid); }else{ - rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid); + rc = sqlite3Fts5StorageFindDeleteRow(pTab->pStorage, iOld); if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); + rc = sqlite3Fts5StorageContentInsert(pTab->pStorage,apVal,pRowid); + } + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1); } if( rc==SQLITE_OK ){ rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid); } } }else{ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1); fts5StorageInsert(&rc, pTab, apVal, pRowid); } bUpdateOrDelete = 1; + sqlite3Fts5StorageReleaseDeleteRow(pTab->pStorage); } + } } @@ -2606,6 +2614,16 @@ static Fts5Cursor *fts5CursorFromCsrid(Fts5Global *pGlobal, i64 iCsrId){ return pCsr; } +static void fts5ResultError(sqlite3_context *pCtx, const char *zFmt, ...){ + char *zErr = 0; + va_list ap; + va_start(ap, zFmt); + zErr = sqlite3_vmprintf(zFmt, ap); + sqlite3_result_error(pCtx, zErr, -1); + sqlite3_free(zErr); + va_end(ap); +} + static void fts5ApiCallback( sqlite3_context *context, int argc, @@ -2622,9 +2640,7 @@ static void fts5ApiCallback( pCsr = fts5CursorFromCsrid(pAux->pGlobal, iCsrId); if( pCsr==0 || pCsr->ePlan==0 ){ - char *zErr = sqlite3_mprintf("no such cursor: %lld", iCsrId); - sqlite3_result_error(context, zErr, -1); - sqlite3_free(zErr); + fts5ResultError(context, "no such cursor: %lld", iCsrId); }else{ sqlite3_vtab *pTab = pCsr->base.pVtab; fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]); @@ -2776,8 +2792,8 @@ static int fts5ColumnMethod( ** auxiliary function. */ sqlite3_result_int64(pCtx, pCsr->iCsrId); }else if( iCol==pConfig->nCol+1 ){ - /* The value of the "rank" column. */ + if( pCsr->ePlan==FTS5_PLAN_SOURCE ){ fts5PoslistBlob(pCtx, pCsr); }else if( @@ -2788,21 +2804,27 @@ static int fts5ColumnMethod( fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg); } } - }else if( !fts5IsContentless(pTab) ){ - pConfig->pzErrmsg = &pTab->p.base.zErrMsg; - rc = fts5SeekCursor(pCsr, 1); - if( rc==SQLITE_OK ){ - sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); - fts5ExtractValueFromColumn(pCtx, pConfig, pVal); + }else{ + /* A column created by the user containing values. */ + int bNochange = sqlite3_vtab_nochange(pCtx); + + if( fts5IsContentless(pTab) ){ + if( bNochange && pConfig->bContentlessDelete ){ + fts5ResultError(pCtx, "cannot UPDATE a subset of " + "columns on fts5 contentless-delete table: %s", pConfig->zName + ); + } + }else if( bNochange==0 || pConfig->eContent!=FTS5_CONTENT_NORMAL ){ + pConfig->pzErrmsg = &pTab->p.base.zErrMsg; + rc = fts5SeekCursor(pCsr, 1); + if( rc==SQLITE_OK ){ + sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); + fts5ExtractValueFromColumn(pCtx, pConfig, pVal); + } + pConfig->pzErrmsg = 0; } - pConfig->pzErrmsg = 0; - }else if( pConfig->bContentlessDelete && sqlite3_vtab_nochange(pCtx) ){ - char *zErr = sqlite3_mprintf("cannot UPDATE a subset of " - "columns on fts5 contentless-delete table: %s", pConfig->zName - ); - sqlite3_result_error(pCtx, zErr, -1); - sqlite3_free(zErr); } + return rc; } diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 5d7f3f055e..f94c2ea908 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -22,7 +22,8 @@ struct Fts5Storage { int bTotalsValid; /* True if nTotalRow/aTotalSize[] are valid */ i64 nTotalRow; /* Total number of rows in FTS table */ i64 *aTotalSize; /* Total sizes of each column */ - sqlite3_stmt *aStmt[11]; + sqlite3_stmt *pSavedRow; + sqlite3_stmt *aStmt[12]; }; @@ -36,14 +37,15 @@ struct Fts5Storage { # error "FTS5_STMT_LOOKUP mismatch" #endif -#define FTS5_STMT_INSERT_CONTENT 3 -#define FTS5_STMT_REPLACE_CONTENT 4 -#define FTS5_STMT_DELETE_CONTENT 5 -#define FTS5_STMT_REPLACE_DOCSIZE 6 -#define FTS5_STMT_DELETE_DOCSIZE 7 -#define FTS5_STMT_LOOKUP_DOCSIZE 8 -#define FTS5_STMT_REPLACE_CONFIG 9 -#define FTS5_STMT_SCAN 10 +#define FTS5_STMT_LOOKUP2 3 +#define FTS5_STMT_INSERT_CONTENT 4 +#define FTS5_STMT_REPLACE_CONTENT 5 +#define FTS5_STMT_DELETE_CONTENT 6 +#define FTS5_STMT_REPLACE_DOCSIZE 7 +#define FTS5_STMT_DELETE_DOCSIZE 8 +#define FTS5_STMT_LOOKUP_DOCSIZE 9 +#define FTS5_STMT_REPLACE_CONFIG 10 +#define FTS5_STMT_SCAN 11 /* ** Prepare the two insert statements - Fts5Storage.pInsertContent and @@ -73,6 +75,7 @@ static int fts5StorageGetStmt( "SELECT %s FROM %s T WHERE T.%Q >= ? AND T.%Q <= ? ORDER BY T.%Q ASC", "SELECT %s FROM %s T WHERE T.%Q <= ? AND T.%Q >= ? ORDER BY T.%Q DESC", "SELECT %s FROM %s T WHERE T.%Q=?", /* LOOKUP */ + "SELECT %s FROM %s T WHERE T.%Q=?", /* LOOKUP2 */ "INSERT INTO %Q.'%q_content' VALUES(%s)", /* INSERT_CONTENT */ "REPLACE INTO %Q.'%q_content' VALUES(%s)", /* REPLACE_CONTENT */ @@ -88,6 +91,8 @@ static int fts5StorageGetStmt( Fts5Config *pC = p->pConfig; char *zSql = 0; + assert( ArraySize(azStmt)==ArraySize(p->aStmt) ); + switch( eStmt ){ case FTS5_STMT_SCAN: zSql = sqlite3_mprintf(azStmt[eStmt], @@ -104,6 +109,7 @@ static int fts5StorageGetStmt( break; case FTS5_STMT_LOOKUP: + case FTS5_STMT_LOOKUP2: zSql = sqlite3_mprintf(azStmt[eStmt], pC->zContentExprlist, pC->zContent, pC->zContentRowid ); @@ -150,7 +156,7 @@ static int fts5StorageGetStmt( rc = SQLITE_NOMEM; }else{ int f = SQLITE_PREPARE_PERSISTENT; - if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB; + if( eStmt>FTS5_STMT_LOOKUP2 ) f |= SQLITE_PREPARE_NO_VTAB; p->pConfig->bLock++; rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0); p->pConfig->bLock--; @@ -399,6 +405,24 @@ static int fts5StorageInsertCallback( return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken); } +int sqlite3Fts5StorageFindDeleteRow(Fts5Storage *p, i64 iDel){ + int rc = SQLITE_OK; + sqlite3_stmt *pSeek = 0; + + assert( p->pSavedRow==0 ); + rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP+1, &pSeek, 0); + if( rc==SQLITE_OK ){ + sqlite3_bind_int64(pSeek, 1, iDel); + if( sqlite3_step(pSeek)!=SQLITE_ROW ){ + rc = sqlite3_reset(pSeek); + }else{ + p->pSavedRow = pSeek; + } + } + + return rc; +} + /* ** If a row with rowid iDel is present in the %_content table, add the ** delete-markers to the FTS index necessary to delete it. Do not actually @@ -407,7 +431,8 @@ static int fts5StorageInsertCallback( static int fts5StorageDeleteFromIndex( Fts5Storage *p, i64 iDel, - sqlite3_value **apVal + sqlite3_value **apVal, + int bSaveRow ){ Fts5Config *pConfig = p->pConfig; sqlite3_stmt *pSeek = 0; /* SELECT to read row iDel from %_data */ @@ -416,12 +441,21 @@ static int fts5StorageDeleteFromIndex( int iCol; Fts5InsertCtx ctx; + assert( bSaveRow==0 || apVal==0 ); + assert( bSaveRow==0 || bSaveRow==1 ); + assert( FTS5_STMT_LOOKUP2==FTS5_STMT_LOOKUP+1 ); + if( apVal==0 ){ - rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP, &pSeek, 0); - if( rc!=SQLITE_OK ) return rc; - sqlite3_bind_int64(pSeek, 1, iDel); - if( sqlite3_step(pSeek)!=SQLITE_ROW ){ - return sqlite3_reset(pSeek); + if( p->pSavedRow && bSaveRow ){ + pSeek = p->pSavedRow; + p->pSavedRow = 0; + }else{ + rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP+bSaveRow, &pSeek, 0); + if( rc!=SQLITE_OK ) return rc; + sqlite3_bind_int64(pSeek, 1, iDel); + if( sqlite3_step(pSeek)!=SQLITE_ROW ){ + return sqlite3_reset(pSeek); + } } } @@ -462,11 +496,21 @@ static int fts5StorageDeleteFromIndex( p->nTotalRow--; } - rc2 = sqlite3_reset(pSeek); - if( rc==SQLITE_OK ) rc = rc2; + if( rc==SQLITE_OK && bSaveRow ){ + assert( p->pSavedRow==0 ); + p->pSavedRow = pSeek; + }else{ + rc2 = sqlite3_reset(pSeek); + if( rc==SQLITE_OK ) rc = rc2; + } return rc; } +void sqlite3Fts5StorageReleaseDeleteRow(Fts5Storage *pStorage){ + sqlite3_reset(pStorage->pSavedRow); + pStorage->pSavedRow = 0; +} + /* ** This function is called to process a DELETE on a contentless_delete=1 ** table. It adds the tombstone required to delete the entry with rowid @@ -582,7 +626,12 @@ static int fts5StorageSaveTotals(Fts5Storage *p){ /* ** Remove a row from the FTS table. */ -int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel, sqlite3_value **apVal){ +int sqlite3Fts5StorageDelete( + Fts5Storage *p, /* Storage object */ + i64 iDel, /* Rowid to delete from table */ + sqlite3_value **apVal, /* Optional - values to remove from index */ + int bSaveRow +){ Fts5Config *pConfig = p->pConfig; int rc; sqlite3_stmt *pDel = 0; @@ -599,7 +648,7 @@ int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel, sqlite3_value **apVal){ if( p->pConfig->bContentlessDelete ){ rc = fts5StorageContentlessDelete(p, iDel); }else{ - rc = fts5StorageDeleteFromIndex(p, iDel, apVal); + rc = fts5StorageDeleteFromIndex(p, iDel, apVal, bSaveRow); } } @@ -787,7 +836,11 @@ int sqlite3Fts5StorageContentInsert( int i; /* Counter variable */ rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0); for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){ - rc = sqlite3_bind_value(pInsert, i, apVal[i]); + sqlite3_value *pVal = apVal[i]; + if( sqlite3_value_nochange(pVal) && p->pSavedRow ){ + pVal = sqlite3_column_value(p->pSavedRow, i-1); + } + rc = sqlite3_bind_value(pInsert, i, pVal); } if( rc==SQLITE_OK ){ sqlite3_step(pInsert); @@ -825,9 +878,13 @@ int sqlite3Fts5StorageIndexInsert( int bReset = 0; int nText = 0; const char *pText = 0; - rc = sqlite3Fts5ExtractText( - pConfig, 0, apVal[ctx.iCol+2], &bReset, &pText, &nText - ); + sqlite3_value *pVal = apVal[ctx.iCol+2]; + int bDisk = 0; + if( p->pSavedRow && sqlite3_value_nochange(pVal) ){ + pVal = sqlite3_column_value(p->pSavedRow, ctx.iCol+1); + bDisk = 1; + } + rc = sqlite3Fts5ExtractText(pConfig, bDisk, pVal, &bReset,&pText,&nText); if( rc==SQLITE_OK ){ if( bReset && pConfig->bLocale==0 ){ rc = SQLITE_ERROR; diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index 923990f5a9..f508ea1335 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -167,9 +167,54 @@ do_execsql_test 3.4 { hello world } +#------------------------------------------------------------------------- +# Test that an UPDATE that updates a subset of the columns does not +# magically discard the locale from those columns not updated. +# +reset_db +sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create + +do_execsql_test 4.1 { + CREATE VIRTUAL TABLE d1 USING fts5(x, y, locale=1, tokenize=tcl); + CREATE VIRTUAL TABLE d2 USING fts5vocab('d1', instance); + INSERT INTO d1(rowid, x, y) VALUES(1, 'abc', 'def'); + INSERT INTO d1(rowid, x, y) VALUES(2, 'ghi', fts5_locale('reverse', 'hello')); +} + +do_execsql_test 4.2 { + SELECT DISTINCT term FROM d2 ORDER BY 1 +} { + abc def ghi olleh +} + +do_execsql_test 4.3 { + UPDATE d1 SET x='jkl' WHERE rowid=2; +} -# execsql_pp { SELECT * FROM ttt } +do_execsql_test 4.4 { + SELECT DISTINCT term FROM d2 ORDER BY 1 +} { + abc def jkl olleh +} + +do_execsql_test 4.5 { + SELECT rowid, * FROM d1 +} { + 1 abc def + 2 jkl hello +} + +do_execsql_test 4.6 { + UPDATE d1 SET rowid=4 WHERE rowid=2 +} + +do_execsql_test 4.7 { + SELECT rowid, * FROM d1 +} { + 1 abc def + 4 jkl hello +} finish_test diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 6384095067..050509fb37 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -312,6 +312,7 @@ do_execsql_test 13.1 { INSERT INTO xy(rowid, x) VALUES(3, '3 4 5'); } +breakpoint do_execsql_test 13.2 { UPDATE OR REPLACE xy SET rowid=3 WHERE rowid = 2; SELECT rowid, x FROM xy; diff --git a/manifest b/manifest index 6f223ff085..9ff1a30afb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sfts5_locale()\sfunction,\sand\sbegin\sadding\sthe\srelated\sfunctionality\sto\sfts5. -D 2024-07-26T20:50:33.303 +C Ensure\sthat\san\sfts5\sUPDATE\sdoes\snot\sstrip\sthe\slocale\sfrom\scolumns\sthat\sit\sdoes\snot\swrite\sto. +D 2024-07-27T19:46:10.539 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,15 +93,15 @@ F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6d F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h 38a9553791828b3cf677b9347735fc531d54015ce4f5229d5cf1e2a5c1d3955a -F ext/fts5/fts5Int.h b4a5ed934cb3da55737c4d75cb5f26a39b17470fca67c06c7fe6878992998c99 +F ext/fts5/fts5Int.h 330b1e2dad9ea9cccc9fa93817062fa21e89f00e7eac9a84be440f7e93bf7c3c F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 0c96490fbad746b3780174f38b2ee5e3d719f2f81ee6b58ca828772871e0f680 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 5b6f85aae5f25ee4e8762f26eb8c998c9c53443bb56483ebf712aca591bcb41e -F ext/fts5/fts5_storage.c 1d7b358af3d4a7a4c5a7258a847229ca54c1b26d4f1b9e971ea5f2539631c3d4 +F ext/fts5/fts5_main.c f08525b3378b9131f76b415b44b882aa9f0a861fb135caaf3faf6a9ba5a409a1 +F ext/fts5/fts5_storage.c 6beefaa9229193e85fe9b920aa62f46a79cac867feb8a5af8ce6df28dec90e8d F ext/fts5/fts5_tcl.c a1c307785bb505735a8d914fff7d08881e64ba28c40c406b218c591010d1bc9e F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -184,7 +184,7 @@ F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fd F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 92c6ae79df0aa57b379c50e400151f4a9a36d292819beefc31019c749249844a +F ext/fts5/test/fts5locale.test 60217c6f67331e2b3218b4da3f96f54b856a341b23e7328c9f30efe9ca343130 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -222,7 +222,7 @@ F ext/fts5/test/fts5secure6.test 74bf04733cc523bccca519bb03d3b4e2ed6f6e3db7c59bf F ext/fts5/test/fts5secure7.test fd03d0868d64340a1db8615b02e5508fea409de13910114e4f19eaefc120777a F ext/fts5/test/fts5secure8.test e68c0ac4447f415ff3e4e82531e99548289286f9f3a29c8cd53036113fe28602 F ext/fts5/test/fts5securefault.test c34a28c7cd2f31a8b8907563889e1329a97da975c08df2d951422bcef8e2ebc5 -F ext/fts5/test/fts5simple.test 847fb828262328744733847dc76d6b5d4a6bd4c5d9b282cb819f6504340e061a +F ext/fts5/test/fts5simple.test 453b2348193911c2d51c208bfe247a09b936c4ddd9a836160495a5554340c256 F ext/fts5/test/fts5simple2.test d10d963a357b8ec77b99032e4c816459b4dbdb1f6eee25eada7ef3ed245cb2dc F ext/fts5/test/fts5simple3.test 146ec3dc8f5763d6212641c9f0a2f1cba41679353d2add7b963beceb115dc7f4 F ext/fts5/test/fts5synonym.test becc8cea6cfc958a50b30c572c68cbfdf7455971d0fe988202ce67638d2c6cf6 @@ -2196,11 +2196,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04 -R f9f51b6d625a93fd57b76dfee17ab828 -T *branch * fts5-locale -T *sym-fts5-locale * -T -sym-trunk * +P 8839ef7cfb49239e7f1c4812a53a93a672827c88d6921408b1d5062b352c87cc +R 8e79393df1bdcc86ce7609abeba8cbda U dan -Z 2b42cc25153434047e86f4740a226c4e +Z 68a8dc4d8e1906054989de2a0038cabe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 64398355c9..26be2f42c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8839ef7cfb49239e7f1c4812a53a93a672827c88d6921408b1d5062b352c87cc +69205264debd829573b1c777a5a493cfeb6083c4cdec106b1f819989f859ac75 From 07f215ad9e3606253d9bc52d59e46a9c7d9a1b63 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 27 Jul 2024 20:28:13 +0000 Subject: [PATCH 0568/1030] Fix documentation typo. [forum:/forumpost/993cb82402|Forum post 993cb82402] FossilOrigin-Name: 86de4e755e37dc1cbcbd59018927aa87ff49fc15f706a36187631d8f14075c12 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 608c658c9e..3fab5b62af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C wasm\sminimal\sbuild:\sstrip\sauthorizers\sand\sJSON\ssupport\s(saves\sapprox\s35kb).\sStrip\svtab\ssupport\sfrom\sthe\sJS\sbits\sbut\scannot\syet\sstrip\sit\sfrom\sthe\sC\sbits\sbecause\sthat\srequires\sa\scustom-configured\ssqlite3.c. -D 2024-07-24T23:58:28.415 +C Fix\sdocumentation\stypo.\s\n[forum:/forumpost/993cb82402|Forum\spost\s993cb82402] +D 2024-07-27T20:28:13.014 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -761,7 +761,7 @@ F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e F src/shell.c.in 44c02fd1581d95e066b479241e081f37dc95c98452badd03627ef2a1c21bdc80 -F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1 +F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955ac1 @@ -2199,8 +2199,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ee2191f7302210100fa0b29ace8156531ad995bf61aa2642e526e0901d0c6862 -R 72e8c79f1e4399a95154f130ea5870d2 -U stephan -Z 427f56307156eafbb2685aac023af7a2 +P eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0 +R ad51bbdd14781776f7624246eec357e7 +U drh +Z 102d909571cd81f9b00d601f888788db # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 01abe9750d..da015916e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0 +86de4e755e37dc1cbcbd59018927aa87ff49fc15f706a36187631d8f14075c12 diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 183fb2a082..027c0e62d4 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5820,7 +5820,7 @@ int sqlite3_value_encoding(sqlite3_value*); ** one SQL function to another. Use the [sqlite3_result_subtype()] ** routine to set the subtype for the return value of an SQL function. ** -** Every [application-defined SQL function] that invoke this interface +** Every [application-defined SQL function] that invokes this interface ** should include the [SQLITE_SUBTYPE] property in the text ** encoding argument when the function is [sqlite3_create_function|registered]. ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype() From b4afecc626c8db8a2d540279384a960c76cc6cf9 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 Jul 2024 15:00:11 +0000 Subject: [PATCH 0569/1030] Fix a couple of asan problems on this branch. FossilOrigin-Name: 4e3e529313c86b42d5f1ba113d0714d1545bc6641e09e4537d622057f0352989 --- ext/fts5/fts5_main.c | 4 +++- ext/fts5/fts5_tcl.c | 4 +++- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 611c08a57e..7fb08fd6ed 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1407,6 +1407,7 @@ static int fts5FilterMethod( case 'M': { char *zText = 0; int bFreeAndReset = 0; + int bInternal = 0; rc = fts5ExtractExprText(pTab, apVal[i], &zText, &bFreeAndReset); if( rc!=SQLITE_OK ) goto filter_out; @@ -1423,6 +1424,7 @@ static int fts5FilterMethod( ** indicates that the MATCH expression is not a full text query, ** but a request for an internal parameter. */ rc = fts5SpecialMatch(pTab, pCsr, &zText[1]); + bInternal = 1; }else{ char **pzErr = &pTab->p.base.zErrMsg; rc = sqlite3Fts5ExprNew(pConfig, 0, iCol, zText, &pExpr, pzErr); @@ -1437,7 +1439,7 @@ static int fts5FilterMethod( sqlite3Fts5ClearLocale(pConfig); } - if( zText[0]=='*' || rc!=SQLITE_OK ) goto filter_out; + if( bInternal || rc!=SQLITE_OK ) goto filter_out; break; } diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index c1fc7f82ae..a0d951526d 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -836,7 +836,9 @@ static int f5tTokenizerSetLocale( } memset(pInst->zLocale, 0, sizeof(pInst->zLocale)); - memcpy(pInst->zLocale, pLocale, nLocale); + if( nLocale>0 ){ + memcpy(pInst->zLocale, pLocale, nLocale); + } return SQLITE_OK; } diff --git a/manifest b/manifest index 9ff1a30afb..594ebdb848 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\san\sfts5\sUPDATE\sdoes\snot\sstrip\sthe\slocale\sfrom\scolumns\sthat\sit\sdoes\snot\swrite\sto. -D 2024-07-27T19:46:10.539 +C Fix\sa\scouple\sof\sasan\sproblems\son\sthis\sbranch. +D 2024-07-29T15:00:11.833 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,9 +100,9 @@ F ext/fts5/fts5_config.c 0c96490fbad746b3780174f38b2ee5e3d719f2f81ee6b58ca828772 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c f08525b3378b9131f76b415b44b882aa9f0a861fb135caaf3faf6a9ba5a409a1 +F ext/fts5/fts5_main.c 71ea9fe3aba423ad325a7ac600b83bb79e2a640f62094f6df356f978245c78db F ext/fts5/fts5_storage.c 6beefaa9229193e85fe9b920aa62f46a79cac867feb8a5af8ce6df28dec90e8d -F ext/fts5/fts5_tcl.c a1c307785bb505735a8d914fff7d08881e64ba28c40c406b218c591010d1bc9e +F ext/fts5/fts5_tcl.c e22e5791076fdfcbcd2dd5e45aff9d3615f7840bae5d984088ce2c24cfdf77b4 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be @@ -2196,8 +2196,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8839ef7cfb49239e7f1c4812a53a93a672827c88d6921408b1d5062b352c87cc -R 8e79393df1bdcc86ce7609abeba8cbda +P 69205264debd829573b1c777a5a493cfeb6083c4cdec106b1f819989f859ac75 +R c565bdc34845dfb3802fedc964dd8edd U dan -Z 68a8dc4d8e1906054989de2a0038cabe +Z 92c34b492aef5c04b9af8f99ed4665b1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 26be2f42c2..d52188542b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69205264debd829573b1c777a5a493cfeb6083c4cdec106b1f819989f859ac75 +4e3e529313c86b42d5f1ba113d0714d1545bc6641e09e4537d622057f0352989 From 8f14c4519782942cd659df0ad8acd2b115b420a5 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 Jul 2024 20:31:17 +0000 Subject: [PATCH 0570/1030] Fix xColumnText() and xColumnSize() APIs. Add xColumnLocale() and xTokenizeSetLocale(). FossilOrigin-Name: 14006711d83d098e665c540b978b0e29aa8f458da1c2c8e9c2baf2ad5ebd502c --- ext/fts5/fts5.h | 40 +++++++++- ext/fts5/fts5_main.c | 134 ++++++++++++++++++++++++++++------ ext/fts5/fts5_storage.c | 12 +++ ext/fts5/fts5_tcl.c | 15 ++++ ext/fts5/test/fts5_common.tcl | 13 ++++ ext/fts5/test/fts5locale.test | 87 ++++++++++++++++++++++ manifest | 22 +++--- manifest.uuid | 2 +- 8 files changed, 289 insertions(+), 36 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index ccdebbe1ab..ecdb944f68 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -308,9 +308,42 @@ struct Fts5PhraseIter { ** ** This API can be quite slow if used with an FTS5 table created with the ** "detail=none" or "detail=column" option. +** +** xColumnLocale(pFts5, iIdx, pzLocale, pnLocale) +** If parameter iCol is less than zero, or greater than or equal to the +** number of columns in the table, SQLITE_RANGE is returned. +** +** Otherwise, this function attempts to retrieve the locale associated +** with column iCol of the current row. Usually, there is no associated +** locale, and output parameters (*pzLocale) and (*pnLocale) are set +** to NULL and 0, respectively. However, if the fts5_locale() function +** was used to associated a locale with the value when it was inserted +** into the fts5 table, then (*pzLocale) is set to point to a buffer +** containing the name of the locale in utf-8 encoding. (*pnLocale) is +** set to the size in bytes of the buffer. +** +** If successful, SQLITE_OK is returned. Or, if an error occurs, an +** SQLite error code is returned. The final value of the output parameters +** is undefined in this case. +** +** xTokenizeSetLocale(pFts5, pLocale, nLocale) +** This API function is used to invoke the fts5_tokenizer_v2.xSetLocale() +** method of the fts5 table's tokenizer, in the same way as xTokenize() is +** used to invoke fts5_tokenizer_v2.xTokenize(). +** +** Parameters pLocale and nLocale may both be 0, in which case the tokenizer +** is configured to use its default locale. Otherwise, pLocale should point +** to a buffer containing the name of the locale to use encoded as utf-8. +** It does not have to be nul-terminated. nLocale must be passed the size +** of the text in bytes. The buffer indicated by pLocale must remain valid +** for the duration of any calls made to xTokenize() by the auxiliary +** function call up until the next invocation of xTokenizeSetLocale(), if +** any. +** +** SQLITE_OK is returned on success, or an SQLite error code otherwise. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 3 */ + int iVersion; /* Currently always set to 4 */ void *(*xUserData)(Fts5Context*); @@ -352,6 +385,11 @@ struct Fts5ExtensionApi { const char **ppToken, int *pnToken ); int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*); + + /* Below this point are iVersion>=4 only */ + int (*xColumnLocale)(Fts5Context*, int iCol, const char **pz, int *pn); + + int (*xTokenizeSetLocale)(Fts5Context*, const char *z, int n); }; /* diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 7fb08fd6ed..b57864d8b0 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -195,11 +195,15 @@ struct Fts5Cursor { Fts5Auxiliary *pAux; /* Currently executing extension function */ Fts5Auxdata *pAuxdata; /* First in linked list of saved aux-data */ - /* Cache used by auxiliary functions xInst() and xInstCount() */ + /* Cache used by auxiliary API functions xInst() and xInstCount() */ Fts5PoslistReader *aInstIter; /* One for each phrase */ int nInstAlloc; /* Size of aInst[] array (entries / 3) */ int nInstCount; /* Number of phrase instances */ int *aInst; /* 3 integers per phrase instance */ + + /* Values set by xTokenizeSetLocale() */ + const char *pLocale; + int nLocale; }; /* @@ -1258,16 +1262,17 @@ int sqlite3Fts5ExtractText( ){ const char *pText = 0; int nText = 0; - int bResetTokenizer = 0; int rc = SQLITE_OK; - int bDecodeBlob = 0; + + assert( pbResetTokenizer==0 || *pbResetTokenizer==0 ); + if( sqlite3_value_type(pVal)==SQLITE_BLOB ){ - if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE - || (bContent && pConfig->bLocale && pConfig->eContent==FTS5_CONTENT_NORMAL) - ){ - bDecodeBlob = 1; - } + if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE + || (bContent && pConfig->bLocale && pConfig->eContent==FTS5_CONTENT_NORMAL) + ){ + bDecodeBlob = 1; + } } if( bDecodeBlob ){ @@ -1283,8 +1288,10 @@ int sqlite3Fts5ExtractText( pText = (const char*)&pBlob[nLocale+1]; nText = nBlob-nLocale-1; - rc = fts5SetLocale(pConfig, (const char*)pBlob, nLocale); - bResetTokenizer = 1; + if( pbResetTokenizer ){ + rc = fts5SetLocale(pConfig, (const char*)pBlob, nLocale); + *pbResetTokenizer = 1; + } }else{ pText = (const char*)sqlite3_value_text(pVal); @@ -1293,7 +1300,6 @@ int sqlite3Fts5ExtractText( *ppText = pText; *pnText = nText; - *pbResetTokenizer = bResetTokenizer; return rc; } @@ -2030,9 +2036,20 @@ static int fts5ApiTokenize( ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); - return sqlite3Fts5Tokenize( - pTab->pConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken - ); + int rc = SQLITE_OK; + const char *pLocale = pCsr->pLocale; + if( pLocale ){ + rc = fts5SetLocale(pTab->pConfig, pLocale, pCsr->nLocale); + } + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5Tokenize( + pTab->pConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken + ); + } + if( pLocale ){ + sqlite3Fts5ClearLocale(pTab->pConfig); + } + return rc; } static int fts5ApiPhraseCount(Fts5Context *pCtx){ @@ -2064,8 +2081,13 @@ static int fts5ApiColumnText( }else{ rc = fts5SeekCursor(pCsr, 0); if( rc==SQLITE_OK ){ - *pz = (const char*)sqlite3_column_text(pCsr->pStmt, iCol+1); - *pn = sqlite3_column_bytes(pCsr->pStmt, iCol+1); + Fts5Config *pConfig = pTab->pConfig; + int bContent = ( + pConfig->bLocale && pConfig->abUnindexed[iCol]==0 && + pConfig->eContent==FTS5_CONTENT_NORMAL + ); + sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); + sqlite3Fts5ExtractText(pConfig, bContent, pVal, 0, pz, pn); } } return rc; @@ -2277,16 +2299,22 @@ static int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){ } }else{ int i; + rc = fts5SeekCursor(pCsr, 0); for(i=0; rc==SQLITE_OK && inCol; i++){ if( pConfig->abUnindexed[i]==0 ){ - const char *z; int n; - void *p = (void*)(&pCsr->aColumnSize[i]); + const int bContent = (pConfig->eContent==FTS5_CONTENT_NORMAL); + const char *z = 0; + int n = 0; + int bReset = 0; + sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, i+1); + pCsr->aColumnSize[i] = 0; - rc = fts5ApiColumnText(pCtx, i, &z, &n); + rc = sqlite3Fts5ExtractText(pConfig, bContent, pVal, &bReset, &z, &n); if( rc==SQLITE_OK ){ - rc = sqlite3Fts5Tokenize( - pConfig, FTS5_TOKENIZE_AUX, z, n, p, fts5ColumnSizeCb + rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_AUX, + z, n, (void*)&pCsr->aColumnSize[i], fts5ColumnSizeCb ); + if( bReset ) sqlite3Fts5ClearLocale(pConfig); } } } @@ -2530,8 +2558,64 @@ static int fts5ApiQueryPhrase(Fts5Context*, int, void*, int(*)(const Fts5ExtensionApi*, Fts5Context*, void*) ); +static int fts5ApiColumnLocale( + Fts5Context *pCtx, + int iCol, + const char **pzLocale, + int *pnLocale +){ + int rc = SQLITE_OK; + Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; + Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; + + *pzLocale = 0; + *pnLocale = 0; + + if( iCol<0 || iCol>=pConfig->nCol ){ + rc = SQLITE_RANGE; + }else{ + int bNormal = (pConfig->eContent==FTS5_CONTENT_NORMAL); + if( pConfig->abUnindexed[iCol]==0 + && pCsr->ePlan!=FTS5_PLAN_SPECIAL + && pConfig->eContent!=FTS5_CONTENT_NONE + && (bNormal==0 || pConfig->bLocale) + ){ + rc = fts5SeekCursor(pCsr, 0); + if( rc==SQLITE_OK ){ + sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); + if( sqlite3_value_type(pVal)==SQLITE_BLOB + && (bNormal || sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE) + ){ + const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); + int nBlob = sqlite3_value_bytes(pVal); + int nLocale = 0; + for(nLocale=0; nLocalepLocale = pLocale; + pCsr->nLocale = nLocale; + return rc; +} + static const Fts5ExtensionApi sFts5Api = { - 3, /* iVersion */ + 4, /* iVersion */ fts5ApiUserData, fts5ApiColumnCount, fts5ApiRowCount, @@ -2552,7 +2636,9 @@ static const Fts5ExtensionApi sFts5Api = { fts5ApiPhraseFirstColumn, fts5ApiPhraseNextColumn, fts5ApiQueryToken, - fts5ApiInstToken + fts5ApiInstToken, + fts5ApiColumnLocale, + fts5ApiTokenizeSetLocale }; /* @@ -2606,6 +2692,8 @@ static void fts5ApiInvoke( pCsr->pAux = pAux; pAux->xFunc(&sFts5Api, (Fts5Context*)pCsr, context, argc, argv); pCsr->pAux = 0; + pCsr->pLocale = 0; + pCsr->nLocale = 0; } static Fts5Cursor *fts5CursorFromCsrid(Fts5Global *pGlobal, i64 iCsrId){ diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index f94c2ea908..72a136f421 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -839,7 +839,19 @@ int sqlite3Fts5StorageContentInsert( sqlite3_value *pVal = apVal[i]; if( sqlite3_value_nochange(pVal) && p->pSavedRow ){ pVal = sqlite3_column_value(p->pSavedRow, i-1); + }else if( i>1 && pConfig->abUnindexed[i-2] + && pConfig->bLocale + && sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE + ){ + /* At attempt to insert an fts5_locale() value into an UNINDEXED + ** column. Strip the locale away and just bind the text. */ + const char *pText = 0; + int nText = 0; + rc = sqlite3Fts5ExtractText(pConfig, 0, pVal, 0, &pText, &nText); + sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); + continue; } + rc = sqlite3_bind_value(pInsert, i, pVal); } if( rc==SQLITE_OK ){ diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index a0d951526d..fb951291a6 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -247,6 +247,7 @@ static int SQLITE_TCLAPI xF5tApi( { "xQueryToken", 2, "IPHRASE ITERM" }, /* 18 */ { "xInstToken", 2, "IDX ITERM" }, /* 19 */ + { "xColumnLocale", 1, "COL" }, /* 20 */ { 0, 0, 0} }; @@ -535,6 +536,20 @@ static int SQLITE_TCLAPI xF5tApi( break; } + CASE(20, "xColumnLocale") { + const char *z = 0; + int n = 0; + int iCol; + if( Tcl_GetIntFromObj(interp, objv[2], &iCol) ){ + return TCL_ERROR; + } + rc = p->pApi->xColumnLocale(p->pFts, iCol, &z, &n); + if( rc==SQLITE_OK && z ){ + Tcl_SetObjResult(interp, Tcl_NewStringObj(z, n)); + } + break; + } + default: assert( 0 ); break; diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index 7076a52bbf..b78064e8d8 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -78,6 +78,9 @@ proc fts5_test_columnsize {cmd} { proc fts5_columntext {cmd iCol} { $cmd xColumnText $iCol } +proc fts5_columnlocale {cmd iCol} { + $cmd xColumnLocale $iCol +} proc fts5_test_columntext {cmd} { set res [list] @@ -87,6 +90,14 @@ proc fts5_test_columntext {cmd} { set res } +proc fts5_test_columnlocale {cmd} { + set res [list] + for {set i 0} {$i < [$cmd xColumnCount]} {incr i} { + lappend res [$cmd xColumnLocale $i] + } + set res +} + proc fts5_test_columntotalsize {cmd} { set res [list] for {set i 0} {$i < [$cmd xColumnCount]} {incr i} { @@ -165,6 +176,7 @@ proc fts5_aux_test_functions {db} { foreach f { fts5_test_columnsize fts5_test_columntext + fts5_test_columnlocale fts5_test_columntotalsize fts5_test_poslist fts5_test_poslist2 @@ -177,6 +189,7 @@ proc fts5_aux_test_functions {db} { fts5_test_queryphrase fts5_test_phrasecount fts5_columntext + fts5_columnlocale fts5_queryphrase fts5_collist } { diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index f508ea1335..71a76677ae 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -41,7 +41,13 @@ proc transform_token {locale token} { proc tcl_create {args} { return "tcl_tokenize" } proc tcl_tokenize {tflags text} { + set iToken 1 + set bSkip 0 + if {[sqlite3_fts5_locale]=="second"} { set bSkip 1 } foreach {w iStart iEnd} [fts5_tokenize_split $text] { + incr iToken + if {(($iToken) % ($bSkip + 1))} continue + set w [transform_token [sqlite3_fts5_locale] $w] sqlite3_fts5_token $w $iStart $iEnd } @@ -216,6 +222,87 @@ do_execsql_test 4.7 { 4 jkl hello } +fts5_aux_test_functions db + +do_execsql_test 4.8.1 { + SELECT fts5_test_columntext(d1) FROM d1('jkl') +} {{jkl hello}} +do_execsql_test 4.8.2 { + SELECT fts5_test_columntext(d1) FROM d1(fts5_locale('reverse', 'hello')) +} {{jkl hello}} + +do_execsql_test 4.9 { + SELECT fts5_test_columnlocale(d1) FROM d1(fts5_locale('reverse', 'hello')) +} {{{} reverse}} + +do_execsql_test 4.10 { + SELECT fts5_test_columnlocale(d1) FROM d1 +} { + {{} {}} + {{} reverse} +} + +#------------------------------------------------------------------------- +# Test that if an fts5_locale() value is written to an UNINDEXED +# column it is stored as text. This is so that blobs and other values +# can also be stored as is. +# +reset_db +sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create + +do_execsql_test 5.1 { + CREATE VIRTUAL TABLE t1 USING fts5( + x, y UNINDEXED, locale=1, tokenize=tcl + ); + + INSERT INTO t1(rowid, x, y) VALUES(111, + fts5_locale('reverse', 'one two three'), + fts5_locale('reverse', 'four five six') + ); +} + +do_execsql_test 5.2 { + SELECT rowid, x, y FROM t1 +} { + 111 {one two three} {four five six} +} + +do_execsql_test 5.3 { + SELECT typeof(c0), typeof(c1) FROM t1_content +} { + blob text +} + +#------------------------------------------------------------------------- + +foreach {tn opt} { + 1 {} + 2 {, columnsize=0} +} { + reset_db + sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create + do_execsql_test 6.$tn.1 " + CREATE VIRTUAL TABLE y1 USING fts5(t, locale=1, tokenize=tcl $opt); + " + + do_execsql_test 6.$tn.2 { + INSERT INTO y1(rowid, t) VALUES + (1, fts5_locale('second', 'the city of London')), + (2, fts5_locale('second', 'shall have all the old')), + (3, fts5_locale('second', 'Liberties and Customs')), + (4, fts5_locale('second', 'which it hath been used to have')); + } + + fts5_aux_test_functions db + + do_execsql_test 5.$tn.3 { + SELECT fts5_test_columnsize(y1) FROM y1 + } { + 2 3 2 4 + } +} + + finish_test diff --git a/manifest b/manifest index 594ebdb848..8fb2030236 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\sof\sasan\sproblems\son\sthis\sbranch. -D 2024-07-29T15:00:11.833 +C Fix\sxColumnText()\sand\sxColumnSize()\sAPIs.\sAdd\sxColumnLocale()\sand\sxTokenizeSetLocale(). +D 2024-07-29T20:31:17.644 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,7 +92,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h 38a9553791828b3cf677b9347735fc531d54015ce4f5229d5cf1e2a5c1d3955a +F ext/fts5/fts5.h 7cd47e5dfe68d798e667caa76722374f0c909f2db05bb4d42b1ec5300d18e658 F ext/fts5/fts5Int.h 330b1e2dad9ea9cccc9fa93817062fa21e89f00e7eac9a84be440f7e93bf7c3c F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 @@ -100,9 +100,9 @@ F ext/fts5/fts5_config.c 0c96490fbad746b3780174f38b2ee5e3d719f2f81ee6b58ca828772 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 71ea9fe3aba423ad325a7ac600b83bb79e2a640f62094f6df356f978245c78db -F ext/fts5/fts5_storage.c 6beefaa9229193e85fe9b920aa62f46a79cac867feb8a5af8ce6df28dec90e8d -F ext/fts5/fts5_tcl.c e22e5791076fdfcbcd2dd5e45aff9d3615f7840bae5d984088ce2c24cfdf77b4 +F ext/fts5/fts5_main.c ee4bba42d8d093cd870c55a342ab85a647ec39dc79985e2b1084514d990de82d +F ext/fts5/fts5_storage.c 2118a5bd2ae617367259f6cf2412b6ff26bc1cd1cc29bf64a6249edcc1572f19 +F ext/fts5/fts5_tcl.c 93b705cb87633574983161edc5234f9b91ba03f9fecfbd2c5d401a1da6f93aa5 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be @@ -111,7 +111,7 @@ F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d0988 F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl bc33c6cc65e5d390f28a68aeeb3a526dadd2c3a947d2466ee1986c1a4002df56 +F ext/fts5/test/fts5_common.tcl 48c0855d235a2f141e5519d3170bad7cddcc53ad3a16ac8ef952ba61048c2958 F ext/fts5/test/fts5aa.test 4db81519863244a3cab35795fe65ab6b592e7970c7409eba098b23ebbfc08d95 F ext/fts5/test/fts5ab.test 4bdb619fee409e11417e8827e320b857e42e926a01a0408fc9f143ec870a6ced F ext/fts5/test/fts5ac.test 4a73626de86f3d17c95738034880c4f0de8d54741fb943d819b528373657e59b @@ -184,7 +184,7 @@ F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fd F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 60217c6f67331e2b3218b4da3f96f54b856a341b23e7328c9f30efe9ca343130 +F ext/fts5/test/fts5locale.test 14e46de0fbab3a01e16d8f61143260a7865cbe9d1759a564927635a1b08e9310 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2196,8 +2196,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 69205264debd829573b1c777a5a493cfeb6083c4cdec106b1f819989f859ac75 -R c565bdc34845dfb3802fedc964dd8edd +P 4e3e529313c86b42d5f1ba113d0714d1545bc6641e09e4537d622057f0352989 +R 76149d45da5064496ccc1cbc5f33d6bf U dan -Z 92c34b492aef5c04b9af8f99ed4665b1 +Z 4addb1a2e7bbe8797df686b1934d0dc8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d52188542b..eb3a346d11 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4e3e529313c86b42d5f1ba113d0714d1545bc6641e09e4537d622057f0352989 +14006711d83d098e665c540b978b0e29aa8f458da1c2c8e9c2baf2ad5ebd502c From 064b681e9bb2a0230c312c5a48f0797f821b3074 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Jul 2024 15:49:02 +0000 Subject: [PATCH 0571/1030] First attempt at getting the build to work with Tcl 9.0. FossilOrigin-Name: 6e5bb48a74d63fb8c30528f0005d1763cd2dbb882abf86baf1565721e6bfcf84 --- autoconf/tea/tclconfig/tcl.m4 | 2 +- autoconf/tea/win/rules.vc | 1 - ext/expert/test_expert.c | 10 +-- ext/fts3/fts3_test.c | 30 ++++----- ext/fts3/fts3_tokenizer.c | 6 +- ext/fts5/fts5_tcl.c | 43 ++++++------ ext/intck/test_intck.c | 8 +-- ext/rbu/test_rbu.c | 15 +---- ext/recover/test_recover.c | 4 +- ext/rtree/test_rtreedoc.c | 10 +-- ext/session/test_session.c | 73 +++++++++++---------- manifest | 120 ++++++++++++++++++---------------- manifest.uuid | 2 +- src/tclsqlite.c | 69 +++++++++---------- src/tclsqlite.h | 37 +++++++++++ src/test1.c | 33 +++++----- src/test2.c | 6 +- src/test3.c | 14 ++-- src/test4.c | 6 +- src/test5.c | 12 ++-- src/test6.c | 15 ++--- src/test8.c | 6 +- src/test9.c | 6 +- src/test_async.c | 11 +--- src/test_autoext.c | 9 +-- src/test_backup.c | 9 +-- src/test_bestindex.c | 14 ++-- src/test_blob.c | 20 +++--- src/test_btree.c | 6 +- src/test_config.c | 6 +- src/test_demovfs.c | 9 +-- src/test_fs.c | 7 +- src/test_func.c | 6 +- src/test_hexio.c | 42 ++++++------ src/test_init.c | 6 +- src/test_intarray.c | 9 +-- src/test_malloc.c | 13 ++-- src/test_md5.c | 9 +-- src/test_multiplex.c | 9 +-- src/test_mutex.c | 7 +- src/test_osinst.c | 9 +-- src/test_quota.c | 11 +--- src/test_rtree.c | 12 +--- src/test_schema.c | 6 +- src/test_superlock.c | 9 +-- src/test_syscall.c | 14 ++-- src/test_tclsh.c | 9 +-- src/test_tclvar.c | 14 ++-- src/test_thread.c | 14 ++-- src/test_vdbecov.c | 6 +- src/test_vfs.c | 24 +++---- src/test_window.c | 2 +- tool/mkmsvcmin.tcl | 4 +- tool/mkvsix.tcl | 4 +- tool/replace.tcl | 4 +- tool/restore_jrnl.tcl | 63 +++++++++--------- 56 files changed, 375 insertions(+), 550 deletions(-) create mode 100644 src/tclsqlite.h diff --git a/autoconf/tea/tclconfig/tcl.m4 b/autoconf/tea/tclconfig/tcl.m4 index c83d660e18..455a7964d1 100644 --- a/autoconf/tea/tclconfig/tcl.m4 +++ b/autoconf/tea/tclconfig/tcl.m4 @@ -4064,4 +4064,4 @@ AC_DEFUN([TEA_ZIPFS_SUPPORT], [ # Local Variables: # mode: autoconf -# End: \ No newline at end of file +# End: diff --git a/autoconf/tea/win/rules.vc b/autoconf/tea/win/rules.vc index 99471053c8..f09e2ea48e 100644 --- a/autoconf/tea/win/rules.vc +++ b/autoconf/tea/win/rules.vc @@ -708,4 +708,3 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" !message *** Link options '$(LINKERFLAGS)' !endif - diff --git a/ext/expert/test_expert.c b/ext/expert/test_expert.c index 064c1908a9..cae5d0f258 100644 --- a/ext/expert/test_expert.c +++ b/ext/expert/test_expert.c @@ -16,15 +16,7 @@ #include "sqlite3expert.h" #include #include - -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #ifndef SQLITE_OMIT_VIRTUALTABLE diff --git a/ext/fts3/fts3_test.c b/ext/fts3/fts3_test.c index 49a8476bf3..09adbc06ce 100644 --- a/ext/fts3/fts3_test.c +++ b/ext/fts3/fts3_test.c @@ -18,14 +18,7 @@ ** that the sqlite3_tokenizer_module.xLanguage() method is invoked correctly. */ -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #include #include @@ -167,7 +160,8 @@ static int SQLITE_TCLAPI fts3_near_match_cmd( Tcl_Obj *pPhrasecount = 0; Tcl_Obj **apExprToken; - int nExprToken; + Tcl_Size nExprToken; + Tcl_Size nn; UNUSED_PARAMETER(clientData); @@ -201,23 +195,25 @@ static int SQLITE_TCLAPI fts3_near_match_cmd( } } - rc = Tcl_ListObjGetElements(interp, objv[1], &doc.nToken, &apDocToken); + rc = Tcl_ListObjGetElements(interp, objv[1], &nn, &apDocToken); + doc.nToken = (int)nn; if( rc!=TCL_OK ) goto near_match_out; doc.aToken = (NearToken *)ckalloc(doc.nToken*sizeof(NearToken)); for(ii=0; iiz = Tcl_GetStringFromObj(apToken[jj], &pT->n); + Tcl_Size nn; + pT->z = Tcl_GetStringFromObj(apToken[jj], &nn); + pT->n = (int)nn; } - aPhrase[ii].nToken = nToken; + aPhrase[ii].nToken = (int)nToken; } for(ii=1; ii /* diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index c5b5f41f83..b67b037c45 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -14,14 +14,7 @@ #ifdef SQLITE_TEST -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #ifdef SQLITE_ENABLE_FTS5 @@ -297,12 +290,12 @@ static int SQLITE_TCLAPI xF5tApi( break; } CASE(3, "xTokenize") { - int nText; + Tcl_Size nText; char *zText = Tcl_GetStringFromObj(objv[2], &nText); F5tFunction ctx; ctx.interp = interp; ctx.pScript = objv[3]; - rc = p->pApi->xTokenize(p->pFts, zText, nText, &ctx, xTokenizeCb); + rc = p->pApi->xTokenize(p->pFts, zText, (int)nText, &ctx, xTokenizeCb); if( rc==SQLITE_OK ){ Tcl_ResetResult(interp); } @@ -605,15 +598,16 @@ static void xF5tFunction( sqlite3_result_error(pCtx, Tcl_GetStringResult(p->interp), -1); }else{ Tcl_Obj *pVar = Tcl_GetObjResult(p->interp); - int n; const char *zType = (pVar->typePtr ? pVar->typePtr->name : ""); char c = zType[0]; if( c=='b' && strcmp(zType,"bytearray")==0 && pVar->bytes==0 ){ /* Only return a BLOB type if the Tcl variable is a bytearray and ** has no string representation. */ - unsigned char *data = Tcl_GetByteArrayFromObj(pVar, &n); - sqlite3_result_blob(pCtx, data, n, SQLITE_TRANSIENT); + Tcl_Size nn; + unsigned char *data = Tcl_GetByteArrayFromObj(pVar, &nn); + sqlite3_result_blob(pCtx, data, (int)nn, SQLITE_TRANSIENT); }else if( c=='b' && strcmp(zType,"boolean")==0 ){ + int n; Tcl_GetIntFromObj(0, pVar, &n); sqlite3_result_int(pCtx, n); }else if( c=='d' && strcmp(zType,"double")==0 ){ @@ -626,8 +620,9 @@ static void xF5tFunction( Tcl_GetWideIntFromObj(0, pVar, &v); sqlite3_result_int64(pCtx, v); }else{ - unsigned char *data = (unsigned char *)Tcl_GetStringFromObj(pVar, &n); - sqlite3_result_text(pCtx, (char *)data, n, SQLITE_TRANSIENT); + Tcl_Size nn; + unsigned char *data = (unsigned char *)Tcl_GetStringFromObj(pVar, &nn); + sqlite3_result_text(pCtx, (char*)data, (int)nn, SQLITE_TRANSIENT); } } } @@ -720,7 +715,7 @@ static int SQLITE_TCLAPI f5tTokenize( Tcl_Obj *CONST objv[] ){ char *zText; - int nText; + Tcl_Size nText; sqlite3 *db = 0; fts5_api *pApi = 0; Fts5Tokenizer *pTok = 0; @@ -729,7 +724,7 @@ static int SQLITE_TCLAPI f5tTokenize( void *pUserdata; int rc; - int nArg; + Tcl_Size nArg; const char **azArg; F5tTokenizeCtx ctx; @@ -761,7 +756,7 @@ static int SQLITE_TCLAPI f5tTokenize( return TCL_ERROR; } - rc = tokenizer.xCreate(pUserdata, &azArg[1], nArg-1, &pTok); + rc = tokenizer.xCreate(pUserdata, &azArg[1], (int)(nArg-1), &pTok); if( rc!=SQLITE_OK ){ Tcl_AppendResult(interp, "error in tokenizer.xCreate()", 0); return TCL_ERROR; @@ -773,7 +768,7 @@ static int SQLITE_TCLAPI f5tTokenize( ctx.pRet = pRet; ctx.zInput = zText; rc = tokenizer.xTokenize( - pTok, (void*)&ctx, FTS5_TOKENIZE_DOCUMENT, zText, nText, xTokenizeCb2 + pTok, (void*)&ctx, FTS5_TOKENIZE_DOCUMENT, zText,(int)nText, xTokenizeCb2 ); tokenizer.xDelete(pTok); if( rc!=SQLITE_OK ){ @@ -928,13 +923,13 @@ static int SQLITE_TCLAPI f5tTokenizerReturn( F5tTokenizerContext *p = (F5tTokenizerContext*)clientData; int iStart; int iEnd; - int nToken; + Tcl_Size nToken; int tflags = 0; char *zToken; int rc; if( objc==5 ){ - int nArg; + Tcl_Size nArg; char *zArg = Tcl_GetStringFromObj(objv[1], &nArg); if( nArg<=10 && nArg>=2 && memcmp("-colocated", zArg, nArg)==0 ){ tflags |= FTS5_TOKEN_COLOCATED; @@ -959,7 +954,7 @@ static int SQLITE_TCLAPI f5tTokenizerReturn( return TCL_ERROR; } - rc = p->xToken(p->pCtx, tflags, zToken, nToken, iStart, iEnd); + rc = p->xToken(p->pCtx, tflags, zToken, (int)nToken, iStart, iEnd); Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE); return rc==SQLITE_OK ? TCL_OK : TCL_ERROR; @@ -1083,7 +1078,7 @@ static int SQLITE_TCLAPI f5tTokenHash( Tcl_Obj *CONST objv[] ){ char *z; - int n; + Tcl_Size n; unsigned int iVal; int nSlot; @@ -1096,7 +1091,7 @@ static int SQLITE_TCLAPI f5tTokenHash( } z = Tcl_GetStringFromObj(objv[2], &n); - iVal = f5t_fts5HashKey(nSlot, z, n); + iVal = f5t_fts5HashKey(nSlot, z, (int)n); Tcl_SetObjResult(interp, Tcl_NewIntObj(iVal)); return TCL_OK; } diff --git a/ext/intck/test_intck.c b/ext/intck/test_intck.c index 412c9f201c..d3a619b503 100644 --- a/ext/intck/test_intck.c +++ b/ext/intck/test_intck.c @@ -15,13 +15,7 @@ #include "sqlite3.h" #include "sqlite3intck.h" - -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif - +#include "tclsqlite.h" #include #include diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index af794d80f8..969d6208d8 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -17,14 +17,7 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) #include "sqlite3rbu.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #include #include @@ -432,11 +425,7 @@ int SqliteRbu_Init(Tcl_Interp *interp){ } #else -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" int SqliteRbu_Init(Tcl_Interp *interp){ return TCL_OK; } #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */ #endif /* defined(SQLITE_TEST) */ diff --git a/ext/recover/test_recover.c b/ext/recover/test_recover.c index ba8ef6da11..c1c0d88386 100644 --- a/ext/recover/test_recover.c +++ b/ext/recover/test_recover.c @@ -14,8 +14,7 @@ #include "sqlite3recover.h" #include "sqliteInt.h" - -#include +#include "tclsqlite.h" #include #ifndef SQLITE_OMIT_VIRTUALTABLE @@ -308,4 +307,3 @@ int TestRecover_Init(Tcl_Interp *interp){ #endif return TCL_OK; } - diff --git a/ext/rtree/test_rtreedoc.c b/ext/rtree/test_rtreedoc.c index cdbcb2e8dc..0c042d05a9 100644 --- a/ext/rtree/test_rtreedoc.c +++ b/ext/rtree/test_rtreedoc.c @@ -14,11 +14,7 @@ */ #include "sqlite3.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" /* Solely for the UNUSED_PARAMETER() macro. */ #include "sqliteInt.h" @@ -90,7 +86,7 @@ static int invokeTclGeomCb( if( rc!=TCL_OK ){ rc = SQLITE_ERROR; }else{ - int nObj = 0; + Tcl_Size nObj = 0; Tcl_Obj **aObj = 0; pRes = Tcl_GetObjResult(interp); @@ -279,7 +275,7 @@ static int box_query(sqlite3_rtree_query_info *pInfo){ if( rc==SQLITE_OK ){ double rScore = 0.0; - int nObj = 0; + Tcl_Size nObj = 0; int eP = 0; Tcl_Obj **aObj = 0; Tcl_Obj *pRes = Tcl_GetObjResult(interp); diff --git a/ext/session/test_session.c b/ext/session/test_session.c index 00c3c25068..79ad000e18 100644 --- a/ext/session/test_session.c +++ b/ext/session/test_session.c @@ -5,14 +5,7 @@ #include "sqlite3session.h" #include #include -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #ifndef SQLITE_AMALGAMATION typedef unsigned char u8; @@ -517,11 +510,11 @@ struct TestConflictHandler { }; static int test_obj_eq_string(Tcl_Obj *p, const char *z){ - int n; - int nObj; + Tcl_Size n; + Tcl_Size nObj; char *zObj; - n = (int)strlen(z); + n = (Tcl_Size)strlen(z); zObj = Tcl_GetStringFromObj(p, &nObj); return (nObj==n && (n==0 || 0==memcmp(zObj, z, n))); @@ -796,7 +789,7 @@ static int SQLITE_TCLAPI testSqlite3changesetApply( Tcl_CmdInfo info; /* Database Tcl command (objv[1]) info */ int rc; /* Return code from changeset_invert() */ void *pChangeset; /* Buffer containing changeset */ - int nChangeset; /* Size of buffer aChangeset in bytes */ + Tcl_Size nChangeset; /* Size of buffer aChangeset in bytes */ TestConflictHandler ctx; TestStreamInput sStr; void *pRebase = 0; @@ -853,18 +846,18 @@ static int SQLITE_TCLAPI testSqlite3changesetApply( if( sStr.nStream==0 ){ if( bV2==0 ){ - rc = sqlite3changeset_apply(db, nChangeset, pChangeset, + rc = sqlite3changeset_apply(db, (int)nChangeset, pChangeset, (objc==5)?test_filter_handler:0, test_conflict_handler, (void *)&ctx ); }else{ - rc = sqlite3changeset_apply_v2(db, nChangeset, pChangeset, + rc = sqlite3changeset_apply_v2(db, (int)nChangeset, pChangeset, (objc==5)?test_filter_handler:0, test_conflict_handler, (void *)&ctx, &pRebase, &nRebase, flags ); } }else{ sStr.aData = (unsigned char*)pChangeset; - sStr.nData = nChangeset; + sStr.nData = (int)nChangeset; if( bV2==0 ){ rc = sqlite3changeset_apply_strm(db, testStreamInput, (void*)&sStr, (objc==5) ? test_filter_handler : 0, @@ -927,7 +920,7 @@ static int SQLITE_TCLAPI test_sqlite3changeset_apply_replace_all( Tcl_CmdInfo info; /* Database Tcl command (objv[1]) info */ int rc; /* Return code from changeset_invert() */ void *pChangeset; /* Buffer containing changeset */ - int nChangeset; /* Size of buffer aChangeset in bytes */ + Tcl_Size nChangeset; /* Size of buffer aChangeset in bytes */ if( objc!=3 ){ Tcl_WrongNumArgs(interp, 1, objv, "DB CHANGESET"); @@ -940,7 +933,8 @@ static int SQLITE_TCLAPI test_sqlite3changeset_apply_replace_all( db = *(sqlite3 **)info.objClientData; pChangeset = (void *)Tcl_GetByteArrayFromObj(objv[2], &nChangeset); - rc = sqlite3changeset_apply(db, nChangeset, pChangeset, 0, replace_handler,0); + rc = sqlite3changeset_apply(db, (int)nChangeset, pChangeset, + 0, replace_handler,0); if( rc!=SQLITE_OK ){ return test_session_error(interp, rc, 0); } @@ -959,6 +953,7 @@ static int SQLITE_TCLAPI test_sqlite3changeset_invert( Tcl_Obj *CONST objv[] ){ int rc; /* Return code from changeset_invert() */ + Tcl_Size nn; TestStreamInput sIn; /* Input stream */ TestSessionsBlob sOut; /* Output blob */ @@ -970,7 +965,8 @@ static int SQLITE_TCLAPI test_sqlite3changeset_invert( memset(&sIn, 0, sizeof(sIn)); memset(&sOut, 0, sizeof(sOut)); sIn.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR); - sIn.aData = Tcl_GetByteArrayFromObj(objv[1], &sIn.nData); + sIn.aData = Tcl_GetByteArrayFromObj(objv[1], &nn); + sIn.nData = (int)nn; if( sIn.nStream ){ rc = sqlite3changeset_invert_strm( @@ -999,6 +995,7 @@ static int SQLITE_TCLAPI test_sqlite3changeset_concat( Tcl_Obj *CONST objv[] ){ int rc; /* Return code from changeset_invert() */ + Tcl_Size nn; TestStreamInput sLeft; /* Input stream */ TestStreamInput sRight; /* Input stream */ @@ -1011,8 +1008,10 @@ static int SQLITE_TCLAPI test_sqlite3changeset_concat( memset(&sLeft, 0, sizeof(sLeft)); memset(&sRight, 0, sizeof(sRight)); - sLeft.aData = Tcl_GetByteArrayFromObj(objv[1], &sLeft.nData); - sRight.aData = Tcl_GetByteArrayFromObj(objv[2], &sRight.nData); + sLeft.aData = Tcl_GetByteArrayFromObj(objv[1], &nn); + sLeft.nData = (int)nn; + sRight.aData = Tcl_GetByteArrayFromObj(objv[2], &nn); + sRight.nData = (int)nn; sLeft.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR); sRight.nStream = sLeft.nStream; @@ -1106,7 +1105,7 @@ static int SQLITE_TCLAPI test_sqlite3session_foreach( Tcl_Obj *CONST objv[] ){ void *pChangeset; - int nChangeset; + Tcl_Size nChangeset; sqlite3_changeset_iter *pIter; int rc; Tcl_Obj *pVarname; @@ -1148,19 +1147,19 @@ static int SQLITE_TCLAPI test_sqlite3session_foreach( if( isInvert ){ int f = SQLITE_CHANGESETSTART_INVERT; if( sStr.nStream==0 ){ - rc = sqlite3changeset_start_v2(&pIter, nChangeset, pChangeset, f); + rc = sqlite3changeset_start_v2(&pIter, (int)nChangeset, pChangeset, f); }else{ void *pCtx = (void*)&sStr; sStr.aData = (unsigned char*)pChangeset; - sStr.nData = nChangeset; + sStr.nData = (int)nChangeset; rc = sqlite3changeset_start_v2_strm(&pIter, testStreamInput, pCtx, f); } }else{ if( sStr.nStream==0 ){ - rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset); + rc = sqlite3changeset_start(&pIter, (int)nChangeset, pChangeset); }else{ sStr.aData = (unsigned char*)pChangeset; - sStr.nData = nChangeset; + sStr.nData = (int)nChangeset; rc = sqlite3changeset_start_strm(&pIter, testStreamInput, (void*)&sStr); } } @@ -1237,9 +1236,9 @@ static int SQLITE_TCLAPI test_rebaser_cmd( assert( rc==SQLITE_OK ); switch( iSub ){ case 0: { /* configure */ - int nRebase = 0; + Tcl_Size nRebase = 0; unsigned char *pRebase = Tcl_GetByteArrayFromObj(objv[2], &nRebase); - rc = sqlite3rebaser_configure(p, nRebase, pRebase); + rc = sqlite3rebaser_configure(p, (int)nRebase, pRebase); break; } @@ -1250,10 +1249,12 @@ static int SQLITE_TCLAPI test_rebaser_cmd( default: { /* rebase */ TestStreamInput sStr; /* Input stream */ TestSessionsBlob sOut; /* Output blob */ + Tcl_Size nn; memset(&sStr, 0, sizeof(sStr)); memset(&sOut, 0, sizeof(sOut)); - sStr.aData = Tcl_GetByteArrayFromObj(objv[2], &sStr.nData); + sStr.aData = Tcl_GetByteArrayFromObj(objv[2], &nn); + sStr.nData = nn; sStr.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR); if( sStr.nStream ){ @@ -1392,7 +1393,7 @@ static int SQLITE_TCLAPI test_changeset( Tcl_Obj *CONST objv[] ){ void *pChangeset = 0; /* Buffer containing changeset */ - int nChangeset = 0; /* Size of buffer aChangeset in bytes */ + Tcl_Size nChangeset = 0; /* Size of buffer aChangeset in bytes */ int rc = SQLITE_OK; char *z = 0; @@ -1403,7 +1404,7 @@ static int SQLITE_TCLAPI test_changeset( pChangeset = (void *)Tcl_GetByteArrayFromObj(objv[1], &nChangeset); Tcl_ResetResult(interp); - rc = sqlite3_test_changeset(nChangeset, pChangeset, &z); + rc = sqlite3_test_changeset((int)nChangeset, pChangeset, &z); if( rc!=SQLITE_OK ){ char *zErr = sqlite3_mprintf("(%d) - \"%s\"", rc, z); Tcl_SetObjResult(interp, Tcl_NewStringObj(zErr, -1)); @@ -1528,9 +1529,9 @@ static int SQLITE_TCLAPI test_changegroup_cmd( }; case 1: { /* add */ - int nByte = 0; + Tcl_Size nByte = 0; const u8 *aByte = Tcl_GetByteArrayFromObj(objv[2], &nByte); - rc = sqlite3changegroup_add(p->pGrp, nByte, (void*)aByte); + rc = sqlite3changegroup_add(p->pGrp, (int)nByte, (void*)aByte); if( rc!=SQLITE_OK ) rc = test_session_error(interp, rc, 0); break; }; @@ -1678,7 +1679,7 @@ static int SQLITE_TCLAPI test_sqlite3changeset_start( ){ int isInvert = 0; void *pChangeset = 0; /* Buffer containing changeset */ - int nChangeset = 0; /* Size of buffer aChangeset in bytes */ + Tcl_Size nChangeset = 0; /* Size of buffer aChangeset in bytes */ TestChangeIter *pNew = 0; sqlite3_changeset_iter *pIter = 0; int flags = 0; @@ -1688,9 +1689,9 @@ static int SQLITE_TCLAPI test_sqlite3changeset_start( char zCmd[64]; if( objc==3 ){ - int n = 0; + Tcl_Size n = 0; const char *z = Tcl_GetStringFromObj(objv[1], &n); - isInvert = (n>=2 && sqlite3_strnicmp(z, "-invert", n)==0); + isInvert = (n>=2 && sqlite3_strnicmp(z, "-invert", (int)n)==0); } if( objc!=2 && (objc!=3 || !isInvert) ){ @@ -1700,7 +1701,7 @@ static int SQLITE_TCLAPI test_sqlite3changeset_start( flags = isInvert ? SQLITE_CHANGESETSTART_INVERT : 0; pChangeset = (void *)Tcl_GetByteArrayFromObj(objv[objc-1], &nChangeset); - rc = sqlite3changeset_start_v2(&pIter, nChangeset, pChangeset, flags); + rc = sqlite3changeset_start_v2(&pIter, (int)nChangeset, pChangeset, flags); if( rc!=SQLITE_OK ){ char *zErr = sqlite3_mprintf( "error in sqlite3changeset_start_v2() - %d", rc diff --git a/manifest b/manifest index 3fab5b62af..7821b9bd42 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sdocumentation\stypo.\s\n[forum:/forumpost/993cb82402|Forum\spost\s993cb82402] -D 2024-07-27T20:28:13.014 +C First\sattempt\sat\sgetting\sthe\sbuild\sto\swork\swith\sTcl\s9.0. +D 2024-07-30T15:49:02.043 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -29,10 +29,10 @@ F autoconf/tea/doc/sqlite3.n e1fe45d4f5286ee3d0ccc877aca2a0def488e9bb F autoconf/tea/license.terms 13bd403c9610fd2b76ece0ab50c4c5eda933d523 F autoconf/tea/pkgIndex.tcl.in b9eb6dd37f64e08e637d576b3c83259814b9cddd78bec4af2e5abfc6c5c750ce F autoconf/tea/tclconfig/install-sh bdd5e293591621ae60d9824d86a4b1c5f22c3d00 -F autoconf/tea/tclconfig/tcl.m4 debe13280bd5a9d76dc34e7919cd9ed3a1408c7320400900357128c2d1abb723 +F autoconf/tea/tclconfig/tcl.m4 c6e5f2fc7178f40d087403daa044ef3b86a8e30793f3b121bdcbdf152c6a776a F autoconf/tea/win/makefile.vc 2c478a9a962e48b2bf9062734e04d7c63c556e217095419173f9d7938d7d78f7 F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea00342d1a1a7eaa19cb -F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 +F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 F configure 27d144c2edfa993ac155a2ad5e6b431e4ec811159598ef55a59f345bc2e5e533 x @@ -60,7 +60,7 @@ F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3 F ext/expert/expert1.test 53a749de08939e3bc14f804e97410927d46fa772cbce0247d7e8fa6fc2523b0c F ext/expert/sqlite3expert.c c8cea5ff15fbe792cccc4992a9b40b706411c41d32611f617897fecac6ff06a4 F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b -F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 +F ext/expert/test_expert.c b767b2039a0df707eb3147e86bcf68b252d8455d9a41774b1a836cd052ceca70 F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c7cc3bf59ee F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers b92bdeb8b46503f0dd301d364efc5ef59ef9fa8e2758b8e742f39fa93a2e422d @@ -76,9 +76,9 @@ F ext/fts3/fts3_icu.c 305ce7fb6036484085b5556a9c8e62acdc7763f0f4cdf5fd538212a9f3 F ext/fts3/fts3_porter.c e19807ce0ae31c1c6e9898e89ecc93183d7ec224ea101af039722a4f49e5f2b8 F ext/fts3/fts3_snippet.c 610328fe128c047c6b0eba77768982ccf3933daae095d497949a75c9dfd47409 F ext/fts3/fts3_term.c 6a96027ad364001432545fe43322b6af04ed28bb5619ec51af1f59d0710d6d69 -F ext/fts3/fts3_test.c d8d7b2734f894e8a489987447658e374cdd3a3bc8575c401decf1911cb7c6454 +F ext/fts3/fts3_test.c a17e6c6249a58279617f9f57220ad85f3f343d9f002d721967939a1624f55b4a F ext/fts3/fts3_tokenize_vtab.c 7fd9ef364f257b97218b9c331f2378e307375c592f70fd541f714e747d944962 -F ext/fts3/fts3_tokenizer.c 6d8fc150c48238955d5182bf661498db0dd473c8a2a80e00c16994a646fa96e7 +F ext/fts3/fts3_tokenizer.c defede96b5dd5d658edfae77355b9c31ea65236eedc7bbe1adbc50d645cca5bc F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c c1de4ae28356ad98ccb8b2e3388a7fdcce7607b5523738c9afb6275dab765154 F ext/fts3/fts3_unicode.c de426ff05c1c2e7bce161cf6b706638419c3a1d9c2667de9cb9dc0458c18e226 @@ -102,7 +102,7 @@ F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 77fefb37e7931095a5ff271a28fbe4f73ec46d5492ef1f35d405d98e137ad8ed F ext/fts5/fts5_storage.c 1d7e08d4331da2f3f7e78e70eef2ed6a013d91ba16175c651adbc5ad672235aa -F ext/fts5/fts5_tcl.c fdf7e2bb9a9186cfcaf2d2ce11d338309342b7a7593c2812bc54455db53da5d2 +F ext/fts5/fts5_tcl.c 5ca3e3e35010d326f5b821a563e4fcde3913e052935f5c2c72c264122a26b48f F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be @@ -259,7 +259,7 @@ F ext/intck/intckcorrupt.test f6c302792326fb3db9dcfc70b554c55369bc4b52882eaaf039 F ext/intck/intckfault.test cff3f75dff74abb3edfcb13f6aa53f6436746ab64b09fe5e2028f051e985efab F ext/intck/sqlite3intck.c 0d10df36e2b7b438aa80ecd3f5e584d41b747586b038258fe6b407f66b81e7c5 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9 -F ext/intck/test_intck.c 6050ed1f3e11eb58c66ed20f75af43dec0e37c88c9089b98b8a0a26022735dc3 +F ext/intck/test_intck.c 4f9eaadaedccb9df1d26ba41116a0a8e5b0c5556dc3098c8ff68633adcccdea8 F ext/jni/GNUmakefile 59eb05f2a363bdfac8d15d66bed624bfe1ff289229184f3861b95f98a19cf4b2 F ext/jni/README.md d899789a9082a07b99bf30b1bbb6204ae57c060efcaa634536fa669323918f42 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa @@ -479,7 +479,7 @@ F ext/rbu/rbuvacuum3.test 3ce42695fdf21aaa3499e857d7d4253bc499ad759bcd6c9362042c F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69eefaebb205 F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 -F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055 +F ext/rbu/test_rbu.c b9727c3394307d058e806c1da0f8bb7b24daf3c6bb94cb10cca88ea4d5c806c0 F ext/recover/dbdata.c a22ecd689f00ff2ad33b5633c4ef84c8f088c65faeac18d4eb73c128395c7aec F ext/recover/recover1.test e16d78e94183562abff569967b18b7c77451d7044365516cd0fe14713a284851 F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a @@ -498,7 +498,7 @@ F ext/recover/recoverslowidx.test 5205a9742dd9490ee99950dabb622307355ef1662dea6a F ext/recover/recoversql.test e66d01f95302a223bcd3fd42b5ee58dc2b53d70afa90b0d00e41e4b8eab20486 F ext/recover/sqlite3recover.c 65ef0f56301a16c0536c9839fb7e23540c9c4f75da0afe3b7b4d163c8f624404 F ext/recover/sqlite3recover.h 011c799f02deb70ab685916f6f538e6bb32c4e0025e79bfd0e24ff9c74820959 -F ext/recover/test_recover.c fd871a40f2238022bedcbdf3cb493b91225edaa94d6ae8892af97a10e7ccc4ba +F ext/recover/test_recover.c 072260d7452a3b81aba995b2b3269e7ec2aa7f06725544ba4c25b1b0a1dbc61a F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15 F ext/repair/checkfreelist.c e21f06995ff4efdc1622dcceaea4dcba2caa83ca2f31a1607b98a8509168a996 F ext/repair/checkindex.c af5c66463f51462d8a6f796b2c44ef8cfa1116bbdc35a15da07c67a705388bfd @@ -541,7 +541,7 @@ F ext/rtree/rtreedoc2.test 194ebb7d561452dcdc10bf03f44e30c082c2f0c14efeb07f5e02c F ext/rtree/rtreedoc3.test 555a878c4d79c4e37fa439a1c3b02ee65d3ebaf75d9e8d96a9c55d66db3efbf8 F ext/rtree/rtreefuzz001.test 44f680a23dbe00d1061dbde381d711119099846d166580c4381e402b9d62cb74 F ext/rtree/sqlite3rtree.h 03c8db3261e435fbddcfc961471795cbf12b24e03001d0015b2636b0f3881373 -F ext/rtree/test_rtreedoc.c de76b3472bc74b788d079342fdede22ff598796dd3d97acffe46e09228af83a3 +F ext/rtree/test_rtreedoc.c d20f51d1ad69c72947a4ac72194e5a12e70b3464e7492538fcef66fa871c5081 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/util/randomshape.tcl 54ee03d0d4a1c621806f7f44d5b78d2db8fac26e0e8687c36c4bd0203b27dbff F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 @@ -588,7 +588,7 @@ F ext/session/sessionstat1.test 5e718d5888c0c49bbb33a7a4f816366db85f59f6a4f97544 F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009ecef8511f4cf3fc F ext/session/sqlite3session.c c7473aafbd88f796391a8c25aa90975a8f3729ab7f4f8cf74ab9d3b014e10abe F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b -F ext/session/test_session.c 8bcc857125372e640f75ab63b4188080f9bbab92b65f86dfd160721c574b2044 +F ext/session/test_session.c 6acbe67db80ab0806147eb62a12f9e3a44930f4a740b68b0a4340dddda2c10d7 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb @@ -768,57 +768,58 @@ F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c ecbc3c99c0d0c3ed122a913f143026c26d38d57f33e06bb71185dd5c1efe37cd -F src/test1.c 6bd203421934f2af4d4a4b673f609879f1e0c35164f7e21d0d6cdc0da2eeee8f -F src/test2.c 54520d0565ef2b9bf0f8f1dcac43dc4d06baf4ffe13d10905f8d8c3ad3e4b9ab -F src/test3.c e5178558c41ff53236ae0271e9acb3d6885a94981d2eb939536ee6474598840e -F src/test4.c 4533b76419e7feb41b40582554663ed3cd77aaa54e135cf76b3205098cd6e664 -F src/test5.c 328aae2c010c57a9829d255dc099d6899311672d -F src/test6.c e53bc69dc3cb3815fb74df74f38159ec05ba6dd5273216062e26bc797f925530 -F src/test8.c 303c2e3bcf7795e888810a7ef03809602b851f0ebec8d6e06a429ed85cafd9a2 -F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 -F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a -F src/test_autoext.c 915d245e736652a219a907909bb6710f0d587871 -F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 -F src/test_bestindex.c 1b5a1407b66c5caa67cfe1d93d96de5ec5d9d516bc69eb512482f85c037858c3 -F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce -F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 -F src/test_config.c 5fa77ee6064ba546e144c4fea870c5ede2c54314616f81485c6a9c4192100c75 +F src/tclsqlite.c f4753c1c90964a89f2c094f62bcb413fdefe0215c73c2d4fca4e8c50ace7a1f6 +F src/tclsqlite.h f3dc9ed1464a7cc775a47da70ac6f23e95d0fb939dd7eaf48639778f94d5aaad w src/tclinterface.h +F src/test1.c 9f01a43b5d9d0c08c31617f3ab4e924bb30cd47db784527dbf6a309456a4db3b +F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 +F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b +F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d +F src/test5.c bb87279ed12e199486894e6c83e58dc8cd1de9524ace171d59219d3ab696a0c1 +F src/test6.c 763b92489f11f4a77b773f0d3b8369ab0edd5292ac794043062c337019f12d8a +F src/test8.c 206d8f3cc73950d252906656e2646b5de0d580b07187b635fcb3edd8c2c5fbc0 +F src/test9.c 7a708ad27f8fda79113e5e15de66632710958c401e64c2f22bc04e2f5a7a1b62 +F src/test_async.c 0101173cf8137ba5473a84a695281fa9dedc2a1d155998c68623f2978017ad98 +F src/test_autoext.c 14d4bbd3d0bd1eec0f6d16b29e28cf1e2d0b020d454835f0721a5f68121ac10f +F src/test_backup.c bd901e3c116c7f3b3bbbd4aae4ce87d99b400c9cbb0a9e7b4610af451d9719a7 +F src/test_bestindex.c 3401bee51665cbf7f9ed2552b5795452a8b86365e4c9ece745b54155a55670c6 +F src/test_blob.c bcdf6a6c22d0bcc13c41479d63692ef413add2a4d30e1e26b9f74ab85b9fb4d5 +F src/test_btree.c 28283787d32b8fa953eb77412ad0de2c9895260e4e5bd5a94b3c7411664f90d5 +F src/test_config.c 46eaf39842cace9d540aeefb50fe24dd3204a622893a97952cbb49c20b2f8b21 F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f -F src/test_demovfs.c 38a459d1c78fd9afa770445b224c485e079018d6ac07332ff9bd07b54d2b8ce9 +F src/test_demovfs.c 3efa2adf4f21e10d95521721687d5ca047aea91fa62dd8cc22ac9e5a9c942383 F src/test_devsym.c 649434ed34d0b03fbd5a6b42df80f0f9a7e53f94dd1710aad5dd8831e91c4e86 -F src/test_fs.c 56cc17e4fdc57efa61695026e2ba96e910b17060d7ee01d775ec048791522e2f -F src/test_func.c 4d2dc7e3e0946e55091784ddaf0302294f2ee300614f6f3e19a4b38df77d5167 -F src/test_hexio.c 9478e56a0f08e07841a014a93b20e4ba2709ab56d039d1ca8020e26846aa19bd -F src/test_init.c f2cc4774b7c9140f76e45ecbb2ae219f68e3acbbe248c0179db666a70eae9f08 -F src/test_intarray.c 26ffba666beb658d73cd925d9b4fb56913a3ca9aaeac122b3691436abb192b92 +F src/test_fs.c c411c40baba679536fc34e2679349f59d8225570aed3488b5b3ef1908525a3d5 +F src/test_func.c 8c0e89192f70fac307822d1ac2911ee51751288780b3db0c5ab5ca75fa0fe851 +F src/test_hexio.c af6db9300edd2d7b786a2d40d64177cad4b8ee22085e8ca5fe812cdeffdb6502 +F src/test_init.c 17313332d58e90defc527129d5eda4a08bd6b6e8de7207a231523c8d98fb445e +F src/test_intarray.c e4216aadee9df2de7d1aee7e70f6b22c80ee79ece72a63d57105db74217639e5 F src/test_intarray.h 6c3534641108cd1bea517a8e117dcba237081310a29a4c35bd2190caa8972293 F src/test_journal.c a0b9709b2f12b1ec819eea8a1176f283bca6d688a6d4a502bd6fd79786f4e287 F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd -F src/test_malloc.c 21121ea85b49ec0bdb69995847cef9036ef9beca3ce63bbb776e4ea2ecc44b97 -F src/test_md5.c 0472c86d561f7f9e4ff94080100c2783196f50e583bb83375b759450c5b81802 -F src/test_multiplex.c 70479161239d65af2a231550b270e9d11ece717ad7bf0e13ef42206586e9dd7f +F src/test_malloc.c a0295e022103b14a1bc5e0660cc2af7fbec05e0d029098782e326e50612e69d9 +F src/test_md5.c 811a45330c9391933360f998156a8907ee29909c828ab83ac05d329942cbea8f +F src/test_multiplex.c b99d7f43ec859e6b93a40aaa5455420b3ad133053cce3db739498d29ea30735f F src/test_multiplex.h f0ff5b6f4462bfd46dac165d6375b9530d08089b7bcbe75e88e0926110db5363 -F src/test_mutex.c cd5bac43f2fd168f43c4326b1febe0966439217fac52afb270a6b8215f94cb40 +F src/test_mutex.c f10fcbc2086b19c7b0ddf2752caf2095e42be74d8d7f6093619445b43b1f777b F src/test_onefile.c f31e52e891c5fef6709b9fcef54ce660648a34172423a9cbdf4cbce3ba0049f4 -F src/test_osinst.c 8e11faf10f5d4df10d3450ecee0b8f4cfa2b62e0f341fafbeb480a08cefeaec4 +F src/test_osinst.c 7aa3feaa3a1da1b5f75bde2ce958dbfe14ec484f065bb2b5b9727d8851fa089b F src/test_pcache.c 496da3f7e2ca66aefbc36bbf22138b1eff43ba0dff175c228b760fa020a37bd0 -F src/test_quota.c ea44c05f29b995bdb71c55eb0c602604884e55681d59b7736e604bbcc68b0464 +F src/test_quota.c 07369655d24c3f3fbdbd8fd8f42e856a054a7497846ca1c83ed4be68152a251f F src/test_quota.h 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d -F src/test_rtree.c 671f3fae50ff116ef2e32a3bf1fe21b5615b4b7b -F src/test_schema.c cbfd7a9a9b6b40d4377d0c76a6c5b2a58387385977f26edab4e77eb5f90a14ce +F src/test_rtree.c d844d746a3cc027247318b970025a927f14772339c991f40e7911583ea5ed0d9 +F src/test_schema.c b06d3ddc3edc173c143878f3edb869dd200d57d918ae2f38820534f9a5e3d7d9 F src/test_sqllog.c 540feaea7280cd5f926168aee9deb1065ae136d0bbbe7361e2ef3541783e187a -F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e -F src/test_syscall.c 9fdb13b1df05e639808d44fcb8f6064aaded32b6565c00b215cfd05a060d1aca -F src/test_tclsh.c aaf0d1de4a518a8db5ad38e5262be3e48b4a74ad1909f2dba753cecb30979d5d -F src/test_tclvar.c 3273f9d59395b336e381b53cfc68ec6ebdaada4e93106a2e976ffb0550504e1c -F src/test_thread.c 7ddcf0c8b79fa3c1d172f82f322302c963d923cdb503c6171f3c8081586d0b01 -F src/test_vdbecov.c f60c6f135ec42c0de013a1d5136777aa328a776d33277f92abac648930453d43 -F src/test_vfs.c 193c18da3dbf62a0e33ae7a240bbef938a50846672ee947664512b77d853fe81 +F src/test_superlock.c 18355ca274746aa6909e3744163e5deb1196a85d5bc64b9cd377273cef626da7 +F src/test_syscall.c 9ad7ab39910c16d29411678d91b0d27a7a996a718df5ee93dcd635e846d0275c +F src/test_tclsh.c 6077f2bdc6b4ea2bace2a0cd6ea48e0a4651007ae7382c13efc0c495eb0c6956 +F src/test_tclvar.c 2c42fe9a74af0f3c8f87a339f66d9d3bd3a967fb5db1ed2500348055b954e391 +F src/test_thread.c d7a8bcea7445f37cc2a1f7f81dd6059634f45e0c61bfe80182b02872fb0328bb +F src/test_vdbecov.c 5c426d9cd2b351f5f9ceb30cabf8c64a63bfcad644c507e0bd9ce2f6ae1a3bf3 +F src/test_vfs.c f298475e468c7e14945b20af885917181090c265aa3c4ade897849c9fbd396f2 F src/test_vfstrace.c a2ea82df2ed8927e9eba49bdba1aa1aeb1dcb13dbf6558cff036da813031de9a F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca2486ac1 F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb775ebc50 -F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f +F src/test_window.c 6d80e11fba89a1796525e6f0048ff0c7789aa2c6b0b11c80827dc1437bd8ea72 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 @@ -2121,7 +2122,7 @@ F tool/mkautoconfamal.sh cbdcf993fa83dccbef7fb77b39cdeb31ef9f77d9d88c9e343b58d35 F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x F tool/mkctimec.tcl 060e9785e9503bf51f8b1b11b542bdeef90fd0ceb0738154f6762acec0c61e5f x F tool/mkkeywordhash.c b9faa0ae7e14e4dbbcd951cddd786bf46b8a65bb07b129ba8c0cfade723aaffd -F tool/mkmsvcmin.tcl 8897d515ef7f94772322db95a3b6fce6c614d84fe0bdd06ba5a1c786351d5a1d +F tool/mkmsvcmin.tcl d76c45efda1cce2d4005bcea7b8a22bb752e3256009f331120fb4fecb14ebb7a F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef F tool/mkopcodeh.tcl 2b4e6967a670ef21bf53a164964c35c6163277d002a4c6f56fa231d68c88d023 F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa @@ -2134,14 +2135,14 @@ F tool/mksqlite3c.tcl c6acfdf4e4ef93478ff3ce3cd593e17abb03f446036ce710c3156bcfa1 F tool/mksqlite3h.tcl d391cff7cad0a372ee1406faee9ccc7dad9cb80a0c95cae0f73d10dd26e06762 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mktoolzip.tcl c7a9b685f5131d755e7d941cec50cee7f34178b9e34c9a89811eeb08617f8423 -F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 +F tool/mkvsix.tcl 67b40996a50f985a573278eea32fc5a5eb6110bdf14d33f1d8086e48c69e540a F tool/offsets.c 8ed2b344d33f06e71366a9b93ccedaa38c096cc1dbd4c3c26ad08c6115285845 F tool/omittest-msvc.tcl d6b8f501ac1d7798c4126065030f89812379012cad98a1735d6d7221492abc08 F tool/omittest.tcl e99c9fecc3f7a8ca2fa75d8ec8bdbb5acce33dc69f0c280aae53064693387f65 F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b -F tool/replace.tcl 937c931ad560688e85bdd6258bdc754371bb1e2732e1fb28ef441e44c9228fce -F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a +F tool/replace.tcl 511c61acfe563dfb58675efb4628bb158a13d48ff8322123ac447e9d25a82d9a +F tool/restore_jrnl.tcl 1079ecba47cc82fa82115b81c1f68097ab1f956f357ee8da5fc4b2589af6bd98 F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 F tool/run-speed-test.sh f95d19fd669b68c4c38b6b475242841d47c66076 F tool/showdb.c 0f74b54cc67076c76cba9b2b7f54d3e05b78d130c70ffc394eb84c5b41bab017 @@ -2199,8 +2200,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0 -R ad51bbdd14781776f7624246eec357e7 +P 86de4e755e37dc1cbcbd59018927aa87ff49fc15f706a36187631d8f14075c12 +R f26b0d5f665cd9e5cd8b699e9fa3852a +T *branch * tcl9 +T *sym-tcl9 * +T -sym-trunk * U drh -Z 102d909571cd81f9b00d601f888788db +Z 6096f47dfe122296507e83030fc2948d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index da015916e3..9daced7f7e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -86de4e755e37dc1cbcbd59018927aa87ff49fc15f706a36187631d8f14075c12 +6e5bb48a74d63fb8c30528f0005d1763cd2dbb882abf86baf1565721e6bfcf84 diff --git a/src/tclsqlite.c b/src/tclsqlite.c index d91b2fa3f1..ae3b61c6c3 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -35,14 +35,7 @@ # include "msvc.h" #endif -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #include /* @@ -388,7 +381,7 @@ static int SQLITE_TCLAPI incrblobHandle( static Tcl_ChannelType IncrblobChannelType = { "incrblob", /* typeName */ - TCL_CHANNEL_VERSION_2, /* version */ + TCL_CHANNEL_VERSION_5, /* version */ incrblobClose, /* closeProc */ incrblobInput, /* inputProc */ incrblobOutput, /* outputProc */ @@ -474,7 +467,7 @@ static int safeToUseEvalObjv(Tcl_Interp *interp, Tcl_Obj *pCmd){ ** characters appear in pCmd, we will report the string as unsafe. */ const char *z; - int n; + Tcl_Size n; z = Tcl_GetStringFromObj(pCmd, &n); while( n-- > 0 ){ int c = *(z++); @@ -981,7 +974,7 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ ** be preserved and reused on the next invocation. */ Tcl_Obj **aArg; - int nArg; + Tcl_Size nArg; if( Tcl_ListObjGetElements(p->interp, p->pScript, &nArg, &aArg) ){ sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); return; @@ -1044,7 +1037,7 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); }else{ Tcl_Obj *pVar = Tcl_GetObjResult(p->interp); - int n; + Tcl_Size n; u8 *data; const char *zType = (pVar->typePtr ? pVar->typePtr->name : ""); char c = zType[0]; @@ -1455,7 +1448,7 @@ static int dbPrepareAndBind( } } if( pVar ){ - int n; + Tcl_Size n; u8 *data; const char *zType = (pVar->typePtr ? pVar->typePtr->name : ""); c = zType[0]; @@ -1469,8 +1462,9 @@ static int dbPrepareAndBind( Tcl_IncrRefCount(pVar); pPreStmt->apParm[iParm++] = pVar; }else if( c=='b' && strcmp(zType,"boolean")==0 ){ - Tcl_GetIntFromObj(interp, pVar, &n); - sqlite3_bind_int(pStmt, i, n); + int nn; + Tcl_GetIntFromObj(interp, pVar, &nn); + sqlite3_bind_int(pStmt, i, nn); }else if( c=='d' && strcmp(zType,"double")==0 ){ double r; Tcl_GetDoubleFromObj(interp, pVar, &r); @@ -2034,7 +2028,7 @@ static int SQLITE_TCLAPI DbObjCmd( } }else{ char *zAuth; - int len; + Tcl_Size len; if( pDb->zAuth ){ Tcl_Free(pDb->zAuth); } @@ -2137,7 +2131,7 @@ static int SQLITE_TCLAPI DbObjCmd( } }else{ char *zCallback; - int len; + Tcl_Size len; if( pDb->zBindFallback ){ Tcl_Free(pDb->zBindFallback); } @@ -2167,7 +2161,7 @@ static int SQLITE_TCLAPI DbObjCmd( } }else{ char *zBusy; - int len; + Tcl_Size len; if( pDb->zBusy ){ Tcl_Free(pDb->zBusy); } @@ -2274,7 +2268,7 @@ static int SQLITE_TCLAPI DbObjCmd( SqlCollate *pCollate; char *zName; char *zScript; - int nScript; + Tcl_Size nScript; if( objc!=4 ){ Tcl_WrongNumArgs(interp, 2, objv, "NAME SCRIPT"); return TCL_ERROR; @@ -2333,7 +2327,7 @@ static int SQLITE_TCLAPI DbObjCmd( } }else{ const char *zCommit; - int len; + Tcl_Size len; if( pDb->zCommit ){ Tcl_Free(pDb->zCommit); } @@ -2653,7 +2647,8 @@ static int SQLITE_TCLAPI DbObjCmd( Tcl_Obj *pValue = 0; unsigned char *pBA; unsigned char *pData; - int len, xrc; + Tcl_Size len; + int xrc; sqlite3_int64 mxSize = 0; int i; int isReadonly = 0; @@ -3024,7 +3019,7 @@ static int SQLITE_TCLAPI DbObjCmd( return TCL_ERROR; } if( objc==3 ){ - int len; + Tcl_Size len; char *zNull = Tcl_GetStringFromObj(objv[2], &len); if( pDb->zNull ){ Tcl_Free(pDb->zNull); @@ -3078,7 +3073,7 @@ static int SQLITE_TCLAPI DbObjCmd( #endif }else if( objc==4 ){ char *zProgress; - int len; + Tcl_Size len; int N; if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &N) ){ return TCL_ERROR; @@ -3124,7 +3119,7 @@ static int SQLITE_TCLAPI DbObjCmd( } }else{ char *zProfile; - int len; + Tcl_Size len; if( pDb->zProfile ){ Tcl_Free(pDb->zProfile); } @@ -3335,7 +3330,7 @@ static int SQLITE_TCLAPI DbObjCmd( } }else{ char *zTrace; - int len; + Tcl_Size len; if( pDb->zTrace ){ Tcl_Free(pDb->zTrace); } @@ -3375,7 +3370,7 @@ static int SQLITE_TCLAPI DbObjCmd( } }else{ char *zTraceV2; - int len; + Tcl_Size len; Tcl_WideInt wMask = 0; if( objc==4 ){ static const char *TTYPE_strs[] = { @@ -3961,14 +3956,20 @@ EXTERN int Tclsqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } EXTERN int Sqlite3_SafeInit(Tcl_Interp *interp){ return TCL_ERROR; } EXTERN int Sqlite3_SafeUnload(Tcl_Interp *interp, int flags){return TCL_ERROR;} - - -#ifndef SQLITE_3_SUFFIX_ONLY -int Sqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } -int Tclsqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } -int Sqlite_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } -int Tclsqlite_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } -#endif +/* +** Versions of all of the above entry points that omit the "3" at the end +** of the name. Years ago (circa 2004) the "3" was necessary to distinguish +** SQLite version 3 from Sqlite version 2. But two decades have elapsed. +** SQLite2 is not longer a conflict. So it is ok to omit the "3". +** +** Omitting the "3" helps TCL find the entry point. +*/ +EXTERN int Sqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp);} +EXTERN int Tclsqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } +EXTERN int Sqlite_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } +EXTERN int Tclsqlite_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } +EXTERN int Sqlite_SafeInit(Tcl_Interp *interp){ return TCL_ERROR; } +EXTERN int Sqlite_SafeUnload(Tcl_Interp *interp, int flags){return TCL_ERROR;} /* ** If the TCLSH macro is defined, add code to make a stand-alone program. diff --git a/src/tclsqlite.h b/src/tclsqlite.h new file mode 100644 index 0000000000..217b9a05b6 --- /dev/null +++ b/src/tclsqlite.h @@ -0,0 +1,37 @@ +/* +** 2024-07-30 +** +** 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 header file defines the interface to TCL as used by SQLite. +** SQLite subcomponents that use TCL (the libsqlite3.c interface library +** and various test*.c pieces) should #include this file rather than +** including tcl.h directly. +*/ + +/* When compiling for Windows using STDCALL instead of CDECL calling +** conventions, the MSVC makefile has to build a customized version of +** the "tcl.h" header that specifies the calling conventions for each +** interface. That customized "tcl.h" is named "sqlite_tcl.h". +*/ +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" /* Special case for Windows using STDCALL */ +#else +# include "tcl.h" /* All normal cases */ +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif +#endif + +/* Compatability between Tcl8.6 and Tcl9.0 */ +#if TCL_MAJOR_VERSION==9 +# define CONST const +#else + typedef int Tcl_Size; +#endif diff --git a/src/test1.c b/src/test1.c index 975758131e..90035151e4 100644 --- a/src/test1.c +++ b/src/test1.c @@ -26,11 +26,7 @@ #endif #include "vdbeInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include @@ -1772,7 +1768,7 @@ static int SQLITE_TCLAPI blobHandleFromObj( sqlite3_blob **ppBlob ){ char *z; - int n; + Tcl_Size n; z = Tcl_GetStringFromObj(pObj, &n); if( n==0 ){ @@ -4102,7 +4098,7 @@ static int SQLITE_TCLAPI test_bind_text( ){ sqlite3_stmt *pStmt; int idx; - int trueLength = 0; + Tcl_Size trueLength = 0; int bytes; char *value; int rc; @@ -4160,7 +4156,7 @@ static int SQLITE_TCLAPI test_bind_text16( char *value; char *toFree = 0; int rc; - int trueLength = 0; + Tcl_Size trueLength = 0; void (*xDel)(void*) = (objc==6?SQLITE_STATIC:SQLITE_TRANSIENT); Tcl_Obj *oStmt = objv[objc-4]; @@ -4214,7 +4210,8 @@ static int SQLITE_TCLAPI test_bind_blob( Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; - int len, idx; + Tcl_Size len; + int idx; int bytes; char *value; int rc; @@ -4240,7 +4237,7 @@ static int SQLITE_TCLAPI test_bind_blob( if( bytes>len ){ char zBuf[200]; sqlite3_snprintf(sizeof(zBuf), zBuf, - "cannot use %d blob bytes, have %d", bytes, len); + "cannot use %d blob bytes, have %d", bytes, (int)len); Tcl_AppendResult(interp, zBuf, (char*)0); return TCL_ERROR; } @@ -4538,9 +4535,9 @@ static int SQLITE_TCLAPI test_carray_bind( struct iovec *a = sqlite3_malloc( sizeof(struct iovec)*nData ); if( a==0 ){ rc = SQLITE_NOMEM; goto carray_bind_done; } for(j=0; jpMethods->xWrite(pFile, aData, nData, iOff); + rc = pFile->pMethods->xWrite(pFile, aData, (int)(nData&0x7fffffff), iOff); Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); return TCL_OK; diff --git a/src/test2.c b/src/test2.c index c75fa2ebab..a9549aa7f5 100644 --- a/src/test2.c +++ b/src/test2.c @@ -14,11 +14,7 @@ ** testing of the SQLite library. */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include #include diff --git a/src/test3.c b/src/test3.c index 7fd7662479..f1b2b01680 100644 --- a/src/test3.c +++ b/src/test3.c @@ -15,11 +15,7 @@ */ #include "sqliteInt.h" #include "btreeInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include @@ -623,6 +619,7 @@ static int SQLITE_TCLAPI btree_insert( BtCursor *pCur; int rc; BtreePayload x; + Tcl_Size n; if( objc!=4 && objc!=3 ){ Tcl_WrongNumArgs(interp, 1, objv, "?-intkey? CSR KEY VALUE"); @@ -633,10 +630,11 @@ static int SQLITE_TCLAPI btree_insert( if( objc==4 ){ if( Tcl_GetIntFromObj(interp, objv[2], &rc) ) return TCL_ERROR; x.nKey = rc; - x.pData = (void*)Tcl_GetByteArrayFromObj(objv[3], &x.nData); + x.pData = (void*)Tcl_GetByteArrayFromObj(objv[3], &n); + x.nData = (int)n; }else{ - x.pKey = (void*)Tcl_GetByteArrayFromObj(objv[2], &rc); - x.nKey = rc; + x.pKey = (void*)Tcl_GetByteArrayFromObj(objv[2], &n); + x.nKey = (int)n; } pCur = (BtCursor*)sqlite3TestTextToPtr(Tcl_GetString(objv[1])); diff --git a/src/test4.c b/src/test4.c index 2043a33830..8a68f7d3e4 100644 --- a/src/test4.c +++ b/src/test4.c @@ -12,11 +12,7 @@ ** Code for testing the SQLite library in a multithreaded environment. */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #if SQLITE_OS_UNIX && SQLITE_THREADSAFE #include #include diff --git a/src/test5.c b/src/test5.c index 0d9242862b..334b5d07fe 100644 --- a/src/test5.c +++ b/src/test5.c @@ -17,11 +17,7 @@ */ #include "sqliteInt.h" #include "vdbeInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include @@ -36,7 +32,7 @@ static int SQLITE_TCLAPI binarize( int objc, Tcl_Obj *CONST objv[] ){ - int len; + Tcl_Size len; char *bytes; Tcl_Obj *pRet; assert(objc==2); @@ -133,7 +129,7 @@ static int SQLITE_TCLAPI test_translate( sqlite3_value *pVal; char *z; - int len; + Tcl_Size len; void (*xDel)(void *p) = SQLITE_STATIC; if( objc!=4 && objc!=5 ){ @@ -164,7 +160,7 @@ static int SQLITE_TCLAPI test_translate( z = (char*)Tcl_GetByteArrayFromObj(objv[1], &len); if( objc==5 ){ char *zTmp = z; - z = sqlite3_malloc(len); + z = sqlite3_malloc64(len); memcpy(z, zTmp, len); } sqlite3ValueSetStr(pVal, -1, z, enc_from, xDel); diff --git a/src/test6.c b/src/test6.c index 5d8e6b9be6..76db640c4d 100644 --- a/src/test6.c +++ b/src/test6.c @@ -16,11 +16,7 @@ */ #if SQLITE_TEST /* This file is used for testing only */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #ifndef SQLITE_OMIT_DISKIO /* This file is a no-op if disk I/O is disabled */ @@ -751,7 +747,7 @@ static int processDevSymArgs( int setDeviceChar = 0; for(i=0; i11 || nOpt<2 || strncmp("-sectorsize", zOpt, nOpt)) @@ -776,11 +772,11 @@ static int processDevSymArgs( }else{ int j; Tcl_Obj **apObj; - int nObj; + Tcl_Size nObj; if( Tcl_ListObjGetElements(interp, objv[i+1], &nObj, &apObj) ){ return TCL_ERROR; } - for(j=0; j #include diff --git a/src/test9.c b/src/test9.c index 5b139e8a56..b5362adb7f 100644 --- a/src/test9.c +++ b/src/test9.c @@ -15,11 +15,7 @@ ** as there is not much point in binding to Tcl. */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include diff --git a/src/test_async.c b/src/test_async.c index c32c74c660..afe401ac69 100644 --- a/src/test_async.c +++ b/src/test_async.c @@ -14,15 +14,8 @@ ** (defined in ext/async/sqlite3async.h) to Tcl. */ -#define TCL_THREADS -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#define TCL_THREADS +#include "tclsqlite.h" #ifdef SQLITE_ENABLE_ASYNCIO diff --git a/src/test_autoext.c b/src/test_autoext.c index e23e41a08a..74ca55879f 100644 --- a/src/test_autoext.c +++ b/src/test_autoext.c @@ -11,14 +11,7 @@ ************************************************************************* ** Test extension for testing the sqlite3_auto_extension() function. */ -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #include "sqlite3ext.h" #ifndef SQLITE_OMIT_LOAD_EXTENSION diff --git a/src/test_backup.c b/src/test_backup.c index 9b684a28f6..8051888ee6 100644 --- a/src/test_backup.c +++ b/src/test_backup.c @@ -13,14 +13,7 @@ ** */ -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #include "sqlite3.h" #include diff --git a/src/test_bestindex.c b/src/test_bestindex.c index c89cab2e39..2f9203d85e 100644 --- a/src/test_bestindex.c +++ b/src/test_bestindex.c @@ -93,11 +93,7 @@ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #ifndef SQLITE_OMIT_VIRTUALTABLE @@ -352,14 +348,14 @@ static int tclFilter( */ Tcl_Obj *pRes = Tcl_GetObjResult(interp); Tcl_Obj **apElem = 0; - int nElem; + Tcl_Size nElem; rc = Tcl_ListObjGetElements(interp, pRes, &nElem, &apElem); if( rc!=TCL_OK ){ const char *zErr = Tcl_GetStringResult(interp); rc = SQLITE_ERROR; pTab->base.zErrMsg = sqlite3_mprintf("%s", zErr); }else{ - for(ii=0; rc==SQLITE_OK && ii #include #include @@ -58,7 +54,7 @@ static int blobHandleFromObj( sqlite3_blob **ppBlob ){ char *z; - int n; + Tcl_Size n; z = Tcl_GetStringFromObj(pObj, &n); if( n==0 ){ @@ -88,7 +84,7 @@ static int blobHandleFromObj( ** NULL Pointer is returned. */ static char *blobStringFromObj(Tcl_Obj *pObj){ - int n; + Tcl_Size n; char *z; z = Tcl_GetStringFromObj(pObj, &n); return (n ? z : 0); @@ -112,7 +108,7 @@ static int SQLITE_TCLAPI test_blob_open( Tcl_WideInt iRowid; int flags; const char *zVarname; - int nVarname; + Tcl_Size nVarname; sqlite3_blob *pBlob = (sqlite3_blob*)&flags; /* Non-zero initialization */ int rc; @@ -281,7 +277,8 @@ static int SQLITE_TCLAPI test_blob_write( int rc; unsigned char *zBuf; - int nBuf; + Tcl_Size nBuf; + int n; if( objc!=4 && objc!=5 ){ Tcl_WrongNumArgs(interp, 1, objv, "HANDLE OFFSET DATA ?NDATA?"); @@ -294,10 +291,11 @@ static int SQLITE_TCLAPI test_blob_write( } zBuf = Tcl_GetByteArrayFromObj(objv[3], &nBuf); - if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &nBuf) ){ + n = (int)(nBuf & 0x7fffffff); + if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &n) ){ return TCL_ERROR; } - rc = sqlite3_blob_write(pBlob, zBuf, nBuf, iOffset); + rc = sqlite3_blob_write(pBlob, zBuf, n, iOffset); if( rc!=SQLITE_OK ){ Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); } diff --git a/src/test_btree.c b/src/test_btree.c index 03b8b207c9..168a10f1f3 100644 --- a/src/test_btree.c +++ b/src/test_btree.c @@ -14,11 +14,7 @@ ** testing of the SQLite library. */ #include "btreeInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" /* ** Usage: sqlite3_shared_cache_report diff --git a/src/test_config.c b/src/test_config.c index 76904e5bf2..58de5a4625 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -24,11 +24,7 @@ # include "os_win.h" #endif -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include diff --git a/src/test_demovfs.c b/src/test_demovfs.c index e990e98f29..e92fd56138 100644 --- a/src/test_demovfs.c +++ b/src/test_demovfs.c @@ -645,14 +645,7 @@ sqlite3_vfs *sqlite3_demovfs(void){ #ifdef SQLITE_TEST -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" #if SQLITE_OS_UNIX static int SQLITE_TCLAPI register_demovfs( diff --git a/src/test_fs.c b/src/test_fs.c index f88f3a9425..d821a83b9d 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -62,12 +62,7 @@ ** SELECT * FROM fstree WHERE path LIKE '/home/dan/sqlite/%' */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif - +#include "tclsqlite.h" #include #include #include diff --git a/src/test_func.c b/src/test_func.c index 80df488282..8c06705ae4 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -13,11 +13,7 @@ ** implements new SQL functions used by the test scripts. */ #include "sqlite3.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include #include diff --git a/src/test_hexio.c b/src/test_hexio.c index 61a41d5b1c..8999d84d27 100644 --- a/src/test_hexio.c +++ b/src/test_hexio.c @@ -18,11 +18,7 @@ ** easier and safer to build our own mechanism. */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include #include @@ -155,7 +151,8 @@ static int SQLITE_TCLAPI hexio_write( Tcl_Obj *CONST objv[] ){ int offset; - int nIn, nOut, written; + Tcl_Size nIn; + int nOut, written; const char *zFile; const unsigned char *zIn; unsigned char *aOut; @@ -168,11 +165,11 @@ static int SQLITE_TCLAPI hexio_write( if( Tcl_GetIntFromObj(interp, objv[2], &offset) ) return TCL_ERROR; zFile = Tcl_GetString(objv[1]); zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[3], &nIn); - aOut = sqlite3_malloc( 1 + nIn/2 ); + aOut = sqlite3_malloc64( 1 + nIn/2 ); if( aOut==0 ){ return TCL_ERROR; } - nOut = sqlite3TestHexToBin(zIn, nIn, aOut); + nOut = sqlite3TestHexToBin(zIn, (int)nIn, aOut); out = fopen(zFile, "r+b"); if( out==0 ){ out = fopen(zFile, "r+"); @@ -203,7 +200,8 @@ static int SQLITE_TCLAPI hexio_get_int( Tcl_Obj *CONST objv[] ){ int val; - int nIn, nOut; + Tcl_Size nIn; + int nOut; const unsigned char *zIn; unsigned char *aOut; unsigned char aNum[4]; @@ -213,11 +211,11 @@ static int SQLITE_TCLAPI hexio_get_int( return TCL_ERROR; } zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[1], &nIn); - aOut = sqlite3_malloc( 1 + nIn/2 ); + aOut = sqlite3_malloc64( 1 + nIn/2 ); if( aOut==0 ){ return TCL_ERROR; } - nOut = sqlite3TestHexToBin(zIn, nIn, aOut); + nOut = sqlite3TestHexToBin(zIn, (int)nIn, aOut); if( nOut>=4 ){ memcpy(aNum, aOut, 4); }else{ @@ -300,7 +298,7 @@ static int SQLITE_TCLAPI utf8_to_utf8( Tcl_Obj *CONST objv[] ){ #ifdef SQLITE_DEBUG - int n; + Tcl_Size n; int nOut; const unsigned char *zOrig; unsigned char *z; @@ -309,8 +307,8 @@ static int SQLITE_TCLAPI utf8_to_utf8( return TCL_ERROR; } zOrig = (unsigned char *)Tcl_GetStringFromObj(objv[1], &n); - z = sqlite3_malloc( n+4 ); - n = sqlite3TestHexToBin(zOrig, n, z); + z = sqlite3_malloc64( n+4 ); + n = sqlite3TestHexToBin(zOrig, (int)n, z); z[n] = 0; nOut = sqlite3Utf8To8(z); sqlite3TestBinToHex(z,nOut); @@ -361,7 +359,7 @@ static int SQLITE_TCLAPI read_fts3varint( int objc, Tcl_Obj *CONST objv[] ){ - int nBlob; + Tcl_Size nBlob; unsigned char *zBlob; sqlite3_int64 iVal; int nVal; @@ -388,10 +386,10 @@ static int SQLITE_TCLAPI make_fts3record( Tcl_Obj *CONST objv[] ){ Tcl_Obj **aArg = 0; - int nArg = 0; + Tcl_Size nArg = 0; unsigned char *aOut = 0; - int nOut = 0; - int nAlloc = 0; + sqlite3_int64 nOut = 0; + sqlite3_int64 nAlloc = 0; int i; if( objc!=2 ){ @@ -402,7 +400,7 @@ static int SQLITE_TCLAPI make_fts3record( return TCL_ERROR; } - for(i=0; inAlloc ){ @@ -417,11 +415,11 @@ static int SQLITE_TCLAPI make_fts3record( } nOut += putFts3Varint((char*)&aOut[nOut], iVal); }else{ - int nVal = 0; + Tcl_Size nVal = 0; char *zVal = Tcl_GetStringFromObj(aArg[i], &nVal); while( (nOut + nVal)>nAlloc ){ - int nNew = nAlloc?nAlloc*2:128; - unsigned char *aNew = sqlite3_realloc(aOut, nNew); + sqlite3_int64 nNew = nAlloc?nAlloc*2:128; + unsigned char *aNew = sqlite3_realloc64(aOut, nNew); if( aNew==0 ){ sqlite3_free(aOut); return TCL_ERROR; diff --git a/src/test_init.c b/src/test_init.c index 400ab9a2bf..f7b85875b0 100644 --- a/src/test_init.c +++ b/src/test_init.c @@ -27,11 +27,7 @@ #include "sqliteInt.h" #include -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" static struct Wrapped { sqlite3_pcache_methods2 pcache; diff --git a/src/test_intarray.c b/src/test_intarray.c index a978ed585d..16c1df2e9c 100644 --- a/src/test_intarray.c +++ b/src/test_intarray.c @@ -279,14 +279,7 @@ SQLITE_API int sqlite3_intarray_bind( ** Everything below is interface for testing this module. */ #ifdef SQLITE_TEST -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" /* ** Routines to encode and decode pointers diff --git a/src/test_malloc.c b/src/test_malloc.c index 8146501c9c..21faa0d291 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -14,11 +14,7 @@ ** memory allocation subsystem. */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include #include @@ -387,7 +383,8 @@ static int SQLITE_TCLAPI test_memset( Tcl_Obj *CONST objv[] ){ void *p; - int size, n, i; + int size, i; + Tcl_Size n; char *zHex; char *zOut; char zBin[100]; @@ -409,7 +406,7 @@ static int SQLITE_TCLAPI test_memset( } zHex = Tcl_GetStringFromObj(objv[3], &n); if( n>sizeof(zBin)*2 ) n = sizeof(zBin)*2; - n = sqlite3TestHexToBin(zHex, n, zBin); + n = sqlite3TestHexToBin(zHex, (int)n, zBin); if( n==0 ){ Tcl_AppendResult(interp, "no data", (char*)0); return TCL_ERROR; @@ -624,7 +621,7 @@ static int SQLITE_TCLAPI test_memdebug_fail( if( Tcl_GetIntFromObj(interp, objv[1], &iFail) ) return TCL_ERROR; for(ii=2; ii #include #include "sqlite3.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" /* * This code implements the MD5 message-digest algorithm. diff --git a/src/test_multiplex.c b/src/test_multiplex.c index d06ed2f793..e5b43f4cc1 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -1219,14 +1219,7 @@ int sqlite3_multiplex_shutdown(int eForce){ /***************************** Test Code ***********************************/ #ifdef SQLITE_TEST -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" extern const char *sqlite3ErrName(int); diff --git a/src/test_mutex.c b/src/test_mutex.c index a203208abe..e60a06df32 100644 --- a/src/test_mutex.c +++ b/src/test_mutex.c @@ -11,12 +11,7 @@ ************************************************************************* ** This file contains test logic for the sqlite3_mutex interfaces. */ - -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include "sqlite3.h" #include "sqliteInt.h" #include diff --git a/src/test_osinst.c b/src/test_osinst.c index 062e83159b..2d03d2bbcd 100644 --- a/src/test_osinst.c +++ b/src/test_osinst.c @@ -1109,14 +1109,7 @@ int sqlite3_vfslog_register(sqlite3 *db){ #if defined(SQLITE_TEST) || defined(TCLSH) -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" static int SQLITE_TCLAPI test_vfslog( void *clientData, diff --git a/src/test_quota.c b/src/test_quota.c index b436de4667..1bfc5ce11c 100644 --- a/src/test_quota.c +++ b/src/test_quota.c @@ -1278,14 +1278,7 @@ int sqlite3_quota_remove(const char *zFilename){ /***************************** Test Code ***********************************/ #ifdef SQLITE_TEST -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" /* ** Argument passed to a TCL quota-over-limit callback. @@ -1420,7 +1413,7 @@ static int SQLITE_TCLAPI test_quota_set( Tcl_Obj *pScript; /* Tcl script to invoke to increase quota */ int rc; /* Value returned by quota_set() */ TclQuotaCallback *p; /* Callback object */ - int nScript; /* Length of callback script */ + Tcl_Size nScript; /* Length of callback script */ void (*xDestroy)(void*); /* Optional destructor for pArg */ void (*xCallback)(const char *, sqlite3_int64 *, sqlite3_int64, void *); diff --git a/src/test_rtree.c b/src/test_rtree.c index 0c6dbf3cd7..53af6e5cfe 100644 --- a/src/test_rtree.c +++ b/src/test_rtree.c @@ -14,11 +14,7 @@ */ #include "sqlite3.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" /* Solely for the UNUSED_PARAMETER() macro. */ #include "sqliteInt.h" @@ -357,11 +353,7 @@ static int bfs_query_func(sqlite3_rtree_query_info *p){ *************************************************************************/ #include -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" typedef struct Cube Cube; struct Cube { diff --git a/src/test_schema.c b/src/test_schema.c index 2cbc18e2b2..660d21ea4e 100644 --- a/src/test_schema.c +++ b/src/test_schema.c @@ -36,11 +36,7 @@ */ #ifdef SQLITE_TEST # include "sqliteInt.h" -# if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -# else -# include "tcl.h" -# endif +# include "tclsqlite.h" #else # include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 diff --git a/src/test_superlock.c b/src/test_superlock.c index 45d0d623a0..7f3bf163a5 100644 --- a/src/test_superlock.c +++ b/src/test_superlock.c @@ -256,14 +256,7 @@ int sqlite3demo_superlock( #ifdef SQLITE_TEST -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" struct InterpAndScript { Tcl_Interp *interp; diff --git a/src/test_syscall.c b/src/test_syscall.c index 3cd1034d3f..af2ae10015 100644 --- a/src/test_syscall.c +++ b/src/test_syscall.c @@ -76,11 +76,7 @@ #include "sqliteInt.h" #include "sqlite3.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include #include @@ -197,7 +193,7 @@ static int tsIsFail(void){ */ static int tsErrno(const char *zFunc){ int i; - int nFunc = strlen(zFunc); + size_t nFunc = strlen(zFunc); for(i=0; aSyscall[i].zName; i++){ if( strlen(aSyscall[i].zName)!=nFunc ) continue; if( memcmp(aSyscall[i].zName, zFunc, nFunc) ) continue; @@ -429,7 +425,7 @@ static int SQLITE_TCLAPI test_syscall_install( Tcl_Obj *CONST objv[] ){ sqlite3_vfs *pVfs; - int nElem; + Tcl_Size nElem; int i; Tcl_Obj **apElem; @@ -442,7 +438,7 @@ static int SQLITE_TCLAPI test_syscall_install( } pVfs = sqlite3_vfs_find(0); - for(i=0; ixSetSystemCall(pVfs, 0, 0); for(i=0; aSyscall[i].zName; i++) aSyscall[i].xOrig = 0; }else{ - int nFunc; + Tcl_Size nFunc; char *zFunc = Tcl_GetStringFromObj(objv[2], &nFunc); rc = pVfs->xSetSystemCall(pVfs, Tcl_GetString(objv[2]), 0); for(i=0; rc==SQLITE_OK && aSyscall[i].zName; i++){ diff --git a/src/test_tclsh.c b/src/test_tclsh.c index 4697c3b856..db362049e7 100644 --- a/src/test_tclsh.c +++ b/src/test_tclsh.c @@ -20,14 +20,7 @@ ** in an effort to keep the tclsqlite.c file pure. */ #include "sqlite3.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -# ifndef SQLITE_TCLAPI -# define SQLITE_TCLAPI -# endif -#endif +#include "tclsqlite.h" /* Needed for the setrlimit() system call on unix */ #if defined(unix) diff --git a/src/test_tclvar.c b/src/test_tclvar.c index 36165bc27d..9be8774491 100644 --- a/src/test_tclvar.c +++ b/src/test_tclvar.c @@ -36,11 +36,7 @@ ** according to "fullname" and "value" only. */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #include #include @@ -150,10 +146,10 @@ static int next2(Tcl_Interp *interp, tclvar_cursor *pCur, Tcl_Obj *pObj){ Tcl_IncrRefCount(pCur->pList2); assert( pCur->i2==0 ); }else{ - int n = 0; + Tcl_Size n = 0; pCur->i2++; Tcl_ListObjLength(0, pCur->pList2, &n); - if( pCur->i2>=n ){ + if( pCur->i2>=(int)n ){ Tcl_DecrRefCount(pCur->pList2); pCur->pList2 = 0; pCur->i2 = 0; @@ -167,14 +163,14 @@ static int next2(Tcl_Interp *interp, tclvar_cursor *pCur, Tcl_Obj *pObj){ static int tclvarNext(sqlite3_vtab_cursor *cur){ Tcl_Obj *pObj; - int n = 0; + Tcl_Size n = 0; int ok = 0; tclvar_cursor *pCur = (tclvar_cursor *)cur; Tcl_Interp *interp = ((tclvar_vtab *)(cur->pVtab))->interp; Tcl_ListObjLength(0, pCur->pList1, &n); - while( !ok && pCur->i1i1<(int)n ){ Tcl_ListObjIndex(0, pCur->pList1, pCur->i1, &pObj); ok = next2(interp, pCur, pObj); if( !ok ){ diff --git a/src/test_thread.c b/src/test_thread.c index 126fd98369..7c06d110ac 100644 --- a/src/test_thread.c +++ b/src/test_thread.c @@ -16,11 +16,7 @@ */ #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #if SQLITE_THREADSAFE @@ -94,7 +90,7 @@ static int SQLITE_TCLAPI tclScriptEvent(Tcl_Event *evPtr, int flags){ static void postToParent(SqlThread *p, Tcl_Obj *pScript){ EvalEvent *pEvent; char *zMsg; - int nMsg; + Tcl_Size nMsg; zMsg = Tcl_GetStringFromObj(pScript, &nMsg); pEvent = (EvalEvent *)ckalloc(sizeof(EvalEvent)+nMsg+1); @@ -181,8 +177,8 @@ static int SQLITE_TCLAPI sqlthread_spawn( SqlThread *pNew; int rc; - int nVarname; char *zVarname; - int nScript; char *zScript; + Tcl_Size nVarname; char *zVarname; + Tcl_Size nScript; char *zScript; /* Parameters for thread creation */ const int nStack = TCL_THREAD_STACK_DEFAULT; @@ -232,7 +228,7 @@ static int SQLITE_TCLAPI sqlthread_parent( ){ EvalEvent *pEvent; char *zMsg; - int nMsg; + Tcl_Size nMsg; SqlThread *p = (SqlThread *)clientData; assert(objc==3); diff --git a/src/test_vdbecov.c b/src/test_vdbecov.c index a001b1df0a..283936aeb7 100644 --- a/src/test_vdbecov.c +++ b/src/test_vdbecov.c @@ -15,11 +15,7 @@ #include "sqlite3.h" #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" #ifdef SQLITE_VDBE_COVERAGE diff --git a/src/test_vfs.c b/src/test_vfs.c index 312e1a1be6..9f84b4f801 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -28,11 +28,7 @@ #include "sqlite3.h" #include "sqliteInt.h" -#if defined(INCLUDE_SQLITE_TCL_H) -# include "sqlite_tcl.h" -#else -# include "tcl.h" -#endif +#include "tclsqlite.h" typedef struct Testvfs Testvfs; typedef struct TestvfsShm TestvfsShm; @@ -1150,15 +1146,15 @@ static int SQLITE_TCLAPI testvfs_obj_cmd( return TCL_ERROR; } if( objc==4 ){ - int n; + Tcl_Size n; u8 *a = Tcl_GetByteArrayFromObj(objv[3], &n); int pgsz = pBuffer->pgsz; if( pgsz==0 ) pgsz = 65536; - for(i=0; i*pgszaPage[i], &a[i*pgsz], nByte); } @@ -1203,7 +1199,7 @@ static int SQLITE_TCLAPI testvfs_obj_cmd( { "xFileControl", TESTVFS_FCNTL_MASK }, }; Tcl_Obj **apElem = 0; - int nElem = 0; + Tcl_Size nElem = 0; int mask = 0; if( objc!=3 ){ Tcl_WrongNumArgs(interp, 2, objv, "LIST"); @@ -1213,7 +1209,7 @@ static int SQLITE_TCLAPI testvfs_obj_cmd( return TCL_ERROR; } Tcl_ResetResult(interp); - for(i=0; ipScript ){ Tcl_DecrRefCount(p->pScript); p->pScript = 0; @@ -1337,13 +1333,13 @@ static int SQLITE_TCLAPI testvfs_obj_cmd( int j; int iNew = 0; Tcl_Obj **flags = 0; - int nFlags = 0; + Tcl_Size nFlags = 0; if( Tcl_ListObjGetElements(interp, objv[2], &nFlags, &flags) ){ return TCL_ERROR; } - for(j=0; j +#include "tclsqlite.h" extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); extern const char *sqlite3ErrName(int); diff --git a/tool/mkmsvcmin.tcl b/tool/mkmsvcmin.tcl index 6cb145db85..7926952554 100644 --- a/tool/mkmsvcmin.tcl +++ b/tool/mkmsvcmin.tcl @@ -23,7 +23,7 @@ if {$argc==0} { proc readFile { fileName } { set file_id [open $fileName RDONLY] - fconfigure $file_id -encoding binary -translation binary + fconfigure $file_id -translation binary set result [read $file_id] close $file_id return $result @@ -31,7 +31,7 @@ proc readFile { fileName } { proc writeFile { fileName data } { set file_id [open $fileName {WRONLY CREAT TRUNC}] - fconfigure $file_id -encoding binary -translation binary + fconfigure $file_id -translation binary puts -nonewline $file_id $data close $file_id return "" diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index c874d538fb..0663213639 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -156,7 +156,7 @@ proc readFile { fileName } { # may contain binary data. # set file_id [open $fileName RDONLY] - fconfigure $file_id -encoding binary -translation binary + fconfigure $file_id -translation binary set result [read $file_id] close $file_id return $result @@ -168,7 +168,7 @@ proc writeFile { fileName data } { # binary data. # set file_id [open $fileName {WRONLY CREAT TRUNC}] - fconfigure $file_id -encoding binary -translation binary + fconfigure $file_id -translation binary puts -nonewline $file_id $data close $file_id return "" diff --git a/tool/replace.tcl b/tool/replace.tcl index e87cb922f2..6a462d95ff 100644 --- a/tool/replace.tcl +++ b/tool/replace.tcl @@ -4,8 +4,8 @@ # only lines successfully modified with a regular # expression. # -fconfigure stdout -translation binary -encoding binary -fconfigure stderr -translation binary -encoding binary +fconfigure stdout -translation binary +fconfigure stderr -translation binary set mode [string tolower [lindex $argv 0]] set from [lindex $argv 1] set to [lindex $argv 2] diff --git a/tool/restore_jrnl.tcl b/tool/restore_jrnl.tcl index 05af4f9a2a..200f9b1d29 100644 --- a/tool/restore_jrnl.tcl +++ b/tool/restore_jrnl.tcl @@ -114,40 +114,40 @@ proc dump_jrnl_page {jrnl_pgno} { set db_pgno [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset] 4]] set chksum [hexio_get_int [hexio_read $jrnl_name [expr $jrnl_pg_offset+4+$db_pgsz] 4]] set nonce [calc_nonce $jrnl_pgno] - puts [ format {jrnl_pg_offset: %08x (%d) jrnl_pgno: %d db_pgno: %d} \ - $jrnl_pg_offset $jrnl_pg_offset \ - $jrnl_pgno $db_pgno] - puts [ format {nonce: %08x chksum: %08x} \ - $nonce $chksum] + puts [ format {jrnl_pg_offset: %08x (%d) jrnl_pgno: %d db_pgno: %d} \ + $jrnl_pg_offset $jrnl_pg_offset \ + $jrnl_pgno $db_pgno] + puts [ format {nonce: %08x chksum: %08x} \ + $nonce $chksum] # now hex dump the data - # This is derived from the Tcler's WIKI - set fid [open $jrnl_name r] - fconfigure $fid -translation binary -encoding binary - seek $fid [expr $jrnl_pg_offset+4] - set data [read $fid $db_pgsz] - close $fid + # This is derived from the Tcler's WIKI + set fid [open $jrnl_name r] + fconfigure $fid -translation binary + seek $fid [expr $jrnl_pg_offset+4] + set data [read $fid $db_pgsz] + close $fid for {set addr 0} {$addr<$db_pgsz} {set addr [expr $addr+16]} { - # get 16 bytes of data - set s [string range $data $addr [expr $addr+16]] - - # Convert the data to hex and to characters. - binary scan $s H*@0a* hex ascii - - # Replace non-printing characters in the data. - regsub -all -- {[^[:graph:] ]} $ascii {.} ascii - - # Split the 16 bytes into two 8-byte chunks - regexp -- {(.{16})(.{0,16})} $hex -> hex1 hex2 - - # Convert the hex to pairs of hex digits - regsub -all -- {..} $hex1 {& } hex1 - regsub -all -- {..} $hex2 {& } hex2 - - # Print the hex and ascii data - puts [ format {%08x %-24s %-24s %-16s} \ - $addr $hex1 $hex2 $ascii ] - } + # get 16 bytes of data + set s [string range $data $addr [expr $addr+16]] + + # Convert the data to hex and to characters. + binary scan $s H*@0a* hex ascii + + # Replace non-printing characters in the data. + regsub -all -- {[^[:graph:] ]} $ascii {.} ascii + + # Split the 16 bytes into two 8-byte chunks + regexp -- {(.{16})(.{0,16})} $hex -> hex1 hex2 + + # Convert the hex to pairs of hex digits + regsub -all -- {..} $hex1 {& } hex1 + regsub -all -- {..} $hex2 {& } hex2 + + # Print the hex and ascii data + puts [ format {%08x %-24s %-24s %-16s} \ + $addr $hex1 $hex2 $ascii ] + } } # Setup for the tests. Make a backup copy of the files. @@ -230,4 +230,3 @@ do_test restore_jrnl-1.0 { catchsql {PRAGMA integrity_check} } {0 ok} db close - From 8174305e175bf352d47f6b3023b4b664abeb5ef6 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 30 Jul 2024 15:55:51 +0000 Subject: [PATCH 0572/1030] Update the highlight() and snippet() functions to use locales when available. FossilOrigin-Name: 569ae56a673a2e101fac7003a1cb41c7a02a515adf55bd1e1f2a03c19eb2b085 --- ext/fts5/fts5_aux.c | 29 +++++++++++++++++++++++++++++ ext/fts5/test/fts5locale.test | 34 ++++++++++++++++++++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c index 30101fbe25..e2226e3f03 100644 --- a/ext/fts5/fts5_aux.c +++ b/ext/fts5/fts5_aux.c @@ -226,6 +226,27 @@ static int fts5HighlightCb( return rc; } +/* +** Use xTokenizeSetLocale() to configure the tokenizer to use the locale +** associated with column iCol of the current row. +*/ +static int fts5ConfigureTokenizer( + const Fts5ExtensionApi *pApi, + Fts5Context *pFts, + int iCol +){ + int rc = SQLITE_OK; + const char *zLocale = 0; + int nLocale = 0; + + rc = pApi->xColumnLocale(pFts, iCol, &zLocale, &nLocale); + if( rc==SQLITE_OK ){ + rc = pApi->xTokenizeSetLocale(pFts, zLocale, nLocale); + } + return rc; +} + + /* ** Implementation of highlight() function. */ @@ -260,6 +281,9 @@ static void fts5HighlightFunction( rc = fts5CInstIterInit(pApi, pFts, iCol, &ctx.iter); } + if( rc==SQLITE_OK ){ + rc = fts5ConfigureTokenizer(pApi, pFts, iCol); + } if( rc==SQLITE_OK ){ rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); } @@ -465,6 +489,8 @@ static void fts5SnippetFunction( sFinder.nFirst = 0; rc = pApi->xColumnText(pFts, i, &sFinder.zDoc, &nDoc); if( rc!=SQLITE_OK ) break; + rc = fts5ConfigureTokenizer(pApi, pFts, i); + if( rc!=SQLITE_OK ) break; rc = pApi->xTokenize(pFts, sFinder.zDoc, nDoc, (void*)&sFinder,fts5SentenceFinderCb ); @@ -541,6 +567,9 @@ static void fts5SnippetFunction( rc = fts5CInstIterNext(&ctx.iter); } + if( rc==SQLITE_OK ){ + rc = fts5ConfigureTokenizer(pApi, pFts, iBestCol); + } if( rc==SQLITE_OK ){ rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); } diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index 71a76677ae..1124a44436 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -300,6 +300,40 @@ foreach {tn opt} { } { 2 3 2 4 } + + do_execsql_test 5.$tn.4 { + SELECT rowid, fts5_test_columnsize(y1) FROM y1('shall'); + } { + 2 3 + } + + do_execsql_test 5.$tn.5 { + SELECT rowid, fts5_test_columnsize(y1) FROM y1('shall'); + } { + 2 3 + } + + do_execsql_test 5.$tn.6 { + SELECT rowid, fts5_test_columnsize(y1) FROM y1('have'); + } { + 4 4 + } + + do_execsql_test 5.$tn.7 { + SELECT rowid, highlight(y1, 0, '[', ']') FROM y1('have'); + } { + 4 {which it hath been used to [have]} + } + + do_execsql_test 5.$tn.8 { + SELECT rowid, + highlight(y1, 0, '[', ']'), + snippet(y1, 0, '[', ']', '...', 10) + FROM y1('Liberties + Customs'); + } { + 3 {[Liberties and Customs]} + {[Liberties and Customs]} + } } diff --git a/manifest b/manifest index 8fb2030236..89acd2b99f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sxColumnText()\sand\sxColumnSize()\sAPIs.\sAdd\sxColumnLocale()\sand\sxTokenizeSetLocale(). -D 2024-07-29T20:31:17.644 +C Update\sthe\shighlight()\sand\ssnippet()\sfunctions\sto\suse\slocales\swhen\savailable. +D 2024-07-30T15:55:51.884 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -94,7 +94,7 @@ F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a0 F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h 7cd47e5dfe68d798e667caa76722374f0c909f2db05bb4d42b1ec5300d18e658 F ext/fts5/fts5Int.h 330b1e2dad9ea9cccc9fa93817062fa21e89f00e7eac9a84be440f7e93bf7c3c -F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 +F ext/fts5/fts5_aux.c 652f839dc0c77431295f10b08f268631560bb5630e65fd701de7a58744428a82 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 0c96490fbad746b3780174f38b2ee5e3d719f2f81ee6b58ca828772871e0f680 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad @@ -184,7 +184,7 @@ F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fd F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 14e46de0fbab3a01e16d8f61143260a7865cbe9d1759a564927635a1b08e9310 +F ext/fts5/test/fts5locale.test 7c332f882080a69ed4be9790d99ee49747ca44cf241d45f762298e17fea6e7a7 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2196,8 +2196,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4e3e529313c86b42d5f1ba113d0714d1545bc6641e09e4537d622057f0352989 -R 76149d45da5064496ccc1cbc5f33d6bf +P 14006711d83d098e665c540b978b0e29aa8f458da1c2c8e9c2baf2ad5ebd502c +R 8ced4a5b525d31957945a9ad2a3de4d9 U dan -Z 4addb1a2e7bbe8797df686b1934d0dc8 +Z 395467bf290b92744f082b81bcb8dffe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index eb3a346d11..634c3661ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14006711d83d098e665c540b978b0e29aa8f458da1c2c8e9c2baf2ad5ebd502c +569ae56a673a2e101fac7003a1cb41c7a02a515adf55bd1e1f2a03c19eb2b085 From 1631c64f780b54a0363495b58c52b8c942516671 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Jul 2024 16:51:51 +0000 Subject: [PATCH 0573/1030] Fix the incrblob channel so that partial close works with Tcl9. FossilOrigin-Name: d54ec2de78c2aed12be643e59a30b6827fe4728a0ab6504dd64ee9116e5f885a --- ext/fts5/test/fts5aa.test | 2 +- manifest | 19 ++++++++----------- manifest.uuid | 2 +- src/tclsqlite.c | 30 ++++++++++++++++++++++++++---- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/ext/fts5/test/fts5aa.test b/ext/fts5/test/fts5aa.test index a80a307a49..57f878c7ca 100644 --- a/ext/fts5/test/fts5aa.test +++ b/ext/fts5/test/fts5aa.test @@ -440,7 +440,7 @@ do_execsql_test 16.1 { proc funk {} { db eval { UPDATE n1_config SET v=50 WHERE k='version' } set fd [db incrblob main n1_data block 10] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary # puts -nonewline $fd "\x44\x45" close $fd } diff --git a/manifest b/manifest index 7821b9bd42..6fb17d9191 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C First\sattempt\sat\sgetting\sthe\sbuild\sto\swork\swith\sTcl\s9.0. -D 2024-07-30T15:49:02.043 +C Fix\sthe\sincrblob\schannel\sso\sthat\spartial\sclose\sworks\swith\sTcl9. +D 2024-07-30T16:51:51.690 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -112,7 +112,7 @@ F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl bc33c6cc65e5d390f28a68aeeb3a526dadd2c3a947d2466ee1986c1a4002df56 -F ext/fts5/test/fts5aa.test 4db81519863244a3cab35795fe65ab6b592e7970c7409eba098b23ebbfc08d95 +F ext/fts5/test/fts5aa.test 183a2296fc4dab220f935dbb99a81f441bc6b7226fdda268597f755d69e8205b F ext/fts5/test/fts5ab.test 4bdb619fee409e11417e8827e320b857e42e926a01a0408fc9f143ec870a6ced F ext/fts5/test/fts5ac.test 4a73626de86f3d17c95738034880c4f0de8d54741fb943d819b528373657e59b F ext/fts5/test/fts5ad.test 058e616612964e61d19f70295f0e6eaedceb4b29b1fbf4f859615ef7e779dc22 @@ -768,8 +768,8 @@ F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c f4753c1c90964a89f2c094f62bcb413fdefe0215c73c2d4fca4e8c50ace7a1f6 -F src/tclsqlite.h f3dc9ed1464a7cc775a47da70ac6f23e95d0fb939dd7eaf48639778f94d5aaad w src/tclinterface.h +F src/tclsqlite.c e36996d1426c37e314c648b6746c2671a875e1b66e9641ac13b89b16ab8c7ec1 +F src/tclsqlite.h f3dc9ed1464a7cc775a47da70ac6f23e95d0fb939dd7eaf48639778f94d5aaad F src/test1.c 9f01a43b5d9d0c08c31617f3ab4e924bb30cd47db784527dbf6a309456a4db3b F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b @@ -2200,11 +2200,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 86de4e755e37dc1cbcbd59018927aa87ff49fc15f706a36187631d8f14075c12 -R f26b0d5f665cd9e5cd8b699e9fa3852a -T *branch * tcl9 -T *sym-tcl9 * -T -sym-trunk * +P 6e5bb48a74d63fb8c30528f0005d1763cd2dbb882abf86baf1565721e6bfcf84 +R b6fac0aac026b18427ddeec14d1b1b88 U drh -Z 6096f47dfe122296507e83030fc2948d +Z 4e51314270d54eeb39bc75af76080956 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9daced7f7e..f026a787f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6e5bb48a74d63fb8c30528f0005d1763cd2dbb882abf86baf1565721e6bfcf84 +d54ec2de78c2aed12be643e59a30b6827fe4728a0ab6504dd64ee9116e5f885a diff --git a/src/tclsqlite.c b/src/tclsqlite.c index ae3b61c6c3..189446bcae 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -203,6 +203,7 @@ struct IncrblobChannel { sqlite3_blob *pBlob; /* sqlite3 blob handle */ SqliteDb *pDb; /* Associated database connection */ int iSeek; /* Current seek offset */ + int isClosed; /* TCL_CLOSE_READ or TCL_CLOSE_WRITE */ Tcl_Channel channel; /* Channel identifier */ IncrblobChannel *pNext; /* Linked list of all open incrblob channels */ IncrblobChannel *pPrev; /* Linked list of all open incrblob channels */ @@ -242,14 +243,27 @@ static void closeIncrblobChannels(SqliteDb *pDb){ /* ** Close an incremental blob channel. */ -static int SQLITE_TCLAPI incrblobClose( +static int SQLITE_TCLAPI incrblobClose2( ClientData instanceData, - Tcl_Interp *interp + Tcl_Interp *interp, + int flags ){ IncrblobChannel *p = (IncrblobChannel *)instanceData; - int rc = sqlite3_blob_close(p->pBlob); + int rc; sqlite3 *db = p->pDb->db; + if( flags ){ + p->isClosed |= flags; + if( (p->isClosed & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) + != (TCL_CLOSE_READ|TCL_CLOSE_WRITE) ){ + /* Not yet fully closed. Just return. */ + return TCL_OK; + } + } + + /* If we reach this point, then we really do need to close the channel */ + rc = sqlite3_blob_close(p->pBlob); + /* Remove the channel from the SqliteDb.pIncrblob list. */ if( p->pNext ){ p->pNext->pPrev = p->pPrev; @@ -270,6 +284,13 @@ static int SQLITE_TCLAPI incrblobClose( } return TCL_OK; } +static int SQLITE_TCLAPI incrblobClose( + ClientData instanceData, + Tcl_Interp *interp +){ + return incrblobClose2(instanceData, interp, 0); +} + /* ** Read data from an incremental blob channel. @@ -390,7 +411,7 @@ static Tcl_ChannelType IncrblobChannelType = { 0, /* getOptionProc */ incrblobWatch, /* watchProc (this is a no-op) */ incrblobHandle, /* getHandleProc (always returns error) */ - 0, /* close2Proc */ + incrblobClose2, /* close2Proc */ 0, /* blockModeProc */ 0, /* flushProc */ 0, /* handlerProc */ @@ -428,6 +449,7 @@ static int createIncrblobChannel( p = (IncrblobChannel *)Tcl_Alloc(sizeof(IncrblobChannel)); p->iSeek = 0; p->pBlob = pBlob; + if( (flags & TCL_WRITABLE)==0 ) p->isClosed |= TCL_CLOSE_WRITE; sqlite3_snprintf(sizeof(zChannel), zChannel, "incrblob_%d", ++count); p->channel = Tcl_CreateChannel(&IncrblobChannelType, zChannel, p, flags); From 3302bf4dbdda5ba3ccbf3229ecd9e2fec3a6b06e Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Jul 2024 16:59:33 +0000 Subject: [PATCH 0574/1030] Use the SQLite format() function to format floating point values for test results, to avoid inconsistences in TCL versions. FossilOrigin-Name: 6a63c472190dafb36582c116c925bbcbe48c3a2f3217fc1ffcb64a733b0151e1 --- ext/fts5/test/fts5aa.test | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/fts5/test/fts5aa.test b/ext/fts5/test/fts5aa.test index 57f878c7ca..bcad9e7241 100644 --- a/ext/fts5/test/fts5aa.test +++ b/ext/fts5/test/fts5aa.test @@ -453,7 +453,7 @@ db func funk funk # statement no longer fails. # do_catchsql_test 16.2 { - SELECT funk(), bm25(n1), funk() FROM n1 WHERE n1 MATCH 'a+b+c+d' + SELECT funk(), format('%g',bm25(n1)), funk() FROM n1 WHERE n1 MATCH 'a+b+c+d' } {0 {{} -1e-06 {}}} # {1 {SQL logic error}} diff --git a/manifest b/manifest index 6fb17d9191..a37275420c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sincrblob\schannel\sso\sthat\spartial\sclose\sworks\swith\sTcl9. -D 2024-07-30T16:51:51.690 +C Use\sthe\sSQLite\sformat()\sfunction\sto\sformat\sfloating\spoint\svalues\sfor\stest\nresults,\sto\savoid\sinconsistences\sin\sTCL\sversions. +D 2024-07-30T16:59:33.915 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -112,7 +112,7 @@ F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl bc33c6cc65e5d390f28a68aeeb3a526dadd2c3a947d2466ee1986c1a4002df56 -F ext/fts5/test/fts5aa.test 183a2296fc4dab220f935dbb99a81f441bc6b7226fdda268597f755d69e8205b +F ext/fts5/test/fts5aa.test 015c81b84d53bfcedd77d624202c8b02e9f0cbbb4b51688e3a9c9f90bccbb4ac F ext/fts5/test/fts5ab.test 4bdb619fee409e11417e8827e320b857e42e926a01a0408fc9f143ec870a6ced F ext/fts5/test/fts5ac.test 4a73626de86f3d17c95738034880c4f0de8d54741fb943d819b528373657e59b F ext/fts5/test/fts5ad.test 058e616612964e61d19f70295f0e6eaedceb4b29b1fbf4f859615ef7e779dc22 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6e5bb48a74d63fb8c30528f0005d1763cd2dbb882abf86baf1565721e6bfcf84 -R b6fac0aac026b18427ddeec14d1b1b88 +P d54ec2de78c2aed12be643e59a30b6827fe4728a0ab6504dd64ee9116e5f885a +R 7f4866a427091a29b1780632dea5351c U drh -Z 4e51314270d54eeb39bc75af76080956 +Z 73c4c9a57f9fc1f499055df74c59b8ce # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f026a787f1..167a28a68a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d54ec2de78c2aed12be643e59a30b6827fe4728a0ab6504dd64ee9116e5f885a +6a63c472190dafb36582c116c925bbcbe48c3a2f3217fc1ffcb64a733b0151e1 From 780187f090d7da3ec49041ab24fc3363a30cb1b0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Jul 2024 17:09:51 +0000 Subject: [PATCH 0575/1030] Get rid of "-encoding binary" across all test cases, as that is no longer supported in Tcl9. Use "-translation binary" instead. FossilOrigin-Name: e0d9670dd98a22d2e22aac8ba8720787a05e280e18ec9b2d4323f947c83718f5 --- ext/fts5/test/fts5corrupt2.test | 5 +- ext/recover/recovercorrupt4.test | 5 +- ext/recover/recoverpgsz.test | 9 ++-- ext/session/changesetfuzz1.test | 3 +- ext/session/session4.test | 2 +- ext/session/sessiondiff.test | 2 +- manifest | 78 ++++++++++++++++---------------- manifest.uuid | 2 +- test/backcompat.test | 4 +- test/corrupt.test | 2 +- test/corrupt2.test | 18 ++++---- test/corrupt4.test | 2 +- test/corruptK.test | 4 +- test/crash.test | 2 +- test/exclusive2.test | 4 +- test/func6.test | 2 +- test/fuzz3.test | 2 +- test/incrvacuum3.test | 4 +- test/ioerr.test | 2 +- test/ioerr5.test | 4 +- test/memdb1.test | 2 +- test/pendingrace.test | 4 +- test/recover.test | 1 - test/rollback.test | 2 +- test/shell5.test | 2 +- test/shell7.test | 1 - test/superlock.test | 4 +- test/syscall.test | 2 +- test/tester.tcl | 4 +- test/tkt3457.test | 2 +- test/wal.test | 2 +- test/wal_common.tcl | 4 -- test/walcksum.test | 3 -- test/walslow.test | 1 - test/zipfile.test | 2 +- vsixtest/vsixtest.tcl | 4 +- 36 files changed, 91 insertions(+), 105 deletions(-) diff --git a/ext/fts5/test/fts5corrupt2.test b/ext/fts5/test/fts5corrupt2.test index 51141adf0d..6b4d6d411f 100644 --- a/ext/fts5/test/fts5corrupt2.test +++ b/ext/fts5/test/fts5corrupt2.test @@ -100,6 +100,7 @@ set lrowid [db one {SELECT max(rowid) FROM t1_data WHERE (rowid & $mask)=0}] set nbyte [db one {SELECT length(block) FROM t1_data WHERE rowid=$lrowid}] set all [db eval {SELECT rowid FROM t1}] sqlite3_db_config db DEFENSIVE 0 +unset -nocomplain res for {set i [expr $nbyte-2]} {$i>=0} {incr i -1} { do_execsql_test 2.$i.1 { BEGIN; @@ -152,7 +153,7 @@ foreach {tn hdr} { execsql BEGIN set fd [db incrblob main x3_data block $rowid] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary set existing [read $fd [string length $hdr]] seek $fd 0 puts -nonewline $fd $hdr @@ -238,7 +239,7 @@ foreach {tn hdr} { execsql BEGIN set fd [db incrblob main x5_data block $rowid] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary puts -nonewline $fd $hdr close $fd diff --git a/ext/recover/recovercorrupt4.test b/ext/recover/recovercorrupt4.test index 0ff0b502df..25cfb88fa3 100644 --- a/ext/recover/recovercorrupt4.test +++ b/ext/recover/recovercorrupt4.test @@ -34,11 +34,11 @@ if {[permutation]!="inmemory_journal"} { do_test 1.1 { set sz [expr [file size test.db] - 1024] set fd [open test.db] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary set data [read $fd $sz] set fd2 [open test.db2 w] - fconfigure $fd2 -encoding binary -translation binary + fconfigure $fd2 -translation binary puts -nonewline $fd2 $data close $fd2 set {} {} @@ -61,4 +61,3 @@ if {[permutation]!="inmemory_journal"} { } finish_test - diff --git a/ext/recover/recoverpgsz.test b/ext/recover/recoverpgsz.test index 1a91f08459..f921a78692 100644 --- a/ext/recover/recoverpgsz.test +++ b/ext/recover/recoverpgsz.test @@ -39,14 +39,14 @@ foreach {pgsz bOverflow} { set fd [open test.db] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary seek $fd $pgsz set pg1 [read $fd $pgsz] set pg2 [read $fd $pgsz] close $fd set fd2 [open test.db2 w] - fconfigure $fd2 -encoding binary -translation binary + fconfigure $fd2 -translation binary seek $fd2 $pgsz puts -nonewline $fd2 $pg1 close $fd2 @@ -71,7 +71,7 @@ foreach {pgsz bOverflow} { forcedelete test.db2 set fd2 [open test.db2 w] - fconfigure $fd2 -encoding binary -translation binary + fconfigure $fd2 -translation binary seek $fd2 $pgsz puts -nonewline $fd2 $pg2 close $fd2 @@ -95,6 +95,3 @@ foreach {pgsz bOverflow} { finish_test - - - diff --git a/ext/session/changesetfuzz1.test b/ext/session/changesetfuzz1.test index 20f5ac6deb..d77fd53b9a 100644 --- a/ext/session/changesetfuzz1.test +++ b/ext/session/changesetfuzz1.test @@ -27,7 +27,7 @@ if {$CF==""} { proc writefile {zFile data} { set fd [open $zFile w] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary puts -nonewline $fd $data close $fd } @@ -81,4 +81,3 @@ do_test 1.2 { finish_test - diff --git a/ext/session/session4.test b/ext/session/session4.test index de183a69a0..6c5ab5d025 100644 --- a/ext/session/session4.test +++ b/ext/session/session4.test @@ -136,7 +136,7 @@ foreach {tn blob} { do_test 2.$tn { set changeset [binary decode hex $blob] #set fd [open x.change w+] -#fconfigure $fd -encoding binary -translation binary +#fconfigure $fd -translation binary #puts -nonewline $fd $changeset #close $fd list [catch { sqlite3changeset_apply db $changeset xConflict } msg] $msg diff --git a/ext/session/sessiondiff.test b/ext/session/sessiondiff.test index b00af0eb3b..461ce17c9e 100644 --- a/ext/session/sessiondiff.test +++ b/ext/session/sessiondiff.test @@ -47,7 +47,7 @@ proc database_cksum {db1} { proc readfile {filename} { set fd [open $filename] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary set data [read $fd] close $fd set data diff --git a/manifest b/manifest index a37275420c..bc53326724 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sthe\sSQLite\sformat()\sfunction\sto\sformat\sfloating\spoint\svalues\sfor\stest\nresults,\sto\savoid\sinconsistences\sin\sTCL\sversions. -D 2024-07-30T16:59:33.915 +C Get\srid\sof\s"-encoding\sbinary"\sacross\sall\stest\scases,\sas\sthat\sis\sno\slonger\nsupported\sin\sTcl9.\s\sUse\s"-translation\sbinary"\sinstead. +D 2024-07-30T17:09:51.545 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -146,7 +146,7 @@ F ext/fts5/test/fts5contentless3.test 75eaae5ad6b284ee447788943974d323228f27cc35 F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b05ea89964c863833b6eff8 F ext/fts5/test/fts5contentless5.test 40cdcb4fe751672450829c5a96bd32c25fc2f6076279dd2ce5c58ac9a390132a F ext/fts5/test/fts5corrupt.test a9bda1ded5112ebf1ee85c5381bd1fe8974952e2523cede4d5072804d2011503 -F ext/fts5/test/fts5corrupt2.test a524eaa861aebecb33db919f065c8d2212f4871217446db3e5e79c1c4b49c798 +F ext/fts5/test/fts5corrupt2.test 335911e3f68b9625d850325f9e29a128db3f4276a8c9d4e32134580da8f924c4 F ext/fts5/test/fts5corrupt3.test 3cbb18b8970c66ed4d741eb3eecf42c986bd4c430572a5050350a72030de66cf F ext/fts5/test/fts5corrupt4.test dc08d19f5b8943e95a7778a7d8da592042504faf18dd93f68f7d7a0d7d7dd733 F ext/fts5/test/fts5corrupt5.test 11b47126f5772cc37b67e3e8b2ed05895c4d07c05338bc07e4eea225bfe32c76 @@ -488,11 +488,11 @@ F ext/recover/recoverclobber.test 3ba6c0c373c5c63d17e82eced64c05c57ccaf26c1abe1c F ext/recover/recovercorrupt.test 64c081ad1200ae77b447da99eb724785d6bf71715f394543dc7689642e92bf49 F ext/recover/recovercorrupt2.test 1418f1710debc24ff38276cedfcea234beb37a34205708e7e3e6d76cc4a979db F ext/recover/recovercorrupt3.test 2e7b9a1b528ca23ed382cec6f64e3fcbbd0f8e852add7562397fd8df83f335d5 -F ext/recover/recovercorrupt4.test cc4a56086c50fba6a5b20db122a3f220195b3d4f11a86e0858c7f5f5d8ba58d1 +F ext/recover/recovercorrupt4.test 3e2794145dad2517c018cb68b96f59d4d55b18b3d6271e1d37852cfd7a30b50c F ext/recover/recoverfault.test 9d9f88eeb222615a25e7514f234c950d46bee20d24cd8db49d8fff8d650dcfe1 F ext/recover/recoverfault2.test 730e7371bcda769554d15460cb23126abba1be8eca9539ccabf63623e7bb7e09 F ext/recover/recoverold.test 68db3d6f85dd2b98e785b6c4da4f5eea4bbe52ccf6674d9a94c7506dc92596aa -F ext/recover/recoverpgsz.test 3658ab8e68475b1bb87d6af88baa04551c84b73280a566a1be847182410ffc58 +F ext/recover/recoverpgsz.test 88766fcb810e52ee05335c456d4e5fb06d02b73d3ccb48c52bf293434305e2b1 F ext/recover/recoverrowid.test f948bf4024a5f41b0e21b8af80c60564c5b5d78c05a8d64fc00787715ff9f45f F ext/recover/recoverslowidx.test 5205a9742dd9490ee99950dabb622307355ef1662dea6a3a21030057bfd81411 F ext/recover/recoversql.test e66d01f95302a223bcd3fd42b5ee58dc2b53d70afa90b0d00e41e4b8eab20486 @@ -548,11 +548,11 @@ F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F ext/rtree/visual01.txt e9c2564083bcd30ec51b07f881bffbf0e12b50a3f6fced0c222c5c1d2f94ac66 F ext/session/changeset.c 7a1e6a14c7e92d36ca177e92e88b5281acd709f3b726298dc34ec0fb58869cb5 F ext/session/changesetfuzz.c 227076ab0ae4447d742c01ee88a564da6478bbf26b65108bf8fac9cd8b0b24aa -F ext/session/changesetfuzz1.test 2e1b90d888fbf0eea5e1bd2f1e527a48cc85f8e0ff75df1ec4e320b21f580b3a +F ext/session/changesetfuzz1.test 15b629004e58d5ffcc852e6842a603775bb64b1ce51254831f3d12b113b616cd F ext/session/session1.test e94f764fbfb672147c0ef7026b195988133b371dc8cf9e52423eba6cad69717e F ext/session/session2.test ee83bb973b9ce17ccce4db931cdcdae65eb40bbb22089b2fe6aa4f6be3b9303f F ext/session/session3.test 2cc1629cfb880243aec1a7251145e07b78411d851b39b2aa1390704550db8e6a -F ext/session/session4.test 6778997065b44d99c51ff9cece047ff9244a32856b328735ae27ddef68979c40 +F ext/session/session4.test d5a119a42954754ad505be757be5b0e24396e6ca675518af458d5e2c338dd48b F ext/session/session5.test 716bc6fafd625ce60dfa62ae128971628c1a1169 F ext/session/session6.test 35279f2ec45448cd2e24a61688219dc6cf7871757716063acf4a8b5455e1e926 F ext/session/session8.test 326f3273abf9d5d2d7d559eee8f5994c4ea74a5d935562454605e6607ee29904 @@ -572,7 +572,7 @@ F ext/session/sessionat.test 00c8badb35e43a2f12a716d2734a44d614ff62361979b6b8541 F ext/session/sessionbig.test 47c381e7acfabeef17d98519a3080d69151723354d220afa2053852182ca7adf F ext/session/sessionchange.test 77c4702050f24270b58070e2cf01c95c3d232a3ef164b70f31974b386ce69903 F ext/session/sessionconflict.test 8b8cbd98548e2e636ddc17d0986276f60e833fb865617dd4f88ea5bbe3a16b96 -F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec +F ext/session/sessiondiff.test e89f7aedcdd89e5ebac3a455224eb553a171e9586fc3e1e6a7b3388d2648ba8d F ext/session/sessionfault.test 573bf027fb870d57bd4e7cf50822a3e4b17b2b923407438747aaa918dec57a09 F ext/session/sessionfault2.test b0d6a7c1d7398a7e800d84657404909c7d385965ea8576dc79ed344c46fbf41c F ext/session/sessionfault3.test 7c7547202775de268f3fe6f074c4d0d165151829710b4e64f90d4a01645ba9e7 @@ -923,7 +923,7 @@ F test/autovacuum2.test 76f7eb4fe6a6bf6d33a196a7141dba98886d2fb53a268d7feca285d5 F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 F test/avfs.test 76f59743dc1f5fa533840d1818b420fe1ee45e21c0fd6bbac7942ba677903128 F test/avtrans.test b7dc25459ecbd86c6fa9c606ee3068f59d81e225118617dcf2bbb6ded2ade89e -F test/backcompat.test 3e64cedda754c778ef6bbe417b6e7a295e662a4d +F test/backcompat.test f2431465ed668f09fc3f6998e56e893a1506ccea6e8b6f409f085f759f431b48 F test/backup.test 3b08fd4af69f0fa786931103a31f4542b184aba16e239e5f22b18c3c2476697f F test/backup2.test 8facb54df1388419d34b362ab1f7e233310ff3a3af64e8ad5ec47ba3c2bbe5cf F test/backup4.test 8f6fd48e0dfde77b9a3bb26dc471ede3e101df32 @@ -1010,10 +1010,10 @@ F test/conflict.test b705cddf025a675d3c13d62fa78ab1e2696fb8e07a3d7cccce1596ff8b3 F test/conflict2.test 5557909ce683b1073982f5d1b61dfb1d41e369533bfdaf003180c5bc87282dd1 F test/conflict3.test 81865d9599609aca394fb3b9cd5f561d4729ea5b176bece3644f6ecb540f88ac F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4 -F test/corrupt.test d7cb0300e4a297147b6a05e92a1684bc8973635c3bcaa3d66e983c9cbdbf47a3 -F test/corrupt2.test 9745c55b3ff2d84d9b6dc4f7365f91a99e70d90f3127ebc97ff0549c418e4d3d +F test/corrupt.test 54509b182b1927663e0a425b681b0935a08a01b11d8153a4a9545ed36760ebe2 +F test/corrupt2.test 4ce5eadd51baa1aedb48e141dd885d155946f5c3677bb032547e350ce91b17f4 F test/corrupt3.test 6a982535d52c8165654cbc79a043cfd0bf02495a5efbf4754295e056fc548539 -F test/corrupt4.test b5ae41607e8d17d9c1f3e94fdb572ce061ed3beeebdb46fb3a348181b8c8a097 +F test/corrupt4.test 5fa4559bcfd14afbb99670d463546ba75fb4975c710b7f6dfa592ae90471cce7 F test/corrupt5.test 387be3250795e2a86e6234745558b80efb248a357d0cd8e53bce75c7463f545d F test/corrupt6.test fc6a891716139665dae0073b6945e3670bf92568 F test/corrupt7.test ffa86896fe63a3d00b0a131e1e64f402e4da9f7e5d89609d6501c851e511d73a @@ -1029,7 +1029,7 @@ F test/corruptG.test adf79b669cbfd19e28c8191a610d083ae53a6d51 F test/corruptH.test 79801d97ec5c2f9f3c87739aa1ec2eb786f96454 F test/corruptI.test 9d8cbf6214e492abe9e822e759b9751ae336cec0a6fe3ff3b37bfbd8ff9c22ca F test/corruptJ.test 4d5ccc4bf959464229a836d60142831ef76a5aa4 -F test/corruptK.test 5b4212fe346699831c5ad559a62c54e11c0611bdde1ea8423a091f9c01aa32af +F test/corruptK.test ac13504593d89d69690d45479547616ed12644d42b5cb7eeb2e759a76fc23dcb F test/corruptL.test 652fc8ac0763a6fd3eb28b951d481924167b2d9936083bcc68253b2274a0c8fe F test/corruptM.test 7d574320e08c1b36caa3e47262061f186367d593a7e305d35f15289cc2c3e067 F test/corruptN.test 7c099d153a554001b4fb829c799b01f2ea6276cbc32479131e0db0da4efd9cc4 @@ -1037,7 +1037,7 @@ F test/cost.test cc434a026b1e9d0d98137a147e24e5daf1b1ad09e9ff7da63b34c83ddd136d9 F test/count.test cd4bd531066e8d77ef8fe1e3fc8253d042072e117ccab214b290cf83f1602249 F test/countofview.test 4088e461a10ee33e69803c177a69aa1d7bba81a9ffc2df66d76465a22ca7fdfc F test/coveridxscan.test f35c7208dedc4f98e471c569df64c0f95a49f6e072d8dc7c8f99bdee2697de1b -F test/crash.test fb9dc4a02dcba30d4aa5c2c226f98b220b2b959f +F test/crash.test f699152b8ae759bdf1c19c278b135f5d43fa4b6466e63489cd02edbc94aebad0 F test/crash2.test 5b14d4eb58b880e231361d3b609b216acda86651 F test/crash3.test 8f5de9d32ab9ab95475a9efe7f47a940aa889418 F test/crash4.test fe2821baf37168dc59dd733dcf7dba2a401487bc @@ -1116,7 +1116,7 @@ F test/eqp2.test 6e8996148de88f0e7670491e92e712a2920a369b4406f21a27c3c9b6a46b68d F test/errmsg.test eae9f091eb39ce7e20305de45d8e5d115b68fa856fba4ea6757b6ca3705ff7f9 F test/eval.test 73969a2d43a511bf44080c44485a8c4d796b6a4f038d19e491867081155692c0 F test/exclusive.test 7ff63be7503990921838d5c9f77f6e33e68e48ed1a9d48cd28745bf650bf0747 -F test/exclusive2.test 984090e8e9d1b331d2e8111daf6e5d61dda0bef7 +F test/exclusive2.test cd70b1d9c6fffd336f9795b711dcc5d9ceba133ad3f7001da3fda63615bdc91e F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac F test/expr.test 5c06696478212e5a04e04b043f993373f6f8e5ce5a80f5548a84703b123b6caa @@ -1247,14 +1247,14 @@ F test/func2.test 69f6ae3751b4ec765bdc3b803c0a255aa0f693f28f44805bef03e6b4a3fd24 F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5 F test/func5.test 863e6d1bd0013d09c17236f8a13ea34008dd857d87d85a13a673960e4c25d82a -F test/func6.test 9cc9b1f43b435af34fe1416eb1e318c8920448ea7a6962f2121972f5215cb9b0 +F test/func6.test 3bc89ec0f2605736d3a118f43d25ef58115a7db4dba8ae939a363917d815c0bb F test/func7.test adbfc910385a6ffd15dc47be3c619ef070c542fcb7488964badb17b2d9a4d080 F test/func8.test c4e2ecacf9f16e47a245e7a25fbabcc7e78f9c7c41a80f158527cdfdc6dd299d F test/func9.test b32d313f679aa9698d52f39519d301c3941823cb72b4e23406c210eadd82c824 F test/fuzz-oss1.test 514dcabb24687818ea949fa6760229eaacad74ca70157743ef36d35bbe01ffb0 F test/fuzz.test 4608c1310cff4c3014a84bcced6278139743e080046e5f6784b0de7b069371d8 F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 -F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c31 +F test/fuzz3.test 70ba57260364b83e964707b9d4b5625284239768ab907dd387c740c0370ce313 F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2 @@ -1298,7 +1298,7 @@ F test/incrblobfault.test de274b1e329169c2c3438f9528994807ea8201ebf38ae9f157d34b F test/incrcorrupt.test 6c567fbf870aa9e91866fe52ce6f200cd548939a F test/incrvacuum.test 3fa6145f5e71f603554fd7b8ec3da4290b1341029682313285cb5f9e1893d6ba F test/incrvacuum2.test 7d26cfda66c7e55898d196de54ac4ec7d86a4e3d -F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a +F test/incrvacuum3.test 0bf0ffe7f2cbc87ba1d471e4bbadabbf10dacf8d4ee26b3a072708d575d637a9 F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635 F test/index.test d866054c88b394fd42cbf2825628f127ca24dfac525fa019069a936674d92cbe F test/index2.test f835d5e13ca163bd78c4459ca15fd2e4ed487407 @@ -1329,11 +1329,11 @@ F test/interrupt2.test e4408ca770a6feafbadb0801e54a0dcd1a8d108d F test/intpkey.test aee694afed1a65c86c4e69ad030224b3fc268113d00685234d40079fca16bad3 F test/intreal.test 68829a8bb073ee1610ca3f8f9e0f99b0371fb36e0fa64862dd5ced4ef03c2343 F test/io.test f138f3fe696d1ed8c51dfea5b325910d319a1b29e1d25ea57231a02092f02cca -F test/ioerr.test 530d05801ff1b6327018b2e140da34a74effa2773a844ddb8dc79c32e9567318 +F test/ioerr.test c94eef1cd8bfc36f9aa493e41e151e9160281ac8e2d960cc9dcdcc8e6aa99ab3 F test/ioerr2.test 2593563599e2cc6b6b4fcf5878b177bdd5d8df26 F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c -F test/ioerr5.test 2edfa4fb0f896f733071303b42224df8bedd9da4 +F test/ioerr5.test 5984da7bf74b6540aa356f2ab0c6ae68a6d12039a3d798a9ac6a100abc17d520 F test/ioerr6.test a395a6ab144b26a9e3e21059a1ab6a7149cca65b F test/istrue.test e7f285bb70282625c258e866ce6337d4c762922f5a300e1b50f958aef6e7d9c9 F test/join.test f7abfef3faeaf2800308872e33a57e5b6e4a2b44fb8c6b90c6068412e71a6cf4 @@ -1427,7 +1427,7 @@ F test/malloctraceviewer.tcl 3e3ddf11e30d2b20f53aa16aa6615082fb24a100bea61cca721 F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7 -F test/memdb1.test 2fb27d5dadd4e7784d2229e570f6368b059fc0b7fe88ca25e46e17150ba8ad4c +F test/memdb1.test c737ac9aa5895092332b1dde24fae7ae494b7fcbcd346d22d600891096a3836d F test/memdb2.test 4ba1fc09e2f51df80d148a540e4a3fa66d0462e91167b27497084de4d1f6b5b4 F test/memjournal.test 70f3a00c7f84ee2978ad14e831231caa1e7f23915a2c54b4f775a021d5740c6c F test/memjournal2.test dbc2c5cb5f7b38950f4f6dc3e73fcecf0fcbed3fc32c7ce913bba164d288da1e @@ -1507,7 +1507,7 @@ F test/pagesize.test 5769fc62d8c890a83a503f67d47508dfdc543305 F test/parser1.test 6ccdf5e459a5dc4673d3273dc311a7e9742ca952dd0551a6a6320d27035ce4b3 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 -F test/pendingrace.test 6aa33756b950c4529f79c4f3817a9a1e4025bd0d9961571a05c0279bd183d9c6 +F test/pendingrace.test e99efc5ab3584da3dfc8cd6a0ec4e5a42214820574f5ea24ee93f1d84655f463 F test/percentile.test 74e383216a075251512d6ba98beb9dccd6da465e3f73817fc438379e3a628de7 F test/permutations.test 405542f1d659942994a6b38a9e024cf5cfd23eaa68c806aeb24a72d7c9186e80 F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f @@ -1536,7 +1536,7 @@ F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/readonly.test c1985f0b4ab55041f2ba629dadc6578a3ff0f0e5b0ec7912e85c51f49c3e82fe -F test/recover.test 6463509a7404e0c35431dd9b4a1c3b4a29d7a6af8a08462b31670c8a5a616d3a +F test/recover.test a163a156ea9f2beea63fa83c4dcd8dea6e57b8a569fc647155e3d2754eaac1b5 F test/regexp1.test 8f2a8bc1569666e29a4cee6c1a666cd224eb6d50e2470d1dc1df995170f3e0f1 F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed1368b5 F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d @@ -1544,7 +1544,7 @@ F test/resetdb.test 54c06f18bc832ac6d6319e5ab23d5c8dd49fdbeec7c696d791682a8006bd F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/returning1.test 212cd4111bb941a60abf608f20250db666c21eb1bc4d49217e96c87ff3ab9d1a F test/returningfault.test ae4c4b5e8745813287a359d9ccdb9d5c883c2e68afb18fb0767937d5de5692a4 -F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa +F test/rollback.test 952c4d805bca96adc2be76f621ea22115fe40b330015af36fcc8028c8547fcee F test/rollback2.test 3f3a4e20401825017df7e7671e9f31b6de5fae5620c2b9b49917f52f8c160a8f F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/round1.test 29c3c9039936ed024d672f003c4d35ee11c14c0acb75c5f7d6188ff16190cfd4 @@ -1620,9 +1620,9 @@ F test/shell1.test 17a5ca9c6f24f807b2f505b4b38fcbce143d96cd8664c06c34bbbe0672bf7 F test/shell2.test 56da24128304c9ab67da2964cc80beff7b35761c446ec6e6e98bff2775b15026 F test/shell3.test db1953a8e59d08e9240b7cc5948878e184f7eb2623591587f8fd1f1a5bd536d8 F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f807 -F test/shell5.test 6a49440bddc33a132f856fb189e71228f8132963655d12a2c8b8a161263b9632 +F test/shell5.test bafa4c0b67b7a8027e729970a625c9225cb7ef854acc4e52624c45074faaaddf F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bdbb8 -F test/shell7.test 753c6ece5361df50025a50cadf378ea36db9cc05fb23d7a96cff7fa130626ef9 +F test/shell7.test 43fd8e511c533bab5232e95c7b4be93b243451709e89582600d4b6e67693d5c3 F test/shell8.test aea51ecbcd4494c746b096aeff51d841d04d5f0dc4b62eb42427f16109b87acd F test/shell9.test 8742a5b390cdcef6369f5aa223e415aa4255a4129ef249b177887dc635a87209 F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5 @@ -1681,7 +1681,7 @@ F test/subquery2.test 90cf944b9de8204569cf656028391e4af1ccc8c0cc02d4ef38ee3be8de F test/subselect.test 0966aa8e720224dbd6a5e769a3ec2a723e332303 F test/substr.test a673e3763e247e9b5e497a6cacbaf3da2bd8ec8921c0677145c109f2e633f36b F test/subtype1.test 7a9c55ed84d4ce551203d18046f925e293d75f69da81bff71aaf2696e4a2a748 -F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12 +F test/superlock.test 85256830339a6871ce36a2ef591c3f67716a701b5497788fb2068b90159c2442 F test/swarmvtab.test 250231404fcac88f61a6c147bb0e3a118ed879278cd3ccb0ae2d3a729e1e8e26 F test/swarmvtab2.test c948cb2fdfc5b01d85e8f6d6504854202dc1a0782ab2a0ed61538f27cbd0aa5c F test/swarmvtab3.test 41a3ab47cb7a834d4e5336425103b617410a67bb95d335ef536f887587ece073 @@ -1690,7 +1690,7 @@ F test/symlink.test 4368af0e213dd6e726a6240a16f2bb96a5a58f83f2d5d60652f27547b28c F test/symlink2.test 9531f475a53d8781c4f81373f87faf2e2aff4f5fb2102ec6386e0c827916a670 F test/sync.test 89539f4973c010eda5638407e71ca7fddbcd8e0594f4c9980229f804d4333092 F test/sync2.test 8f9f7d4f6d5be8ca8941a8dadcc4299e558cb6a1ff653a9469146c7a76ef2039 -F test/syscall.test a39d9a36f852ae6e4800f861bc2f2e83f68bbc2112d9399931ecfadeabd2d69d +F test/syscall.test a067468b43b8cb2305e9f9fe414e5f40c875bb5d2cba5f00b8154396e95fcf37 F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 F test/tabfunc01.test f150d206294471d20f50029e6b46b76b87a7a010b16dc57eb44245c76dd02802 F test/table.test 7862a00b58b5541511a26757ea9c5c7c3f8298766e98aa099deec703d9c0a8e0 @@ -1704,7 +1704,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d1631311a16 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc -F test/tester.tcl fe617b88c7eb08bdf983d2aaa31c20fbf439eee7b8e0d61ca636fcd0c305bbbf +F test/tester.tcl f16465ee09897fc2bf5ea266146c5f15d507eb2a6a33129cffe135495192a3aa F test/testrunner.tcl 1386667c04207d0a540ce1a9bc5ee0b734f7a3ba856c14a03943fb4f32de55bb F test/testrunner_data.tcl 3d36660cfd55ea5e20e661e8f94c0520feebcb437848f9b98b33c483cc479c0c F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 @@ -1833,7 +1833,7 @@ F test/tkt3357.test 77c37c6482b526fe89941ce951c22d011f5922ed F test/tkt3419.test 1bbf36d7ea03b638c15804251287c2391f5c1f6b F test/tkt3424.test 61f831bd2b071bd128fa5d00fbda57e656ca5812 F test/tkt3442.test c9d95b4c8f4f35a51b523f35d2afd0ce124937812af296545ad551ff763504fd -F test/tkt3457.test 5651e2cbb94645b677ec663160b9e192b87b7d365aecdfb24e19f749575a6fc2 +F test/tkt3457.test 5b9cc2b6cbbf896e9b973db83f6520f43f326f4d08604372a7b0379625e28412 F test/tkt3461.test 228ea328a5a21e8663f80ee3d212a6ad92549a19 F test/tkt3493.test 1686cbde85f8721fc1bdc0ee72f2ef2f63139218 F test/tkt3508.test d75704db9501625c7f7deec119fcaf1696aefb7d @@ -1973,7 +1973,7 @@ F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad F test/vtabdistinct.test 7688f0889358f849fd60bbfde1ded38b014b18066076d4bfbb75395804dfe072 F test/vtabdrop.test 65d4cf6722972e5499bdaf0c0d70ee3b8133944a4e4bc31862563f32a7edca12 F test/vtabrhs1.test 9b5ecbc74a689500c33a4b2b36761f9bcc22fcc4e3f9d21066ee0c9c74cf5f6c -F test/wal.test b7cc6984709f54afbf8441747ced1f646af120bf0c1b1d847bfa39306fbea089 +F test/wal.test 519c550255c78f55959e9159b93ebbfad2b4e9f36f5b76284da41f572f9d27da F test/wal2.test 31f6e2c404b9f2cdf9ca19b105a1742fdc19653c2c936da39e3658c617524046 F test/wal3.test 5de023bb862fd1eb9d2ad26fa8d9c43abb5370582e5b08b2ae0d6f93661bc310 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c @@ -1983,11 +1983,11 @@ F test/wal64k.test 2a525c0f45d709bae3765c71045ccec5df7d100ccbd3a7860fdba46c9addb F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd F test/wal8.test d9df3fba4caad5854ed69ed673c68482514203c8 F test/wal9.test 378e76a9ad09cd9bee06c172ad3547b0129a6750 -F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe +F test/wal_common.tcl 4589f701d5527ace2eba43823c96c2177e1f9dd2a6098256ee2203a0a313c13a F test/walbak.test 018d4e5a3d45c6298d11b99f09a8ef6876527946 F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434 F test/walblock.test be48f3a75eff0b4456209f26b3ce186c2015497d -F test/walcksum.test bb234a1bb42248b3515d992b719708015c384278 +F test/walcksum.test ba02b4fe6d22cb42e57a323003cbae62f77a740983e1355b2b520e019ae261c7 F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36 F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af @@ -2007,7 +2007,7 @@ F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cf F test/walseh1.test bae700eb99519b6d5cd3f893c04759accc5a59c391d4189fe4dd6995a533442b F test/walsetlk.test 34c901443b31ab720afc463f5b236c86ca5c4134402573dce91aa0761de8db5a F test/walshared.test 42e3808582504878af237ea02c42ca793e8a0efaa19df7df26ac573370dbc7a3 -F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f +F test/walslow.test 0c51843836c9dcf40a5ac05aa781bfb977b396ee2c872d92bd48b79d5dd9aa23 F test/walthread.test 14b20fcfa6ae152f5d8e12f5dc8a8a724b7ef189f5d8ef1e2ceab79f2af51747 F test/walvfs.test e1a6ad0f3c78e98b55c3d5f0889cf366cc0d0a1cb2bccb44ac9ec67384adc4a1 F test/where.test 59abb854eee24f166b5f7ba9d17eb250abc59ce0a66c48912ffb10763648196d @@ -2085,7 +2085,7 @@ F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501d F test/zeroblob.test 7b74cefc7b281dfa2b07cd237987fbe94b4a2037a7771e9e83f2d5f608b1d99e F test/zeroblobfault.test 861d8191a0d944dfebb3cb4d2c5b4e46a5a119eaec5a63dd996c2389f8063441 F test/zerodamage.test 9c41628db7e8d9e8a0181e59ea5f189df311a9f6ce99cc376dc461f66db6f8dc -F test/zipfile.test 416adb0ca9bb54f978fe2e77978b1b964ce5e1c0199f45e381caa771e9f8cfc1 +F test/zipfile.test b51e19c3bf19ef62486f275463ac7e83d026bacb1a73c93f53125048b79cd38b F test/zipfile2.test 9903388a602a3834189857a985106ff95c3bba6a3969e0134127df991889db5d F test/zipfilefault.test 44d4d7a7f7cca7521d569d7f71026b241d65a6b1757aa409c1a168827edbbc2c F tool/GetFile.cs 47852aa0d806fe47ed1ac5138bdce7f000fe87aaa7f28107d0cb1e26682aeb44 @@ -2196,12 +2196,12 @@ F vsixtest/Package.appxmanifest 6b6db1eb7df3a315c5d681059754d5f0e0c47a93 F vsixtest/pch.cpp cb823cfac36f1a39a7eb0acbd7e9a0b0de8f23af F vsixtest/pch.h 9cab7980f2ac4baa40807d8b5e52af32a21cf78c F vsixtest/vsixtest.sln 77cadbe4e96c1fe1bf51cd77de9e9b0a12ada547 -F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 +F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080bb302912 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d54ec2de78c2aed12be643e59a30b6827fe4728a0ab6504dd64ee9116e5f885a -R 7f4866a427091a29b1780632dea5351c +P 6a63c472190dafb36582c116c925bbcbe48c3a2f3217fc1ffcb64a733b0151e1 +R 83dca5d41a8135b553aa7f3c66845d1d U drh -Z 73c4c9a57f9fc1f499055df74c59b8ce +Z cf1a87e83e012da81921b4e6790c3e27 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 167a28a68a..31b8990f64 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a63c472190dafb36582c116c925bbcbe48c3a2f3217fc1ffcb64a733b0151e1 +e0d9670dd98a22d2e22aac8ba8720787a05e280e18ec9b2d4323f947c83718f5 diff --git a/test/backcompat.test b/test/backcompat.test index 87ffc4b3ea..d477d4466c 100644 --- a/test/backcompat.test +++ b/test/backcompat.test @@ -112,7 +112,7 @@ proc read_file {zFile} { set zData {} if {[file exists $zFile]} { set fd [open $zFile] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary if {[file size $zFile]<=$::sqlite_pending_byte || $zFile != "test.db"} { set zData [read $fd] @@ -129,7 +129,7 @@ proc read_file {zFile} { } proc write_file {zFile zData} { set fd [open $zFile w] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary puts -nonewline $fd $zData close $fd } diff --git a/test/corrupt.test b/test/corrupt.test index 62ead4d9a7..ff61cc0bbe 100644 --- a/test/corrupt.test +++ b/test/corrupt.test @@ -290,7 +290,7 @@ ifcapable oversize_cell_check { # detecting corruption was not possible at that point, and an assert() failed. # set fd [open test.db r+] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary seek $fd [expr 1024+8] puts -nonewline $fd "\x03\x14" close $fd diff --git a/test/corrupt2.test b/test/corrupt2.test index 2e36cbd301..fc24cb376f 100644 --- a/test/corrupt2.test +++ b/test/corrupt2.test @@ -69,7 +69,7 @@ do_test corrupt2-1.3 { forcedelete corrupt.db-journal forcecopy test.db corrupt.db set f [open corrupt.db RDWR] - fconfigure $f -encoding binary + fconfigure $f -translation binary seek $f 16 start puts -nonewline $f "\x00\xFF" close $f @@ -89,7 +89,7 @@ do_test corrupt2-1.4 { forcedelete corrupt.db-journal forcecopy test.db corrupt.db set f [open corrupt.db RDWR] - fconfigure $f -encoding binary + fconfigure $f -translation binary seek $f 101 start puts -nonewline $f "\xFF\xFF" close $f @@ -109,7 +109,7 @@ do_test corrupt2-1.5 { forcedelete corrupt.db-journal forcecopy test.db corrupt.db set f [open corrupt.db RDWR] - fconfigure $f -encoding binary + fconfigure $f -translation binary seek $f 101 start puts -nonewline $f "\x00\xC8" seek $f 200 start @@ -179,7 +179,7 @@ do_test corrupt2-3.1 { # of the DROP TABLE operation below. # set fd [open corrupt.db r+] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary seek $fd [expr 1024*3 + 12] set zCelloffset [read $fd 2] binary scan $zCelloffset S iCelloffset @@ -227,7 +227,7 @@ do_test corrupt2-5.1 { # This block links a page from table t2 into the t1 table structure. # set fd [open corrupt.db r+] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary seek $fd [expr 1024 + 12] set zCelloffset [read $fd 2] binary scan $zCelloffset S iCelloffset @@ -392,7 +392,7 @@ corruption_test -sqlprep $sqlprep -corrupt { # 0x0D (interpreted by SQLite as "leaf page of a table B-Tree"). # set fd [open corrupt.db r+] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary seek $fd [expr 1024*2 + 8] set zRightChild [read $fd 4] binary scan $zRightChild I iRightChild @@ -410,7 +410,7 @@ corruption_test -sqlprep $sqlprep -corrupt { # The corruption is detected as part of an OP_Prev opcode. # set fd [open corrupt.db r+] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary seek $fd [expr 1024*2 + 12] set zCellOffset [read $fd 2] binary scan $zCellOffset S iCellOffset @@ -431,7 +431,7 @@ corruption_test -sqlprep $sqlprep -corrupt { # 0x0A (interpreted by SQLite as "leaf page of an index B-Tree"). # set fd [open corrupt.db r+] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary seek $fd [expr 1024*1 + 8] set zRightChild [read $fd 4] binary scan $zRightChild I iRightChild @@ -459,7 +459,7 @@ corruption_test -sqlprep { CREATE TABLE x6(a, b, c); CREATE TABLE xD(a, b, c); CREATE TABLE xJ(a, b, c); } -corrupt { set fd [open corrupt.db r+] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary seek $fd 108 set zRightChild [read $fd 4] binary scan $zRightChild I iRightChild diff --git a/test/corrupt4.test b/test/corrupt4.test index 5b0965a836..544ac33053 100644 --- a/test/corrupt4.test +++ b/test/corrupt4.test @@ -122,7 +122,7 @@ proc put4byte {fd offset val} { # the second rightmost child page number of page 1 to 1. # set fd [open test.db r+] -fconfigure $fd -encoding binary -translation binary +fconfigure $fd -translation binary set nChild [get2byte $fd 103] set offChild [get2byte $fd [expr 100+12+($nChild-2)*2]] set pgnoChild [get4byte $fd $offChild] diff --git a/test/corruptK.test b/test/corruptK.test index 1569afe4a8..0bdb3c45b5 100644 --- a/test/corruptK.test +++ b/test/corruptK.test @@ -60,7 +60,7 @@ do_test 1.2 { sqlite3 db test.db set fd [db incrblob t1 x 3] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary seek $fd 30 puts -nonewline $fd "\x18" close $fd @@ -102,7 +102,7 @@ do_test 2.2 { sqlite3 db test.db set fd [db incrblob t1 x 5] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary seek $fd 22 puts -nonewline $fd "\x5d" diff --git a/test/crash.test b/test/crash.test index c1901daec6..f631636599 100644 --- a/test/crash.test +++ b/test/crash.test @@ -399,7 +399,7 @@ do_test crash-7.1 { # Change the checksum value for the master journal name. set f [open test.db-journal a] - fconfigure $f -encoding binary + fconfigure $f -translation binary seek $f [expr [file size test.db-journal] - 12] puts -nonewline $f "\00\00\00\00" close $f diff --git a/test/exclusive2.test b/test/exclusive2.test index 92fcd76ab3..0a5d2b6eb8 100644 --- a/test/exclusive2.test +++ b/test/exclusive2.test @@ -41,7 +41,7 @@ sqlite3_soft_heap_limit 0 proc pagerChangeCounter {filename new {fd ""}} { if {$fd==""} { set fd [open $filename RDWR] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary set needClose 1 } else { set needClose 0 @@ -70,7 +70,7 @@ proc pagerChangeCounter {filename new {fd ""}} { proc readPagerChangeCounter {filename} { set fd [open $filename RDONLY] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary seek $fd 24 foreach {a b c d} [list 0 0 0 0] {} diff --git a/test/func6.test b/test/func6.test index fe90a755d7..acca490f33 100644 --- a/test/func6.test +++ b/test/func6.test @@ -43,7 +43,7 @@ do_execsql_test func6-100 { # string. proc loadhex {file} { set fd [open $file] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary set data [read $fd] close $fd binary encode hex $data diff --git a/test/fuzz3.test b/test/fuzz3.test index bf778ed2bc..8ac1f4d58f 100644 --- a/test/fuzz3.test +++ b/test/fuzz3.test @@ -83,7 +83,7 @@ proc modify_database {iMod} { set offset [expr {$iMod>>8}] set fd [open test.db r+] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary seek $fd $offset set old_blob [read $fd 1] seek $fd $offset diff --git a/test/incrvacuum3.test b/test/incrvacuum3.test index e901bfe1f5..b4cbc8b0c8 100644 --- a/test/incrvacuum3.test +++ b/test/incrvacuum3.test @@ -50,8 +50,8 @@ proc check_on_disk {} { set sz [file size test.db] set fd [open test.db] set fd2 [open test2.db w] - fconfigure $fd -encoding binary -translation binary - fconfigure $fd2 -encoding binary -translation binary + fconfigure $fd -translation binary + fconfigure $fd2 -translation binary if {$sz>$::sqlite_pending_byte} { puts -nonewline $fd2 [read $fd $::sqlite_pending_byte] seek $fd [expr $::sqlite_pending_byte+512] diff --git a/test/ioerr.test b/test/ioerr.test index 29a3dede8a..fb54d8b384 100644 --- a/test/ioerr.test +++ b/test/ioerr.test @@ -225,7 +225,7 @@ if {$tcl_platform(platform)=="unix" && [atomic_batch_write test.db]==0} { } forcecopy test2.db-journal test.db-journal set f [open test.db-journal a] - fconfigure $f -encoding binary + fconfigure $f -translation binary puts -nonewline $f "hello" puts -nonewline $f "\x00\x00\x00\x05\x01\x02\x03\x04" puts -nonewline $f "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7" diff --git a/test/ioerr5.test b/test/ioerr5.test index a430f53407..a0a74bd953 100644 --- a/test/ioerr5.test +++ b/test/ioerr5.test @@ -117,7 +117,7 @@ foreach locking_mode {normal exclusive} { # Read the contents of the database file into a Tcl variable. # set fd [open test.db] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary set zDatabase [read $fd] close $fd @@ -138,7 +138,7 @@ foreach locking_mode {normal exclusive} { # do_test ioerr5-1.$locking_mode-$iFail.4 { set fd [open test.db] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary set zDatabase2 [read $fd] close $fd expr {$zDatabase eq $zDatabase2} diff --git a/test/memdb1.test b/test/memdb1.test index 3a31c8e284..c0510abae7 100644 --- a/test/memdb1.test +++ b/test/memdb1.test @@ -245,7 +245,7 @@ if {[wal_is_capable]} { db close set fd [open test.db] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary set data [read $fd [expr 20*1024]] close $fd diff --git a/test/pendingrace.test b/test/pendingrace.test index ef42578f21..80160149a3 100644 --- a/test/pendingrace.test +++ b/test/pendingrace.test @@ -61,12 +61,12 @@ proc my_db_restore {} { forcecopy sv_test.db-journal test.db-journal set fd1 [open sv_test.db r] - fconfigure $fd1 -encoding binary -translation binary + fconfigure $fd1 -translation binary set data [read $fd1] close $fd1 set fd1 [open test.db w] - fconfigure $fd1 -encoding binary -translation binary + fconfigure $fd1 -translation binary puts -nonewline $fd1 $data close $fd1 } diff --git a/test/recover.test b/test/recover.test index 5495b7a006..268d3a55b0 100644 --- a/test/recover.test +++ b/test/recover.test @@ -43,7 +43,6 @@ proc compare_dbs {db1 db2} { proc recover_with_opts {opts} { set cmd ".recover $opts" set fd [open [list |$::CLI test.db $cmd]] - fconfigure $fd -encoding binary fconfigure $fd -translation binary set sql [read $fd] close $fd diff --git a/test/rollback.test b/test/rollback.test index 423bf20fce..f32ce523e5 100644 --- a/test/rollback.test +++ b/test/rollback.test @@ -111,7 +111,7 @@ if {$tcl_platform(platform) == "unix" ] set iOffset [expr (([file size testA.db-journal] + 511)/512)*512] set fd [open testA.db-journal a+] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary seek $fd $iOffset puts -nonewline $fd $zAppend diff --git a/test/shell5.test b/test/shell5.test index 8727edaafb..31d5449fdc 100644 --- a/test/shell5.test +++ b/test/shell5.test @@ -410,7 +410,7 @@ CREATE TABLE t4(a, b); # do_test shell5-3.1 { set fd [open shell5.csv w] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary puts -nonewline $fd "\"test 1\"\x1F,test 2\r\n\x1E" puts -nonewline $fd "test 3\x1Ftest 4\n" close $fd diff --git a/test/shell7.test b/test/shell7.test index dfd9e47c2d..460789e544 100644 --- a/test/shell7.test +++ b/test/shell7.test @@ -33,7 +33,6 @@ do_execsql_test 1.0 { foreach {tn l x} [db eval { SELECT tn, length(x) AS l, x FROM f1 }] { forcedelete shell7_test.bin set fd [open shell7_test.bin w] - fconfigure $fd -encoding binary fconfigure $fd -translation binary puts -nonewline $fd $x close $fd diff --git a/test/superlock.test b/test/superlock.test index 704b0677a1..10e7caa298 100644 --- a/test/superlock.test +++ b/test/superlock.test @@ -166,7 +166,7 @@ do_multiclient_test tn { proc read_content {file} { if {[file exists $file]==0} {return ""} set fd [open $file] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary set content [read $fd] close $fd return $content @@ -174,7 +174,7 @@ proc read_content {file} { proc write_content {file content} { set fd [open $file w+] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary puts -nonewline $fd $content close $fd } diff --git a/test/syscall.test b/test/syscall.test index 19313a5e67..fe4a4177fe 100644 --- a/test/syscall.test +++ b/test/syscall.test @@ -211,7 +211,7 @@ forcedelete test.db test.db2 proc create_db_file {nByte} { set fd [open test.db w] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary puts -nonewline $fd [string range "xSQLite" 1 $nByte] close $fd } diff --git a/test/tester.tcl b/test/tester.tcl index b96bc505d8..f7f5347f5a 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -897,7 +897,7 @@ proc catchsafecmd {db {cmd ""}} { proc catchcmdex {db {cmd ""}} { global CLI set out [open cmds.txt w] - fconfigure $out -encoding binary -translation binary + fconfigure $out -translation binary puts -nonewline $out $cmd close $out set line "exec -keepnewline -- $CLI $db < cmds.txt" @@ -905,7 +905,7 @@ proc catchcmdex {db {cmd ""}} { foreach chan $chans { catch { set modes($chan) [fconfigure $chan] - fconfigure $chan -encoding binary -translation binary -buffering none + fconfigure $chan -translation binary -buffering none } } set rc [catch { eval $line } msg] diff --git a/test/tkt3457.test b/test/tkt3457.test index 24b4f0eac0..0273494639 100644 --- a/test/tkt3457.test +++ b/test/tkt3457.test @@ -58,7 +58,7 @@ do_test tkt3457-1.1 { # start of the first journal-header has not been written by SQLite. # So write it now. set fd [open bak.db-journal a+] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary seek $fd 0 puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7" close $fd diff --git a/test/wal.test b/test/wal.test index 234668240e..50988debe3 100644 --- a/test/wal.test +++ b/test/wal.test @@ -1219,7 +1219,7 @@ foreach {tn pgsz works} { set framehdr [binary format IIIIII $pg 5 22 23 $c1 $c2] set fd [open test.db-wal w] - fconfigure $fd -encoding binary -translation binary + fconfigure $fd -translation binary puts -nonewline $fd $walhdr puts -nonewline $fd $framehdr puts -nonewline $fd $framebody diff --git a/test/wal_common.tcl b/test/wal_common.tcl index 917ad598f6..cdba53b5b2 100644 --- a/test/wal_common.tcl +++ b/test/wal_common.tcl @@ -65,7 +65,6 @@ proc wal_set_walhdr {filename {intlist {}}} { set fd [open $filename r+] fconfigure $fd -translation binary - fconfigure $fd -encoding binary seek $fd 0 puts -nonewline $fd $blob close $fd @@ -73,7 +72,6 @@ proc wal_set_walhdr {filename {intlist {}}} { set fd [open $filename] fconfigure $fd -translation binary - fconfigure $fd -encoding binary set blob [read $fd 24] close $fd @@ -89,5 +87,3 @@ proc wal_fix_walindex_cksum {hdrvar} { lset hdr 10 $c1 lset hdr 11 $c2 } - - diff --git a/test/walcksum.test b/test/walcksum.test index f3fc427115..10329ba6c8 100644 --- a/test/walcksum.test +++ b/test/walcksum.test @@ -22,7 +22,6 @@ ifcapable !wal {finish_test ; return } # proc readfile {filename} { set fd [open $filename] - fconfigure $fd -encoding binary fconfigure $fd -translation binary set data [read $fd] close $fd @@ -59,7 +58,6 @@ proc log_checksum_write {filename iFrame endian} { set bin [binary format II $c1 $c2] set fd [open $filename r+] - fconfigure $fd -encoding binary fconfigure $fd -translation binary seek $fd $offset puts -nonewline $fd $bin @@ -114,7 +112,6 @@ proc log_checksum_writemagic {filename endian} { set val [expr {0x377f0682 | ($endian == "big" ? 1 : 0)}] set bin [binary format I $val] set fd [open $filename r+] - fconfigure $fd -encoding binary fconfigure $fd -translation binary puts -nonewline $fd $bin diff --git a/test/walslow.test b/test/walslow.test index 2a52a225d8..6a0f147a06 100644 --- a/test/walslow.test +++ b/test/walslow.test @@ -109,7 +109,6 @@ foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} { forcecopy test.db-wal test2.db-wal set fd [open test2.db-wal r+] - fconfigure $fd -encoding binary fconfigure $fd -translation binary seek $fd $iOff diff --git a/test/zipfile.test b/test/zipfile.test index 4d09e08b1c..c406edeec8 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -30,7 +30,7 @@ if {[catch {load_static_extension db fileio} error]} { proc readfile {f} { set fd [open $f] - fconfigure $fd -translation binary -encoding binary + fconfigure $fd -translation binary set data [read $fd] close $fd set data diff --git a/vsixtest/vsixtest.tcl b/vsixtest/vsixtest.tcl index 5dce821dc4..8b2288be35 100644 --- a/vsixtest/vsixtest.tcl +++ b/vsixtest/vsixtest.tcl @@ -132,7 +132,7 @@ proc readFile { fileName } { # may contain binary data. # set file_id [open $fileName RDONLY] - fconfigure $file_id -encoding binary -translation binary + fconfigure $file_id -translation binary set result [read $file_id] close $file_id return $result @@ -144,7 +144,7 @@ proc writeFile { fileName data } { # binary data. # set file_id [open $fileName {WRONLY CREAT TRUNC}] - fconfigure $file_id -encoding binary -translation binary + fconfigure $file_id -translation binary puts -nonewline $file_id $data close $file_id return "" From 1c2ad465c67cc61b93623928fc03bb9e70a01460 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Jul 2024 18:15:59 +0000 Subject: [PATCH 0576/1030] Tcl_ChannelType implementations for Tcl9 apparently require that wideSeekProc be implemented. Also adjust minor test script issues for fts5 tests so that they can be run sequentially and so that they do not depend on the specific floating point output formats generated by Tcl. FossilOrigin-Name: 19fda979c5dc1a385ed3f8ab8df34388c1acfc7ff951fe1b183a79186bd20cdb --- ext/fts5/test/fts5eb.test | 4 ++-- ext/fts5/test/fts5first.test | 1 + ext/fts5/test/fts5integrity.test | 1 + ext/fts5/test/fts5interrupt.test | 2 +- ext/fts5/test/fts5restart.test | 1 + ext/fts5/test/fts5unicode.test | 1 + ext/fts5/test/fts5unicode2.test | 1 + ext/fts5/test/fts5vocab.test | 1 + manifest | 28 ++++++++++++------------- manifest.uuid | 2 +- src/tclsqlite.c | 36 +++++++++++++++++++------------- 11 files changed, 46 insertions(+), 32 deletions(-) diff --git a/ext/fts5/test/fts5eb.test b/ext/fts5/test/fts5eb.test index b704cf4eca..bee9683c3c 100644 --- a/ext/fts5/test/fts5eb.test +++ b/ext/fts5/test/fts5eb.test @@ -86,13 +86,13 @@ do_execsql_test 3.0 { INSERT INTO e1 VALUES ('just a few words with a / inside'); } do_execsql_test 3.1 { - SELECT rowid, bm25(e1) FROM e1 WHERE e1 MATCH '"just"' ORDER BY rank; + SELECT rowid, format('%g',bm25(e1)) FROM e1 WHERE e1 MATCH '"just"' ORDER BY rank; } {1 -1e-06} do_execsql_test 3.2 { SELECT rowid FROM e1 WHERE e1 MATCH '"/" OR "just"' } 1 do_execsql_test 3.3 { - SELECT rowid, bm25(e1) FROM e1 WHERE e1 MATCH '"/" OR "just"' ORDER BY rank; + SELECT rowid, format('%g',bm25(e1)) FROM e1 WHERE e1 MATCH '"/" OR "just"' ORDER BY rank; } {1 -1e-06} do_execsql_test 3.4 " diff --git a/ext/fts5/test/fts5first.test b/ext/fts5/test/fts5first.test index 357672de68..492681eed7 100644 --- a/ext/fts5/test/fts5first.test +++ b/ext/fts5/test/fts5first.test @@ -22,6 +22,7 @@ do_execsql_test 1.0 { CREATE VIRTUAL TABLE x1 USING fts5(a, b); } +unset -nocomplain res foreach {tn expr ok} { 1 {^abc} 1 2 {^abc + def} 1 diff --git a/ext/fts5/test/fts5integrity.test b/ext/fts5/test/fts5integrity.test index d1365a47a1..5c40021803 100644 --- a/ext/fts5/test/fts5integrity.test +++ b/ext/fts5/test/fts5integrity.test @@ -153,6 +153,7 @@ do_execsql_test 5.3 { INSERT INTO gg(gg) VALUES('integrity-check'); } +unset -nocomplain res do_test 5.4.1 { set ok 0 for {set i 0} {$i < 10000} {incr i} { diff --git a/ext/fts5/test/fts5interrupt.test b/ext/fts5/test/fts5interrupt.test index ca682852c4..67ef5f7e97 100644 --- a/ext/fts5/test/fts5interrupt.test +++ b/ext/fts5/test/fts5interrupt.test @@ -33,6 +33,7 @@ proc progress_handler {args} { return 0 } +unset -nocomplain res foreach {tn sql} { 1 { INSERT INTO t1(rowid, a) VALUES(0, 'z z z z') } 2 { COMMIT } @@ -64,4 +65,3 @@ foreach {tn sql} { } finish_test - diff --git a/ext/fts5/test/fts5restart.test b/ext/fts5/test/fts5restart.test index 411433600d..da58fe3aed 100644 --- a/ext/fts5/test/fts5restart.test +++ b/ext/fts5/test/fts5restart.test @@ -29,6 +29,7 @@ do_execsql_test 1.0 { # Run the 'optimize' command. Check that it does not disturb ongoing # full-text queries. # +unset -nocomplain lRowid do_test 1.1 { for {set i 1} {$i < 1000} {incr i} { execsql { INSERT INTO f1 VALUES('a b c d e') } diff --git a/ext/fts5/test/fts5unicode.test b/ext/fts5/test/fts5unicode.test index d7fb9670f0..f10e0d02d8 100644 --- a/ext/fts5/test/fts5unicode.test +++ b/ext/fts5/test/fts5unicode.test @@ -60,6 +60,7 @@ do_execsql_test 2.1 " # require 17 or more bits to store). # +unset -nocomplain A B C D set A [db one {SELECT char(0x1F75E)}] ;# Type So set B [db one {SELECT char(0x1F5FD)}] ;# Type So set C [db one {SELECT char(0x2F802)}] ;# Type Lo diff --git a/ext/fts5/test/fts5unicode2.test b/ext/fts5/test/fts5unicode2.test index 48daf4f100..dccaff0b1c 100644 --- a/ext/fts5/test/fts5unicode2.test +++ b/ext/fts5/test/fts5unicode2.test @@ -116,6 +116,7 @@ set docs [list { connected by OR. }] +unset -nocomplain map set map(a) [list "\u00C4" "\u00E4"] ; # LATIN LETTER A WITH DIAERESIS set map(e) [list "\u00CB" "\u00EB"] ; # LATIN LETTER E WITH DIAERESIS set map(i) [list "\u00CF" "\u00EF"] ; # LATIN LETTER I WITH DIAERESIS diff --git a/ext/fts5/test/fts5vocab.test b/ext/fts5/test/fts5vocab.test index 9e20180c89..b1644527ea 100644 --- a/ext/fts5/test/fts5vocab.test +++ b/ext/fts5/test/fts5vocab.test @@ -513,6 +513,7 @@ do_execsql_test 10.5 { INSERT INTO ft(a) VALUES('4 5 6'); } +unset -nocomplain x res do_test 10.6 { set res [list] db eval { SELECT rowid FROM ft('4') } x { diff --git a/manifest b/manifest index bc53326724..d962fd035b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Get\srid\sof\s"-encoding\sbinary"\sacross\sall\stest\scases,\sas\sthat\sis\sno\slonger\nsupported\sin\sTcl9.\s\sUse\s"-translation\sbinary"\sinstead. -D 2024-07-30T17:09:51.545 +C Tcl_ChannelType\simplementations\sfor\sTcl9\sapparently\srequire\sthat\nwideSeekProc\sbe\simplemented.\s\sAlso\sadjust\sminor\stest\sscript\sissues\sfor\nfts5\stests\sso\sthat\sthey\scan\sbe\srun\ssequentially\sand\sso\sthat\sthey\sdo\snot\ndepend\son\sthe\sspecific\sfloating\spoint\soutput\sformats\sgenerated\sby\sTcl. +D 2024-07-30T18:15:59.082 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -158,7 +158,7 @@ F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3 F ext/fts5/test/fts5dlidx.test a7c42b0a74dc7c8aa1a46d586e0aadda4b6cc42c24450f8d3774b21166e93159 F ext/fts5/test/fts5doclist.test b7cb84758504519746957802db9cd31187bb4e0028b89d9087ba06e26cc4155f F ext/fts5/test/fts5ea.test cefdf66024550fa7920c03395c71ce5046235ed1a1a7a469d79b19e7aad5afb5 -F ext/fts5/test/fts5eb.test a7bd20ef7f5d37defb7eda93c8a7e65cba4a5aae95177df37020adca99600f76 +F ext/fts5/test/fts5eb.test 401f756fdb77083aeba8b696c1e0ad4d834c39dbd6f17e492bb55a2ad64b4296 F ext/fts5/test/fts5fault1.test d28a65caee75db6897c3cf1358c5230d3bb2a3bf7fb31062c19c7e5382b3d2bd F ext/fts5/test/fts5fault2.test 69c8fdbef830cd0d450908d4504d5bb86609e255af99c421c20a0756251fe344 F ext/fts5/test/fts5fault3.test da2f9e3e56ff5740d68ebdd6877c97089e7ed28ddff28a0da87a6afea27e5522 @@ -175,12 +175,12 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5first.test 3fcf2365c00a15fc9704233674789a3b95131d12de18a9b996159f6909dc8079 +F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e F ext/fts5/test/fts5hash.test fd3e0367fbf0b0944d6936fdb22696350f57b9871069c6766251578a103e8a14 -F ext/fts5/test/fts5integrity.test 4c26d4663d002f90388d364a52827ae8729c232fbb6469bff1853b0e64a5c9aa -F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fdde7ea00e78ea283d227 +F ext/fts5/test/fts5integrity.test 646796671205dae46af5bb12a49b5696483cfe8e12d71d21454940b13ace95ab +F ext/fts5/test/fts5interrupt.test 20d04204d3e341b104c0c24a41596b6393a3a81eba1044c168db0e106f9ac92c F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c @@ -209,7 +209,7 @@ F ext/fts5/test/fts5prefix2.test a5bb43b8a2687efafa7ac4e5ccff6812015cf8cf18e3086 F ext/fts5/test/fts5query.test 0320a7a4b58a6e3e50ec8910b301649da90ace675001f9e0bf6392750ad4591d F ext/fts5/test/fts5rank.test 47c1e8e5d84754ff18e012fdd629776088b5a15de41bdd24957581cf084d8a00 F ext/fts5/test/fts5rebuild.test 83e72d77636378833233fadc7cb7517a2fa446ea7d1f94dd526ba3e7e104b9f5 -F ext/fts5/test/fts5restart.test ee7b40ac3f4ea027ea7d5f5422eddbcdaa14944ec4cc5791cfc1b796c71ae2a5 +F ext/fts5/test/fts5restart.test 9af2084b8e065130037b95f05f3f220bb7973903a7701e2c5fb916dff7cf80c5 F ext/fts5/test/fts5rowid.test 8632829fec04996832a4cfb4f0bd89721ba65b7e398c1731741bdb63f070e1a3 F ext/fts5/test/fts5savepoint.test 7f373184cf2d6c1c472d2bc732e1fce62211ffe023f13e381db0f5e4fd06e41d F ext/fts5/test/fts5secure.test a02f771742fb2b1b9bdcb4bf523bcf2d0aa1ff597831d40fe3e72aaa6d0ec40f @@ -234,14 +234,14 @@ F ext/fts5/test/fts5trigram.test 6c4e37864f3e7d90673db5563d9736d7e40080ab94d10eb F ext/fts5/test/fts5trigram2.test c91f0a94f7e1ff859682228646abeab4c0eba2effc46af2cbc8f0f48b05a0566 F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 -F ext/fts5/test/fts5unicode.test 625f4ccd2fc4f480ca7af29349c1dea9d510aaca66bb8ec3aa90593b1e9e885b -F ext/fts5/test/fts5unicode2.test c7f5b338dc40c7f0480a94baf1a6ad0dc55ad7aefe51ba4655ffa9d4cf3dde19 +F ext/fts5/test/fts5unicode.test 41898f7e476e6515cd4b737c02a442cda5a580a74509788aa9072a2074948e0e +F ext/fts5/test/fts5unicode2.test 3ff7ea5d27310d65441779d9919055084cdbb570ed7743af1f8f4eeca1a3be26 F ext/fts5/test/fts5unicode3.test f4891a3dac3b49c3d7c0fdb29566e9eb0ecff35263370c89f9661b1952b20818 F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8df04eff87923c74b4d0 F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e -F ext/fts5/test/fts5vocab.test 03a2e0b7fd6134a33fef7701076d8a3d4971afd324621abdac1c9c4f0019d63f +F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 F ext/fts5/test/fts5vocab2.test bbba149c254375d00055930c1a501c9a51e80b0d20bf7b98f3e9fa3b03786373 F ext/fts5/tool/fts5speed.tcl b0056f91a55b2d1a3684ec05729de92b042e2f85 F ext/fts5/tool/fts5txt2db.tcl c0d43c8590656f8240e622b00957b3a0facc49482411a9fdc2870b45c0c82f9f @@ -768,7 +768,7 @@ F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c e36996d1426c37e314c648b6746c2671a875e1b66e9641ac13b89b16ab8c7ec1 +F src/tclsqlite.c 121754e462f24e1e4f865ea7b21e0a9cae943f7f6dadfe98bae2058e10def813 F src/tclsqlite.h f3dc9ed1464a7cc775a47da70ac6f23e95d0fb939dd7eaf48639778f94d5aaad F src/test1.c 9f01a43b5d9d0c08c31617f3ab4e924bb30cd47db784527dbf6a309456a4db3b F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a63c472190dafb36582c116c925bbcbe48c3a2f3217fc1ffcb64a733b0151e1 -R 83dca5d41a8135b553aa7f3c66845d1d +P e0d9670dd98a22d2e22aac8ba8720787a05e280e18ec9b2d4323f947c83718f5 +R 0516231a2ea9e600f4b16ff82d6015df U drh -Z cf1a87e83e012da81921b4e6790c3e27 +Z 6ecda6df1246f3587330a953d9052353 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 31b8990f64..d78b6c181f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e0d9670dd98a22d2e22aac8ba8720787a05e280e18ec9b2d4323f947c83718f5 +19fda979c5dc1a385ed3f8ab8df34388c1acfc7ff951fe1b183a79186bd20cdb diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 189446bcae..b86200bfa2 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -202,8 +202,8 @@ struct SqliteDb { struct IncrblobChannel { sqlite3_blob *pBlob; /* sqlite3 blob handle */ SqliteDb *pDb; /* Associated database connection */ - int iSeek; /* Current seek offset */ - int isClosed; /* TCL_CLOSE_READ or TCL_CLOSE_WRITE */ + sqlite3_int64 iSeek; /* Current seek offset */ + unsigned int isClosed; /* TCL_CLOSE_READ or TCL_CLOSE_WRITE */ Tcl_Channel channel; /* Channel identifier */ IncrblobChannel *pNext; /* Linked list of all open incrblob channels */ IncrblobChannel *pPrev; /* Linked list of all open incrblob channels */ @@ -302,9 +302,9 @@ static int SQLITE_TCLAPI incrblobInput( int *errorCodePtr ){ IncrblobChannel *p = (IncrblobChannel *)instanceData; - int nRead = bufSize; /* Number of bytes to read */ - int nBlob; /* Total size of the blob */ - int rc; /* sqlite error code */ + sqlite3_int64 nRead = bufSize; /* Number of bytes to read */ + sqlite3_int64 nBlob; /* Total size of the blob */ + int rc; /* sqlite error code */ nBlob = sqlite3_blob_bytes(p->pBlob); if( (p->iSeek+nRead)>nBlob ){ @@ -314,7 +314,7 @@ static int SQLITE_TCLAPI incrblobInput( return 0; } - rc = sqlite3_blob_read(p->pBlob, (void *)buf, nRead, p->iSeek); + rc = sqlite3_blob_read(p->pBlob, (void *)buf, (int)nRead, (int)p->iSeek); if( rc!=SQLITE_OK ){ *errorCodePtr = rc; return -1; @@ -334,9 +334,9 @@ static int SQLITE_TCLAPI incrblobOutput( int *errorCodePtr ){ IncrblobChannel *p = (IncrblobChannel *)instanceData; - int nWrite = toWrite; /* Number of bytes to write */ - int nBlob; /* Total size of the blob */ - int rc; /* sqlite error code */ + sqlite3_int64 nWrite = toWrite; /* Number of bytes to write */ + sqlite3_int64 nBlob; /* Total size of the blob */ + int rc; /* sqlite error code */ nBlob = sqlite3_blob_bytes(p->pBlob); if( (p->iSeek+nWrite)>nBlob ){ @@ -347,7 +347,7 @@ static int SQLITE_TCLAPI incrblobOutput( return 0; } - rc = sqlite3_blob_write(p->pBlob, (void *)buf, nWrite, p->iSeek); + rc = sqlite3_blob_write(p->pBlob, (void*)buf,(int)nWrite, (int)p->iSeek); if( rc!=SQLITE_OK ){ *errorCodePtr = EIO; return -1; @@ -360,9 +360,9 @@ static int SQLITE_TCLAPI incrblobOutput( /* ** Seek an incremental blob channel. */ -static int SQLITE_TCLAPI incrblobSeek( +static long long SQLITE_TCLAPI incrblobWideSeek( ClientData instanceData, - long offset, + long long offset, int seekMode, int *errorCodePtr ){ @@ -384,6 +384,14 @@ static int SQLITE_TCLAPI incrblobSeek( return p->iSeek; } +static int SQLITE_TCLAPI incrblobSeek( + ClientData instanceData, + long offset, + int seekMode, + int *errorCodePtr +){ + return incrblobWideSeek(instanceData,offset,seekMode,errorCodePtr); +} static void SQLITE_TCLAPI incrblobWatch( @@ -415,7 +423,7 @@ static Tcl_ChannelType IncrblobChannelType = { 0, /* blockModeProc */ 0, /* flushProc */ 0, /* handlerProc */ - 0, /* wideSeekProc */ + incrblobWideSeek, /* wideSeekProc */ }; /* @@ -447,7 +455,7 @@ static int createIncrblobChannel( } p = (IncrblobChannel *)Tcl_Alloc(sizeof(IncrblobChannel)); - p->iSeek = 0; + memset(p, 0, sizeof(*p)); p->pBlob = pBlob; if( (flags & TCL_WRITABLE)==0 ) p->isClosed |= TCL_CLOSE_WRITE; From 15669d302d20eed5fded80ffd6c3b27b65384725 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Jul 2024 18:42:31 +0000 Subject: [PATCH 0577/1030] Adjustments to test cases for session so that they work with Tcl9. FossilOrigin-Name: d417415b967e62d41667e14ebf5455932ebf38d218a941f13878f0aba6d19bc8 --- ext/session/session4.test | 5 ++++- ext/session/sessionfault.test | 1 + manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ext/session/session4.test b/ext/session/session4.test index 6c5ab5d025..55cb76f153 100644 --- a/ext/session/session4.test +++ b/ext/session/session4.test @@ -11,7 +11,10 @@ # This file implements regression tests for the session module. # -package require Tcl 8.6 +if {$tcl_version<8.6} { + puts "This module requires Tcl 8.6 or later" + return +} if {![info exists testdir]} { set testdir [file join [file dirname [info script]] .. .. test] diff --git a/ext/session/sessionfault.test b/ext/session/sessionfault.test index 96e966b41d..9c1b2b9996 100644 --- a/ext/session/sessionfault.test +++ b/ext/session/sessionfault.test @@ -367,6 +367,7 @@ do_execsql_test 7.prep1 { } faultsim_save_and_close +unset -nocomplain res set res [list] for {set ::i 0} {$::i < 480} {incr ::i 4} { lappend res "INSERT t1 0 X. {} {i $::i i $::i}" diff --git a/manifest b/manifest index d962fd035b..b611dc3220 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tcl_ChannelType\simplementations\sfor\sTcl9\sapparently\srequire\sthat\nwideSeekProc\sbe\simplemented.\s\sAlso\sadjust\sminor\stest\sscript\sissues\sfor\nfts5\stests\sso\sthat\sthey\scan\sbe\srun\ssequentially\sand\sso\sthat\sthey\sdo\snot\ndepend\son\sthe\sspecific\sfloating\spoint\soutput\sformats\sgenerated\sby\sTcl. -D 2024-07-30T18:15:59.082 +C Adjustments\sto\stest\scases\sfor\ssession\sso\sthat\sthey\swork\swith\sTcl9. +D 2024-07-30T18:42:31.471 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -552,7 +552,7 @@ F ext/session/changesetfuzz1.test 15b629004e58d5ffcc852e6842a603775bb64b1ce51254 F ext/session/session1.test e94f764fbfb672147c0ef7026b195988133b371dc8cf9e52423eba6cad69717e F ext/session/session2.test ee83bb973b9ce17ccce4db931cdcdae65eb40bbb22089b2fe6aa4f6be3b9303f F ext/session/session3.test 2cc1629cfb880243aec1a7251145e07b78411d851b39b2aa1390704550db8e6a -F ext/session/session4.test d5a119a42954754ad505be757be5b0e24396e6ca675518af458d5e2c338dd48b +F ext/session/session4.test 823f6f018fcbb8dacf61e2960f8b3b848d492b094f8b495eae1d9407d9ab7219 F ext/session/session5.test 716bc6fafd625ce60dfa62ae128971628c1a1169 F ext/session/session6.test 35279f2ec45448cd2e24a61688219dc6cf7871757716063acf4a8b5455e1e926 F ext/session/session8.test 326f3273abf9d5d2d7d559eee8f5994c4ea74a5d935562454605e6607ee29904 @@ -573,7 +573,7 @@ F ext/session/sessionbig.test 47c381e7acfabeef17d98519a3080d69151723354d220afa20 F ext/session/sessionchange.test 77c4702050f24270b58070e2cf01c95c3d232a3ef164b70f31974b386ce69903 F ext/session/sessionconflict.test 8b8cbd98548e2e636ddc17d0986276f60e833fb865617dd4f88ea5bbe3a16b96 F ext/session/sessiondiff.test e89f7aedcdd89e5ebac3a455224eb553a171e9586fc3e1e6a7b3388d2648ba8d -F ext/session/sessionfault.test 573bf027fb870d57bd4e7cf50822a3e4b17b2b923407438747aaa918dec57a09 +F ext/session/sessionfault.test c2b43d01213b389a3f518e90775fca2120812ba51e50444c4066962263e45c11 F ext/session/sessionfault2.test b0d6a7c1d7398a7e800d84657404909c7d385965ea8576dc79ed344c46fbf41c F ext/session/sessionfault3.test 7c7547202775de268f3fe6f074c4d0d165151829710b4e64f90d4a01645ba9e7 F ext/session/sessioninvert.test 04075517a9497a80d39c495ba6b44f3982c7371129b89e2c52219819bc105a25 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e0d9670dd98a22d2e22aac8ba8720787a05e280e18ec9b2d4323f947c83718f5 -R 0516231a2ea9e600f4b16ff82d6015df +P 19fda979c5dc1a385ed3f8ab8df34388c1acfc7ff951fe1b183a79186bd20cdb +R a643402027c268eb90fce274177b0fb0 U drh -Z 6ecda6df1246f3587330a953d9052353 +Z f9db89498774d5b3d5a43bfc1584031f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d78b6c181f..dd7cf5f9ba 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19fda979c5dc1a385ed3f8ab8df34388c1acfc7ff951fe1b183a79186bd20cdb +d417415b967e62d41667e14ebf5455932ebf38d218a941f13878f0aba6d19bc8 From a28a784ef469a483aa2ff2ee3325a1d4966f01df Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Jul 2024 18:49:20 +0000 Subject: [PATCH 0578/1030] More adjustments to the incrblob channel: Apparently you need to wait until the close2Proc is called with a flag of 0 before actually shutting down the channel. FossilOrigin-Name: fa549a5507b5f805b469b4360c11155aa9d22043f01f6d9428bf44d0f2351eb0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tclsqlite.c | 6 +----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index b611dc3220..aa3e75d2c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjustments\sto\stest\scases\sfor\ssession\sso\sthat\sthey\swork\swith\sTcl9. -D 2024-07-30T18:42:31.471 +C More\sadjustments\sto\sthe\sincrblob\schannel:\s\sApparently\syou\sneed\sto\swait\nuntil\sthe\sclose2Proc\sis\scalled\swith\sa\sflag\sof\s0\sbefore\sactually\sshutting\ndown\sthe\schannel. +D 2024-07-30T18:49:20.607 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -768,7 +768,7 @@ F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c 121754e462f24e1e4f865ea7b21e0a9cae943f7f6dadfe98bae2058e10def813 +F src/tclsqlite.c 671206cdad1ebc93d0e5db94c91a23d342d3906cb2a7ef25ceac44a2ca0cdc67 F src/tclsqlite.h f3dc9ed1464a7cc775a47da70ac6f23e95d0fb939dd7eaf48639778f94d5aaad F src/test1.c 9f01a43b5d9d0c08c31617f3ab4e924bb30cd47db784527dbf6a309456a4db3b F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 19fda979c5dc1a385ed3f8ab8df34388c1acfc7ff951fe1b183a79186bd20cdb -R a643402027c268eb90fce274177b0fb0 +P d417415b967e62d41667e14ebf5455932ebf38d218a941f13878f0aba6d19bc8 +R 94e782c05e2c9cf245122cb0fc8c093c U drh -Z f9db89498774d5b3d5a43bfc1584031f +Z eacf65a6bef4c82f39e33d70e480d0fd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dd7cf5f9ba..7865e00a79 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d417415b967e62d41667e14ebf5455932ebf38d218a941f13878f0aba6d19bc8 +fa549a5507b5f805b469b4360c11155aa9d22043f01f6d9428bf44d0f2351eb0 diff --git a/src/tclsqlite.c b/src/tclsqlite.c index b86200bfa2..76e6701603 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -254,11 +254,7 @@ static int SQLITE_TCLAPI incrblobClose2( if( flags ){ p->isClosed |= flags; - if( (p->isClosed & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) - != (TCL_CLOSE_READ|TCL_CLOSE_WRITE) ){ - /* Not yet fully closed. Just return. */ - return TCL_OK; - } + return TCL_OK; } /* If we reach this point, then we really do need to close the channel */ From 262addd9ab8213c14859335708eb645e1aec609f Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Jul 2024 20:39:05 +0000 Subject: [PATCH 0579/1030] All tests in "make test" now pass with Tcl9, except for about 198 cases where the error involves small differences in the rendering to floating point values. FossilOrigin-Name: 8e27f5326c69aa4fb6f3f1f42668ab1b08140ab0a614ac4a9d94679c8fb9734e --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- test/tkt-2d1a5c67d.test | 1 + test/types3.test | 5 ++--- test/wal2.test | 6 +++++- test/zipfile.test | 5 ++++- test/zipfile2.test | 5 ++++- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index aa3e75d2c1..41a530ae7e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\sadjustments\sto\sthe\sincrblob\schannel:\s\sApparently\syou\sneed\sto\swait\nuntil\sthe\sclose2Proc\sis\scalled\swith\sa\sflag\sof\s0\sbefore\sactually\sshutting\ndown\sthe\schannel. -D 2024-07-30T18:49:20.607 +C All\stests\sin\s"make\stest"\snow\spass\swith\sTcl9,\sexcept\sfor\sabout\s198\scases\swhere\nthe\serror\sinvolves\ssmall\sdifferences\sin\sthe\srendering\sto\sfloating\spoint\nvalues. +D 2024-07-30T20:39:05.717 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1727,7 +1727,7 @@ F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c F test/tkt-18458b1a.test 6a62cb1ee50fa3c620da59e3a6f531eb38fceaf7e2166203816b724524e6f1d6 F test/tkt-26ff0c2d1e.test c15bec890c4d226c0da2f35ff30f9e84c169cfef90e73a8cb5cec11d723dfa96 F test/tkt-2a5629202f.test 0521bd25658428baa26665aa53ffed9367d33af2 -F test/tkt-2d1a5c67d.test f143872a2102c62e777be3486b38ac2744c18ece31585ed3d0afcb573ca3b4f5 +F test/tkt-2d1a5c67d.test 92bf2a2de5757d2d24ef554f8a6a38476a6735074e32dc28c775b5b9a23f96a3 F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28 F test/tkt-31338dca7e.test 6fb8807851964da0d24e942f2e19c7c705b9fb58 F test/tkt-313723c356.test 4b306ad45c736cedf2f5221f6155b92143244b6d @@ -1902,7 +1902,7 @@ F test/tt3_stress.c f9a769ca8b026ecc76ee93ca8c9700a5619f8e51c581107c4053ba6ac97f F test/tt3_vacuum.c 71b254cde1fc49d6c8c44efd54f4668f3e57d7b3a8f4601ade069f75a999ba39 F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff F test/types2.test 1aeb81976841a91eef292723649b5c4fe3bc3cac -F test/types3.test c9db8f9e80309edfa4252585cf16bcab7ed31f39eeb904d21e831199a3613fb0 +F test/types3.test c60e89c4d6babe44b23a2ea0090f3044e549403b20648b1c6bb65a69fea5f1ed F test/unhex.test b7f1b806207cb77fa31c3e434fe92fba524464e3e9356809bfcc28f15af1a8b7 F test/unionall.test 04d30726c5056f84f92b3a12bf8d8a1dbbe807d1ddc8af95def09e6ef2dd91e3 F test/unionall2.test 71e8fa08d5699d50dc9f9dc0c9799c2e7a6bb7931a330d369307a4df7f157fa1 @@ -1974,7 +1974,7 @@ F test/vtabdistinct.test 7688f0889358f849fd60bbfde1ded38b014b18066076d4bfbb75395 F test/vtabdrop.test 65d4cf6722972e5499bdaf0c0d70ee3b8133944a4e4bc31862563f32a7edca12 F test/vtabrhs1.test 9b5ecbc74a689500c33a4b2b36761f9bcc22fcc4e3f9d21066ee0c9c74cf5f6c F test/wal.test 519c550255c78f55959e9159b93ebbfad2b4e9f36f5b76284da41f572f9d27da -F test/wal2.test 31f6e2c404b9f2cdf9ca19b105a1742fdc19653c2c936da39e3658c617524046 +F test/wal2.test 44fe1cb4935dbbddfa0a34c2c4fd90f0ba8654d59b83c4136eb90fb327fd264f F test/wal3.test 5de023bb862fd1eb9d2ad26fa8d9c43abb5370582e5b08b2ae0d6f93661bc310 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c F test/wal5.test 9c11da7aeccd83a46d79a556ad11a18d3cb15aa9 @@ -2085,8 +2085,8 @@ F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501d F test/zeroblob.test 7b74cefc7b281dfa2b07cd237987fbe94b4a2037a7771e9e83f2d5f608b1d99e F test/zeroblobfault.test 861d8191a0d944dfebb3cb4d2c5b4e46a5a119eaec5a63dd996c2389f8063441 F test/zerodamage.test 9c41628db7e8d9e8a0181e59ea5f189df311a9f6ce99cc376dc461f66db6f8dc -F test/zipfile.test b51e19c3bf19ef62486f275463ac7e83d026bacb1a73c93f53125048b79cd38b -F test/zipfile2.test 9903388a602a3834189857a985106ff95c3bba6a3969e0134127df991889db5d +F test/zipfile.test a36327c5697a03150a313ba06ab45842facef8b0c21be19d73a3a4fee58bc54c +F test/zipfile2.test 6df5f5ef9d247756f7200066f43e7f3f52cffff47f0c02cbefe4ce9c3284cb10 F test/zipfilefault.test 44d4d7a7f7cca7521d569d7f71026b241d65a6b1757aa409c1a168827edbbc2c F tool/GetFile.cs 47852aa0d806fe47ed1ac5138bdce7f000fe87aaa7f28107d0cb1e26682aeb44 F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e04534bbf @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d417415b967e62d41667e14ebf5455932ebf38d218a941f13878f0aba6d19bc8 -R 94e782c05e2c9cf245122cb0fc8c093c +P fa549a5507b5f805b469b4360c11155aa9d22043f01f6d9428bf44d0f2351eb0 +R b16c3971e6beab65b3114759a6ea073a U drh -Z eacf65a6bef4c82f39e33d70e480d0fd +Z b90cc1cc87390ce48c689e5c22b10880 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7865e00a79..aa4cf748eb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa549a5507b5f805b469b4360c11155aa9d22043f01f6d9428bf44d0f2351eb0 +8e27f5326c69aa4fb6f3f1f42668ab1b08140ab0a614ac4a9d94679c8fb9734e diff --git a/test/tkt-2d1a5c67d.test b/test/tkt-2d1a5c67d.test index 1f797686bf..5dad781692 100644 --- a/test/tkt-2d1a5c67d.test +++ b/test/tkt-2d1a5c67d.test @@ -102,6 +102,7 @@ do_test 3.4 { set blobs [list] for {set i 1} {$i<100} {incr i} { set b [db incrblob -readonly t3 b $i] + fconfigure $b -translation binary read $b lappend blobs $b } diff --git a/test/types3.test b/test/types3.test index 0ff346ce28..457ee6d68a 100644 --- a/test/types3.test +++ b/test/types3.test @@ -18,10 +18,9 @@ source $testdir/tester.tcl # A variable with only a string representation comes in as TEXT do_test types3-1.1 { - set V {} - append V x + set V [format %s xxxxx] concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] -} {string text} +} {text} # A variable with an integer representation comes in as INTEGER do_test types3-1.2 { diff --git a/test/wal2.test b/test/wal2.test index ae6134d8b5..5e4c4ebc27 100644 --- a/test/wal2.test +++ b/test/wal2.test @@ -1098,7 +1098,11 @@ if {$::tcl_platform(platform) == "unix"} { 3 00600 4 00755 } { - set effective [format %.5o [expr $permissions & ~$umask]] + if {$tcl_version>=9.0} { + set effective [format %.5d [expr $permissions & ~$umask]] + } else { + set effective [format %.5o [expr $permissions & ~$umask]] + } do_test wal2-12.2.$tn.1 { file attributes test.db -permissions $permissions string map {o 0} [file attributes test.db -permissions] diff --git a/test/zipfile.test b/test/zipfile.test index c406edeec8..0f854a6768 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -10,7 +10,10 @@ #*********************************************************************** # -package require Tcl 8.6 +if {$tcl_version<8.6} { + puts "Requires TCL 8.6 or later" + return +} set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/zipfile2.test b/test/zipfile2.test index 987e4f0cfd..5277cd58f8 100644 --- a/test/zipfile2.test +++ b/test/zipfile2.test @@ -10,7 +10,10 @@ #*********************************************************************** # -package require Tcl 8.6 +if {$tcl_version<8.6} { + puts "Requires TCL 8.6 or later" + return +} set testdir [file dirname $argv0] source $testdir/tester.tcl From 9015b8822df620e23ca692d6dfbad3825aac14b2 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 30 Jul 2024 20:39:58 +0000 Subject: [PATCH 0580/1030] Fix cases surrounding blob values being stored in locale=1 fts5 tables. FossilOrigin-Name: ae435aff1785d5832821c19dc88ccf6c496a7ff55be80276b31e5c9abee723db --- ext/fts5/fts5Int.h | 2 + ext/fts5/fts5_main.c | 90 +++++++++++++++++++++++++++-------- ext/fts5/fts5_storage.c | 35 ++++++++++---- ext/fts5/test/fts5blob.test | 77 ++++++++++++++++++++++++++++++ ext/fts5/test/fts5locale.test | 13 +++++ manifest | 19 ++++---- manifest.uuid | 2 +- 7 files changed, 197 insertions(+), 41 deletions(-) create mode 100644 ext/fts5/test/fts5blob.test diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 1cc25ae7e0..14140658b2 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -228,6 +228,8 @@ struct Fts5Config { char *zContentExprlist; Fts5TokenizerConfig t; int bLock; /* True when table is preparing statement */ + int eEnc; /* An FTS5_ENCODING_XXX constant */ + /* Values loaded from the %_config table */ int iVersion; /* fts5 file format 'version' */ diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index b57864d8b0..673a44d139 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -118,12 +118,16 @@ struct Fts5FullTable { Fts5Global *pGlobal; /* Global (connection wide) data */ Fts5Cursor *pSortCsr; /* Sort data from this cursor */ int iSavepoint; /* Successful xSavepoint()+1 */ - + #ifdef SQLITE_DEBUG struct Fts5TransactionState ts; #endif }; +#define FTS5_ENCODING_UNKNOWN 0 +#define FTS5_ENCODING_UTF8 1 +#define FTS5_ENCODING_UTF16 2 + struct Fts5MatchPhrase { Fts5Buffer *pPoslist; /* Pointer to current poslist */ int nTerm; /* Size of phrase in terms */ @@ -1252,6 +1256,30 @@ void sqlite3Fts5ClearLocale(Fts5Config *pConfig){ fts5SetLocale(pConfig, 0, 0); } +static int fts5IsUtf16(Fts5Config *pConfig, int *pbIs){ + if( pConfig->eEnc==FTS5_ENCODING_UNKNOWN ){ + sqlite3_stmt *pPragma = 0; + int rc = fts5PrepareStatement(&pPragma, pConfig, + "SELECT (encoding LIKE '%%16%%') FROM pragma_encoding" + ); + if( rc==SQLITE_OK ){ + int val; + sqlite3_step(pPragma); + val = sqlite3_column_int(pPragma, 0); + rc = sqlite3_finalize(pPragma); + if( rc!=SQLITE_OK ) return rc; + if( val ){ + pConfig->eEnc = FTS5_ENCODING_UTF16; + }else{ + pConfig->eEnc = FTS5_ENCODING_UTF8; + } + } + } + + *pbIs = (pConfig->eEnc==FTS5_ENCODING_UTF16); + return SQLITE_OK; +} + int sqlite3Fts5ExtractText( Fts5Config *pConfig, int bContent, @@ -1280,17 +1308,33 @@ int sqlite3Fts5ExtractText( int nBlob = sqlite3_value_bytes(pVal); int nLocale = 0; - for(nLocale=0; nLocale=4 && memcmp(pBlob, "\0\0\0\0", 4)==0 ){ + int bIs16 = 0; + pText = (const char*)sqlite3_value_text(pVal); + nText = sqlite3_value_bytes(pVal); + rc = fts5IsUtf16(pConfig, &bIs16); + + if( bIs16 ){ + pText += 2; + nText -= 2; + }else{ + pText += 4; + nText -= 4; + } + + }else{ + for(nLocale=0; nLocalepSavedRow ){ pVal = sqlite3_column_value(p->pSavedRow, i-1); - }else if( i>1 && pConfig->abUnindexed[i-2] - && pConfig->bLocale - && sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE - ){ - /* At attempt to insert an fts5_locale() value into an UNINDEXED - ** column. Strip the locale away and just bind the text. */ - const char *pText = 0; - int nText = 0; - rc = sqlite3Fts5ExtractText(pConfig, 0, pVal, 0, &pText, &nText); - sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); + }else if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE ){ + if( pConfig->bLocale==0 ){ + sqlite3Fts5ConfigErrmsg(pConfig, + "fts5_locale() may not be used without locale=1" + ); + rc = SQLITE_ERROR; + break; + }else if( i>1 && pConfig->abUnindexed[i-2] ){ + /* At attempt to insert an fts5_locale() value into an UNINDEXED + ** column. Strip the locale away and just bind the text. */ + const char *pText = 0; + int nText = 0; + rc = sqlite3Fts5ExtractText(pConfig, 0, pVal, 0, &pText, &nText); + sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); + continue; + } + }else if( pConfig->bLocale && sqlite3_value_type(pVal)==SQLITE_BLOB ){ + /* Inserting a blob into a normal content table with locale=1. */ + int n = sqlite3_value_bytes(pVal); + u8 *pBlob = sqlite3Fts5MallocZero(&rc, n+4); + if( pBlob ){ + memcpy(&pBlob[4], sqlite3_value_blob(pVal), n); + rc = sqlite3_bind_blob(pInsert, i, pBlob, n+4, SQLITE_TRANSIENT); + sqlite3_free(pBlob); + } continue; } diff --git a/ext/fts5/test/fts5blob.test b/ext/fts5/test/fts5blob.test new file mode 100644 index 0000000000..9c838b75a6 --- /dev/null +++ b/ext/fts5/test/fts5blob.test @@ -0,0 +1,77 @@ +# 2024 July 30 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5blob + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +foreach {tn enc locale} { + 1 utf8 0 + 2 utf8 1 + 3 utf16 0 + 4 utf16 1 +} { + reset_db + fts5_aux_test_functions db + + execsql "PRAGMA encoding = $enc" + + if {$tn==3 || $tn==4} breakpoint + + execsql " + CREATE VIRTUAL TABLE t1 USING fts5(x, y, locale=$locale); + " + do_execsql_test 1.$tn.0 { + CREATE VIRTUAL TABLE tt USING fts5vocab('t1', 'instance'); + INSERT INTO t1(rowid, x, y) VALUES(1, 555, X'0000000041424320444546'); + INSERT INTO t1(rowid, x, y) VALUES(2, 666, X'41424300444546'); + INSERT INTO t1(rowid, x, y) VALUES(3, 777, 'xyz'); + } + + do_execsql_test 1.$tn.1 { + SELECT rowid, quote(x), quote(y) FROM t1 + } { + 1 555 X'0000000041424320444546' + 2 666 X'41424300444546' + 3 777 'xyz' + } + + set T($enc,$locale) [execsql { SELECT * FROM tt }] + set U($enc,$locale) [execsql { SELECT fts5_test_columntext(t1) FROM t1 }] + + do_execsql_test 1.$tn.2 { + DELETE FROM t1 WHERE rowid=2; + DELETE FROM t1 WHERE rowid=1; + } + + do_execsql_test 1.$tn.3 { + PRAGMA integrity_check; + } {ok} +} + +do_test 1.5.1 { set T(utf8,1) } $T(utf8,0) +do_test 1.5.2 { set T(utf16,1) } $T(utf16,0) + +do_test 1.6.1 { set U(utf8,1) } $U(utf8,0) +do_test 1.6.2 { set U(utf16,1) } $U(utf16,0) + + + +finish_test + + diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index 1124a44436..d3fd9989c0 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -336,6 +336,19 @@ foreach {tn opt} { } } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 6.0 { + CREATE VIRTUAL TABLE x1 USING fts5(x); +} +do_catchsql_test 6.1 { + INSERT INTO x1(rowid, x) VALUES(123, fts5_locale('en_AU', 'hello world')); +} {1 {fts5_locale() may not be used without locale=1}} + +do_execsql_test 6.2 { + SELECT typeof( fts5_locale(NULL, 'xyz') ), typeof( fts5_locale('', 'abc') ); +} {text text} + finish_test diff --git a/manifest b/manifest index 89acd2b99f..156f1a64a5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\shighlight()\sand\ssnippet()\sfunctions\sto\suse\slocales\swhen\savailable. -D 2024-07-30T15:55:51.884 +C Fix\scases\ssurrounding\sblob\svalues\sbeing\sstored\sin\slocale=1\sfts5\stables. +D 2024-07-30T20:39:58.636 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,15 +93,15 @@ F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6d F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h 7cd47e5dfe68d798e667caa76722374f0c909f2db05bb4d42b1ec5300d18e658 -F ext/fts5/fts5Int.h 330b1e2dad9ea9cccc9fa93817062fa21e89f00e7eac9a84be440f7e93bf7c3c +F ext/fts5/fts5Int.h 833a2fe729f926ebcde47e21e495d141b99ede9a188fc577873f24bea0f0bfa2 F ext/fts5/fts5_aux.c 652f839dc0c77431295f10b08f268631560bb5630e65fd701de7a58744428a82 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 0c96490fbad746b3780174f38b2ee5e3d719f2f81ee6b58ca828772871e0f680 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c ee4bba42d8d093cd870c55a342ab85a647ec39dc79985e2b1084514d990de82d -F ext/fts5/fts5_storage.c 2118a5bd2ae617367259f6cf2412b6ff26bc1cd1cc29bf64a6249edcc1572f19 +F ext/fts5/fts5_main.c d9a3fef86887e373027d48ab8216ab8caca95f2316e05d953d8885633162a9c5 +F ext/fts5/fts5_storage.c cc6173bb755d668573169c038034a9ec8deadd10b3c10c145adbdf04ab5f889c F ext/fts5/fts5_tcl.c 93b705cb87633574983161edc5234f9b91ba03f9fecfbd2c5d401a1da6f93aa5 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -132,6 +132,7 @@ F ext/fts5/test/fts5auxdata.test 372549088ff792655f73e62b9dfaf4863ce74f5e604c06c F ext/fts5/test/fts5bigid.test 2860854c2561a57594192b00c33a29f91cb85e25f3d6c03b5c2b8f62708f39dd F ext/fts5/test/fts5bigpl.test 8f09858aab866c33593560e6480b2b6975ae7ff29ca32ad7b77e2da61402f8ef F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36 +F ext/fts5/test/fts5blob.test a16160688e181a212bcb4968325c57ef2864a0bcae0794d6a1e16185007f00b9 F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62 F ext/fts5/test/fts5colset.test 544f4998cdbfe06a3123887fc0221612e8aa8192cdaff152872f1aadb10e6897 @@ -184,7 +185,7 @@ F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fd F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 7c332f882080a69ed4be9790d99ee49747ca44cf241d45f762298e17fea6e7a7 +F ext/fts5/test/fts5locale.test bfd8704f9bea963314fcbcf810f08a357ac8035bcb80a2d6170c1e57fa6ad52a F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2196,8 +2197,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 14006711d83d098e665c540b978b0e29aa8f458da1c2c8e9c2baf2ad5ebd502c -R 8ced4a5b525d31957945a9ad2a3de4d9 +P 569ae56a673a2e101fac7003a1cb41c7a02a515adf55bd1e1f2a03c19eb2b085 +R 937929d817b727d57bac9fb974f93247 U dan -Z 395467bf290b92744f082b81bcb8dffe +Z 807f8f93a084e88be44a4f6a2009b39e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 634c3661ab..dfceffa3c6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -569ae56a673a2e101fac7003a1cb41c7a02a515adf55bd1e1f2a03c19eb2b085 +ae435aff1785d5832821c19dc88ccf6c496a7ff55be80276b31e5c9abee723db From f504cc761be78840089c838306840d9ccad990a9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 01:45:14 +0000 Subject: [PATCH 0581/1030] Implement a new comparison routine to compare text renderings of floating point values. This gets the number of failures down to just 5. But the routine needs work, and probably refactoring. FossilOrigin-Name: 71f2ee5db01150707401804b136641170e7ed44760fccec20de19184e4d0a840 --- manifest | 16 +++--- manifest.uuid | 2 +- src/test1.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++ test/cast.test | 1 + test/tester.tcl | 3 ++ 5 files changed, 153 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 41a530ae7e..193eb35732 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C All\stests\sin\s"make\stest"\snow\spass\swith\sTcl9,\sexcept\sfor\sabout\s198\scases\swhere\nthe\serror\sinvolves\ssmall\sdifferences\sin\sthe\srendering\sto\sfloating\spoint\nvalues. -D 2024-07-30T20:39:05.717 +C Implement\sa\snew\scomparison\sroutine\sto\scompare\stext\srenderings\sof\nfloating\spoint\svalues.\s\sThis\sgets\sthe\snumber\sof\sfailures\sdown\sto\sjust\s5.\nBut\sthe\sroutine\sneeds\swork,\sand\sprobably\srefactoring. +D 2024-07-31T01:45:14.852 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c 671206cdad1ebc93d0e5db94c91a23d342d3906cb2a7ef25ceac44a2ca0cdc67 F src/tclsqlite.h f3dc9ed1464a7cc775a47da70ac6f23e95d0fb939dd7eaf48639778f94d5aaad -F src/test1.c 9f01a43b5d9d0c08c31617f3ab4e924bb30cd47db784527dbf6a309456a4db3b +F src/test1.c 179c80be560631a24ca7dc40542c560f6afcf22232ac7502e3a041a96abd8df3 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d @@ -981,7 +981,7 @@ F test/capi3c.test 31d3a6778f2d06f2d9222bd7660c41a516d1518a059b069e96ebbeadb5a49 F test/capi3d.test 8b778794af891b0dca3d900bd345fbc8ebd2aa2aae425a9dccdd10d5233dfbde F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe F test/carray01.test 23ed7074307c4a829ba5ff2970993a9d87db7c5cdbbe1a2cbef672d0df6d6e31 -F test/cast.test af2286fdd28f3470b7dcad23977282b8cc117747ad55acff74a770dad3b19398 +F test/cast.test 42f7d79d88ab5e8080e96c650c52fcf72eef3e6476aaaee2c9f6e074396cfdfc F test/cffault.test 9d6b20606afe712374952eec4f8fd74b1a8097ef F test/changes.test 4377d202a487f66fc2822c1bf57c46798c8b2caf7446f4f701723b1dbb6b86f6 F test/changes2.test 07949edcc732af28cb54276bfb7d99723bccc1e905a423648bf57ac5cb0dc792 @@ -1704,7 +1704,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d1631311a16 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc -F test/tester.tcl f16465ee09897fc2bf5ea266146c5f15d507eb2a6a33129cffe135495192a3aa +F test/tester.tcl 80626ee1ce542f3171a2e64e5d944f9a37ff06386ac325dd8988445494f526b1 F test/testrunner.tcl 1386667c04207d0a540ce1a9bc5ee0b734f7a3ba856c14a03943fb4f32de55bb F test/testrunner_data.tcl 3d36660cfd55ea5e20e661e8f94c0520feebcb437848f9b98b33c483cc479c0c F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fa549a5507b5f805b469b4360c11155aa9d22043f01f6d9428bf44d0f2351eb0 -R b16c3971e6beab65b3114759a6ea073a +P 8e27f5326c69aa4fb6f3f1f42668ab1b08140ab0a614ac4a9d94679c8fb9734e +R 2961dc3384c51136e21cb2a47ab0b5d2 U drh -Z b90cc1cc87390ce48c689e5c22b10880 +Z f1dc4569062e062a05b7f613172f6c6b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aa4cf748eb..1461bc6798 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e27f5326c69aa4fb6f3f1f42668ab1b08140ab0a614ac4a9d94679c8fb9734e +71f2ee5db01150707401804b136641170e7ed44760fccec20de19184e4d0a840 diff --git a/src/test1.c b/src/test1.c index 90035151e4..6372a9b54a 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5964,6 +5964,145 @@ static int SQLITE_TCLAPI tcl_variable_type( return TCL_OK; } +#include + +/* +** Usage: fpnum_compare STRING1 STRING2 +** +** Compare two strings. Return true if the strings are the same and +** false if they differ. +** +** For this comparison, the strings are analyzed as a sequenced of +** whitespace separated tokens. The whitespace is ignored. Only the +** tokens are compared. Comparison rules: +** +** A. Tokens that are not floating-point numbers must match exactly. +** +** B. Floating point number must have exactly the same digits before +** the decimal point. +** +** C. Digits must match after the decimal point up to 15 digits, +** taking rounding into consideration. +** +** D. An exponent on a floating point of the form "e+NN" will +** match "e+N" if NN==N. Likewise for the negative exponent. +** +** This routine is used for comparing results that might involve floating +** point values. Tcl9.0 and Tcl8.6 differ in the number of significant +** digits that they show, so there is no way to write a portable test result +** without this routine. +** +** This routine is only called after [string compare] fails, which is seldom, +** so performance is not a pressing concern. Better to get the correct answer +** slowly. +*/ +static int SQLITE_TCLAPI fpnum_compare( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + const unsigned char *zA; + const unsigned char *zB; + int i, j; + int nDigit; + + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 1, objv, "STRING1 STRING2"); + return TCL_ERROR; + } + zA = (const unsigned char*)Tcl_GetString(objv[1]); + zB = (const unsigned char*)Tcl_GetString(objv[2]); + i = j = 0; + while( 1 ){ + /* Skip whitespace before and after tokens */ + while( isspace(zA[i]) ){ i++; } + while( isspace(zB[j]) ){ j++; } + + if( zA[i]!=zB[j] ) break; /* First character must match */ + if( zA[i]=='-' && isdigit(zA[i+1]) ){ i++; j++; } /* Skip initial '-' */ + if( !isdigit(zA[i]) ){ + /* Not a number. Must match exactly */ + while( !isspace(zA[i]) && zA[i] && zA[i]==zB[j] ){ i++; j++; } + if( zA[i]!=zB[j] ) break; + if( isspace(zA[i]) ) continue; + break; + } + + /* At this point we know we are dealing with a number zA[i] and zB[j] + ** are both digits (leading "-" have been skipped). See if they are + ** the same number. Start by matching digits before the decimal + ** point, which must all be the same. */ + nDigit = 0; + while( zA[i]==zB[j] && isdigit(zA[i]) ){ i++; j++; nDigit++; } + if( zA[i]!=zB[j] ) break; + if( zA[i]==0 ) break; + if( zA[i]=='.' && zB[j]=='.' ){ + /* Count more matching digits after the decimal point */ + i++; + j++; + while( zA[i]==zB[j] && isdigit(zA[i]) ){ i++; j++; nDigit++; } + if( zA[i]==0 ){ + while( zB[j]=='0' || (isdigit(zB[j]) && nDigit>=15) ){ j++; nDigit++; } + break; + } + if( zB[j]==0 ){ + while( zA[i]=='0' || (isdigit(zA[i]) && nDigit>=15) ){ i++; nDigit++; } + break; + } + if( isspace(zA[i]) && isspace(zB[j]) ) continue; + + if( isdigit(zA[i]) && isdigit(zB[j]) ){ + /* A and B are both digits, but different digits */ + if( zA[i]==zB[j]+1 && !isdigit(zA[i+1]) && isdigit(zB[j+1]) ){ + /* Is A a rounded up version of B? */ + j++; + while( zB[j]=='9' ){ j++; nDigit++; } + if( nDigit<14 && (!isdigit(zB[j]) || zB[j]<5) ) break; + while( isdigit(zB[j]) ){ j++; } + i++; + }else if( zB[j]==zA[i]+1 && !isdigit(zB[j+1]) && isdigit(zA[i+1]) ){ + /* Is B a rounded up version of A? */ + i++; + while( zA[i]=='9' ){ i++; nDigit++; } + if( nDigit<14 && (!isdigit(zA[i]) || zA[i]<5) ) break; + while( isdigit(zA[i]) ){ i++; } + j++; + }else{ + break; + } + }else if( !isdigit(zA[i]) && isdigit(zB[j]) ){ + while( zB[j]=='0' ){ j++; nDigit++; } + if( nDigit<15 ) break; + while( isdigit(zB[j]) ){ j++; } + }else if( !isdigit(zB[j]) && isdigit(zA[i]) ){ + while( zA[i]=='0' ){ i++; nDigit++; } + if( nDigit<15 ) break; + while( isdigit(zA[i]) ){ i++; } + }else{ + break; + } + } + if( zA[i]=='e' && zB[i]=='e' ){ + i++; + j++; + if( (zA[i]=='+' || zA[i]=='-') && zB[j]==zA[i] ){ i++; j++; } + if( zA[i]!=zB[j] ){ + if( zA[i]=='0' && zA[i+1]==zB[j] ){ i++; } + if( zB[j]=='0' && zB[j+1]==zA[i] ){ j++; } + } + while( zA[i]==zB[j] && isdigit(zA[i]) ){ i++; j++; } + if( zA[i]!=zB[j] ) break; + if( zA[i]==0 ) break; + continue; + } + } + while( isspace(zA[i]) ){ i++; } + while( isspace(zB[j]) ){ j++; } + Tcl_SetObjResult(interp, Tcl_NewIntObj(zA[i]==0 && zB[j]==0)); + return TCL_OK; +} + /* ** Usage: sqlite3_release_memory ?N? ** @@ -9234,6 +9373,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ #endif { "sqlite3_test_errstr", test_errstr, 0 }, { "tcl_variable_type", tcl_variable_type, 0 }, + { "fpnum_compare", fpnum_compare, 0 }, #ifndef SQLITE_OMIT_SHARED_CACHE { "sqlite3_enable_shared_cache", test_enable_shared, 0 }, { "sqlite3_shared_cache_report", sqlite3BtreeSharedCacheReport, 0}, diff --git a/test/cast.test b/test/cast.test index ebfea5aa06..7f48ed80bf 100644 --- a/test/cast.test +++ b/test/cast.test @@ -234,6 +234,7 @@ do_test cast-3.1 { do_test cast-3.2 { execsql {SELECT CAST(9223372036854774800 AS numeric)} } 9223372036854774800 +breakpoint do_realnum_test cast-3.3 { execsql {SELECT CAST(9223372036854774800 AS real)} } 9.22337203685477e+18 diff --git a/test/tester.tcl b/test/tester.tcl index f7f5347f5a..2c18c4690e 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -847,6 +847,9 @@ proc do_test {name cmd expected} { } } else { set ok [expr {[string compare $result $expected]==0}] + if {!$ok} { + set ok [fpnum_compare $result $expected] + } } if {!$ok} { # if {![info exists ::testprefix] || $::testprefix eq ""} { From 3bad3d6964018b9929e6ef56ea93ffe47d57e471 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 01:53:48 +0000 Subject: [PATCH 0582/1030] Adjust a few tests that don't work even with the new floating point comparison routine. FossilOrigin-Name: 895125a4895099df7c3841ca7c34697ba17fd667bddbc2fd7148f7aa9d6d2b9d --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/func7.test | 2 +- test/misc3.test | 5 +++-- test/nan.test | 9 +++++---- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 193eb35732..8ce4b76e10 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Implement\sa\snew\scomparison\sroutine\sto\scompare\stext\srenderings\sof\nfloating\spoint\svalues.\s\sThis\sgets\sthe\snumber\sof\sfailures\sdown\sto\sjust\s5.\nBut\sthe\sroutine\sneeds\swork,\sand\sprobably\srefactoring. -D 2024-07-31T01:45:14.852 +C Adjust\sa\sfew\stests\sthat\sdon't\swork\seven\swith\sthe\snew\sfloating\spoint\ncomparison\sroutine. +D 2024-07-31T01:53:48.615 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1248,7 +1248,7 @@ F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5 F test/func5.test 863e6d1bd0013d09c17236f8a13ea34008dd857d87d85a13a673960e4c25d82a F test/func6.test 3bc89ec0f2605736d3a118f43d25ef58115a7db4dba8ae939a363917d815c0bb -F test/func7.test adbfc910385a6ffd15dc47be3c619ef070c542fcb7488964badb17b2d9a4d080 +F test/func7.test 38d882ca14f3ec178b50d9354e6bb092c7dc8e1c30c9e4ac62b8f3e6a0b6a7d9 F test/func8.test c4e2ecacf9f16e47a245e7a25fbabcc7e78f9c7c41a80f158527cdfdc6dd299d F test/func9.test b32d313f679aa9698d52f39519d301c3941823cb72b4e23406c210eadd82c824 F test/fuzz-oss1.test 514dcabb24687818ea949fa6760229eaacad74ca70157743ef36d35bbe01ffb0 @@ -1441,7 +1441,7 @@ F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 272ca395257f05937dc96441c9dde4bc9fbf116a8d4fa02baeb0d13d50e36c87 F test/misc1.test e3e36262aff1bd9b8b9bf1eeb3af04adb3fc1e23f0a92dbff708bba9e939ace1 F test/misc2.test a1a3573cc02662becd967766021d6f16c54684d56df5f227481c7ef0d9df0bd0 -F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d +F test/misc3.test 4eab749f3bbab4405b1f64ca827543049d74d4b4446a694659d33396581ee178 F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e F test/misc5.test 027cf0ac10314ea534173f335a33bb4059907ddabbac2c16786766d6f26c8923 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 @@ -1462,7 +1462,7 @@ F test/multiplex3.test fac575e0b1b852025575a6a8357701d80933e98b5d2fe6d35ddaa68f9 F test/multiplex4.test e8ae4c4bd70606a5727743241f13b5701990abe4 F test/mutex1.test 42cb5e244c3a77bb0ef2b967e06fa5e7ba7d32d90a9b20bed98f6f5ede185a25 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 -F test/nan.test 437d40e6d0778b050d7750726c0cbd2c9936b81962926e8f8c48ca698f00f4d1 +F test/nan.test 73ea63ab43668313e2f8cc9ef9e9a966672c7934f3ce76926fbe991235d07d91 F test/nockpt.test 8c43b25af63b0bd620cf1b003529e37b6f1dc53bd22690e96a1bd73f78dde53a F test/nolock.test f196cf8b8fbea4e2ca345140a2b3f3b0da45c76e F test/normalize.test f23b6c5926c59548635fcf39678ac613e726121e073dd902a3062fbb83903b72 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8e27f5326c69aa4fb6f3f1f42668ab1b08140ab0a614ac4a9d94679c8fb9734e -R 2961dc3384c51136e21cb2a47ab0b5d2 +P 71f2ee5db01150707401804b136641170e7ed44760fccec20de19184e4d0a840 +R cd4b28da8f0177e6ba3602669e9943bb U drh -Z f1dc4569062e062a05b7f613172f6c6b +Z 107af80bed0e760d0f1a4661620a5bc3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1461bc6798..62734ab651 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -71f2ee5db01150707401804b136641170e7ed44760fccec20de19184e4d0a840 +895125a4895099df7c3841ca7c34697ba17fd667bddbc2fd7148f7aa9d6d2b9d diff --git a/test/func7.test b/test/func7.test index bb4f80b325..af1a2e0227 100644 --- a/test/func7.test +++ b/test/func7.test @@ -139,7 +139,7 @@ do_execsql_test func7-pg-420 { SELECT round( tan(1), 7); } {1.5574077} do_execsql_test func7-pg-421 { - SELECT tan( radians(45) ); + SELECT round(tan( radians(45) ),10); } {1.0} do_execsql_test func7-pg-500 { SELECT round( sinh(1), 7); diff --git a/test/misc3.test b/test/misc3.test index bc1f0ff911..79c06224aa 100644 --- a/test/misc3.test +++ b/test/misc3.test @@ -87,9 +87,10 @@ do_test misc3-2.3 { do_test misc3-2.4 { execsql {SELECT 2e-25*0.5e250} } 1e+225 +load_static_extension db decimal do_test misc3-2.5 { - execsql {SELECT 2.0e-250*0.5e25} -} 1e-225 + execsql {SELECT decimal_exp(2.0e-250*0.5e25)} +} {/\+1\.000000000000000\d+e-225/} do_test misc3-2.6 { execsql {SELECT '-2.0e-127' * '-0.5e27'} } 1e-100 diff --git a/test/nan.test b/test/nan.test index 615a4ad227..8d8a98ab3b 100644 --- a/test/nan.test +++ b/test/nan.test @@ -281,6 +281,7 @@ do_test nan-4.14 { # These tests test some really, really small floating point numbers. # +load_static_extension db decimal if {$tcl_platform(platform) != "symbian"} { # These two are not run on symbian because tcl has trouble converting # the very small numbers back to text form (probably due to a difference @@ -291,15 +292,15 @@ if {$tcl_platform(platform) != "symbian"} { set small \ [string repeat 0 10000].[string repeat 0 323][string repeat 9 10000] db eval "INSERT INTO t1 VALUES($small)" - db eval {SELECT x, typeof(x) FROM t1} - } {9.88131291682493e-324 real} + db eval {SELECT decimal_exp(x), typeof(x) FROM t1} + } {/9\.88131291682493\d*e-324 real/} do_test nan-4.16 { db eval {DELETE FROM t1} set small \ -[string repeat 0 10000].[string repeat 0 323][string repeat 9 10000] db eval "INSERT INTO t1 VALUES($small)" - db eval {SELECT x, typeof(x) FROM t1} - } {-9.88131291682493e-324 real} + db eval {SELECT decimal_exp(x), typeof(x) FROM t1} + } {/-9\.88131291682493\d*e-324 real/} } do_test nan-4.17 { db eval {DELETE FROM t1} From 4400b0ac45840d17cb5fca1ba4d173fa3982002b Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 02:01:19 +0000 Subject: [PATCH 0583/1030] Fix a problem with strictly conforming UTF8 in shell1.test. FossilOrigin-Name: 8ee187f98d310e1e7cf6c3fdf000c19e98a9f11e01436c3c407df04da79aa7c0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/shell1.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8ce4b76e10..b2153e650b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sa\sfew\stests\sthat\sdon't\swork\seven\swith\sthe\snew\sfloating\spoint\ncomparison\sroutine. -D 2024-07-31T01:53:48.615 +C Fix\sa\sproblem\swith\sstrictly\sconforming\sUTF8\sin\sshell1.test. +D 2024-07-31T02:01:19.346 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1616,7 +1616,7 @@ F test/sharedA.test 64bdd21216dda2c6a3bd3475348ccdc108160f34682c97f2f51c19fc0e21 F test/sharedB.test 1a84863d7a2204e0d42f2e1606577c5e92e4473fa37ea0f5bdf829e4bf8ee707 F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test 17a5ca9c6f24f807b2f505b4b38fcbce143d96cd8664c06c34bbbe0672bf7c30 +F test/shell1.test 490bf9d0c7c9564fea318c46d49369f4690b825b584c9a544dbdccf61bc0babc F test/shell2.test 56da24128304c9ab67da2964cc80beff7b35761c446ec6e6e98bff2775b15026 F test/shell3.test db1953a8e59d08e9240b7cc5948878e184f7eb2623591587f8fd1f1a5bd536d8 F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f807 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 71f2ee5db01150707401804b136641170e7ed44760fccec20de19184e4d0a840 -R cd4b28da8f0177e6ba3602669e9943bb +P 895125a4895099df7c3841ca7c34697ba17fd667bddbc2fd7148f7aa9d6d2b9d +R 29e6c2fe80c749b833106a3f129e0b0b U drh -Z 107af80bed0e760d0f1a4661620a5bc3 +Z 4f162a5701a7f3bcc06c08326c1da654 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 62734ab651..2d4519b087 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -895125a4895099df7c3841ca7c34697ba17fd667bddbc2fd7148f7aa9d6d2b9d +8ee187f98d310e1e7cf6c3fdf000c19e98a9f11e01436c3c407df04da79aa7c0 diff --git a/test/shell1.test b/test/shell1.test index 206fb0a4fd..f355989c31 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -1059,7 +1059,7 @@ do_test shell1-5.0 { continue } # Tcl 8.7 maps 0x80 through 0x9f into valid UTF8. So skip those tests. - if {$i>=0x80 && $i<=0x9f} continue + if {$i>=0x80 && ($i<=0x9F || $tcl_version>=9.0)} continue if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue set hex [format %02X $i] From e388fc7367f4752c6b23b28154654ca39adaf009 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 10:59:19 +0000 Subject: [PATCH 0584/1030] Fixes to tclsqlite.c to facilitate TEA installs. FossilOrigin-Name: 7157c3c910565c9385a028793a0c0106c5064ab6a8a6efbe29dd1f1cdb2bd48d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tclsqlite.c | 23 ++++++++++++++++++++++- src/tclsqlite.h | 5 +++++ 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b2153e650b..50da815b2e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sstrictly\sconforming\sUTF8\sin\sshell1.test. -D 2024-07-31T02:01:19.346 +C Fixes\sto\stclsqlite.c\sto\sfacilitate\sTEA\sinstalls. +D 2024-07-31T10:59:19.356 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -768,8 +768,8 @@ F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c 671206cdad1ebc93d0e5db94c91a23d342d3906cb2a7ef25ceac44a2ca0cdc67 -F src/tclsqlite.h f3dc9ed1464a7cc775a47da70ac6f23e95d0fb939dd7eaf48639778f94d5aaad +F src/tclsqlite.c 6242341191e43952a8ed466b1ee4993cad3a2b93ec3e4a5e826f0b06225a6716 +F src/tclsqlite.h 4ed60ea4084b2ea46e19ab13857b3f39d33250ebbf5b2df62b0999bb9b2766b7 F src/test1.c 179c80be560631a24ca7dc40542c560f6afcf22232ac7502e3a041a96abd8df3 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 895125a4895099df7c3841ca7c34697ba17fd667bddbc2fd7148f7aa9d6d2b9d -R 29e6c2fe80c749b833106a3f129e0b0b +P 8ee187f98d310e1e7cf6c3fdf000c19e98a9f11e01436c3c407df04da79aa7c0 +R 11b997737d72a6acc08733c094770fe6 U drh -Z 4f162a5701a7f3bcc06c08326c1da654 +Z 95699a30a586f97e0f36f4f5ea30a6cf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2d4519b087..89f4381777 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ee187f98d310e1e7cf6c3fdf000c19e98a9f11e01436c3c407df04da79aa7c0 +7157c3c910565c9385a028793a0c0106c5064ab6a8a6efbe29dd1f1cdb2bd48d diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 76e6701603..55084687a7 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -35,7 +35,23 @@ # include "msvc.h" #endif -#include "tclsqlite.h" +/****** Copy of tclsqlite.h ******/ +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" /* Special case for Windows using STDCALL */ +#else +# include "tcl.h" /* All normal cases */ +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif +#endif +/* Compatability between Tcl8.6 and Tcl9.0 */ +#if TCL_MAJOR_VERSION==9 +# define CONST const +#else + typedef int Tcl_Size; +#endif +/**** End copy of tclsqlite.h ****/ + #include /* @@ -3997,6 +4013,11 @@ EXTERN int Tclsqlite_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } EXTERN int Sqlite_SafeInit(Tcl_Interp *interp){ return TCL_ERROR; } EXTERN int Sqlite_SafeUnload(Tcl_Interp *interp, int flags){return TCL_ERROR;} +/* Also variants with a lowercase "s" */ +EXTERN int sqlite3_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp);} +EXTERN int sqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp);} + + /* ** If the TCLSH macro is defined, add code to make a stand-alone program. */ diff --git a/src/tclsqlite.h b/src/tclsqlite.h index 217b9a05b6..ef63641bbb 100644 --- a/src/tclsqlite.h +++ b/src/tclsqlite.h @@ -14,6 +14,7 @@ ** and various test*.c pieces) should #include this file rather than ** including tcl.h directly. */ +/****** Any edits to this file must mirrored in tclsqlite.c ***********/ /* When compiling for Windows using STDCALL instead of CDECL calling ** conventions, the MSVC makefile has to build a customized version of @@ -29,9 +30,13 @@ # endif #endif +/****** Any edits to this file must mirrored in tclsqlite.c ***********/ + /* Compatability between Tcl8.6 and Tcl9.0 */ #if TCL_MAJOR_VERSION==9 # define CONST const #else typedef int Tcl_Size; #endif + +/****** Any edits to this file must mirrored in tclsqlite.c ***********/ From f15c80d80f5c6bdea2f2eac2a300ec053732cedb Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 11:12:13 +0000 Subject: [PATCH 0585/1030] Patch to testrunner.tcl so that it works with Tcl9's pedantic UTF-8 checking. FossilOrigin-Name: 8d4a23d32dc16b115153e6e100ba3ba15273c3e37310e8a1b4bace885c5383a8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 50da815b2e..e6268c8273 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sto\stclsqlite.c\sto\sfacilitate\sTEA\sinstalls. -D 2024-07-31T10:59:19.356 +C Patch\sto\stestrunner.tcl\sso\sthat\sit\sworks\swith\sTcl9's\spedantic\sUTF-8\schecking. +D 2024-07-31T11:12:13.141 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1705,7 +1705,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 80626ee1ce542f3171a2e64e5d944f9a37ff06386ac325dd8988445494f526b1 -F test/testrunner.tcl 1386667c04207d0a540ce1a9bc5ee0b734f7a3ba856c14a03943fb4f32de55bb +F test/testrunner.tcl 757f79c68f82cad563441d80f02c492465f51cf537336c7b719c3ef45f348911 F test/testrunner_data.tcl 3d36660cfd55ea5e20e661e8f94c0520feebcb437848f9b98b33c483cc479c0c F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8ee187f98d310e1e7cf6c3fdf000c19e98a9f11e01436c3c407df04da79aa7c0 -R 11b997737d72a6acc08733c094770fe6 +P 7157c3c910565c9385a028793a0c0106c5064ab6a8a6efbe29dd1f1cdb2bd48d +R 2e7d18721eb725cc0ae0df1dfecc64bd U drh -Z 95699a30a586f97e0f36f4f5ea30a6cf +Z 2989fad3f143368778831d6aee688e14 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 89f4381777..9eda64c6a8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7157c3c910565c9385a028793a0c0106c5064ab6a8a6efbe29dd1f1cdb2bd48d +8d4a23d32dc16b115153e6e100ba3ba15273c3e37310e8a1b4bace885c5383a8 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index fd82716769..57c39e7a4c 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -1117,7 +1117,7 @@ proc launch_another_job {iJob} { set fd [open "|$TRG(runcmd) 2>@1" r] cd $pwd - fconfigure $fd -blocking false + fconfigure $fd -blocking false -translation binary fileevent $fd readable [list script_input_ready $fd $iJob $job(jobid)] } From d3b58968a98e0826a169326c27780d54a8f2e849 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 11:42:47 +0000 Subject: [PATCH 0586/1030] Adjust the configure script so that the --with-tcl option is used to find the appropriate tclsh. FossilOrigin-Name: 6fb9e37c751cd1a411c77f792794e1abafa5c40ad4dda8d433600d44d525a97c --- configure | 22 +++++++++++++++++++++- configure.ac | 22 ++++++++++++++++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 625d3f8cb9..efd0422ac1 100755 --- a/configure +++ b/configure @@ -10318,7 +10318,20 @@ USE_AMALGAMATION=1 # if not, then we fall back to plain tclsh. # TODO: try other versions before falling back? # -for ac_prog in tclsh8.7 tclsh8.6 tclsh8.5 tclsh +if test x"${with_tcl}" != x; then + if test ! -r ${with_tcl}/tclConfig.sh; then + as_fn_error $? "no tclConfig.sh file found in --with-tcl: ${with_tcl}" "$LINENO" 5 + else + . ${with_tcl}/tclConfig.sh + TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} + if test ! -x ${TCLSH_CMD}; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot use tclsh at: ${TCLSH_CMD}" >&5 +$as_echo "$as_me: WARNING: cannot use tclsh at: ${TCLSH_CMD}" >&2;} + TCLSH_CMD=none + fi + fi +else + for ac_prog in tclsh8.6 tclsh8.5 tclsh do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -10361,6 +10374,7 @@ fi done test -n "$TCLSH_CMD" || TCLSH_CMD="none" +fi if test "$TCLSH_CMD" = "none"; then # If we can't find a local tclsh, then building the amalgamation will fail. # We act as though --disable-amalgamation has been used. @@ -10368,6 +10382,12 @@ if test "$TCLSH_CMD" = "none"; then USE_AMALGAMATION=0 TCLSH_CMD="tclsh" fi +if test x"$TCLSH_CMD" = x; then + as_fn_error $? "cannot find a usable tclsh" "$LINENO" 5 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using $TCLSH_CMD" >&5 +$as_echo "using $TCLSH_CMD" >&6; } +fi diff --git a/configure.ac b/configure.ac index 54f985fd70..9d8c594bae 100644 --- a/configure.ac +++ b/configure.ac @@ -119,8 +119,21 @@ USE_AMALGAMATION=1 # See whether we can run specific tclsh versions known to work well; # if not, then we fall back to plain tclsh. # TODO: try other versions before falling back? -# -AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.7 tclsh8.6 tclsh8.5 tclsh], none) +# +if test x"${with_tcl}" != x; then + if test ! -r ${with_tcl}/tclConfig.sh; then + AC_MSG_ERROR([no tclConfig.sh file found in --with-tcl: ${with_tcl}]) + else + . ${with_tcl}/tclConfig.sh + TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} + if test ! -x ${TCLSH_CMD}; then + AC_MSG_WARN([cannot use tclsh at: ${TCLSH_CMD}]) + TCLSH_CMD=none + fi + fi +else + AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh8.5 tclsh], none) +fi if test "$TCLSH_CMD" = "none"; then # If we can't find a local tclsh, then building the amalgamation will fail. # We act as though --disable-amalgamation has been used. @@ -128,6 +141,11 @@ if test "$TCLSH_CMD" = "none"; then USE_AMALGAMATION=0 TCLSH_CMD="tclsh" fi +if test x"$TCLSH_CMD" = x; then + AC_MSG_ERROR([cannot find a usable tclsh]) +else + AC_MSG_RESULT([using $TCLSH_CMD]) +fi AC_SUBST(TCLSH_CMD) AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin]) diff --git a/manifest b/manifest index e6268c8273..7a4b325da9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Patch\sto\stestrunner.tcl\sso\sthat\sit\sworks\swith\sTcl9's\spedantic\sUTF-8\schecking. -D 2024-07-31T11:12:13.141 +C Adjust\sthe\sconfigure\sscript\sso\sthat\sthe\s--with-tcl\soption\sis\sused\sto\nfind\sthe\sappropriate\stclsh. +D 2024-07-31T11:42:47.316 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 27d144c2edfa993ac155a2ad5e6b431e4ec811159598ef55a59f345bc2e5e533 x -F configure.ac f25bd7843120f2c2b8bc9db5a92b0502bbdd28e68907415c3d42fc8e57c657b9 +F configure e0efd210b151971f4158e3fdf93b34322882a668a96f88b6167a6f7a51edebec x +F configure.ac 7361a1dd862c0ba0d2daa3d978bc3b93fcccc1ef3efe204d0238722c19bbdcf5 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7157c3c910565c9385a028793a0c0106c5064ab6a8a6efbe29dd1f1cdb2bd48d -R 2e7d18721eb725cc0ae0df1dfecc64bd +P 8d4a23d32dc16b115153e6e100ba3ba15273c3e37310e8a1b4bace885c5383a8 +R 64a8d10fb6347ca8ef346534c156b0fa U drh -Z 2989fad3f143368778831d6aee688e14 +Z fd89c8e44bc980444bfd6347c100cdd8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9eda64c6a8..caf0604cff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8d4a23d32dc16b115153e6e100ba3ba15273c3e37310e8a1b4bace885c5383a8 +6fb9e37c751cd1a411c77f792794e1abafa5c40ad4dda8d433600d44d525a97c From 096c22ad5e9e16a1075af34dabd89b3b77ef12ea Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 12:19:16 +0000 Subject: [PATCH 0587/1030] Minor adjustments to get Tcl9-based testing working on Macs. FossilOrigin-Name: 066c8672ee85a6ce972de38fcd3793fc2c1ef4f21c3de2379746d0ff18df8dc0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test1.c | 2 +- test/misc3.test | 5 ++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 7a4b325da9..815d2297fc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sthe\sconfigure\sscript\sso\sthat\sthe\s--with-tcl\soption\sis\sused\sto\nfind\sthe\sappropriate\stclsh. -D 2024-07-31T11:42:47.316 +C Minor\sadjustments\sto\sget\sTcl9-based\stesting\sworking\son\sMacs. +D 2024-07-31T12:19:16.986 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c 6242341191e43952a8ed466b1ee4993cad3a2b93ec3e4a5e826f0b06225a6716 F src/tclsqlite.h 4ed60ea4084b2ea46e19ab13857b3f39d33250ebbf5b2df62b0999bb9b2766b7 -F src/test1.c 179c80be560631a24ca7dc40542c560f6afcf22232ac7502e3a041a96abd8df3 +F src/test1.c b0ebd758a5ee92305510bc526448cde3b2015c4ac6e1b7b0c450ba2745cfda24 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d @@ -1441,7 +1441,7 @@ F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 272ca395257f05937dc96441c9dde4bc9fbf116a8d4fa02baeb0d13d50e36c87 F test/misc1.test e3e36262aff1bd9b8b9bf1eeb3af04adb3fc1e23f0a92dbff708bba9e939ace1 F test/misc2.test a1a3573cc02662becd967766021d6f16c54684d56df5f227481c7ef0d9df0bd0 -F test/misc3.test 4eab749f3bbab4405b1f64ca827543049d74d4b4446a694659d33396581ee178 +F test/misc3.test 651b88bca19b8ff6a7b6af73dae00c3fd5b3ea5bee0c0d1d91abd4c4b4748718 F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e F test/misc5.test 027cf0ac10314ea534173f335a33bb4059907ddabbac2c16786766d6f26c8923 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8d4a23d32dc16b115153e6e100ba3ba15273c3e37310e8a1b4bace885c5383a8 -R 64a8d10fb6347ca8ef346534c156b0fa +P 6fb9e37c751cd1a411c77f792794e1abafa5c40ad4dda8d433600d44d525a97c +R 75074f72d19f6c210244f75d22179060 U drh -Z fd89c8e44bc980444bfd6347c100cdd8 +Z 82e857c9b07f1185c6a5a8324ed25dc7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index caf0604cff..95611b3402 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6fb9e37c751cd1a411c77f792794e1abafa5c40ad4dda8d433600d44d525a97c +066c8672ee85a6ce972de38fcd3793fc2c1ef4f21c3de2379746d0ff18df8dc0 diff --git a/src/test1.c b/src/test1.c index 6372a9b54a..39249a6c66 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6791,7 +6791,7 @@ static int SQLITE_TCLAPI file_control_lockproxy_test( { char *testPath; int rc; - int nPwd; + Tcl_Size nPwd; const char *zPwd; char proxyPath[400]; diff --git a/test/misc3.test b/test/misc3.test index 79c06224aa..f64b0fe1dd 100644 --- a/test/misc3.test +++ b/test/misc3.test @@ -87,10 +87,9 @@ do_test misc3-2.3 { do_test misc3-2.4 { execsql {SELECT 2e-25*0.5e250} } 1e+225 -load_static_extension db decimal do_test misc3-2.5 { - execsql {SELECT decimal_exp(2.0e-250*0.5e25)} -} {/\+1\.000000000000000\d+e-225/} + execsql {SELECT format('%.15e',2.0e-250*0.5e25)} +} {1.0000000000000e-225} do_test misc3-2.6 { execsql {SELECT '-2.0e-127' * '-0.5e27'} } 1e-100 From 3f80dbd51ef9bbb5cc876144a8a3dfa09d279c04 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 13:00:18 +0000 Subject: [PATCH 0588/1030] Fix problems uncovered while testing Tcl9 on Windows. FossilOrigin-Name: d5523c77fd0bcdc8344971a116d6ce9657f2b6daddeb7d936cd7607163a36744 --- ext/fts3/fts3_test.c | 1 - manifest | 14 +++++++------- manifest.uuid | 2 +- test/readonly.test | 5 ++++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ext/fts3/fts3_test.c b/ext/fts3/fts3_test.c index 09adbc06ce..3c42a7bf02 100644 --- a/ext/fts3/fts3_test.c +++ b/ext/fts3/fts3_test.c @@ -225,7 +225,6 @@ static int SQLITE_TCLAPI fts3_near_match_cmd( } for(jj=0; jj<(int)nToken; jj++){ NearToken *pT = &aPhrase[ii].aToken[jj]; - Tcl_Size nn; pT->z = Tcl_GetStringFromObj(apToken[jj], &nn); pT->n = (int)nn; } diff --git a/manifest b/manifest index 815d2297fc..f3dd368582 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sadjustments\sto\sget\sTcl9-based\stesting\sworking\son\sMacs. -D 2024-07-31T12:19:16.986 +C Fix\sproblems\suncovered\swhile\stesting\sTcl9\son\sWindows. +D 2024-07-31T13:00:18.912 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -76,7 +76,7 @@ F ext/fts3/fts3_icu.c 305ce7fb6036484085b5556a9c8e62acdc7763f0f4cdf5fd538212a9f3 F ext/fts3/fts3_porter.c e19807ce0ae31c1c6e9898e89ecc93183d7ec224ea101af039722a4f49e5f2b8 F ext/fts3/fts3_snippet.c 610328fe128c047c6b0eba77768982ccf3933daae095d497949a75c9dfd47409 F ext/fts3/fts3_term.c 6a96027ad364001432545fe43322b6af04ed28bb5619ec51af1f59d0710d6d69 -F ext/fts3/fts3_test.c a17e6c6249a58279617f9f57220ad85f3f343d9f002d721967939a1624f55b4a +F ext/fts3/fts3_test.c 7a9cb3d61774134211bf4bfdf1adcb581a1a0377f2d050a121ae7ab44baef0e3 F ext/fts3/fts3_tokenize_vtab.c 7fd9ef364f257b97218b9c331f2378e307375c592f70fd541f714e747d944962 F ext/fts3/fts3_tokenizer.c defede96b5dd5d658edfae77355b9c31ea65236eedc7bbe1adbc50d645cca5bc F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 @@ -1535,7 +1535,7 @@ F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 -F test/readonly.test c1985f0b4ab55041f2ba629dadc6578a3ff0f0e5b0ec7912e85c51f49c3e82fe +F test/readonly.test 69a7ccec846cad2e000b3539d56360d02f327061dc5e41f7f9a3e01f19719952 F test/recover.test a163a156ea9f2beea63fa83c4dcd8dea6e57b8a569fc647155e3d2754eaac1b5 F test/regexp1.test 8f2a8bc1569666e29a4cee6c1a666cd224eb6d50e2470d1dc1df995170f3e0f1 F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed1368b5 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6fb9e37c751cd1a411c77f792794e1abafa5c40ad4dda8d433600d44d525a97c -R 75074f72d19f6c210244f75d22179060 +P 066c8672ee85a6ce972de38fcd3793fc2c1ef4f21c3de2379746d0ff18df8dc0 +R c8830a3ba8018dbbcdef74f3842d2ce5 U drh -Z 82e857c9b07f1185c6a5a8324ed25dc7 +Z fef8cf123496ca8dc33a3e7042cf9e2f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 95611b3402..4f7d53a35f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -066c8672ee85a6ce972de38fcd3793fc2c1ef4f21c3de2379746d0ff18df8dc0 +d5523c77fd0bcdc8344971a116d6ce9657f2b6daddeb7d936cd7607163a36744 diff --git a/test/readonly.test b/test/readonly.test index 1ccbcee284..303300e6f1 100644 --- a/test/readonly.test +++ b/test/readonly.test @@ -15,7 +15,10 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl -if {$tcl_platform(platform)=="windows"} finish_test +if {$tcl_platform(platform)=="windows"} { + finish_test + return +} source $testdir/lock_common.tcl source $testdir/wal_common.tcl set ::testprefix readonly From ad2bcef112a0e36b677e19be625189913352e47e Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 15:04:37 +0000 Subject: [PATCH 0589/1030] Remove obsolete testfixture TCL commands formerly required by Windows but now handled by Tcl itself. Update tests case accordingly. FossilOrigin-Name: 4f065fb638b24b33283518af8ad55f28a49cfac4086fa5e4568e2f3a6814962d --- manifest | 18 ++--- manifest.uuid | 2 +- src/test1.c | 144 ---------------------------------------- test/tester.tcl | 60 ----------------- test/vtabH.test | 4 +- test/win32longpath.test | 18 ++--- 6 files changed, 19 insertions(+), 227 deletions(-) diff --git a/manifest b/manifest index f3dd368582..8ae09e848d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sproblems\suncovered\swhile\stesting\sTcl9\son\sWindows. -D 2024-07-31T13:00:18.912 +C Remove\sobsolete\stestfixture\sTCL\scommands\sformerly\srequired\sby\sWindows\nbut\snow\shandled\sby\sTcl\sitself.\s\sUpdate\stests\scase\saccordingly. +D 2024-07-31T15:04:37.311 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c 6242341191e43952a8ed466b1ee4993cad3a2b93ec3e4a5e826f0b06225a6716 F src/tclsqlite.h 4ed60ea4084b2ea46e19ab13857b3f39d33250ebbf5b2df62b0999bb9b2766b7 -F src/test1.c b0ebd758a5ee92305510bc526448cde3b2015c4ac6e1b7b0c450ba2745cfda24 +F src/test1.c cb27cfe75c7df9d14a10fe34e1f1e2327c294984cc185595b4893c8e2af8ec08 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d @@ -1704,7 +1704,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d1631311a16 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc -F test/tester.tcl 80626ee1ce542f3171a2e64e5d944f9a37ff06386ac325dd8988445494f526b1 +F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef F test/testrunner.tcl 757f79c68f82cad563441d80f02c492465f51cf537336c7b719c3ef45f348911 F test/testrunner_data.tcl 3d36660cfd55ea5e20e661e8f94c0520feebcb437848f9b98b33c483cc479c0c F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 @@ -1962,7 +1962,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test 2a143fe75a11275781d1fd1988d86b66a3f69cb98f4add62e3da8fd0f637b45f F test/vtabF.test 1918844c7c902f6a16c8dacf1ec8f84886d6e78b -F test/vtabH.test 2efb5a24b0bb50796b21eca23032cfb77abfa4b0c03938e38ce5897abac404ca +F test/vtabH.test 8e338acba32207085b6fe9cb2a58f7b408e74c8e1a2964cbdaca903ac82213cc F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtabJ.test a6aef49d558af90fae10565b29501f82a95781cb4f797f2d13e2d19f9b6bc77b F test/vtabK.test 13293177528fada1235c0112db0d187d754af1355c5a39371abd365104e3afbf @@ -2041,7 +2041,7 @@ F test/wherelimit3.test 22d73e046870cf8bbe15573eda6b432b07ebe64a88711f9f849c6b36 F test/widetab1.test c296a98e123762de79917350e45fa33fdf88577a2571eb3a64c8bf7e44ef74d1 F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2aeee74 F test/win32lock.test e0924eb8daac02bf80e9da88930747bd44dd9b230b7759fed927b1655b467c9c -F test/win32longpath.test 4baffc3acb2e5188a5e3a895b2b543ed09e62f7c72d713c1feebf76222fe9976 +F test/win32longpath.test 42210789bcfc5c0ac202643d6d0237db08df2c9218f2070d9a69e8af1eccf7d7 F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc F test/window1.test 79dc3b9a2226f622d7e104a1fc750d1c4c3c08d6147b59085bdbe05352947ffa F test/window2.tcl 492c125fa550cda1dd3555768a2303b3effbeceee215293adf8871efc25f1476 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 066c8672ee85a6ce972de38fcd3793fc2c1ef4f21c3de2379746d0ff18df8dc0 -R c8830a3ba8018dbbcdef74f3842d2ce5 +P d5523c77fd0bcdc8344971a116d6ce9657f2b6daddeb7d936cd7607163a36744 +R 84a489b31a0c3218dd037a53107529be U drh -Z fef8cf123496ca8dc33a3e7042cf9e2f +Z c83bb23b49c74bc693e83c6e007c904e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4f7d53a35f..460e5dce4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d5523c77fd0bcdc8344971a116d6ce9657f2b6daddeb7d936cd7607163a36744 +4f065fb638b24b33283518af8ad55f28a49cfac4086fa5e4568e2f3a6814962d diff --git a/src/test1.c b/src/test1.c index 39249a6c66..861048a9a9 100644 --- a/src/test1.c +++ b/src/test1.c @@ -8061,145 +8061,6 @@ static int SQLITE_TCLAPI win32_file_lock( CloseHandle(ev); return TCL_OK; } - -/* -** exists_win32_path PATH -** -** Returns non-zero if the specified path exists, whose fully qualified name -** may exceed 260 characters if it is prefixed with "\\?\". -*/ -static int SQLITE_TCLAPI win32_exists_path( - void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj *CONST objv[] -){ - if( objc!=2 ){ - Tcl_WrongNumArgs(interp, 1, objv, "PATH"); - return TCL_ERROR; - } - Tcl_SetObjResult(interp, Tcl_NewBooleanObj( - GetFileAttributesW( Tcl_GetUnicode(objv[1]))!=INVALID_FILE_ATTRIBUTES )); - return TCL_OK; -} - -/* -** find_win32_file PATTERN -** -** Returns a list of entries in a directory that match the specified pattern, -** whose fully qualified name may exceed 248 characters if it is prefixed with -** "\\?\". -*/ -static int SQLITE_TCLAPI win32_find_file( - void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj *CONST objv[] -){ - HANDLE hFindFile = INVALID_HANDLE_VALUE; - WIN32_FIND_DATAW findData; - Tcl_Obj *listObj; - DWORD lastErrno; - if( objc!=2 ){ - Tcl_WrongNumArgs(interp, 1, objv, "PATTERN"); - return TCL_ERROR; - } - hFindFile = FindFirstFileW(Tcl_GetUnicode(objv[1]), &findData); - if( hFindFile==INVALID_HANDLE_VALUE ){ - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); - return TCL_ERROR; - } - listObj = Tcl_NewObj(); - Tcl_IncrRefCount(listObj); - do { - Tcl_ListObjAppendElement(interp, listObj, Tcl_NewUnicodeObj( - findData.cFileName, -1)); - Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj( - findData.dwFileAttributes)); - } while( FindNextFileW(hFindFile, &findData) ); - lastErrno = GetLastError(); - if( lastErrno!=NO_ERROR && lastErrno!=ERROR_NO_MORE_FILES ){ - FindClose(hFindFile); - Tcl_DecrRefCount(listObj); - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); - return TCL_ERROR; - } - FindClose(hFindFile); - Tcl_SetObjResult(interp, listObj); - return TCL_OK; -} - -/* -** delete_win32_file FILENAME -** -** Deletes the specified file, whose fully qualified name may exceed 260 -** characters if it is prefixed with "\\?\". -*/ -static int SQLITE_TCLAPI win32_delete_file( - void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj *CONST objv[] -){ - if( objc!=2 ){ - Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); - return TCL_ERROR; - } - if( !DeleteFileW(Tcl_GetUnicode(objv[1])) ){ - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); - return TCL_ERROR; - } - Tcl_ResetResult(interp); - return TCL_OK; -} - -/* -** make_win32_dir DIRECTORY -** -** Creates the specified directory, whose fully qualified name may exceed 248 -** characters if it is prefixed with "\\?\". -*/ -static int SQLITE_TCLAPI win32_mkdir( - void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj *CONST objv[] -){ - if( objc!=2 ){ - Tcl_WrongNumArgs(interp, 1, objv, "DIRECTORY"); - return TCL_ERROR; - } - if( !CreateDirectoryW(Tcl_GetUnicode(objv[1]), NULL) ){ - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); - return TCL_ERROR; - } - Tcl_ResetResult(interp); - return TCL_OK; -} - -/* -** remove_win32_dir DIRECTORY -** -** Removes the specified directory, whose fully qualified name may exceed 248 -** characters if it is prefixed with "\\?\". -*/ -static int SQLITE_TCLAPI win32_rmdir( - void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj *CONST objv[] -){ - if( objc!=2 ){ - Tcl_WrongNumArgs(interp, 1, objv, "DIRECTORY"); - return TCL_ERROR; - } - if( !RemoveDirectoryW(Tcl_GetUnicode(objv[1])) ){ - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); - return TCL_ERROR; - } - Tcl_ResetResult(interp); - return TCL_OK; -} #endif @@ -9294,11 +9155,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "optimization_control", optimization_control,0}, #if SQLITE_OS_WIN { "lock_win32_file", win32_file_lock, 0 }, - { "exists_win32_path", win32_exists_path, 0 }, - { "find_win32_file", win32_find_file, 0 }, - { "delete_win32_file", win32_delete_file, 0 }, - { "make_win32_dir", win32_mkdir, 0 }, - { "remove_win32_dir", win32_rmdir, 0 }, #endif { "tcl_objproc", runAsObjProc, 0 }, diff --git a/test/tester.tcl b/test/tester.tcl index 2c18c4690e..63c83187aa 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -310,66 +310,6 @@ proc do_delete_file {force args} { } } -if {$::tcl_platform(platform) eq "windows"} { - proc do_remove_win32_dir {args} { - set nRetry [getFileRetries] ;# Maximum number of retries. - set nDelay [getFileRetryDelay] ;# Delay in ms before retrying. - - foreach dirName $args { - # On windows, sometimes even a [remove_win32_dir] can fail just after - # a directory is emptied. The cause is usually "tag-alongs" - programs - # like anti-virus software, automatic backup tools and various explorer - # extensions that keep a file open a little longer than we expect, - # causing the delete to fail. - # - # The solution is to wait a short amount of time before retrying the - # removal. - # - if {$nRetry > 0} { - for {set i 0} {$i < $nRetry} {incr i} { - set rc [catch { - remove_win32_dir $dirName - } msg] - if {$rc == 0} break - if {$nDelay > 0} { after $nDelay } - } - if {$rc} { error $msg } - } else { - remove_win32_dir $dirName - } - } - } - - proc do_delete_win32_file {args} { - set nRetry [getFileRetries] ;# Maximum number of retries. - set nDelay [getFileRetryDelay] ;# Delay in ms before retrying. - - foreach fileName $args { - # On windows, sometimes even a [delete_win32_file] can fail just after - # a file is closed. The cause is usually "tag-alongs" - programs like - # anti-virus software, automatic backup tools and various explorer - # extensions that keep a file open a little longer than we expect, - # causing the delete to fail. - # - # The solution is to wait a short amount of time before retrying the - # delete. - # - if {$nRetry > 0} { - for {set i 0} {$i < $nRetry} {incr i} { - set rc [catch { - delete_win32_file $fileName - } msg] - if {$rc == 0} break - if {$nDelay > 0} { after $nDelay } - } - if {$rc} { error $msg } - } else { - delete_win32_file $fileName - } - } - } -} - proc execpresql {handle args} { trace remove execution $handle enter [list execpresql $handle] if {[info exists ::G(perm:presql)]} { diff --git a/test/vtabH.test b/test/vtabH.test index f1a0466554..cf3dcafd9a 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -128,10 +128,10 @@ if {$tcl_platform(platform)=="windows"} { set drive [string range [pwd] 0 1] set ::env(fstreeDrive) $drive } +reset_db +register_fs_module db if {$tcl_platform(platform)!="windows" || \ [regexp -nocase -- {^[A-Z]:} $drive]} { - reset_db - register_fs_module db do_execsql_test 3.0 { SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db'; SELECT name FROM fsdir WHERE dir = '.' AND name = '.' diff --git a/test/win32longpath.test b/test/win32longpath.test index 01b4af70ac..c0eac8d9de 100644 --- a/test/win32longpath.test +++ b/test/win32longpath.test @@ -49,19 +49,19 @@ set longPath(1) \\\\?\\$path\\[pid] set uriPath(1a) %5C%5C%3F%5C$path\\[pid] set uriPath(1b) %5C%5C%3F%5C$rawPath/[pid] -make_win32_dir $longPath(1) +file mkdir $longPath(1) set longPath(2) $longPath(1)\\[string repeat X 255] set uriPath(2a) $uriPath(1a)\\[string repeat X 255] set uriPath(2b) $uriPath(1b)/[string repeat X 255] -make_win32_dir $longPath(2) +file mkdir $longPath(2) set longPath(3) $longPath(2)\\[string repeat Y 255] set uriPath(3a) $uriPath(2a)\\[string repeat Y 255] set uriPath(3b) $uriPath(2b)/[string repeat Y 255] -make_win32_dir $longPath(3) +file mkdir $longPath(3) set fileName $longPath(3)\\test.db @@ -92,7 +92,6 @@ do_test 1.4 { } {5 6 7 8} db3 close -# puts " Database exists \{[exists_win32_path $fileName]\}" sqlite3 db3 $fileName -vfs win32-longpath @@ -115,7 +114,6 @@ do_test 1.6 { } {5 6 7 8 9 10 11 12} db3 close -# puts " Database exists \{[exists_win32_path $fileName]\}" foreach tn {1a 1b 1c 1d 1e 1f} { sqlite3 db3 $uri($tn) -vfs win32-longpath -uri 1 -translatefilename 0 @@ -129,11 +127,9 @@ foreach tn {1a 1b 1c 1d 1e 1f} { db3 close } -do_delete_win32_file $fileName -# puts " Files remaining \{[find_win32_file $longPath(3)\\*]\}" - -do_remove_win32_dir $longPath(3) -do_remove_win32_dir $longPath(2) -do_remove_win32_dir $longPath(1) +file delete -force $fileName +file delete -force $longPath(3) +file delete -force $longPath(2) +file delete -force $longPath(1) finish_test From 8e3042b5657fc41ab1c01881b80754c71b17aa95 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 31 Jul 2024 15:46:41 +0000 Subject: [PATCH 0590/1030] Add missing documentation for new features to fts5.h. FossilOrigin-Name: fa0da3b28e411affd45a918d6b7faba49f744ca8b4adf3cd5ce6609bb630499e --- ext/fts5/fts5.h | 72 ++++++++++++++++++++++++++++++++++++------------- manifest | 14 +++++----- manifest.uuid | 2 +- 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index ecdb944f68..2f6c387760 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -317,10 +317,11 @@ struct Fts5PhraseIter { ** with column iCol of the current row. Usually, there is no associated ** locale, and output parameters (*pzLocale) and (*pnLocale) are set ** to NULL and 0, respectively. However, if the fts5_locale() function -** was used to associated a locale with the value when it was inserted -** into the fts5 table, then (*pzLocale) is set to point to a buffer -** containing the name of the locale in utf-8 encoding. (*pnLocale) is -** set to the size in bytes of the buffer. +** was used to associate a locale with the value when it was inserted +** into the fts5 table, then (*pzLocale) is set to point to a nul-terminated +** buffer containing the name of the locale in utf-8 encoding. (*pnLocale) +** is set to the size in bytes of the buffer, not including the +** nul-terminator. ** ** If successful, SQLITE_OK is returned. Or, if an error occurs, an ** SQLite error code is returned. The final value of the output parameters @@ -333,7 +334,7 @@ struct Fts5PhraseIter { ** ** Parameters pLocale and nLocale may both be 0, in which case the tokenizer ** is configured to use its default locale. Otherwise, pLocale should point -** to a buffer containing the name of the locale to use encoded as utf-8. +** to a buffer containing the utf-8 encoded name of the locale to use. ** It does not have to be nul-terminated. nLocale must be passed the size ** of the text in bytes. The buffer indicated by pLocale must remain valid ** for the duration of any calls made to xTokenize() by the auxiliary @@ -388,8 +389,7 @@ struct Fts5ExtensionApi { /* Below this point are iVersion>=4 only */ int (*xColumnLocale)(Fts5Context*, int iCol, const char **pz, int *pn); - - int (*xTokenizeSetLocale)(Fts5Context*, const char *z, int n); + int (*xTokenizeSetLocale)(Fts5Context*, const char *p, int n); }; /* @@ -401,16 +401,17 @@ struct Fts5ExtensionApi { ** ** Applications may also register custom tokenizer types. A tokenizer ** is registered by providing fts5 with a populated instance of the -** following structure. All structure methods must be defined, setting -** any member of the fts5_tokenizer struct to NULL leads to undefined -** behaviour. The structure methods are expected to function as follows: +** following structure. Of the three structure methods, xCreate, xDelete and +** xTokenize must be supplied, any fo these three members of the +** fts5_tokenizer_v2 struct to NULL leads to undefined behaviour. The +** structure methods are expected to function as follows: ** ** xCreate: ** This function is used to allocate and initialize a tokenizer instance. ** A tokenizer instance is required to actually tokenize text. ** ** The first argument passed to this function is a copy of the (void*) -** pointer provided by the application when the fts5_tokenizer object +** pointer provided by the application when the fts5_tokenizer_v2 object ** was registered with FTS5 (the third argument to xCreateTokenizer()). ** The second and third arguments are an array of nul-terminated strings ** containing the tokenizer arguments, if any, specified following the @@ -481,6 +482,33 @@ struct Fts5ExtensionApi { ** may abandon the tokenization and return any error code other than ** SQLITE_OK or SQLITE_DONE. ** +** xSetLocale: +** This function is invoked by FTS5 to configure the locale to use for +** subsequent calls to xTokenize. The second argument is a pointer to +** a nul-terminated buffer containing the utf-8 encoded name of the locale +** to use. The third argument is the size of the buffer in bytes, not +** including the nul-terminator character. This function may also be +** invoked with the second and third parameters set to 0 - instructing +** the tokenizer to use its default locale. +** +** FTS5 guarantees that any buffer passed to xSetLocale() will remain +** valid until either the next call to xSetLocale() or xDelete() on the +** same tokenizer object. +** +** This function should return SQLITE_OK if successful, or an SQLite +** error code if an error occurs. If an error does occur and an error +** code is returned, execution of the current statement is abandoned +** and FTS5 returns the error code to the caller. +** +** Often, this function is not required and is never invoked. It is only +** ever invoked when processing a value that has had a locale associated +** with it using SQL function fts5_locale(). +** +** It is not necessary to supply an implementation of this method when +** registering a tokenizer. If fts5_tokenizer_v2.xSetLocale is set to NULL, +** then no attempt is made to pass locale information through to the +** tokenizer. +** ** SYNONYM SUPPORT ** ** Custom tokenizers may also support synonyms. Consider a case in which a @@ -589,8 +617,10 @@ struct Fts5ExtensionApi { ** inefficient. */ typedef struct Fts5Tokenizer Fts5Tokenizer; -typedef struct fts5_tokenizer fts5_tokenizer; -struct fts5_tokenizer { +typedef struct fts5_tokenizer_v2 fts5_tokenizer_v2; +struct fts5_tokenizer_v2 { + int iVersion; /* Currently always 2 */ + int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); void (*xDelete)(Fts5Tokenizer*); int (*xTokenize)(Fts5Tokenizer*, @@ -606,12 +636,17 @@ struct fts5_tokenizer { int iEnd /* Byte offset of end of token within input text */ ) ); -}; -typedef struct fts5_tokenizer_v2 fts5_tokenizer_v2; -struct fts5_tokenizer_v2 { - int iVersion; /* Currently always 2 */ + int (*xSetLocale)(Fts5Tokenizer*, const char *pLocale, int nLocale); +}; +/* +** New code should use the fts5_tokenizer_v2 type to define tokenizer +** implementations. The following type is included for legacy applications +** that still use it. +*/ +typedef struct fts5_tokenizer fts5_tokenizer; +struct fts5_tokenizer { int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); void (*xDelete)(Fts5Tokenizer*); int (*xTokenize)(Fts5Tokenizer*, @@ -627,10 +662,9 @@ struct fts5_tokenizer_v2 { int iEnd /* Byte offset of end of token within input text */ ) ); - - int (*xSetLocale)(Fts5Tokenizer*, const char *pLocale, int nLocale); }; + /* Flags that may be passed as the third argument to xTokenize() */ #define FTS5_TOKENIZE_QUERY 0x0001 #define FTS5_TOKENIZE_PREFIX 0x0002 diff --git a/manifest b/manifest index a08c7ec6c7..a18841d7c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\slatest\schanges\sfrom\strunk\sinto\sthis\sbranch. -D 2024-07-31T10:52:38.878 +C Add\smissing\sdocumentation\sfor\snew\sfeatures\sto\sfts5.h. +D 2024-07-31T15:46:41.319 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,7 +92,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h 7cd47e5dfe68d798e667caa76722374f0c909f2db05bb4d42b1ec5300d18e658 +F ext/fts5/fts5.h f5451da088d0004c4be7314e2fdb41fda16ce682ce2aa3b54b9474ebe9a013d5 F ext/fts5/fts5Int.h 833a2fe729f926ebcde47e21e495d141b99ede9a188fc577873f24bea0f0bfa2 F ext/fts5/fts5_aux.c 652f839dc0c77431295f10b08f268631560bb5630e65fd701de7a58744428a82 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 @@ -604,7 +604,7 @@ F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ce F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth 7ac80cc3b6a6d52e041bb295e85555ce797be78c15ef2008a64ae58815014080 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 400213eb52a7e5ad5f448053d375cacf4dac2cf45d134f3edfe485ae4a49a183 w ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 400213eb52a7e5ad5f448053d375cacf4dac2cf45d134f3edfe485ae4a49a183 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate d1d62a2212099f2c0782d730beb8cb84a7a52d99c15ead2cb9b1411fff5fd6b1 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session 213b6c04267cb9bd760172db011eb1650732805fb3d01f9395478a8ceec18eb0 @@ -2201,8 +2201,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ae435aff1785d5832821c19dc88ccf6c496a7ff55be80276b31e5c9abee723db 86de4e755e37dc1cbcbd59018927aa87ff49fc15f706a36187631d8f14075c12 -R 854c24bb1cc78c16c421b7985fead9f3 +P ff64939ec8399949393f1029fa6d514892fbf2bf1498545300cc5e120b9622a5 +R f7dbcf0c98ed562d42b896f7c143383b U dan -Z 7ee036ea576e2778dfe1b42f432458d4 +Z 344ab71a9372cfa91d638c7c0c606714 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2864ea1b96..a1e4d24ea7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff64939ec8399949393f1029fa6d514892fbf2bf1498545300cc5e120b9622a5 +fa0da3b28e411affd45a918d6b7faba49f744ca8b4adf3cd5ce6609bb630499e From ff79000f28f4d98cf6a7867bcb264f39f0af3883 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 16:37:02 +0000 Subject: [PATCH 0591/1030] Fix a typo in testrunner_data.tcl that prevented --with-tcl specifications from being carried through into sub-builds. Adjust test cases to account for new floating-point differences discovered when --with-tcl was fixed. FossilOrigin-Name: b8f81351914deac99b14be6bb5e4096c1efed9bdb057750825760f09dae04656 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/func7.test | 4 ++-- test/testrunner_data.tcl | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 8ae09e848d..a82aeee292 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sobsolete\stestfixture\sTCL\scommands\sformerly\srequired\sby\sWindows\nbut\snow\shandled\sby\sTcl\sitself.\s\sUpdate\stests\scase\saccordingly. -D 2024-07-31T15:04:37.311 +C Fix\sa\stypo\sin\stestrunner_data.tcl\sthat\sprevented\s--with-tcl\sspecifications\nfrom\sbeing\scarried\sthrough\sinto\ssub-builds.\s\sAdjust\stest\scases\sto\saccount\nfor\snew\sfloating-point\sdifferences\sdiscovered\swhen\s--with-tcl\swas\sfixed. +D 2024-07-31T16:37:02.026 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1248,7 +1248,7 @@ F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5 F test/func5.test 863e6d1bd0013d09c17236f8a13ea34008dd857d87d85a13a673960e4c25d82a F test/func6.test 3bc89ec0f2605736d3a118f43d25ef58115a7db4dba8ae939a363917d815c0bb -F test/func7.test 38d882ca14f3ec178b50d9354e6bb092c7dc8e1c30c9e4ac62b8f3e6a0b6a7d9 +F test/func7.test 7e009275f52c52954c8c028fdb62f8bc16cc47276fcc8753c1d2b22c6e074598 F test/func8.test c4e2ecacf9f16e47a245e7a25fbabcc7e78f9c7c41a80f158527cdfdc6dd299d F test/func9.test b32d313f679aa9698d52f39519d301c3941823cb72b4e23406c210eadd82c824 F test/fuzz-oss1.test 514dcabb24687818ea949fa6760229eaacad74ca70157743ef36d35bbe01ffb0 @@ -1706,7 +1706,7 @@ F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef F test/testrunner.tcl 757f79c68f82cad563441d80f02c492465f51cf537336c7b719c3ef45f348911 -F test/testrunner_data.tcl 3d36660cfd55ea5e20e661e8f94c0520feebcb437848f9b98b33c483cc479c0c +F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d5523c77fd0bcdc8344971a116d6ce9657f2b6daddeb7d936cd7607163a36744 -R 84a489b31a0c3218dd037a53107529be +P 4f065fb638b24b33283518af8ad55f28a49cfac4086fa5e4568e2f3a6814962d +R 0eeaa8c9fa32916768afe9b85f481a38 U drh -Z c83bb23b49c74bc693e83c6e007c904e +Z 0225a9df2e84c769557dd80358cb5fb8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 460e5dce4a..1ba77fbb64 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f065fb638b24b33283518af8ad55f28a49cfac4086fa5e4568e2f3a6814962d +b8f81351914deac99b14be6bb5e4096c1efed9bdb057750825760f09dae04656 diff --git a/test/func7.test b/test/func7.test index af1a2e0227..6026b557f5 100644 --- a/test/func7.test +++ b/test/func7.test @@ -100,13 +100,13 @@ do_execsql_test func7-pg-300 { SELECT acos(1); } {0.0} do_execsql_test func7-pg-301 { - SELECT degrees(acos(0.5)); + SELECT format('%f',degrees(acos(0.5))); } {60.0} do_execsql_test func7-pg-310 { SELECT round( asin(1), 7); } {1.5707963} do_execsql_test func7-pg-311 { - SELECT degrees( asin(0.5) ); + SELECT format('%f',degrees( asin(0.5) )); } {30.0} do_execsql_test func7-pg-320 { SELECT round( atan(1), 7); diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index f8f12d91a7..af480fc4cf 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -486,7 +486,7 @@ proc make_sh_script {srcdir opts cflags makeOpts configOpts} { TCLDIR="$tcldir" if [ ! -f Makefile ] ; then - \$SRCDIR/configure --with-tcl=\$TCL $configOpts + \$SRCDIR/configure --with-tcl=\$TCLDIR $configOpts fi $myopts From 15fef79a2989421215d8cea11a4501992c4a8770 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 17:15:24 +0000 Subject: [PATCH 0592/1030] Fixes to testfixture routines needed to test snapshots. FossilOrigin-Name: 66f61c3b35383b2575774d309043a722cc87a53d03518d339d6dbdcf342adc93 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test1.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index a82aeee292..52cc27c77b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\stestrunner_data.tcl\sthat\sprevented\s--with-tcl\sspecifications\nfrom\sbeing\scarried\sthrough\sinto\ssub-builds.\s\sAdjust\stest\scases\sto\saccount\nfor\snew\sfloating-point\sdifferences\sdiscovered\swhen\s--with-tcl\swas\sfixed. -D 2024-07-31T16:37:02.026 +C Fixes\sto\stestfixture\sroutines\sneeded\sto\stest\ssnapshots. +D 2024-07-31T17:15:24.049 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c 6242341191e43952a8ed466b1ee4993cad3a2b93ec3e4a5e826f0b06225a6716 F src/tclsqlite.h 4ed60ea4084b2ea46e19ab13857b3f39d33250ebbf5b2df62b0999bb9b2766b7 -F src/test1.c cb27cfe75c7df9d14a10fe34e1f1e2327c294984cc185595b4893c8e2af8ec08 +F src/test1.c 78b1f09c410ccc88d55c9fc7d4128a8ff5006b7118cf640458e6df1893ec6e24 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4f065fb638b24b33283518af8ad55f28a49cfac4086fa5e4568e2f3a6814962d -R 0eeaa8c9fa32916768afe9b85f481a38 +P b8f81351914deac99b14be6bb5e4096c1efed9bdb057750825760f09dae04656 +R ed4a46e87468bba46f614d62afb17c20 U drh -Z 0225a9df2e84c769557dd80358cb5fb8 +Z 3a09c9e2a0ce88f1333ee44d49cfbdb9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1ba77fbb64..a85299e50f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8f81351914deac99b14be6bb5e4096c1efed9bdb057750825760f09dae04656 +66f61c3b35383b2575774d309043a722cc87a53d03518d339d6dbdcf342adc93 diff --git a/src/test1.c b/src/test1.c index 861048a9a9..a246baafa1 100644 --- a/src/test1.c +++ b/src/test1.c @@ -2762,7 +2762,7 @@ static int SQLITE_TCLAPI test_snapshot_open_blob( sqlite3 *db; char *zName; unsigned char *pBlob; - int nBlob; + Tcl_Size nBlob; if( objc!=4 ){ Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SNAPSHOT"); @@ -2797,8 +2797,8 @@ static int SQLITE_TCLAPI test_snapshot_cmp_blob( int res; unsigned char *p1; unsigned char *p2; - int n1; - int n2; + Tcl_Size n1; + Tcl_Size n2; if( objc!=3 ){ Tcl_WrongNumArgs(interp, 1, objv, "SNAPSHOT1 SNAPSHOT2"); From a7382d35231e81ccab2fe42161e5590c90e8b629 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 19:56:14 +0000 Subject: [PATCH 0593/1030] Under Tcl9, the %x format letter truncates to 32-bits. Must use %llx in order to get a 64-bit rendering. FossilOrigin-Name: a3044e0ae65c099d76bf04536e223e70d89971688627c342252951f6c65f49d1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/scanstatus2.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 52cc27c77b..9f60154a7c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sto\stestfixture\sroutines\sneeded\sto\stest\ssnapshots. -D 2024-07-31T17:15:24.049 +C Under\sTcl9,\sthe\s%x\sformat\sletter\struncates\sto\s32-bits.\s\sMust\suse\s%llx\sin\sorder\nto\sget\sa\s64-bit\srendering. +D 2024-07-31T19:56:14.739 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1573,7 +1573,7 @@ F test/savepoint6.test f41279c5e137139fa5c21485773332c7adb98cd7 F test/savepoint7.test cde525ea3075283eb950cdcdefe23ead4f700daa F test/savepointfault.test f044eac64b59f09746c7020ee261734de82bf9b2 F test/scanstatus.test b249328caf4d317e71058006872b8012598a5fa045b30bf24a81eeff650ab49e -F test/scanstatus2.test 688adc0c3ab1ffadead218cbce6446b10aa892004a8ea5e3640d59257fb836f2 +F test/scanstatus2.test d85d17f2b0b4c013dde95232f7beab749f11f0ef847f5ecffb9486d2f5ecf9f9 F test/schema.test 5dd11c96ba64744de955315d2e4f8992e447533690153b93377dffb2a5ef5431 F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5 F test/schema3.test 8ed4ae66e082cdd8b1b1f22d8549e1e7a0db4527a8e6ee8b6193053ee1e5c9ce @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b8f81351914deac99b14be6bb5e4096c1efed9bdb057750825760f09dae04656 -R ed4a46e87468bba46f614d62afb17c20 +P 66f61c3b35383b2575774d309043a722cc87a53d03518d339d6dbdcf342adc93 +R 3754410baf7d81a240b5f3745d6a91b6 U drh -Z 3a09c9e2a0ce88f1333ee44d49cfbdb9 +Z f4de28c04f76ade84e47b56a0971adc2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a85299e50f..9d482f6a5e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -66f61c3b35383b2575774d309043a722cc87a53d03518d339d6dbdcf342adc93 +a3044e0ae65c099d76bf04536e223e70d89971688627c342252951f6c65f49d1 diff --git a/test/scanstatus2.test b/test/scanstatus2.test index 7f107cd2eb..c94db88f23 100644 --- a/test/scanstatus2.test +++ b/test/scanstatus2.test @@ -265,7 +265,7 @@ ifcapable trace { } proc trace {stmt sql} { - array set A [sqlite3_stmt_scanstatus -flags complex [format %x $stmt] 0] + array set A [sqlite3_stmt_scanstatus -flags complex [format %llx $stmt] 0] lappend ::trace_explain $A(zExplain) } db trace_v2 trace From ed1b616f4a07559fdaaa1668567990ff122ff439 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 19:57:22 +0000 Subject: [PATCH 0594/1030] More tweaks to testfixture-implemented TCL commands to make them safe for Tcl9. FossilOrigin-Name: 67897ca97d8c98e119a498a3adb39548a579e12ee477e9dd74e9564a6f5e4c2b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test1.c | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 9f60154a7c..f8763a7bff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Under\sTcl9,\sthe\s%x\sformat\sletter\struncates\sto\s32-bits.\s\sMust\suse\s%llx\sin\sorder\nto\sget\sa\s64-bit\srendering. -D 2024-07-31T19:56:14.739 +C More\stweaks\sto\stestfixture-implemented\sTCL\scommands\sto\smake\sthem\ssafe\sfor\sTcl9. +D 2024-07-31T19:57:22.447 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c 6242341191e43952a8ed466b1ee4993cad3a2b93ec3e4a5e826f0b06225a6716 F src/tclsqlite.h 4ed60ea4084b2ea46e19ab13857b3f39d33250ebbf5b2df62b0999bb9b2766b7 -F src/test1.c 78b1f09c410ccc88d55c9fc7d4128a8ff5006b7118cf640458e6df1893ec6e24 +F src/test1.c 51159784f29d3dfd4b50fd6ed9c43c8f7f36925c501a3ad3083528e5e5544bd7 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 66f61c3b35383b2575774d309043a722cc87a53d03518d339d6dbdcf342adc93 -R 3754410baf7d81a240b5f3745d6a91b6 +P a3044e0ae65c099d76bf04536e223e70d89971688627c342252951f6c65f49d1 +R 0254aafb585571107527e25f3f3685a5 U drh -Z f4de28c04f76ade84e47b56a0971adc2 +Z 7b3931730652d7e33f08dab109d8bc57 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9d482f6a5e..814d44eaf0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a3044e0ae65c099d76bf04536e223e70d89971688627c342252951f6c65f49d1 +67897ca97d8c98e119a498a3adb39548a579e12ee477e9dd74e9564a6f5e4c2b diff --git a/src/test1.c b/src/test1.c index a246baafa1..88bfdc06d2 100644 --- a/src/test1.c +++ b/src/test1.c @@ -2335,13 +2335,13 @@ static int SQLITE_TCLAPI test_stmt_scanstatus( }; Tcl_Obj **aFlag = 0; - int nFlag = 0; + Tcl_Size nFlag = 0; int ii; if( Tcl_ListObjGetElements(interp, objv[2], &nFlag, &aFlag) ){ return TCL_ERROR; } - for(ii=0; ii Date: Wed, 31 Jul 2024 20:49:00 +0000 Subject: [PATCH 0595/1030] Fix various problems with the code on this branch. FossilOrigin-Name: 8bd4ae7e95c7b6ce34db5ea705dc136e742a22f333d0e7370b485ebd736b5ec2 --- ext/fts5/fts5Int.h | 16 ++- ext/fts5/fts5_aux.c | 2 + ext/fts5/fts5_config.c | 12 +- ext/fts5/fts5_main.c | 221 ++++++++++++++++++++++++++++-------- ext/fts5/fts5_storage.c | 19 ++-- ext/fts5/test/fts5blob.test | 16 ++- manifest | 22 ++-- manifest.uuid | 2 +- 8 files changed, 235 insertions(+), 75 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 14140658b2..53e269df93 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -206,6 +206,14 @@ struct Fts5TokenizerConfig { ** ** INSERT INTO tbl(tbl, rank) VALUES('prefix-index', $bPrefixIndex); ** +** bLocale: +** Set to true if locale=1 was specified when the table was created. +** +** eEnc: +** Set to either FTS5_ENCODING_UNKNOWN, ENCODING_UTF8, or ENCODING_UTF16, +** to indicate the encoding used by the database handle. This is initially +** set to UNKNOWN, then to one of the other two values the first time it +** is required. */ struct Fts5Config { sqlite3 *db; /* Database handle */ @@ -270,6 +278,10 @@ struct Fts5Config { #define FTS5_PATTERN_LIKE 65 /* matches SQLITE_INDEX_CONSTRAINT_LIKE */ #define FTS5_PATTERN_GLOB 66 /* matches SQLITE_INDEX_CONSTRAINT_GLOB */ +#define FTS5_ENCODING_UNKNOWN 0 +#define FTS5_ENCODING_UTF8 1 +#define FTS5_ENCODING_UTF16 2 + int sqlite3Fts5ConfigParse( Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char** ); @@ -634,9 +646,9 @@ int sqlite3Fts5FlushToDisk(Fts5Table*); int sqlite3Fts5ExtractText( Fts5Config *pConfig, - int bContent, /* Loaded from content table */ sqlite3_value *pVal, /* Value to extract text from */ - int *pbResetTokenizer, /* OUT: True if xSetLocale(NULL) required */ + int bContent, /* Loaded from content table */ + int *pbResetTokenizer, /* OUT: True if ClearLocale() required */ const char **ppText, /* OUT: Pointer to text buffer */ int *pnText /* OUT: Size of (*ppText) in bytes */ ); diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c index e2226e3f03..8695369f5e 100644 --- a/ext/fts5/fts5_aux.c +++ b/ext/fts5/fts5_aux.c @@ -239,6 +239,8 @@ static int fts5ConfigureTokenizer( const char *zLocale = 0; int nLocale = 0; + assert( pApi->iVersion>=4 ); /* Ensure xColumnLocale() is available */ + rc = pApi->xColumnLocale(pFts, iCol, &zLocale, &nLocale); if( rc==SQLITE_OK ){ rc = pApi->xTokenizeSetLocale(pFts, zLocale, nLocale); diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 3736f8685f..1312f459db 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -615,7 +615,9 @@ int sqlite3Fts5ConfigParse( sqlite3_free(zTwo); } - /* If this is not an FTS5_CONTENT_NORMAL table, set bLocale */ + /* If this is not an FTS5_CONTENT_NORMAL table, set bLocale. There are + ** no restrictions on using fts5_locale() with external-content or + ** contentless tables. */ if( pRet->eContent!=FTS5_CONTENT_NORMAL ){ pRet->bLocale = 1; } @@ -1028,7 +1030,7 @@ int sqlite3Fts5ConfigLoad(Fts5Config *pConfig, int iCookie){ rc = SQLITE_ERROR; if( pConfig->pzErrmsg ){ assert( 0==*pConfig->pzErrmsg ); - *pConfig->pzErrmsg = sqlite3_mprintf("invalid fts5 file format " + sqlite3Fts5ConfigErrmsg(pConfig, "invalid fts5 file format " "(found %d, expected %d or %d) - run 'rebuild'", iVersion, FTS5_CURRENT_VERSION, FTS5_CURRENT_VERSION_SECUREDELETE ); @@ -1043,6 +1045,11 @@ int sqlite3Fts5ConfigLoad(Fts5Config *pConfig, int iCookie){ return rc; } +/* +** Set (*pConfig->pzErrmsg) to point to an sqlite3_malloc()ed buffer +** containing the error message created using printf() style formatting +** string zFmt and its trailing arguments. +*/ void sqlite3Fts5ConfigErrmsg(Fts5Config *pConfig, const char *zFmt, ...){ va_list ap; /* ... printf arguments */ char *zMsg = 0; @@ -1050,6 +1057,7 @@ void sqlite3Fts5ConfigErrmsg(Fts5Config *pConfig, const char *zFmt, ...){ va_start(ap, zFmt); zMsg = sqlite3_vmprintf(zFmt, ap); if( pConfig->pzErrmsg ){ + assert( *pConfig->pzErrmsg==0 ); *pConfig->pzErrmsg = zMsg; }else{ sqlite3_free(zMsg); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 673a44d139..c9c01aafea 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -124,10 +124,6 @@ struct Fts5FullTable { #endif }; -#define FTS5_ENCODING_UNKNOWN 0 -#define FTS5_ENCODING_UTF8 1 -#define FTS5_ENCODING_UTF16 2 - struct Fts5MatchPhrase { Fts5Buffer *pPoslist; /* Pointer to current poslist */ int nTerm; /* Size of phrase in terms */ @@ -169,6 +165,12 @@ struct Fts5Sorter { ** If the cursor iterates in descending order of rowid, iFirstRowid ** is the upper limit (i.e. the "first" rowid visited) and iLastRowid ** the lower. +** +** pLocale, nLocale: +** These are set by API method xTokenizeSetLocale(). xTokenizeSetLocale() +** does not actually configure the tokenizer, it just stores the values +** it is passed in these variables. The fts5_tokenizer_v2.xSetLocale() +** method is called from within the xTokenize() API method if required. */ struct Fts5Cursor { sqlite3_vtab_cursor base; /* Base class used by SQLite core */ @@ -238,6 +240,9 @@ struct Fts5Cursor { #define BitFlagAllTest(x,y) (((x) & (y))==(y)) #define BitFlagTest(x,y) (((x) & (y))!=0) +/* +** The subtype values returned by fts5_locale() are tagged with. +*/ #define FTS5_LOCALE_SUBTYPE ((unsigned int)'L') @@ -1003,7 +1008,7 @@ static int fts5PrepareStatement( rc = sqlite3_prepare_v3(pConfig->db, zSql, -1, SQLITE_PREPARE_PERSISTENT, &pRet, 0); if( rc!=SQLITE_OK ){ - *pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db)); + sqlite3Fts5ConfigErrmsg(pConfig, "%s", sqlite3_errmsg(pConfig->db)); } sqlite3_free(zSql); } @@ -1238,7 +1243,11 @@ static void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){ va_end(ap); } - +/* +** Configure the tokenizer to use the locale specified by nLocale byte +** buffer zLocale. Return SQLITE_OK if successful, or an SQLite error +** code otherwise. +*/ static int fts5SetLocale( Fts5Config *pConfig, const char *zLocale, @@ -1252,11 +1261,27 @@ static int fts5SetLocale( return rc; } +/* +** Reset the locale of the tokenizer to its default. +*/ void sqlite3Fts5ClearLocale(Fts5Config *pConfig){ fts5SetLocale(pConfig, 0, 0); } -static int fts5IsUtf16(Fts5Config *pConfig, int *pbIs){ +/* +** This function is used to determine if the database handle uses utf-8 or +** a utf-16 encoding. If it uses utf-8, then output parameter (*pbIs) is set +** to 0. Otherwise, if it uses utf-16, then the output parameter is set +** to 1. +** +** This function returns SQLITE_OK if successful, or an SQLite error code +** otherwise. If an error code is returned, the final value of (*pbIs) is +** undefined. +*/ +static int fts5IsUtf16( + Fts5Config *pConfig, /* Configuration object */ + int *pbIs /* OUT: True if utf-16, false if utf-8 */ +){ if( pConfig->eEnc==FTS5_ENCODING_UNKNOWN ){ sqlite3_stmt *pPragma = 0; int rc = fts5PrepareStatement(&pPragma, pConfig, @@ -1280,10 +1305,57 @@ static int fts5IsUtf16(Fts5Config *pConfig, int *pbIs){ return SQLITE_OK; } +/* +** This function is used to extract utf-8 text from an sqlite3_value. This +** is usually done in order to tokenize it. For example, when: +** +** * a value is written to an fts5 table, +** * a value is deleted from an FTS5_CONTENT_NORMAL table, +** * a value containing a query expression is passed to xFilter() +** +** and so on. +** +** This function handles 3 cases: +** +** 1) Ordinary values. The text can be extracted from these using +** sqlite3_value_text(). +** +** 2) Blobs tagged with sub-type FTS5_LOCALE_SUBTYPE, or those read from +** the content table of an FTS5_CONTENT_NORMAL table with locale=1 +** set that do not begin with 0x00. +** +** In these cases the value is a blob formatted by fts5_locale() that +** contains both a locale and a text value. The locale is first, as +** utf-8, followed by a single 0x00 byte, followed by the text value, +** also as utf-8. There is no nul-terminator for the text value. +** +** 3) Blobs read from the content table of an FTS5_CONTENT_NORMAL table +** with locale=1 set that do begin with 0x00. These are used to +** store actual SQLITE_BLOB values written to the fts5 table by the +** user. They begin with 4 0x00 bytes, followed by the blob data as +** specified by the user. +** +** If successful, SQLITE_OK is returned and output parameters (*ppText) +** and (*pnText) are set to point to a buffer containing the extracted utf-8 +** text and its length in bytes, respectively. The buffer is not +** nul-terminated. It has the same lifetime as the sqlite3_value object +** from which it is extracted. +** +** Parameter bContent must be true if the value was read from an indexed +** column (i.e. not UNINDEXED) of the on disk content. In this case, if +** the table is FTS5_CONTENT_NORMAL and locale=1 was specified, special blob +** cases (2) and (3) above will apply. +** +** If pbResetTokenizer is not NULL and if case (2) is used, then the +** tokenizer is configured to use the locale. In this case (*pbResetTokenizer) +** is set to true before returning, to indicate that the caller must +** call sqlite3Fts5ClearLocale() to reset the tokenizer after tokenizing +** the text. +*/ int sqlite3Fts5ExtractText( Fts5Config *pConfig, - int bContent, sqlite3_value *pVal, /* Value to extract text from */ + int bContent, /* True if indexed table content */ int *pbResetTokenizer, /* OUT: True if xSetLocale(NULL) required */ const char **ppText, /* OUT: Pointer to text buffer */ int *pnText /* OUT: Size of (*ppText) in bytes */ @@ -1309,11 +1381,23 @@ int sqlite3Fts5ExtractText( int nLocale = 0; if( nBlob>=4 && memcmp(pBlob, "\0\0\0\0", 4)==0 ){ - int bIs16 = 0; + /* Extract the text from a blob stored in a locale=1 table. The + ** value consists of 4 0x00 bytes followed by the blob specified + ** by the user. The extracted text has to match the text extracted + ** when the blob was inserted - by calling sqlite3_value_text() on + ** the value without the 4 0x00 byte header. + ** + ** The tricky bit here is that the exact text extracted from a blob + ** depends on the encoding of the database. To avoid reimplementing + ** SQLite's blob-to-text conversion code here, we call + ** sqlite3_value_text() on the blob with the header, then trim off the + ** leading utf-8 characters that the 4 byte header was converted to. In + ** practice this is 4 0x00 bytes for a utf-8 database, or 2 0x00 bytes + ** for a utf-16 database. */ + int bIs16 = 0; /* True for utf-16 database */ pText = (const char*)sqlite3_value_text(pVal); nText = sqlite3_value_bytes(pVal); rc = fts5IsUtf16(pConfig, &bIs16); - if( bIs16 ){ pText += 2; nText -= 2; @@ -1321,7 +1405,6 @@ int sqlite3Fts5ExtractText( pText += 4; nText -= 4; } - }else{ for(nLocale=0; nLocalep.pConfig, 0, pVal, &bReset, &zText,&nText); + rc = sqlite3Fts5ExtractText(pTab->p.pConfig, pVal, 0, &bReset, &zText,&nText); if( rc==SQLITE_OK ){ if( bReset ){ *pzText = sqlite3Fts5Mprintf(&rc, "%.*s", nText, zText); @@ -1930,16 +2012,12 @@ static int fts5UpdateMethod( else{ int eType1 = sqlite3_value_numeric_type(apVal[1]); - if( (eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL) - || (eType0==SQLITE_INTEGER && eType1==SQLITE_NULL) - ){ - rc = SQLITE_MISMATCH; - } - - else if( eType0!=SQLITE_INTEGER ){ + if( eType0!=SQLITE_INTEGER ){ /* An INSERT statement. If the conflict-mode is REPLACE, first remove ** the current entry (if any). */ - if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ + if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){ + rc = SQLITE_MISMATCH; + }else if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0); bUpdateOrDelete = 1; @@ -1951,8 +2029,9 @@ static int fts5UpdateMethod( else{ i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */ i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */ - assert( eType1==SQLITE_INTEGER ); - if( iOld!=iNew ){ + if( eType1!=SQLITE_INTEGER ){ + rc = SQLITE_MISMATCH; + }else if( iOld!=iNew ){ if( eConflict==SQLITE_REPLACE ){ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1); if( rc==SQLITE_OK ){ @@ -2126,12 +2205,9 @@ static int fts5ApiColumnText( rc = fts5SeekCursor(pCsr, 0); if( rc==SQLITE_OK ){ Fts5Config *pConfig = pTab->pConfig; - int bContent = ( - pConfig->bLocale && pConfig->abUnindexed[iCol]==0 && - pConfig->eContent==FTS5_CONTENT_NORMAL - ); + int bContent = (pConfig->abUnindexed[iCol]==0); sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); - sqlite3Fts5ExtractText(pConfig, bContent, pVal, 0, pz, pn); + sqlite3Fts5ExtractText(pConfig, pVal, bContent, 0, pz, pn); } } return rc; @@ -2346,14 +2422,13 @@ static int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){ rc = fts5SeekCursor(pCsr, 0); for(i=0; rc==SQLITE_OK && inCol; i++){ if( pConfig->abUnindexed[i]==0 ){ - const int bContent = (pConfig->eContent==FTS5_CONTENT_NORMAL); const char *z = 0; int n = 0; int bReset = 0; sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, i+1); pCsr->aColumnSize[i] = 0; - rc = sqlite3Fts5ExtractText(pConfig, bContent, pVal, &bReset, &z, &n); + rc = sqlite3Fts5ExtractText(pConfig, pVal, 1, &bReset, &z, &n); if( rc==SQLITE_OK ){ rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_AUX, z, n, (void*)&pCsr->aColumnSize[i], fts5ColumnSizeCb @@ -2602,6 +2677,9 @@ static int fts5ApiQueryPhrase(Fts5Context*, int, void*, int(*)(const Fts5ExtensionApi*, Fts5Context*, void*) ); +/* +** The xColumnLocale() API. +*/ static int fts5ApiColumnLocale( Fts5Context *pCtx, int iCol, @@ -2617,24 +2695,34 @@ static int fts5ApiColumnLocale( if( iCol<0 || iCol>=pConfig->nCol ){ rc = SQLITE_RANGE; - }else{ - int bNormal = (pConfig->eContent==FTS5_CONTENT_NORMAL); - if( pConfig->abUnindexed[iCol]==0 - && pCsr->ePlan!=FTS5_PLAN_SPECIAL - && pConfig->eContent!=FTS5_CONTENT_NONE - && (bNormal==0 || pConfig->bLocale) - ){ - rc = fts5SeekCursor(pCsr, 0); - if( rc==SQLITE_OK ){ - sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); - if( sqlite3_value_type(pVal)==SQLITE_BLOB - && (bNormal || sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE) + }else if( + pConfig->abUnindexed[iCol]==0 + && pCsr->ePlan!=FTS5_PLAN_SPECIAL + && pConfig->eContent!=FTS5_CONTENT_NONE + && pConfig->bLocale + ){ + rc = fts5SeekCursor(pCsr, 0); + if( rc==SQLITE_OK ){ + /* Load the value into pVal. pVal is a locale/text pair iff: + ** + ** 1) It is an SQLITE_BLOB, and + ** 2) Either the subtype is FTS5_LOCALE_SUBTYPE, or else the + ** value was loaded from an FTS5_CONTENT_NORMAL table, and + ** 3) It does not begin with an 0x00 byte. + */ + sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); + if( sqlite3_value_type(pVal)==SQLITE_BLOB ){ + if( pConfig->eContent==FTS5_CONTENT_NORMAL + || sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE ){ const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); int nBlob = sqlite3_value_bytes(pVal); int nLocale = 0; for(nLocale=0; nLocalebLocale + && sqlite3_value_type(pVal)==SQLITE_BLOB + && pConfig->abUnindexed[iCol]==0 + ){ if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE - || (pConfig->bLocale && pConfig->eContent==FTS5_CONTENT_NORMAL) + || pConfig->eContent==FTS5_CONTENT_NORMAL ){ const u8 *pBlob = sqlite3_value_blob(pVal); int nBlob = sqlite3_value_bytes(pVal); @@ -2953,7 +3066,7 @@ static int fts5ColumnMethod( rc = fts5SeekCursor(pCsr, 1); if( rc==SQLITE_OK ){ sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); - fts5ExtractValueFromColumn(pCtx, pConfig, pVal); + fts5ExtractValueFromColumn(pCtx, pConfig, iCol, pVal); } pConfig->pzErrmsg = 0; } @@ -3322,7 +3435,17 @@ static void fts5SourceIdFunc( } /* -** Implementation of fts5_locale() function. +** Implementation of fts5_locale(LOCALE, TEXT) function. +** +** If parameter LOCALE is NULL, or a zero-length string, then a copy of +** TEXT is returned. Otherwise, both LOCALE and TEXT are interpreted as +** text, and the value returned is a blob consisting of: +** +** * The LOCALE, as utf-8 text, followed by +** * 0x00, followed by +** * The TEXT, as utf-8 text. +** +** There is no final nul-terminator following the TEXT value. */ static void fts5LocaleFunc( sqlite3_context *pCtx, /* Function call context */ diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index ea5b61a4b6..e55e2b833b 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -476,7 +476,7 @@ static int fts5StorageDeleteFromIndex( pVal = apVal[iCol-1]; } - rc = sqlite3Fts5ExtractText(pConfig,pSeek!=0,pVal,&bReset,&pText,&nText); + rc = sqlite3Fts5ExtractText(pConfig, pVal, 1, &bReset, &pText, &nText); if( rc==SQLITE_OK ){ ctx.szCol = 0; rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, @@ -740,8 +740,8 @@ int sqlite3Fts5StorageRebuild(Fts5Storage *p){ int bReset = 0; int nText = 0; const char *pText = 0; - rc = sqlite3Fts5ExtractText(pConfig, 1, - sqlite3_column_value(pScan, ctx.iCol+1), &bReset, &pText, &nText + rc = sqlite3Fts5ExtractText(pConfig, + sqlite3_column_value(pScan, ctx.iCol+1), 1, &bReset, &pText, &nText ); if( rc==SQLITE_OK ){ @@ -851,11 +851,14 @@ int sqlite3Fts5StorageContentInsert( ** column. Strip the locale away and just bind the text. */ const char *pText = 0; int nText = 0; - rc = sqlite3Fts5ExtractText(pConfig, 0, pVal, 0, &pText, &nText); + rc = sqlite3Fts5ExtractText(pConfig, pVal, 0, 0, &pText, &nText); sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); continue; } - }else if( pConfig->bLocale && sqlite3_value_type(pVal)==SQLITE_BLOB ){ + }else if( pConfig->bLocale + && sqlite3_value_type(pVal)==SQLITE_BLOB + && i>=2 && pConfig->abUnindexed[i-2]==0 + ){ /* Inserting a blob into a normal content table with locale=1. */ int n = sqlite3_value_bytes(pVal); u8 *pBlob = sqlite3Fts5MallocZero(&rc, n+4); @@ -911,7 +914,7 @@ int sqlite3Fts5StorageIndexInsert( pVal = sqlite3_column_value(p->pSavedRow, ctx.iCol+1); bDisk = 1; } - rc = sqlite3Fts5ExtractText(pConfig, bDisk, pVal, &bReset,&pText,&nText); + rc = sqlite3Fts5ExtractText(pConfig, pVal, bDisk, &bReset,&pText,&nText); if( rc==SQLITE_OK ){ if( bReset && pConfig->bLocale==0 ){ rc = SQLITE_ERROR; @@ -1100,8 +1103,8 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg){ int nText = 0; int bReset = 0; - rc = sqlite3Fts5ExtractText(pConfig, 1, - sqlite3_column_value(pScan, i+1), &bReset, &pText, &nText + rc = sqlite3Fts5ExtractText(pConfig, + sqlite3_column_value(pScan, i+1), 1, &bReset, &pText, &nText ); if( rc==SQLITE_OK ){ diff --git a/ext/fts5/test/fts5blob.test b/ext/fts5/test/fts5blob.test index 9c838b75a6..56a571b9c4 100644 --- a/ext/fts5/test/fts5blob.test +++ b/ext/fts5/test/fts5blob.test @@ -31,8 +31,6 @@ foreach {tn enc locale} { execsql "PRAGMA encoding = $enc" - if {$tn==3 || $tn==4} breakpoint - execsql " CREATE VIRTUAL TABLE t1 USING fts5(x, y, locale=$locale); " @@ -71,6 +69,20 @@ do_test 1.6.1 { set U(utf8,1) } $U(utf8,0) do_test 1.6.2 { set U(utf16,1) } $U(utf16,0) +#-------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x, y UNINDEXED, locale=1); + INSERT INTO t1(rowid, x, y) VALUES(12, 'twelve', X'0000000041424320444546'); +} + +breakpoint +do_execsql_test 2.1 { + select rowid, x, quote(y) FROM t1 +} { + 12 twelve X'0000000041424320444546' +} + finish_test diff --git a/manifest b/manifest index a18841d7c4..9a70fc55a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smissing\sdocumentation\sfor\snew\sfeatures\sto\sfts5.h. -D 2024-07-31T15:46:41.319 +C Fix\svarious\sproblems\swith\sthe\scode\son\sthis\sbranch. +D 2024-07-31T20:49:00.656 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,15 +93,15 @@ F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6d F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h f5451da088d0004c4be7314e2fdb41fda16ce682ce2aa3b54b9474ebe9a013d5 -F ext/fts5/fts5Int.h 833a2fe729f926ebcde47e21e495d141b99ede9a188fc577873f24bea0f0bfa2 -F ext/fts5/fts5_aux.c 652f839dc0c77431295f10b08f268631560bb5630e65fd701de7a58744428a82 +F ext/fts5/fts5Int.h 2eab38c52d12bfa0a1cedb742276035e05634c6365f8defb599f023bb8743559 +F ext/fts5/fts5_aux.c 598c80fc0faabab91c833cdda99f8e36387bd907f4acb0480a19b612a4add93e F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 0c96490fbad746b3780174f38b2ee5e3d719f2f81ee6b58ca828772871e0f680 +F ext/fts5/fts5_config.c 31267fc68f9d16feaa5b5f7efb902a3410f0caa708cc2372c90a77d75890b2a8 F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c d9a3fef86887e373027d48ab8216ab8caca95f2316e05d953d8885633162a9c5 -F ext/fts5/fts5_storage.c cc6173bb755d668573169c038034a9ec8deadd10b3c10c145adbdf04ab5f889c +F ext/fts5/fts5_main.c bda8d421024191376343a571370a7b2f92fdf5303e32c6dc0d7456bef9ffedd8 +F ext/fts5/fts5_storage.c f94b924db1bc164af3feadcc3f08f0d8f5da5cd45e4909313637aeee85d0d13c F ext/fts5/fts5_tcl.c 93b705cb87633574983161edc5234f9b91ba03f9fecfbd2c5d401a1da6f93aa5 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -132,7 +132,7 @@ F ext/fts5/test/fts5auxdata.test 372549088ff792655f73e62b9dfaf4863ce74f5e604c06c F ext/fts5/test/fts5bigid.test 2860854c2561a57594192b00c33a29f91cb85e25f3d6c03b5c2b8f62708f39dd F ext/fts5/test/fts5bigpl.test 8f09858aab866c33593560e6480b2b6975ae7ff29ca32ad7b77e2da61402f8ef F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36 -F ext/fts5/test/fts5blob.test a16160688e181a212bcb4968325c57ef2864a0bcae0794d6a1e16185007f00b9 +F ext/fts5/test/fts5blob.test 6d1cf0c5ba2e6f8f9b4e915d3677c16ead3a79c22dcb386c0b21169a9349718d F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62 F ext/fts5/test/fts5colset.test 544f4998cdbfe06a3123887fc0221612e8aa8192cdaff152872f1aadb10e6897 @@ -2201,8 +2201,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ff64939ec8399949393f1029fa6d514892fbf2bf1498545300cc5e120b9622a5 -R f7dbcf0c98ed562d42b896f7c143383b +P fa0da3b28e411affd45a918d6b7faba49f744ca8b4adf3cd5ce6609bb630499e +R 4281c2d6e2e80158745c4320fdfed09d U dan -Z 344ab71a9372cfa91d638c7c0c606714 +Z 7ae6a6ddbc4056daf1c0903e2b7934cf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a1e4d24ea7..dee0563fc6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa0da3b28e411affd45a918d6b7faba49f744ca8b4adf3cd5ce6609bb630499e +8bd4ae7e95c7b6ce34db5ea705dc136e742a22f333d0e7370b485ebd736b5ec2 From 3f91c05e5d4574f641db5ab0f937707fa95b69ae Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 21:59:29 +0000 Subject: [PATCH 0596/1030] Use `` instead of `"tcl.h"` to include the TCL interface. FossilOrigin-Name: 4e32d4aed7c487ee9ed39a7e4486c2989a01781a3edbe9cdce52c6ed357f6366 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/tclsqlite.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6e9d844f46..7ff8a9cb81 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\stclsqlite.c\sTCL\sinterface\smodule\sso\sthat\sit\sworks\swith\sboth\sTcl8\sand\nTcl9.\s\sMake\schanges\sacross\sthe\sTCL-based\stest\sharness\sto\senable\sSQLite\sto\nbe\stested\swith\seither\sTcl8\sor\sTcl9.\s\sGet\sthe\s--with-tcl=\sargument\son\sthe\nconfigure\sscript\sworking.\s\sTesting\schanges\sonly\s-\sno\schanges\sto\sthe\sSQLite\score. -D 2024-07-31T21:46:46.869 +C Use\s``\sinstead\sof\s`"tcl.h"`\sto\sinclude\sthe\sTCL\sinterface. +D 2024-07-31T21:59:29.340 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -769,7 +769,7 @@ F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c 6242341191e43952a8ed466b1ee4993cad3a2b93ec3e4a5e826f0b06225a6716 -F src/tclsqlite.h 4ed60ea4084b2ea46e19ab13857b3f39d33250ebbf5b2df62b0999bb9b2766b7 +F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 F src/test1.c 51159784f29d3dfd4b50fd6ed9c43c8f7f36925c501a3ad3083528e5e5544bd7 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b @@ -2200,9 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 86de4e755e37dc1cbcbd59018927aa87ff49fc15f706a36187631d8f14075c12 67897ca97d8c98e119a498a3adb39548a579e12ee477e9dd74e9564a6f5e4c2b -R 0254aafb585571107527e25f3f3685a5 -T +closed 67897ca97d8c98e119a498a3adb39548a579e12ee477e9dd74e9564a6f5e4c2b +P 2a04b1bea12b0b4c3387d675f487337533ac0813248f70085398485e4cacd691 +R cf1060fba03288ec86002f1429d44bb7 U drh -Z 02c36e4e36a49e1b1991b0d0d54fc29a +Z 21f3a8c1ff9bb0324684e0a84afd736f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ded472ed21..0d9e955eb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2a04b1bea12b0b4c3387d675f487337533ac0813248f70085398485e4cacd691 +4e32d4aed7c487ee9ed39a7e4486c2989a01781a3edbe9cdce52c6ed357f6366 diff --git a/src/tclsqlite.h b/src/tclsqlite.h index ef63641bbb..b9a948ef14 100644 --- a/src/tclsqlite.h +++ b/src/tclsqlite.h @@ -24,7 +24,7 @@ #if defined(INCLUDE_SQLITE_TCL_H) # include "sqlite_tcl.h" /* Special case for Windows using STDCALL */ #else -# include "tcl.h" /* All normal cases */ +# include /* All normal cases */ # ifndef SQLITE_TCLAPI # define SQLITE_TCLAPI # endif From d888e79bb8a8efc75245fe337fd1d6c4d6266b31 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 22:17:26 +0000 Subject: [PATCH 0597/1030] Fix typo in testrunner.tcl for the "status" command that was causing it to fail if any errors were seen. FossilOrigin-Name: 8327c5ed535c57c4082211a50bfb1c32ea5d5fe1cf71f37798d8b58e88948ac2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7ff8a9cb81..cda6d8ba08 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\s``\sinstead\sof\s`"tcl.h"`\sto\sinclude\sthe\sTCL\sinterface. -D 2024-07-31T21:59:29.340 +C Fix\stypo\sin\stestrunner.tcl\sfor\sthe\s"status"\scommand\sthat\swas\scausing\sit\nto\sfail\sif\sany\serrors\swere\sseen. +D 2024-07-31T22:17:26.138 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1705,7 +1705,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef -F test/testrunner.tcl 757f79c68f82cad563441d80f02c492465f51cf537336c7b719c3ef45f348911 +F test/testrunner.tcl c1bd2910543a685a9cd44b70a69b1ca88b5cf9d2d5030bd57e17d9fbe3f1b6ce F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2a04b1bea12b0b4c3387d675f487337533ac0813248f70085398485e4cacd691 -R cf1060fba03288ec86002f1429d44bb7 +P 4e32d4aed7c487ee9ed39a7e4486c2989a01781a3edbe9cdce52c6ed357f6366 +R c8d75f24cdc92f2c156f1c37c053f824 U drh -Z 21f3a8c1ff9bb0324684e0a84afd736f +Z 97aa9466e911e388cc1550afb23cf268 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0d9e955eb6..aacf3d7da9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4e32d4aed7c487ee9ed39a7e4486c2989a01781a3edbe9cdce52c6ed357f6366 +8327c5ed535c57c4082211a50bfb1c32ea5d5fe1cf71f37798d8b58e88948ac2 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 57c39e7a4c..29be84e34e 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -447,7 +447,7 @@ if {[llength $argv]==1 } job { display_job [array get job] } - set nOmit [db one {SELECT count(*) FROM jobs WHERE state='omit'}] + set nOmit [mydb one {SELECT count(*) FROM jobs WHERE state='omit'}] if {$nOmit} { puts "$nOmit jobs omitted due to failures" } From 5addf9f1117567821c6cad070671a2a03b8bbeab Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 22:25:25 +0000 Subject: [PATCH 0598/1030] Make the #include section of tclsqlite.c the same as tclsqlite.h. FossilOrigin-Name: 2afadbeb124d6d7bb81d473379269014ebd8601f98f231e2218f54350a2e5fd3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tclsqlite.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index cda6d8ba08..c38dd8f848 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\stestrunner.tcl\sfor\sthe\s"status"\scommand\sthat\swas\scausing\sit\nto\sfail\sif\sany\serrors\swere\sseen. -D 2024-07-31T22:17:26.138 +C Make\sthe\s#include\ssection\sof\stclsqlite.c\sthe\ssame\sas\stclsqlite.h. +D 2024-07-31T22:25:25.378 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -768,7 +768,7 @@ F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c 6242341191e43952a8ed466b1ee4993cad3a2b93ec3e4a5e826f0b06225a6716 +F src/tclsqlite.c 8e86ab2595c2ff7bb155331fb173e560180235bceaacce7931a718b1c2e6dfb4 F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 F src/test1.c 51159784f29d3dfd4b50fd6ed9c43c8f7f36925c501a3ad3083528e5e5544bd7 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4e32d4aed7c487ee9ed39a7e4486c2989a01781a3edbe9cdce52c6ed357f6366 -R c8d75f24cdc92f2c156f1c37c053f824 +P 8327c5ed535c57c4082211a50bfb1c32ea5d5fe1cf71f37798d8b58e88948ac2 +R 20b530f4b4cc3303006640f07228cc1d U drh -Z 97aa9466e911e388cc1550afb23cf268 +Z 8814e0397816bd225e332f4bc053c4a6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aacf3d7da9..c9a2ae7fd7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8327c5ed535c57c4082211a50bfb1c32ea5d5fe1cf71f37798d8b58e88948ac2 +2afadbeb124d6d7bb81d473379269014ebd8601f98f231e2218f54350a2e5fd3 diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 55084687a7..906f429ab9 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -39,7 +39,7 @@ #if defined(INCLUDE_SQLITE_TCL_H) # include "sqlite_tcl.h" /* Special case for Windows using STDCALL */ #else -# include "tcl.h" /* All normal cases */ +# include /* All normal cases */ # ifndef SQLITE_TCLAPI # define SQLITE_TCLAPI # endif From b030bc698088aef9789763123de0f6dcd374cba4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Jul 2024 22:26:04 +0000 Subject: [PATCH 0599/1030] testrunner.db should be in WAL mode for improved concurrency while running "watch sqlite3 test/testrunner.tcl status". FossilOrigin-Name: f23ad0979865f3c11a3dbd0598ee7c4e2eabeaf1863d000fc0242e18890a4a11 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c38dd8f848..282a025c06 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\s#include\ssection\sof\stclsqlite.c\sthe\ssame\sas\stclsqlite.h. -D 2024-07-31T22:25:25.378 +C testrunner.db\sshould\sbe\sin\sWAL\smode\sfor\simproved\sconcurrency\swhile\srunning\n"watch\ssqlite3\stest/testrunner.tcl\sstatus". +D 2024-07-31T22:26:04.028 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1705,7 +1705,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef -F test/testrunner.tcl c1bd2910543a685a9cd44b70a69b1ca88b5cf9d2d5030bd57e17d9fbe3f1b6ce +F test/testrunner.tcl 2d100e73245e5f423942b6c198176c699137ee65192ed872bd8c9d4ac2c779b3 F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8327c5ed535c57c4082211a50bfb1c32ea5d5fe1cf71f37798d8b58e88948ac2 -R 20b530f4b4cc3303006640f07228cc1d +P 2afadbeb124d6d7bb81d473379269014ebd8601f98f231e2218f54350a2e5fd3 +R 5fce834a5a2db65fecaa00b46e4798f7 U drh -Z 8814e0397816bd225e332f4bc053c4a6 +Z 15b14d3b91c5abdab729b01ed2691ec8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c9a2ae7fd7..ddddcb7d72 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2afadbeb124d6d7bb81d473379269014ebd8601f98f231e2218f54350a2e5fd3 +f23ad0979865f3c11a3dbd0598ee7c4e2eabeaf1863d000fc0242e18890a4a11 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 29be84e34e..b320528735 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -399,7 +399,7 @@ if {[llength $argv]==1 } sqlite3 mydb $TRG(dbname) - mydb timeout 1000 + mydb timeout 2000 mydb eval BEGIN set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }] @@ -963,6 +963,7 @@ proc add_jobs_from_cmdline {patternlist} { proc make_new_testset {} { global TRG + trdb eval {PRAGMA journal_mode=WAL;} r_write_db { trdb eval $TRG(schema) set nJob $TRG(nJob) From 5cc7f4b5802d4a5ce0fa16f827382dd8dfdb512e Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Aug 2024 14:16:36 +0000 Subject: [PATCH 0600/1030] Add the "errors" command to testrunner.tcl. FossilOrigin-Name: 03b7f99229cfcffde024915e6812d75ae11318db9dc93a00838e4588a79b1243 --- manifest | 12 ++++---- manifest.uuid | 2 +- test/testrunner.tcl | 67 +++++++++++++++++++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index ce082dd8f3..5a1c13a60f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\stclsqlite.c\sTCL\sinterface\smodule\sso\sthat\sit\sworks\swith\sboth\sTcl8\sand\nTcl9.\s\sMake\schanges\sacross\sthe\sTCL-based\stest\sharness\sto\senable\sSQLite\sto\nbe\stested\swith\seither\sTcl8\sor\sTcl9.\s\sGet\sthe\s--with-tcl=\sargument\son\sthe\nconfigure\sscript\sworking.\sTesting\schanges\sonly\s-\sno\schanges\sto\sthe\sSQLite\score.\nI\sbelieve\sthe\sprevious\smerge\sattempt\sdidn't\swork\sbecause\sof\serrors\sin\sthe\nmerge\sitself,\snot\sbecause\sof\sfaults\sin\sthe\scode.\s\sTrying\sagain... -D 2024-07-31T22:36:14.186 +C Add\sthe\s"errors"\scommand\sto\stestrunner.tcl. +D 2024-08-01T14:16:36.126 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1705,7 +1705,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef -F test/testrunner.tcl 2d100e73245e5f423942b6c198176c699137ee65192ed872bd8c9d4ac2c779b3 +F test/testrunner.tcl 609d9e8f073ad7a4f839e3394ffb5019d4ea895c08e6701115bb0e94afa45c65 F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 86de4e755e37dc1cbcbd59018927aa87ff49fc15f706a36187631d8f14075c12 f23ad0979865f3c11a3dbd0598ee7c4e2eabeaf1863d000fc0242e18890a4a11 -R 5fce834a5a2db65fecaa00b46e4798f7 +P ea9d88f9ca3399bca83bf03893689a927b73e481604b94527e42de43f103eb46 +R bfca8ad2d62c4f03659e091bb06ca2cc U drh -Z 9ec5dbf6df6049abe121ce7ac9b8445b +Z 49d94432a94da4d21f2422461c255ece # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 05b9c5c202..6742779a8c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ea9d88f9ca3399bca83bf03893689a927b73e481604b94527e42de43f103eb46 +03b7f99229cfcffde024915e6812d75ae11318db9dc93a00838e4588a79b1243 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index b320528735..3b9da35b00 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -54,6 +54,7 @@ proc usage {} { Usage: $a0 ?SWITCHES? ?PERMUTATION? ?PATTERNS? $a0 PERMUTATION FILE + $a0 errors ?-v|--verbose? $a0 help $a0 njob ?NJOB? $a0 script ?-msvc? CONFIG @@ -107,6 +108,11 @@ The "script" command outputs the script used to build a configuration. Add the "-msvc" option for a Windows-compatible script. For a list of available configurations enter "$a0 script help". +The "errors" commands shows the output of all tests that failed in the +most recent run. Complete output is shown if the -v or --verbose options +are used. Otherwise, an attempt is made to minimize the output to show +only the parts that contain the error messages. + Full documentation here: https://sqlite.org/src/doc/trunk/doc/testrunner.md }]] @@ -398,12 +404,22 @@ if {[llength $argv]==1 puts " $dfname $dtm" } + if {![file readable $TRG(dbname)]} { + puts "Database missing: $TRG(dbname)" + exit + } sqlite3 mydb $TRG(dbname) mydb timeout 2000 mydb eval BEGIN - set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }] - set nJob [mydb one { SELECT value FROM config WHERE name='njob' }] + if {[catch { + set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }] + set nJob [mydb one { SELECT value FROM config WHERE name='njob' }] + } msg]} { + puts "Cannot read database: $TRG(dbname)" + mydb close + exit + } set now [clock_milliseconds] set tm [mydb one { @@ -457,6 +473,47 @@ if {[llength $argv]==1 exit } +#-------------------------------------------------------------------------- +# Check if this is the "errors" command: +# +if {[llength $argv]>=1 && [llength $argv]<=2 + && ([string compare -nocase errors [lindex $argv 0]]==0 || + [string match err* [lindex $argv 0]]==1) +} { + set verbose 0 + for {set ii 1} {$ii<[llength $argv]} {incr ii} { + set a0 [lindex $argv $ii] + if {$a0=="-v" || $a0=="--verbose" || $a0=="-verbose"} { + set verbose 1 + } else { + puts "unknown option: \"$a0\"". Use --help for more info." + exit 1 + } + } + set cnt 0 + sqlite3 mydb $TRG(dbname) + mydb timeout 2000 + mydb eval {SELECT displaytype, displayname, output + FROM jobs WHERE state='failed'} { + puts "**** $displayname ****" + if {$verbose || $displaytype!="tcl"} { + puts $output + } else { + foreach line [split $output \n] { + if {[string match {!*} $line] || [string match *failed* $line]} { + puts $line + } + } + } + incr cnt + } + mydb close + if {$cnt==0} { + puts "No errors" + } + exit +} + #------------------------------------------------------------------------- # Parse the command line. # @@ -603,12 +660,6 @@ proc r_get_next_job {iJob} { return $ret } -#rename r_get_next_job r_get_next_job_r -#proc r_get_next_job {iJob} { - #puts [time { set res [r_get_next_job_r $iJob] }] - #set res -#} - # Usage: # # add_job OPTION ARG OPTION ARG... From a51de65758d5bfd9507dfbee897d66dd3215503c Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Aug 2024 14:43:27 +0000 Subject: [PATCH 0601/1030] Include a test case summary in the output of "errors" in testrunner.tcl. FossilOrigin-Name: 173df1478e89996126e172656e35da8026d4ef145b2341ef56213f00ade14f48 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 31 ++++++++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 5a1c13a60f..488738897e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"errors"\scommand\sto\stestrunner.tcl. -D 2024-08-01T14:16:36.126 +C Include\sa\stest\scase\ssummary\sin\sthe\soutput\sof\s"errors"\sin\stestrunner.tcl. +D 2024-08-01T14:43:27.026 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1705,7 +1705,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef -F test/testrunner.tcl 609d9e8f073ad7a4f839e3394ffb5019d4ea895c08e6701115bb0e94afa45c65 +F test/testrunner.tcl f6ac1a55ce4c9278cf8c4dbaed1facd347c9b80acae5d32511c3bf3e529a4817 F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2200,8 +2200,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ea9d88f9ca3399bca83bf03893689a927b73e481604b94527e42de43f103eb46 -R bfca8ad2d62c4f03659e091bb06ca2cc +P 03b7f99229cfcffde024915e6812d75ae11318db9dc93a00838e4588a79b1243 +R 08e6905a776f74e196253ed63d164e48 U drh -Z 49d94432a94da4d21f2422461c255ece +Z 096dcbc7b2b21544af81d2d7e8439d72 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6742779a8c..7d0cd49d41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -03b7f99229cfcffde024915e6812d75ae11318db9dc93a00838e4588a79b1243 +173df1478e89996126e172656e35da8026d4ef145b2341ef56213f00ade14f48 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 3b9da35b00..aeb015865d 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -473,6 +473,32 @@ if {[llength $argv]==1 exit } +# Scan the output of all jobs looking for the summary lines that +# report the number of test cases and the number of errors. +# Aggregate these numbers and return them. +# +proc aggregate_test_counts {db} { + set ncase 0 + set nerr 0 + $db eval {SELECT output FROM jobs WHERE displaytype IN ('tcl','fuzz')} { + set n 0 + set m 0 + if {[regexp {(\d+) errors out of (\d+) tests} $output all n m] + && [string is integer -strict $n] + && [string is integer -strict $m]} { + incr ncase $m + incr nerr $n + } elseif {[regexp {sessionfuzz.*: *(\d+) cases, (\d+) crash} $output \ + all m n] + && [string is integer -strict $m] + && [string is integer -strict $n]} { + incr ncase $m + incr nerr $n + } + } + return [list $nerr $ncase] +} + #-------------------------------------------------------------------------- # Check if this is the "errors" command: # @@ -507,10 +533,9 @@ if {[llength $argv]>=1 && [llength $argv]<=2 } incr cnt } + set summary [aggregate_test_counts mydb] mydb close - if {$cnt==0} { - puts "No errors" - } + puts "Total [lindex $summary 0] errors out of [lindex $summary 1] tests" exit } From f971c15b1f48bd986da68c40602158e9669914ba Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 1 Aug 2024 17:15:17 +0000 Subject: [PATCH 0602/1030] Clarify the role of Fts5Storage.pSavedRow in the new feature on this branch. FossilOrigin-Name: e8a61d5c48073fdd4d99d0b6fc70469b37af009f281336a44e3789e7eeed820d --- ext/fts5/fts5_storage.c | 106 ++++++++++++++++++++++++++++------------ manifest | 12 ++--- manifest.uuid | 2 +- 3 files changed, 82 insertions(+), 38 deletions(-) diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index e55e2b833b..0a655d160f 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -16,6 +16,32 @@ #include "fts5Int.h" +/* +** pSavedRow: +** SQL statement FTS5_STMT_LOOKUP2 is a copy of FTS5_STMT_LOOKUP, it +** does a by-rowid lookup to retrieve a single row from the %_content +** table or equivalent external-content table/view. +** +** However, FTS5_STMT_LOOKUP2 is only used when retrieving the original +** values for a row being UPDATEd. In that case, the SQL statement is +** not reset and pSavedRow is set to point at it. This is so that the +** insert operation that follows the delete may access the original +** row values for any new values for which sqlite3_value_nochange() returns +** true. i.e. if the user executes: +** +** CREATE VIRTUAL TABLE ft USING fts5(a, b, c, locale=1); +** ... +** UPDATE fts SET a=?, b=? WHERE rowid=?; +** +** then the value passed to the xUpdate() method of this table as the +** new.c value is an sqlite3_value_nochange() value. So in this case it +** must be read from the saved row stored in Fts5Storage.pSavedRow. +** +** This is necessary - using sqlite3_value_nochange() instead of just having +** SQLite pass the original value back via xUpdate() - so as not to discard +** any locale information associated with such values. +** +*/ struct Fts5Storage { Fts5Config *pConfig; Fts5Index *pIndex; @@ -37,15 +63,15 @@ struct Fts5Storage { # error "FTS5_STMT_LOOKUP mismatch" #endif -#define FTS5_STMT_LOOKUP2 3 +#define FTS5_STMT_LOOKUP2 3 #define FTS5_STMT_INSERT_CONTENT 4 #define FTS5_STMT_REPLACE_CONTENT 5 #define FTS5_STMT_DELETE_CONTENT 6 -#define FTS5_STMT_REPLACE_DOCSIZE 7 +#define FTS5_STMT_REPLACE_DOCSIZE 7 #define FTS5_STMT_DELETE_DOCSIZE 8 #define FTS5_STMT_LOOKUP_DOCSIZE 9 #define FTS5_STMT_REPLACE_CONFIG 10 -#define FTS5_STMT_SCAN 11 +#define FTS5_STMT_SCAN 11 /* ** Prepare the two insert statements - Fts5Storage.pInsertContent and @@ -405,6 +431,16 @@ static int fts5StorageInsertCallback( return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken); } +/* +** This function is used as part of an UPDATE statement that modifies the +** rowid of a row. In that case, this function is called first to set +** Fts5Storage.pSavedRow to point to a statement that may be used to +** access the original values of the row being deleted - iDel. +** +** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +** It is not considered an error if row iDel does not exist. In this case +** pSavedRow is not set and SQLITE_OK returned. +*/ int sqlite3Fts5StorageFindDeleteRow(Fts5Storage *p, i64 iDel){ int rc = SQLITE_OK; sqlite3_stmt *pSeek = 0; @@ -427,12 +463,17 @@ int sqlite3Fts5StorageFindDeleteRow(Fts5Storage *p, i64 iDel){ ** If a row with rowid iDel is present in the %_content table, add the ** delete-markers to the FTS index necessary to delete it. Do not actually ** remove the %_content row at this time though. +** +** If parameter bSaveRow is true, then Fts5Storage.pSavedRow is left +** pointing to a statement (FTS5_STMT_LOOKUP2) that may be used to access +** the original values of the row being deleted. This is used by UPDATE +** statements. */ static int fts5StorageDeleteFromIndex( Fts5Storage *p, i64 iDel, sqlite3_value **apVal, - int bSaveRow + int bSaveRow /* True to set pSavedRow */ ){ Fts5Config *pConfig = p->pConfig; sqlite3_stmt *pSeek = 0; /* SELECT to read row iDel from %_data */ @@ -506,7 +547,15 @@ static int fts5StorageDeleteFromIndex( return rc; } +/* +** Reset any saved statement pSavedRow. Zero pSavedRow as well. This +** should be called by the xUpdate() method of the fts5 table before +** returning from any operation that may have set Fts5Storage.pSavedRow. +*/ void sqlite3Fts5StorageReleaseDeleteRow(Fts5Storage *pStorage){ + assert( pStorage->pSavedRow==0 + || pStorage->pSavedRow==pStorage->aStmt[FTS5_STMT_LOOKUP2] + ); sqlite3_reset(pStorage->pSavedRow); pStorage->pSavedRow = 0; } @@ -630,7 +679,7 @@ int sqlite3Fts5StorageDelete( Fts5Storage *p, /* Storage object */ i64 iDel, /* Rowid to delete from table */ sqlite3_value **apVal, /* Optional - values to remove from index */ - int bSaveRow + int bSaveRow /* If true, set pSavedRow for deleted row */ ){ Fts5Config *pConfig = p->pConfig; int rc; @@ -737,13 +786,12 @@ int sqlite3Fts5StorageRebuild(Fts5Storage *p){ for(ctx.iCol=0; rc==SQLITE_OK && ctx.iColnCol; ctx.iCol++){ ctx.szCol = 0; if( pConfig->abUnindexed[ctx.iCol]==0 ){ - int bReset = 0; - int nText = 0; - const char *pText = 0; - rc = sqlite3Fts5ExtractText(pConfig, - sqlite3_column_value(pScan, ctx.iCol+1), 1, &bReset, &pText, &nText - ); + int bReset = 0; /* True if tokenizer locale must be reset */ + int nText = 0; /* Size of pText in bytes */ + const char *pText = 0; /* Pointer to buffer containing text value */ + sqlite3_value *pVal = sqlite3_column_value(pScan, ctx.iCol+1); + rc = sqlite3Fts5ExtractText(pConfig, pVal, 1, &bReset, &pText, &nText); if( rc==SQLITE_OK ){ rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, @@ -838,6 +886,8 @@ int sqlite3Fts5StorageContentInsert( for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){ sqlite3_value *pVal = apVal[i]; if( sqlite3_value_nochange(pVal) && p->pSavedRow ){ + /* This is an UPDATE statement, and column (i-2) was not modified. + ** Retrieve the value from Fts5Storage.pSavedRow instead. */ pVal = sqlite3_column_value(p->pSavedRow, i-1); }else if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE ){ if( pConfig->bLocale==0 ){ @@ -859,7 +909,8 @@ int sqlite3Fts5StorageContentInsert( && sqlite3_value_type(pVal)==SQLITE_BLOB && i>=2 && pConfig->abUnindexed[i-2]==0 ){ - /* Inserting a blob into a normal content table with locale=1. */ + /* Inserting a blob into a normal content table with locale=1. + ** Add the 4 0x00 byte header. */ int n = sqlite3_value_bytes(pVal); u8 *pBlob = sqlite3Fts5MallocZero(&rc, n+4); if( pBlob ){ @@ -905,28 +956,22 @@ int sqlite3Fts5StorageIndexInsert( for(ctx.iCol=0; rc==SQLITE_OK && ctx.iColnCol; ctx.iCol++){ ctx.szCol = 0; if( pConfig->abUnindexed[ctx.iCol]==0 ){ - int bReset = 0; - int nText = 0; - const char *pText = 0; + int bReset = 0; /* True if tokenizer locale must be reset */ + int nText = 0; /* Size of pText in bytes */ + const char *pText = 0; /* Pointer to buffer containing text value */ sqlite3_value *pVal = apVal[ctx.iCol+2]; int bDisk = 0; if( p->pSavedRow && sqlite3_value_nochange(pVal) ){ pVal = sqlite3_column_value(p->pSavedRow, ctx.iCol+1); bDisk = 1; } - rc = sqlite3Fts5ExtractText(pConfig, pVal, bDisk, &bReset,&pText,&nText); + rc = sqlite3Fts5ExtractText(pConfig, pVal, bDisk, &bReset, &pText,&nText); if( rc==SQLITE_OK ){ - if( bReset && pConfig->bLocale==0 ){ - rc = SQLITE_ERROR; - sqlite3Fts5ConfigErrmsg(pConfig, - "fts5_locale() may not be used without locale=1" - ); - }else{ - rc = sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, pText, nText, (void*)&ctx, - fts5StorageInsertCallback - ); - } + assert( bReset==0 || pConfig->bLocale ); + rc = sqlite3Fts5Tokenize(pConfig, + FTS5_TOKENIZE_DOCUMENT, pText, nText, (void*)&ctx, + fts5StorageInsertCallback + ); if( bReset ) sqlite3Fts5ClearLocale(pConfig); } } @@ -1099,14 +1144,13 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg){ rc = sqlite3Fts5TermsetNew(&ctx.pTermset); } if( rc==SQLITE_OK ){ - const char *pText = 0; - int nText = 0; - int bReset = 0; + int bReset = 0; /* True if tokenizer locale must be reset */ + int nText = 0; /* Size of pText in bytes */ + const char *pText = 0; /* Pointer to buffer containing text value */ rc = sqlite3Fts5ExtractText(pConfig, sqlite3_column_value(pScan, i+1), 1, &bReset, &pText, &nText ); - if( rc==SQLITE_OK ){ rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, diff --git a/manifest b/manifest index 9a70fc55a7..fc335fa46f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\svarious\sproblems\swith\sthe\scode\son\sthis\sbranch. -D 2024-07-31T20:49:00.656 +C Clarify\sthe\srole\sof\sFts5Storage.pSavedRow\sin\sthe\snew\sfeature\son\sthis\sbranch. +D 2024-08-01T17:15:17.507 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -101,7 +101,7 @@ F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac62232 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c bda8d421024191376343a571370a7b2f92fdf5303e32c6dc0d7456bef9ffedd8 -F ext/fts5/fts5_storage.c f94b924db1bc164af3feadcc3f08f0d8f5da5cd45e4909313637aeee85d0d13c +F ext/fts5/fts5_storage.c 784c6c4edf676c831ffbaef7b0484dcafe925d3d39049b8ee6b6eeaadae1b042 F ext/fts5/fts5_tcl.c 93b705cb87633574983161edc5234f9b91ba03f9fecfbd2c5d401a1da6f93aa5 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -2201,8 +2201,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fa0da3b28e411affd45a918d6b7faba49f744ca8b4adf3cd5ce6609bb630499e -R 4281c2d6e2e80158745c4320fdfed09d +P 8bd4ae7e95c7b6ce34db5ea705dc136e742a22f333d0e7370b485ebd736b5ec2 +R 65a2f69590c259e395cd85b8f6d4acad U dan -Z 7ae6a6ddbc4056daf1c0903e2b7934cf +Z cbe99cb860ae582ece42e3b6610aa855 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dee0563fc6..0c89f035e2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bd4ae7e95c7b6ce34db5ea705dc136e742a22f333d0e7370b485ebd736b5ec2 +e8a61d5c48073fdd4d99d0b6fc70469b37af009f281336a44e3789e7eeed820d From 91db27aff576f818bd8be078494fed3feb341f0d Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Aug 2024 18:10:00 +0000 Subject: [PATCH 0603/1030] Clean up and restructure the TCL configuration sections in autoconf. The new --with-tclsh=FILE option lets you select the specific tclsh that you want to run. FossilOrigin-Name: 8fafc679d91e857602fbbe203144ca98242246660ede5a49c5fec8aaff571151 --- configure | 361 +++++++++++----------------------------- configure.ac | 248 ++++++--------------------- manifest | 18 +- manifest.uuid | 2 +- tool/find_tclconfig.tcl | 24 +++ 5 files changed, 185 insertions(+), 468 deletions(-) create mode 100644 tool/find_tclconfig.tcl diff --git a/configure b/configure index efd0422ac1..744410589b 100755 --- a/configure +++ b/configure @@ -781,18 +781,6 @@ TARGET_HAVE_EDITLINE TARGET_HAVE_READLINE TARGET_READLINE_INC TARGET_READLINE_LIBS -HAVE_TCL -TCL_SHLIB_SUFFIX -TCL_STUB_LIB_SPEC -TCL_STUB_LIB_FLAG -TCL_STUB_LIB_FILE -TCL_LIB_SPEC -TCL_LIB_FLAG -TCL_LIB_FILE -TCL_INCLUDE_SPEC -TCL_SRC_DIR -TCL_BIN_DIR -TCL_VERSION TARGET_EXEEXT SQLITE_OS_WIN SQLITE_OS_UNIX @@ -806,6 +794,18 @@ RELEASE VERSION program_prefix TCLLIBDIR +HAVE_TCL +TCL_SHLIB_SUFFIX +TCL_STUB_LIB_SPEC +TCL_STUB_LIB_FLAG +TCL_STUB_LIB_FILE +TCL_LIB_SPEC +TCL_LIB_FLAG +TCL_LIB_FILE +TCL_INCLUDE_SPEC +TCL_SRC_DIR +TCL_BIN_DIR +TCL_VERSION TCLSH_CMD INSTALL_DATA INSTALL_SCRIPT @@ -894,12 +894,12 @@ enable_fast_install with_gnu_ld enable_libtool_lock enable_largefile +with_tclsh +with_tcl with_wasi_sdk enable_threadsafe enable_releasemode enable_tempstore -enable_tcl -with_tcl enable_editline enable_readline with_readline_lib @@ -1555,7 +1555,6 @@ Optional Features: --enable-releasemode Support libtool link to release mode --enable-tempstore Use an in-ram database for temporary tables (never,no,yes,always) - --disable-tcl do not build TCL extension --enable-editline enable BSD editline support --disable-readline disable readline support --enable-debug enable debugging & verbose explain @@ -1583,10 +1582,10 @@ Optional Packages: --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-tclsh=PATHNAME full pathname of a tclsh to use + --with-tcl=DIR directory containing (tclConfig.sh) --with-wasi-sdk=DIR directory containing the WASI SDK. Triggers cross-compile to WASM. - --with-tcl=DIR directory containing tcl configuration - (tclConfig.sh) --with-readline-lib specify readline library --with-readline-inc specify readline include paths --with-linenoise=DIR source directory for linenoise library @@ -3945,13 +3944,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3948: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3947: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3951: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3950: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3954: output\"" >&5) + (eval echo "\"\$as_me:3953: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5157,7 +5156,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5160 "configure"' > conftest.$ac_ext + echo '#line 5159 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6682,11 +6681,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6685: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6684: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6689: \$? = $ac_status" >&5 + echo "$as_me:6688: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7021,11 +7020,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7024: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7023: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7028: \$? = $ac_status" >&5 + echo "$as_me:7027: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7126,11 +7125,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7129: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7128: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7133: \$? = $ac_status" >&5 + echo "$as_me:7132: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7181,11 +7180,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7184: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7183: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7188: \$? = $ac_status" >&5 + echo "$as_me:7187: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9561,7 +9560,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9564 "configure" +#line 9563 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9657,7 +9656,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9660 "configure" +#line 9659 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10314,24 +10313,23 @@ done USE_AMALGAMATION=1 ######### -# See whether we can run specific tclsh versions known to work well; -# if not, then we fall back to plain tclsh. -# TODO: try other versions before falling back? +# Figure out all the name of a working tclsh and parameters needed to compile against Tcl. +# The --with-tcl= configuration parameter might be useful for this. # -if test x"${with_tcl}" != x; then - if test ! -r ${with_tcl}/tclConfig.sh; then - as_fn_error $? "no tclConfig.sh file found in --with-tcl: ${with_tcl}" "$LINENO" 5 - else - . ${with_tcl}/tclConfig.sh - TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} - if test ! -x ${TCLSH_CMD}; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot use tclsh at: ${TCLSH_CMD}" >&5 -$as_echo "$as_me: WARNING: cannot use tclsh at: ${TCLSH_CMD}" >&2;} - TCLSH_CMD=none - fi - fi -else - for ac_prog in tclsh8.6 tclsh8.5 tclsh + +# Check whether --with-tclsh was given. +if test "${with_tclsh+set}" = set; then : + withval=$with_tclsh; +fi + + +# Check whether --with-tcl was given. +if test "${with_tcl+set}" = set; then : + withval=$with_tcl; +fi + +if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then + for ac_prog in tclsh8.6 tclsh tclsh9.0 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -10374,23 +10372,71 @@ fi done test -n "$TCLSH_CMD" || TCLSH_CMD="none" + with_tclsh=${TCLSH_CMD} +fi +if test x"${with_tclsh}" != x -a x"${with_tclsh}" != xnone; then + TCLSH_CMD=${with_tclsh} + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using tclsh at \"$TCLSH_CMD\"" >&5 +$as_echo "using tclsh at \"$TCLSH_CMD\"" >&6; } + with_tcl=`${with_tclsh} <${srcdir}/tool/find_tclconfig.tcl` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&5 +$as_echo "$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&6; } +fi +if test x"${with_tcl}" != x; then + if test -r ${with_tcl}/tclConfig.sh; then + tclconfig="${with_tcl}/tclConfig.sh" + else + if test -r ${with_tcl}/tcl8.6/tclConfig.sh; then + tclconfig="${with_tcl}/tcl8.6/tclConfig.sh" + else + as_fn_error $? "no tclConfig.sh file found in ${with_tcl} or ${with_tcl}/tcl8.6" "$LINENO" 5 + fi + fi + if test x"${tclconfig}" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading TCL configuration from ${tclconfig}" >&5 +$as_echo "loading TCL configuration from ${tclconfig}" >&6; } + . ${tclconfig} + + + + + + + + + + + + fi + if test x"$TCLSH_CMD" == x; then + TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} + if test ! -x ${TCLSH_CMD}; then + TCLSH_CMD_2=${TCL_EXEC_PREFIX}/bin/tclsh + if test ! -x ${TCLSH_CMD_2}; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find a usable tclsh at either ${TCLSH_CMD} or ${TCLSH_CMD_2}" >&5 +$as_echo "$as_me: WARNING: cannot find a usable tclsh at either ${TCLSH_CMD} or ${TCLSH_CMD_2}" >&2;} + TCLSH_CMD=none + else + TCLSH_CMD=${TCLSH_CMD_2} + fi + fi + fi fi if test "$TCLSH_CMD" = "none"; then # If we can't find a local tclsh, then building the amalgamation will fail. # We act as though --disable-amalgamation has been used. - echo "Warning: can't find tclsh - defaulting to non-amalgamation build." + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Warning: can't find tclsh - defaulting to non-amalgamation build." >&5 +$as_echo "$as_me: WARNING: Warning: can't find tclsh - defaulting to non-amalgamation build." >&2;} USE_AMALGAMATION=0 TCLSH_CMD="tclsh" -fi -if test x"$TCLSH_CMD" = x; then - as_fn_error $? "cannot find a usable tclsh" "$LINENO" 5 + HAVE_TCL=0 else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: using $TCLSH_CMD" >&5 -$as_echo "using $TCLSH_CMD" >&6; } + HAVE_TCL=1 fi + if test "x${TCLLIBDIR+set}" != "xset" ; then TCLLIBDIR='$(libdir)' for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` ; do @@ -10789,213 +10835,6 @@ fi -########## -# Figure out all the parameters needed to compile against Tcl. -# -# This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG -# macros in the in the tcl.m4 file of the standard TCL distribution. -# Those macros could not be used directly since we have to make some -# minor changes to accomodate systems that do not have TCL installed. -# -# Check whether --enable-tcl was given. -if test "${enable_tcl+set}" = set; then : - enableval=$enable_tcl; use_tcl=$enableval -else - use_tcl=yes -fi - -if test "${use_tcl}" = "yes" ; then - -# Check whether --with-tcl was given. -if test "${with_tcl+set}" = set; then : - withval=$with_tcl; with_tclconfig=${withval} -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5 -$as_echo_n "checking for Tcl configuration... " >&6; } - if ${ac_cv_c_tclconfig+:} false; then : - $as_echo_n "(cached) " >&6 -else - - # First check to see if --with-tcl was specified. - if test x"${with_tclconfig}" != x ; then - if test -f "${with_tclconfig}/tclConfig.sh" ; then - ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)` - else - as_fn_error $? "${with_tclconfig} directory doesn't contain tclConfig.sh" "$LINENO" 5 - fi - fi - - # Start autosearch by asking tclsh - if test x"${ac_cv_c_tclconfig}" = x ; then - if test x"$cross_compiling" = xno; then - for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig="$i" - break - fi - done - fi - fi - - # On ubuntu 14.10, $auto_path on tclsh is not quite correct. - # So try again after applying corrections. - if test x"${ac_cv_c_tclconfig}" = x ; then - if test x"$cross_compiling" = xno; then - for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD} | sed 's,/tcltk/tcl,/tcl,g'` - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig="$i" - break - fi - done - fi - fi - - # Recent versions of Xcode on Macs hid the tclConfig.sh file - # in a strange place. - if test x"${ac_cv_c_tclconfig}" = x ; then - if test x"$cross_compiling" = xno; then - for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig="$i" - break - fi - done - fi - fi - - # then check for a private Tcl installation - if test x"${ac_cv_c_tclconfig}" = x ; then - for i in \ - ../tcl \ - `ls -dr ../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ - `ls -dr ../tcl[8-9].[0-9] 2>/dev/null` \ - `ls -dr ../tcl[8-9].[0-9]* 2>/dev/null` \ - ../../tcl \ - `ls -dr ../../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ - `ls -dr ../../tcl[8-9].[0-9] 2>/dev/null` \ - `ls -dr ../../tcl[8-9].[0-9]* 2>/dev/null` \ - ../../../tcl \ - `ls -dr ../../../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ - `ls -dr ../../../tcl[8-9].[0-9] 2>/dev/null` \ - `ls -dr ../../../tcl[8-9].[0-9]* 2>/dev/null` - do - if test -f "$i/unix/tclConfig.sh" ; then - ac_cv_c_tclconfig=`(cd $i/unix; pwd)` - break - fi - done - fi - - # check in a few common install locations - if test x"${ac_cv_c_tclconfig}" = x ; then - for i in \ - `ls -d ${libdir} 2>/dev/null` \ - `ls -d /usr/local/lib 2>/dev/null` \ - `ls -d /usr/contrib/lib 2>/dev/null` \ - `ls -d /usr/lib 2>/dev/null` - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig=`(cd $i; pwd)` - break - fi - done - fi - - # check in a few other private locations - if test x"${ac_cv_c_tclconfig}" = x ; then - for i in \ - ${srcdir}/../tcl \ - `ls -dr ${srcdir}/../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ - `ls -dr ${srcdir}/../tcl[8-9].[0-9] 2>/dev/null` \ - `ls -dr ${srcdir}/../tcl[8-9].[0-9]* 2>/dev/null` - do - if test -f "$i/unix/tclConfig.sh" ; then - ac_cv_c_tclconfig=`(cd $i/unix; pwd)` - break - fi - done - fi - -fi - - - if test x"${ac_cv_c_tclconfig}" = x ; then - use_tcl=no - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can't find Tcl configuration definitions" >&5 -$as_echo "$as_me: WARNING: Can't find Tcl configuration definitions" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Without Tcl the regression tests cannot be executed ***" >&5 -$as_echo "$as_me: WARNING: *** Without Tcl the regression tests cannot be executed ***" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Consider using --with-tcl=... to define location of Tcl ***" >&5 -$as_echo "$as_me: WARNING: *** Consider using --with-tcl=... to define location of Tcl ***" >&2;} - else - TCL_BIN_DIR=${ac_cv_c_tclconfig} - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $TCL_BIN_DIR/tclConfig.sh" >&5 -$as_echo "found $TCL_BIN_DIR/tclConfig.sh" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for existence of $TCL_BIN_DIR/tclConfig.sh" >&5 -$as_echo_n "checking for existence of $TCL_BIN_DIR/tclConfig.sh... " >&6; } - if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading" >&5 -$as_echo "loading" >&6; } - . $TCL_BIN_DIR/tclConfig.sh - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: file not found" >&5 -$as_echo "file not found" >&6; } - fi - - # - # If the TCL_BIN_DIR is the build directory (not the install directory), - # then set the common variable name to the value of the build variables. - # For example, the variable TCL_LIB_SPEC will be set to the value - # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC - # instead of TCL_BUILD_LIB_SPEC since it will work with both an - # installed and uninstalled version of Tcl. - # - - if test -f $TCL_BIN_DIR/Makefile ; then - TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC} - TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC} - TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH} - fi - - # - # eval is required to do the TCL_DBGX substitution - # - - eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\"" - eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" - eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" - - eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\"" - eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" - eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" - - - - - - - - - - - - - - - fi -fi -if test "${use_tcl}" = "no" ; then - HAVE_TCL="" -else - HAVE_TCL=1 -fi - - ########## # Figure out what C libraries are required to compile programs # that use "readline()" library. diff --git a/configure.ac b/configure.ac index 9d8c594bae..404a80bffd 100644 --- a/configure.ac +++ b/configure.ac @@ -116,37 +116,71 @@ AC_CHECK_FUNCS([fdatasync gmtime_r isnan localtime_r localtime_s malloc_usable_s USE_AMALGAMATION=1 ######### -# See whether we can run specific tclsh versions known to work well; -# if not, then we fall back to plain tclsh. -# TODO: try other versions before falling back? +# Figure out all the name of a working tclsh and parameters needed to compile against Tcl. +# The --with-tcl= configuration parameter might be useful for this. # +AC_ARG_WITH(tclsh, AS_HELP_STRING([--with-tclsh=PATHNAME],[full pathname of a tclsh to use])) +AC_ARG_WITH(tcl, AS_HELP_STRING([--with-tcl=DIR],[directory containing (tclConfig.sh)])) +if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then + AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh tclsh9.0],none) + with_tclsh=${TCLSH_CMD} +fi +if test x"${with_tclsh}" != x -a x"${with_tclsh}" != xnone; then + TCLSH_CMD=${with_tclsh} + AC_MSG_RESULT([using tclsh at "$TCLSH_CMD"]) + with_tcl=`${with_tclsh} <${srcdir}/tool/find_tclconfig.tcl` + AC_MSG_RESULT([$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}]) +fi if test x"${with_tcl}" != x; then - if test ! -r ${with_tcl}/tclConfig.sh; then - AC_MSG_ERROR([no tclConfig.sh file found in --with-tcl: ${with_tcl}]) + if test -r ${with_tcl}/tclConfig.sh; then + tclconfig="${with_tcl}/tclConfig.sh" else - . ${with_tcl}/tclConfig.sh + if test -r ${with_tcl}/tcl8.6/tclConfig.sh; then + tclconfig="${with_tcl}/tcl8.6/tclConfig.sh" + else + AC_MSG_ERROR([no tclConfig.sh file found in ${with_tcl} or ${with_tcl}/tcl8.6]) + fi + fi + if test x"${tclconfig}" != x; then + AC_MSG_RESULT([loading TCL configuration from ${tclconfig}]) + . ${tclconfig} + AC_SUBST(TCL_VERSION) + AC_SUBST(TCL_BIN_DIR) + AC_SUBST(TCL_SRC_DIR) + AC_SUBST(TCL_INCLUDE_SPEC) + AC_SUBST(TCL_LIB_FILE) + AC_SUBST(TCL_LIB_FLAG) + AC_SUBST(TCL_LIB_SPEC) + AC_SUBST(TCL_STUB_LIB_FILE) + AC_SUBST(TCL_STUB_LIB_FLAG) + AC_SUBST(TCL_STUB_LIB_SPEC) + AC_SUBST(TCL_SHLIB_SUFFIX) + fi + if test x"$TCLSH_CMD" == x; then TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} if test ! -x ${TCLSH_CMD}; then - AC_MSG_WARN([cannot use tclsh at: ${TCLSH_CMD}]) - TCLSH_CMD=none + TCLSH_CMD_2=${TCL_EXEC_PREFIX}/bin/tclsh + if test ! -x ${TCLSH_CMD_2}; then + AC_MSG_WARN([cannot find a usable tclsh at either ${TCLSH_CMD} or ${TCLSH_CMD_2}]) + TCLSH_CMD=none + else + TCLSH_CMD=${TCLSH_CMD_2} + fi fi fi -else - AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh8.5 tclsh], none) fi if test "$TCLSH_CMD" = "none"; then # If we can't find a local tclsh, then building the amalgamation will fail. # We act as though --disable-amalgamation has been used. - echo "Warning: can't find tclsh - defaulting to non-amalgamation build." + AC_MSG_WARN([Warning: can't find tclsh - defaulting to non-amalgamation build.]) USE_AMALGAMATION=0 TCLSH_CMD="tclsh" -fi -if test x"$TCLSH_CMD" = x; then - AC_MSG_ERROR([cannot find a usable tclsh]) + HAVE_TCL=0 else - AC_MSG_RESULT([using $TCLSH_CMD]) + HAVE_TCL=1 fi AC_SUBST(TCLSH_CMD) +AC_SUBST(HAVE_TCL) AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin]) if test "x${TCLLIBDIR+set}" != "xset" ; then @@ -357,190 +391,6 @@ AC_SUBST(SQLITE_OS_UNIX) AC_SUBST(SQLITE_OS_WIN) AC_SUBST(TARGET_EXEEXT) -########## -# Figure out all the parameters needed to compile against Tcl. -# -# This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG -# macros in the in the tcl.m4 file of the standard TCL distribution. -# Those macros could not be used directly since we have to make some -# minor changes to accomodate systems that do not have TCL installed. -# -AC_ARG_ENABLE(tcl, AS_HELP_STRING([--disable-tcl],[do not build TCL extension]), - [use_tcl=$enableval],[use_tcl=yes]) -if test "${use_tcl}" = "yes" ; then - AC_ARG_WITH(tcl, AS_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval}) - AC_MSG_CHECKING([for Tcl configuration]) - AC_CACHE_VAL(ac_cv_c_tclconfig,[ - # First check to see if --with-tcl was specified. - if test x"${with_tclconfig}" != x ; then - if test -f "${with_tclconfig}/tclConfig.sh" ; then - ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)` - else - AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh]) - fi - fi - - # Start autosearch by asking tclsh - if test x"${ac_cv_c_tclconfig}" = x ; then - if test x"$cross_compiling" = xno; then - for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig="$i" - break - fi - done - fi - fi - - # On ubuntu 14.10, $auto_path on tclsh is not quite correct. - # So try again after applying corrections. - if test x"${ac_cv_c_tclconfig}" = x ; then - if test x"$cross_compiling" = xno; then - for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD} | sed 's,/tcltk/tcl,/tcl,g'` - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig="$i" - break - fi - done - fi - fi - - # Recent versions of Xcode on Macs hid the tclConfig.sh file - # in a strange place. - if test x"${ac_cv_c_tclconfig}" = x ; then - if test x"$cross_compiling" = xno; then - for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig="$i" - break - fi - done - fi - fi - - # then check for a private Tcl installation - if test x"${ac_cv_c_tclconfig}" = x ; then - for i in \ - ../tcl \ - `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ - `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \ - `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \ - ../../tcl \ - `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ - `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \ - `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \ - ../../../tcl \ - `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ - `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \ - `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` - do - if test -f "$i/unix/tclConfig.sh" ; then - ac_cv_c_tclconfig=`(cd $i/unix; pwd)` - break - fi - done - fi - - # check in a few common install locations - if test x"${ac_cv_c_tclconfig}" = x ; then - for i in \ - `ls -d ${libdir} 2>/dev/null` \ - `ls -d /usr/local/lib 2>/dev/null` \ - `ls -d /usr/contrib/lib 2>/dev/null` \ - `ls -d /usr/lib 2>/dev/null` - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig=`(cd $i; pwd)` - break - fi - done - fi - - # check in a few other private locations - if test x"${ac_cv_c_tclconfig}" = x ; then - for i in \ - ${srcdir}/../tcl \ - `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ - `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \ - `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` - do - if test -f "$i/unix/tclConfig.sh" ; then - ac_cv_c_tclconfig=`(cd $i/unix; pwd)` - break - fi - done - fi - ]) - - if test x"${ac_cv_c_tclconfig}" = x ; then - use_tcl=no - AC_MSG_WARN(Can't find Tcl configuration definitions) - AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***) - AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***) - else - TCL_BIN_DIR=${ac_cv_c_tclconfig} - AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh) - - AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh]) - if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then - AC_MSG_RESULT([loading]) - . $TCL_BIN_DIR/tclConfig.sh - else - AC_MSG_RESULT([file not found]) - fi - - # - # If the TCL_BIN_DIR is the build directory (not the install directory), - # then set the common variable name to the value of the build variables. - # For example, the variable TCL_LIB_SPEC will be set to the value - # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC - # instead of TCL_BUILD_LIB_SPEC since it will work with both an - # installed and uninstalled version of Tcl. - # - - if test -f $TCL_BIN_DIR/Makefile ; then - TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC} - TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC} - TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH} - fi - - # - # eval is required to do the TCL_DBGX substitution - # - - eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\"" - eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" - eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" - - eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\"" - eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" - eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" - - AC_SUBST(TCL_VERSION) - AC_SUBST(TCL_BIN_DIR) - AC_SUBST(TCL_SRC_DIR) - AC_SUBST(TCL_INCLUDE_SPEC) - - AC_SUBST(TCL_LIB_FILE) - AC_SUBST(TCL_LIB_FLAG) - AC_SUBST(TCL_LIB_SPEC) - - AC_SUBST(TCL_STUB_LIB_FILE) - AC_SUBST(TCL_STUB_LIB_FLAG) - AC_SUBST(TCL_STUB_LIB_SPEC) - AC_SUBST(TCL_SHLIB_SUFFIX) - fi -fi -if test "${use_tcl}" = "no" ; then - HAVE_TCL="" -else - HAVE_TCL=1 -fi -AC_SUBST(HAVE_TCL) - ########## # Figure out what C libraries are required to compile programs # that use "readline()" library. diff --git a/manifest b/manifest index 488738897e..19bf09ec46 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Include\sa\stest\scase\ssummary\sin\sthe\soutput\sof\s"errors"\sin\stestrunner.tcl. -D 2024-08-01T14:43:27.026 +C Clean\sup\sand\srestructure\sthe\sTCL\sconfiguration\ssections\sin\sautoconf.\nThe\snew\s--with-tclsh=FILE\soption\slets\syou\sselect\sthe\sspecific\stclsh\nthat\syou\swant\sto\srun. +D 2024-08-01T18:10:00.524 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure e0efd210b151971f4158e3fdf93b34322882a668a96f88b6167a6f7a51edebec x -F configure.ac 7361a1dd862c0ba0d2daa3d978bc3b93fcccc1ef3efe204d0238722c19bbdcf5 +F configure 7657b4eaced7589ee0259f7c99ca0b71fe3d47b7fdcc13844b64f77d3084c082 x +F configure.ac 6c41bb7a160c3c057af689f5fbf44bd290ccf2fb68be63b3f8d6a9062b224832 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2104,6 +2104,7 @@ F tool/enlargedb.c 3e8b2612b985cfa7e3e8800031ee191b43ae80de96abb5abbd5eada62651e F tool/extract-sqlite3h.tcl 069ceab0cee26cba99952bfa08c0b23e35941c837acabe143f0c355d96c9e2eb x F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c c129ae2924a48310c7b766810391da9e8fda532b9f6bd3f9a9e3a799a1b42af9 +F tool/find_tclconfig.tcl e64886ffe3b982d4df42cd28ed91fe0b5940c2c5785e126c1821baf61bc86a7e F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/fuzzershell.c 41480c8a1e4749351f381431ecfdfceba645396c5d836f8d26b51a33c4a21b33 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 @@ -2200,8 +2201,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 03b7f99229cfcffde024915e6812d75ae11318db9dc93a00838e4588a79b1243 -R 08e6905a776f74e196253ed63d164e48 +P 173df1478e89996126e172656e35da8026d4ef145b2341ef56213f00ade14f48 +R 9276dc9ad744c7eb260be766cc2b74e8 +T *branch * autoconf-revamp +T *sym-autoconf-revamp * +T -sym-trunk * U drh -Z 096dcbc7b2b21544af81d2d7e8439d72 +Z c7858b737379341436d4877837104339 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7d0cd49d41..0be9acc96b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -173df1478e89996126e172656e35da8026d4ef145b2341ef56213f00ade14f48 +8fafc679d91e857602fbbe203144ca98242246660ede5a49c5fec8aaff571151 diff --git a/tool/find_tclconfig.tcl b/tool/find_tclconfig.tcl new file mode 100644 index 0000000000..c3d3df8ec3 --- /dev/null +++ b/tool/find_tclconfig.tcl @@ -0,0 +1,24 @@ +# +# Run this TCL script to find and print the pathname for the tclConfig.sh +# file. Used by ../configure +# +if {[catch { + set libdir [tcl::pkgconfig get libdir,install] +}]} { + puts stderr "tclsh too old: does not support tcl::pkgconfig" + exit 1 +} +if {![file exists $libdir]} { + puts stderr "tclsh reported library directory \"$libdir\" does not exist" + exit 1 +} +if {![file exists $libdir/tclConfig.sh]} { + set n1 $libdir/tcl$::tcl_version + if {[file exists $n1/tclConfig.sh]} { + set libdir $n1 + } else { + puts stderr "cannot find tclConfig.sh in either $libdir or $n1" + exit 1 + } +} +puts $libdir From 24b1d7a0c8d0ad66864d7600ea60888649e54b5b Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Aug 2024 20:18:10 +0000 Subject: [PATCH 0604/1030] Work on a TCL script that will compile and install the TCL extension. Works on Linux only, so far. This is an incremental check-in. FossilOrigin-Name: 58babd2aa4b5c9c70e1169cdf09f05eb95d7b13f50bb2ec0e487182288172678 --- manifest | 14 ++-- manifest.uuid | 2 +- tool/buildtclext.tcl | 167 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+), 9 deletions(-) create mode 100644 tool/buildtclext.tcl diff --git a/manifest b/manifest index 19bf09ec46..a7deb9327a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clean\sup\sand\srestructure\sthe\sTCL\sconfiguration\ssections\sin\sautoconf.\nThe\snew\s--with-tclsh=FILE\soption\slets\syou\sselect\sthe\sspecific\stclsh\nthat\syou\swant\sto\srun. -D 2024-08-01T18:10:00.524 +C Work\son\sa\sTCL\sscript\sthat\swill\scompile\sand\sinstall\sthe\sTCL\sextension.\nWorks\son\sLinux\sonly,\sso\sfar.\s\sThis\sis\san\sincremental\scheck-in. +D 2024-08-01T20:18:10.470 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2093,6 +2093,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh f193b5e3eb4afcb4abbf96bf1475be6cfb74763ee2e50c82bc7ca105e8a136c5 +F tool/buildtclext.tcl 0ef183d0786744d13b06fec85e2cd4ee7369dd58c3ef2f684c5a616d952777d4 F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2201,11 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 173df1478e89996126e172656e35da8026d4ef145b2341ef56213f00ade14f48 -R 9276dc9ad744c7eb260be766cc2b74e8 -T *branch * autoconf-revamp -T *sym-autoconf-revamp * -T -sym-trunk * +P 8fafc679d91e857602fbbe203144ca98242246660ede5a49c5fec8aaff571151 +R e8c67e263d146ad1487048a2a5cec02e U drh -Z c7858b737379341436d4877837104339 +Z b7f53b5d5d52347992c8bf634ae8776a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0be9acc96b..0a50f25895 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8fafc679d91e857602fbbe203144ca98242246660ede5a49c5fec8aaff571151 +58babd2aa4b5c9c70e1169cdf09f05eb95d7b13f50bb2ec0e487182288172678 diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl new file mode 100644 index 0000000000..947bcf5e4c --- /dev/null +++ b/tool/buildtclext.tcl @@ -0,0 +1,167 @@ +# +# Run this TCL script to build and optionally install the TCL interface +# library for SQLite. Run the script with the specific "tclsh" for which +# the installation should occur. +# +# Options: +# +# --build-only Only build the extension, don't install it +# --install-only Install an extension previously build +# --uninstall Uninstall the extension +# +set installonly 0 +set buildonly 0 +set uninstall 0 +for {set ii 0} {$ii<[llength $argv]} {incr ii} { + set a0 [lindex $argv $ii] + if {$a0=="--install-only"} { + set installonly 1 + } elseif {$a0=="--build-only"} { + set buildonly 1 + } elseif {$a0=="--uninstall"} { + set uninstall 1 + } else { + puts stderr "Unknown option: \"$a0\"" + exit 1 + } +} + +# Find the root of the SQLite source tree +# +set srcdir [file normalize [file dir $argv0]/..] + +# Get the SQLite version number into $VERSION +# +set fd [open $srcdir/VERSION] +set VERSION [string trim [read $fd]] +close $fd + +# Figure out the location of the tclConfig.sh file used by the +# tclsh that is executing this script. +# +if {[catch { + set LIBDIR [tcl::pkgconfig get libdir,install] +}]} { + puts stderr "$argv0: tclsh does not support tcl::pkgconfig." + exit 1 +} +if {![file exists $LIBDIR]} { + puts stderr "$argv0: cannot find the tclConfig.sh file." + puts stderr "$argv0: tclsh reported library directory \"$LIBDIR\"\ + does not exist." + exit 1 +} +if {![file exists $LIBDIR/tclConfig.sh]} { + set n1 $LIBDIR/tcl$::tcl_version + if {[file exists $n1/tclConfig.sh]} { + set LIBDIR $n1 + } else { + puts stderr "$argv0: cannot find tclConfig.sh in either $LIBDIR or $n1" + exit 1 + } +} + +# Read the tclConfig.sh file into the $tclConfig variable +# +set fd [open $LIBDIR/tclConfig.sh rb] +set tclConfig [read $fd] +close $fd + +# Extract parameter we will need from the tclConfig.sh file +# +set TCLMAJOR 8 +regexp {TCL_MAJOR_VERSION='(\d)'} $tclConfig all TCLMAJOR +set SUFFIX so +regexp {TCL_SHLIB_SUFFIX='\.([^']+)'} $tclConfig all SUFFIX +set CC gcc +regexp {TCL_CC='([^']+)'} $tclConfig all CC +set CFLAGS -fPIC +regexp {TCL_SHLIB_CFLAGS='([^']+)'} $tclConfig all CFLAGS +set opt {} +regexp {TCL_CFLAGS_OPTIMIZE='([^']+)'} $tclConfig all opt +if {$opt!=""} { + append CFLAGS " $opt" +} +set LIBS {} +regexp {TCL_STUB_LIB_SPEC='([^']+)'} $tclConfig all LIBS +set INC "-I$srcdir/src" +set inc {} +regexp {TCL_INCLUDE_SPEC='([^']+)'} $tclConfig all inc +if {$inc!=""} { + append INC " $inc" +} +set cmd {} +regexp {TCL_SHLIB_LD='([^']+)'} $tclConfig all cmd +set LDFLAGS $INC +set CMD [subst $cmd] +if {$TCLMAJOR>8} { + set OUT libtcl9sqlite$VERSION.$SUFFIX +} else { + set OUT libsqlite$VERSION.$SUFFIX +} + +# Uninstall the extension +# +if {$uninstall} { + set cnt 0 + foreach dir $auto_path { + if {[file isdirectory $dir/sqlite$VERSION]} { + incr cnt + if {![file writable $dir] || ![file writable $dir/sqlite$VERSION]} { + puts "cannot uninstall $dir/sqlite$VERSION - permission denied" + } else { + puts "uninstalling $dir/sqlite$VERSION..." + file delete -force $dir/sqlite$VERSION + } + } + } + if {$cnt==0} { + puts "nothing to uninstall" + } + exit +} + +# Figure out where the extension will be installed. +# +set DEST {} +foreach dir $auto_path { + if {[file writable $dir]} { + set DEST $dir + break + } +} +if {$DEST==""} { + puts "None of the directories on $auto_path are writable by this process," + puts "so the installation cannot take place. Consider running using sudo" + puts "to work around this." +} + +if {!$installonly} { + # Generate the pkgIndex.tcl file + # + set fd [open pkgIndex.tcl w] + puts $fd [subst -nocommands {# -*- tcl -*- +# Tcl package index file, version ??? +# +package ifneeded sqlite3 $VERSION \\ + [list load [file join \$dir $OUT] sqlite3] +}] + close $fd + + # Generate and execute the command with which to do the compilation. + # + set cmd "$CMD tclsqlite3.c -o $OUT $LIBS" + puts $cmd + exec {*}$cmd +} + +# Install the extension +# +if {$DEST!="" && !$buildonly} { + set DEST2 $DEST/sqlite$VERSION + file mkdir $DEST2 + puts "installing $DEST2/pkgIndex.tcl" + file copy -force pkgIndex.tcl $DEST2 + puts "installing $DEST2/$OUT" + file copy -force $OUT $DEST2 +} From 1bed50d42470ead54ce5236e5978cc398f756c0a Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Aug 2024 20:26:22 +0000 Subject: [PATCH 0605/1030] New makefile targets: tclextension-install and tclextension-uninstall. Seem to work on Linux. FossilOrigin-Name: 534f8344abbda78e841edafe84c27ea8b1dfdecb9ab51271772a7f7264ef5b8c --- Makefile.in | 15 ++++++++------- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/buildtclext.tcl | 2 ++ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4ce4b7392f..bae560b4dc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1556,13 +1556,14 @@ install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_instal $(INSTALL) -d $(DESTDIR)$(pkgconfigdir) $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir) -pkgIndex.tcl: - echo 'package ifneeded sqlite3 $(RELEASE) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] sqlite3]' > $@ -tcl_install: lib_install libtclsqlite3.la pkgIndex.tcl - $(INSTALL) -d $(DESTDIR)$(TCLLIBDIR) - $(LTINSTALL) libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR) - rm -f $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.a - $(INSTALL) -m 0644 pkgIndex.tcl $(DESTDIR)$(TCLLIBDIR) +pkgIndex.tcl: tclsqlite3.c + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --build-only + +tclextension-install: pkgIndex.tcl + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --install-only + +tclextension-uninstall: + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --uninstall clean: rm -f *.lo *.la *.o sqlite3$(TEXE) libsqlite3.la diff --git a/manifest b/manifest index a7deb9327a..e6c0cd9da5 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Work\son\sa\sTCL\sscript\sthat\swill\scompile\sand\sinstall\sthe\sTCL\sextension.\nWorks\son\sLinux\sonly,\sso\sfar.\s\sThis\sis\san\sincremental\scheck-in. -D 2024-08-01T20:18:10.470 +C New\smakefile\stargets:\stclextension-install\sand\stclextension-uninstall.\s\sSeem\nto\swork\son\sLinux. +D 2024-08-01T20:26:22.352 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 58c2cc5010aa5fd5e8eef6fe24d4ebcec7dc2e8c56f135d4f49e90a099bbc531 +F Makefile.in 1e1686272e573f924567483d123abc2a1397cf59c0ec823916a1368b46e13382 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 993f8addade63bcac7192416e7161ceee60edcee2376299ea48b2a74c66ac2d5 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -2093,7 +2093,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh f193b5e3eb4afcb4abbf96bf1475be6cfb74763ee2e50c82bc7ca105e8a136c5 -F tool/buildtclext.tcl 0ef183d0786744d13b06fec85e2cd4ee7369dd58c3ef2f684c5a616d952777d4 +F tool/buildtclext.tcl b360c5133169d555b2b2d6aeac8aece43a34babc672dd6c05fd41ebc850cc14f F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8fafc679d91e857602fbbe203144ca98242246660ede5a49c5fec8aaff571151 -R e8c67e263d146ad1487048a2a5cec02e +P 58babd2aa4b5c9c70e1169cdf09f05eb95d7b13f50bb2ec0e487182288172678 +R 38f4741323b0ec90afecf9f175b90c98 U drh -Z b7f53b5d5d52347992c8bf634ae8776a +Z a4ed4e2858217ff286bef81105749295 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0a50f25895..49f1f98f35 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58babd2aa4b5c9c70e1169cdf09f05eb95d7b13f50bb2ec0e487182288172678 +534f8344abbda78e841edafe84c27ea8b1dfdecb9ab51271772a7f7264ef5b8c diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl index 947bcf5e4c..f2510da98e 100644 --- a/tool/buildtclext.tcl +++ b/tool/buildtclext.tcl @@ -3,6 +3,8 @@ # library for SQLite. Run the script with the specific "tclsh" for which # the installation should occur. # +# Must do "make tclsqlite3.c" first. +# # Options: # # --build-only Only build the extension, don't install it From 58c5a95c07f12a17a554da852cdbbfc0297bded8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Aug 2024 23:00:37 +0000 Subject: [PATCH 0606/1030] Add the tclextension-list makefile target. The the makefile running on Mac. FossilOrigin-Name: 2f667cc8e54167342e17e63e1a017388365ebf4cd379f9c16c12e4603b34a326 --- Makefile.in | 19 +++++++- manifest | 16 +++---- manifest.uuid | 2 +- src/tclsqlite.c | 11 ++++- tool/buildtclext.tcl | 111 ++++++++++++++++++++++++++++++------------- 5 files changed, 112 insertions(+), 47 deletions(-) diff --git a/Makefile.in b/Makefile.in index bae560b4dc..61fcf6e7d6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1556,15 +1556,30 @@ install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_instal $(INSTALL) -d $(DESTDIR)$(pkgconfigdir) $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir) -pkgIndex.tcl: tclsqlite3.c +# Build the SQLite TCL extension in a way that make it compatible +# with whatever version of TCL is running as $TCLSH_CMD, possibly defined +# by --with-tclsh= +# +tclextension: tclsqlite3.c $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --build-only -tclextension-install: pkgIndex.tcl +# Install the SQLite TCL extension in a way that is appropriate for $TCLSH_CMD +# to find it. +# +tclextension-install: tclextension $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --install-only +# Install the SQLite TCL extension that is used by $TCLSH_CMD +# tclextension-uninstall: $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --uninstall +# List all installed the SQLite TCL extension that is are accessible +# by $TCLSH_CMD, included prior versions. +# +tclextension-list: + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --info + clean: rm -f *.lo *.la *.o sqlite3$(TEXE) libsqlite3.la rm -f sqlite3.h opcodes.* diff --git a/manifest b/manifest index e6c0cd9da5..15bb5252ff 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C New\smakefile\stargets:\stclextension-install\sand\stclextension-uninstall.\s\sSeem\nto\swork\son\sLinux. -D 2024-08-01T20:26:22.352 +C Add\sthe\stclextension-list\smakefile\starget.\s\sThe\sthe\smakefile\srunning\son\sMac. +D 2024-08-01T23:00:37.841 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 1e1686272e573f924567483d123abc2a1397cf59c0ec823916a1368b46e13382 +F Makefile.in 4fc6dc2def18b4a2e8fb4c4cad04699e829b3fcefa85974ec71a4a9110a0ea88 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 993f8addade63bcac7192416e7161ceee60edcee2376299ea48b2a74c66ac2d5 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -768,7 +768,7 @@ F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c 8e86ab2595c2ff7bb155331fb173e560180235bceaacce7931a718b1c2e6dfb4 +F src/tclsqlite.c 9bd7443f5db3250dbb073aa6f046a52f939832ac0193c710d6fffb6ca68674be F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 F src/test1.c 51159784f29d3dfd4b50fd6ed9c43c8f7f36925c501a3ad3083528e5e5544bd7 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2093,7 +2093,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh f193b5e3eb4afcb4abbf96bf1475be6cfb74763ee2e50c82bc7ca105e8a136c5 -F tool/buildtclext.tcl b360c5133169d555b2b2d6aeac8aece43a34babc672dd6c05fd41ebc850cc14f +F tool/buildtclext.tcl 23a986cfcb0338e02ad277cebd94d92b37a9cd848fe168f088fa80ca973b4d79 F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 58babd2aa4b5c9c70e1169cdf09f05eb95d7b13f50bb2ec0e487182288172678 -R 38f4741323b0ec90afecf9f175b90c98 +P 534f8344abbda78e841edafe84c27ea8b1dfdecb9ab51271772a7f7264ef5b8c +R 2909fb7ee21646cc58011e08d136b308 U drh -Z a4ed4e2858217ff286bef81105749295 +Z d8a3255efb288995807535829d58616f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 49f1f98f35..01a9c859f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -534f8344abbda78e841edafe84c27ea8b1dfdecb9ab51271772a7f7264ef5b8c +2f667cc8e54167342e17e63e1a017388365ebf4cd379f9c16c12e4603b34a326 diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 906f429ab9..51049b4d21 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -369,12 +369,19 @@ static int SQLITE_TCLAPI incrblobOutput( return nWrite; } +/* The datatype of Tcl_DriverWideSeekProc changes between tcl8.6 and tcl9.0 */ +#if TCL_MAJOR_VERSION==9 +# define WideSeekProcType long lone +#else +# define WideSeekProcType Tcl_WideInt +#endif + /* ** Seek an incremental blob channel. */ -static long long SQLITE_TCLAPI incrblobWideSeek( +static WideSeekProcType SQLITE_TCLAPI incrblobWideSeek( ClientData instanceData, - long long offset, + WideSeekProcType offset, int seekMode, int *errorCodePtr ){ diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl index f2510da98e..26067ecd87 100644 --- a/tool/buildtclext.tcl +++ b/tool/buildtclext.tcl @@ -1,29 +1,38 @@ +#!/usr/bin/tclsh # -# Run this TCL script to build and optionally install the TCL interface -# library for SQLite. Run the script with the specific "tclsh" for which -# the installation should occur. -# -# Must do "make tclsqlite3.c" first. -# -# Options: -# -# --build-only Only build the extension, don't install it -# --install-only Install an extension previously build -# --uninstall Uninstall the extension -# -set installonly 0 -set buildonly 0 +set help \ +{Run this TCL script to build and install the TCL interface library for +SQLite. Run the script with the specific "tclsh" for which the installation +should occur. + +There must be a valid "tclsqlite3.c" file in the working directory prior +to running this script. Use "make tclsqlite3.c" to generate that file. + +Options: + + --build-only Only build the extension, don't install it + --info Show info on existing SQLite TCL extension installs + --install-only Install an extension previously build + --uninstall Uninstall the extension} + + +set build 1 +set install 1 set uninstall 0 +set infoonly 0 for {set ii 0} {$ii<[llength $argv]} {incr ii} { set a0 [lindex $argv $ii] if {$a0=="--install-only"} { - set installonly 1 + set build 0 } elseif {$a0=="--build-only"} { - set buildonly 1 + set install 0 } elseif {$a0=="--uninstall"} { set uninstall 1 + } elseif {$a0=="--info"} { + set infoonly 1 } else { - puts stderr "Unknown option: \"$a0\"" + puts stderr "Unknown option: \"$a0\"\n" + puts stderr $help exit 1 } } @@ -94,7 +103,7 @@ if {$inc!=""} { } set cmd {} regexp {TCL_SHLIB_LD='([^']+)'} $tclConfig all cmd -set LDFLAGS $INC +set LDFLAGS "$INC -DUSE_TCL_STUBS" set CMD [subst $cmd] if {$TCLMAJOR>8} { set OUT libtcl9sqlite$VERSION.$SUFFIX @@ -102,6 +111,24 @@ if {$TCLMAJOR>8} { set OUT libsqlite$VERSION.$SUFFIX } +# Show information about prior installs +# +if {$infoonly} { + set cnt 0 + foreach dir $auto_path { + foreach subdir [glob -nocomplain -types d $dir/sqlite3*] { + if {[file exists $subdir/pkgIndex.tcl]} { + puts $subdir + incr cnt + } + } + } + if {$cnt==0} { + puts "no current installations of the SQLite TCL extension" + } + exit +} + # Uninstall the extension # if {$uninstall} { @@ -123,24 +150,40 @@ if {$uninstall} { exit } -# Figure out where the extension will be installed. -# -set DEST {} -foreach dir $auto_path { - if {[file writable $dir]} { - set DEST $dir - break +if {$install} { + # Figure out where the extension will be installed. Put the extension + # in the first writable directory on $auto_path. + # + set DEST {} + foreach dir $auto_path { + if {[file writable $dir]} { + set DEST $dir + break + } elseif {[glob -nocomplain $dir/sqlite3*/pkgIndex.tcl]!=""} { + set conflict [lindex [glob $dir/sqlite3*/pkgIndex.tcl] 0] + puts "Unable to install. There is already a conflicting version" + puts "of the SQLite TCL Extension that cannot be overwritten at\n" + puts " [file dirname $conflict]\n" + puts "Consider running using sudo to work around this problem." + exit 1 + } + } + if {$DEST==""} { + puts "None of the directories on \$auto_path are writable by this process," + puts "so the installation cannot take place. Consider running using sudo" + puts "to work around this problem.\n" + puts "These are the (unwritable) \$auto_path directories:\n" + foreach dir $auto_path { + puts " * $dir" + } + exit 1 } -} -if {$DEST==""} { - puts "None of the directories on $auto_path are writable by this process," - puts "so the installation cannot take place. Consider running using sudo" - puts "to work around this." } -if {!$installonly} { +if {$build} { # Generate the pkgIndex.tcl file # + puts "generating pkgConfig.tcl..." set fd [open pkgIndex.tcl w] puts $fd [subst -nocommands {# -*- tcl -*- # Tcl package index file, version ??? @@ -157,9 +200,9 @@ package ifneeded sqlite3 $VERSION \\ exec {*}$cmd } -# Install the extension -# -if {$DEST!="" && !$buildonly} { + +if {$install} { + # Install the extension set DEST2 $DEST/sqlite$VERSION file mkdir $DEST2 puts "installing $DEST2/pkgIndex.tcl" From bb99e73ef55cd18764754509affaf333ae345d96 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Aug 2024 23:30:29 +0000 Subject: [PATCH 0607/1030] Simplification the ./configure script. Carry Makefile CFLAGS and OPTS through into builttclext.tcl. Fix a bug in tclsqlite.c introduced by the previous check-in. FossilOrigin-Name: 72a80aa0abb121a23f8cc1eb1af04ba06c733a7a40c06f1fe9e62f2a0a26ca6e --- Makefile.in | 2 +- configure | 51 +++++++++++++++----------------------------- configure.ac | 13 +++-------- manifest | 20 ++++++++--------- manifest.uuid | 2 +- src/tclsqlite.c | 2 +- tool/buildtclext.tcl | 33 ++++++++++++++++++++-------- 7 files changed, 57 insertions(+), 66 deletions(-) diff --git a/Makefile.in b/Makefile.in index 61fcf6e7d6..4e804f889a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1561,7 +1561,7 @@ install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_instal # by --with-tclsh= # tclextension: tclsqlite3.c - $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --build-only + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --build-only --cc $(CC) $(CFLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) # Install the SQLite TCL extension in a way that is appropriate for $TCLSH_CMD # to find it. diff --git a/configure b/configure index 744410589b..3486ebc034 100755 --- a/configure +++ b/configure @@ -795,17 +795,7 @@ VERSION program_prefix TCLLIBDIR HAVE_TCL -TCL_SHLIB_SUFFIX -TCL_STUB_LIB_SPEC -TCL_STUB_LIB_FLAG -TCL_STUB_LIB_FILE TCL_LIB_SPEC -TCL_LIB_FLAG -TCL_LIB_FILE -TCL_INCLUDE_SPEC -TCL_SRC_DIR -TCL_BIN_DIR -TCL_VERSION TCLSH_CMD INSTALL_DATA INSTALL_SCRIPT @@ -3944,13 +3934,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3947: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3937: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3950: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3940: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3953: output\"" >&5) + (eval echo "\"\$as_me:3943: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5156,7 +5146,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5159 "configure"' > conftest.$ac_ext + echo '#line 5149 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6681,11 +6671,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6684: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6674: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6688: \$? = $ac_status" >&5 + echo "$as_me:6678: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7020,11 +7010,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7023: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7013: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7027: \$? = $ac_status" >&5 + echo "$as_me:7017: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7125,11 +7115,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7128: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7118: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7132: \$? = $ac_status" >&5 + echo "$as_me:7122: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7180,11 +7170,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7183: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7173: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7187: \$? = $ac_status" >&5 + echo "$as_me:7177: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9560,7 +9550,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9563 "configure" +#line 9553 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9656,7 +9646,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9659 "configure" +#line 9649 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10397,16 +10387,9 @@ if test x"${with_tcl}" != x; then $as_echo "loading TCL configuration from ${tclconfig}" >&6; } . ${tclconfig} - - - - - - - - - - + # There are lots of other configuration variables that are provided by the + # tclConfig.sh file and that could be included here. But as of right now, + # TCL_LIB_SPEC is the only what that the Makefile uses. fi if test x"$TCLSH_CMD" == x; then TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} diff --git a/configure.ac b/configure.ac index 404a80bffd..fba0755e62 100644 --- a/configure.ac +++ b/configure.ac @@ -144,17 +144,10 @@ if test x"${with_tcl}" != x; then if test x"${tclconfig}" != x; then AC_MSG_RESULT([loading TCL configuration from ${tclconfig}]) . ${tclconfig} - AC_SUBST(TCL_VERSION) - AC_SUBST(TCL_BIN_DIR) - AC_SUBST(TCL_SRC_DIR) - AC_SUBST(TCL_INCLUDE_SPEC) - AC_SUBST(TCL_LIB_FILE) - AC_SUBST(TCL_LIB_FLAG) AC_SUBST(TCL_LIB_SPEC) - AC_SUBST(TCL_STUB_LIB_FILE) - AC_SUBST(TCL_STUB_LIB_FLAG) - AC_SUBST(TCL_STUB_LIB_SPEC) - AC_SUBST(TCL_SHLIB_SUFFIX) + # There are lots of other configuration variables that are provided by the + # tclConfig.sh file and that could be included here. But as of right now, + # TCL_LIB_SPEC is the only what that the Makefile uses. fi if test x"$TCLSH_CMD" == x; then TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} diff --git a/manifest b/manifest index 15bb5252ff..26917c15b6 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\sthe\stclextension-list\smakefile\starget.\s\sThe\sthe\smakefile\srunning\son\sMac. -D 2024-08-01T23:00:37.841 +C Simplification\sthe\s./configure\sscript.\s\sCarry\sMakefile\sCFLAGS\sand\sOPTS\sthrough\ninto\sbuilttclext.tcl.\s\sFix\sa\sbug\sin\stclsqlite.c\sintroduced\sby\sthe\sprevious\ncheck-in. +D 2024-08-01T23:30:29.441 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 4fc6dc2def18b4a2e8fb4c4cad04699e829b3fcefa85974ec71a4a9110a0ea88 +F Makefile.in 3de6a3420170d4f6fac8fd0f338db422ce100be1e64c1e8cb62b85876ebc5fca F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 993f8addade63bcac7192416e7161ceee60edcee2376299ea48b2a74c66ac2d5 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 7657b4eaced7589ee0259f7c99ca0b71fe3d47b7fdcc13844b64f77d3084c082 x -F configure.ac 6c41bb7a160c3c057af689f5fbf44bd290ccf2fb68be63b3f8d6a9062b224832 +F configure 33192bee7d11f68a2be3a1ddf1dc4aa02060675f0bfb48eaf61b63fcd45abedf x +F configure.ac 1665604ede8e83da1454f26eb19dcc7cff70f1b21d305616b6c7cea2d107c005 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -768,7 +768,7 @@ F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955a F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c 9bd7443f5db3250dbb073aa6f046a52f939832ac0193c710d6fffb6ca68674be +F src/tclsqlite.c c6888598f08dee3d9112a38ef42c8f5c89ca7f3190f4694744d0b84250f4bf8c F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 F src/test1.c 51159784f29d3dfd4b50fd6ed9c43c8f7f36925c501a3ad3083528e5e5544bd7 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2093,7 +2093,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh f193b5e3eb4afcb4abbf96bf1475be6cfb74763ee2e50c82bc7ca105e8a136c5 -F tool/buildtclext.tcl 23a986cfcb0338e02ad277cebd94d92b37a9cd848fe168f088fa80ca973b4d79 +F tool/buildtclext.tcl d6e880173bec323f30c0505c5f82eb29c5661bd501d33b5b7a3b5507269dc4f9 F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 534f8344abbda78e841edafe84c27ea8b1dfdecb9ab51271772a7f7264ef5b8c -R 2909fb7ee21646cc58011e08d136b308 +P 2f667cc8e54167342e17e63e1a017388365ebf4cd379f9c16c12e4603b34a326 +R 79bc0ffb836cbf05c7dcfd1908280244 U drh -Z d8a3255efb288995807535829d58616f +Z c826d5650b7fb369e6f2edfd17fa30c3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 01a9c859f1..a4767bc367 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f667cc8e54167342e17e63e1a017388365ebf4cd379f9c16c12e4603b34a326 +72a80aa0abb121a23f8cc1eb1af04ba06c733a7a40c06f1fe9e62f2a0a26ca6e diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 51049b4d21..0c8888fd48 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -371,7 +371,7 @@ static int SQLITE_TCLAPI incrblobOutput( /* The datatype of Tcl_DriverWideSeekProc changes between tcl8.6 and tcl9.0 */ #if TCL_MAJOR_VERSION==9 -# define WideSeekProcType long lone +# define WideSeekProcType long long #else # define WideSeekProcType Tcl_WideInt #endif diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl index 26067ecd87..8d6d0c25b0 100644 --- a/tool/buildtclext.tcl +++ b/tool/buildtclext.tcl @@ -11,15 +11,20 @@ to running this script. Use "make tclsqlite3.c" to generate that file. Options: --build-only Only build the extension, don't install it + --cc COMPILER Build using this compiler --info Show info on existing SQLite TCL extension installs --install-only Install an extension previously build - --uninstall Uninstall the extension} + --uninstall Uninstall the extension + +Other options are retained and passed through into the compiler.} set build 1 set install 1 set uninstall 0 set infoonly 0 +set CC {} +set OPTS {} for {set ii 0} {$ii<[llength $argv]} {incr ii} { set a0 [lindex $argv $ii] if {$a0=="--install-only"} { @@ -30,6 +35,11 @@ for {set ii 0} {$ii<[llength $argv]} {incr ii} { set uninstall 1 } elseif {$a0=="--info"} { set infoonly 1 + } elseif {$a0=="--cc" && $ii+1<[llength $argv]} { + incr ii + set CC [lindex $argv $ii] + } elseif {[string match -* $a0]} { + append OPTS " $a0" } else { puts stderr "Unknown option: \"$a0\"\n" puts stderr $help @@ -84,15 +94,12 @@ set TCLMAJOR 8 regexp {TCL_MAJOR_VERSION='(\d)'} $tclConfig all TCLMAJOR set SUFFIX so regexp {TCL_SHLIB_SUFFIX='\.([^']+)'} $tclConfig all SUFFIX -set CC gcc -regexp {TCL_CC='([^']+)'} $tclConfig all CC +if {$CC==""} { + set CC gcc + regexp {TCL_CC='([^']+)'} $tclConfig all CC +} set CFLAGS -fPIC regexp {TCL_SHLIB_CFLAGS='([^']+)'} $tclConfig all CFLAGS -set opt {} -regexp {TCL_CFLAGS_OPTIMIZE='([^']+)'} $tclConfig all opt -if {$opt!=""} { - append CFLAGS " $opt" -} set LIBS {} regexp {TCL_STUB_LIB_SPEC='([^']+)'} $tclConfig all LIBS set INC "-I$srcdir/src" @@ -104,6 +111,9 @@ if {$inc!=""} { set cmd {} regexp {TCL_SHLIB_LD='([^']+)'} $tclConfig all cmd set LDFLAGS "$INC -DUSE_TCL_STUBS" +if {[string length $OPTS]>1} { + append LDFLAGS $OPTS +} set CMD [subst $cmd] if {$TCLMAJOR>8} { set OUT libtcl9sqlite$VERSION.$SUFFIX @@ -197,7 +207,12 @@ package ifneeded sqlite3 $VERSION \\ # set cmd "$CMD tclsqlite3.c -o $OUT $LIBS" puts $cmd - exec {*}$cmd + if {[catch { + exec {*}$cmd + } errmsg]} { + puts $errmsg + exit 1 + } } From 490661fd967d301985a558d1cce3b1630140fb00 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Aug 2024 00:19:59 +0000 Subject: [PATCH 0608/1030] Extra robustness for the SQLite Tcl Extension builder, so that it works on Debian Linux. FossilOrigin-Name: 2f0738daaff48c51a60f063af6e453443bd7eedf6936daab325b2a36927c7a2b --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/buildtclext.tcl | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 26917c15b6..55d18cc6fd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sthe\s./configure\sscript.\s\sCarry\sMakefile\sCFLAGS\sand\sOPTS\sthrough\ninto\sbuilttclext.tcl.\s\sFix\sa\sbug\sin\stclsqlite.c\sintroduced\sby\sthe\sprevious\ncheck-in. -D 2024-08-01T23:30:29.441 +C Extra\srobustness\sfor\sthe\sSQLite\sTcl\sExtension\sbuilder,\sso\sthat\sit\sworks\non\sDebian\sLinux. +D 2024-08-02T00:19:59.895 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2093,7 +2093,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh f193b5e3eb4afcb4abbf96bf1475be6cfb74763ee2e50c82bc7ca105e8a136c5 -F tool/buildtclext.tcl d6e880173bec323f30c0505c5f82eb29c5661bd501d33b5b7a3b5507269dc4f9 +F tool/buildtclext.tcl 865343ca043c4119e19de9651d01185d0017e588d70f533612c345553cc8160b F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2f667cc8e54167342e17e63e1a017388365ebf4cd379f9c16c12e4603b34a326 -R 79bc0ffb836cbf05c7dcfd1908280244 +P 72a80aa0abb121a23f8cc1eb1af04ba06c733a7a40c06f1fe9e62f2a0a26ca6e +R 30cc174315110745d69ebebfb5ba6cf9 U drh -Z c826d5650b7fb369e6f2edfd17fa30c3 +Z 07ee2d4f800935e6e99694df22387f92 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a4767bc367..d4b99149ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -72a80aa0abb121a23f8cc1eb1af04ba06c733a7a40c06f1fe9e62f2a0a26ca6e +2f0738daaff48c51a60f063af6e453443bd7eedf6936daab325b2a36927c7a2b diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl index 8d6d0c25b0..5b50c627f9 100644 --- a/tool/buildtclext.tcl +++ b/tool/buildtclext.tcl @@ -72,9 +72,11 @@ if {![file exists $LIBDIR]} { does not exist." exit 1 } -if {![file exists $LIBDIR/tclConfig.sh]} { +if {![file exists $LIBDIR/tclConfig.sh] + || [file size $LIBDIR/tclConfig.sh]<5000} { set n1 $LIBDIR/tcl$::tcl_version - if {[file exists $n1/tclConfig.sh]} { + if {[file exists $n1/tclConfig.sh] + && [file size $n1/tclConfig.sh]>5000} { set LIBDIR $n1 } else { puts stderr "$argv0: cannot find tclConfig.sh in either $LIBDIR or $n1" @@ -84,6 +86,7 @@ if {![file exists $LIBDIR/tclConfig.sh]} { # Read the tclConfig.sh file into the $tclConfig variable # +#puts "using $LIBDIR/tclConfig.sh" set fd [open $LIBDIR/tclConfig.sh rb] set tclConfig [read $fd] close $fd @@ -94,9 +97,15 @@ set TCLMAJOR 8 regexp {TCL_MAJOR_VERSION='(\d)'} $tclConfig all TCLMAJOR set SUFFIX so regexp {TCL_SHLIB_SUFFIX='\.([^']+)'} $tclConfig all SUFFIX +if {$CC==""} { + set cc {} + regexp {TCL_CC='([^']+)'} $tclConfig all cc + if {$cc!=""} { + set CC $cc + } +} if {$CC==""} { set CC gcc - regexp {TCL_CC='([^']+)'} $tclConfig all CC } set CFLAGS -fPIC regexp {TCL_SHLIB_CFLAGS='([^']+)'} $tclConfig all CFLAGS @@ -108,7 +117,7 @@ regexp {TCL_INCLUDE_SPEC='([^']+)'} $tclConfig all inc if {$inc!=""} { append INC " $inc" } -set cmd {} +set cmd {${CC} ${CFLAGS} ${LDFLAGS} -shared} regexp {TCL_SHLIB_LD='([^']+)'} $tclConfig all cmd set LDFLAGS "$INC -DUSE_TCL_STUBS" if {[string length $OPTS]>1} { From 0c059b598d6ec7528cb455fe79b58ab67f869bd4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Aug 2024 00:51:52 +0000 Subject: [PATCH 0609/1030] Continuing refinements of the tclextension-install makefile target. FossilOrigin-Name: 871c20a848e0e9b7f3d5661bd076fde16e9ec1e445a7ee657ef267978988ad56 --- Makefile.in | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/buildtclext.tcl | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4e804f889a..626a6bb909 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1566,8 +1566,8 @@ tclextension: tclsqlite3.c # Install the SQLite TCL extension in a way that is appropriate for $TCLSH_CMD # to find it. # -tclextension-install: tclextension - $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --install-only +tclextension-install: tclsqlite3.c + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl # Install the SQLite TCL extension that is used by $TCLSH_CMD # diff --git a/manifest b/manifest index 55d18cc6fd..b182fa3dff 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Extra\srobustness\sfor\sthe\sSQLite\sTcl\sExtension\sbuilder,\sso\sthat\sit\sworks\non\sDebian\sLinux. -D 2024-08-02T00:19:59.895 +C Continuing\srefinements\sof\sthe\stclextension-install\smakefile\starget. +D 2024-08-02T00:51:52.845 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 3de6a3420170d4f6fac8fd0f338db422ce100be1e64c1e8cb62b85876ebc5fca +F Makefile.in 3cbcc2626f946d826350d68e16ecc987cb653117dde77ebfb33179f5ec86b5a9 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 993f8addade63bcac7192416e7161ceee60edcee2376299ea48b2a74c66ac2d5 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -2093,7 +2093,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh f193b5e3eb4afcb4abbf96bf1475be6cfb74763ee2e50c82bc7ca105e8a136c5 -F tool/buildtclext.tcl 865343ca043c4119e19de9651d01185d0017e588d70f533612c345553cc8160b +F tool/buildtclext.tcl 0368eda9802262105d4b1896439889b042a40acfe73e55869ea24edb4fcba94b F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 72a80aa0abb121a23f8cc1eb1af04ba06c733a7a40c06f1fe9e62f2a0a26ca6e -R 30cc174315110745d69ebebfb5ba6cf9 +P 2f0738daaff48c51a60f063af6e453443bd7eedf6936daab325b2a36927c7a2b +R 154770fef55d2b7a022438541d20df55 U drh -Z 07ee2d4f800935e6e99694df22387f92 +Z fb4c8793f898a65a5ea5be50709db328 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d4b99149ef..fb3c0b0c69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f0738daaff48c51a60f063af6e453443bd7eedf6936daab325b2a36927c7a2b +871c20a848e0e9b7f3d5661bd076fde16e9ec1e445a7ee657ef267978988ad56 diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl index 5b50c627f9..011f01cb5b 100644 --- a/tool/buildtclext.tcl +++ b/tool/buildtclext.tcl @@ -216,9 +216,9 @@ package ifneeded sqlite3 $VERSION \\ # set cmd "$CMD tclsqlite3.c -o $OUT $LIBS" puts $cmd - if {[catch { - exec {*}$cmd - } errmsg]} { + file delete -force $OUT + catch {exec {*}$cmd} errmsg + if {$errmsg!="" && ![file exists $OUT]} { puts $errmsg exit 1 } From ea9a25e5005a8e405738b1bcebf1f96eae0ba23c Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Aug 2024 00:56:31 +0000 Subject: [PATCH 0610/1030] Previous Makefile.in change broke the tclextension-install target. FossilOrigin-Name: 7748367c78a1f480ec9e892ba77652e3c31a4b387b89221ae584891818804851 --- Makefile.in | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile.in b/Makefile.in index 626a6bb909..778dc08493 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1567,7 +1567,7 @@ tclextension: tclsqlite3.c # to find it. # tclextension-install: tclsqlite3.c - $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --cc $(CC) $(CFLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) # Install the SQLite TCL extension that is used by $TCLSH_CMD # diff --git a/manifest b/manifest index b182fa3dff..c5f9ba6e5a 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Continuing\srefinements\sof\sthe\stclextension-install\smakefile\starget. -D 2024-08-02T00:51:52.845 +C Previous\sMakefile.in\schange\sbroke\sthe\stclextension-install\starget. +D 2024-08-02T00:56:31.886 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 3cbcc2626f946d826350d68e16ecc987cb653117dde77ebfb33179f5ec86b5a9 +F Makefile.in fbfe18ff577bcb35b1236015e442667bcdf94230cef07a0897e26f3cab5bf488 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 993f8addade63bcac7192416e7161ceee60edcee2376299ea48b2a74c66ac2d5 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2f0738daaff48c51a60f063af6e453443bd7eedf6936daab325b2a36927c7a2b -R 154770fef55d2b7a022438541d20df55 +P 871c20a848e0e9b7f3d5661bd076fde16e9ec1e445a7ee657ef267978988ad56 +R ba9c12b4ec23352b095b4f17c1f3bef8 U drh -Z fb4c8793f898a65a5ea5be50709db328 +Z bc0e02f193279e0ca2d17c115ebd2a46 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fb3c0b0c69..797363580e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -871c20a848e0e9b7f3d5661bd076fde16e9ec1e445a7ee657ef267978988ad56 +7748367c78a1f480ec9e892ba77652e3c31a4b387b89221ae584891818804851 From eb48fddac73b11aea3a83d0f86141fcb9f85ec11 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Aug 2024 11:32:28 +0000 Subject: [PATCH 0611/1030] Fix problems in the configure/Makefile system caused by recent enhancements and report by [forum:/forumpost/242ebd0c81|forum post 242ebd0c81]. FossilOrigin-Name: a59319fe4adc094381c46e490289b3e0cda8f804edaea6984571c47a68a23eef --- Makefile.in | 4 ---- configure | 32 ++++++++++++++++++-------------- configure.ac | 2 ++ manifest | 17 ++++++++--------- manifest.uuid | 2 +- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/Makefile.in b/Makefile.in index 778dc08493..c83e76a3db 100644 --- a/Makefile.in +++ b/Makefile.in @@ -121,10 +121,6 @@ TCLSH_CMD = @TCLSH_CMD@ # TCLLIBDIR = @TCLLIBDIR@ -# The suffix used on shared libraries. Ex: ".dll", ".so", ".dylib" -# -SHLIB_SUFFIX = @TCL_SHLIB_SUFFIX@ - # If gcov support was enabled by the configure script, add the appropriate # flags here. It's not always as easy as just having the user add the right # CFLAGS / LDFLAGS, because libtool wants to use CFLAGS when linking, which diff --git a/configure b/configure index 3486ebc034..616fb26276 100755 --- a/configure +++ b/configure @@ -795,7 +795,9 @@ VERSION program_prefix TCLLIBDIR HAVE_TCL +TCL_STUB_LIB_SPEC TCL_LIB_SPEC +TCL_INCLUDE_SPEC TCLSH_CMD INSTALL_DATA INSTALL_SCRIPT @@ -3934,13 +3936,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3937: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3939: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3940: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3942: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3943: output\"" >&5) + (eval echo "\"\$as_me:3945: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5146,7 +5148,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5149 "configure"' > conftest.$ac_ext + echo '#line 5151 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6671,11 +6673,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6674: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6676: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6678: \$? = $ac_status" >&5 + echo "$as_me:6680: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7010,11 +7012,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7013: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7015: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7017: \$? = $ac_status" >&5 + echo "$as_me:7019: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7115,11 +7117,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7118: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7120: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7122: \$? = $ac_status" >&5 + echo "$as_me:7124: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7170,11 +7172,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7173: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7175: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7177: \$? = $ac_status" >&5 + echo "$as_me:7179: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9550,7 +9552,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9553 "configure" +#line 9555 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9646,7 +9648,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9649 "configure" +#line 9651 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10387,6 +10389,8 @@ if test x"${with_tcl}" != x; then $as_echo "loading TCL configuration from ${tclconfig}" >&6; } . ${tclconfig} + + # There are lots of other configuration variables that are provided by the # tclConfig.sh file and that could be included here. But as of right now, # TCL_LIB_SPEC is the only what that the Makefile uses. diff --git a/configure.ac b/configure.ac index fba0755e62..7526c211dc 100644 --- a/configure.ac +++ b/configure.ac @@ -144,7 +144,9 @@ if test x"${with_tcl}" != x; then if test x"${tclconfig}" != x; then AC_MSG_RESULT([loading TCL configuration from ${tclconfig}]) . ${tclconfig} + AC_SUBST(TCL_INCLUDE_SPEC) AC_SUBST(TCL_LIB_SPEC) + AC_SUBST(TCL_STUB_LIB_SPEC) # There are lots of other configuration variables that are provided by the # tclConfig.sh file and that could be included here. But as of right now, # TCL_LIB_SPEC is the only what that the Makefile uses. diff --git a/manifest b/manifest index b778d5d880..023e985314 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C New\sconfiguration\soption:\s\s--with-tclsh=FILE.\s\sNew\smakefile\stargets:\ntclextension,\stclextension-install,\stclextension-uninstall,\ntclextension-list. -D 2024-08-02T00:59:32.758 +C Fix\sproblems\sin\sthe\sconfigure/Makefile\ssystem\scaused\sby\srecent\senhancements\nand\sreport\sby\s[forum:/forumpost/242ebd0c81|forum\spost\s242ebd0c81]. +D 2024-08-02T11:32:28.781 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in fbfe18ff577bcb35b1236015e442667bcdf94230cef07a0897e26f3cab5bf488 +F Makefile.in d9d8d60efaad73dde2ed2380ab3ae3b9b15cb98089d0a7d0573f39de7f093ea2 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 993f8addade63bcac7192416e7161ceee60edcee2376299ea48b2a74c66ac2d5 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 33192bee7d11f68a2be3a1ddf1dc4aa02060675f0bfb48eaf61b63fcd45abedf x -F configure.ac 1665604ede8e83da1454f26eb19dcc7cff70f1b21d305616b6c7cea2d107c005 +F configure 187978aa8b6e5bfe261bce02a883f82f7a1d239f95e53cbb5eb6be0aaab2a5b6 x +F configure.ac 50ac86967b264eab4f2925ae8c981601f154aa090ef2fd0c413974fca63251d0 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2202,9 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 173df1478e89996126e172656e35da8026d4ef145b2341ef56213f00ade14f48 7748367c78a1f480ec9e892ba77652e3c31a4b387b89221ae584891818804851 -R ba9c12b4ec23352b095b4f17c1f3bef8 -T +closed 7748367c78a1f480ec9e892ba77652e3c31a4b387b89221ae584891818804851 +P 888284d1d47269e66e23627e2519cd2cf83ef65a777a679af20c288453f092e2 +R 93c99f8e3949df92d18547af26ca7640 U drh -Z d1d647e1ea5237f2d093d8aa4cd2371f +Z ef0c9981348aa214ce55c288609b3967 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 942974cd56..5f086dac62 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -888284d1d47269e66e23627e2519cd2cf83ef65a777a679af20c288453f092e2 +a59319fe4adc094381c46e490289b3e0cda8f804edaea6984571c47a68a23eef From 9e88d4bb8a3143e7cc03d569e0c496bbd59049d8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Aug 2024 13:56:55 +0000 Subject: [PATCH 0612/1030] Fix typo in a progress message in the builttclext.tcl script. FossilOrigin-Name: 5e7c94645632b736e805428ff4c135666ab525fac99c29c12d5127b06f39fc6e --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/buildtclext.tcl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 023e985314..a208551566 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sproblems\sin\sthe\sconfigure/Makefile\ssystem\scaused\sby\srecent\senhancements\nand\sreport\sby\s[forum:/forumpost/242ebd0c81|forum\spost\s242ebd0c81]. -D 2024-08-02T11:32:28.781 +C Fix\stypo\sin\sa\sprogress\smessage\sin\sthe\sbuilttclext.tcl\sscript. +D 2024-08-02T13:56:55.670 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2093,7 +2093,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh f193b5e3eb4afcb4abbf96bf1475be6cfb74763ee2e50c82bc7ca105e8a136c5 -F tool/buildtclext.tcl 0368eda9802262105d4b1896439889b042a40acfe73e55869ea24edb4fcba94b +F tool/buildtclext.tcl 6b8907c6a7b6734940513886d06ea9c00d2f3ba62ce39208db4e2ea5d115198b F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 888284d1d47269e66e23627e2519cd2cf83ef65a777a679af20c288453f092e2 -R 93c99f8e3949df92d18547af26ca7640 +P a59319fe4adc094381c46e490289b3e0cda8f804edaea6984571c47a68a23eef +R 50f27b8d2c62eae13aeca51f3735d0b2 U drh -Z ef0c9981348aa214ce55c288609b3967 +Z d21a99cc930b4bc362ff91cb037b47fd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5f086dac62..bd9c9a3c54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a59319fe4adc094381c46e490289b3e0cda8f804edaea6984571c47a68a23eef +5e7c94645632b736e805428ff4c135666ab525fac99c29c12d5127b06f39fc6e diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl index 011f01cb5b..016f5751d2 100644 --- a/tool/buildtclext.tcl +++ b/tool/buildtclext.tcl @@ -202,7 +202,7 @@ if {$install} { if {$build} { # Generate the pkgIndex.tcl file # - puts "generating pkgConfig.tcl..." + puts "generating pkgIndex.tcl..." set fd [open pkgIndex.tcl w] puts $fd [subst -nocommands {# -*- tcl -*- # Tcl package index file, version ??? From dcea6335c7e8c50194a341da328f52822a5fa54c Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Aug 2024 15:28:40 +0000 Subject: [PATCH 0613/1030] New MSVC makefile targets: tclextension, tclextension-install, tclextension-uninstall, and tclextension-list. FossilOrigin-Name: c38734f57509c50dd28029738dd602600950703b773d9b7b60fdb1dcb06e8fd8 --- Makefile.msc | 13 ++++ manifest | 14 ++-- manifest.uuid | 2 +- tool/buildtclext.tcl | 154 ++++++++++++++++++++++++------------------- 4 files changed, 107 insertions(+), 76 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index a5191739ff..e31aee0899 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1820,6 +1820,19 @@ pkgIndex.tcl: $(TOP)\VERSION $(SQLITE3TCLDLL): libtclsqlite3.lib $(LIBRESOBJS) tclsqlite3.def pkgIndex.tcl $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /DEF:tclsqlite3.def /OUT:$@ libtclsqlite3.lib $(LIBRESOBJS) $(LTLIBS) $(TLIBS) + +tclextension: $(SQLITE3TCLDLL) + +tclextension-install: $(SQLITE3TCLDLL) + $(TCLSH_CMD) $(TOP)\tool\buildtclext.tcl --install-only + +tclextension-uninstall: + $(TCLSH_CMD) $(TOP)\tool\buildtclext.tcl --uninstall + +tclextension-list: + $(TCLSH_CMD) $(TOP)\tool\buildtclext.tcl --info + + # <> $(SQLITE3DLL): $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP) diff --git a/manifest b/manifest index a208551566..0e8de61d1a 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Fix\stypo\sin\sa\sprogress\smessage\sin\sthe\sbuilttclext.tcl\sscript. -D 2024-08-02T13:56:55.670 +C New\sMSVC\smakefile\stargets:\s\stclextension,\stclextension-install,\ntclextension-uninstall,\sand\stclextension-list. +D 2024-08-02T15:28:40.391 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in d9d8d60efaad73dde2ed2380ab3ae3b9b15cb98089d0a7d0573f39de7f093ea2 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 993f8addade63bcac7192416e7161ceee60edcee2376299ea48b2a74c66ac2d5 +F Makefile.msc 6c3fe8b6ce60e73f34a148c957d78b4648745c8d30e792423aa1a8d8bf12d065 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -2093,7 +2093,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh f193b5e3eb4afcb4abbf96bf1475be6cfb74763ee2e50c82bc7ca105e8a136c5 -F tool/buildtclext.tcl 6b8907c6a7b6734940513886d06ea9c00d2f3ba62ce39208db4e2ea5d115198b +F tool/buildtclext.tcl b64d250517b148e644d26fcbc097851867a0df52cd4bafe9bcd94b8421e1428a F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a59319fe4adc094381c46e490289b3e0cda8f804edaea6984571c47a68a23eef -R 50f27b8d2c62eae13aeca51f3735d0b2 +P 5e7c94645632b736e805428ff4c135666ab525fac99c29c12d5127b06f39fc6e +R 34f8aa4c5bd786ba6f617a118e3aad0d U drh -Z d21a99cc930b4bc362ff91cb037b47fd +Z 99d8311f9a3fa0ec204446f79bbc573f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bd9c9a3c54..e3145013e7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e7c94645632b736e805428ff4c135666ab525fac99c29c12d5127b06f39fc6e +c38734f57509c50dd28029738dd602600950703b773d9b7b60fdb1dcb06e8fd8 diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl index 016f5751d2..6d9e4c3063 100644 --- a/tool/buildtclext.tcl +++ b/tool/buildtclext.tcl @@ -32,8 +32,12 @@ for {set ii 0} {$ii<[llength $argv]} {incr ii} { } elseif {$a0=="--build-only"} { set install 0 } elseif {$a0=="--uninstall"} { + set build 0 + set install 0 set uninstall 1 } elseif {$a0=="--info"} { + set build 0 + set install 0 set infoonly 1 } elseif {$a0=="--cc" && $ii+1<[llength $argv]} { incr ii @@ -57,79 +61,93 @@ set fd [open $srcdir/VERSION] set VERSION [string trim [read $fd]] close $fd -# Figure out the location of the tclConfig.sh file used by the -# tclsh that is executing this script. -# -if {[catch { - set LIBDIR [tcl::pkgconfig get libdir,install] -}]} { - puts stderr "$argv0: tclsh does not support tcl::pkgconfig." - exit 1 -} -if {![file exists $LIBDIR]} { - puts stderr "$argv0: cannot find the tclConfig.sh file." - puts stderr "$argv0: tclsh reported library directory \"$LIBDIR\"\ - does not exist." - exit 1 -} -if {![file exists $LIBDIR/tclConfig.sh] - || [file size $LIBDIR/tclConfig.sh]<5000} { - set n1 $LIBDIR/tcl$::tcl_version - if {[file exists $n1/tclConfig.sh] - && [file size $n1/tclConfig.sh]>5000} { - set LIBDIR $n1 - } else { - puts stderr "$argv0: cannot find tclConfig.sh in either $LIBDIR or $n1" +if {$tcl_platform(platform)=="windows"} { + # We are only able to install, uninstall, and list on Windows. + # The build process is handled by the Makefile.msc, specifically + # using "nmake /f Makefile.msc pkgIndex.tcl tclsqlite3.dll" + # + if {$build} { + puts "Unable to build on Windows using the builttclext.tcl script." + puts "To build, run\n" + puts " \"nmake /f Makefile.msc pkgIndex.tcl tclsqlite3.dll" exit 1 } -} - -# Read the tclConfig.sh file into the $tclConfig variable -# -#puts "using $LIBDIR/tclConfig.sh" -set fd [open $LIBDIR/tclConfig.sh rb] -set tclConfig [read $fd] -close $fd + set OUT tclsqlite3.dll +} else { + # Figure out the location of the tclConfig.sh file used by the + # tclsh that is executing this script. + # + if {[catch { + set LIBDIR [tcl::pkgconfig get libdir,install] + }]} { + puts stderr "$argv0: tclsh does not support tcl::pkgconfig." + exit 1 + } + if {![file exists $LIBDIR]} { + puts stderr "$argv0: cannot find the tclConfig.sh file." + puts stderr "$argv0: tclsh reported library directory \"$LIBDIR\"\ + does not exist." + exit 1 + } + if {![file exists $LIBDIR/tclConfig.sh] + || [file size $LIBDIR/tclConfig.sh]<5000} { + set n1 $LIBDIR/tcl$::tcl_version + if {[file exists $n1/tclConfig.sh] + && [file size $n1/tclConfig.sh]>5000} { + set LIBDIR $n1 + } else { + puts stderr "$argv0: cannot find tclConfig.sh in either $LIBDIR or $n1" + exit 1 + } + } -# Extract parameter we will need from the tclConfig.sh file -# -set TCLMAJOR 8 -regexp {TCL_MAJOR_VERSION='(\d)'} $tclConfig all TCLMAJOR -set SUFFIX so -regexp {TCL_SHLIB_SUFFIX='\.([^']+)'} $tclConfig all SUFFIX -if {$CC==""} { - set cc {} - regexp {TCL_CC='([^']+)'} $tclConfig all cc - if {$cc!=""} { - set CC $cc + # Read the tclConfig.sh file into the $tclConfig variable + # + #puts "using $LIBDIR/tclConfig.sh" + set fd [open $LIBDIR/tclConfig.sh rb] + set tclConfig [read $fd] + close $fd + + # Extract parameter we will need from the tclConfig.sh file + # + set TCLMAJOR 8 + regexp {TCL_MAJOR_VERSION='(\d)'} $tclConfig all TCLMAJOR + set SUFFIX so + regexp {TCL_SHLIB_SUFFIX='\.([^']+)'} $tclConfig all SUFFIX + if {$CC==""} { + set cc {} + regexp {TCL_CC='([^']+)'} $tclConfig all cc + if {$cc!=""} { + set CC $cc + } + } + if {$CC==""} { + set CC gcc + } + set CFLAGS -fPIC + regexp {TCL_SHLIB_CFLAGS='([^']+)'} $tclConfig all CFLAGS + set LIBS {} + regexp {TCL_STUB_LIB_SPEC='([^']+)'} $tclConfig all LIBS + set INC "-I$srcdir/src" + set inc {} + regexp {TCL_INCLUDE_SPEC='([^']+)'} $tclConfig all inc + if {$inc!=""} { + append INC " $inc" + } + set cmd {${CC} ${CFLAGS} ${LDFLAGS} -shared} + regexp {TCL_SHLIB_LD='([^']+)'} $tclConfig all cmd + set LDFLAGS "$INC -DUSE_TCL_STUBS" + if {[string length $OPTS]>1} { + append LDFLAGS $OPTS + } + set CMD [subst $cmd] + if {$TCLMAJOR>8} { + set OUT libtcl9sqlite$VERSION.$SUFFIX + } else { + set OUT libsqlite$VERSION.$SUFFIX } } -if {$CC==""} { - set CC gcc -} -set CFLAGS -fPIC -regexp {TCL_SHLIB_CFLAGS='([^']+)'} $tclConfig all CFLAGS -set LIBS {} -regexp {TCL_STUB_LIB_SPEC='([^']+)'} $tclConfig all LIBS -set INC "-I$srcdir/src" -set inc {} -regexp {TCL_INCLUDE_SPEC='([^']+)'} $tclConfig all inc -if {$inc!=""} { - append INC " $inc" -} -set cmd {${CC} ${CFLAGS} ${LDFLAGS} -shared} -regexp {TCL_SHLIB_LD='([^']+)'} $tclConfig all cmd -set LDFLAGS "$INC -DUSE_TCL_STUBS" -if {[string length $OPTS]>1} { - append LDFLAGS $OPTS -} -set CMD [subst $cmd] -if {$TCLMAJOR>8} { - set OUT libtcl9sqlite$VERSION.$SUFFIX -} else { - set OUT libsqlite$VERSION.$SUFFIX -} - + # Show information about prior installs # if {$infoonly} { From b2d590c5f918be381b9aeb3a4a3dd0b60908b808 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Aug 2024 17:36:34 +0000 Subject: [PATCH 0614/1030] Add the "-d SECS" option to the "status" command of testrunner.tcl FossilOrigin-Name: 2151ea31632f7aa363c7d4b7205e1174a45d710783a8efad8176049d356cfc70 --- manifest | 12 ++-- manifest.uuid | 2 +- test/testrunner.tcl | 160 ++++++++++++++++++++++++++++---------------- 3 files changed, 109 insertions(+), 65 deletions(-) diff --git a/manifest b/manifest index 0e8de61d1a..d42c57accb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\sMSVC\smakefile\stargets:\s\stclextension,\stclextension-install,\ntclextension-uninstall,\sand\stclextension-list. -D 2024-08-02T15:28:40.391 +C Add\sthe\s"-d\sSECS"\soption\sto\sthe\s"status"\scommand\sof\stestrunner.tcl +D 2024-08-02T17:36:34.415 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1705,7 +1705,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef -F test/testrunner.tcl f6ac1a55ce4c9278cf8c4dbaed1facd347c9b80acae5d32511c3bf3e529a4817 +F test/testrunner.tcl 8a32439556e7ebba144e30c46cca95a3780647bd4f0101f3d43fbf92ef86414d F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5e7c94645632b736e805428ff4c135666ab525fac99c29c12d5127b06f39fc6e -R 34f8aa4c5bd786ba6f617a118e3aad0d +P c38734f57509c50dd28029738dd602600950703b773d9b7b60fdb1dcb06e8fd8 +R 83c1979a453bc44130a53ce766cc177f U drh -Z 99d8311f9a3fa0ec204446f79bbc573f +Z 6d452c8f357818d9c3aa4547edb14d11 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e3145013e7..304debfec0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c38734f57509c50dd28029738dd602600950703b773d9b7b60fdb1dcb06e8fd8 +2151ea31632f7aa363c7d4b7205e1174a45d710783a8efad8176049d356cfc70 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index aeb015865d..80cf3ff9b9 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -58,7 +58,7 @@ Usage: $a0 help $a0 njob ?NJOB? $a0 script ?-msvc? CONFIG - $a0 status + $a0 status ?-d SECS? where SWITCHES are: --buildonly Build test exes but do not run tests @@ -101,8 +101,9 @@ with the specified permutation. The "status" and "njob" commands are designed to be run from the same directory as a running testrunner.tcl script that is running tests. The "status" command prints a report describing the current state and progress -of the tests. The "njob" command may be used to query or modify the number -of sub-processes the test script uses to run tests. +of the tests. Use the "-d N" option to have the status display clear the +screen and repeat every N seconds. The "njob" command may be used to query +or modify the number of sub-processes the test script uses to run tests. The "script" command outputs the script used to build a configuration. Add the "-msvc" option for a Windows-compatible script. For a list of @@ -390,10 +391,24 @@ if {[string compare -nocase script [lindex $argv 0]]==0} { #-------------------------------------------------------------------------- # Check if this is the "status" command: # -if {[llength $argv]==1 +if {[llength $argv]>=1 && [string compare -nocase status [lindex $argv 0]]==0 } { - + set delay 0 + for {set ii 1} {$ii<[llength $argv]} {incr ii} { + set a0 [lindex $argv $ii] + if {$a0=="-d" && $ii+1<[llength $argv]} { + incr ii + set delay [lindex $argv $ii] + if {![string is integer -strict $delay]} { + puts "Argument to -d should be an integer" + exit 1 + } + } else { + puts "unknown option: \"$a0\"" + exit 1 + } + } proc display_job {jobdict {tm ""}} { array set job $jobdict @@ -404,71 +419,100 @@ if {[llength $argv]==1 puts " $dfname $dtm" } + # The clreol proc returns the VT100 escape code for clear-to-end-of-line, + # if delay>0. If we are only painting the status once, it returns an + # empty string. + # + if {$delay>0} { + proc clreol {} {return ""} + } else { + proc clreol {} {return \033K} + } + if {![file readable $TRG(dbname)]} { puts "Database missing: $TRG(dbname)" exit } sqlite3 mydb $TRG(dbname) mydb timeout 2000 - mydb eval BEGIN - - if {[catch { - set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }] - set nJob [mydb one { SELECT value FROM config WHERE name='njob' }] - } msg]} { - puts "Cannot read database: $TRG(dbname)" - mydb close - exit - } - - set now [clock_milliseconds] - set tm [mydb one { - SELECT - COALESCE((SELECT value FROM config WHERE name='end'), $now) - - (SELECT value FROM config WHERE name='start') - }] - - set total 0 - foreach s {"" ready running done failed} { set S($s) 0 } - mydb eval { - SELECT state, count(*) AS cnt FROM jobs GROUP BY 1 - } { - incr S($state) $cnt - incr total $cnt - } - set fin [expr $S(done)+$S(failed)] - if {$cmdline!=""} {set cmdline " $cmdline"} - set f "" - if {$S(failed)>0} { - set f "$S(failed) FAILED, " - } - puts "Command line: \[testrunner.tcl$cmdline\]" - puts "Jobs: $nJob" - puts "Summary: ${tm}ms, ($fin/$total) finished, ${f}$S(running) running" - - set srcdir [file dirname [file dirname $TRG(info_script)]] - if {$S(running)>0} { - puts "Running: " - mydb eval { - SELECT * FROM jobs WHERE state='running' ORDER BY starttime - } job { - display_job [array get job] $now + # Clear the whole screen initially. + # + if {$delay>0} {puts -nonewline "\033\[2J"} + + while {1} { + mydb eval BEGIN + if {[catch { + set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }] + set nJob [mydb one { SELECT value FROM config WHERE name='njob' }] + } msg]} { + puts "Cannot read database: $TRG(dbname)" + mydb close + exit } - } - if {$S(failed)>0} { - puts "Failures: " + + set now [clock_milliseconds] + set tm [mydb one { + SELECT + COALESCE((SELECT value FROM config WHERE name='end'), $now) - + (SELECT value FROM config WHERE name='start') + }] + + set total 0 + foreach s {"" ready running done failed} { set S($s) 0 } mydb eval { - SELECT * FROM jobs WHERE state='failed' ORDER BY starttime - } job { - display_job [array get job] + SELECT state, count(*) AS cnt FROM jobs GROUP BY 1 + } { + incr S($state) $cnt + incr total $cnt + } + set fin [expr $S(done)+$S(failed)] + if {$cmdline!=""} {set cmdline " $cmdline"} + + if {$delay>0} { + # Move the cursor to the top-left corner. Each iteration will simply + # overwrite. + puts -nonewline "\033\[H" + } + set f "" + if {$S(failed)>0} { + set f "$S(failed) FAILED, " + } + puts "Command line: \[testrunner.tcl$cmdline\]" + puts "Jobs: $nJob" + puts "Summary: ${tm}ms, ($fin/$total) finished,\ + ${f}$S(running) running " + + set srcdir [file dirname [file dirname $TRG(info_script)]] + if {$S(running)>0} { + puts "Running: " + mydb eval { + SELECT * FROM jobs WHERE state='running' ORDER BY starttime + } job { + display_job [array get job] $now + } + } + if {$S(failed)>0} { + puts "Failures: " + mydb eval { + SELECT * FROM jobs WHERE state='failed' ORDER BY starttime + } job { + display_job [array get job] + } + set nOmit [mydb one {SELECT count(*) FROM jobs WHERE state='omit'}] + if {$nOmit} { + puts "$nOmit jobs omitted due to failures[clreol]" + } } - set nOmit [mydb one {SELECT count(*) FROM jobs WHERE state='omit'}] - if {$nOmit} { - puts "$nOmit jobs omitted due to failures" + if {$delay>0} { + # Clear everything else to the bottom of the screen + puts -nonewline "\033\[J" + flush stdout } + mydb eval COMMIT + if {$delay<=0} break + after [expr {$delay*1000}] } - mydb close exit } From 8517b7d2b6a47591edb8808be7d38adb967d6625 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Aug 2024 18:20:10 +0000 Subject: [PATCH 0615/1030] Make sure the input buffer is big enough for an memcpy() when doing the restore autodetection in the shell. FossilOrigin-Name: 1637d29d518b3b4534a1b4c0dc0eddcb770f6f71763e4177812a3e79b97d2365 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d42c57accb..9200a9a3a8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"-d\sSECS"\soption\sto\sthe\s"status"\scommand\sof\stestrunner.tcl -D 2024-08-02T17:36:34.415 +C Make\ssure\sthe\sinput\sbuffer\sis\sbig\senough\sfor\san\smemcpy()\swhen\sdoing\sthe\nrestore\sautodetection\sin\sthe\sshell. +D 2024-08-02T18:20:10.582 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e -F src/shell.c.in 44c02fd1581d95e066b479241e081f37dc95c98452badd03627ef2a1c21bdc80 +F src/shell.c.in 271bc66d805cedc9064d6218434bdaadb207d917dcecb4f46c17e5ff66085590 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c38734f57509c50dd28029738dd602600950703b773d9b7b60fdb1dcb06e8fd8 -R 83c1979a453bc44130a53ce766cc177f +P 2151ea31632f7aa363c7d4b7205e1174a45d710783a8efad8176049d356cfc70 +R 4661deca42f48a6dcbd9a9e1fd37e56e U drh -Z 6d452c8f357818d9c3aa4547edb14d11 +Z dd91b61800449a04528ebdc3156c12eb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 304debfec0..40805aee4e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2151ea31632f7aa363c7d4b7205e1174a45d710783a8efad8176049d356cfc70 +1637d29d518b3b4534a1b4c0dc0eddcb770f6f71763e4177812a3e79b97d2365 diff --git a/src/shell.c.in b/src/shell.c.in index f389c1f475..eea87b2dc7 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -11640,7 +11640,10 @@ static int doAutoDetectRestore(ShellState *p, const char *zSql){ case 0: { const char *zExpect = "PRAGMA foreign_keys=OFF;"; assert( strlen(zExpect)==24 ); - if( p->bSafeMode==0 && memcmp(zSql, zExpect, 25)==0 ){ + if( p->bSafeMode==0 + && strlen(zSql)>=25 + && memcmp(zSql, zExpect, 25)==0 + ){ p->eRestoreState = 1; }else{ p->eRestoreState = 7; From e317e7f4b4238bb16f33aa6831eb09376adf5115 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 2 Aug 2024 21:06:13 +0000 Subject: [PATCH 0616/1030] Change things so that locale=1 is required to write fts5_locale() values to an fts5 table, and so that blobs may not be stored in indexed (i.e. not UNINDEXED) columns of these tables. FossilOrigin-Name: c98ccc12169419b8b27ead89ef0665de40320277c5daa748b80869337419e43e --- ext/fts5/fts5Int.h | 11 -- ext/fts5/fts5_config.c | 7 -- ext/fts5/fts5_main.c | 222 +++++++++++++++------------------- ext/fts5/fts5_storage.c | 46 +++---- ext/fts5/test/fts5blob.test | 94 +++++++++++--- ext/fts5/test/fts5locale.test | 52 +++++++- manifest | 22 ++-- manifest.uuid | 2 +- 8 files changed, 255 insertions(+), 201 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 53e269df93..5f10d5773e 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -208,12 +208,6 @@ struct Fts5TokenizerConfig { ** ** bLocale: ** Set to true if locale=1 was specified when the table was created. -** -** eEnc: -** Set to either FTS5_ENCODING_UNKNOWN, ENCODING_UTF8, or ENCODING_UTF16, -** to indicate the encoding used by the database handle. This is initially -** set to UNKNOWN, then to one of the other two values the first time it -** is required. */ struct Fts5Config { sqlite3 *db; /* Database handle */ @@ -236,7 +230,6 @@ struct Fts5Config { char *zContentExprlist; Fts5TokenizerConfig t; int bLock; /* True when table is preparing statement */ - int eEnc; /* An FTS5_ENCODING_XXX constant */ /* Values loaded from the %_config table */ @@ -278,10 +271,6 @@ struct Fts5Config { #define FTS5_PATTERN_LIKE 65 /* matches SQLITE_INDEX_CONSTRAINT_LIKE */ #define FTS5_PATTERN_GLOB 66 /* matches SQLITE_INDEX_CONSTRAINT_GLOB */ -#define FTS5_ENCODING_UNKNOWN 0 -#define FTS5_ENCODING_UTF8 1 -#define FTS5_ENCODING_UTF16 2 - int sqlite3Fts5ConfigParse( Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char** ); diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 1312f459db..0d86d81622 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -615,13 +615,6 @@ int sqlite3Fts5ConfigParse( sqlite3_free(zTwo); } - /* If this is not an FTS5_CONTENT_NORMAL table, set bLocale. There are - ** no restrictions on using fts5_locale() with external-content or - ** contentless tables. */ - if( pRet->eContent!=FTS5_CONTENT_NORMAL ){ - pRet->bLocale = 1; - } - /* We only allow contentless_delete=1 if the table is indeed contentless. */ if( rc==SQLITE_OK && pRet->bContentlessDelete diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index c9c01aafea..6f2e8de88c 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -244,6 +244,7 @@ struct Fts5Cursor { ** The subtype values returned by fts5_locale() are tagged with. */ #define FTS5_LOCALE_SUBTYPE ((unsigned int)'L') +#define FTS5_LOCALE_HEADER "\x00\xE0\xB2\xEB" /* @@ -1268,43 +1269,6 @@ void sqlite3Fts5ClearLocale(Fts5Config *pConfig){ fts5SetLocale(pConfig, 0, 0); } -/* -** This function is used to determine if the database handle uses utf-8 or -** a utf-16 encoding. If it uses utf-8, then output parameter (*pbIs) is set -** to 0. Otherwise, if it uses utf-16, then the output parameter is set -** to 1. -** -** This function returns SQLITE_OK if successful, or an SQLite error code -** otherwise. If an error code is returned, the final value of (*pbIs) is -** undefined. -*/ -static int fts5IsUtf16( - Fts5Config *pConfig, /* Configuration object */ - int *pbIs /* OUT: True if utf-16, false if utf-8 */ -){ - if( pConfig->eEnc==FTS5_ENCODING_UNKNOWN ){ - sqlite3_stmt *pPragma = 0; - int rc = fts5PrepareStatement(&pPragma, pConfig, - "SELECT (encoding LIKE '%%16%%') FROM pragma_encoding" - ); - if( rc==SQLITE_OK ){ - int val; - sqlite3_step(pPragma); - val = sqlite3_column_int(pPragma, 0); - rc = sqlite3_finalize(pPragma); - if( rc!=SQLITE_OK ) return rc; - if( val ){ - pConfig->eEnc = FTS5_ENCODING_UTF16; - }else{ - pConfig->eEnc = FTS5_ENCODING_UTF8; - } - } - } - - *pbIs = (pConfig->eEnc==FTS5_ENCODING_UTF16); - return SQLITE_OK; -} - /* ** This function is used to extract utf-8 text from an sqlite3_value. This ** is usually done in order to tokenize it. For example, when: @@ -1315,25 +1279,14 @@ static int fts5IsUtf16( ** ** and so on. ** -** This function handles 3 cases: +** This function handles 2 cases: ** ** 1) Ordinary values. The text can be extracted from these using ** sqlite3_value_text(). ** ** 2) Blobs tagged with sub-type FTS5_LOCALE_SUBTYPE, or those read from -** the content table of an FTS5_CONTENT_NORMAL table with locale=1 -** set that do not begin with 0x00. -** -** In these cases the value is a blob formatted by fts5_locale() that -** contains both a locale and a text value. The locale is first, as -** utf-8, followed by a single 0x00 byte, followed by the text value, -** also as utf-8. There is no nul-terminator for the text value. -** -** 3) Blobs read from the content table of an FTS5_CONTENT_NORMAL table -** with locale=1 set that do begin with 0x00. These are used to -** store actual SQLITE_BLOB values written to the fts5 table by the -** user. They begin with 4 0x00 bytes, followed by the blob data as -** specified by the user. +** the content table of a normal content or external-conten table +** with locale=1 set. ** ** If successful, SQLITE_OK is returned and output parameters (*ppText) ** and (*pnText) are set to point to a buffer containing the extracted utf-8 @@ -1342,9 +1295,7 @@ static int fts5IsUtf16( ** from which it is extracted. ** ** Parameter bContent must be true if the value was read from an indexed -** column (i.e. not UNINDEXED) of the on disk content. In this case, if -** the table is FTS5_CONTENT_NORMAL and locale=1 was specified, special blob -** cases (2) and (3) above will apply. +** column (i.e. not UNINDEXED) of the on disk content. ** ** If pbResetTokenizer is not NULL and if case (2) is used, then the ** tokenizer is configured to use the locale. In this case (*pbResetTokenizer) @@ -1366,57 +1317,50 @@ int sqlite3Fts5ExtractText( int bDecodeBlob = 0; assert( pbResetTokenizer==0 || *pbResetTokenizer==0 ); + assert( bContent==0 || pConfig->eContent!=FTS5_CONTENT_NONE ); + assert( bContent==0 || sqlite3_value_subtype(pVal)==0 ); if( sqlite3_value_type(pVal)==SQLITE_BLOB ){ if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE - || (bContent && pConfig->bLocale && pConfig->eContent==FTS5_CONTENT_NORMAL) + || (bContent && pConfig->bLocale) ){ bDecodeBlob = 1; } } if( bDecodeBlob ){ + const int SZHDR = sizeof(FTS5_LOCALE_HEADER)-1; const u8 *pBlob = sqlite3_value_blob(pVal); int nBlob = sqlite3_value_bytes(pVal); - int nLocale = 0; - - if( nBlob>=4 && memcmp(pBlob, "\0\0\0\0", 4)==0 ){ - /* Extract the text from a blob stored in a locale=1 table. The - ** value consists of 4 0x00 bytes followed by the blob specified - ** by the user. The extracted text has to match the text extracted - ** when the blob was inserted - by calling sqlite3_value_text() on - ** the value without the 4 0x00 byte header. - ** - ** The tricky bit here is that the exact text extracted from a blob - ** depends on the encoding of the database. To avoid reimplementing - ** SQLite's blob-to-text conversion code here, we call - ** sqlite3_value_text() on the blob with the header, then trim off the - ** leading utf-8 characters that the 4 byte header was converted to. In - ** practice this is 4 0x00 bytes for a utf-8 database, or 2 0x00 bytes - ** for a utf-16 database. */ - int bIs16 = 0; /* True for utf-16 database */ - pText = (const char*)sqlite3_value_text(pVal); - nText = sqlite3_value_bytes(pVal); - rc = fts5IsUtf16(pConfig, &bIs16); - if( bIs16 ){ - pText += 2; - nText -= 2; + + /* Unless this blob was read from the %_content table of an + ** FTS5_CONTENT_NORMAL table, it should have the 4 byte fts5_locale() + ** header. Check for this. If it is not found, return an error. */ + if( (!bContent || pConfig->eContent!=FTS5_CONTENT_NORMAL) ){ + if( nBlobnCol; ii++){ + if( sqlite3_value_type(apVal[ii+2])==SQLITE_BLOB ){ + int bSub = (sqlite3_value_subtype(apVal[ii+2])==FTS5_LOCALE_SUBTYPE); + if( (pConfig->bLocale && !bSub && pConfig->abUnindexed[ii]==0) + || (pConfig->bLocale==0 && bSub) + ){ + if( pConfig->bLocale==0 ){ + fts5SetVtabError(pTab, "fts5_locale() requires locale=1"); + } + rc = SQLITE_MISMATCH; + goto update_out; + } + } + } + if( eType0!=SQLITE_INTEGER ){ /* An INSERT statement. If the conflict-mode is REPLACE, first remove ** the current entry (if any). */ @@ -2074,6 +2037,7 @@ static int fts5UpdateMethod( } } + update_out: pTab->p.pConfig->pzErrmsg = 0; return rc; } @@ -2712,11 +2676,17 @@ static int fts5ApiColumnLocale( */ sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1); if( sqlite3_value_type(pVal)==SQLITE_BLOB ){ - if( pConfig->eContent==FTS5_CONTENT_NORMAL - || sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE - ){ - const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); - int nBlob = sqlite3_value_bytes(pVal); + const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); + int nBlob = sqlite3_value_bytes(pVal); + if( pConfig->eContent==FTS5_CONTENT_EXTERNAL ){ + const int SZHDR = sizeof(FTS5_LOCALE_HEADER)-1; + if( nBlobeContent!=FTS5_CONTENT_NONE ); + if( pConfig->bLocale && sqlite3_value_type(pVal)==SQLITE_BLOB && pConfig->abUnindexed[iCol]==0 ){ - if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE - || pConfig->eContent==FTS5_CONTENT_NORMAL - ){ - const u8 *pBlob = sqlite3_value_blob(pVal); - int nBlob = sqlite3_value_bytes(pVal); + const int SZHDR = sizeof(FTS5_LOCALE_HEADER)-1; + const u8 *pBlob = sqlite3_value_blob(pVal); + int nBlob = sqlite3_value_bytes(pVal); + int ii; - if( nBlob>=4 && memcmp(pBlob, "\0\0\0\0", 4)==0 ){ - sqlite3_result_blob(pCtx, &pBlob[4], nBlob-4, SQLITE_TRANSIENT); + if( pConfig->eContent==FTS5_CONTENT_EXTERNAL ){ + if( nBlobpSavedRow, i-1); }else if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE ){ - if( pConfig->bLocale==0 ){ - sqlite3Fts5ConfigErrmsg(pConfig, - "fts5_locale() may not be used without locale=1" - ); - rc = SQLITE_ERROR; - break; - }else if( i>1 && pConfig->abUnindexed[i-2] ){ - /* At attempt to insert an fts5_locale() value into an UNINDEXED - ** column. Strip the locale away and just bind the text. */ - const char *pText = 0; - int nText = 0; - rc = sqlite3Fts5ExtractText(pConfig, pVal, 0, 0, &pText, &nText); - sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); + assert( pConfig->bLocale ); + if( i>1 ){ + if( pConfig->abUnindexed[i-2] ){ + /* At attempt to insert an fts5_locale() value into an UNINDEXED + ** column. Strip the locale away and just bind the text. */ + const char *pText = 0; + int nText = 0; + rc = sqlite3Fts5ExtractText(pConfig, pVal, 0, 0, &pText, &nText); + sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); + }else{ + const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); + int nBlob = sqlite3_value_bytes(pVal); + assert( nBlob>4 ); + sqlite3_bind_blob(pInsert, i, pBlob+4, nBlob-4, SQLITE_TRANSIENT); + } continue; } - }else if( pConfig->bLocale - && sqlite3_value_type(pVal)==SQLITE_BLOB - && i>=2 && pConfig->abUnindexed[i-2]==0 - ){ - /* Inserting a blob into a normal content table with locale=1. - ** Add the 4 0x00 byte header. */ - int n = sqlite3_value_bytes(pVal); - u8 *pBlob = sqlite3Fts5MallocZero(&rc, n+4); - if( pBlob ){ - memcpy(&pBlob[4], sqlite3_value_blob(pVal), n); - rc = sqlite3_bind_blob(pInsert, i, pBlob, n+4, SQLITE_TRANSIENT); - sqlite3_free(pBlob); - } - continue; } rc = sqlite3_bind_value(pInsert, i, pVal); diff --git a/ext/fts5/test/fts5blob.test b/ext/fts5/test/fts5blob.test index 56a571b9c4..985fe2888c 100644 --- a/ext/fts5/test/fts5blob.test +++ b/ext/fts5/test/fts5blob.test @@ -9,6 +9,19 @@ # #*********************************************************************** # +# This file verifies that: +# +# * blob values may be written to locale=0 tables. +# +# * blob values - other than fts5_locale() values - may not be written +# to locale=0 tables. This is an SQLITE_MISMATCH error +# +# * blob values may be returned by queries on the external-content table +# of a locale=0 table. +# +# * blob values not may be returned by queries on the external-content +# table of a locale=1 table, apart from fts5_locale() blobs. This is an +# SQLITE_MISMATCH error. # source [file join [file dirname [info script]] fts5_common.tcl] @@ -20,11 +33,11 @@ ifcapable !fts5 { return } -foreach {tn enc locale} { - 1 utf8 0 - 2 utf8 1 - 3 utf16 0 - 4 utf16 1 +# Test that blobs may be stored in normal locale=0 tables. +# +foreach {tn enc} { + 1 utf8 + 2 utf16 } { reset_db fts5_aux_test_functions db @@ -32,7 +45,7 @@ foreach {tn enc locale} { execsql "PRAGMA encoding = $enc" execsql " - CREATE VIRTUAL TABLE t1 USING fts5(x, y, locale=$locale); + CREATE VIRTUAL TABLE t1 USING fts5(x, y); " do_execsql_test 1.$tn.0 { CREATE VIRTUAL TABLE tt USING fts5vocab('t1', 'instance'); @@ -49,9 +62,6 @@ foreach {tn enc locale} { 3 777 'xyz' } - set T($enc,$locale) [execsql { SELECT * FROM tt }] - set U($enc,$locale) [execsql { SELECT fts5_test_columntext(t1) FROM t1 }] - do_execsql_test 1.$tn.2 { DELETE FROM t1 WHERE rowid=2; DELETE FROM t1 WHERE rowid=1; @@ -62,27 +72,77 @@ foreach {tn enc locale} { } {ok} } -do_test 1.5.1 { set T(utf8,1) } $T(utf8,0) -do_test 1.5.2 { set T(utf16,1) } $T(utf16,0) - -do_test 1.6.1 { set U(utf8,1) } $U(utf8,0) -do_test 1.6.2 { set U(utf16,1) } $U(utf16,0) - - #-------------------------------------------------------------------------- +# Test that a blob may be stored and retrieved in an unindexed column of +# a regular table with locale=1. +# reset_db do_execsql_test 2.0 { CREATE VIRTUAL TABLE t1 USING fts5(x, y UNINDEXED, locale=1); INSERT INTO t1(rowid, x, y) VALUES(12, 'twelve', X'0000000041424320444546'); } -breakpoint do_execsql_test 2.1 { select rowid, x, quote(y) FROM t1 } { 12 twelve X'0000000041424320444546' } +#-------------------------------------------------------------------------- +# Test that blobs may not be written to any type of table with locale=1 +# set. Except, they may be written to UNINDEXED columns. +# +reset_db +do_execsql_test 3.0 { + CREATE TABLE t1(a, b); + + CREATE VIRTUAL TABLE x1 USING fts5(a, b, locale=1); + CREATE VIRTUAL TABLE x2 USING fts5(a, b, locale=1, content=t2); + CREATE VIRTUAL TABLE x3 USING fts5(a, b, locale=1, content=); +} + +do_catchsql_test 3.1 { + INSERT INTO x1(rowid, a, b) VALUES(113, 'hello world', X'123456'); +} {1 {datatype mismatch}} +do_catchsql_test 3.2 { + INSERT INTO x2(rowid, a, b) VALUES(113, 'hello world', X'123456'); +} {1 {datatype mismatch}} +do_catchsql_test 3.3 { + INSERT INTO x3(rowid, a, b) VALUES(113, 'hello world', X'123456'); +} {1 {datatype mismatch}} + + +#-------------------------------------------------------------------------- +# Test that fts5_locale() values may not be written to any type of table +# without locale=1 set. Even to an UNINDEXED column. +# +reset_db +do_execsql_test 3.0 { + CREATE TABLE t1(a, b); + + CREATE VIRTUAL TABLE x1 USING fts5(a, b); + CREATE VIRTUAL TABLE x2 USING fts5(a, b, content=t2); + CREATE VIRTUAL TABLE x3 USING fts5(a, b, content=); + + CREATE VIRTUAL TABLE x4 USING fts5(a, b, c UNINDEXED); +} + +do_catchsql_test 3.1 { + INSERT INTO x1(rowid, a, b) + VALUES(113, 'hello world', fts5_locale('en_AU', 'abc')); +} {1 {fts5_locale() requires locale=1}} +do_catchsql_test 3.2 { + INSERT INTO x2(rowid, a, b) + VALUES(113, 'hello world', fts5_locale('en_AU', 'abc')); +} {1 {fts5_locale() requires locale=1}} +do_catchsql_test 3.3 { + INSERT INTO x3(rowid, a, b) + VALUES(113, 'hello world', fts5_locale('en_AU', 'abc')); +} {1 {fts5_locale() requires locale=1}} +do_catchsql_test 3.4 { + INSERT INTO x4(rowid, a, b, c) + VALUES(113, 'hello world', 'yesno', fts5_locale('en_AU', 'abc')); +} {1 {fts5_locale() requires locale=1}} finish_test diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index d3fd9989c0..40ed28243c 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -107,7 +107,7 @@ do_execsql_test 2.5 { do_catchsql_test 2.6 { INSERT INTO b2 VALUES('def', fts5_locale('reverse', 'four five six')); -} {1 {fts5_locale() may not be used without locale=1}} +} {1 {fts5_locale() requires locale=1}} do_execsql_test 2.7 { SELECT rowid FROM b1('one') } {1} do_execsql_test 2.8 { SELECT rowid FROM b1('four') } {} @@ -149,7 +149,7 @@ reset_db sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create do_execsql_test 3.1 { - CREATE VIRTUAL TABLE c1 USING fts5(x, content=, tokenize=tcl); + CREATE VIRTUAL TABLE c1 USING fts5(x, content=, tokenize=tcl, locale=1); CREATE VIRTUAL TABLE c2 USING fts5vocab('c1', instance); INSERT INTO c1 VALUES('hello world'); @@ -343,12 +343,58 @@ do_execsql_test 6.0 { } do_catchsql_test 6.1 { INSERT INTO x1(rowid, x) VALUES(123, fts5_locale('en_AU', 'hello world')); -} {1 {fts5_locale() may not be used without locale=1}} +} {1 {fts5_locale() requires locale=1}} do_execsql_test 6.2 { SELECT typeof( fts5_locale(NULL, 'xyz') ), typeof( fts5_locale('', 'abc') ); } {text text} +#-------------------------------------------------------------------------- +# Test that fts5_locale() works with virtual tables. +# +reset_db +sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create +# optimization_control db query-flattener 0 + +do_execsql_test 7.1 { + CREATE TABLE t1(ii INTEGER PRIMARY KEY, bb BLOB, tt TEXT, locale TEXT); + CREATE VIEW v1 AS + SELECT ii AS rowid, bb, fts5_locale(locale, tt) AS tt FROM t1; + + CREATE VIRTUAL TABLE ft USING fts5( + bb, tt, locale=1, tokenize=tcl, content=v1 + ); + + INSERT INTO t1 VALUES(1, NULL, 'one two three', NULL); + INSERT INTO t1 VALUES(2, '7800616263', 'four five six', 'reverse'); + INSERT INTO t1 VALUES(3, '000000007800616263', 'seven eight nine', 'second'); +} + +do_execsql_test 7.2 { + INSERT INTO ft(ft) VALUES('rebuild'); + INSERT INTO ft(ft) VALUES('integrity-check'); +} + +do_execsql_test 7.3 { + SELECT rowid, quote(bb), quote(tt) FROM ft +} { + 1 NULL {'one two three'} + 2 '7800616263' {'four five six'} + 3 '000000007800616263' {'seven eight nine'} +} + +do_execsql_test 7.4 { SELECT rowid FROM ft('six'); } +do_execsql_test 7.5 { SELECT rowid FROM ft(fts5_locale('reverse','six')); } 2 + +fts5_aux_test_functions db + +do_execsql_test 7.6 { + SELECT fts5_test_columnlocale(ft) FROM ft; +} { + {{} {}} {{} reverse} {{} second} +} + + finish_test diff --git a/manifest b/manifest index fc335fa46f..fdb1dfd115 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clarify\sthe\srole\sof\sFts5Storage.pSavedRow\sin\sthe\snew\sfeature\son\sthis\sbranch. -D 2024-08-01T17:15:17.507 +C Change\sthings\sso\sthat\slocale=1\sis\srequired\sto\swrite\sfts5_locale()\svalues\sto\san\sfts5\stable,\sand\sso\sthat\sblobs\smay\snot\sbe\sstored\sin\sindexed\s(i.e.\snot\sUNINDEXED)\scolumns\sof\sthese\stables. +D 2024-08-02T21:06:13.360 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,15 +93,15 @@ F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6d F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h f5451da088d0004c4be7314e2fdb41fda16ce682ce2aa3b54b9474ebe9a013d5 -F ext/fts5/fts5Int.h 2eab38c52d12bfa0a1cedb742276035e05634c6365f8defb599f023bb8743559 +F ext/fts5/fts5Int.h 64ccc862cbf3be08103ed9435b8670017019f5bd620db4e4317936170008b2b1 F ext/fts5/fts5_aux.c 598c80fc0faabab91c833cdda99f8e36387bd907f4acb0480a19b612a4add93e F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 31267fc68f9d16feaa5b5f7efb902a3410f0caa708cc2372c90a77d75890b2a8 +F ext/fts5/fts5_config.c b7924194b5dc035d9f0bd82c74564e133ff38aaa2edf86d8a95c23c9c82ba17f F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c bda8d421024191376343a571370a7b2f92fdf5303e32c6dc0d7456bef9ffedd8 -F ext/fts5/fts5_storage.c 784c6c4edf676c831ffbaef7b0484dcafe925d3d39049b8ee6b6eeaadae1b042 +F ext/fts5/fts5_main.c 79b1d6099d8140afbd930a4e280759728099f584f91e39a8e81f2df0a0e0e839 +F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 F ext/fts5/fts5_tcl.c 93b705cb87633574983161edc5234f9b91ba03f9fecfbd2c5d401a1da6f93aa5 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -132,7 +132,7 @@ F ext/fts5/test/fts5auxdata.test 372549088ff792655f73e62b9dfaf4863ce74f5e604c06c F ext/fts5/test/fts5bigid.test 2860854c2561a57594192b00c33a29f91cb85e25f3d6c03b5c2b8f62708f39dd F ext/fts5/test/fts5bigpl.test 8f09858aab866c33593560e6480b2b6975ae7ff29ca32ad7b77e2da61402f8ef F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36 -F ext/fts5/test/fts5blob.test 6d1cf0c5ba2e6f8f9b4e915d3677c16ead3a79c22dcb386c0b21169a9349718d +F ext/fts5/test/fts5blob.test 2f84ef3591dd3eb0efa686a3615e9ed5c5005462c663c7c72c350692b99f91f5 F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62 F ext/fts5/test/fts5colset.test 544f4998cdbfe06a3123887fc0221612e8aa8192cdaff152872f1aadb10e6897 @@ -185,7 +185,7 @@ F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fd F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test bfd8704f9bea963314fcbcf810f08a357ac8035bcb80a2d6170c1e57fa6ad52a +F ext/fts5/test/fts5locale.test 57f4effee98b8c3b8b63f80ce08cc424e68a4ef1b7ce74a91c1e64b2d213053e F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2201,8 +2201,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8bd4ae7e95c7b6ce34db5ea705dc136e742a22f333d0e7370b485ebd736b5ec2 -R 65a2f69590c259e395cd85b8f6d4acad +P e8a61d5c48073fdd4d99d0b6fc70469b37af009f281336a44e3789e7eeed820d +R 1b40b0a91a44b0bf6782847dce5b9e1d U dan -Z cbe99cb860ae582ece42e3b6610aa855 +Z 06efbaab9999ac759a0d226937b631dd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0c89f035e2..09bba22cd4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e8a61d5c48073fdd4d99d0b6fc70469b37af009f281336a44e3789e7eeed820d +c98ccc12169419b8b27ead89ef0665de40320277c5daa748b80869337419e43e From 4a36d304930cf3df27e43f8821fe149cce08cf88 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 3 Aug 2024 15:55:25 +0000 Subject: [PATCH 0617/1030] Add the --status option to the test runs using testrunner.tcl. Only works on Unix platforms. The "exec" command appears to interfere with VT100 escape codes on windows. FossilOrigin-Name: 94015cda4ceb4292ceceadb951fe5d9cb3e4e20403719b7254ad094a5b749ab3 --- manifest | 12 +- manifest.uuid | 2 +- test/testrunner.tcl | 289 ++++++++++++++++++++++++-------------------- 3 files changed, 167 insertions(+), 136 deletions(-) diff --git a/manifest b/manifest index 9200a9a3a8..cd4233fd08 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\sinput\sbuffer\sis\sbig\senough\sfor\san\smemcpy()\swhen\sdoing\sthe\nrestore\sautodetection\sin\sthe\sshell. -D 2024-08-02T18:20:10.582 +C Add\sthe\s--status\soption\sto\sthe\stest\sruns\susing\stestrunner.tcl.\s\sOnly\sworks\non\sUnix\splatforms.\s\sThe\s"exec"\scommand\sappears\sto\sinterfere\swith\sVT100\nescape\scodes\son\swindows. +D 2024-08-03T15:55:25.995 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1705,7 +1705,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef -F test/testrunner.tcl 8a32439556e7ebba144e30c46cca95a3780647bd4f0101f3d43fbf92ef86414d +F test/testrunner.tcl 5d02deeba7a53baeadae6aa7641d90aac58fdfa3a7bcac85cfcfd752b1aab87c F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2151ea31632f7aa363c7d4b7205e1174a45d710783a8efad8176049d356cfc70 -R 4661deca42f48a6dcbd9a9e1fd37e56e +P 1637d29d518b3b4534a1b4c0dc0eddcb770f6f71763e4177812a3e79b97d2365 +R 2baa0a7875a2461a2d1db67ee8455074 U drh -Z dd91b61800449a04528ebdc3156c12eb +Z cdd1e09ba643f6fa1e24fe72f8439dd6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 40805aee4e..551ed083cd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1637d29d518b3b4534a1b4c0dc0eddcb770f6f71763e4177812a3e79b97d2365 +94015cda4ceb4292ceceadb951fe5d9cb3e4e20403719b7254ad094a5b749ab3 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 80cf3ff9b9..d3a2c1f4c9 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -58,7 +58,7 @@ Usage: $a0 help $a0 njob ?NJOB? $a0 script ?-msvc? CONFIG - $a0 status ?-d SECS? + $a0 status ?-d SECS? ?--cls? where SWITCHES are: --buildonly Build test exes but do not run tests @@ -67,6 +67,7 @@ Usage: --explain Write summary to stdout --jobs NUM Run tests using NUM separate processes --omit CONFIGS Omit configs on comma-separated list CONFIGS + --status Show the full "status" report while running --stop-on-coredump Stop running if any test segfaults --stop-on-error Stop running after any reported error --zipvfs ZIPVFSDIR ZIPVFS source directory @@ -187,6 +188,7 @@ set TRG(dryrun) 0 ;# True if --dryrun option set TRG(explain) 0 ;# True for the --explain option set TRG(stopOnError) 0 ;# Stop running at first failure set TRG(stopOnCore) 0 ;# Stop on a core-dump +set TRG(fullstatus) 0 ;# Full "status" report while running switch -nocase -glob -- $tcl_platform(os) { *darwin* { @@ -386,6 +388,99 @@ if {[string compare -nocase script [lindex $argv 0]]==0} { puts [trd_buildscript $config [file dirname $testdir] $bMsvc] exit } + +# Helper routine for show_status +# +proc display_job {jobdict {tm ""}} { + array set job $jobdict + set dfname [format %-60s $job(displayname)] + set dtm "" + if {$tm!=""} { + set dtm [format %-10s "\[[expr {$tm-$job(starttime)}]ms\]"] + } + puts " $dfname $dtm" +} + +# This procedure shows the "status" page. It uses the database +# connect passed in as the "db" parameter. If the "cls" parameter +# is true, then VT100 escape codes are used to format the display. +# +proc show_status {db cls} { + global TRG + $db eval BEGIN + if {[catch { + set cmdline [$db one { SELECT value FROM config WHERE name='cmdline' }] + set nJob [$db one { SELECT value FROM config WHERE name='njob' }] + } msg]} { + if {$cls} {puts "\033\[H\033\[2J"} + puts "Cannot read database: $TRG(dbname)" + return + } + set now [clock_milliseconds] + set tm [$db one { + SELECT + COALESCE((SELECT value FROM config WHERE name='end'), $now) - + (SELECT value FROM config WHERE name='start') + }] + + set total 0 + foreach s {"" ready running done failed} { set S($s) 0 } + $db eval { + SELECT state, count(*) AS cnt FROM jobs GROUP BY 1 + } { + incr S($state) $cnt + incr total $cnt + } + set fin [expr $S(done)+$S(failed)] + if {$cmdline!=""} {set cmdline " $cmdline"} + + if {$cls} { + # Move the cursor to the top-left corner. Each iteration will simply + # overwrite. + puts -nonewline "\033\[H" + flush stdout + set clreol "\033\[K" + } else { + set clreol "" + } + set f "" + if {$S(failed)>0} { + set f "$S(failed) FAILED, " + } + puts "Command line: \[testrunner.tcl$cmdline\]$clreol" + puts "Jobs: $nJob " + puts "Summary: ${tm}ms, ($fin/$total) finished,\ + ${f}$S(running) running " + + set srcdir [file dirname [file dirname $TRG(info_script)]] + if {$S(running)>0} { + puts "Running: " + $db eval { + SELECT * FROM jobs WHERE state='running' ORDER BY starttime + } job { + display_job [array get job] $now + } + } + if {$S(failed)>0} { + puts "Failures: " + $db eval { + SELECT * FROM jobs WHERE state='failed' ORDER BY starttime + } job { + display_job [array get job] + } + set nOmit [$db one {SELECT count(*) FROM jobs WHERE state='omit'}] + if {$nOmit} { + puts "$nOmit jobs omitted due to failures$clreol" + } + } + if {$cls} { + # Clear everything else to the bottom of the screen + puts -nonewline "\033\[0J" + flush stdout + } + $db eval COMMIT +} + #-------------------------------------------------------------------------- @@ -395,6 +490,7 @@ if {[llength $argv]>=1 && [string compare -nocase status [lindex $argv 0]]==0 } { set delay 0 + set cls 0 for {set ii 1} {$ii<[llength $argv]} {incr ii} { set a0 [lindex $argv $ii] if {$a0=="-d" && $ii+1<[llength $argv]} { @@ -404,30 +500,13 @@ if {[llength $argv]>=1 puts "Argument to -d should be an integer" exit 1 } + } elseif {$a0=="-cls" || $a0=="--cls"} { + set cls 1 } else { puts "unknown option: \"$a0\"" exit 1 } } - proc display_job {jobdict {tm ""}} { - array set job $jobdict - - set dfname [format %-60s $job(displayname)] - - set dtm "" - if {$tm!=""} { set dtm "\[[expr {$tm-$job(starttime)}]ms\]" } - puts " $dfname $dtm" - } - - # The clreol proc returns the VT100 escape code for clear-to-end-of-line, - # if delay>0. If we are only painting the status once, it returns an - # empty string. - # - if {$delay>0} { - proc clreol {} {return ""} - } else { - proc clreol {} {return \033K} - } if {![file readable $TRG(dbname)]} { puts "Database missing: $TRG(dbname)" @@ -438,78 +517,10 @@ if {[llength $argv]>=1 # Clear the whole screen initially. # - if {$delay>0} {puts -nonewline "\033\[2J"} + if {$delay>0 || $cls} {puts -nonewline "\033\[2J"} while {1} { - mydb eval BEGIN - if {[catch { - set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }] - set nJob [mydb one { SELECT value FROM config WHERE name='njob' }] - } msg]} { - puts "Cannot read database: $TRG(dbname)" - mydb close - exit - } - - set now [clock_milliseconds] - set tm [mydb one { - SELECT - COALESCE((SELECT value FROM config WHERE name='end'), $now) - - (SELECT value FROM config WHERE name='start') - }] - - set total 0 - foreach s {"" ready running done failed} { set S($s) 0 } - mydb eval { - SELECT state, count(*) AS cnt FROM jobs GROUP BY 1 - } { - incr S($state) $cnt - incr total $cnt - } - set fin [expr $S(done)+$S(failed)] - if {$cmdline!=""} {set cmdline " $cmdline"} - - if {$delay>0} { - # Move the cursor to the top-left corner. Each iteration will simply - # overwrite. - puts -nonewline "\033\[H" - } - set f "" - if {$S(failed)>0} { - set f "$S(failed) FAILED, " - } - puts "Command line: \[testrunner.tcl$cmdline\]" - puts "Jobs: $nJob" - puts "Summary: ${tm}ms, ($fin/$total) finished,\ - ${f}$S(running) running " - - set srcdir [file dirname [file dirname $TRG(info_script)]] - if {$S(running)>0} { - puts "Running: " - mydb eval { - SELECT * FROM jobs WHERE state='running' ORDER BY starttime - } job { - display_job [array get job] $now - } - } - if {$S(failed)>0} { - puts "Failures: " - mydb eval { - SELECT * FROM jobs WHERE state='failed' ORDER BY starttime - } job { - display_job [array get job] - } - set nOmit [mydb one {SELECT count(*) FROM jobs WHERE state='omit'}] - if {$nOmit} { - puts "$nOmit jobs omitted due to failures[clreol]" - } - } - if {$delay>0} { - # Clear everything else to the bottom of the screen - puts -nonewline "\033\[J" - flush stdout - } - mydb eval COMMIT + show_status mydb [expr {$delay>0 || $cls}] if {$delay<=0} break after [expr {$delay*1000}] } @@ -616,6 +627,16 @@ for {set ii 0} {$ii < [llength $argv]} {incr ii} { set TRG(stopOnError) 1 } elseif {[string match "$a*" --stop-on-coredump]} { set TRG(stopOnCore) 1 + } elseif {[string match "$a*" --status]} { + if {$tcl_platform(platform)=="windows"} { + puts stdout \ +"The --status option is not available on Windows. A suggested work-around" + puts stdout \ +"is to run the following command in a separate window:\n" + puts stdout " [info nameofexe] $argv0 status -d 2\n" + } else { + set TRG(fullstatus) 1 + } } else { usage } @@ -1245,49 +1266,58 @@ proc launch_another_job {iJob} { return 1 } -proc one_line_report {} { +# Show the testing progress report +# +proc progress_report {} { global TRG - set tm [expr [clock_milliseconds] - $TRG(starttime)] - set tm [format "%d" [expr int($tm/1000.0 + 0.5)]] - - r_write_db { - trdb eval { - SELECT displaytype, state, count(*) AS cnt - FROM jobs - GROUP BY 1, 2 - } { - set v($state,$displaytype) $cnt - incr t($displaytype) $cnt + if {$TRG(fullstatus)} { + if {$::tcl_platform(platform)=="windows"} { + exec [info nameofexe] $::argv0 status --cls + } else { + show_status trdb 1 } - } - - set text "" - foreach j [lsort [array names t]] { - foreach k {done failed running} { incr v($k,$j) 0 } - set fin [expr $v(done,$j) + $v(failed,$j)] - lappend text "${j}($fin/$t($j))" - if {$v(failed,$j)>0} { - lappend text "f$v(failed,$j)" + } else { + set tm [expr [clock_milliseconds] - $TRG(starttime)] + set tm [format "%d" [expr int($tm/1000.0 + 0.5)]] + + r_write_db { + trdb eval { + SELECT displaytype, state, count(*) AS cnt + FROM jobs + GROUP BY 1, 2 + } { + set v($state,$displaytype) $cnt + incr t($displaytype) $cnt + } } - if {$v(running,$j)>0} { - lappend text "r$v(running,$j)" + + set text "" + foreach j [lsort [array names t]] { + foreach k {done failed running} { incr v($k,$j) 0 } + set fin [expr $v(done,$j) + $v(failed,$j)] + lappend text "${j}($fin/$t($j))" + if {$v(failed,$j)>0} { + lappend text "f$v(failed,$j)" + } + if {$v(running,$j)>0} { + lappend text "r$v(running,$j)" + } + } + + if {[info exists TRG(reportlength)]} { + puts -nonewline "[string repeat " " $TRG(reportlength)]\r" + } + set report "${tm} [join $text { }]" + set TRG(reportlength) [string length $report] + if {[string length $report]<100} { + puts -nonewline "$report\r" + flush stdout + } else { + puts $report } } - - if {[info exists TRG(reportlength)]} { - puts -nonewline "[string repeat " " $TRG(reportlength)]\r" - } - set report "${tm} [join $text { }]" - set TRG(reportlength) [string length $report] - if {[string length $report]<100} { - puts -nonewline "$report\r" - flush stdout - } else { - puts $report - } - - after $TRG(reporttime) one_line_report + after $TRG(reporttime) progress_report } proc launch_some_jobs {} { @@ -1312,13 +1342,14 @@ proc run_testset {} { launch_some_jobs - one_line_report + if {$TRG(fullstatus)} {puts "\033\[2J"} + progress_report while {[dirs_nHelper]>0} { after 500 {incr ::wakeup} vwait ::wakeup } close $TRG(log) - one_line_report + progress_report r_write_db { set tm [clock_milliseconds] From 0a83dac31c9d4c2d65d4127f9cef07405757cf4d Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 3 Aug 2024 18:45:48 +0000 Subject: [PATCH 0618/1030] Ensure the sqlite3_index_info.colUsed mask always includes the PK fields of WITHOUT ROWID vtabs in cases where they may be used. FossilOrigin-Name: c327c0c02cfefdba373cfb15933a9cdfddb578b6582f2ce7c08929203743ffe9 --- manifest | 15 +++---- manifest.uuid | 2 +- src/where.c | 11 +++++- test/bestindexD.test | 93 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 test/bestindexD.test diff --git a/manifest b/manifest index cd4233fd08..c6e1fa4c8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--status\soption\sto\sthe\stest\sruns\susing\stestrunner.tcl.\s\sOnly\sworks\non\sUnix\splatforms.\s\sThe\s"exec"\scommand\sappears\sto\sinterfere\swith\sVT100\nescape\scodes\son\swindows. -D 2024-08-03T15:55:25.995 +C Ensure\sthe\ssqlite3_index_info.colUsed\smask\salways\sincludes\sthe\sPK\sfields\sof\sWITHOUT\sROWID\svtabs\sin\scases\swhere\sthey\smay\sbe\sused. +D 2024-08-03T18:45:48.287 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -845,7 +845,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c d87a4160e26a7a96a2f7ca283b147b1b283b54ba545c46acb14cfcc6ec37ae9e +F src/where.c 31d100c11a21e479e0dda679585f0ab2675e746a169349519a9a38d3ef10dec7 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -946,6 +946,7 @@ F test/bestindex9.test 1a4b93db117fd8abe74ae9be982f86aa72f01e60cd4ac541e6ede3967 F test/bestindexA.test e1b5def6b190797cacf008e6815ffb78fb30261999030d60a728d572eef44c7f F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce F test/bestindexC.test 2df6ada16d8f00d9bb6a9664d9c323560aeed0e0ebc7a32b99d85d70037fd250 +F test/bestindexD.test 6a8f6f84990bcf17dfa59652a1f935beddb7afd96f8302830fbc86b0a13df3c3 F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -2202,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1637d29d518b3b4534a1b4c0dc0eddcb770f6f71763e4177812a3e79b97d2365 -R 2baa0a7875a2461a2d1db67ee8455074 -U drh -Z cdd1e09ba643f6fa1e24fe72f8439dd6 +P 94015cda4ceb4292ceceadb951fe5d9cb3e4e20403719b7254ad094a5b749ab3 +R 0e3129b74e025069f852e333318489ef +U dan +Z 98131b222c55011293de598d5d0fb4ed # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 551ed083cd..abf3e708eb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -94015cda4ceb4292ceceadb951fe5d9cb3e4e20403719b7254ad094a5b749ab3 +c327c0c02cfefdba373cfb15933a9cdfddb578b6582f2ce7c08929203743ffe9 diff --git a/src/where.c b/src/where.c index a9a2589956..35c6f204a9 100644 --- a/src/where.c +++ b/src/where.c @@ -1501,6 +1501,16 @@ static sqlite3_index_info *allocateIndexInfo( pIdxInfo->aConstraint = pIdxCons; pIdxInfo->aOrderBy = pIdxOrderBy; pIdxInfo->aConstraintUsage = pUsage; + pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed; + if( HasRowid(pTab)==0 ){ + /* Ensure that all bits associated with PK columns are set. This is to + ** ensure they are available for cases like RIGHT joins or OR loops. */ + Index *pPk = sqlite3PrimaryKeyIndex((Table*)pTab); + for(i=0; inKeyCol; i++){ + int iCol = pPk->aiColumn[i]; + pIdxInfo->colUsed |= (iCol>=BMS ? ALLBITS : MASKBIT(iCol)); + } + } pHidden->pWC = pWC; pHidden->pParse = pParse; pHidden->eDistinct = eDistinct; @@ -4216,7 +4226,6 @@ static int whereLoopAddVirtualOne( pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2; pIdxInfo->estimatedRows = 25; pIdxInfo->idxFlags = 0; - pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed; pHidden->mHandleIn = 0; /* Invoke the virtual table xBestIndex() method */ diff --git a/test/bestindexD.test b/test/bestindexD.test new file mode 100644 index 0000000000..b06d6b4270 --- /dev/null +++ b/test/bestindexD.test @@ -0,0 +1,93 @@ +# 2024-08-03 +# +# 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 +set testprefix bestindexD + +ifcapable !vtab { + finish_test + return +} + +register_tcl_module db + +proc vtab_command {method args} { + switch -- $method { + xConnect { + return "CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID" + } + + xBestIndex { + set hdl [lindex $args 0] + set ::colUsed [$hdl mask] + + set cost 1000000 + set used "" + + set cons 0 + foreach c [$hdl constraints] { + set cost [expr $cost/10] + append used " use $cons" + incr cons + } + + return "cost $cost rows $cost $used" + } + } + + return {} +} + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE x1 USING tcl(vtab_command); + + CREATE TABLE t2(a, b); +} {} + +# This proc assumes that there is only one use of a virtual table - x1 - +# in SQL statement $sql. It tests that the colUsed value passed to the +# xBestIndex method matches the actual columns used, which is ascertained +# by searching the compiled VM code for VColumn instructions. +# +proc do_colsused_test {tn sql} { + set ::colUsed "" + execsql $sql + set got $::colUsed + + set expect 0 + db eval "EXPLAIN $sql" x { + if {$x(opcode)=="VColumn"} { + set expect [expr $expect | (1<<$x(p2))] + } + } + + uplevel [list do_test $tn.($expect/$got) [list expr ($expect & $got)] $expect] +} + +do_colsused_test 1.1 { SELECT a FROM x1 } +do_colsused_test 1.2 { SELECT a,c FROM x1 } +do_colsused_test 1.3 { SELECT b FROM x1 } +do_colsused_test 1.4 { SELECT b FROM x1 WHERE c=? } + +do_colsused_test 1.5 { + select 1 from t2 full join x1; +} + +do_colsused_test 1.6 { + select 1 from x1 WHERE (b=? AND c=?) OR (b=? AND c=?) +} + +finish_test + + From 5c85ddc3d7c6688d8a29a224adfbe341c860000f Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 3 Aug 2024 18:58:25 +0000 Subject: [PATCH 0619/1030] Fix a typo in [c327c0c0] preventing the shell tool from running ".dump" scripts that feature virtual tables. FossilOrigin-Name: 10e97abb878debb67410902ea1af4df75a9ced1e38fec710b1796c5143aff48e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index cd4233fd08..fabb35471f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--status\soption\sto\sthe\stest\sruns\susing\stestrunner.tcl.\s\sOnly\sworks\non\sUnix\splatforms.\s\sThe\s"exec"\scommand\sappears\sto\sinterfere\swith\sVT100\nescape\scodes\son\swindows. -D 2024-08-03T15:55:25.995 +C Fix\sa\stypo\sin\s[c327c0c0]\spreventing\sthe\sshell\stool\sfrom\srunning\s".dump"\sscripts\sthat\sfeature\svirtual\stables. +D 2024-08-03T18:58:25.762 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e -F src/shell.c.in 271bc66d805cedc9064d6218434bdaadb207d917dcecb4f46c17e5ff66085590 +F src/shell.c.in 664d443867c2a6d3f17da7dd864af5660012750847a985d0b22ee0c8cd6fc18a F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1637d29d518b3b4534a1b4c0dc0eddcb770f6f71763e4177812a3e79b97d2365 -R 2baa0a7875a2461a2d1db67ee8455074 -U drh -Z cdd1e09ba643f6fa1e24fe72f8439dd6 +P 94015cda4ceb4292ceceadb951fe5d9cb3e4e20403719b7254ad094a5b749ab3 +R 29b4b37a6a2fc091f26014a6acc94dba +U dan +Z ee0e09932c59f9ad04251e6acfe5d403 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 551ed083cd..f469e40925 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -94015cda4ceb4292ceceadb951fe5d9cb3e4e20403719b7254ad094a5b749ab3 +10e97abb878debb67410902ea1af4df75a9ced1e38fec710b1796c5143aff48e diff --git a/src/shell.c.in b/src/shell.c.in index eea87b2dc7..4434a97aba 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -11641,7 +11641,7 @@ static int doAutoDetectRestore(ShellState *p, const char *zSql){ const char *zExpect = "PRAGMA foreign_keys=OFF;"; assert( strlen(zExpect)==24 ); if( p->bSafeMode==0 - && strlen(zSql)>=25 + && strlen(zSql)>=24 && memcmp(zSql, zExpect, 25)==0 ){ p->eRestoreState = 1; From 3a799b3e4e9f485e6efeb08fc508ee6570b6fa3b Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 3 Aug 2024 23:00:17 +0000 Subject: [PATCH 0620/1030] Fix to the previous checkin: The colUsed parameter should have high-order bit set if any of the 64-th or greater columns of the virtual table is used. The lower 63 bits of colUsed always show the usage of the first 63 columns of the virtual table. FossilOrigin-Name: 90ac8457750ace1d76d7bc957af7877e86e6301bb07361e19beaf5c7b3b6085a --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/where.c | 5 ++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index da99073cfd..952974c320 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\ssqlite3_index_info.colUsed\smask\salways\sincludes\sthe\sPK\sfields\sof\sWITHOUT\sROWID\svirtual\stables. -D 2024-08-03T21:45:46.594 +C Fix\sto\sthe\sprevious\scheckin:\s\sThe\scolUsed\sparameter\sshould\shave\shigh-order\sbit\nset\sif\sany\sof\sthe\s64-th\sor\sgreater\scolumns\sof\sthe\svirtual\stable\sis\sused.\s\sThe\nlower\s63\sbits\sof\scolUsed\salways\sshow\sthe\susage\sof\sthe\sfirst\s63\scolumns\sof\sthe\nvirtual\stable. +D 2024-08-03T23:00:17.844 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -845,7 +845,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 31d100c11a21e479e0dda679585f0ab2675e746a169349519a9a38d3ef10dec7 +F src/where.c 5bbe53db73ae6c8ee34a5eab693a5586ad8ff4f094ff0e524df965b683bec884 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -2203,9 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 10e97abb878debb67410902ea1af4df75a9ced1e38fec710b1796c5143aff48e c327c0c02cfefdba373cfb15933a9cdfddb578b6582f2ce7c08929203743ffe9 -R 1d93f534d15ca5d5211a14297b5dec08 -T +closed c327c0c02cfefdba373cfb15933a9cdfddb578b6582f2ce7c08929203743ffe9 +P ff4ac279b02190cc2107b0b110806dd7abcea47a6589d827b5ee39d4b80fb719 +R a2921e0516f49bd12a52be68e2b8cf58 U drh -Z cedb7caeaa81af02824696e786ffbd42 +Z fc6c19311d5767734dbc13dfa2309323 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 22570d3b73..cb9b47f097 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff4ac279b02190cc2107b0b110806dd7abcea47a6589d827b5ee39d4b80fb719 +90ac8457750ace1d76d7bc957af7877e86e6301bb07361e19beaf5c7b3b6085a diff --git a/src/where.c b/src/where.c index 35c6f204a9..c850121c34 100644 --- a/src/where.c +++ b/src/where.c @@ -1506,9 +1506,12 @@ static sqlite3_index_info *allocateIndexInfo( /* Ensure that all bits associated with PK columns are set. This is to ** ensure they are available for cases like RIGHT joins or OR loops. */ Index *pPk = sqlite3PrimaryKeyIndex((Table*)pTab); + assert( pPk!=0 ); for(i=0; inKeyCol; i++){ int iCol = pPk->aiColumn[i]; - pIdxInfo->colUsed |= (iCol>=BMS ? ALLBITS : MASKBIT(iCol)); + assert( iCol>=0 ); + if( iCol>=BMS-1 ) iCol = BMS-1; + pIdxInfo->colUsed |= MASKBIT(iCol); } } pHidden->pWC = pWC; From f2b21a5f57e1a1db1a286c42af40563077635c3d Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 4 Aug 2024 10:13:01 +0000 Subject: [PATCH 0621/1030] Restore legacy "tcl_install" makefile target, as an interim measure until I can figure out what is going on. FossilOrigin-Name: 931ad7d9e3aedb6d466fffc0af1f8d6b20d57a35dec644f28585f3e84f22d1ce --- Makefile.in | 9 +++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile.in b/Makefile.in index c83e76a3db..7ff6e901e4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1552,6 +1552,15 @@ install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_instal $(INSTALL) -d $(DESTDIR)$(pkgconfigdir) $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir) +pkgIndex.tcl: + echo 'package ifneeded sqlite3 $(RELEASE) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] sqlite3]' > $@ + +tcl_install: lib_install libtclsqlite3.la pkgIndex.tcl + $(INSTALL) -d $(DESTDIR)$(TCLLIBDIR) + $(LTINSTALL) libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR) + rm -f $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.a + $(INSTALL) -m 0644 pkgIndex.tcl $(DESTDIR)$(TCLLIBDIR) + # Build the SQLite TCL extension in a way that make it compatible # with whatever version of TCL is running as $TCLSH_CMD, possibly defined # by --with-tclsh= diff --git a/manifest b/manifest index 952974c320..ee70922c67 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\sto\sthe\sprevious\scheckin:\s\sThe\scolUsed\sparameter\sshould\shave\shigh-order\sbit\nset\sif\sany\sof\sthe\s64-th\sor\sgreater\scolumns\sof\sthe\svirtual\stable\sis\sused.\s\sThe\nlower\s63\sbits\sof\scolUsed\salways\sshow\sthe\susage\sof\sthe\sfirst\s63\scolumns\sof\sthe\nvirtual\stable. -D 2024-08-03T23:00:17.844 +C Restore\slegacy\s"tcl_install"\smakefile\starget,\sas\san\sinterim\smeasure\suntil\nI\scan\sfigure\sout\swhat\sis\sgoing\son. +D 2024-08-04T10:13:01.193 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in d9d8d60efaad73dde2ed2380ab3ae3b9b15cb98089d0a7d0573f39de7f093ea2 +F Makefile.in cf96aa7d2682650dec56dc2f03cfe463feb101a1be594e4929bcd38662bc2ea8 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 6c3fe8b6ce60e73f34a148c957d78b4648745c8d30e792423aa1a8d8bf12d065 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ff4ac279b02190cc2107b0b110806dd7abcea47a6589d827b5ee39d4b80fb719 -R a2921e0516f49bd12a52be68e2b8cf58 +P 90ac8457750ace1d76d7bc957af7877e86e6301bb07361e19beaf5c7b3b6085a +R 9b2d1c4cfc1de11b88618206fa47dc44 U drh -Z fc6c19311d5767734dbc13dfa2309323 +Z 58431a0b0955994c226a6fb05d3d3ed5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cb9b47f097..cc1a387f2b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -90ac8457750ace1d76d7bc957af7877e86e6301bb07361e19beaf5c7b3b6085a +931ad7d9e3aedb6d466fffc0af1f8d6b20d57a35dec644f28585f3e84f22d1ce From 575a7b85f5f999bd8c04e59374e1e6d25b7af815 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 6 Aug 2024 10:29:41 +0000 Subject: [PATCH 0622/1030] Change the AggInfoColumnReg() and AggInfoFuncReg() macros for compilers that cannot parse empty elements of a comma expression. [forum:/forumpost/8fd21998dc|Forum post 8fd21998dc]. FossilOrigin-Name: 533a6251f188805363f0e39613ea03b1bfd758eaea00e0855803238585bdfec7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index ee70922c67..a186bcee82 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Restore\slegacy\s"tcl_install"\smakefile\starget,\sas\san\sinterim\smeasure\suntil\nI\scan\sfigure\sout\swhat\sis\sgoing\son. -D 2024-08-04T10:13:01.193 +C Change\sthe\sAggInfoColumnReg()\sand\sAggInfoFuncReg()\smacros\sfor\ncompilers\sthat\scannot\sparse\sempty\selements\sof\sa\scomma\sexpression.\n[forum:/forumpost/8fd21998dc|Forum\spost\s8fd21998dc]. +D 2024-08-06T10:29:41.290 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -764,7 +764,7 @@ F src/shell.c.in 664d443867c2a6d3f17da7dd864af5660012750847a985d0b22ee0c8cd6fc18 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h b77218c425891c7c90506c77fd2eb13bae03628d065b44fffeb37401cd955ac1 +F src/sqliteInt.h e3f3b3d80a666a7c5c85b4db102d41ca831c5624f0b3001814479d376f00c19d F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 90ac8457750ace1d76d7bc957af7877e86e6301bb07361e19beaf5c7b3b6085a -R 9b2d1c4cfc1de11b88618206fa47dc44 +P 931ad7d9e3aedb6d466fffc0af1f8d6b20d57a35dec644f28585f3e84f22d1ce +R d8ba70166a18ab57aa5e818fead8a2e7 U drh -Z 58431a0b0955994c226a6fb05d3d3ed5 +Z 3f8f0dbf60885f64555a59fa3dde5754 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cc1a387f2b..5b481e56df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -931ad7d9e3aedb6d466fffc0af1f8d6b20d57a35dec644f28585f3e84f22d1ce +533a6251f188805363f0e39613ea03b1bfd758eaea00e0855803238585bdfec7 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6a92befe0f..dca5bb150d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2914,9 +2914,15 @@ struct AggInfo { ** assignAggregateRegisters() that computes the value of pAggInfo->iFirstReg. ** The assert()s that are part of this macro verify that constraint. */ +#ifndef NDEBUG #define AggInfoColumnReg(A,I) (assert((A)->iFirstReg),(A)->iFirstReg+(I)) #define AggInfoFuncReg(A,I) \ (assert((A)->iFirstReg),(A)->iFirstReg+(A)->nColumn+(I)) +#else +#define AggInfoColumnReg(A,I) ((A)->iFirstReg+(I)) +#define AggInfoFuncReg(A,I) \ + ((A)->iFirstReg+(A)->nColumn+(I)) +#endif /* ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. From 210f6f89befbe4e4c561fc34aabc175f552450f4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 6 Aug 2024 20:00:10 +0000 Subject: [PATCH 0623/1030] Improvements to ./configure that will hopefully break fewer builds. FossilOrigin-Name: 769e32a69b7b7c04225afa0371f139b2ed29aaee5a7a4159a30d600ed9f25c57 --- configure | 78 ++++++++++++++++++++++++++++++++++---------------- configure.ac | 79 ++++++++++++++++++++++++++++++++++----------------- manifest | 14 ++++----- manifest.uuid | 2 +- 4 files changed, 114 insertions(+), 59 deletions(-) diff --git a/configure b/configure index 616fb26276..2c57d6ac3a 100755 --- a/configure +++ b/configure @@ -10306,7 +10306,7 @@ USE_AMALGAMATION=1 ######### # Figure out all the name of a working tclsh and parameters needed to compile against Tcl. -# The --with-tcl= configuration parameter might be useful for this. +# The --with-tcl= and/or --with-tclsh= configuration arguments might be useful for this. # # Check whether --with-tclsh was given. @@ -10371,41 +10371,70 @@ if test x"${with_tclsh}" != x -a x"${with_tclsh}" != xnone; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: using tclsh at \"$TCLSH_CMD\"" >&5 $as_echo "using tclsh at \"$TCLSH_CMD\"" >&6; } with_tcl=`${with_tclsh} <${srcdir}/tool/find_tclconfig.tcl` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&5 + if test x"${with_tcl}" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&5 $as_echo "$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $TCLSH_CMD is unable to recommend a tclConfig.sh" >&5 +$as_echo "$as_me: WARNING: $TCLSH_CMD is unable to recommend a tclConfig.sh" >&2;} + fi fi if test x"${with_tcl}" != x; then if test -r ${with_tcl}/tclConfig.sh; then tclconfig="${with_tcl}/tclConfig.sh" else - if test -r ${with_tcl}/tcl8.6/tclConfig.sh; then - tclconfig="${with_tcl}/tcl8.6/tclConfig.sh" - else - as_fn_error $? "no tclConfig.sh file found in ${with_tcl} or ${with_tcl}/tcl8.6" "$LINENO" 5 - fi + for i in tcl8.6 tcl9.0 lib; do + if test -r ${with_tcl}/$i/tclConfig.sh; then + tclconfig=${with_tcl}/$i/tclConfig.sh + break + fi + done + fi + if test ! -r "${tclconfig}"; then + as_fn_error $? "no tclConfig.sh file found under ${with_tcl}" "$LINENO" 5 fi - if test x"${tclconfig}" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading TCL configuration from ${tclconfig}" >&5 +else + # If we have not yet found a tclConfig.sh file, look in $libdir whic is + # set automatically by autoconf or by the --prefix command-line option. + # See https://sqlite.org/forum/forumpost/e04e693439a22457 + libdir=${prefix}/lib + if test -r ${libdir}/tclConfig.sh; then + tclconfig=${libdir}/tclConfig.sh + else + for i in tcl8.6 tcl9.0 lib; do + if test -r ${libdir}/$i/tclConfig.sh; then + tclconfig=${libdir}/$i/tclConfig.sh + break + fi + done + fi + if test ! -r "${tclconfig}"; then + as_fn_error $? "cannot find a usable tclConfig.sh file. + Use --with-tcl=DIR to specify a directory where tclConfig.sh can be found. + SQLite does not use TCL internally, but TCL is required to build SQLite + from canonical sources and TCL is required for testing." "$LINENO" 5 + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: loading TCL configuration from ${tclconfig}" >&5 $as_echo "loading TCL configuration from ${tclconfig}" >&6; } - . ${tclconfig} +. ${tclconfig} - # There are lots of other configuration variables that are provided by the - # tclConfig.sh file and that could be included here. But as of right now, - # TCL_LIB_SPEC is the only what that the Makefile uses. - fi - if test x"$TCLSH_CMD" == x; then - TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} - if test ! -x ${TCLSH_CMD}; then - TCLSH_CMD_2=${TCL_EXEC_PREFIX}/bin/tclsh - if test ! -x ${TCLSH_CMD_2}; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find a usable tclsh at either ${TCLSH_CMD} or ${TCLSH_CMD_2}" >&5 +# There are lots of other configuration variables that are provided by the +# tclConfig.sh file and that could be included here. But as of right now, +# TCL_LIB_SPEC is the only what that the Makefile uses. + +if test x"$TCLSH_CMD" == x; then + TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} + if test ! -x ${TCLSH_CMD}; then + TCLSH_CMD_2=${TCL_EXEC_PREFIX}/bin/tclsh + if test ! -x ${TCLSH_CMD_2}; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find a usable tclsh at either ${TCLSH_CMD} or ${TCLSH_CMD_2}" >&5 $as_echo "$as_me: WARNING: cannot find a usable tclsh at either ${TCLSH_CMD} or ${TCLSH_CMD_2}" >&2;} - TCLSH_CMD=none - else - TCLSH_CMD=${TCLSH_CMD_2} - fi + TCLSH_CMD=none + else + TCLSH_CMD=${TCLSH_CMD_2} fi fi fi @@ -10425,7 +10454,6 @@ fi if test "x${TCLLIBDIR+set}" != "xset" ; then - TCLLIBDIR='$(libdir)' for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` ; do if test -d $i ; then TCLLIBDIR=$i diff --git a/configure.ac b/configure.ac index 7526c211dc..095df5e4f6 100644 --- a/configure.ac +++ b/configure.ac @@ -117,7 +117,7 @@ USE_AMALGAMATION=1 ######### # Figure out all the name of a working tclsh and parameters needed to compile against Tcl. -# The --with-tcl= configuration parameter might be useful for this. +# The --with-tcl= and/or --with-tclsh= configuration arguments might be useful for this. # AC_ARG_WITH(tclsh, AS_HELP_STRING([--with-tclsh=PATHNAME],[full pathname of a tclsh to use])) AC_ARG_WITH(tcl, AS_HELP_STRING([--with-tcl=DIR],[directory containing (tclConfig.sh)])) @@ -129,38 +129,66 @@ if test x"${with_tclsh}" != x -a x"${with_tclsh}" != xnone; then TCLSH_CMD=${with_tclsh} AC_MSG_RESULT([using tclsh at "$TCLSH_CMD"]) with_tcl=`${with_tclsh} <${srcdir}/tool/find_tclconfig.tcl` - AC_MSG_RESULT([$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}]) + if test x"${with_tcl}" != x; then + AC_MSG_RESULT([$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}]) + else + AC_MSG_WARN([$TCLSH_CMD is unable to recommend a tclConfig.sh]) + fi fi if test x"${with_tcl}" != x; then if test -r ${with_tcl}/tclConfig.sh; then tclconfig="${with_tcl}/tclConfig.sh" else - if test -r ${with_tcl}/tcl8.6/tclConfig.sh; then - tclconfig="${with_tcl}/tcl8.6/tclConfig.sh" - else - AC_MSG_ERROR([no tclConfig.sh file found in ${with_tcl} or ${with_tcl}/tcl8.6]) - fi + for i in tcl8.6 tcl9.0 lib; do + if test -r ${with_tcl}/$i/tclConfig.sh; then + tclconfig=${with_tcl}/$i/tclConfig.sh + break + fi + done fi - if test x"${tclconfig}" != x; then - AC_MSG_RESULT([loading TCL configuration from ${tclconfig}]) - . ${tclconfig} - AC_SUBST(TCL_INCLUDE_SPEC) - AC_SUBST(TCL_LIB_SPEC) - AC_SUBST(TCL_STUB_LIB_SPEC) - # There are lots of other configuration variables that are provided by the - # tclConfig.sh file and that could be included here. But as of right now, - # TCL_LIB_SPEC is the only what that the Makefile uses. + if test ! -r "${tclconfig}"; then + AC_MSG_ERROR([no tclConfig.sh file found under ${with_tcl}]) fi - if test x"$TCLSH_CMD" == x; then - TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} - if test ! -x ${TCLSH_CMD}; then - TCLSH_CMD_2=${TCL_EXEC_PREFIX}/bin/tclsh - if test ! -x ${TCLSH_CMD_2}; then - AC_MSG_WARN([cannot find a usable tclsh at either ${TCLSH_CMD} or ${TCLSH_CMD_2}]) - TCLSH_CMD=none - else - TCLSH_CMD=${TCLSH_CMD_2} +else + # If we have not yet found a tclConfig.sh file, look in $libdir whic is + # set automatically by autoconf or by the --prefix command-line option. + # See https://sqlite.org/forum/forumpost/e04e693439a22457 + libdir=${prefix}/lib + if test -r ${libdir}/tclConfig.sh; then + tclconfig=${libdir}/tclConfig.sh + else + for i in tcl8.6 tcl9.0 lib; do + if test -r ${libdir}/$i/tclConfig.sh; then + tclconfig=${libdir}/$i/tclConfig.sh + break fi + done + fi + if test ! -r "${tclconfig}"; then + AC_MSG_ERROR([cannot find a usable tclConfig.sh file. + Use --with-tcl=DIR to specify a directory where tclConfig.sh can be found. + SQLite does not use TCL internally, but TCL is required to build SQLite + from canonical sources and TCL is required for testing.]) + fi +fi +AC_MSG_RESULT([loading TCL configuration from ${tclconfig}]) +. ${tclconfig} +AC_SUBST(TCL_INCLUDE_SPEC) +AC_SUBST(TCL_LIB_SPEC) +AC_SUBST(TCL_STUB_LIB_SPEC) +# There are lots of other configuration variables that are provided by the +# tclConfig.sh file and that could be included here. But as of right now, +# TCL_LIB_SPEC is the only what that the Makefile uses. + +if test x"$TCLSH_CMD" == x; then + TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} + if test ! -x ${TCLSH_CMD}; then + TCLSH_CMD_2=${TCL_EXEC_PREFIX}/bin/tclsh + if test ! -x ${TCLSH_CMD_2}; then + AC_MSG_WARN([cannot find a usable tclsh at either ${TCLSH_CMD} or ${TCLSH_CMD_2}]) + TCLSH_CMD=none + else + TCLSH_CMD=${TCLSH_CMD_2} fi fi fi @@ -179,7 +207,6 @@ AC_SUBST(HAVE_TCL) AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin]) if test "x${TCLLIBDIR+set}" != "xset" ; then - TCLLIBDIR='$(libdir)' for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` ; do if test -d $i ; then TCLLIBDIR=$i diff --git a/manifest b/manifest index a186bcee82..215ae7ad21 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sAggInfoColumnReg()\sand\sAggInfoFuncReg()\smacros\sfor\ncompilers\sthat\scannot\sparse\sempty\selements\sof\sa\scomma\sexpression.\n[forum:/forumpost/8fd21998dc|Forum\spost\s8fd21998dc]. -D 2024-08-06T10:29:41.290 +C Improvements\sto\s./configure\sthat\swill\shopefully\sbreak\sfewer\sbuilds. +D 2024-08-06T20:00:10.407 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 187978aa8b6e5bfe261bce02a883f82f7a1d239f95e53cbb5eb6be0aaab2a5b6 x -F configure.ac 50ac86967b264eab4f2925ae8c981601f154aa090ef2fd0c413974fca63251d0 +F configure 8c74221e3e3af939270c27f0600281a5485ac2e5014dd7581b056e24a528d625 x +F configure.ac 9a3d92b38ad56456d09c1272f83131794f73110437f0f53fb94c90ce0d7a351a F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 931ad7d9e3aedb6d466fffc0af1f8d6b20d57a35dec644f28585f3e84f22d1ce -R d8ba70166a18ab57aa5e818fead8a2e7 +P 533a6251f188805363f0e39613ea03b1bfd758eaea00e0855803238585bdfec7 +R a7a477ca379232403aa066474b0e57d0 U drh -Z 3f8f0dbf60885f64555a59fa3dde5754 +Z 01918af4ac385e19f077c5342eefac64 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5b481e56df..c7ef415a77 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -533a6251f188805363f0e39613ea03b1bfd758eaea00e0855803238585bdfec7 +769e32a69b7b7c04225afa0371f139b2ed29aaee5a7a4159a30d600ed9f25c57 From e9b919d550262076d1b8453c3d6852b88822b922 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 6 Aug 2024 22:49:01 +0000 Subject: [PATCH 0624/1030] Improved robustness of parsing of tokenize= arguments in FTS5. [forum:/forumpost/171bcc2bcd|Forum post 171bcc2bcd]. FossilOrigin-Name: d9f726ade6b258f8723f90d0b04a4682e885e30939eb29773913e4dfc8e85503 --- ext/fts5/fts5_tokenize.c | 12 +++++++----- ext/fts5/test/fts5tokenizer2.test | 20 ++++++++++++++++++++ ext/fts5/test/fts5trigram.test | 5 ++++- ext/fts5/test/fts5trigram2.test | 3 +++ manifest | 18 +++++++++--------- manifest.uuid | 2 +- 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index 3e9fdff3eb..08de0d60d7 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -79,7 +79,7 @@ static int fts5AsciiCreate( int i; memset(p, 0, sizeof(AsciiTokenizer)); memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar)); - for(i=0; rc==SQLITE_OK && ibFold = 1; pNew->iFoldParam = 0; - for(i=0; rc==SQLITE_OK && iiFoldParam!=0 && pNew->bFold==0 ){ rc = SQLITE_ERROR; diff --git a/ext/fts5/test/fts5tokenizer2.test b/ext/fts5/test/fts5tokenizer2.test index 0017046baf..4fe31d22c4 100644 --- a/ext/fts5/test/fts5tokenizer2.test +++ b/ext/fts5/test/fts5tokenizer2.test @@ -85,5 +85,25 @@ do_execsql_test 1.7 { SELECT highlight(t1, 0, '>', '<') FROM t1('BB mess'); } {AAdont>BBmess<} +# 2024-08-06 https://sqlite.org/forum/forumpost/171bcc2bcd +# Error handling of tokenize= arguments. +# +foreach {n tkz} { + 1 {ascii none} + 2 {unicode61 none} + 3 {porter none} + 4 {trigram none} + 5 {ascii none 0} + 6 {unicode61 none 0} + 7 {porter none 0} + 8 {trigram none 0} +} { + db eval {DROP TABLE IF EXISTS t2;} + do_catchsql_test 2.$n " + DROP TABLE IF EXISTS t2; + CREATE VIRTUAL TABLE t2 USING fts5(a,b,c,tokenize='$tkz'); + " {1 {error in tokenizer constructor}} +} + finish_test diff --git a/ext/fts5/test/fts5trigram.test b/ext/fts5/test/fts5trigram.test index 351c059bf5..752686620c 100644 --- a/ext/fts5/test/fts5trigram.test +++ b/ext/fts5/test/fts5trigram.test @@ -69,6 +69,9 @@ do_execsql_test 2.0 { INSERT INTO t1 VALUES('abcdefghijklm'); INSERT INTO t1 VALUES('กรุงเทพมหานคร'); } +do_catchsql_test 2.0.1 { + CREATE VIRTUAL TABLE t2 USING fts5(z, tokenize='trigram case_sensitive'); +} {1 {error in tokenizer constructor}} foreach {tn s res} { 1 abc "(abc)defghijklm" @@ -206,7 +209,7 @@ do_execsql_test 7.0 { (20, "жираф.png"), (30, "cat.png"), (40, "кот.png"), - (50, "misic-🎵-.mp3"); + (50, "misic-🎵-.mp3"); } do_execsql_test 7.1 { SELECT rowid FROM f WHERE +filename GLOB '*ир*'; diff --git a/ext/fts5/test/fts5trigram2.test b/ext/fts5/test/fts5trigram2.test index 00f6d43952..33c07d3f8b 100644 --- a/ext/fts5/test/fts5trigram2.test +++ b/ext/fts5/test/fts5trigram2.test @@ -21,6 +21,9 @@ do_execsql_test 1.0 " INSERT INTO t1 VALUES('abc\u0303defghijklm'); INSERT INTO t1 VALUES('a\u0303b\u0303c\u0303defghijklm'); " +do_catchsql_test 1.0.1 { + CREATE VIRTUAL TABLE t2 USING fts5(z, tokenize='trigram remove_diacritics'); +} {1 {error in tokenizer constructor}} do_execsql_test 1.1 { SELECT highlight(t1, 0, '(', ')') FROM t1('abc'); diff --git a/manifest b/manifest index 215ae7ad21..dcbcb3f3ae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\s./configure\sthat\swill\shopefully\sbreak\sfewer\sbuilds. -D 2024-08-06T20:00:10.407 +C Improved\srobustness\sof\sparsing\sof\stokenize=\sarguments\sin\sFTS5.\n[forum:/forumpost/171bcc2bcd|Forum\spost\s171bcc2bcd]. +D 2024-08-06T22:49:01.135 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -105,7 +105,7 @@ F ext/fts5/fts5_storage.c 1d7e08d4331da2f3f7e78e70eef2ed6a013d91ba16175c651adbc5 F ext/fts5/fts5_tcl.c 5ca3e3e35010d326f5b821a563e4fcde3913e052935f5c2c72c264122a26b48f F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b -F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be +F ext/fts5/fts5_tokenize.c b1c3dc4de28f2532d9ee7be7182a96f943fa09fcc31c6f271d69dce72874ff8c F ext/fts5/fts5_unicode2.c eca63dbc797f8ff0572e97caf4631389c0ab900d6364861b915bdd4735973f00 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 @@ -229,9 +229,9 @@ F ext/fts5/test/fts5synonym2.test 58f357b997cf2fedeeb9d0de4db9f880fa96fa2fe27a74 F ext/fts5/test/fts5tok1.test 1f7817499f5971450d8c4a652114b3d833393c8134e32422d0af27884ffe9cef F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test 7937cec672b148223fff8746d21d3e7ed0965fd7caf35ccdc888a005bb452f98 -F ext/fts5/test/fts5tokenizer2.test 9c1ad8ef0465076cbc9ff5c764782594329b3bce3e0f6a931a026902d006f495 -F ext/fts5/test/fts5trigram.test 6c4e37864f3e7d90673db5563d9736d7e40080ab94d10ebdffa94c1b77941da0 -F ext/fts5/test/fts5trigram2.test c91f0a94f7e1ff859682228646abeab4c0eba2effc46af2cbc8f0f48b05a0566 +F ext/fts5/test/fts5tokenizer2.test ddb8b10fbe4b84b2a75812671f127774c1d2e3e2bf82d2e0e4f0bb1cd8a2b2d6 +F ext/fts5/test/fts5trigram.test be914555deb8504dde682bd5aa343d00c4da37dfad20709a5bac30d5f97f2ef5 +F ext/fts5/test/fts5trigram2.test 9be01ec340a61869931a23ec109d189e589e2b807d574e1fc1f0cf2c23765c42 F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 F ext/fts5/test/fts5unicode.test 41898f7e476e6515cd4b737c02a442cda5a580a74509788aa9072a2074948e0e @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 533a6251f188805363f0e39613ea03b1bfd758eaea00e0855803238585bdfec7 -R a7a477ca379232403aa066474b0e57d0 +P 769e32a69b7b7c04225afa0371f139b2ed29aaee5a7a4159a30d600ed9f25c57 +R f82e2089204b40d7709881ee6cd588a3 U drh -Z 01918af4ac385e19f077c5342eefac64 +Z e2400150d004e016a710bc2ae395399e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c7ef415a77..0cc2838448 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -769e32a69b7b7c04225afa0371f139b2ed29aaee5a7a4159a30d600ed9f25c57 +d9f726ade6b258f8723f90d0b04a4682e885e30939eb29773913e4dfc8e85503 From eaa560f3fce32619cd0ca017278b9ad94ebba0e8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 6 Aug 2024 23:09:37 +0000 Subject: [PATCH 0625/1030] Remove unused test cases from FTS5, as they interfere with "grep". FossilOrigin-Name: 048a71bae48aacdfc91e59330db4d4b3d663f00665f51a7110ea82e0508758ec --- ext/fts5/test/fts5unicode2.test | 116 -------------------------------- manifest | 12 ++-- manifest.uuid | 2 +- 3 files changed, 7 insertions(+), 123 deletions(-) diff --git a/ext/fts5/test/fts5unicode2.test b/ext/fts5/test/fts5unicode2.test index dccaff0b1c..3fc1f673a4 100644 --- a/ext/fts5/test/fts5unicode2.test +++ b/ext/fts5/test/fts5unicode2.test @@ -470,120 +470,4 @@ do_execsql_test 8.2.3 { SELECT rowid FROM t4 WHERE t4 MATCH 'a' ORDER BY rowid ASC; } {2 4} -#------------------------------------------------------------------------- -# -if 0 { -foreach {tn sql} { - 1 { - CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 [tokenchars= .]); - CREATE VIRTUAL TABLE t6 USING fts4( - tokenize=unicode61 [tokenchars=="] "tokenchars=[]"); - CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 [separators=x\xC4]); - } - 2 { - CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 "tokenchars= ."); - CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 "tokenchars=[=""]"); - CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 "separators=x\xC4"); - } - 3 { - CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 'tokenchars= .'); - CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 'tokenchars=="[]'); - CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 'separators=x\xC4'); - } - 4 { - CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 `tokenchars= .`); - CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 `tokenchars=[="]`); - CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 `separators=x\xC4`); - } -} { - do_execsql_test 9.$tn.0 { - DROP TABLE IF EXISTS t5; - DROP TABLE IF EXISTS t5aux; - DROP TABLE IF EXISTS t6; - DROP TABLE IF EXISTS t6aux; - DROP TABLE IF EXISTS t7; - DROP TABLE IF EXISTS t7aux; - } - do_execsql_test 9.$tn.1 $sql - - do_execsql_test 9.$tn.2 { - CREATE VIRTUAL TABLE t5aux USING fts4aux(t5); - INSERT INTO t5 VALUES('one two three/four.five.six'); - SELECT * FROM t5aux; - } { - four.five.six * 1 1 four.five.six 0 1 1 - {one two three} * 1 1 {one two three} 0 1 1 - } - - do_execsql_test 9.$tn.3 { - CREATE VIRTUAL TABLE t6aux USING fts4aux(t6); - INSERT INTO t6 VALUES('alpha=beta"gamma/delta[epsilon]zeta'); - SELECT * FROM t6aux; - } { - {alpha=beta"gamma} * 1 1 {alpha=beta"gamma} 0 1 1 - {delta[epsilon]zeta} * 1 1 {delta[epsilon]zeta} 0 1 1 - } - - do_execsql_test 9.$tn.4 { - CREATE VIRTUAL TABLE t7aux USING fts4aux(t7); - INSERT INTO t7 VALUES('alephxbeth\xC4gimel'); - SELECT * FROM t7aux; - } { - aleph * 1 1 aleph 0 1 1 - beth * 1 1 beth 0 1 1 - gimel * 1 1 gimel 0 1 1 - } -} - -# Check that multiple options are handled correctly. -# -do_execsql_test 10.1 { - DROP TABLE IF EXISTS t1; - CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61 - "tokenchars=xyz" "tokenchars=.=" "separators=.=" "separators=xy" - "separators=a" "separators=a" "tokenchars=a" "tokenchars=a" - ); - - INSERT INTO t1 VALUES('oneatwoxthreeyfour'); - INSERT INTO t1 VALUES('a.single=word'); - CREATE VIRTUAL TABLE t1aux USING fts4aux(t1); - SELECT * FROM t1aux; -} { - .single=word * 1 1 .single=word 0 1 1 - four * 1 1 four 0 1 1 - one * 1 1 one 0 1 1 - three * 1 1 three 0 1 1 - two * 1 1 two 0 1 1 -} - -# Test that case folding happens after tokenization, not before. -# -do_execsql_test 10.2 { - DROP TABLE IF EXISTS t2; - CREATE VIRTUAL TABLE t2 USING fts4(tokenize=unicode61 "separators=aB"); - INSERT INTO t2 VALUES('oneatwoBthree'); - INSERT INTO t2 VALUES('onebtwoAthree'); - CREATE VIRTUAL TABLE t2aux USING fts4aux(t2); - SELECT * FROM t2aux; -} { - one * 1 1 one 0 1 1 - onebtwoathree * 1 1 onebtwoathree 0 1 1 - three * 1 1 three 0 1 1 - two * 1 1 two 0 1 1 -} - -# Test that the tokenchars and separators options work with the -# fts3tokenize table. -# -do_execsql_test 11.1 { - CREATE VIRTUAL TABLE ft1 USING fts3tokenize( - "unicode61", "tokenchars=@.", "separators=1234567890" - ); - SELECT token FROM ft1 WHERE input = 'berlin@street123sydney.road'; -} { - berlin@street sydney.road -} - -} - finish_test diff --git a/manifest b/manifest index dcbcb3f3ae..182a5add47 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\srobustness\sof\sparsing\sof\stokenize=\sarguments\sin\sFTS5.\n[forum:/forumpost/171bcc2bcd|Forum\spost\s171bcc2bcd]. -D 2024-08-06T22:49:01.135 +C Remove\sunused\stest\scases\sfrom\sFTS5,\sas\sthey\sinterfere\swith\s"grep". +D 2024-08-06T23:09:37.114 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -235,7 +235,7 @@ F ext/fts5/test/fts5trigram2.test 9be01ec340a61869931a23ec109d189e589e2b807d574e F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 F ext/fts5/test/fts5unicode.test 41898f7e476e6515cd4b737c02a442cda5a580a74509788aa9072a2074948e0e -F ext/fts5/test/fts5unicode2.test 3ff7ea5d27310d65441779d9919055084cdbb570ed7743af1f8f4eeca1a3be26 +F ext/fts5/test/fts5unicode2.test a5c38179b311a188b24376772309389b073c996f52b79bb9ca760a19e62043ea F ext/fts5/test/fts5unicode3.test f4891a3dac3b49c3d7c0fdb29566e9eb0ecff35263370c89f9661b1952b20818 F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8df04eff87923c74b4d0 F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 769e32a69b7b7c04225afa0371f139b2ed29aaee5a7a4159a30d600ed9f25c57 -R f82e2089204b40d7709881ee6cd588a3 +P d9f726ade6b258f8723f90d0b04a4682e885e30939eb29773913e4dfc8e85503 +R 8883991defb511b18c50a1c79414e20d U drh -Z e2400150d004e016a710bc2ae395399e +Z 52ae6209c36ddaa63cf3a7ae6e99cfb1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0cc2838448..e3862d0484 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d9f726ade6b258f8723f90d0b04a4682e885e30939eb29773913e4dfc8e85503 +048a71bae48aacdfc91e59330db4d4b3d663f00665f51a7110ea82e0508758ec From 92d317f787fdc8342a60aee494217914e417b766 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 7 Aug 2024 14:54:54 +0000 Subject: [PATCH 0626/1030] Fix a harmless compiler warning in an assert(). FossilOrigin-Name: 5e4c9a74b2efa74ace67f644fb6bb37e07f5982f8faaca9463e3daa50b0469d7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbesort.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 182a5add47..1c1ed26a5e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunused\stest\scases\sfrom\sFTS5,\sas\sthey\sinterfere\swith\s"grep". -D 2024-08-06T23:09:37.114 +C Fix\sa\sharmless\scompiler\swarning\sin\san\sassert(). +D 2024-08-07T14:54:54.630 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -837,7 +837,7 @@ F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df F src/vdbeaux.c 25d685cafe119ff890c94345e884ea558a6b5d823bfa52ba708eb8ff3c70aa71 F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 831a244831eaa45335f9ae276b50a7a82ee10d8c46c2c72492d4eb8c98d94d89 -F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547 +F src/vdbesort.c 218fb7358e6c4ca3c843171d989ff31b4bc0b708c10e6a095ae7e9aa3335cfae F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 F src/vtab.c 5fb499d20494b7eecaadb7584634af9afcb374cb0524912b475fcb1712458a1b @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d9f726ade6b258f8723f90d0b04a4682e885e30939eb29773913e4dfc8e85503 -R 8883991defb511b18c50a1c79414e20d +P 048a71bae48aacdfc91e59330db4d4b3d663f00665f51a7110ea82e0508758ec +R 29c7af48e92a52bfc015cef89b4e9b80 U drh -Z 52ae6209c36ddaa63cf3a7ae6e99cfb1 +Z 823f9a62b624b3de6573555750300eee # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e3862d0484..7494572243 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -048a71bae48aacdfc91e59330db4d4b3d663f00665f51a7110ea82e0508758ec +5e4c9a74b2efa74ace67f644fb6bb37e07f5982f8faaca9463e3daa50b0469d7 diff --git a/src/vdbesort.c b/src/vdbesort.c index 0083690308..2a4be0f4cf 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -556,7 +556,7 @@ static int vdbePmaReadBlob( while( nRem>0 ){ int rc; /* vdbePmaReadBlob() return code */ int nCopy; /* Number of bytes to copy */ - u8 *aNext; /* Pointer to buffer to copy data from */ + u8 *aNext = 0; /* Pointer to buffer to copy data from */ nCopy = nRem; if( nRem>p->nBuffer ) nCopy = p->nBuffer; From c76520c5b917e5ad108ec264328e6ab7ad08cec8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 7 Aug 2024 15:17:37 +0000 Subject: [PATCH 0627/1030] Add a new assert() to help static analyzers understand that a pointer is never NULL. FossilOrigin-Name: 433f2b942ee6f79d50ebe9b08fa3ea8162db6a10ce9d80e2bc193124baa1b083 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbesort.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 1c1ed26a5e..bdd89ab3f8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning\sin\san\sassert(). -D 2024-08-07T14:54:54.630 +C Add\sa\snew\sassert()\sto\shelp\sstatic\sanalyzers\sunderstand\sthat\sa\spointer\sis\nnever\sNULL. +D 2024-08-07T15:17:37.116 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -837,7 +837,7 @@ F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df F src/vdbeaux.c 25d685cafe119ff890c94345e884ea558a6b5d823bfa52ba708eb8ff3c70aa71 F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 F src/vdbemem.c 831a244831eaa45335f9ae276b50a7a82ee10d8c46c2c72492d4eb8c98d94d89 -F src/vdbesort.c 218fb7358e6c4ca3c843171d989ff31b4bc0b708c10e6a095ae7e9aa3335cfae +F src/vdbesort.c d0a3c7056c081703c8b6d91ad60f17da5e062a5c64bf568ed0fa1b5f4cae311f F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 F src/vtab.c 5fb499d20494b7eecaadb7584634af9afcb374cb0524912b475fcb1712458a1b @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 048a71bae48aacdfc91e59330db4d4b3d663f00665f51a7110ea82e0508758ec -R 29c7af48e92a52bfc015cef89b4e9b80 +P 5e4c9a74b2efa74ace67f644fb6bb37e07f5982f8faaca9463e3daa50b0469d7 +R 563f140a9b39903a75648b155c162aef U drh -Z 823f9a62b624b3de6573555750300eee +Z 2831e995241ff77754cf2f0030919a15 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7494572243..f5c40f5049 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e4c9a74b2efa74ace67f644fb6bb37e07f5982f8faaca9463e3daa50b0469d7 +433f2b942ee6f79d50ebe9b08fa3ea8162db6a10ce9d80e2bc193124baa1b083 diff --git a/src/vdbesort.c b/src/vdbesort.c index 2a4be0f4cf..239c0a0f36 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -563,6 +563,7 @@ static int vdbePmaReadBlob( rc = vdbePmaReadBlob(p, nCopy, &aNext); if( rc!=SQLITE_OK ) return rc; assert( aNext!=p->aAlloc ); + assert( aNext!=0 ); memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy); nRem -= nCopy; } From 5cd01c30b4486a90c5d139ebf6ca5d3d4bb0dee8 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 7 Aug 2024 21:20:08 +0000 Subject: [PATCH 0628/1030] Fix a broken assert in fts5_expr.c. FossilOrigin-Name: 08cc5488404d068e59378b82988460793710df43ec21b4a83a794b497abd035f --- ext/fts5/fts5_expr.c | 1 + ext/fts5/test/fts5trigram2.test | 14 ++++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 732d4cf893..176d4e6a5f 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2457,6 +2457,7 @@ Fts5ExprNode *sqlite3Fts5ParseImplicitAnd( assert( pRight->eType==FTS5_STRING || pRight->eType==FTS5_TERM || pRight->eType==FTS5_EOF + || (pRight->eType==FTS5_AND && pParse->bPhraseToAnd) ); if( pLeft->eType==FTS5_AND ){ diff --git a/ext/fts5/test/fts5trigram2.test b/ext/fts5/test/fts5trigram2.test index 33c07d3f8b..c81684a22b 100644 --- a/ext/fts5/test/fts5trigram2.test +++ b/ext/fts5/test/fts5trigram2.test @@ -120,4 +120,18 @@ do_execsql_test 4.2 { SELECT rowid FROM t4 WHERE z LIKE '%abc%' } {1} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 5.0 { + CREATE VIRTUAL TABLE t5 USING fts5( + c1, tokenize='trigram', detail='none' + ); + INSERT INTO t5(rowid, c1) VALUES(1, 'abc_____xyx_yxz'); + INSERT INTO t5(rowid, c1) VALUES(2, 'abc_____xyxz'); + INSERT INTO t5(rowid, c1) VALUES(3, 'ac_____xyxz'); +} {} +do_execsql_test 5.1 { + SELECT rowid FROM t5 WHERE c1 LIKE 'abc%xyxz' +} {2} + finish_test diff --git a/manifest b/manifest index bdd89ab3f8..49d8819fe6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\sassert()\sto\shelp\sstatic\sanalyzers\sunderstand\sthat\sa\spointer\sis\nnever\sNULL. -D 2024-08-07T15:17:37.116 +C Fix\sa\sbroken\sassert\sin\sfts5_expr.c. +D 2024-08-07T21:20:08.849 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -97,7 +97,7 @@ F ext/fts5/fts5Int.h 41fb3a2dd40e818cc96c6f4176dbdf2aaa8f57043cfc9a8f2676e7e6a72 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 -F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad +F ext/fts5/fts5_expr.c 29558460f161b0bee816fdfb6547cdcaefc7b61c64a1bf78d50052932a210201 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 77fefb37e7931095a5ff271a28fbe4f73ec46d5492ef1f35d405d98e137ad8ed @@ -231,7 +231,7 @@ F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test 7937cec672b148223fff8746d21d3e7ed0965fd7caf35ccdc888a005bb452f98 F ext/fts5/test/fts5tokenizer2.test ddb8b10fbe4b84b2a75812671f127774c1d2e3e2bf82d2e0e4f0bb1cd8a2b2d6 F ext/fts5/test/fts5trigram.test be914555deb8504dde682bd5aa343d00c4da37dfad20709a5bac30d5f97f2ef5 -F ext/fts5/test/fts5trigram2.test 9be01ec340a61869931a23ec109d189e589e2b807d574e1fc1f0cf2c23765c42 +F ext/fts5/test/fts5trigram2.test 6fde9de7f63a6b4aa18dc731be56dbd6be4e755c9b13dcd55479e200d1df0e61 F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 F ext/fts5/test/fts5unicode.test 41898f7e476e6515cd4b737c02a442cda5a580a74509788aa9072a2074948e0e @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5e4c9a74b2efa74ace67f644fb6bb37e07f5982f8faaca9463e3daa50b0469d7 -R 563f140a9b39903a75648b155c162aef -U drh -Z 2831e995241ff77754cf2f0030919a15 +P 433f2b942ee6f79d50ebe9b08fa3ea8162db6a10ce9d80e2bc193124baa1b083 +R 4344cfe486b9af9c627d27d1110ce2f0 +U dan +Z 57ed22c9ed030aee910e69827579449e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f5c40f5049..a97e2bbfc9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -433f2b942ee6f79d50ebe9b08fa3ea8162db6a10ce9d80e2bc193124baa1b083 +08cc5488404d068e59378b82988460793710df43ec21b4a83a794b497abd035f From 6d02d2647b4f1bbc455b252ef8794aa8b5708586 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 8 Aug 2024 10:10:38 +0000 Subject: [PATCH 0629/1030] Add the --memory option to the ".parameter init" CLI command. When present, the --memory option causes the sqlite_parameters table to be created in a completely independent :memory: database. This can be done to avoid parameter binding queries from being affected by debug settings such as ".wheretrace", ".treetrace", "PRAGMA vdbe_addoptrace=on", and similar. FossilOrigin-Name: 4e69dce2093b75b7db4fbdca4953b664b907be15d991ed352ea1d87c64fbf9d2 --- manifest | 14 ++-- manifest.uuid | 2 +- src/shell.c.in | 185 ++++++++++++++++++++++++++++++++----------------- 3 files changed, 128 insertions(+), 73 deletions(-) diff --git a/manifest b/manifest index 49d8819fe6..587d9af3bb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbroken\sassert\sin\sfts5_expr.c. -D 2024-08-07T21:20:08.849 +C Add\sthe\s--memory\soption\sto\sthe\s".parameter\sinit"\sCLI\scommand.\s\sWhen\spresent,\nthe\s--memory\soption\scauses\sthe\ssqlite_parameters\stable\sto\sbe\screated\sin\sa\ncompletely\sindependent\s:memory:\sdatabase.\s\sThis\scan\sbe\sdone\sto\savoid\nparameter\sbinding\squeries\sfrom\sbeing\saffected\sby\sdebug\ssettings\ssuch\sas\n".wheretrace",\s".treetrace",\s"PRAGMA\svdbe_addoptrace=on",\sand\ssimilar. +D 2024-08-08T10:10:38.385 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e -F src/shell.c.in 664d443867c2a6d3f17da7dd864af5660012750847a985d0b22ee0c8cd6fc18a +F src/shell.c.in 8b1a82ddbcf93580f991eecec0a22e8edc7d62fa856388d9bed2392da1cbfa42 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 433f2b942ee6f79d50ebe9b08fa3ea8162db6a10ce9d80e2bc193124baa1b083 -R 4344cfe486b9af9c627d27d1110ce2f0 -U dan -Z 57ed22c9ed030aee910e69827579449e +P 08cc5488404d068e59378b82988460793710df43ec21b4a83a794b497abd035f +R d4d35f38c7731eed804015561204e2a7 +U drh +Z 252eafc7dac030f0d53111914f8dbebb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a97e2bbfc9..950203b129 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -08cc5488404d068e59378b82988460793710df43ec21b4a83a794b497abd035f +4e69dce2093b75b7db4fbdca4953b664b907be15d991ed352ea1d87c64fbf9d2 diff --git a/src/shell.c.in b/src/shell.c.in index 4434a97aba..2d6c76d3b0 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1356,6 +1356,8 @@ struct ShellState { #endif } aAuxDb[5], /* Array of all database connections */ *pAuxDb; /* Currently active database connection */ + sqlite3 *dbParam; /* Database to use for query parameters. Often the + ** same as "db", but might be different. */ int *aiIndent; /* Array of indents used in MODE_Explain */ int nIndent; /* Size of array aiIndent[] */ int iIndent; /* Index of current op in aiIndent[] */ @@ -3480,22 +3482,44 @@ static void restore_debug_trace_modes(void){ sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 3, &savedWhereTrace); } -/* Create the TEMP table used to store parameter bindings */ -static void bind_table_init(ShellState *p){ +/* Create the TEMP table used to store parameter bindings. +** +** If bInMemory is true, create a separate in-memory database for +** the parameter binding table. +** +** The database that stores the sqlite_parameter table will be +** p->dbParam. This might be a copy of p->db. Or it might be a +** completely separate database (if bInMemory is true, because of +** the ".param init --memory" command). +*/ +static void bind_table_init(ShellState *p, int bInMemory){ int wrSchema = 0; int defensiveMode = 0; - sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, -1, &defensiveMode); - sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, 0, 0); - sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema); - sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0); - sqlite3_exec(p->db, + sqlite3 *dbx; + if( p->dbParam ) return; + if( sqlite3_table_column_metadata(p->db, "TEMP", "sqlite_parameters", + "key", 0, 0, 0, 0, 0)==SQLITE_OK ){ + return; + } + if( bInMemory && p->dbParam==0 ){ + sqlite3_open(":memory:", &p->dbParam); + }else{ + p->dbParam = p->db; + } + dbx = p->dbParam; + + sqlite3_db_config(dbx, SQLITE_DBCONFIG_DEFENSIVE, -1, &defensiveMode); + sqlite3_db_config(dbx, SQLITE_DBCONFIG_DEFENSIVE, 0, 0); + sqlite3_db_config(dbx, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema); + sqlite3_db_config(dbx, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0); + sqlite3_exec(dbx, "CREATE TABLE IF NOT EXISTS temp.sqlite_parameters(\n" " key TEXT PRIMARY KEY,\n" " value\n" ") WITHOUT ROWID;", 0, 0, 0); - sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0); - sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, defensiveMode, 0); + sqlite3_db_config(dbx, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0); + sqlite3_db_config(dbx, SQLITE_DBCONFIG_DEFENSIVE, defensiveMode, 0); } /* @@ -3518,12 +3542,14 @@ static void bind_prepared_stmt(ShellState *pArg, sqlite3_stmt *pStmt){ nVar = sqlite3_bind_parameter_count(pStmt); if( nVar==0 ) return; /* Nothing to do */ - if( sqlite3_table_column_metadata(pArg->db, "TEMP", "sqlite_parameters", - "key", 0, 0, 0, 0, 0)!=SQLITE_OK ){ + if( pArg->dbParam==0 + || sqlite3_table_column_metadata(pArg->dbParam, "TEMP", "sqlite_parameters", + "key", 0, 0, 0, 0, 0)!=SQLITE_OK + ){ rc = SQLITE_NOTFOUND; pQ = 0; }else{ - rc = sqlite3_prepare_v2(pArg->db, + rc = sqlite3_prepare_v2(pArg->dbParam, "SELECT value FROM temp.sqlite_parameters" " WHERE key=?1", -1, &pQ, 0); } @@ -4829,7 +4855,7 @@ static const char *(azHelp[]) = { #endif ".parameter CMD ... Manage SQL parameter bindings", " clear Erase all bindings", - " init Initialize the TEMP table that holds bindings", + " init ?--memory? Initialize the TEMP table that holds bindings", " list List the current parameter bindings", " set PARAMETER VALUE Given SQL parameter PARAMETER a value of VALUE", " PARAMETER should start with one of: $ : @ ?", @@ -5485,9 +5511,17 @@ static void open_db(ShellState *p, int openFlags){ /* ** Attempt to close the database connection. Report errors. +** +** If dbParam is not NULL and is different from db, then close it +** too. No error checking is done on the close of dbParam, as it +** should be a :memory: database which cannot really fail on close. */ -void close_db(sqlite3 *db){ - int rc = sqlite3_close(db); +void close_db(sqlite3 *db, sqlite3 *dbParam){ + int rc; + if( dbParam && dbParam!=db ){ + sqlite3_close(dbParam); + } + rc = sqlite3_close(db); if( rc ){ eputf("Error: sqlite3_close() returns %d: %s\n", rc, sqlite3_errmsg(db)); } @@ -6146,7 +6180,7 @@ static void tryToClone(ShellState *p, const char *zNewDb){ sqlite3_exec(newDb, "COMMIT;", 0, 0, 0); sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0); } - close_db(newDb); + close_db(newDb, 0); } #ifndef SQLITE_SHELL_FIDDLE @@ -7581,7 +7615,7 @@ static int arDotCommand( } end_ar_command: if( cmd.db!=pState->db ){ - close_db(cmd.db); + close_db(cmd.db, 0); } sqlite3_free(cmd.zSrcTable); @@ -8106,7 +8140,7 @@ static int do_meta_command(char *zLine, ShellState *p){ SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, zVfs); if( rc!=SQLITE_OK ){ eputf("Error: cannot open \"%s\"\n", zDestFile); - close_db(pDest); + close_db(pDest, 0); return 1; } if( bAsync ){ @@ -8117,7 +8151,7 @@ static int do_meta_command(char *zLine, ShellState *p){ pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb); if( pBackup==0 ){ eputf("Error: %s\n", sqlite3_errmsg(pDest)); - close_db(pDest); + close_db(pDest, 0); return 1; } while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){} @@ -8128,7 +8162,7 @@ static int do_meta_command(char *zLine, ShellState *p){ eputf("Error: %s\n", sqlite3_errmsg(pDest)); rc = 1; } - close_db(pDest); + close_db(pDest, 0); }else #endif /* !defined(SQLITE_SHELL_FIDDLE) */ @@ -8268,7 +8302,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = 1; }else if( p->aAuxDb[i].db ){ session_close_all(p, i); - close_db(p->aAuxDb[i].db); + close_db(p->aAuxDb[i].db, 0); p->aAuxDb[i].db = 0; } }else{ @@ -9558,8 +9592,8 @@ static int do_meta_command(char *zLine, ShellState *p){ /* Close the existing database */ session_close_all(p, -1); - close_db(p->db); - p->db = 0; + close_db(p->db, p->dbParam); + p->db = p->dbParam = 0; p->pAuxDb->zDbFilename = 0; sqlite3_free(p->pAuxDb->zFreeOnClose); p->pAuxDb->zFreeOnClose = 0; @@ -9725,8 +9759,15 @@ static int do_meta_command(char *zLine, ShellState *p){ ** Clear all bind parameters by dropping the TEMP table that holds them. */ if( nArg==2 && cli_strcmp(azArg[1],"clear")==0 ){ - sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.sqlite_parameters;", - 0, 0, 0); + if( p->dbParam==0 ){ + /* no-op */ + }else if( p->dbParam==p->db ){ + sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.sqlite_parameters;", + 0, 0, 0); + }else{ + sqlite3_close(p->dbParam); + } + p->dbParam = 0; }else /* .parameter list @@ -9736,33 +9777,45 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_stmt *pStmt = 0; int rx; int len = 0; - rx = sqlite3_prepare_v2(p->db, - "SELECT max(length(key)) " - "FROM temp.sqlite_parameters;", -1, &pStmt, 0); - if( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ - len = sqlite3_column_int(pStmt, 0); - if( len>40 ) len = 40; - } - sqlite3_finalize(pStmt); - pStmt = 0; - if( len ){ - rx = sqlite3_prepare_v2(p->db, - "SELECT key, quote(value) " - "FROM temp.sqlite_parameters;", -1, &pStmt, 0); - while( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ - oputf("%-*s %s\n", len, sqlite3_column_text(pStmt,0), - sqlite3_column_text(pStmt,1)); + if( p->dbParam ){ + rx = sqlite3_prepare_v2(p->dbParam, + "SELECT max(length(key)) " + "FROM temp.sqlite_parameters;", -1, &pStmt, 0); + if( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ + len = sqlite3_column_int(pStmt, 0); + if( len>40 ) len = 40; } sqlite3_finalize(pStmt); + pStmt = 0; + if( len ){ + rx = sqlite3_prepare_v2(p->db, + "SELECT key, quote(value) " + "FROM temp.sqlite_parameters;", -1, &pStmt, 0); + while( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ + oputf("%-*s %s\n", len, sqlite3_column_text(pStmt,0), + sqlite3_column_text(pStmt,1)); + } + sqlite3_finalize(pStmt); + } } }else - /* .parameter init + /* .parameter init ?--memory? ** Make sure the TEMP table used to hold bind parameters exists. ** Create it if necessary. + ** + ** If the --memory option is specified, the sqlite_parameters table + ** is held in a separate database so that parameter binding queries + ** do not show up in debugging output from .treetrace, .wheretrace, + ** PRAGMA vdbe_addoptrace=on, and similar. */ if( nArg==2 && cli_strcmp(azArg[1],"init")==0 ){ - bind_table_init(p); + bind_table_init(p, 0); + }else + if( nArg==3 && cli_strcmp(azArg[1],"init")==0 + && cli_strcmp(azArg[2],"--memory")==0 + ){ + bind_table_init(p, 1); }else /* .parameter set NAME VALUE @@ -9777,28 +9830,30 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_stmt *pStmt; const char *zKey = azArg[2]; const char *zValue = azArg[3]; - bind_table_init(p); - zSql = sqlite3_mprintf( - "REPLACE INTO temp.sqlite_parameters(key,value)" - "VALUES(%Q,%s);", zKey, zValue); - shell_check_oom(zSql); - pStmt = 0; - rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); - sqlite3_free(zSql); - if( rx!=SQLITE_OK ){ - sqlite3_finalize(pStmt); - pStmt = 0; + bind_table_init(p, 0); + if( p->dbParam ){ zSql = sqlite3_mprintf( - "REPLACE INTO temp.sqlite_parameters(key,value)" - "VALUES(%Q,%Q);", zKey, zValue); + "REPLACE INTO temp.sqlite_parameters(key,value)" + "VALUES(%Q,%s);", zKey, zValue); shell_check_oom(zSql); - rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); + pStmt = 0; + rx = sqlite3_prepare_v2(p->dbParam, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rx!=SQLITE_OK ){ - oputf("Error: %s\n", sqlite3_errmsg(p->db)); sqlite3_finalize(pStmt); pStmt = 0; - rc = 1; + zSql = sqlite3_mprintf( + "REPLACE INTO temp.sqlite_parameters(key,value)" + "VALUES(%Q,%Q);", zKey, zValue); + shell_check_oom(zSql); + rx = sqlite3_prepare_v2(p->dbParam, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + if( rx!=SQLITE_OK ){ + oputf("Error: %s\n", sqlite3_errmsg(p->db)); + sqlite3_finalize(pStmt); + pStmt = 0; + rc = 1; + } } } sqlite3_step(pStmt); @@ -9813,7 +9868,7 @@ static int do_meta_command(char *zLine, ShellState *p){ char *zSql = sqlite3_mprintf( "DELETE FROM temp.sqlite_parameters WHERE key=%Q", azArg[2]); shell_check_oom(zSql); - sqlite3_exec(p->db, zSql, 0, 0, 0); + if( p->dbParam ) sqlite3_exec(p->dbParam, zSql, 0, 0, 0); sqlite3_free(zSql); }else /* If no command name matches, show a syntax error */ @@ -9951,14 +10006,14 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = sqlite3_open(zSrcFile, &pSrc); if( rc!=SQLITE_OK ){ eputf("Error: cannot open \"%s\"\n", zSrcFile); - close_db(pSrc); + close_db(pSrc, 0); return 1; } open_db(p, 0); pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main"); if( pBackup==0 ){ eputf("Error: %s\n", sqlite3_errmsg(p->db)); - close_db(pSrc); + close_db(pSrc, 0); return 1; } while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK @@ -9978,7 +10033,7 @@ static int do_meta_command(char *zLine, ShellState *p){ eputf("Error: %s\n", sqlite3_errmsg(p->db)); rc = 1; } - close_db(pSrc); + close_db(pSrc, 0); }else #endif /* !defined(SQLITE_SHELL_FIDDLE) */ @@ -12845,13 +12900,13 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ set_table_name(&data, 0); if( data.db ){ session_close_all(&data, -1); - close_db(data.db); + close_db(data.db, data.dbParam); } for(i=0; i Date: Thu, 8 Aug 2024 10:51:56 +0000 Subject: [PATCH 0630/1030] Move a misplaced va_end, as reported in [forum:702c79e9da|forum post 702c79e9da]. FossilOrigin-Name: daa25fb35fd7bdd482d51214439f38b0b9a7df93f689a2b3d30a113daa9f2a1a --- ext/recover/sqlite3recover.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/recover/sqlite3recover.c b/ext/recover/sqlite3recover.c index 1d858c0ab9..afa1ae8619 100644 --- a/ext/recover/sqlite3recover.c +++ b/ext/recover/sqlite3recover.c @@ -363,8 +363,8 @@ static int recoverError( va_start(ap, zFmt); if( zFmt ){ z = sqlite3_vmprintf(zFmt, ap); - va_end(ap); } + va_end(ap); sqlite3_free(p->zErrMsg); p->zErrMsg = z; p->errCode = errCode; diff --git a/manifest b/manifest index 587d9af3bb..be8df9916c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--memory\soption\sto\sthe\s".parameter\sinit"\sCLI\scommand.\s\sWhen\spresent,\nthe\s--memory\soption\scauses\sthe\ssqlite_parameters\stable\sto\sbe\screated\sin\sa\ncompletely\sindependent\s:memory:\sdatabase.\s\sThis\scan\sbe\sdone\sto\savoid\nparameter\sbinding\squeries\sfrom\sbeing\saffected\sby\sdebug\ssettings\ssuch\sas\n".wheretrace",\s".treetrace",\s"PRAGMA\svdbe_addoptrace=on",\sand\ssimilar. -D 2024-08-08T10:10:38.385 +C Move\sa\smisplaced\sva_end,\sas\sreported\sin\s[forum:702c79e9da|forum\spost\s702c79e9da]. +D 2024-08-08T10:51:56.875 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -496,7 +496,7 @@ F ext/recover/recoverpgsz.test 88766fcb810e52ee05335c456d4e5fb06d02b73d3ccb48c52 F ext/recover/recoverrowid.test f948bf4024a5f41b0e21b8af80c60564c5b5d78c05a8d64fc00787715ff9f45f F ext/recover/recoverslowidx.test 5205a9742dd9490ee99950dabb622307355ef1662dea6a3a21030057bfd81411 F ext/recover/recoversql.test e66d01f95302a223bcd3fd42b5ee58dc2b53d70afa90b0d00e41e4b8eab20486 -F ext/recover/sqlite3recover.c 65ef0f56301a16c0536c9839fb7e23540c9c4f75da0afe3b7b4d163c8f624404 +F ext/recover/sqlite3recover.c 2dcf6b56c5e0e2b43fc4c6115b689ab194c374ced7f7f8380ad9a24d8ef24ac9 F ext/recover/sqlite3recover.h 011c799f02deb70ab685916f6f538e6bb32c4e0025e79bfd0e24ff9c74820959 F ext/recover/test_recover.c 072260d7452a3b81aba995b2b3269e7ec2aa7f06725544ba4c25b1b0a1dbc61a F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15 @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 08cc5488404d068e59378b82988460793710df43ec21b4a83a794b497abd035f -R d4d35f38c7731eed804015561204e2a7 -U drh -Z 252eafc7dac030f0d53111914f8dbebb +P 4e69dce2093b75b7db4fbdca4953b664b907be15d991ed352ea1d87c64fbf9d2 +R 935874f09c4ed9cbbe850ee6abdc733e +U stephan +Z 89ea814313a09066a5db1ffe092c64f9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 950203b129..3b9c763676 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4e69dce2093b75b7db4fbdca4953b664b907be15d991ed352ea1d87c64fbf9d2 +daa25fb35fd7bdd482d51214439f38b0b9a7df93f689a2b3d30a113daa9f2a1a From 6e7a0c2d86bc143d45333d9f60c04d08c4ce5cae Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 8 Aug 2024 12:08:36 +0000 Subject: [PATCH 0631/1030] In the CLI, recognize magic parameter names "$int_NNN" and "$text_TTT" and bind them with integer value NNN and text value TTT respectively. Intended for testing and debugging use only. FossilOrigin-Name: a929cdb00ff74d77cdf55087d32abf53578f7127b36276f89b64ccbef1d4a9a4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index be8df9916c..4e8e40977e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\sa\smisplaced\sva_end,\sas\sreported\sin\s[forum:702c79e9da|forum\spost\s702c79e9da]. -D 2024-08-08T10:51:56.875 +C In\sthe\sCLI,\srecognize\smagic\sparameter\snames\s"$int_NNN"\sand\s"$text_TTT"\sand\nbind\sthem\swith\sinteger\svalue\sNNN\sand\stext\svalue\sTTT\srespectively.\s\sIntended\nfor\stesting\sand\sdebugging\suse\sonly. +D 2024-08-08T12:08:36.854 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e -F src/shell.c.in 8b1a82ddbcf93580f991eecec0a22e8edc7d62fa856388d9bed2392da1cbfa42 +F src/shell.c.in 1dfa62d27d77aa8c436d0dfc62920e2e2a2294548ffd078aee0f87b7ab95cc28 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2203,8 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4e69dce2093b75b7db4fbdca4953b664b907be15d991ed352ea1d87c64fbf9d2 -R 935874f09c4ed9cbbe850ee6abdc733e -U stephan -Z 89ea814313a09066a5db1ffe092c64f9 +P daa25fb35fd7bdd482d51214439f38b0b9a7df93f689a2b3d30a113daa9f2a1a +R 659621e574300f0e8637eafa75ce3615 +U drh +Z 38571f620a01d4193af4068fe3fcd87f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3b9c763676..f43ac8b8ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -daa25fb35fd7bdd482d51214439f38b0b9a7df93f689a2b3d30a113daa9f2a1a +a929cdb00ff74d77cdf55087d32abf53578f7127b36276f89b64ccbef1d4a9a4 diff --git a/src/shell.c.in b/src/shell.c.in index 2d6c76d3b0..5e89be57aa 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3571,6 +3571,14 @@ static void bind_prepared_stmt(ShellState *pArg, sqlite3_stmt *pStmt){ }else if( sqlite3_strlike("_INF", zVar, 0)==0 ){ sqlite3_bind_double(pStmt, i, INFINITY); #endif + }else if( strncmp(zVar, "$int_", 5)==0 ){ + sqlite3_bind_int(pStmt, i, atoi(&zVar[5])); + }else if( strncmp(zVar, "$text_", 6)==0 ){ + char *zBuf = sqlite3_malloc64( strlen(zVar)-5 ); + if( zBuf ){ + memcpy(zBuf, &zVar[6], strlen(zVar)-5); + sqlite3_bind_text64(pStmt, i, zBuf, -1, sqlite3_free, SQLITE_UTF8); + } }else{ sqlite3_bind_null(pStmt, i); } From 35c6f58dce05a727ba13697bff9b254379cb7a25 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 8 Aug 2024 12:14:07 +0000 Subject: [PATCH 0632/1030] Back out the --memory option to ".parameter init" in the CLI, as the capability is no longer needed for testing due to the new "$int_N" and "$text_T" automatic bindings, and the "init --memory" is hence just added complication. FossilOrigin-Name: 3b1b0c141993eb0f8749f54ea40d6014f9bdccbe0fdb3ccccad971a0baea8d3c --- manifest | 13 ++-- manifest.uuid | 2 +- src/shell.c.in | 185 +++++++++++++++++-------------------------------- 3 files changed, 73 insertions(+), 127 deletions(-) diff --git a/manifest b/manifest index 4e8e40977e..c751b57718 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sCLI,\srecognize\smagic\sparameter\snames\s"$int_NNN"\sand\s"$text_TTT"\sand\nbind\sthem\swith\sinteger\svalue\sNNN\sand\stext\svalue\sTTT\srespectively.\s\sIntended\nfor\stesting\sand\sdebugging\suse\sonly. -D 2024-08-08T12:08:36.854 +C Back\sout\sthe\s--memory\soption\sto\s".parameter\sinit"\sin\sthe\sCLI,\sas\sthe\ncapability\sis\sno\slonger\sneeded\sfor\stesting\sdue\sto\sthe\snew\s"$int_N"\sand\n"$text_T"\sautomatic\sbindings,\sand\sthe\s"init\s--memory"\sis\shence\sjust\nadded\scomplication. +D 2024-08-08T12:14:07.897 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e -F src/shell.c.in 1dfa62d27d77aa8c436d0dfc62920e2e2a2294548ffd078aee0f87b7ab95cc28 +F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2203,8 +2203,9 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P daa25fb35fd7bdd482d51214439f38b0b9a7df93f689a2b3d30a113daa9f2a1a -R 659621e574300f0e8637eafa75ce3615 +P a929cdb00ff74d77cdf55087d32abf53578f7127b36276f89b64ccbef1d4a9a4 +Q -4e69dce2093b75b7db4fbdca4953b664b907be15d991ed352ea1d87c64fbf9d2 +R 80ba63bff6bb194482fa92e681f77bdc U drh -Z 38571f620a01d4193af4068fe3fcd87f +Z 15b4994c5694541199c17b609b4ae0e5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f43ac8b8ad..60de4ef9d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a929cdb00ff74d77cdf55087d32abf53578f7127b36276f89b64ccbef1d4a9a4 +3b1b0c141993eb0f8749f54ea40d6014f9bdccbe0fdb3ccccad971a0baea8d3c diff --git a/src/shell.c.in b/src/shell.c.in index 5e89be57aa..5b0a1a84b0 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1356,8 +1356,6 @@ struct ShellState { #endif } aAuxDb[5], /* Array of all database connections */ *pAuxDb; /* Currently active database connection */ - sqlite3 *dbParam; /* Database to use for query parameters. Often the - ** same as "db", but might be different. */ int *aiIndent; /* Array of indents used in MODE_Explain */ int nIndent; /* Size of array aiIndent[] */ int iIndent; /* Index of current op in aiIndent[] */ @@ -3482,44 +3480,22 @@ static void restore_debug_trace_modes(void){ sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 3, &savedWhereTrace); } -/* Create the TEMP table used to store parameter bindings. -** -** If bInMemory is true, create a separate in-memory database for -** the parameter binding table. -** -** The database that stores the sqlite_parameter table will be -** p->dbParam. This might be a copy of p->db. Or it might be a -** completely separate database (if bInMemory is true, because of -** the ".param init --memory" command). -*/ -static void bind_table_init(ShellState *p, int bInMemory){ +/* Create the TEMP table used to store parameter bindings */ +static void bind_table_init(ShellState *p){ int wrSchema = 0; int defensiveMode = 0; - sqlite3 *dbx; - if( p->dbParam ) return; - if( sqlite3_table_column_metadata(p->db, "TEMP", "sqlite_parameters", - "key", 0, 0, 0, 0, 0)==SQLITE_OK ){ - return; - } - if( bInMemory && p->dbParam==0 ){ - sqlite3_open(":memory:", &p->dbParam); - }else{ - p->dbParam = p->db; - } - dbx = p->dbParam; - - sqlite3_db_config(dbx, SQLITE_DBCONFIG_DEFENSIVE, -1, &defensiveMode); - sqlite3_db_config(dbx, SQLITE_DBCONFIG_DEFENSIVE, 0, 0); - sqlite3_db_config(dbx, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema); - sqlite3_db_config(dbx, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0); - sqlite3_exec(dbx, + sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, -1, &defensiveMode); + sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, 0, 0); + sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema); + sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0); + sqlite3_exec(p->db, "CREATE TABLE IF NOT EXISTS temp.sqlite_parameters(\n" " key TEXT PRIMARY KEY,\n" " value\n" ") WITHOUT ROWID;", 0, 0, 0); - sqlite3_db_config(dbx, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0); - sqlite3_db_config(dbx, SQLITE_DBCONFIG_DEFENSIVE, defensiveMode, 0); + sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0); + sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, defensiveMode, 0); } /* @@ -3542,14 +3518,12 @@ static void bind_prepared_stmt(ShellState *pArg, sqlite3_stmt *pStmt){ nVar = sqlite3_bind_parameter_count(pStmt); if( nVar==0 ) return; /* Nothing to do */ - if( pArg->dbParam==0 - || sqlite3_table_column_metadata(pArg->dbParam, "TEMP", "sqlite_parameters", - "key", 0, 0, 0, 0, 0)!=SQLITE_OK - ){ + if( sqlite3_table_column_metadata(pArg->db, "TEMP", "sqlite_parameters", + "key", 0, 0, 0, 0, 0)!=SQLITE_OK ){ rc = SQLITE_NOTFOUND; pQ = 0; }else{ - rc = sqlite3_prepare_v2(pArg->dbParam, + rc = sqlite3_prepare_v2(pArg->db, "SELECT value FROM temp.sqlite_parameters" " WHERE key=?1", -1, &pQ, 0); } @@ -4863,7 +4837,7 @@ static const char *(azHelp[]) = { #endif ".parameter CMD ... Manage SQL parameter bindings", " clear Erase all bindings", - " init ?--memory? Initialize the TEMP table that holds bindings", + " init Initialize the TEMP table that holds bindings", " list List the current parameter bindings", " set PARAMETER VALUE Given SQL parameter PARAMETER a value of VALUE", " PARAMETER should start with one of: $ : @ ?", @@ -5519,17 +5493,9 @@ static void open_db(ShellState *p, int openFlags){ /* ** Attempt to close the database connection. Report errors. -** -** If dbParam is not NULL and is different from db, then close it -** too. No error checking is done on the close of dbParam, as it -** should be a :memory: database which cannot really fail on close. */ -void close_db(sqlite3 *db, sqlite3 *dbParam){ - int rc; - if( dbParam && dbParam!=db ){ - sqlite3_close(dbParam); - } - rc = sqlite3_close(db); +void close_db(sqlite3 *db){ + int rc = sqlite3_close(db); if( rc ){ eputf("Error: sqlite3_close() returns %d: %s\n", rc, sqlite3_errmsg(db)); } @@ -6188,7 +6154,7 @@ static void tryToClone(ShellState *p, const char *zNewDb){ sqlite3_exec(newDb, "COMMIT;", 0, 0, 0); sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0); } - close_db(newDb, 0); + close_db(newDb); } #ifndef SQLITE_SHELL_FIDDLE @@ -7623,7 +7589,7 @@ static int arDotCommand( } end_ar_command: if( cmd.db!=pState->db ){ - close_db(cmd.db, 0); + close_db(cmd.db); } sqlite3_free(cmd.zSrcTable); @@ -8148,7 +8114,7 @@ static int do_meta_command(char *zLine, ShellState *p){ SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, zVfs); if( rc!=SQLITE_OK ){ eputf("Error: cannot open \"%s\"\n", zDestFile); - close_db(pDest, 0); + close_db(pDest); return 1; } if( bAsync ){ @@ -8159,7 +8125,7 @@ static int do_meta_command(char *zLine, ShellState *p){ pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb); if( pBackup==0 ){ eputf("Error: %s\n", sqlite3_errmsg(pDest)); - close_db(pDest, 0); + close_db(pDest); return 1; } while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){} @@ -8170,7 +8136,7 @@ static int do_meta_command(char *zLine, ShellState *p){ eputf("Error: %s\n", sqlite3_errmsg(pDest)); rc = 1; } - close_db(pDest, 0); + close_db(pDest); }else #endif /* !defined(SQLITE_SHELL_FIDDLE) */ @@ -8310,7 +8276,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = 1; }else if( p->aAuxDb[i].db ){ session_close_all(p, i); - close_db(p->aAuxDb[i].db, 0); + close_db(p->aAuxDb[i].db); p->aAuxDb[i].db = 0; } }else{ @@ -9600,8 +9566,8 @@ static int do_meta_command(char *zLine, ShellState *p){ /* Close the existing database */ session_close_all(p, -1); - close_db(p->db, p->dbParam); - p->db = p->dbParam = 0; + close_db(p->db); + p->db = 0; p->pAuxDb->zDbFilename = 0; sqlite3_free(p->pAuxDb->zFreeOnClose); p->pAuxDb->zFreeOnClose = 0; @@ -9767,15 +9733,8 @@ static int do_meta_command(char *zLine, ShellState *p){ ** Clear all bind parameters by dropping the TEMP table that holds them. */ if( nArg==2 && cli_strcmp(azArg[1],"clear")==0 ){ - if( p->dbParam==0 ){ - /* no-op */ - }else if( p->dbParam==p->db ){ - sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.sqlite_parameters;", - 0, 0, 0); - }else{ - sqlite3_close(p->dbParam); - } - p->dbParam = 0; + sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.sqlite_parameters;", + 0, 0, 0); }else /* .parameter list @@ -9785,45 +9744,33 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_stmt *pStmt = 0; int rx; int len = 0; - if( p->dbParam ){ - rx = sqlite3_prepare_v2(p->dbParam, - "SELECT max(length(key)) " - "FROM temp.sqlite_parameters;", -1, &pStmt, 0); - if( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ - len = sqlite3_column_int(pStmt, 0); - if( len>40 ) len = 40; + rx = sqlite3_prepare_v2(p->db, + "SELECT max(length(key)) " + "FROM temp.sqlite_parameters;", -1, &pStmt, 0); + if( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ + len = sqlite3_column_int(pStmt, 0); + if( len>40 ) len = 40; + } + sqlite3_finalize(pStmt); + pStmt = 0; + if( len ){ + rx = sqlite3_prepare_v2(p->db, + "SELECT key, quote(value) " + "FROM temp.sqlite_parameters;", -1, &pStmt, 0); + while( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ + oputf("%-*s %s\n", len, sqlite3_column_text(pStmt,0), + sqlite3_column_text(pStmt,1)); } sqlite3_finalize(pStmt); - pStmt = 0; - if( len ){ - rx = sqlite3_prepare_v2(p->db, - "SELECT key, quote(value) " - "FROM temp.sqlite_parameters;", -1, &pStmt, 0); - while( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ - oputf("%-*s %s\n", len, sqlite3_column_text(pStmt,0), - sqlite3_column_text(pStmt,1)); - } - sqlite3_finalize(pStmt); - } } }else - /* .parameter init ?--memory? + /* .parameter init ** Make sure the TEMP table used to hold bind parameters exists. ** Create it if necessary. - ** - ** If the --memory option is specified, the sqlite_parameters table - ** is held in a separate database so that parameter binding queries - ** do not show up in debugging output from .treetrace, .wheretrace, - ** PRAGMA vdbe_addoptrace=on, and similar. */ if( nArg==2 && cli_strcmp(azArg[1],"init")==0 ){ - bind_table_init(p, 0); - }else - if( nArg==3 && cli_strcmp(azArg[1],"init")==0 - && cli_strcmp(azArg[2],"--memory")==0 - ){ - bind_table_init(p, 1); + bind_table_init(p); }else /* .parameter set NAME VALUE @@ -9838,30 +9785,28 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_stmt *pStmt; const char *zKey = azArg[2]; const char *zValue = azArg[3]; - bind_table_init(p, 0); - if( p->dbParam ){ + bind_table_init(p); + zSql = sqlite3_mprintf( + "REPLACE INTO temp.sqlite_parameters(key,value)" + "VALUES(%Q,%s);", zKey, zValue); + shell_check_oom(zSql); + pStmt = 0; + rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + if( rx!=SQLITE_OK ){ + sqlite3_finalize(pStmt); + pStmt = 0; zSql = sqlite3_mprintf( - "REPLACE INTO temp.sqlite_parameters(key,value)" - "VALUES(%Q,%s);", zKey, zValue); + "REPLACE INTO temp.sqlite_parameters(key,value)" + "VALUES(%Q,%Q);", zKey, zValue); shell_check_oom(zSql); - pStmt = 0; - rx = sqlite3_prepare_v2(p->dbParam, zSql, -1, &pStmt, 0); + rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rx!=SQLITE_OK ){ + oputf("Error: %s\n", sqlite3_errmsg(p->db)); sqlite3_finalize(pStmt); pStmt = 0; - zSql = sqlite3_mprintf( - "REPLACE INTO temp.sqlite_parameters(key,value)" - "VALUES(%Q,%Q);", zKey, zValue); - shell_check_oom(zSql); - rx = sqlite3_prepare_v2(p->dbParam, zSql, -1, &pStmt, 0); - sqlite3_free(zSql); - if( rx!=SQLITE_OK ){ - oputf("Error: %s\n", sqlite3_errmsg(p->db)); - sqlite3_finalize(pStmt); - pStmt = 0; - rc = 1; - } + rc = 1; } } sqlite3_step(pStmt); @@ -9876,7 +9821,7 @@ static int do_meta_command(char *zLine, ShellState *p){ char *zSql = sqlite3_mprintf( "DELETE FROM temp.sqlite_parameters WHERE key=%Q", azArg[2]); shell_check_oom(zSql); - if( p->dbParam ) sqlite3_exec(p->dbParam, zSql, 0, 0, 0); + sqlite3_exec(p->db, zSql, 0, 0, 0); sqlite3_free(zSql); }else /* If no command name matches, show a syntax error */ @@ -10014,14 +9959,14 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = sqlite3_open(zSrcFile, &pSrc); if( rc!=SQLITE_OK ){ eputf("Error: cannot open \"%s\"\n", zSrcFile); - close_db(pSrc, 0); + close_db(pSrc); return 1; } open_db(p, 0); pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main"); if( pBackup==0 ){ eputf("Error: %s\n", sqlite3_errmsg(p->db)); - close_db(pSrc, 0); + close_db(pSrc); return 1; } while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK @@ -10041,7 +9986,7 @@ static int do_meta_command(char *zLine, ShellState *p){ eputf("Error: %s\n", sqlite3_errmsg(p->db)); rc = 1; } - close_db(pSrc, 0); + close_db(pSrc); }else #endif /* !defined(SQLITE_SHELL_FIDDLE) */ @@ -12908,13 +12853,13 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ set_table_name(&data, 0); if( data.db ){ session_close_all(&data, -1); - close_db(data.db, data.dbParam); + close_db(data.db); } for(i=0; i Date: Thu, 8 Aug 2024 14:45:50 +0000 Subject: [PATCH 0633/1030] Do not let the number of terms on a VALUES clause be limited by SQLITE_LIMIT_COMPOUND_SELECT, even if the VALUES clause contains elements that appear to be variables due to the use of double-quoted string literals. [https://issues.chromium.org/issues/358174302|Chromium issue 358174302]. FossilOrigin-Name: 670beb133eb203065a75022f0c6db7c605a4e0e22c8ef6d6b4724be2663ff3dc --- manifest | 17 ++++++++--------- manifest.uuid | 2 +- src/insert.c | 1 + src/parse.y | 6 +++--- test/select7.test | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index c751b57718..81f7e54a26 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\sthe\s--memory\soption\sto\s".parameter\sinit"\sin\sthe\sCLI,\sas\sthe\ncapability\sis\sno\slonger\sneeded\sfor\stesting\sdue\sto\sthe\snew\s"$int_N"\sand\n"$text_T"\sautomatic\sbindings,\sand\sthe\s"init\s--memory"\sis\shence\sjust\nadded\scomplication. -D 2024-08-08T12:14:07.897 +C Do\snot\slet\sthe\snumber\sof\sterms\son\sa\sVALUES\sclause\sbe\slimited\sby\nSQLITE_LIMIT_COMPOUND_SELECT,\seven\sif\sthe\sVALUES\sclause\scontains\selements\nthat\sappear\sto\sbe\svariables\sdue\sto\sthe\suse\sof\sdouble-quoted\sstring\sliterals.\n[https://issues.chromium.org/issues/358174302|Chromium\sissue\s358174302]. +D 2024-08-08T14:45:50.247 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -718,7 +718,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 4bd7c7e54a1062dcd0214b7a6296f7194eb10fb14d3ddca1ed20b01c2a86a18c +F src/insert.c 8ff11e9e54c5fc1fe89707b3d41cf44ad2822f712bd3b5da68338ea42518847e F src/json.c 5b6a1d6015997b9ee848a32948720bdb26a0ef2de5a2127ebf7355ce66dbdc0d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -748,7 +748,7 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 2bd540b3b1e79017eb41fca2396633a75e7dd430c05383c61fe52c6f4e97c6d8 +F src/parse.y 318ef86fbe358b1a93262a42e152f37b97b3fddae8d319dffbd24ce2300f6c88 F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 @@ -1591,7 +1591,7 @@ F test/select3.test 180223af31e1ca5537dd395ef9708ae18e651a233777fd366fd0d75469fc F test/select4.test f0684d3da3bccacbe2a1ebadf6fb49d9df6f53acb4c6ebc228a88d0d6054cc7b F test/select5.test 8afc5e5dcdebc2be54472e73ebd9cd1adef1225fd15d37a1c62f969159f390ae F test/select6.test 9b2fb4ffedf52e1b5703cfcae1212e7a4a063f014c0458d78d29aca3db766d1f -F test/select7.test f659f231489349e8c5734e610803d7654207318f +F test/select7.test b825420da8a0b5722fdb77f3369f6396a3d198c46e8787eb26ff9425d4ac9d27 F test/select8.test 8c8f5ae43894c891efc5755ed905467d1d67ad5d F test/select9.test f7586b207ce2304ab80dc93d3146469a28fd4403621dd3a82d06644563d3c812 F test/selectA.test 1da8ce3884c326e11d2855baffb76436b0d7e044404af8a2a70d1399a4ff7e29 @@ -2203,9 +2203,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a929cdb00ff74d77cdf55087d32abf53578f7127b36276f89b64ccbef1d4a9a4 -Q -4e69dce2093b75b7db4fbdca4953b664b907be15d991ed352ea1d87c64fbf9d2 -R 80ba63bff6bb194482fa92e681f77bdc +P 3b1b0c141993eb0f8749f54ea40d6014f9bdccbe0fdb3ccccad971a0baea8d3c +R 3c5d070c449c1fcf67b35bba7df06bed U drh -Z 15b4994c5694541199c17b609b4ae0e5 +Z dd212a4a681e0046af843c3dc6922a44 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 60de4ef9d1..6b708e5668 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3b1b0c141993eb0f8749f54ea40d6014f9bdccbe0fdb3ccccad971a0baea8d3c +670beb133eb203065a75022f0c6db7c605a4e0e22c8ef6d6b4724be2663ff3dc diff --git a/src/insert.c b/src/insert.c index 072386e656..a7e94420bf 100644 --- a/src/insert.c +++ b/src/insert.c @@ -717,6 +717,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ pRet->pSrc->nSrc = 1; pRet->pPrior = pLeft->pPrior; pRet->op = pLeft->op; + if( pRet->pPrior ) pRet->selFlags |= SF_Values; pLeft->pPrior = 0; pLeft->op = TK_SELECT; assert( pLeft->pNext==0 ); diff --git a/src/parse.y b/src/parse.y index de8282e81f..68c00f0a7f 100644 --- a/src/parse.y +++ b/src/parse.y @@ -532,9 +532,9 @@ cmd ::= select(X). { break; } } - if( (p->selFlags & SF_MultiValue)==0 && - (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 && - cnt>mxSelect + if( (p->selFlags & (SF_MultiValue|SF_Values))==0 + && (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 + && cnt>mxSelect ){ sqlite3ErrorMsg(pParse, "too many terms in compound SELECT"); } diff --git a/test/select7.test b/test/select7.test index d705ebfaf4..0c4051006a 100644 --- a/test/select7.test +++ b/test/select7.test @@ -155,6 +155,38 @@ if {[clang_sanitize_address]==0} { } } +# https://issues.chromium.org/issues/358174302 +# Need to support an unlimited number of terms in a VALUES clause, even +# if some of those terms contain double-quoted string literals. +# +do_execsql_test select7-6.5 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(a,b,c); +} +sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 10 +sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 0 +do_catchsql_test select7-6.6 { + INSERT INTO t1 VALUES + (NULL,0,""), (X'',0.0,0.0), (X'',X'',""), (0.0,0.0,""), (NULL,NULL,0.0), + (0,"",0), (0.0,X'',0), ("",X'',0.0), (0.0,X'',NULL), (0,NULL,""), + (0,"",NULL), (0.0,NULL,X''), ("",X'',NULL), (NULL,0,""), + (0,NULL,0), (X'',X'',0.0); +} {1 {no such column: "" - should this be a string literal in single-quotes?}} +do_execsql_test select7-6.7 { + SELECT count(*) FROM t1; +} {0} +sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1 +do_catchsql_test select7-6.8 { + INSERT INTO t1 VALUES + (NULL,0,""), (X'',0.0,0.0), (X'',X'',""), (0.0,0.0,""), (NULL,NULL,0.0), + (0,"",0), (0.0,X'',0), ("",X'',0.0), (0.0,X'',NULL), (0,NULL,""), + (0,"",NULL), (0.0,NULL,X''), ("",X'',NULL), (NULL,0,""), + (0,NULL,0), (X'',X'',0.0); +} {0 {}} +do_execsql_test select7-6.9 { + SELECT count(*) FROM t1; +} {16} + # This block of tests verifies that bug aa92c76cd4 is fixed. # do_test select7-7.1 { From 679f5d458ec173381f4bb4ab981e2054d2341242 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 8 Aug 2024 15:07:27 +0000 Subject: [PATCH 0634/1030] Add assert() statements and reorganize code slightly in fts3 and fts5 to make it easier to follow. FossilOrigin-Name: 797b0a13fd7a42b0a48ecbf0cd1961aa932da3e9c9ccffd903a3a4d963d0cc54 --- ext/fts3/fts3_snippet.c | 1 + ext/fts5/fts5_expr.c | 11 +++++++-- ext/fts5/test/fts5expr.test | 48 +++++++++++++++++++++++++++++++++++++ manifest | 19 ++++++++------- manifest.uuid | 2 +- test/fts3snippet.test | 5 +++- 6 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 ext/fts5/test/fts5expr.test diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index f6caabf4c9..80f62eb3bb 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -398,6 +398,7 @@ static int fts3SnippetNextCandidate(SnippetIter *pIter){ return 1; } + assert( pIter->nSnippet>=0 ); pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1; for(i=0; inPhrase; i++){ SnippetPhrase *pPhrase = &pIter->aPhrase[i]; diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 176d4e6a5f..a39cc16bbf 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2263,6 +2263,9 @@ static void fts5ExprAssignXNext(Fts5ExprNode *pNode){ } } +/* +** Add pSub as a child of p. +*/ static void fts5ExprAddChildren(Fts5ExprNode *p, Fts5ExprNode *pSub){ int ii = p->nChild; if( p->eType!=FTS5_NOT && pSub->eType==p->eType ){ @@ -2407,19 +2410,23 @@ Fts5ExprNode *sqlite3Fts5ParseNode( "fts5: %s queries are not supported (detail!=full)", pNear->nPhrase==1 ? "phrase": "NEAR" ); - sqlite3_free(pRet); + sqlite3Fts5ParseNodeFree(pRet); pRet = 0; + pNear = 0; + assert( pLeft==0 && pRight==0 ); } } }else{ + assert( pNear==0 ); fts5ExprAddChildren(pRet, pLeft); fts5ExprAddChildren(pRet, pRight); + pLeft = pRight = 0; if( pRet->iHeight>SQLITE_FTS5_MAX_EXPR_DEPTH ){ sqlite3Fts5ParseError(pParse, "fts5 expression tree is too large (maximum depth %d)", SQLITE_FTS5_MAX_EXPR_DEPTH ); - sqlite3_free(pRet); + sqlite3Fts5ParseNodeFree(pRet); pRet = 0; } } diff --git a/ext/fts5/test/fts5expr.test b/ext/fts5/test/fts5expr.test new file mode 100644 index 0000000000..e3938beb0f --- /dev/null +++ b/ext/fts5/test/fts5expr.test @@ -0,0 +1,48 @@ +# 2024 August 8 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the FTS5 module. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5expr + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE x1 USING fts5(a); + INSERT INTO x1(rowid, a) VALUES (113, 'fts5 expr test'); +} + +do_execsql_test 1.1 { + SELECT rowid FROM x1('expr'); +} {113} + +for {set ii 0} {$ii < 300} {incr ii} { + set expr "expr " + append expr [string repeat "NOT abcd " $ii] + + if {$ii<257} { + set res {0 113} + } else { + set res {1 {fts5 expression tree is too large (maximum depth 256)}} + } + do_catchsql_test 1.1.$ii { + SELECT rowid FROM x1($expr) + } $res +} + +finish_test + diff --git a/manifest b/manifest index 81f7e54a26..6482db0f73 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\slet\sthe\snumber\sof\sterms\son\sa\sVALUES\sclause\sbe\slimited\sby\nSQLITE_LIMIT_COMPOUND_SELECT,\seven\sif\sthe\sVALUES\sclause\scontains\selements\nthat\sappear\sto\sbe\svariables\sdue\sto\sthe\suse\sof\sdouble-quoted\sstring\sliterals.\n[https://issues.chromium.org/issues/358174302|Chromium\sissue\s358174302]. -D 2024-08-08T14:45:50.247 +C Add\sassert()\sstatements\sand\sreorganize\scode\sslightly\sin\sfts3\sand\sfts5\sto\smake\sit\seasier\sto\sfollow. +D 2024-08-08T15:07:27.410 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -74,7 +74,7 @@ F ext/fts3/fts3_hash.c 8b6e31bfb0844c27dc6092c2620bdb1fca17ed613072db057d96952c6 F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c 305ce7fb6036484085b5556a9c8e62acdc7763f0f4cdf5fd538212a9f3720116 F ext/fts3/fts3_porter.c e19807ce0ae31c1c6e9898e89ecc93183d7ec224ea101af039722a4f49e5f2b8 -F ext/fts3/fts3_snippet.c 610328fe128c047c6b0eba77768982ccf3933daae095d497949a75c9dfd47409 +F ext/fts3/fts3_snippet.c c38117a2e4dcc9485a170a57a6134423955247b230fef7073c46fa9c51239540 F ext/fts3/fts3_term.c 6a96027ad364001432545fe43322b6af04ed28bb5619ec51af1f59d0710d6d69 F ext/fts3/fts3_test.c 7a9cb3d61774134211bf4bfdf1adcb581a1a0377f2d050a121ae7ab44baef0e3 F ext/fts3/fts3_tokenize_vtab.c 7fd9ef364f257b97218b9c331f2378e307375c592f70fd541f714e747d944962 @@ -97,7 +97,7 @@ F ext/fts5/fts5Int.h 41fb3a2dd40e818cc96c6f4176dbdf2aaa8f57043cfc9a8f2676e7e6a72 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 -F ext/fts5/fts5_expr.c 29558460f161b0bee816fdfb6547cdcaefc7b61c64a1bf78d50052932a210201 +F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 77fefb37e7931095a5ff271a28fbe4f73ec46d5492ef1f35d405d98e137ad8ed @@ -159,6 +159,7 @@ F ext/fts5/test/fts5dlidx.test a7c42b0a74dc7c8aa1a46d586e0aadda4b6cc42c24450f8d3 F ext/fts5/test/fts5doclist.test b7cb84758504519746957802db9cd31187bb4e0028b89d9087ba06e26cc4155f F ext/fts5/test/fts5ea.test cefdf66024550fa7920c03395c71ce5046235ed1a1a7a469d79b19e7aad5afb5 F ext/fts5/test/fts5eb.test 401f756fdb77083aeba8b696c1e0ad4d834c39dbd6f17e492bb55a2ad64b4296 +F ext/fts5/test/fts5expr.test 7e1b2d075b63b727a624a378c2c09f94296a93dc4ae968aad67f8d9f3810c266 F ext/fts5/test/fts5fault1.test d28a65caee75db6897c3cf1358c5230d3bb2a3bf7fb31062c19c7e5382b3d2bd F ext/fts5/test/fts5fault2.test 69c8fdbef830cd0d450908d4504d5bb86609e255af99c421c20a0756251fe344 F ext/fts5/test/fts5fault3.test da2f9e3e56ff5740d68ebdd6877c97089e7ed28ddff28a0da87a6afea27e5522 @@ -1212,7 +1213,7 @@ F test/fts3query.test 45806a302921b245a9dba5d85c9d51fb98b3f137eea6e6bf6eae4883e0 F test/fts3rank.test cd99bc83a3c923c8d52afd90d86979cf05fc41849f892faeac3988055ef37b99 F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0 F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e -F test/fts3snippet.test 0887196d67cffbe365edde535b95ecc642a532ce8551ccd9a73aab5999c3ffae +F test/fts3snippet.test 560c7f38c5fa591d88e367eac1313b64e503625616708ff61da9d5f52cbf75e5 F test/fts3snippet2.test 03f6738ab3897bea2ba6be424a0613872e167acbf37a66200d655d737b470f65 F test/fts3sort.test ed34c716a11cc2009a35210e84ad5f9c102362ca F test/fts3tok1.test a663f4cac22a9505400bc22aacb818d7055240409c28729669ea7d4cc2120d15 @@ -2203,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3b1b0c141993eb0f8749f54ea40d6014f9bdccbe0fdb3ccccad971a0baea8d3c -R 3c5d070c449c1fcf67b35bba7df06bed -U drh -Z dd212a4a681e0046af843c3dc6922a44 +P 670beb133eb203065a75022f0c6db7c605a4e0e22c8ef6d6b4724be2663ff3dc +R 312db3aeda520a84f3f575d1adc99854 +U dan +Z f0731ccfa7622c7f28b0888a2de2dbf2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6b708e5668..e25e0856c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -670beb133eb203065a75022f0c6db7c605a4e0e22c8ef6d6b4724be2663ff3dc +797b0a13fd7a42b0a48ecbf0cd1961aa932da3e9c9ccffd903a3a4d963d0cc54 diff --git a/test/fts3snippet.test b/test/fts3snippet.test index ae022b68a6..ad1fbb3bef 100644 --- a/test/fts3snippet.test +++ b/test/fts3snippet.test @@ -561,7 +561,6 @@ do_test 4.3 { }] } {64} - #------------------------------------------------------------------------- # Request a snippet from a query with more than 64 phrases. # @@ -588,5 +587,9 @@ do_execsql_test 5.1 { {[a70] [a71] [a72]} } +do_execsql_test 5.2 { + SELECT snippet(t5, '[', ']', -1, 0) FROM t5 WHERE t5 MATCH 'a5' +} {{a4 [a5] a6}} + set sqlite_fts3_enable_parentheses 0 finish_test From 0c8c9a64b388c52f18df5b20900bb67d87ee0412 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 8 Aug 2024 15:26:11 +0000 Subject: [PATCH 0635/1030] Ensure sqlite3expert.c unregisters any SQL user-functions it registers with the database handle before returning. FossilOrigin-Name: 123b154ce3b6fee1bbf483704812bd6f8538966f9687520b4470d700f0270719 --- ext/expert/expert1.test | 7 +++++++ ext/expert/sqlite3expert.c | 20 ++++++++++++-------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/ext/expert/expert1.test b/ext/expert/expert1.test index c456c30c52..72c4fd72cd 100644 --- a/ext/expert/expert1.test +++ b/ext/expert/expert1.test @@ -465,6 +465,13 @@ do_execsql_test 5.3 { t2 t2_idx_0001295b {100 20 5} } +do_catchsql_test 5.4 { + SELECT sqlite_expert_rem(123, 123); +} {1 {no such function: sqlite_expert_rem}} +do_catchsql_test 5.5 { + SELECT sqlite_expert_sample(); +} {1 {no such function: sqlite_expert_sample}} + if 0 { do_test expert1-6.0 { catchcmd :memory: { diff --git a/ext/expert/sqlite3expert.c b/ext/expert/sqlite3expert.c index 276c2cc9fe..b59a59728d 100644 --- a/ext/expert/sqlite3expert.c +++ b/ext/expert/sqlite3expert.c @@ -626,7 +626,7 @@ static int expertFilter( pCsr->pData = 0; if( rc==SQLITE_OK ){ rc = idxPrintfPrepareStmt(pExpert->db, &pCsr->pData, &pVtab->base.zErrMsg, - "SELECT * FROM main.%Q WHERE sample()", pVtab->pTab->zName + "SELECT * FROM main.%Q WHERE sqlite_expert_sample()", pVtab->pTab->zName ); } @@ -1500,7 +1500,7 @@ struct IdxRemCtx { }; /* -** Implementation of scalar function rem(). +** Implementation of scalar function sqlite_expert_rem(). */ static void idxRemFunc( sqlite3_context *pCtx, @@ -1513,7 +1513,7 @@ static void idxRemFunc( assert( argc==2 ); iSlot = sqlite3_value_int(argv[0]); - assert( iSlot<=p->nSlot ); + assert( iSlotnSlot ); pSlot = &p->aSlot[iSlot]; switch( pSlot->eType ){ @@ -1624,7 +1624,8 @@ static int idxPopulateOneStat1( const char *zName = (const char*)sqlite3_column_text(pIndexXInfo, 0); const char *zColl = (const char*)sqlite3_column_text(pIndexXInfo, 1); zCols = idxAppendText(&rc, zCols, - "%sx.%Q IS rem(%d, x.%Q) COLLATE %s", zComma, zName, nCol, zName, zColl + "%sx.%Q IS sqlite_expert_rem(%d, x.%Q) COLLATE %s", + zComma, zName, nCol, zName, zColl ); zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol); } @@ -1757,13 +1758,13 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){ if( rc==SQLITE_OK ){ sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv); - rc = sqlite3_create_function( - dbrem, "rem", 2, SQLITE_UTF8, (void*)pCtx, idxRemFunc, 0, 0 + rc = sqlite3_create_function(dbrem, "sqlite_expert_rem", + 2, SQLITE_UTF8, (void*)pCtx, idxRemFunc, 0, 0 ); } if( rc==SQLITE_OK ){ - rc = sqlite3_create_function( - p->db, "sample", 0, SQLITE_UTF8, (void*)&samplectx, idxSampleFunc, 0, 0 + rc = sqlite3_create_function(p->db, "sqlite_expert_sample", + 0, SQLITE_UTF8, (void*)&samplectx, idxSampleFunc, 0, 0 ); } @@ -1815,6 +1816,9 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){ rc = sqlite3_exec(p->dbm, "ANALYZE sqlite_schema", 0, 0, 0); } + sqlite3_create_function(p->db, "sqlite_expert_rem", 2, SQLITE_UTF8, 0,0,0,0); + sqlite3_create_function(p->db, "sqlite_expert_sample", 0,SQLITE_UTF8,0,0,0,0); + sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp."UNIQUE_TABLE_NAME,0,0,0); return rc; } diff --git a/manifest b/manifest index 6482db0f73..173aea971f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sassert()\sstatements\sand\sreorganize\scode\sslightly\sin\sfts3\sand\sfts5\sto\smake\sit\seasier\sto\sfollow. -D 2024-08-08T15:07:27.410 +C Ensure\ssqlite3expert.c\sunregisters\sany\sSQL\suser-functions\sit\sregisters\swith\sthe\sdatabase\shandle\sbefore\sreturning. +D 2024-08-08T15:26:11.708 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -57,8 +57,8 @@ F ext/consio/console_io.c f32b757c9ee7fdf68e7586bee306f8368759e7cd12febb2a683919 F ext/consio/console_io.h 0548b83d7c4b7270ad544a67f2bb90cebc519637fa39b1838df4744cf0d87646 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 -F ext/expert/expert1.test 53a749de08939e3bc14f804e97410927d46fa772cbce0247d7e8fa6fc2523b0c -F ext/expert/sqlite3expert.c c8cea5ff15fbe792cccc4992a9b40b706411c41d32611f617897fecac6ff06a4 +F ext/expert/expert1.test 661f873fd451127edf822ef0d520088faa319135f6a15bd10be6801ac284ac9b +F ext/expert/sqlite3expert.c 8b09aeb2b95a9fca8b6628b522bf4d69aa746ff64c38eb1e99a9b5fad8cf03b9 F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/test_expert.c b767b2039a0df707eb3147e86bcf68b252d8455d9a41774b1a836cd052ceca70 F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c7cc3bf59ee @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 670beb133eb203065a75022f0c6db7c605a4e0e22c8ef6d6b4724be2663ff3dc -R 312db3aeda520a84f3f575d1adc99854 +P 797b0a13fd7a42b0a48ecbf0cd1961aa932da3e9c9ccffd903a3a4d963d0cc54 +R 524433c41a8ffc46e95c387bd9dc2975 U dan -Z f0731ccfa7622c7f28b0888a2de2dbf2 +Z fa7382f01ce16aee65751b978df534e7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e25e0856c1..f7625aad27 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -797b0a13fd7a42b0a48ecbf0cd1961aa932da3e9c9ccffd903a3a4d963d0cc54 +123b154ce3b6fee1bbf483704812bd6f8538966f9687520b4470d700f0270719 From caa7a625917f574cd3adffd22d44eaec6d27150b Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 9 Aug 2024 12:19:11 +0000 Subject: [PATCH 0636/1030] Remove unused static var cBadGroup from ext/consio/console_io.c to resolve a compiler warning reported in the fossil forum. This is a build fix, not a functional change. FossilOrigin-Name: fa047c3ea7a03d76afd6a11f58ef7b84c653f583ed795e0de5be2a6b986e558e --- ext/consio/console_io.c | 5 ----- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/ext/consio/console_io.c b/ext/consio/console_io.c index 3e2f556f52..3fa613ba9d 100755 --- a/ext/consio/console_io.c +++ b/ext/consio/console_io.c @@ -53,11 +53,6 @@ # define CIO_WIN_WC_XLATE 0 /* Not exposing translation routines at all */ #endif -#if CIO_WIN_WC_XLATE -/* Character used to represent a known-incomplete UTF-8 char group (�) */ -static WCHAR cBadGroup = 0xfffd; -#endif - #if CIO_WIN_WC_XLATE static HANDLE handleOfFile(FILE *pf){ int fileDesc = _fileno(pf); diff --git a/manifest b/manifest index 173aea971f..0de0ea94dd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\ssqlite3expert.c\sunregisters\sany\sSQL\suser-functions\sit\sregisters\swith\sthe\sdatabase\shandle\sbefore\sreturning. -D 2024-08-08T15:26:11.708 +C Remove\sunused\sstatic\svar\scBadGroup\sfrom\sext/consio/console_io.c\sto\sresolve\sa\scompiler\swarning\sreported\sin\sthe\sfossil\sforum.\sThis\sis\sa\sbuild\sfix,\snot\sa\sfunctional\schange. +D 2024-08-09T12:19:11.913 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -53,7 +53,7 @@ F ext/README.md fd5f78013b0a2bc6f0067afb19e6ad040e89a10179b4f6f03eee58fac5f169bd F ext/async/README.txt e12275968f6fde133a80e04387d0e839b0c51f91 F ext/async/sqlite3async.c 6f247666b495c477628dd19364d279c78ea48cd90c72d9f9b98ad1aff3294f94 F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a49808287f04aa5309a -F ext/consio/console_io.c f32b757c9ee7fdf68e7586bee306f8368759e7cd12febb2a6839199b1c1af395 x +F ext/consio/console_io.c b4885dfea71ed583315de8f0792a29d5fc7c7460b4a26c0aebe5cda5da8b38f8 x F ext/consio/console_io.h 0548b83d7c4b7270ad544a67f2bb90cebc519637fa39b1838df4744cf0d87646 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 797b0a13fd7a42b0a48ecbf0cd1961aa932da3e9c9ccffd903a3a4d963d0cc54 -R 524433c41a8ffc46e95c387bd9dc2975 -U dan -Z fa7382f01ce16aee65751b978df534e7 +P 123b154ce3b6fee1bbf483704812bd6f8538966f9687520b4470d700f0270719 +R dfb7fc0d7f5895fabd0ef74030340b71 +U stephan +Z 5f05148caae955ae7f0f151431a9b4b8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f7625aad27..367363b980 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -123b154ce3b6fee1bbf483704812bd6f8538966f9687520b4470d700f0270719 +fa047c3ea7a03d76afd6a11f58ef7b84c653f583ed795e0de5be2a6b986e558e From 1107b4b9cf9ea0ab3c7d2f2f344745fc77b710bf Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 9 Aug 2024 12:35:27 +0000 Subject: [PATCH 0637/1030] Bind the new debug parameters in fuzzinvariants.c. FossilOrigin-Name: 7e1dc263051cf50db04643d1a2aa9f91559b2b121859b750ce4446012d5f3c3e --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fuzzinvariants.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 0de0ea94dd..10fc3d74d8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunused\sstatic\svar\scBadGroup\sfrom\sext/consio/console_io.c\sto\sresolve\sa\scompiler\swarning\sreported\sin\sthe\sfossil\sforum.\sThis\sis\sa\sbuild\sfix,\snot\sa\sfunctional\schange. -D 2024-08-09T12:19:11.913 +C Bind\sthe\snew\sdebug\sparameters\sin\sfuzzinvariants.c. +D 2024-08-09T12:35:27.067 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1272,7 +1272,7 @@ F test/fuzzdata8.db 4a53b6d077c6a5c23b609d8d3ac66996fa55ba3f8d02f9b6efdd0214a767 F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc -F test/fuzzinvariants.c 0729b9d8ed77ad0f8c5c7601168a707d5803087d2da030ede9057c51c809cc6c +F test/fuzzinvariants.c 81167c9a7e82c0539a1d704aeb3384046d01f4108cda160a2447cb2a149d6362 F test/gcfault.test 4ea410ac161e685f17b19e1f606f58514a2850e806c65b846d05f60d436c5b0d F test/gencol1.test e169bdfa11c7ed5e9f322a98a7db3afe9e66235750b68c923efee8e1876b46ec F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 123b154ce3b6fee1bbf483704812bd6f8538966f9687520b4470d700f0270719 -R dfb7fc0d7f5895fabd0ef74030340b71 -U stephan -Z 5f05148caae955ae7f0f151431a9b4b8 +P fa047c3ea7a03d76afd6a11f58ef7b84c653f583ed795e0de5be2a6b986e558e +R 4385e87b815ad1924711e2dcdab3d5bb +U drh +Z 5861d6c430a2b6c91eb7ed0d9c3ba80b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 367363b980..c2f77959c0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa047c3ea7a03d76afd6a11f58ef7b84c653f583ed795e0de5be2a6b986e558e +7e1dc263051cf50db04643d1a2aa9f91559b2b121859b750ce4446012d5f3c3e diff --git a/test/fuzzinvariants.c b/test/fuzzinvariants.c index 80eb4aecb7..36121963f5 100644 --- a/test/fuzzinvariants.c +++ b/test/fuzzinvariants.c @@ -38,6 +38,31 @@ static void reportInvariantFailed( int noOpt /* True if opt flags inverted for pTest */ ); +/* +** Special parameter binding, for testing and debugging purposes. +** +** $int_NNN -> integer value NNN +** $text_TTTT -> floating point value TTT with destructor +*/ +static void bindDebugParameters(sqlite3_stmt *pStmt){ + int nVar = sqlite3_bind_parameter_count(pStmt); + int i; + for(i=0; i Date: Fri, 9 Aug 2024 17:09:18 +0000 Subject: [PATCH 0638/1030] Do not attempt to use a covering index based purely on columns-used when doing an UPDATE or DELETE of a WITHOUT ROWID table. Raise an SQLITE_INTERNAL error if there is ever a situation where a table reference cannot be converted into an index reference when the query planner thinks that a covering index is appropriate. FossilOrigin-Name: fae39ae9320c0f4fcc2e3b3baf0a4170ba2b9a04634a0a1fa41dd4918a74b106 --- manifest | 15 +++++++------ manifest.uuid | 2 +- src/where.c | 58 ++++++++++++++++----------------------------------- 3 files changed, 28 insertions(+), 47 deletions(-) diff --git a/manifest b/manifest index 10fc3d74d8..3b74d15e9f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bind\sthe\snew\sdebug\sparameters\sin\sfuzzinvariants.c. -D 2024-08-09T12:35:27.067 +C Do\snot\sattempt\sto\suse\sa\scovering\sindex\sbased\spurely\son\scolumns-used\nwhen\sdoing\san\sUPDATE\sor\sDELETE\sof\sa\sWITHOUT\sROWID\stable.\s\sRaise\san\nSQLITE_INTERNAL\serror\sif\sthere\sis\sever\sa\ssituation\swhere\sa\stable\sreference\ncannot\sbe\sconverted\sinto\san\sindex\sreference\swhen\sthe\squery\splanner\sthinks\nthat\sa\scovering\sindex\sis\sappropriate. +D 2024-08-09T17:09:18.697 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -846,7 +846,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 5bbe53db73ae6c8ee34a5eab693a5586ad8ff4f094ff0e524df965b683bec884 +F src/where.c 5fa17ec4e344e57cf43dd7b2977c95a518bfc2d43edb42df0cd1d5c2b42cee04 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -2204,8 +2204,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fa047c3ea7a03d76afd6a11f58ef7b84c653f583ed795e0de5be2a6b986e558e -R 4385e87b815ad1924711e2dcdab3d5bb +P 7e1dc263051cf50db04643d1a2aa9f91559b2b121859b750ce4446012d5f3c3e +R a22c0892de474f9ba14db4c65993edff +T *branch * covering-index-patch +T *sym-covering-index-patch * +T -sym-trunk * U drh -Z 5861d6c430a2b6c91eb7ed0d9c3ba80b +Z b1c9594c16be220e78f6cfe69b132d52 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c2f77959c0..30b7a517ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7e1dc263051cf50db04643d1a2aa9f91559b2b121859b750ce4446012d5f3c3e +fae39ae9320c0f4fcc2e3b3baf0a4170ba2b9a04634a0a1fa41dd4918a74b106 diff --git a/src/where.c b/src/where.c index c850121c34..15f5fe7d96 100644 --- a/src/where.c +++ b/src/where.c @@ -4047,7 +4047,9 @@ static int whereLoopAddBtree( " according to whereIsCoveringIndex()\n", pProbe->zName)); } } - }else if( m==0 ){ + }else if( m==0 + && (HasRowid(pTab) || pWInfo->pSelect!=0 || sqlite3FaultSim(700)) + ){ WHERETRACE(0x200, ("-> %s a covering index according to bitmasks\n", pProbe->zName, m==0 ? "is" : "is not")); @@ -7078,26 +7080,6 @@ WhereInfo *sqlite3WhereBegin( } #endif -#ifdef SQLITE_DEBUG -/* -** Return true if cursor iCur is opened by instruction k of the -** bytecode. Used inside of assert() only. -*/ -static int cursorIsOpen(Vdbe *v, int iCur, int k){ - while( k>=0 ){ - VdbeOp *pOp = sqlite3VdbeGetOp(v,k--); - if( pOp->p1!=iCur ) continue; - if( pOp->opcode==OP_Close ) return 0; - if( pOp->opcode==OP_OpenRead ) return 1; - if( pOp->opcode==OP_OpenWrite ) return 1; - if( pOp->opcode==OP_OpenDup ) return 1; - if( pOp->opcode==OP_OpenAutoindex ) return 1; - if( pOp->opcode==OP_OpenEphemeral ) return 1; - } - return 0; -} -#endif /* SQLITE_DEBUG */ - /* ** Generate the end of the WHERE loop. See comments on ** sqlite3WhereBegin() for additional information. @@ -7376,18 +7358,20 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ assert( pIdx->pTable==pTab ); #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC if( pOp->opcode==OP_Offset ){ - /* Do not need to translate the column number */ + x = 0; }else #endif - if( !HasRowid(pTab) ){ - Index *pPk = sqlite3PrimaryKeyIndex(pTab); - x = pPk->aiColumn[x]; - assert( x>=0 ); - }else{ - testcase( x!=sqlite3StorageColumnToTable(pTab,x) ); - x = sqlite3StorageColumnToTable(pTab,x); + { + if( !HasRowid(pTab) ){ + Index *pPk = sqlite3PrimaryKeyIndex(pTab); + x = pPk->aiColumn[x]; + assert( x>=0 ); + }else{ + testcase( x!=sqlite3StorageColumnToTable(pTab,x) ); + x = sqlite3StorageColumnToTable(pTab,x); + } + x = sqlite3TableColumnToIndex(pIdx, x); } - x = sqlite3TableColumnToIndex(pIdx, x); if( x>=0 ){ pOp->p2 = x; pOp->p1 = pLevel->iIdxCur; @@ -7397,16 +7381,10 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ ** reference. Verify that this is harmless - that the ** table being referenced really is open. */ -#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC - assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 - || cursorIsOpen(v,pOp->p1,k) - || pOp->opcode==OP_Offset - ); -#else - assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 - || cursorIsOpen(v,pOp->p1,k) - ); -#endif + if( pLoop->wsFlags & WHERE_IDX_ONLY ){ + sqlite3ErrorMsg(pParse, "internal query planner error"); + pParse->rc = SQLITE_INTERNAL; + } } }else if( pOp->opcode==OP_Rowid ){ pOp->p1 = pLevel->iIdxCur; From 610a5bafe24ed186a3741fec09d136d5fc3d5eac Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 9 Aug 2024 18:18:11 +0000 Subject: [PATCH 0639/1030] Fix the internal routine sqlite3ResolveExprListNames() so that it returns SQLITE_OK or SQLITE_ERROR instead of WRC_Continue or WRC_Abort. Without this fix, some times of obscure syntax errors end up returning SQLITE_INTERNAL rather than SQLITE_ERROR. FossilOrigin-Name: 9052187efd1f78abd9b285ac94269a3ba4d65b6aa74c9fa34002ee0628c83919 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/resolve.c | 11 +++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 10fc3d74d8..1939d75760 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bind\sthe\snew\sdebug\sparameters\sin\sfuzzinvariants.c. -D 2024-08-09T12:35:27.067 +C Fix\sthe\sinternal\sroutine\ssqlite3ResolveExprListNames()\sso\sthat\sit\sreturns\nSQLITE_OK\sor\sSQLITE_ERROR\sinstead\sof\sWRC_Continue\sor\sWRC_Abort.\s\sWithout\sthis\nfix,\ssome\stimes\sof\sobscure\ssyntax\serrors\send\sup\sreturning\sSQLITE_INTERNAL\nrather\sthan\sSQLITE_ERROR. +D 2024-08-09T18:18:11.368 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -758,7 +758,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145 +F src/resolve.c 0aee8a2e5340ba95a966917305dfaff5147fcad78d0839cd364b16e4746b8bcb F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fa047c3ea7a03d76afd6a11f58ef7b84c653f583ed795e0de5be2a6b986e558e -R 4385e87b815ad1924711e2dcdab3d5bb +P 7e1dc263051cf50db04643d1a2aa9f91559b2b121859b750ce4446012d5f3c3e +R c2e409b8bb5a5130f0d0a1d7f8083bf5 U drh -Z 5861d6c430a2b6c91eb7ed0d9c3ba80b +Z 115f5c56758e5bdc8ade5fed3254bde0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c2f77959c0..e2642285da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7e1dc263051cf50db04643d1a2aa9f91559b2b121859b750ce4446012d5f3c3e +9052187efd1f78abd9b285ac94269a3ba4d65b6aa74c9fa34002ee0628c83919 diff --git a/src/resolve.c b/src/resolve.c index d5c1515a74..dbb54198cb 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -2154,6 +2154,9 @@ int sqlite3ResolveExprNames( ** Resolve all names for all expression in an expression list. This is ** just like sqlite3ResolveExprNames() except that it works for an expression ** list rather than a single expression. +** +** The return value is SQLITE_OK (0) for success or SQLITE_ERROR (1) for a +** failure. */ int sqlite3ResolveExprListNames( NameContext *pNC, /* Namespace to resolve expressions in. */ @@ -2162,7 +2165,7 @@ int sqlite3ResolveExprListNames( int i; int savedHasAgg = 0; Walker w; - if( pList==0 ) return WRC_Continue; + if( pList==0 ) return SQLITE_OK; w.pParse = pNC->pParse; w.xExprCallback = resolveExprStep; w.xSelectCallback = resolveSelectStep; @@ -2176,7 +2179,7 @@ int sqlite3ResolveExprListNames( #if SQLITE_MAX_EXPR_DEPTH>0 w.pParse->nHeight += pExpr->nHeight; if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){ - return WRC_Abort; + return SQLITE_ERROR; } #endif sqlite3WalkExprNN(&w, pExpr); @@ -2193,10 +2196,10 @@ int sqlite3ResolveExprListNames( (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg); pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg); } - if( w.pParse->nErr>0 ) return WRC_Abort; + if( w.pParse->nErr>0 ) return SQLITE_ERROR; } pNC->ncFlags |= savedHasAgg; - return WRC_Continue; + return SQLITE_OK; } /* From c60c928717aa56cce9b70c95c7c505756aded9c5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 9 Aug 2024 18:42:01 +0000 Subject: [PATCH 0640/1030] Fix another instance where ALTER TABLE was returning SQLITE_INTERNAL instead of SQLITE_ERROR one malformed input. FossilOrigin-Name: b416756320dfb46ad72b843a7fbf18807d3fd1966251c320de626280b5238a5c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/alter.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1939d75760..ea58ba7fcd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sinternal\sroutine\ssqlite3ResolveExprListNames()\sso\sthat\sit\sreturns\nSQLITE_OK\sor\sSQLITE_ERROR\sinstead\sof\sWRC_Continue\sor\sWRC_Abort.\s\sWithout\sthis\nfix,\ssome\stimes\sof\sobscure\ssyntax\serrors\send\sup\sreturning\sSQLITE_INTERNAL\nrather\sthan\sSQLITE_ERROR. -D 2024-08-09T18:18:11.368 +C Fix\sanother\sinstance\swhere\sALTER\sTABLE\swas\sreturning\sSQLITE_INTERNAL\sinstead\nof\sSQLITE_ERROR\sone\smalformed\sinput. +D 2024-08-09T18:42:01.488 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -692,7 +692,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 -F src/alter.c e1b6782b85dd758f89e5c588e4e3eb82638c2dafc0c857b79a43bb8ec1746fca +F src/alter.c bb663fddf1fe0e2e6d8758b2b7fb6374e7c057a6ca3955f37a48986806029765 F src/analyze.c 5c4e2bfd0aa8e5157f7fb91a17d86905510a74397326dc5767ec4e0588a4eea5 F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39 F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7e1dc263051cf50db04643d1a2aa9f91559b2b121859b750ce4446012d5f3c3e -R c2e409b8bb5a5130f0d0a1d7f8083bf5 +P 9052187efd1f78abd9b285ac94269a3ba4d65b6aa74c9fa34002ee0628c83919 +R cfcbe2c3b80f7c18c681a7771600d22b U drh -Z 115f5c56758e5bdc8ade5fed3254bde0 +Z 27325e8a3b0694b1cf9e0c044251f29f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e2642285da..eda87af4fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9052187efd1f78abd9b285ac94269a3ba4d65b6aa74c9fa34002ee0628c83919 +b416756320dfb46ad72b843a7fbf18807d3fd1966251c320de626280b5238a5c diff --git a/src/alter.c b/src/alter.c index c1e0a295a4..a8556d115e 100644 --- a/src/alter.c +++ b/src/alter.c @@ -1320,7 +1320,7 @@ static int renameResolveTrigger(Parse *pParse){ /* ALWAYS() because if the table of the trigger does not exist, the ** error would have been hit before this point */ if( ALWAYS(pParse->pTriggerTab) ){ - rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab); + rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab)!=0; } /* Resolve symbols in WHEN clause */ From 5eba4281b029900a5a4518e5259f52da67a45bad Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 9 Aug 2024 20:59:50 +0000 Subject: [PATCH 0641/1030] Ensure tokenizers registered with xCreateTokenizer_v2() can be accessed using xFindTokenizer(), and that those registered with xCreateTokenizer() work with xFindTokenizer_v2(). FossilOrigin-Name: a3ef7d47b582a66a85ebe802ab40114f77289d6b44a4b375ea7858c60f59b27f --- ext/fts5/fts5_tcl.c | 170 ++++++++++++++++++++++++------ ext/fts5/test/fts5tokenizer3.test | 77 ++++++++++++++ manifest | 13 +-- manifest.uuid | 2 +- 4 files changed, 225 insertions(+), 37 deletions(-) create mode 100644 ext/fts5/test/fts5tokenizer3.test diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index fb951291a6..8b676f1325 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -822,6 +822,9 @@ struct F5tTokenizerContext { struct F5tTokenizerModule { Tcl_Interp *interp; Tcl_Obj *pScript; + void *pParentCtx; + fts5_tokenizer_v2 parent_v2; + fts5_tokenizer parent; F5tTokenizerContext *pContext; }; @@ -836,6 +839,8 @@ struct F5tTokenizerModule { struct F5tTokenizerInstance { Tcl_Interp *interp; Tcl_Obj *pScript; + F5tTokenizerModule *pModule; + Fts5Tokenizer *pParent; F5tTokenizerContext *pContext; char zLocale[128]; }; @@ -864,11 +869,20 @@ static int f5tTokenizerCreate( int nArg, Fts5Tokenizer **ppOut ){ + Fts5Tokenizer *pParent = 0; F5tTokenizerModule *pMod = (F5tTokenizerModule*)pCtx; Tcl_Obj *pEval; int rc = TCL_OK; int i; + assert( pMod->parent_v2.xCreate==0 || pMod->parent.xCreate==0 ); + if( pMod->parent_v2.xCreate ){ + rc = pMod->parent_v2.xCreate(pMod->pParentCtx, 0, 0, &pParent); + } + if( pMod->parent.xCreate ){ + rc = pMod->parent.xCreate(pMod->pParentCtx, 0, 0, &pParent); + } + pEval = Tcl_DuplicateObj(pMod->pScript); Tcl_IncrRefCount(pEval); for(i=0; rc==TCL_OK && iinterp = pMod->interp; pInst->pScript = Tcl_GetObjResult(pMod->interp); pInst->pContext = pMod->pContext; + pInst->pParent = pParent; + pInst->pModule = pMod; Tcl_IncrRefCount(pInst->pScript); *ppOut = (Fts5Tokenizer*)pInst; } @@ -898,11 +914,19 @@ static int f5tTokenizerCreate( static void f5tTokenizerDelete(Fts5Tokenizer *p){ F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)p; + if( pInst->pParent ){ + if( pInst->pModule->parent_v2.xDelete ){ + pInst->pModule->parent_v2.xDelete(pInst->pParent); + }else{ + pInst->pModule->parent.xDelete(pInst->pParent); + } + } Tcl_DecrRefCount(pInst->pScript); ckfree((char *)pInst); } -static int f5tTokenizerTokenize( + +static int f5tTokenizerReallyTokenize( Fts5Tokenizer *p, void *pCtx, int flags, @@ -963,6 +987,54 @@ static int f5tTokenizerTokenize( return rc; } +typedef struct CallbackCtx CallbackCtx; +struct CallbackCtx { + Fts5Tokenizer *p; + void *pCtx; + int flags; + int (*xToken)(void*, int, const char*, int, int, int); +}; + +static int f5tTokenizeCallback( + void *pCtx, + int tflags, + const char *z, int n, + int iStart, int iEnd +){ + CallbackCtx *p = (CallbackCtx*)pCtx; + return f5tTokenizerReallyTokenize(p->p, p->pCtx, p->flags, z, n, p->xToken); +} + +static int f5tTokenizerTokenize( + Fts5Tokenizer *p, + void *pCtx, + int flags, + const char *pText, int nText, + int (*xToken)(void*, int, const char*, int, int, int) +){ + int rc = SQLITE_OK; + F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)p; + if( pInst->pParent ){ + CallbackCtx ctx; + ctx.p = p; + ctx.pCtx = pCtx; + ctx.flags = flags; + ctx.xToken = xToken; + if( pInst->pModule->parent_v2.xTokenize ){ + rc = pInst->pModule->parent_v2.xTokenize( + pInst->pParent, (void*)&ctx, flags, pText, nText, f5tTokenizeCallback + ); + }else{ + rc = pInst->pModule->parent.xTokenize( + pInst->pParent, (void*)&ctx, flags, pText, nText, f5tTokenizeCallback + ); + } + }else{ + rc = f5tTokenizerReallyTokenize(p, pCtx, flags, pText, nText, xToken); + } + return rc; +} + /* ** sqlite3_fts5_locale */ @@ -1078,47 +1150,85 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( F5tTokenizerModule *pMod; int rc; int bV2 = 0; /* True to use _v2 API */ + const char *zParent = 0; /* Name of parent tokenizer, if any */ + int ii = 0; - if( objc==5 ){ - const char *zArg = Tcl_GetString(objv[1]); - if( 0==strcmp(zArg, "-v2") ){ - objv++; - objc--; - bV2 = 1; - } + if( objc<4 ){ + Tcl_WrongNumArgs(interp, 1, objv, "?OPTIONS? DB NAME SCRIPT"); + return TCL_ERROR; } - if( objc!=4 ){ - Tcl_WrongNumArgs(interp, 1, objv, "?-v2? DB NAME SCRIPT"); - return TCL_ERROR; + /* Parse any options. Set stack variables bV2 and zParent. */ + for(ii=1; iiinterp = interp; pMod->pScript = pScript; - pMod->pContext = pContext; Tcl_IncrRefCount(pScript); + pMod->pContext = pContext; + if( zParent ){ + if( bV2 ){ + fts5_tokenizer_v2 *pParent = 0; + rc = pApi->xFindTokenizer_v2(pApi, zParent, &pMod->pParentCtx, &pParent); + if( rc==SQLITE_OK ){ + memcpy(&pMod->parent_v2, pParent, sizeof(fts5_tokenizer_v2)); + } + }else{ + rc = pApi->xFindTokenizer(pApi, zParent, &pMod->pParentCtx,&pMod->parent); + } + } - if( bV2==0 ){ - fts5_tokenizer t; - t.xCreate = f5tTokenizerCreate; - t.xTokenize = f5tTokenizerTokenize; - t.xDelete = f5tTokenizerDelete; - rc = pApi->xCreateTokenizer(pApi, zName, (void*)pMod, &t, f5tDelTokenizer); - }else{ - fts5_tokenizer_v2 t2; - memset(&t2, 0, sizeof(t2)); - t2.iVersion = 2; - t2.xCreate = f5tTokenizerCreate; - t2.xTokenize = f5tTokenizerTokenize; - t2.xDelete = f5tTokenizerDelete; - t2.xSetLocale = f5tTokenizerSetLocale; - rc = pApi->xCreateTokenizer_v2(pApi, zName,(void*)pMod,&t2,f5tDelTokenizer); + if( rc==SQLITE_OK ){ + void *pModCtx = (void*)pMod; + if( bV2==0 ){ + fts5_tokenizer t; + t.xCreate = f5tTokenizerCreate; + t.xTokenize = f5tTokenizerTokenize; + t.xDelete = f5tTokenizerDelete; + rc = pApi->xCreateTokenizer(pApi, zName, pModCtx, &t, f5tDelTokenizer); + }else{ + fts5_tokenizer_v2 t2; + memset(&t2, 0, sizeof(t2)); + t2.iVersion = 2; + t2.xCreate = f5tTokenizerCreate; + t2.xTokenize = f5tTokenizerTokenize; + t2.xDelete = f5tTokenizerDelete; + t2.xSetLocale = f5tTokenizerSetLocale; + rc = pApi->xCreateTokenizer_v2(pApi, zName, pModCtx, &t2,f5tDelTokenizer); + } } if( rc!=SQLITE_OK ){ diff --git a/ext/fts5/test/fts5tokenizer3.test b/ext/fts5/test/fts5tokenizer3.test new file mode 100644 index 0000000000..5cdab743c2 --- /dev/null +++ b/ext/fts5/test/fts5tokenizer3.test @@ -0,0 +1,77 @@ +# 2024 Aug 10 +# +# 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. +# +#*********************************************************************** +# +# Tests focusing on the built-in fts5 tokenizers. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5tokenizer3 + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + + +proc get_sod {args} { return "split_on_dot" } +proc get_lowercase {args} { return "lowercase" } + +proc lowercase {flags txt} { + set n [string length $txt] + sqlite3_fts5_token [string tolower $txt] 0 $n + return 0 +} + +proc split_on_dot {flags txt} { + set iOff 0 + foreach t [split $txt "."] { + set n [string length $txt] + sqlite3_fts5_token $t $iOff [expr $iOff+$n] + incr iOff [expr {$n+1}] + } + return "" +} + +foreach {tn script} { + 1 { + sqlite3_fts5_create_tokenizer db lowercase get_lowercase + sqlite3_fts5_create_tokenizer -parent lowercase db split_on_dot get_sod + } + 2 { + sqlite3_fts5_create_tokenizer -v2 db lowercase get_lowercase + sqlite3_fts5_create_tokenizer -parent lowercase db split_on_dot get_sod + } + 3 { + sqlite3_fts5_create_tokenizer db lowercase get_lowercase + sqlite3_fts5_create_tokenizer -v2 -parent lowercase db split_on_dot get_sod + } + 4 { + sqlite3_fts5_create_tokenizer -v2 db lowercase get_lowercase + sqlite3_fts5_create_tokenizer -v2 -parent lowercase db split_on_dot get_sod + } +} { + reset_db + eval $script + + do_execsql_test 1.$tn.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x, tokenize=split_on_dot); + CREATE VIRTUAL TABLE t1vocab USING fts5vocab(t1, instance); + INSERT INTO t1 VALUES('ABC.Def.ghi'); + } + + do_execsql_test 1.$tn.1 { + SELECT term FROM t1vocab ORDER BY 1 + } {abc def ghi} +} + + +finish_test diff --git a/manifest b/manifest index fdb1dfd115..a95f78f7fb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthings\sso\sthat\slocale=1\sis\srequired\sto\swrite\sfts5_locale()\svalues\sto\san\sfts5\stable,\sand\sso\sthat\sblobs\smay\snot\sbe\sstored\sin\sindexed\s(i.e.\snot\sUNINDEXED)\scolumns\sof\sthese\stables. -D 2024-08-02T21:06:13.360 +C Ensure\stokenizers\sregistered\swith\sxCreateTokenizer_v2()\scan\sbe\saccessed\susing\sxFindTokenizer(),\sand\sthat\sthose\sregistered\swith\sxCreateTokenizer()\swork\swith\sxFindTokenizer_v2(). +D 2024-08-09T20:59:50.030 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -102,7 +102,7 @@ F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 79b1d6099d8140afbd930a4e280759728099f584f91e39a8e81f2df0a0e0e839 F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 -F ext/fts5/fts5_tcl.c 93b705cb87633574983161edc5234f9b91ba03f9fecfbd2c5d401a1da6f93aa5 +F ext/fts5/fts5_tcl.c 20bb08b43f6eeff34f12ba25988f46e3a2500bc441e9885a509d5f3932bc1cdb F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be @@ -232,6 +232,7 @@ F ext/fts5/test/fts5tok1.test 1f7817499f5971450d8c4a652114b3d833393c8134e32422d0 F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test 7937cec672b148223fff8746d21d3e7ed0965fd7caf35ccdc888a005bb452f98 F ext/fts5/test/fts5tokenizer2.test 9c1ad8ef0465076cbc9ff5c764782594329b3bce3e0f6a931a026902d006f495 +F ext/fts5/test/fts5tokenizer3.test eea778f7bb7024c3e904e28915f9d53286141671b138722148be22a9c758bdc3 F ext/fts5/test/fts5trigram.test 6c4e37864f3e7d90673db5563d9736d7e40080ab94d10ebdffa94c1b77941da0 F ext/fts5/test/fts5trigram2.test c91f0a94f7e1ff859682228646abeab4c0eba2effc46af2cbc8f0f48b05a0566 F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 @@ -2201,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e8a61d5c48073fdd4d99d0b6fc70469b37af009f281336a44e3789e7eeed820d -R 1b40b0a91a44b0bf6782847dce5b9e1d +P c98ccc12169419b8b27ead89ef0665de40320277c5daa748b80869337419e43e +R bfbea59aa50b425cf741e16058f3ea26 U dan -Z 06efbaab9999ac759a0d226937b631dd +Z 43db44ab1958e51c418293959d627cfb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 09bba22cd4..f82f7047f7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c98ccc12169419b8b27ead89ef0665de40320277c5daa748b80869337419e43e +a3ef7d47b582a66a85ebe802ab40114f77289d6b44a4b375ea7858c60f59b27f From 555aaa432c8845ef379b58ce9284c956d565ec40 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 9 Aug 2024 22:48:11 +0000 Subject: [PATCH 0642/1030] Fix a few minor TCL9 compatibilities issues. FossilOrigin-Name: 69eed19914ef52bc0101f4ae1c7b242df4ee28675b3581e1f4d60a35494f9f76 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test1.c | 14 +++++++------- src/test_tclvar.c | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index ea58ba7fcd..a4248c360b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\sinstance\swhere\sALTER\sTABLE\swas\sreturning\sSQLITE_INTERNAL\sinstead\nof\sSQLITE_ERROR\sone\smalformed\sinput. -D 2024-08-09T18:42:01.488 +C Fix\sa\sfew\sminor\sTCL9\scompatibilities\sissues. +D 2024-08-09T22:48:11.754 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -771,7 +771,7 @@ F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c c6888598f08dee3d9112a38ef42c8f5c89ca7f3190f4694744d0b84250f4bf8c F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 -F src/test1.c 51159784f29d3dfd4b50fd6ed9c43c8f7f36925c501a3ad3083528e5e5544bd7 +F src/test1.c be8cc208c0d50b3a7e570049e55f25ae40c1dfec8165b7ce12c2c8ed9f5b3030 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d @@ -813,7 +813,7 @@ F src/test_sqllog.c 540feaea7280cd5f926168aee9deb1065ae136d0bbbe7361e2ef3541783e F src/test_superlock.c 18355ca274746aa6909e3744163e5deb1196a85d5bc64b9cd377273cef626da7 F src/test_syscall.c 9ad7ab39910c16d29411678d91b0d27a7a996a718df5ee93dcd635e846d0275c F src/test_tclsh.c 6077f2bdc6b4ea2bace2a0cd6ea48e0a4651007ae7382c13efc0c495eb0c6956 -F src/test_tclvar.c 2c42fe9a74af0f3c8f87a339f66d9d3bd3a967fb5db1ed2500348055b954e391 +F src/test_tclvar.c ae873248a0188459b1c16ca7cc431265dacce524399e8b46725c2b3b7e048424 F src/test_thread.c d7a8bcea7445f37cc2a1f7f81dd6059634f45e0c61bfe80182b02872fb0328bb F src/test_vdbecov.c 5c426d9cd2b351f5f9ceb30cabf8c64a63bfcad644c507e0bd9ce2f6ae1a3bf3 F src/test_vfs.c f298475e468c7e14945b20af885917181090c265aa3c4ade897849c9fbd396f2 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9052187efd1f78abd9b285ac94269a3ba4d65b6aa74c9fa34002ee0628c83919 -R cfcbe2c3b80f7c18c681a7771600d22b +P b416756320dfb46ad72b843a7fbf18807d3fd1966251c320de626280b5238a5c +R 3713bfe5df240ec97ce0810792e582f6 U drh -Z 27325e8a3b0694b1cf9e0c044251f29f +Z 6bb203e3c3683b4f2854978314b46998 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index eda87af4fe..5c8d9489dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b416756320dfb46ad72b843a7fbf18807d3fd1966251c320de626280b5238a5c +69eed19914ef52bc0101f4ae1c7b242df4ee28675b3581e1f4d60a35494f9f76 diff --git a/src/test1.c b/src/test1.c index 88bfdc06d2..9def739f4c 100644 --- a/src/test1.c +++ b/src/test1.c @@ -8324,7 +8324,7 @@ static int SQLITE_TCLAPI sorter_test_sort4_helper( for(iStep=0; iStepi2++; Tcl_ListObjLength(0, pCur->pList2, &n); - if( pCur->i2>=(int)n ){ + if( pCur->i2>=n ){ Tcl_DecrRefCount(pCur->pList2); pCur->pList2 = 0; pCur->i2 = 0; @@ -170,7 +170,7 @@ static int tclvarNext(sqlite3_vtab_cursor *cur){ Tcl_Interp *interp = ((tclvar_vtab *)(cur->pVtab))->interp; Tcl_ListObjLength(0, pCur->pList1, &n); - while( !ok && pCur->i1<(int)n ){ + while( !ok && pCur->i1pList1, pCur->i1, &pObj); ok = next2(interp, pCur, pObj); if( !ok ){ From 4098aa5d198e891e10a7de57abdf3c34c22633d2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 10 Aug 2024 09:56:36 +0000 Subject: [PATCH 0643/1030] Add an assert() to fix a harmless compiler warning in the recovery extension. FossilOrigin-Name: 2502339339f3c831966479a400c2b1a531fb4d990b1776b4dc4870cf734c3fcd --- ext/recover/dbdata.c | 1 + manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ext/recover/dbdata.c b/ext/recover/dbdata.c index 109aeef2d6..001840b17e 100644 --- a/ext/recover/dbdata.c +++ b/ext/recover/dbdata.c @@ -679,6 +679,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ ** near the end of a corrupt record. */ rc = dbdataBufferSize(&pCsr->rec, nPayload+DBDATA_PADDING_BYTES); if( rc!=SQLITE_OK ) return rc; + assert( pCsr->rec.aBuf!=0 ); assert( nPayload!=0 ); /* Load the nLocal bytes of payload */ diff --git a/manifest b/manifest index a4248c360b..6a5cc4cb81 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfew\sminor\sTCL9\scompatibilities\sissues. -D 2024-08-09T22:48:11.754 +C Add\san\sassert()\sto\sfix\sa\sharmless\scompiler\swarning\sin\sthe\srecovery\nextension. +D 2024-08-10T09:56:36.016 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -481,7 +481,7 @@ F ext/rbu/rbuvacuum4.test ffccd22f67e2d0b380d2889685742159dfe0d19a3880ca3d2d1d69 F ext/rbu/sqlite3rbu.c 4a3376c0fb9a844a799ac529fb81260523f6b13c9f629bc270c632dbae5fc1f8 F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304 F ext/rbu/test_rbu.c b9727c3394307d058e806c1da0f8bb7b24daf3c6bb94cb10cca88ea4d5c806c0 -F ext/recover/dbdata.c a22ecd689f00ff2ad33b5633c4ef84c8f088c65faeac18d4eb73c128395c7aec +F ext/recover/dbdata.c 5295f4f922b60d7035b6b9fd5846b13071b9d97ed7fad8496837bb7640d24771 F ext/recover/recover1.test e16d78e94183562abff569967b18b7c77451d7044365516cd0fe14713a284851 F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a F ext/recover/recoverbuild.test c74170e0f7b02456af41838afeb5353fdb985a48cc2331d661bbabbca7c6b8e3 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b416756320dfb46ad72b843a7fbf18807d3fd1966251c320de626280b5238a5c -R 3713bfe5df240ec97ce0810792e582f6 +P 69eed19914ef52bc0101f4ae1c7b242df4ee28675b3581e1f4d60a35494f9f76 +R 1a957c9b84a4c71fe646dcbf28d160e3 U drh -Z 6bb203e3c3683b4f2854978314b46998 +Z fb95dff972d2b07ca88b4d892cd693f5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5c8d9489dc..9adeda1d93 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69eed19914ef52bc0101f4ae1c7b242df4ee28675b3581e1f4d60a35494f9f76 +2502339339f3c831966479a400c2b1a531fb4d990b1776b4dc4870cf734c3fcd From 6010980914207275bcc82e58e534d2923667f631 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 10 Aug 2024 14:53:21 +0000 Subject: [PATCH 0644/1030] Fix behavior change in the offset() SQL function introduced by check-in [f0b671183f44d0ae]. FossilOrigin-Name: c2ac17f183082d6388336338b8d5c0b334095e5f77a27bc08419431f37471d22 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/where.c | 20 +++++++++----------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 8f752559c5..6396d44aca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\scovering-index\sprediction.\s\sIn\sparticular,\savoid\sthe\nfalse-positive\sprediction\sdescribed\sby\n[forum:/forumpost/e60e4c295d22f8ce|forum\spost\se60e4c295d22f8ce].\nAdd\searly\sdetection\sof\sover-prediction\sof\scovering-indexes\sso\sthat\nsqlite3_prepare()\swill\sreturn\san\serror\srather\sthan\sjust\sgenerate\sbad\nbytecode. -D 2024-08-10T10:05:22.244 +C Fix\sbehavior\schange\sin\sthe\soffset()\sSQL\sfunction\sintroduced\sby\s\ncheck-in\s[f0b671183f44d0ae]. +D 2024-08-10T14:53:21.552 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -846,7 +846,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 5fa17ec4e344e57cf43dd7b2977c95a518bfc2d43edb42df0cd1d5c2b42cee04 +F src/where.c 3556ef464ac78f4730f40c085aa0b6729ffe44306c0daaaffe9370c981a66d1d F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -2204,9 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2502339339f3c831966479a400c2b1a531fb4d990b1776b4dc4870cf734c3fcd 1de3e5883613ff6093203720f3cdcf6b3a3e626c99735284fae95a438e1ce24f -R aaaa5a801913afe54fe71ced56170454 -T +closed 1de3e5883613ff6093203720f3cdcf6b3a3e626c99735284fae95a438e1ce24f +P f0b671183f44d0ae294956e7651a1653f47bd6219f9636872d15993f30f28dfb +R df8366cfe7188a7576fdab4cc318948f U drh -Z ad30efef8eafa3ff536c4ae2785bb388 +Z 7afdd89a9e0f36ed074dbb50e50b24a5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e7d37495c7..dd5d8ea8dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0b671183f44d0ae294956e7651a1653f47bd6219f9636872d15993f30f28dfb +c2ac17f183082d6388336338b8d5c0b334095e5f77a27bc08419431f37471d22 diff --git a/src/where.c b/src/where.c index 15f5fe7d96..98e9f117f9 100644 --- a/src/where.c +++ b/src/where.c @@ -7358,20 +7358,18 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ assert( pIdx->pTable==pTab ); #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC if( pOp->opcode==OP_Offset ){ - x = 0; + /* Do not need to translate the column number */ }else #endif - { - if( !HasRowid(pTab) ){ - Index *pPk = sqlite3PrimaryKeyIndex(pTab); - x = pPk->aiColumn[x]; - assert( x>=0 ); - }else{ - testcase( x!=sqlite3StorageColumnToTable(pTab,x) ); - x = sqlite3StorageColumnToTable(pTab,x); - } - x = sqlite3TableColumnToIndex(pIdx, x); + if( !HasRowid(pTab) ){ + Index *pPk = sqlite3PrimaryKeyIndex(pTab); + x = pPk->aiColumn[x]; + assert( x>=0 ); + }else{ + testcase( x!=sqlite3StorageColumnToTable(pTab,x) ); + x = sqlite3StorageColumnToTable(pTab,x); } + x = sqlite3TableColumnToIndex(pIdx, x); if( x>=0 ){ pOp->p2 = x; pOp->p1 = pLevel->iIdxCur; From 4a9a5cbbe93611bec814eac20ffacee3bc352220 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 10 Aug 2024 15:05:22 +0000 Subject: [PATCH 0645/1030] Fix harmless compiler warning related to the TCL8-to-TCL9 transition. This change in testing code only and is not relevante to the core SQLite. FossilOrigin-Name: c86ef65545485eae6aca23b4582e8115d4edfdd6084afa77858e11b21aa270f6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test_hexio.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6396d44aca..c9a5d32dfa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sbehavior\schange\sin\sthe\soffset()\sSQL\sfunction\sintroduced\sby\s\ncheck-in\s[f0b671183f44d0ae]. -D 2024-08-10T14:53:21.552 +C Fix\sharmless\scompiler\swarning\srelated\sto\sthe\sTCL8-to-TCL9\stransition.\s\sThis\nchange\sin\stesting\scode\sonly\sand\sis\snot\srelevante\sto\sthe\score\sSQLite. +D 2024-08-10T15:05:22.550 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -791,7 +791,7 @@ F src/test_demovfs.c 3efa2adf4f21e10d95521721687d5ca047aea91fa62dd8cc22ac9e5a9c9 F src/test_devsym.c 649434ed34d0b03fbd5a6b42df80f0f9a7e53f94dd1710aad5dd8831e91c4e86 F src/test_fs.c c411c40baba679536fc34e2679349f59d8225570aed3488b5b3ef1908525a3d5 F src/test_func.c 8c0e89192f70fac307822d1ac2911ee51751288780b3db0c5ab5ca75fa0fe851 -F src/test_hexio.c af6db9300edd2d7b786a2d40d64177cad4b8ee22085e8ca5fe812cdeffdb6502 +F src/test_hexio.c 0f777bf9fbb2684bb4978372bacc90ef7337d5d9e3cebe067a9409941e88bacf F src/test_init.c 17313332d58e90defc527129d5eda4a08bd6b6e8de7207a231523c8d98fb445e F src/test_intarray.c e4216aadee9df2de7d1aee7e70f6b22c80ee79ece72a63d57105db74217639e5 F src/test_intarray.h 6c3534641108cd1bea517a8e117dcba237081310a29a4c35bd2190caa8972293 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f0b671183f44d0ae294956e7651a1653f47bd6219f9636872d15993f30f28dfb -R df8366cfe7188a7576fdab4cc318948f +P c2ac17f183082d6388336338b8d5c0b334095e5f77a27bc08419431f37471d22 +R cab61c0a74c96f8f1dca2569723fe61f U drh -Z 7afdd89a9e0f36ed074dbb50e50b24a5 +Z e34acd82ee8d24fbce707e518d148a3f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dd5d8ea8dd..46703a088f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c2ac17f183082d6388336338b8d5c0b334095e5f77a27bc08419431f37471d22 +c86ef65545485eae6aca23b4582e8115d4edfdd6084afa77858e11b21aa270f6 diff --git a/src/test_hexio.c b/src/test_hexio.c index 8999d84d27..3c856b3306 100644 --- a/src/test_hexio.c +++ b/src/test_hexio.c @@ -401,7 +401,7 @@ static int SQLITE_TCLAPI make_fts3record( } for(i=0; i<(int)nArg; i++){ - sqlite3_int64 iVal; + Tcl_WideInt iVal; if( TCL_OK==Tcl_GetWideIntFromObj(0, aArg[i], &iVal) ){ if( nOut+10>nAlloc ){ int nNew = nAlloc?nAlloc*2:128; From 5af9fd53f420e0b73796bc30935586eb55af5dca Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 10 Aug 2024 15:46:57 +0000 Subject: [PATCH 0646/1030] Revision to check-in [d9f726ade6b258f8] so that OOM and other unrelated failures are not overridden by a syntax error in the tokenizer spec. FossilOrigin-Name: 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef --- ext/fts5/fts5_tokenize.c | 6 +++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index 08de0d60d7..9f5cd24c3c 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -90,7 +90,7 @@ static int fts5AsciiCreate( rc = SQLITE_ERROR; } } - if( iiFoldParam!=0 && pNew->bFold==0 ){ rc = SQLITE_ERROR; diff --git a/manifest b/manifest index c9a5d32dfa..8e63952a76 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning\srelated\sto\sthe\sTCL8-to-TCL9\stransition.\s\sThis\nchange\sin\stesting\scode\sonly\sand\sis\snot\srelevante\sto\sthe\score\sSQLite. -D 2024-08-10T15:05:22.550 +C Revision\sto\scheck-in\s[d9f726ade6b258f8]\sso\sthat\sOOM\sand\sother\sunrelated\sfailures\nare\snot\soverridden\sby\sa\ssyntax\serror\sin\sthe\stokenizer\sspec. +D 2024-08-10T15:46:57.398 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -105,7 +105,7 @@ F ext/fts5/fts5_storage.c 1d7e08d4331da2f3f7e78e70eef2ed6a013d91ba16175c651adbc5 F ext/fts5/fts5_tcl.c 5ca3e3e35010d326f5b821a563e4fcde3913e052935f5c2c72c264122a26b48f F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b -F ext/fts5/fts5_tokenize.c b1c3dc4de28f2532d9ee7be7182a96f943fa09fcc31c6f271d69dce72874ff8c +F ext/fts5/fts5_tokenize.c 63ebe9057ed3f4dfc49944bc4aee3d3b745cc2faff73bc152ed3554ed3bf9cf4 F ext/fts5/fts5_unicode2.c eca63dbc797f8ff0572e97caf4631389c0ab900d6364861b915bdd4735973f00 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c2ac17f183082d6388336338b8d5c0b334095e5f77a27bc08419431f37471d22 -R cab61c0a74c96f8f1dca2569723fe61f +P c86ef65545485eae6aca23b4582e8115d4edfdd6084afa77858e11b21aa270f6 +R ebd14146d6fe15d97f2e7243900bc453 U drh -Z e34acd82ee8d24fbce707e518d148a3f +Z fd712f59ba7388bc8eea12ab1bbe8630 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 46703a088f..ee6795d147 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c86ef65545485eae6aca23b4582e8115d4edfdd6084afa77858e11b21aa270f6 +3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef From ff6ab9dd2b8437f98b19d8abd7219ca054546735 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 10 Aug 2024 18:59:36 +0000 Subject: [PATCH 0647/1030] Update the fts5_tokenizer_v2 API so that the locale is passed as parameter to xTokenize(), instead of via a separate call to xSetLocale(). FossilOrigin-Name: 03e63ed24e7a08817341e59b075ae2d4e3f7a5e5b37e0e6138359d5fd29a5e9e --- ext/fts5/fts5.h | 3 +- ext/fts5/fts5Int.h | 5 +- ext/fts5/fts5_config.c | 18 +++- ext/fts5/fts5_expr.c | 4 +- ext/fts5/fts5_main.c | 215 ++++++++++++++++++++++++++++++++--------- ext/fts5/fts5_tcl.c | 27 +++++- manifest | 22 ++--- manifest.uuid | 2 +- 8 files changed, 227 insertions(+), 69 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 2f6c387760..f87b03a5c7 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -627,6 +627,7 @@ struct fts5_tokenizer_v2 { void *pCtx, int flags, /* Mask of FTS5_TOKENIZE_* flags */ const char *pText, int nText, + const char *pLocale, int nLocale, int (*xToken)( void *pCtx, /* Copy of 2nd argument to xTokenize() */ int tflags, /* Mask of FTS5_TOKEN_* flags */ @@ -636,8 +637,6 @@ struct fts5_tokenizer_v2 { int iEnd /* Byte offset of end of token within input text */ ) ); - - int (*xSetLocale)(Fts5Tokenizer*, const char *pLocale, int nLocale); }; /* diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 5f10d5773e..9ed15fb3ac 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -162,10 +162,13 @@ typedef struct Fts5TokenizerConfig Fts5TokenizerConfig; struct Fts5TokenizerConfig { Fts5Tokenizer *pTok; - fts5_tokenizer_v2 *pTokApi; + fts5_tokenizer_v2 *pApi2; + fts5_tokenizer *pApi1; const char **azArg; int nArg; int ePattern; /* FTS_PATTERN_XXX constant */ + const char *pLocale; /* Current locale to use */ + int nLocale; }; /* diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 0d86d81622..b11193ec23 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -679,7 +679,11 @@ void sqlite3Fts5ConfigFree(Fts5Config *pConfig){ if( pConfig ){ int i; if( pConfig->t.pTok ){ - pConfig->t.pTokApi->xDelete(pConfig->t.pTok); + if( pConfig->t.pApi1 ){ + pConfig->t.pApi1->xDelete(pConfig->t.pTok); + }else{ + pConfig->t.pApi2->xDelete(pConfig->t.pTok); + } } sqlite3_free((char*)pConfig->t.azArg); sqlite3_free(pConfig->zDb); @@ -762,9 +766,15 @@ int sqlite3Fts5Tokenize( rc = sqlite3Fts5LoadTokenizer(pConfig); } if( rc==SQLITE_OK ){ - rc = pConfig->t.pTokApi->xTokenize( - pConfig->t.pTok, pCtx, flags, pText, nText, xToken - ); + if( pConfig->t.pApi1 ){ + rc = pConfig->t.pApi1->xTokenize( + pConfig->t.pTok, pCtx, flags, pText, nText, xToken + ); + }else{ + rc = pConfig->t.pApi2->xTokenize(pConfig->t.pTok, pCtx, flags, + pText, nText, pConfig->t.pLocale, pConfig->t.nLocale, xToken + ); + } } } return rc; diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 732d4cf893..6a83f63224 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -3084,8 +3084,8 @@ int sqlite3Fts5ExprPopulatePoslists( } } - return sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb + return sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, z, n, + (void*)&sCtx, fts5ExprPopulatePoslistsCb ); } diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 6f2e8de88c..9707d21317 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -103,11 +103,25 @@ struct Fts5Auxiliary { ** Each tokenizer module registered with the FTS5 module is represented ** by an object of the following type. All such objects are stored as part ** of the Fts5Global.pTok list. +** +** bV2Native: +** True if the tokenizer was registered using xCreateTokenizer_v2(), false +** for xCreateTokenizer(). If this variable is true, then x2 is populated +** with the routines as supplied by the caller and x1 contains synthesized +** wrapper routines. In this case the user-data pointer passed to +** x1.xCreate should be a pointer to the Fts5TokenizerModule structure, +** not a copy of pUserData. +** +** Of course, if bV2Native is false, then x1 contains the real routines and +** x2 the synthesized ones. In this case a pointer to the Fts5TokenizerModule +** object should be passed to x2.xCreate. */ struct Fts5TokenizerModule { char *zName; /* Name of tokenizer */ void *pUserData; /* User pointer passed to xCreate() */ - fts5_tokenizer_v2 x; /* Tokenizer functions */ + int bV2Native; /* True if v2 native tokenizer */ + fts5_tokenizer x1; /* Tokenizer functions */ + fts5_tokenizer_v2 x2; /* Tokenizer functions */ void (*xDestroy)(void*); /* Destructor function */ Fts5TokenizerModule *pNext; /* Next registered tokenizer module */ }; @@ -1254,11 +1268,10 @@ static int fts5SetLocale( const char *zLocale, int nLocale ){ - Fts5TokenizerConfig *pT = &pConfig->t; int rc = SQLITE_OK; - if( pT->pTokApi->xSetLocale ){ - rc = pT->pTokApi->xSetLocale(pT->pTok, zLocale, nLocale); - } + Fts5TokenizerConfig *pT = &pConfig->t; + pT->pLocale = zLocale; + pT->nLocale = nLocale; return rc; } @@ -3177,6 +3190,105 @@ static int fts5CreateAux( return rc; } +static int fts5NewTokenizerModule( + Fts5Global *pGlobal, /* Global context (one per db handle) */ + const char *zName, /* Name of new function */ + void *pUserData, /* User data for aux. function */ + void(*xDestroy)(void*), /* Destructor for pUserData */ + Fts5TokenizerModule **ppNew +){ + int rc = SQLITE_OK; + Fts5TokenizerModule *pNew; + sqlite3_int64 nName; /* Size of zName and its \0 terminator */ + sqlite3_int64 nByte; /* Bytes of space to allocate */ + + nName = strlen(zName) + 1; + nByte = sizeof(Fts5TokenizerModule) + nName; + *ppNew = pNew = (Fts5TokenizerModule*)sqlite3Fts5MallocZero(&rc, nByte); + if( pNew ){ + pNew->zName = (char*)&pNew[1]; + memcpy(pNew->zName, zName, nName); + pNew->pUserData = pUserData; + pNew->xDestroy = xDestroy; + pNew->pNext = pGlobal->pTok; + pGlobal->pTok = pNew; + if( pNew->pNext==0 ){ + pGlobal->pDfltTok = pNew; + } + } + + return rc; +} + +typedef struct Fts5VtoVTokenizer Fts5VtoVTokenizer; +struct Fts5VtoVTokenizer { + Fts5TokenizerModule *pMod; + Fts5Tokenizer *pReal; +}; + +static int fts5VtoVCreate( + void *pCtx, + const char **azArg, + int nArg, + Fts5Tokenizer **ppOut +){ + Fts5TokenizerModule *pMod = (Fts5TokenizerModule*)pCtx; + Fts5VtoVTokenizer *pNew = 0; + int rc = SQLITE_OK; + + pNew = (Fts5VtoVTokenizer*)sqlite3Fts5MallocZero(&rc, sizeof(*pNew)); + if( rc==SQLITE_OK ){ + pNew->pMod = pMod; + if( pMod->bV2Native ){ + rc = pMod->x2.xCreate(pMod->pUserData, azArg, nArg, &pNew->pReal); + }else{ + rc = pMod->x1.xCreate(pMod->pUserData, azArg, nArg, &pNew->pReal); + } + if( rc!=SQLITE_OK ){ + sqlite3_free(pNew); + pNew = 0; + } + } + + *ppOut = (Fts5Tokenizer*)pNew; + return rc; +} +static void fts5VtoVDelete(Fts5Tokenizer *pTok){ + Fts5VtoVTokenizer *p = (Fts5VtoVTokenizer*)pTok; + if( p ){ + Fts5TokenizerModule *pMod = p->pMod; + if( pMod->bV2Native ){ + pMod->x2.xDelete(p->pReal); + }else{ + pMod->x1.xDelete(p->pReal); + } + sqlite3_free(p); + } +} +static int fts5V1toV2Tokenize( + Fts5Tokenizer *pTok, + void *pCtx, int flags, + const char *pText, int nText, + int (*xToken)(void*, int, const char*, int, int, int) +){ + Fts5VtoVTokenizer *p = (Fts5VtoVTokenizer*)pTok; + Fts5TokenizerModule *pMod = p->pMod; + assert( pMod->bV2Native ); + return pMod->x2.xTokenize(p->pReal, pCtx, flags, pText, nText, 0, 0, xToken); +} +static int fts5V2toV1Tokenize( + Fts5Tokenizer *pTok, + void *pCtx, int flags, + const char *pText, int nText, + const char *pLocale, int nLocale, + int (*xToken)(void*, int, const char*, int, int, int) +){ + Fts5VtoVTokenizer *p = (Fts5VtoVTokenizer*)pTok; + Fts5TokenizerModule *pMod = p->pMod; + assert( pMod->bV2Native==0 ); + return pMod->x1.xTokenize(p->pReal, pCtx, flags, pText, nText, xToken); +} + /* ** Register a new tokenizer. This is the implementation of the ** fts5_api.xCreateTokenizer_v2() method. @@ -3194,24 +3306,14 @@ static int fts5CreateTokenizer_v2( if( pTokenizer->iVersion>2 ){ rc = SQLITE_ERROR; }else{ - Fts5TokenizerModule *pNew; - sqlite3_int64 nName; /* Size of zName and its \0 terminator */ - sqlite3_int64 nByte; /* Bytes of space to allocate */ - - nName = strlen(zName) + 1; - nByte = sizeof(Fts5TokenizerModule) + nName; - pNew = (Fts5TokenizerModule*)sqlite3Fts5MallocZero(&rc, nByte); + Fts5TokenizerModule *pNew = 0; + rc = fts5NewTokenizerModule(pGlobal, zName, pUserData, xDestroy, &pNew); if( pNew ){ - pNew->zName = (char*)&pNew[1]; - memcpy(pNew->zName, zName, nName); - pNew->pUserData = pUserData; - pNew->x = *pTokenizer; - pNew->xDestroy = xDestroy; - pNew->pNext = pGlobal->pTok; - pGlobal->pTok = pNew; - if( pNew->pNext==0 ){ - pGlobal->pDfltTok = pNew; - } + pNew->x2 = *pTokenizer; + pNew->bV2Native = 1; + pNew->x1.xCreate = fts5VtoVCreate; + pNew->x1.xTokenize = fts5V1toV2Tokenize; + pNew->x1.xDelete = fts5VtoVDelete; } } @@ -3228,15 +3330,19 @@ static int fts5CreateTokenizer( fts5_tokenizer *pTokenizer, /* Tokenizer implementation */ void(*xDestroy)(void*) /* Destructor for pUserData */ ){ - fts5_tokenizer_v2 tok; - - memset(&tok, 0, sizeof(tok)); - tok.iVersion = 2; - tok.xCreate = pTokenizer->xCreate; - tok.xTokenize = pTokenizer->xTokenize; - tok.xDelete = pTokenizer->xDelete; + Fts5TokenizerModule *pNew = 0; + int rc = SQLITE_OK; - return fts5CreateTokenizer_v2(pApi, zName, pUserData, &tok, xDestroy); + rc = fts5NewTokenizerModule( + (Fts5Global*)pApi, zName, pUserData, xDestroy, &pNew + ); + if( pNew ){ + pNew->x1 = *pTokenizer; + pNew->x2.xCreate = fts5VtoVCreate; + pNew->x2.xTokenize = fts5V2toV1Tokenize; + pNew->x2.xDelete = fts5VtoVDelete; + } + return rc; } static Fts5TokenizerModule *fts5LocateTokenizer( @@ -3271,8 +3377,12 @@ static int fts5FindTokenizer_v2( pMod = fts5LocateTokenizer((Fts5Global*)pApi, zName); if( pMod ){ - *ppTokenizer = &pMod->x; - *ppUserData = pMod->pUserData; + if( pMod->bV2Native ){ + *ppUserData = pMod->pUserData; + }else{ + *ppUserData = (void*)pMod; + } + *ppTokenizer = &pMod->x2; }else{ *ppTokenizer = 0; *ppUserData = 0; @@ -3292,14 +3402,21 @@ static int fts5FindTokenizer( void **ppUserData, fts5_tokenizer *pTokenizer /* Populate this object */ ){ - fts5_tokenizer_v2 *pV2 = 0; int rc = SQLITE_OK; + Fts5TokenizerModule *pMod; - rc = fts5FindTokenizer_v2(pApi, zName, ppUserData, &pV2); - if( rc==SQLITE_OK ){ - pTokenizer->xCreate = pV2->xCreate; - pTokenizer->xDelete = pV2->xDelete; - pTokenizer->xTokenize = pV2->xTokenize; + pMod = fts5LocateTokenizer((Fts5Global*)pApi, zName); + if( pMod ){ + if( pMod->bV2Native==0 ){ + *ppUserData = pMod->pUserData; + }else{ + *ppUserData = (void*)pMod; + } + *pTokenizer = pMod->x1; + }else{ + memset(pTokenizer, 0, sizeof(*pTokenizer)); + *ppUserData = 0; + rc = SQLITE_ERROR; } return rc; @@ -3321,23 +3438,33 @@ int fts5GetTokenizer( rc = SQLITE_ERROR; if( pzErr ) *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); }else{ - rc = pMod->x.xCreate( - pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->t.pTok + int (*xCreate)(void*, const char**, int, Fts5Tokenizer**) = 0; + if( pMod->bV2Native ){ + xCreate = pMod->x2.xCreate; + pConfig->t.pApi2 = &pMod->x2; + }else{ + pConfig->t.pApi1 = &pMod->x1; + xCreate = pMod->x1.xCreate; + } + + rc = xCreate(pMod->pUserData, + (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->t.pTok ); - pConfig->t.pTokApi = &pMod->x; + if( rc!=SQLITE_OK ){ if( pzErr && rc!=SQLITE_NOMEM ){ *pzErr = sqlite3_mprintf("error in tokenizer constructor"); } - }else{ + }else if( pMod->bV2Native==0 ){ pConfig->t.ePattern = sqlite3Fts5TokenizerPattern( - pMod->x.xCreate, pConfig->t.pTok + pMod->x1.xCreate, pConfig->t.pTok ); } } if( rc!=SQLITE_OK ){ - pConfig->t.pTokApi = 0; + pConfig->t.pApi1 = 0; + pConfig->t.pApi2 = 0; pConfig->t.pTok = 0; } diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 8b676f1325..516c8b88aa 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -1005,15 +1005,22 @@ static int f5tTokenizeCallback( return f5tTokenizerReallyTokenize(p->p, p->pCtx, p->flags, z, n, p->xToken); } -static int f5tTokenizerTokenize( +static int f5tTokenizerTokenize_v2( Fts5Tokenizer *p, void *pCtx, int flags, const char *pText, int nText, + const char *pLoc, int nLoc, int (*xToken)(void*, int, const char*, int, int, int) ){ int rc = SQLITE_OK; F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)p; + + memset(pInst->zLocale, 0, sizeof(pInst->zLocale)); + if( pLoc && nLoczLocale) ){ + memcpy(pInst->zLocale, pLoc, nLoc); + } + if( pInst->pParent ){ CallbackCtx ctx; ctx.p = p; @@ -1022,7 +1029,8 @@ static int f5tTokenizerTokenize( ctx.xToken = xToken; if( pInst->pModule->parent_v2.xTokenize ){ rc = pInst->pModule->parent_v2.xTokenize( - pInst->pParent, (void*)&ctx, flags, pText, nText, f5tTokenizeCallback + pInst->pParent, (void*)&ctx, flags, pText, nText, + pLoc, nLoc, f5tTokenizeCallback ); }else{ rc = pInst->pModule->parent.xTokenize( @@ -1032,8 +1040,19 @@ static int f5tTokenizerTokenize( }else{ rc = f5tTokenizerReallyTokenize(p, pCtx, flags, pText, nText, xToken); } + + memset(pInst->zLocale, 0, sizeof(pInst->zLocale)); return rc; } +static int f5tTokenizerTokenize( + Fts5Tokenizer *p, + void *pCtx, + int flags, + const char *pText, int nText, + int (*xToken)(void*, int, const char*, int, int, int) +){ + return f5tTokenizerTokenize_v2(p, pCtx, flags, pText, nText, 0, 0, xToken); +} /* ** sqlite3_fts5_locale @@ -1224,9 +1243,9 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( memset(&t2, 0, sizeof(t2)); t2.iVersion = 2; t2.xCreate = f5tTokenizerCreate; - t2.xTokenize = f5tTokenizerTokenize; + t2.xTokenize = f5tTokenizerTokenize_v2; t2.xDelete = f5tTokenizerDelete; - t2.xSetLocale = f5tTokenizerSetLocale; + // t2.xSetLocale = f5tTokenizerSetLocale; rc = pApi->xCreateTokenizer_v2(pApi, zName, pModCtx, &t2,f5tDelTokenizer); } } diff --git a/manifest b/manifest index a95f78f7fb..83397e4981 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\stokenizers\sregistered\swith\sxCreateTokenizer_v2()\scan\sbe\saccessed\susing\sxFindTokenizer(),\sand\sthat\sthose\sregistered\swith\sxCreateTokenizer()\swork\swith\sxFindTokenizer_v2(). -D 2024-08-09T20:59:50.030 +C Update\sthe\sfts5_tokenizer_v2\sAPI\sso\sthat\sthe\slocale\sis\spassed\sas\sparameter\sto\sxTokenize(),\sinstead\sof\svia\sa\sseparate\scall\sto\sxSetLocale(). +D 2024-08-10T18:59:36.297 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,17 +92,17 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h f5451da088d0004c4be7314e2fdb41fda16ce682ce2aa3b54b9474ebe9a013d5 -F ext/fts5/fts5Int.h 64ccc862cbf3be08103ed9435b8670017019f5bd620db4e4317936170008b2b1 +F ext/fts5/fts5.h 1bdf3cde2b00e80f62925931471b6a00da38546eed6f2d9fe6a1d5999cbe3ba6 +F ext/fts5/fts5Int.h b40bb0bd54aaa4ac4712b6c5763b2167764614aaef204dbae81638b4548bca5d F ext/fts5/fts5_aux.c 598c80fc0faabab91c833cdda99f8e36387bd907f4acb0480a19b612a4add93e F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c b7924194b5dc035d9f0bd82c74564e133ff38aaa2edf86d8a95c23c9c82ba17f -F ext/fts5/fts5_expr.c c7336d5f9ecc0e2b014d700be2bec0ea383b0e82c494a7c5c4ac622327c2bfad +F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215549a24a2a +F ext/fts5/fts5_expr.c 16fdd35ebfd9c21d799ad6c7542a36bb3d25ba5fb97bc2e1092d3d86394267b8 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 79b1d6099d8140afbd930a4e280759728099f584f91e39a8e81f2df0a0e0e839 +F ext/fts5/fts5_main.c 6248ba625b6a24c4c5f4706883aa3939b06e7f8e0266e0e8af24f5516e599879 F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 -F ext/fts5/fts5_tcl.c 20bb08b43f6eeff34f12ba25988f46e3a2500bc441e9885a509d5f3932bc1cdb +F ext/fts5/fts5_tcl.c f901f32a1be49dc76c6da63d08224e4d971657db0a0783ebc9796ef0757a57a9 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c98ccc12169419b8b27ead89ef0665de40320277c5daa748b80869337419e43e -R bfbea59aa50b425cf741e16058f3ea26 +P a3ef7d47b582a66a85ebe802ab40114f77289d6b44a4b375ea7858c60f59b27f +R c78b035ad007a6bbcb5c77edceb19899 U dan -Z 43db44ab1958e51c418293959d627cfb +Z 3bd05c86feeacf019b7ab5899d9e19c7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f82f7047f7..4c5b9b3363 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a3ef7d47b582a66a85ebe802ab40114f77289d6b44a4b375ea7858c60f59b27f +03e63ed24e7a08817341e59b075ae2d4e3f7a5e5b37e0e6138359d5fd29a5e9e From 7978910f85327807ac1f7178a97be91bdc108ceb Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 10 Aug 2024 19:18:19 +0000 Subject: [PATCH 0648/1030] Fix an uninitialized variable in fts5_tcl.c. FossilOrigin-Name: 924d3467cebd71ac8dfef8225965d71eda82ef1f0b43508af5b7ea78e2099cf3 --- ext/fts5/fts5_tcl.c | 3 +-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 516c8b88aa..1e1243a337 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -1167,7 +1167,7 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( char *zName; Tcl_Obj *pScript; F5tTokenizerModule *pMod; - int rc; + int rc = SQLITE_OK; int bV2 = 0; /* True to use _v2 API */ const char *zParent = 0; /* Name of parent tokenizer, if any */ int ii = 0; @@ -1245,7 +1245,6 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( t2.xCreate = f5tTokenizerCreate; t2.xTokenize = f5tTokenizerTokenize_v2; t2.xDelete = f5tTokenizerDelete; - // t2.xSetLocale = f5tTokenizerSetLocale; rc = pApi->xCreateTokenizer_v2(pApi, zName, pModCtx, &t2,f5tDelTokenizer); } } diff --git a/manifest b/manifest index 83397e4981..fbf7eb7280 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sfts5_tokenizer_v2\sAPI\sso\sthat\sthe\slocale\sis\spassed\sas\sparameter\sto\sxTokenize(),\sinstead\sof\svia\sa\sseparate\scall\sto\sxSetLocale(). -D 2024-08-10T18:59:36.297 +C Fix\san\suninitialized\svariable\sin\sfts5_tcl.c. +D 2024-08-10T19:18:19.197 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -102,7 +102,7 @@ F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 6248ba625b6a24c4c5f4706883aa3939b06e7f8e0266e0e8af24f5516e599879 F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 -F ext/fts5/fts5_tcl.c f901f32a1be49dc76c6da63d08224e4d971657db0a0783ebc9796ef0757a57a9 +F ext/fts5/fts5_tcl.c af5817de028f5b1210a27dd99b3592fda55f438b3053d6f84145f32fdd265533 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c fa5493075101540270f572038fc1723d44fcc97bfbf237c8530013b8a27860be @@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a3ef7d47b582a66a85ebe802ab40114f77289d6b44a4b375ea7858c60f59b27f -R c78b035ad007a6bbcb5c77edceb19899 +P 03e63ed24e7a08817341e59b075ae2d4e3f7a5e5b37e0e6138359d5fd29a5e9e +R c027b27c24a454af656d09d633573aa9 U dan -Z 3bd05c86feeacf019b7ab5899d9e19c7 +Z d725700101283648380ab327f25111bf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4c5b9b3363..f9d9639f86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -03e63ed24e7a08817341e59b075ae2d4e3f7a5e5b37e0e6138359d5fd29a5e9e +924d3467cebd71ac8dfef8225965d71eda82ef1f0b43508af5b7ea78e2099cf3 From 195ef6baca68b52b4321a5d8b780b11b25f59d8a Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 10 Aug 2024 19:57:28 +0000 Subject: [PATCH 0649/1030] Prevent the fts5 xPhraseNext() or xPhraseFirst() APIs from returning an out-of-range column number, even if the database is corrupt. FossilOrigin-Name: d4014c87ba9b011a6a04c2bf85879b668dc762ebcbbfb50a2f8a417ce594ef88 --- ext/fts5/fts5_main.c | 9 ++++++--- ext/fts5/test/fts5corrupt3.test | 13 +++++++++---- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index c6e7e346aa..c862e2f956 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2235,11 +2235,10 @@ static void *fts5ApiGetAuxdata(Fts5Context *pCtx, int bClear){ } static void fts5ApiPhraseNext( - Fts5Context *pUnused, + Fts5Context *pCtx, Fts5PhraseIter *pIter, int *piCol, int *piOff ){ - UNUSED_PARAM(pUnused); if( pIter->a>=pIter->b ){ *piCol = -1; *piOff = -1; @@ -2247,8 +2246,12 @@ static void fts5ApiPhraseNext( int iVal; pIter->a += fts5GetVarint32(pIter->a, iVal); if( iVal==1 ){ + /* Avoid returning a (*piCol) value that is too large for the table, + ** even if the position-list is corrupt. The caller might not be + ** expecting it. */ + int nCol = ((Fts5Table*)(((Fts5Cursor*)pCtx)->base.pVtab))->pConfig->nCol; pIter->a += fts5GetVarint32(pIter->a, iVal); - *piCol = iVal; + *piCol = (iVal>=nCol ? nCol-1 : iVal); *piOff = 0; pIter->a += fts5GetVarint32(pIter->a, iVal); } diff --git a/ext/fts5/test/fts5corrupt3.test b/ext/fts5/test/fts5corrupt3.test index e2a91e51ef..cfe1438eda 100644 --- a/ext/fts5/test/fts5corrupt3.test +++ b/ext/fts5/test/fts5corrupt3.test @@ -8958,7 +8958,6 @@ do_catchsql_test 61.2 { SELECT * FROM t3 ORDER BY rowid; } {/*malformed database schema*/} -breakpoint #------------------------------------------------------------------------- do_test 62.0 { sqlite3 db {} @@ -10768,6 +10767,7 @@ do_catchsql_test 73.1 { reset_db do_test 74.0 { sqlite3 db {} + sqlite3_fts5_register_matchinfo db db deserialize [decode_hexdb { | size 106496 pagesize 4096 filename x.db | page 1 offset 0 @@ -14587,14 +14587,19 @@ do_test 74.0 { | end x.db }]} {} -do_catchsql_test 74.1 { - SELECT rowid, quote(matchinfo(t1,'p�xyb Date: Mon, 12 Aug 2024 09:49:02 +0000 Subject: [PATCH 0650/1030] Resolve parameters Bind $int_N and $test_T in fuzzcheck inputs. FossilOrigin-Name: 9c10664416274df6f8da53ddd86f6356c9704ad798fd4034d2784ae433c1c056 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fuzzcheck.c | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f7516ccb90..159330c456 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sthe\sfts5\sxPhraseNext()\sor\sxPhraseFirst()\sAPIs\sfrom\sreturning\san\sout-of-range\scolumn\snumber,\seven\sif\sthe\sdatabase\sis\scorrupt. -D 2024-08-10T19:57:28.413 +C Resolve\sparameters\sBind\s$int_N\sand\s$test_T\sin\sfuzzcheck\sinputs. +D 2024-08-12T09:49:02.212 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1260,7 +1260,7 @@ F test/fuzz3.test 70ba57260364b83e964707b9d4b5625284239768ab907dd387c740c0370ce3 F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2 -F test/fuzzcheck.c dc159967609d00b0cfe619e735cbbf8482570aca85711397034b0662b6c18fc7 +F test/fuzzcheck.c 6e87c27df3d95c556870187987dff6efdc712b5cea60abedc8ab9215f471907a F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef -R e552f961f7d429a11cf017943b4b9f14 -U dan -Z 0df3f7a0f800270be689e5fef89cec38 +P d4014c87ba9b011a6a04c2bf85879b668dc762ebcbbfb50a2f8a417ce594ef88 +R 33ab7e360692d6ed2c1cd4d18565e8ac +U drh +Z 32b23835ef00f951c0107d2a77ff843c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0b2355bfab..ef73d7fbbd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d4014c87ba9b011a6a04c2bf85879b668dc762ebcbbfb50a2f8a417ce594ef88 +9c10664416274df6f8da53ddd86f6356c9704ad798fd4034d2784ae433c1c056 diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 6cae348bd6..eaeb54d872 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -1028,6 +1028,30 @@ static int recoverDatabase(sqlite3 *db){ } return rc; } +/* +** Special parameter binding, for testing and debugging purposes. +** +** $int_NNN -> integer value NNN +** $text_TTTT -> floating point value TTT with destructor +*/ +static void bindDebugParameters(sqlite3_stmt *pStmt){ + int nVar = sqlite3_bind_parameter_count(pStmt); + int i; + for(i=0; i=4 ){ From 12866777738884e44d561e27f0d3e17ecae04a4e Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 12 Aug 2024 11:13:56 +0000 Subject: [PATCH 0651/1030] Update the auxiliary function API to include xTokenize_x2() instead of xSetLocale(). FossilOrigin-Name: f7d56a1f2149f0da117167db62e2c28ec337e8da3403873b64cdfc6a951e2e8e --- ext/fts5/fts5.h | 59 +++++++++++++------------------------------- ext/fts5/fts5_aux.c | 47 ++++++++++++++--------------------- ext/fts5/fts5_main.c | 53 ++++++++++++++------------------------- ext/fts5/fts5_tcl.c | 42 +++++++++---------------------- manifest | 18 +++++++------- manifest.uuid | 2 +- 6 files changed, 75 insertions(+), 146 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index f87b03a5c7..784511de26 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -327,21 +327,10 @@ struct Fts5PhraseIter { ** SQLite error code is returned. The final value of the output parameters ** is undefined in this case. ** -** xTokenizeSetLocale(pFts5, pLocale, nLocale) -** This API function is used to invoke the fts5_tokenizer_v2.xSetLocale() -** method of the fts5 table's tokenizer, in the same way as xTokenize() is -** used to invoke fts5_tokenizer_v2.xTokenize(). -** -** Parameters pLocale and nLocale may both be 0, in which case the tokenizer -** is configured to use its default locale. Otherwise, pLocale should point -** to a buffer containing the utf-8 encoded name of the locale to use. -** It does not have to be nul-terminated. nLocale must be passed the size -** of the text in bytes. The buffer indicated by pLocale must remain valid -** for the duration of any calls made to xTokenize() by the auxiliary -** function call up until the next invocation of xTokenizeSetLocale(), if -** any. -** -** SQLITE_OK is returned on success, or an SQLite error code otherwise. +** xTokenize_v2: +** Tokenize text using the tokenizer belonging to the FTS5 table. This +** API is the same as the xTokenize() API, except that it allows a tokenizer +** locale to be specified. */ struct Fts5ExtensionApi { int iVersion; /* Currently always set to 4 */ @@ -389,7 +378,12 @@ struct Fts5ExtensionApi { /* Below this point are iVersion>=4 only */ int (*xColumnLocale)(Fts5Context*, int iCol, const char **pz, int *pn); - int (*xTokenizeSetLocale)(Fts5Context*, const char *p, int n); + int (*xTokenize_v2)(Fts5Context*, + const char *pText, int nText, /* Text to tokenize */ + const char *pLoc, int nLoc, /* Locale to pass to tokenizer */ + void *pCtx, /* Context passed to xToken() */ + int (*xToken)(void*, int, const char*, int, int, int) /* Callback */ + ); }; /* @@ -482,32 +476,13 @@ struct Fts5ExtensionApi { ** may abandon the tokenization and return any error code other than ** SQLITE_OK or SQLITE_DONE. ** -** xSetLocale: -** This function is invoked by FTS5 to configure the locale to use for -** subsequent calls to xTokenize. The second argument is a pointer to -** a nul-terminated buffer containing the utf-8 encoded name of the locale -** to use. The third argument is the size of the buffer in bytes, not -** including the nul-terminator character. This function may also be -** invoked with the second and third parameters set to 0 - instructing -** the tokenizer to use its default locale. -** -** FTS5 guarantees that any buffer passed to xSetLocale() will remain -** valid until either the next call to xSetLocale() or xDelete() on the -** same tokenizer object. -** -** This function should return SQLITE_OK if successful, or an SQLite -** error code if an error occurs. If an error does occur and an error -** code is returned, execution of the current statement is abandoned -** and FTS5 returns the error code to the caller. -** -** Often, this function is not required and is never invoked. It is only -** ever invoked when processing a value that has had a locale associated -** with it using SQL function fts5_locale(). -** -** It is not necessary to supply an implementation of this method when -** registering a tokenizer. If fts5_tokenizer_v2.xSetLocale is set to NULL, -** then no attempt is made to pass locale information through to the -** tokenizer. +** If the tokenizer is registered using an fts5_tokenizer_v2 object, +** then the xTokenize() method has two additional arguments - pLocale +** and nLocale. These specify the locale that the tokenizer should use +** for the current request. If pLocale and nLocale are both 0, then the +** tokenizer should use its default locale. Otherwise, pLocale points to +** a buffer containing the name of the locale to use as utf-8 text. nLocale +** contains the number of bytes in pLocale. pLocale is not nul-terminated. ** ** SYNONYM SUPPORT ** diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c index 8695369f5e..fb177d561e 100644 --- a/ext/fts5/fts5_aux.c +++ b/ext/fts5/fts5_aux.c @@ -226,28 +226,6 @@ static int fts5HighlightCb( return rc; } -/* -** Use xTokenizeSetLocale() to configure the tokenizer to use the locale -** associated with column iCol of the current row. -*/ -static int fts5ConfigureTokenizer( - const Fts5ExtensionApi *pApi, - Fts5Context *pFts, - int iCol -){ - int rc = SQLITE_OK; - const char *zLocale = 0; - int nLocale = 0; - - assert( pApi->iVersion>=4 ); /* Ensure xColumnLocale() is available */ - - rc = pApi->xColumnLocale(pFts, iCol, &zLocale, &nLocale); - if( rc==SQLITE_OK ){ - rc = pApi->xTokenizeSetLocale(pFts, zLocale, nLocale); - } - return rc; -} - /* ** Implementation of highlight() function. @@ -279,15 +257,19 @@ static void fts5HighlightFunction( sqlite3_result_text(pCtx, "", -1, SQLITE_STATIC); rc = SQLITE_OK; }else if( ctx.zIn ){ + const char *pLoc = 0; + int nLoc = 0; if( rc==SQLITE_OK ){ rc = fts5CInstIterInit(pApi, pFts, iCol, &ctx.iter); } if( rc==SQLITE_OK ){ - rc = fts5ConfigureTokenizer(pApi, pFts, iCol); + rc = pApi->xColumnLocale(pFts, iCol, &pLoc, &nLoc); } if( rc==SQLITE_OK ){ - rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); + rc = pApi->xTokenize_v2( + pFts, ctx.zIn, ctx.nIn, pLoc, nLoc, (void*)&ctx, fts5HighlightCb + ); } if( ctx.bOpen ){ fts5HighlightAppend(&rc, &ctx, ctx.zClose, -1); @@ -484,6 +466,8 @@ static void fts5SnippetFunction( memset(&sFinder, 0, sizeof(Fts5SFinder)); for(i=0; ixColumnText(pFts, i, &sFinder.zDoc, &nDoc); if( rc!=SQLITE_OK ) break; - rc = fts5ConfigureTokenizer(pApi, pFts, i); + rc = pApi->xColumnLocale(pFts, i, &pLoc, &nLoc); if( rc!=SQLITE_OK ) break; - rc = pApi->xTokenize(pFts, - sFinder.zDoc, nDoc, (void*)&sFinder,fts5SentenceFinderCb + rc = pApi->xTokenize_v2(pFts, + sFinder.zDoc, nDoc, pLoc, nLoc, (void*)&sFinder, fts5SentenceFinderCb ); if( rc!=SQLITE_OK ) break; rc = pApi->xColumnSize(pFts, i, &nDocsize); @@ -552,6 +536,9 @@ static void fts5SnippetFunction( rc = pApi->xColumnSize(pFts, iBestCol, &nColSize); } if( ctx.zIn ){ + const char *pLoc = 0; /* Locale to tokenize in */ + int nLoc = 0; /* Bytes in pLoc */ + if( rc==SQLITE_OK ){ rc = fts5CInstIterInit(pApi, pFts, iBestCol, &ctx.iter); } @@ -570,10 +557,12 @@ static void fts5SnippetFunction( } if( rc==SQLITE_OK ){ - rc = fts5ConfigureTokenizer(pApi, pFts, iBestCol); + rc = pApi->xColumnLocale(pFts, iBestCol, &pLoc, &nLoc); } if( rc==SQLITE_OK ){ - rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); + rc = pApi->xTokenize_v2( + pFts, ctx.zIn, ctx.nIn, pLoc, nLoc, (void*)&ctx,fts5HighlightCb + ); } if( ctx.bOpen ){ fts5HighlightAppend(&rc, &ctx, ctx.zClose, -1); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 0aa80093bc..9cc7b5cbf3 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -220,10 +220,6 @@ struct Fts5Cursor { int nInstAlloc; /* Size of aInst[] array (entries / 3) */ int nInstCount; /* Number of phrase instances */ int *aInst; /* 3 integers per phrase instance */ - - /* Values set by xTokenizeSetLocale() */ - const char *pLocale; - int nLocale; }; /* @@ -2128,29 +2124,33 @@ static int fts5ApiRowCount(Fts5Context *pCtx, i64 *pnRow){ return sqlite3Fts5StorageRowCount(pTab->pStorage, pnRow); } -static int fts5ApiTokenize( +static int fts5ApiTokenize_v2( Fts5Context *pCtx, const char *pText, int nText, + const char *pLoc, int nLoc, void *pUserData, int (*xToken)(void*, int, const char*, int, int, int) ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); int rc = SQLITE_OK; - const char *pLocale = pCsr->pLocale; - if( pLocale ){ - rc = fts5SetLocale(pTab->pConfig, pLocale, pCsr->nLocale); - } - if( rc==SQLITE_OK ){ - rc = sqlite3Fts5Tokenize( - pTab->pConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken - ); - } - if( pLocale ){ - sqlite3Fts5ClearLocale(pTab->pConfig); - } + + fts5SetLocale(pTab->pConfig, pLoc, nLoc); + rc = sqlite3Fts5Tokenize(pTab->pConfig, + FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken + ); + fts5SetLocale(pTab->pConfig, 0, 0); + return rc; } +static int fts5ApiTokenize( + Fts5Context *pCtx, + const char *pText, int nText, + void *pUserData, + int (*xToken)(void*, int, const char*, int, int, int) +){ + return fts5ApiTokenize_v2(pCtx, pText, nText, 0, 0, pUserData, xToken); +} static int fts5ApiPhraseCount(Fts5Context *pCtx){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; @@ -2720,21 +2720,6 @@ static int fts5ApiColumnLocale( return rc; } -/* -** The xTokenizeSetLocale() API. -*/ -static int fts5ApiTokenizeSetLocale( - Fts5Context *pCtx, - const char *pLocale, - int nLocale -){ - int rc = SQLITE_OK; - Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; - pCsr->pLocale = pLocale; - pCsr->nLocale = nLocale; - return rc; -} - static const Fts5ExtensionApi sFts5Api = { 4, /* iVersion */ fts5ApiUserData, @@ -2759,7 +2744,7 @@ static const Fts5ExtensionApi sFts5Api = { fts5ApiQueryToken, fts5ApiInstToken, fts5ApiColumnLocale, - fts5ApiTokenizeSetLocale + fts5ApiTokenize_v2 }; /* @@ -2813,8 +2798,6 @@ static void fts5ApiInvoke( pCsr->pAux = pAux; pAux->xFunc(&sFts5Api, (Fts5Context*)pCsr, context, argc, argv); pCsr->pAux = 0; - pCsr->pLocale = 0; - pCsr->nLocale = 0; } static Fts5Cursor *fts5CursorFromCsrid(Fts5Global *pGlobal, i64 iCsrId){ diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 2fcc3815fd..60b3f0e9ef 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -825,11 +825,9 @@ struct F5tTokenizerModule { /* ** zLocale: -** Buffer zLocale contains the current locale, as configured by the most -** recent call to xSetLocale(). A NULL (default) locale is represented as -** a 0 byte string - "\0". -** -** This can be retrieved by a Tcl tokenize script using [sqlite3_fts5_locale]. +** Within a call to xTokenize_v2(), pLocale/nLocale store the locale +** passed to the call by fts5. This can be retrieved by a Tcl tokenize +** script using [sqlite3_fts5_locale]. */ struct F5tTokenizerInstance { Tcl_Interp *interp; @@ -837,27 +835,10 @@ struct F5tTokenizerInstance { F5tTokenizerModule *pModule; Fts5Tokenizer *pParent; F5tTokenizerContext *pContext; - char zLocale[128]; + const char *pLocale; + int nLocale; }; -static int f5tTokenizerSetLocale( - Fts5Tokenizer *pTokenizer, - const char *pLocale, - int nLocale -){ - F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)pTokenizer; - if( nLocale>=sizeof(pInst->zLocale) ){ - return SQLITE_ERROR; - } - - memset(pInst->zLocale, 0, sizeof(pInst->zLocale)); - if( nLocale>0 ){ - memcpy(pInst->zLocale, pLocale, nLocale); - } - - return SQLITE_OK; -} - static int f5tTokenizerCreate( void *pCtx, const char **azArg, @@ -1011,10 +992,8 @@ static int f5tTokenizerTokenize_v2( int rc = SQLITE_OK; F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)p; - memset(pInst->zLocale, 0, sizeof(pInst->zLocale)); - if( pLoc && nLoczLocale) ){ - memcpy(pInst->zLocale, pLoc, nLoc); - } + pInst->pLocale = pLoc; + pInst->nLocale = nLoc; if( pInst->pParent ){ CallbackCtx ctx; @@ -1036,7 +1015,8 @@ static int f5tTokenizerTokenize_v2( rc = f5tTokenizerReallyTokenize(p, pCtx, flags, pText, nText, xToken); } - memset(pInst->zLocale, 0, sizeof(pInst->zLocale)); + pInst->pLocale = 0; + pInst->nLocale = 0; return rc; } static int f5tTokenizerTokenize( @@ -1072,7 +1052,9 @@ static int SQLITE_TCLAPI f5tTokenizerLocale( return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewStringObj(p->pInst->zLocale, -1)); + Tcl_SetObjResult(interp, + Tcl_NewStringObj(p->pInst->pLocale, p->pInst->nLocale) + ); return TCL_OK; } diff --git a/manifest b/manifest index a8ab8d86ed..d3ebedd919 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\schanges\sinto\sthis\sbranch. -D 2024-08-10T20:03:01.148 +C Update\sthe\sauxiliary\sfunction\sAPI\sto\sinclude\sxTokenize_x2()\sinstead\sof\sxSetLocale(). +D 2024-08-12T11:13:56.109 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,17 +92,17 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h 1bdf3cde2b00e80f62925931471b6a00da38546eed6f2d9fe6a1d5999cbe3ba6 +F ext/fts5/fts5.h 7f1197009fc0e9822a8a584aa1f90591bdbf04f4503ecfe06949f3afe7a1fe06 F ext/fts5/fts5Int.h b40bb0bd54aaa4ac4712b6c5763b2167764614aaef204dbae81638b4548bca5d -F ext/fts5/fts5_aux.c 598c80fc0faabab91c833cdda99f8e36387bd907f4acb0480a19b612a4add93e +F ext/fts5/fts5_aux.c 0d0ee62dfebe93ccf6b293edb0b21ebe5c8bdc85e962a001745f2d13ea3e79d2 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215549a24a2a F ext/fts5/fts5_expr.c ee1949c5c20901cbaca0885902f1d0c136679262dee71b457a34a92e1d16ddac F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c d6afe9ddaa995d52009d6a3a06b1f4d7481610d7d34b1af6f05bcd4756f7b99a +F ext/fts5/fts5_main.c cd61abbfd02f0f22e3c124ae2ad10c2a51cdf8acf38177410d44e134c1d1364b F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 -F ext/fts5/fts5_tcl.c 7bd4bcd4557814df4fe8412edac34a309da83e90780cdf1d0b6bf5da18e127dd +F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c 63ebe9057ed3f4dfc49944bc4aee3d3b745cc2faff73bc152ed3554ed3bf9cf4 @@ -2207,8 +2207,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 924d3467cebd71ac8dfef8225965d71eda82ef1f0b43508af5b7ea78e2099cf3 d4014c87ba9b011a6a04c2bf85879b668dc762ebcbbfb50a2f8a417ce594ef88 -R f5c4cc25ad182e75985989cfb0d3dcb3 +P b243007525a825b3daf8aa9bb2d3088efb853bd8b7c9ea3c0924fde193eb5c44 +R ca9e80b1fa88da85d78ec3898ab25337 U dan -Z c7a930832d2066471c172888c15e20f1 +Z 8ccf549b58c37ea212fa9c3ab517ca5f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2a2534e013..68e7d56fa7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b243007525a825b3daf8aa9bb2d3088efb853bd8b7c9ea3c0924fde193eb5c44 +f7d56a1f2149f0da117167db62e2c28ec337e8da3403873b64cdfc6a951e2e8e From 29d5e43ad4834f011ccf87a78ad1c75ed8f2da24 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 12 Aug 2024 11:46:09 +0000 Subject: [PATCH 0652/1030] Update the porter tokenizer to use locales. FossilOrigin-Name: 3291ce3a3359a80e51e4546a3d7a187cbe4c7530fca6632f0bb2728525efe212 --- ext/fts5/fts5_tokenize.c | 33 ++++++++++++++++++++++++--------- ext/fts5/test/fts5locale.test | 23 ++++++++++++++++++++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index 9f5cd24c3c..7a36b750a1 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -556,7 +556,7 @@ static int fts5UnicodeTokenize( typedef struct PorterTokenizer PorterTokenizer; struct PorterTokenizer { - fts5_tokenizer tokenizer; /* Parent tokenizer module */ + fts5_tokenizer_v2 tokenizer_v2; /* Parent tokenizer module */ Fts5Tokenizer *pTokenizer; /* Parent tokenizer instance */ char aBuf[FTS5_PORTER_MAX_TOKEN + 64]; }; @@ -568,7 +568,7 @@ static void fts5PorterDelete(Fts5Tokenizer *pTok){ if( pTok ){ PorterTokenizer *p = (PorterTokenizer*)pTok; if( p->pTokenizer ){ - p->tokenizer.xDelete(p->pTokenizer); + p->tokenizer_v2.xDelete(p->pTokenizer); } sqlite3_free(p); } @@ -587,6 +587,7 @@ static int fts5PorterCreate( PorterTokenizer *pRet; void *pUserdata = 0; const char *zBase = "unicode61"; + fts5_tokenizer_v2 *pV2 = 0; if( nArg>0 ){ zBase = azArg[0]; @@ -595,14 +596,15 @@ static int fts5PorterCreate( pRet = (PorterTokenizer*)sqlite3_malloc(sizeof(PorterTokenizer)); if( pRet ){ memset(pRet, 0, sizeof(PorterTokenizer)); - rc = pApi->xFindTokenizer(pApi, zBase, &pUserdata, &pRet->tokenizer); + rc = pApi->xFindTokenizer_v2(pApi, zBase, &pUserdata, &pV2); }else{ rc = SQLITE_NOMEM; } if( rc==SQLITE_OK ){ int nArg2 = (nArg>0 ? nArg-1 : 0); - const char **azArg2 = (nArg2 ? &azArg[1] : 0); - rc = pRet->tokenizer.xCreate(pUserdata, azArg2, nArg2, &pRet->pTokenizer); + const char **az2 = (nArg2 ? &azArg[1] : 0); + memcpy(&pRet->tokenizer_v2, pV2, sizeof(fts5_tokenizer_v2)); + rc = pRet->tokenizer_v2.xCreate(pUserdata, az2, nArg2, &pRet->pTokenizer); } if( rc!=SQLITE_OK ){ @@ -1253,6 +1255,7 @@ static int fts5PorterTokenize( void *pCtx, int flags, const char *pText, int nText, + const char *pLoc, int nLoc, int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd) ){ PorterTokenizer *p = (PorterTokenizer*)pTokenizer; @@ -1260,8 +1263,8 @@ static int fts5PorterTokenize( sCtx.xToken = xToken; sCtx.pCtx = pCtx; sCtx.aBuf = p->aBuf; - return p->tokenizer.xTokenize( - p->pTokenizer, (void*)&sCtx, flags, pText, nText, fts5PorterCb + return p->tokenizer_v2.xTokenize( + p->pTokenizer, (void*)&sCtx, flags, pText, nText, pLoc, nLoc, fts5PorterCb ); } @@ -1450,7 +1453,6 @@ int sqlite3Fts5TokenizerInit(fts5_api *pApi){ } aBuiltin[] = { { "unicode61", {fts5UnicodeCreate, fts5UnicodeDelete, fts5UnicodeTokenize}}, { "ascii", {fts5AsciiCreate, fts5AsciiDelete, fts5AsciiTokenize }}, - { "porter", {fts5PorterCreate, fts5PorterDelete, fts5PorterTokenize }}, { "trigram", {fts5TriCreate, fts5TriDelete, fts5TriTokenize}}, }; @@ -1465,6 +1467,19 @@ int sqlite3Fts5TokenizerInit(fts5_api *pApi){ 0 ); } - + if( rc==SQLITE_OK ){ + fts5_tokenizer_v2 sPorter = { + 2, + fts5PorterCreate, + fts5PorterDelete, + fts5PorterTokenize + }; + rc = pApi->xCreateTokenizer_v2(pApi, + "porter", + (void*)pApi, + &sPorter, + 0 + ); + } return rc; } diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index 40ed28243c..2d5f2a00dc 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -350,11 +350,10 @@ do_execsql_test 6.2 { } {text text} #-------------------------------------------------------------------------- -# Test that fts5_locale() works with virtual tables. +# Test that fts5_locale() works with external-content tables. # reset_db sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create -# optimization_control db query-flattener 0 do_execsql_test 7.1 { CREATE TABLE t1(ii INTEGER PRIMARY KEY, bb BLOB, tt TEXT, locale TEXT); @@ -394,8 +393,26 @@ do_execsql_test 7.6 { {{} {}} {{} reverse} {{} second} } +#------------------------------------------------------------------------- +# Test that the porter tokenizer works with locales. +# +reset_db +sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create +do_execsql_test 8.1 { + CREATE VIRTUAL TABLE ft USING fts5(tt, locale=1, tokenize="porter tcl"); + CREATE VIRTUAL TABLE vocab USING fts5vocab('ft', instance); -finish_test + INSERT INTO ft(rowid, tt) VALUES + (111, fts5_locale('second', 'the porter tokenizer is a wrapper tokenizer')), + (222, fts5_locale('reverse', 'This value may also be set')); +} +do_execsql_test 8.1 { + SELECT DISTINCT term FROM vocab ORDER BY 1 +} { + a eb eulav osla sihT te the token yam +} + +finish_test diff --git a/manifest b/manifest index d3ebedd919..ce9f94a445 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sauxiliary\sfunction\sAPI\sto\sinclude\sxTokenize_x2()\sinstead\sof\sxSetLocale(). -D 2024-08-12T11:13:56.109 +C Update\sthe\sporter\stokenizer\sto\suse\slocales. +D 2024-08-12T11:46:09.154 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -105,7 +105,7 @@ F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b -F ext/fts5/fts5_tokenize.c 63ebe9057ed3f4dfc49944bc4aee3d3b745cc2faff73bc152ed3554ed3bf9cf4 +F ext/fts5/fts5_tokenize.c 96efa85a21a85276680ce3fb19dc5dd8d6b6541b2c37f953ee55bc15092262e1 F ext/fts5/fts5_unicode2.c eca63dbc797f8ff0572e97caf4631389c0ab900d6364861b915bdd4735973f00 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 @@ -186,7 +186,7 @@ F ext/fts5/test/fts5interrupt.test 20d04204d3e341b104c0c24a41596b6393a3a81eba104 F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 57f4effee98b8c3b8b63f80ce08cc424e68a4ef1b7ce74a91c1e64b2d213053e +F ext/fts5/test/fts5locale.test 8e893b5a764d181260f5f862dc529fcdb42315b2d683317043d4609f13f88a02 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2207,8 +2207,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b243007525a825b3daf8aa9bb2d3088efb853bd8b7c9ea3c0924fde193eb5c44 -R ca9e80b1fa88da85d78ec3898ab25337 +P f7d56a1f2149f0da117167db62e2c28ec337e8da3403873b64cdfc6a951e2e8e +R 7151af5ed6816182b47b60322cc8dcba U dan -Z 8ccf549b58c37ea212fa9c3ab517ca5f +Z a17240af0068f64d6da9a8176108962c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 68e7d56fa7..6edb67265e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f7d56a1f2149f0da117167db62e2c28ec337e8da3403873b64cdfc6a951e2e8e +3291ce3a3359a80e51e4546a3d7a187cbe4c7530fca6632f0bb2728525efe212 From 10e54e365a5f9b2a2ea4ab103f762171e733a903 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 12 Aug 2024 17:03:37 +0000 Subject: [PATCH 0653/1030] Fix further issues to do with fts5 locale support. FossilOrigin-Name: e626123580065986f7df50b6140f00048944becce179b9391fbf09f97ac55485 --- ext/fts5/fts5.h | 14 ++--- ext/fts5/fts5Int.h | 2 +- ext/fts5/fts5_aux.c | 10 ++-- ext/fts5/fts5_expr.c | 4 +- ext/fts5/fts5_main.c | 123 +++++++++++++++++++++++++++++-------------- manifest | 20 +++---- manifest.uuid | 2 +- 7 files changed, 109 insertions(+), 66 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 784511de26..dfa075f0a9 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -395,10 +395,10 @@ struct Fts5ExtensionApi { ** ** Applications may also register custom tokenizer types. A tokenizer ** is registered by providing fts5 with a populated instance of the -** following structure. Of the three structure methods, xCreate, xDelete and -** xTokenize must be supplied, any fo these three members of the -** fts5_tokenizer_v2 struct to NULL leads to undefined behaviour. The -** structure methods are expected to function as follows: +** following structure. All structure methods must be defined, setting +** +** any member of the fts5_tokenizer struct to NULL leads to undefined +** behaviour. The structure methods are expected to function as follows: ** ** xCreate: ** This function is used to allocate and initialize a tokenizer instance. @@ -481,8 +481,8 @@ struct Fts5ExtensionApi { ** and nLocale. These specify the locale that the tokenizer should use ** for the current request. If pLocale and nLocale are both 0, then the ** tokenizer should use its default locale. Otherwise, pLocale points to -** a buffer containing the name of the locale to use as utf-8 text. nLocale -** contains the number of bytes in pLocale. pLocale is not nul-terminated. +** an nLocale byte buffer containing the name of the locale to use as utf-8 +** text. pLocale is not nul-terminated. ** ** SYNONYM SUPPORT ** @@ -658,7 +658,7 @@ struct fts5_tokenizer { */ typedef struct fts5_api fts5_api; struct fts5_api { - int iVersion; /* Currently 3, was once 2 */ + int iVersion; /* Currently always set to 3 */ /* Create a new tokenizer */ int (*xCreateTokenizer)( diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 9ed15fb3ac..7e42ea82c1 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -168,7 +168,7 @@ struct Fts5TokenizerConfig { int nArg; int ePattern; /* FTS_PATTERN_XXX constant */ const char *pLocale; /* Current locale to use */ - int nLocale; + int nLocale; /* Size of pLocale in bytes */ }; /* diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c index fb177d561e..eb3f7e359d 100644 --- a/ext/fts5/fts5_aux.c +++ b/ext/fts5/fts5_aux.c @@ -257,8 +257,8 @@ static void fts5HighlightFunction( sqlite3_result_text(pCtx, "", -1, SQLITE_STATIC); rc = SQLITE_OK; }else if( ctx.zIn ){ - const char *pLoc = 0; - int nLoc = 0; + const char *pLoc = 0; /* Locale of column iCol */ + int nLoc = 0; /* Size of pLoc in bytes */ if( rc==SQLITE_OK ){ rc = fts5CInstIterInit(pApi, pFts, iCol, &ctx.iter); } @@ -466,8 +466,8 @@ static void fts5SnippetFunction( memset(&sFinder, 0, sizeof(Fts5SFinder)); for(i=0; ixColumnSize(pFts, iBestCol, &nColSize); } if( ctx.zIn ){ - const char *pLoc = 0; /* Locale to tokenize in */ + const char *pLoc = 0; /* Locale of column iBestCol */ int nLoc = 0; /* Bytes in pLoc */ if( rc==SQLITE_OK ){ diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index b1a0f48209..a39cc16bbf 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -3092,8 +3092,8 @@ int sqlite3Fts5ExprPopulatePoslists( } } - return sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, z, n, - (void*)&sCtx, fts5ExprPopulatePoslistsCb + return sqlite3Fts5Tokenize(pConfig, + FTS5_TOKENIZE_DOCUMENT, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb ); } diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 9cc7b5cbf3..b4ccd04028 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -115,13 +115,16 @@ struct Fts5Auxiliary { ** Of course, if bV2Native is false, then x1 contains the real routines and ** x2 the synthesized ones. In this case a pointer to the Fts5TokenizerModule ** object should be passed to x2.xCreate. +** +** The synthesized wrapper routines are necessary for xFindTokenizer(_v2) +** calls. */ struct Fts5TokenizerModule { char *zName; /* Name of tokenizer */ void *pUserData; /* User pointer passed to xCreate() */ int bV2Native; /* True if v2 native tokenizer */ fts5_tokenizer x1; /* Tokenizer functions */ - fts5_tokenizer_v2 x2; /* Tokenizer functions */ + fts5_tokenizer_v2 x2; /* V2 tokenizer functions */ void (*xDestroy)(void*); /* Destructor function */ Fts5TokenizerModule *pNext; /* Next registered tokenizer module */ }; @@ -179,12 +182,6 @@ struct Fts5Sorter { ** If the cursor iterates in descending order of rowid, iFirstRowid ** is the upper limit (i.e. the "first" rowid visited) and iLastRowid ** the lower. -** -** pLocale, nLocale: -** These are set by API method xTokenizeSetLocale(). xTokenizeSetLocale() -** does not actually configure the tokenizer, it just stores the values -** it is passed in these variables. The fts5_tokenizer_v2.xSetLocale() -** method is called from within the xTokenize() API method if required. */ struct Fts5Cursor { sqlite3_vtab_cursor base; /* Base class used by SQLite core */ @@ -251,7 +248,7 @@ struct Fts5Cursor { #define BitFlagTest(x,y) (((x) & (y))!=0) /* -** The subtype values returned by fts5_locale() are tagged with. +** The subtype value and header bytes used by fts5_locale(). */ #define FTS5_LOCALE_SUBTYPE ((unsigned int)'L') #define FTS5_LOCALE_HEADER "\x00\xE0\xB2\xEB" @@ -1255,24 +1252,24 @@ static void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){ } /* -** Configure the tokenizer to use the locale specified by nLocale byte -** buffer zLocale. Return SQLITE_OK if successful, or an SQLite error -** code otherwise. +** Arrange for subsequent calls to sqlite3Fts5Tokenize() to use the locale +** specified by pLocale/nLocale. The buffer indicated by pLocale must remain +** valid until after the final call to sqlite3Fts5Tokenize() that will use +** the locale. */ -static int fts5SetLocale( +static void fts5SetLocale( Fts5Config *pConfig, const char *zLocale, int nLocale ){ - int rc = SQLITE_OK; Fts5TokenizerConfig *pT = &pConfig->t; pT->pLocale = zLocale; pT->nLocale = nLocale; - return rc; } /* -** Reset the locale of the tokenizer to its default. +** Clear any locale configured by an earlier call to fts5SetLocale() or +** sqlite3Fts5ExtractText(). */ void sqlite3Fts5ClearLocale(Fts5Config *pConfig){ fts5SetLocale(pConfig, 0, 0); @@ -1293,9 +1290,20 @@ void sqlite3Fts5ClearLocale(Fts5Config *pConfig){ ** 1) Ordinary values. The text can be extracted from these using ** sqlite3_value_text(). ** -** 2) Blobs tagged with sub-type FTS5_LOCALE_SUBTYPE, or those read from -** the content table of a normal content or external-conten table -** with locale=1 set. +** 2) Combination text/locale blobs created by fts5_locale(). There +** are several cases for these: +** +** * Blobs tagged with FTS5_LOCALE_SUBTYPE. +** * Blobs read from the content table of a locale=1 external-content +** table, and +** * Blobs read from the content table of a locale=1 regular +** content table. +** +** The first two cases above should have the 4 byte FTS5_LOCALE_HEADER +** header. It is an error if a blob with the subtype or a blob read +** from the content table of an external content table does not have +** the required header. A blob read from the content table of a regular +** locale=1 table does not have the header. This is to save space. ** ** If successful, SQLITE_OK is returned and output parameters (*ppText) ** and (*pnText) are set to point to a buffer containing the extracted utf-8 @@ -1306,11 +1314,11 @@ void sqlite3Fts5ClearLocale(Fts5Config *pConfig){ ** Parameter bContent must be true if the value was read from an indexed ** column (i.e. not UNINDEXED) of the on disk content. ** -** If pbResetTokenizer is not NULL and if case (2) is used, then the -** tokenizer is configured to use the locale. In this case (*pbResetTokenizer) -** is set to true before returning, to indicate that the caller must -** call sqlite3Fts5ClearLocale() to reset the tokenizer after tokenizing -** the text. +** If pbResetTokenizer is not NULL and if case (2) is used, then +** fts5SetLocale() is called to ensure subsequent sqlite3Fts5Tokenize() calls +** use the locale. In this case (*pbResetTokenizer) is set to true before +** returning, to indicate that the caller must call sqlite3Fts5ClearLocale() +** to clear the locale after tokenizing the text. */ int sqlite3Fts5ExtractText( Fts5Config *pConfig, @@ -1367,7 +1375,7 @@ int sqlite3Fts5ExtractText( nText = nBlob-nLocale-1; if( pbResetTokenizer ){ - rc = fts5SetLocale(pConfig, (const char*)pBlob, nLocale); + fts5SetLocale(pConfig, (const char*)pBlob, nLocale); *pbResetTokenizer = 1; } } @@ -1389,18 +1397,18 @@ int sqlite3Fts5ExtractText( ** the text of the expression, and sets output variable (*pzText) to ** point to a nul-terminated buffer containing the expression. ** -** If pVal was an fts5_locale() value, then the tokenizer has been -** configured to us the required locale. +** If pVal was an fts5_locale() value, then fts5SetLocale() is called to +** set the tokenizer to use the specified locale. ** ** If output variable (*pbFreeAndReset) is set to true, then the caller ** is required to (a) call sqlite3Fts5ClearLocale() to reset the tokenizer ** locale, and (b) call sqlite3_free() to free (*pzText). */ static int fts5ExtractExprText( - Fts5FullTable *pTab, - sqlite3_value *pVal, - char **pzText, - int *pbFreeAndReset + Fts5Config *pConfig, /* Fts5 configuration */ + sqlite3_value *pVal, /* Value to extract expression text from */ + char **pzText, /* OUT: nul-terminated buffer of text */ + int *pbFreeAndReset /* OUT: Free (*pzText) and clear locale */ ){ const char *zText = 0; int nText = 0; @@ -1408,12 +1416,12 @@ static int fts5ExtractExprText( int bReset = 0; *pbFreeAndReset = 0; - rc = sqlite3Fts5ExtractText(pTab->p.pConfig, pVal, 0, &bReset, &zText,&nText); + rc = sqlite3Fts5ExtractText(pConfig, pVal, 0, &bReset, &zText, &nText); if( rc==SQLITE_OK ){ if( bReset ){ *pzText = sqlite3Fts5Mprintf(&rc, "%.*s", nText, zText); if( rc!=SQLITE_OK ){ - sqlite3Fts5ClearLocale(pTab->p.pConfig); + sqlite3Fts5ClearLocale(pConfig); }else{ *pbFreeAndReset = 1; } @@ -1494,7 +1502,7 @@ static int fts5FilterMethod( int bFreeAndReset = 0; int bInternal = 0; - rc = fts5ExtractExprText(pTab, apVal[i], &zText, &bFreeAndReset); + rc = fts5ExtractExprText(pConfig, apVal[i], &zText, &bFreeAndReset); if( rc!=SQLITE_OK ) goto filter_out; if( zText==0 ) zText = ""; @@ -2124,6 +2132,9 @@ static int fts5ApiRowCount(Fts5Context *pCtx, i64 *pnRow){ return sqlite3Fts5StorageRowCount(pTab->pStorage, pnRow); } +/* +** Implementation of xTokenize_v2() API. +*/ static int fts5ApiTokenize_v2( Fts5Context *pCtx, const char *pText, int nText, @@ -2143,6 +2154,11 @@ static int fts5ApiTokenize_v2( return rc; } + +/* +** Implementation of xTokenize() API. This is just xTokenize_v2() with NULL/0 +** passed as the locale. +*/ static int fts5ApiTokenize( Fts5Context *pCtx, const char *pText, int nText, @@ -2190,11 +2206,18 @@ static int fts5ApiColumnText( return rc; } +/* +** This is called by various API functions - xInst, xPhraseFirst, +** xPhraseFirstColumn etc. - to obtain the position list for phrase iPhrase +** of the current row. This function works for both detail=full tables (in +** which case the position-list was read from the fts index) or for other +** detail= modes if the row content is available. +*/ static int fts5CsrPoslist( - Fts5Cursor *pCsr, - int iPhrase, - const u8 **pa, - int *pn + Fts5Cursor *pCsr, /* Fts5 cursor object */ + int iPhrase, /* Phrase to find position list for */ + const u8 **pa, /* OUT: Pointer to position list buffer */ + int *pn /* OUT: Size of (*pa) in bytes */ ){ Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; int rc = SQLITE_OK; @@ -2240,7 +2263,6 @@ static int fts5CsrPoslist( *pn = 0; } - return rc; } @@ -2808,6 +2830,11 @@ static Fts5Cursor *fts5CursorFromCsrid(Fts5Global *pGlobal, i64 iCsrId){ return pCsr; } +/* +** Parameter zFmt is a printf() style formatting string. This function +** formats it using the trailing arguments and returns the result as +** an error message to the context passed as the first argument. +*/ static void fts5ResultError(sqlite3_context *pCtx, const char *zFmt, ...){ char *zErr = 0; va_list ap; @@ -2931,12 +2958,13 @@ static int fts5PoslistBlob(sqlite3_context *pCtx, Fts5Cursor *pCsr){ /* ** Value pVal was read from column iCol of the FTS5 table. This function ** returns it to the owner of pCtx via a call to an sqlite3_result_xxx() -** function. This function deals with the same 3 cases as +** function. This function deals with the same cases as ** sqlite3Fts5ExtractText(): ** ** 1) Ordinary values. These can be returned using sqlite3_result_value(). ** -** 2) Blobs from fts5_locale(). +** 2) Blobs from fts5_locale(). The text is extracted from these and +** returned via sqlite3_result_text(). The locale is discarded. */ static void fts5ExtractValueFromColumn( sqlite3_context *pCtx, @@ -3176,6 +3204,21 @@ static int fts5CreateAux( return rc; } +/* +** This function is used by xCreateTokenizer_v2() and xCreateTokenizer(). +** It allocates and partially populates a new Fts5TokenizerModule object. +** The new object is already linked into the Fts5Global context before +** returning. +** +** If successful, SQLITE_OK is returned and a pointer to the new +** Fts5TokenizerModule object returned via output parameter (*ppNew). All +** that is required is for the caller to fill in the methods in +** Fts5TokenizerModule.x1 and x2, and to set Fts5TokenizerModule.bV2Native +** as appropriate. +** +** If an error occurs, an SQLite error code is returned and the final value +** of (*ppNew) undefined. +*/ static int fts5NewTokenizerModule( Fts5Global *pGlobal, /* Global context (one per db handle) */ const char *zName, /* Name of new function */ diff --git a/manifest b/manifest index ce9f94a445..6750b90740 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sporter\stokenizer\sto\suse\slocales. -D 2024-08-12T11:46:09.154 +C Fix\sfurther\sissues\sto\sdo\swith\sfts5\slocale\ssupport. +D 2024-08-12T17:03:37.726 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,15 +92,15 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h 7f1197009fc0e9822a8a584aa1f90591bdbf04f4503ecfe06949f3afe7a1fe06 -F ext/fts5/fts5Int.h b40bb0bd54aaa4ac4712b6c5763b2167764614aaef204dbae81638b4548bca5d -F ext/fts5/fts5_aux.c 0d0ee62dfebe93ccf6b293edb0b21ebe5c8bdc85e962a001745f2d13ea3e79d2 +F ext/fts5/fts5.h 4c6998c6186268b4dbe9baef2c0d2ab974bd90996d61d4dbe801367249be6de4 +F ext/fts5/fts5Int.h 776b21159eef8d30379e5bc4627eae9e841d36e43f19dc8908c786e62aaf9e38 +F ext/fts5/fts5_aux.c 12cd2512f869217c38b70c31de5b5f741812734fafa80f55b32ea9bbd96e2152 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215549a24a2a -F ext/fts5/fts5_expr.c ee1949c5c20901cbaca0885902f1d0c136679262dee71b457a34a92e1d16ddac +F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c cd61abbfd02f0f22e3c124ae2ad10c2a51cdf8acf38177410d44e134c1d1364b +F ext/fts5/fts5_main.c 4fe8349b812a9fde8e44ac5568f19d713ccc4790eb3ecb692f6551729c481b2b F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -2207,8 +2207,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f7d56a1f2149f0da117167db62e2c28ec337e8da3403873b64cdfc6a951e2e8e -R 7151af5ed6816182b47b60322cc8dcba +P 3291ce3a3359a80e51e4546a3d7a187cbe4c7530fca6632f0bb2728525efe212 +R 5bdde041363e74c68796cadade4d8480 U dan -Z a17240af0068f64d6da9a8176108962c +Z 098e7ed7a851f6658bf54618988e8ebd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6edb67265e..902e51759c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3291ce3a3359a80e51e4546a3d7a187cbe4c7530fca6632f0bb2728525efe212 +e626123580065986f7df50b6140f00048944becce179b9391fbf09f97ac55485 From a4a8e9102226f16cccd952e7902a20ee882c08c3 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 12 Aug 2024 17:28:13 +0000 Subject: [PATCH 0654/1030] Fix problem with some fts5 aux function APIs with (locale=, detail=none/column) tables. FossilOrigin-Name: bf116dec6fb20cce69099cb8c031b0de511195482919a99ccfb3c498e9bf8125 --- ext/fts5/fts5_main.c | 11 +++++++++-- ext/fts5/test/fts5locale.test | 30 ++++++++++++++++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index b4ccd04028..8af3dd0515 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2231,14 +2231,21 @@ static int fts5CsrPoslist( int i; aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr, bLive); if( aPopulator==0 ) rc = SQLITE_NOMEM; + if( rc==SQLITE_OK ){ + rc = fts5SeekCursor(pCsr, 0); + } for(i=0; inCol && rc==SQLITE_OK; i++){ - int n; const char *z; - rc = fts5ApiColumnText((Fts5Context*)pCsr, i, &z, &n); + sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, i+1); + const char *z = 0; + int n = 0; + int bReset = 0; + rc = sqlite3Fts5ExtractText(pConfig, pVal, 1, &bReset, &z, &n); if( rc==SQLITE_OK ){ rc = sqlite3Fts5ExprPopulatePoslists( pConfig, pCsr->pExpr, aPopulator, i, z, n ); } + if( bReset ) sqlite3Fts5ClearLocale(pConfig); } sqlite3_free(aPopulator); diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index 2d5f2a00dc..a8ea31e221 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -414,5 +414,35 @@ do_execsql_test 8.1 { a eb eulav osla sihT te the token yam } +#------------------------------------------------------------------------- +# Test that position-lists (used by xInst, xPhraseFirst etc.) work with +# locales and modes other than detail=full. +# + +foreach {tn detail} { + 1 detail=full + 2 detail=none + 3 detail=column +} { + reset_db + sqlite3_fts5_create_tokenizer -v2 db tcl tcl_create + do_execsql_test 9.$tn.0 " + CREATE VIRTUAL TABLE ft USING fts5(tt, locale=1, tokenize=tcl, $detail); + " + do_execsql_test 9.$tn.1 { + CREATE VIRTUAL TABLE vocab USING fts5vocab('ft', instance); + INSERT INTO ft(rowid, tt) VALUES + (-1, fts5_locale('second', 'it is an ancient mariner')); + } + + do_execsql_test 9.$tn.2 { + SELECT DISTINCT term FROM vocab + } {an it mariner} + + do_execsql_test 9.$tn.3 { + SELECT highlight(ft, 0, '[', ']') FROM ft('mariner') + } {{it is an ancient [mariner]}} +} + finish_test diff --git a/manifest b/manifest index 6750b90740..c845da3de9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfurther\sissues\sto\sdo\swith\sfts5\slocale\ssupport. -D 2024-08-12T17:03:37.726 +C Fix\sproblem\swith\ssome\sfts5\saux\sfunction\sAPIs\swith\s(locale=,\sdetail=none/column)\stables. +D 2024-08-12T17:28:13.218 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215 F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 4fe8349b812a9fde8e44ac5568f19d713ccc4790eb3ecb692f6551729c481b2b +F ext/fts5/fts5_main.c b3194ee180859067fc8651d3c4e40d7f24877eb9cd820618d938d1a6d0974493 F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -186,7 +186,7 @@ F ext/fts5/test/fts5interrupt.test 20d04204d3e341b104c0c24a41596b6393a3a81eba104 F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 8e893b5a764d181260f5f862dc529fcdb42315b2d683317043d4609f13f88a02 +F ext/fts5/test/fts5locale.test 1f08fb39af3c0cb49ce48ec1212308db4b0105a38ff1a6864c8ef73abffb5431 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2207,8 +2207,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3291ce3a3359a80e51e4546a3d7a187cbe4c7530fca6632f0bb2728525efe212 -R 5bdde041363e74c68796cadade4d8480 +P e626123580065986f7df50b6140f00048944becce179b9391fbf09f97ac55485 +R 7d41bee88044e0297d8070928920af0c U dan -Z 098e7ed7a851f6658bf54618988e8ebd +Z 30446f621f4abd678975f659d5345d71 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 902e51759c..0fc1e84a71 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e626123580065986f7df50b6140f00048944becce179b9391fbf09f97ac55485 +bf116dec6fb20cce69099cb8c031b0de511195482919a99ccfb3c498e9bf8125 From 3e38aa08218c8a854916a513d54b456960a4f49e Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 12 Aug 2024 18:39:13 +0000 Subject: [PATCH 0655/1030] Add extra documentation comments to fts5_main.c. FossilOrigin-Name: 1a7a9bd3f6a2b9347720f7f0386399e7f14b428500acf07d7c55b9dde1ec233a --- ext/fts5/fts5_main.c | 39 +++++++++++++++++++++++++++++++++++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 8af3dd0515..18582eb54e 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -3256,12 +3256,22 @@ static int fts5NewTokenizerModule( return rc; } +/* +** An instance of this type is used as the Fts5Tokenizer object for +** wrapper tokenizers - those that provide access to a v1 tokenizer via +** the fts5_tokenizer_v2 API, and those that provide access to a v2 tokenizer +** via the fts5_tokenizer API. +*/ typedef struct Fts5VtoVTokenizer Fts5VtoVTokenizer; struct Fts5VtoVTokenizer { Fts5TokenizerModule *pMod; Fts5Tokenizer *pReal; }; +/* +** Create a wrapper tokenizer. The context argument pCtx points to the +** Fts5TokenizerModule object. +*/ static int fts5VtoVCreate( void *pCtx, const char **azArg, @@ -3289,6 +3299,10 @@ static int fts5VtoVCreate( *ppOut = (Fts5Tokenizer*)pNew; return rc; } + +/* +** Delete an Fts5VtoVTokenizer wrapper tokenizer. +*/ static void fts5VtoVDelete(Fts5Tokenizer *pTok){ Fts5VtoVTokenizer *p = (Fts5VtoVTokenizer*)pTok; if( p ){ @@ -3301,6 +3315,12 @@ static void fts5VtoVDelete(Fts5Tokenizer *pTok){ sqlite3_free(p); } } + + +/* +** xTokenizer method for a wrapper tokenizer that offers the v1 interface +** (no support for locales). +*/ static int fts5V1toV2Tokenize( Fts5Tokenizer *pTok, void *pCtx, int flags, @@ -3312,6 +3332,11 @@ static int fts5V1toV2Tokenize( assert( pMod->bV2Native ); return pMod->x2.xTokenize(p->pReal, pCtx, flags, pText, nText, 0, 0, xToken); } + +/* +** xTokenizer method for a wrapper tokenizer that offers the v2 interface +** (with locale support). +*/ static int fts5V2toV1Tokenize( Fts5Tokenizer *pTok, void *pCtx, int flags, @@ -3381,9 +3406,14 @@ static int fts5CreateTokenizer( return rc; } +/* +** Search the global context passed as the first argument for a tokenizer +** module named zName. If found, return a pointer to the Fts5TokenizerModule +** object. Otherwise, return NULL. +*/ static Fts5TokenizerModule *fts5LocateTokenizer( - Fts5Global *pGlobal, - const char *zName + Fts5Global *pGlobal, /* Global (one per db handle) object */ + const char *zName /* Name of tokenizer module to find */ ){ Fts5TokenizerModule *pMod = 0; @@ -3518,6 +3548,11 @@ int sqlite3Fts5LoadTokenizer(Fts5Config *pConfig){ } +/* +** xDestroy callback passed to sqlite3_create_module(). This is invoked +** when the db handle is being closed. Free memory associated with +** tokenizers and aux functions registered with this db handle. +*/ static void fts5ModuleDestroy(void *pCtx){ Fts5TokenizerModule *pTok, *pNextTok; Fts5Auxiliary *pAux, *pNextAux; diff --git a/manifest b/manifest index c845da3de9..238fedebb5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sproblem\swith\ssome\sfts5\saux\sfunction\sAPIs\swith\s(locale=,\sdetail=none/column)\stables. -D 2024-08-12T17:28:13.218 +C Add\sextra\sdocumentation\scomments\sto\sfts5_main.c. +D 2024-08-12T18:39:13.026 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215 F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c b3194ee180859067fc8651d3c4e40d7f24877eb9cd820618d938d1a6d0974493 +F ext/fts5/fts5_main.c 93468b6f48aa7600e46e940918186b74c79388487ea85790ebab8dab133e8468 F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -2207,8 +2207,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e626123580065986f7df50b6140f00048944becce179b9391fbf09f97ac55485 -R 7d41bee88044e0297d8070928920af0c +P bf116dec6fb20cce69099cb8c031b0de511195482919a99ccfb3c498e9bf8125 +R bb64d9fe4ea841aa0ab73938efab7522 U dan -Z 30446f621f4abd678975f659d5345d71 +Z 8f8f9d2cf7c267c2be98bbe165feb5ff # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0fc1e84a71..5f0fdf183c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf116dec6fb20cce69099cb8c031b0de511195482919a99ccfb3c498e9bf8125 +1a7a9bd3f6a2b9347720f7f0386399e7f14b428500acf07d7c55b9dde1ec233a From 7dad9b4297bfc1e66c69aa39ea5673b66755602d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 13 Aug 2024 15:04:00 +0000 Subject: [PATCH 0656/1030] Add tests and fix minor issues with the code on this branch. FossilOrigin-Name: def5243a7b4f1d50427ba607d31332db2d6ac34b181b0cbd2ed4911064f5637a --- ext/fts5/fts5_main.c | 37 ++++++++++++++--------------------- ext/fts5/test/fts5simple.test | 1 - manifest | 14 ++++++------- manifest.uuid | 2 +- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 18582eb54e..a70dad4b20 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -3488,21 +3488,20 @@ static int fts5FindTokenizer( return rc; } -int fts5GetTokenizer( - Fts5Global *pGlobal, - const char **azArg, - int nArg, - Fts5Config *pConfig, - char **pzErr -){ - Fts5TokenizerModule *pMod; +/* +** Attempt to instantiate the tokenizer. +*/ +int sqlite3Fts5LoadTokenizer(Fts5Config *pConfig){ + const char **azArg = pConfig->t.azArg; + const int nArg = pConfig->t.nArg; + Fts5TokenizerModule *pMod = 0; int rc = SQLITE_OK; - pMod = fts5LocateTokenizer(pGlobal, nArg==0 ? 0 : azArg[0]); + pMod = fts5LocateTokenizer(pConfig->pGlobal, nArg==0 ? 0 : azArg[0]); if( pMod==0 ){ assert( nArg>0 ); rc = SQLITE_ERROR; - if( pzErr ) *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); + sqlite3Fts5ConfigErrmsg(pConfig, "no such tokenizer: %s", azArg[0]); }else{ int (*xCreate)(void*, const char**, int, Fts5Tokenizer**) = 0; if( pMod->bV2Native ){ @@ -3518,8 +3517,8 @@ int fts5GetTokenizer( ); if( rc!=SQLITE_OK ){ - if( pzErr && rc!=SQLITE_NOMEM ){ - *pzErr = sqlite3_mprintf("error in tokenizer constructor"); + if( rc!=SQLITE_NOMEM ){ + sqlite3Fts5ConfigErrmsg(pConfig, "error in tokenizer constructor"); } }else if( pMod->bV2Native==0 ){ pConfig->t.ePattern = sqlite3Fts5TokenizerPattern( @@ -3537,16 +3536,6 @@ int fts5GetTokenizer( return rc; } -/* -** Attempt to instantiate the tokenizer. -*/ -int sqlite3Fts5LoadTokenizer(Fts5Config *pConfig){ - return fts5GetTokenizer( - pConfig->pGlobal, pConfig->t.azArg, pConfig->t.nArg, - pConfig, pConfig->pzErrmsg - ); -} - /* ** xDestroy callback passed to sqlite3_create_module(). This is invoked @@ -3573,6 +3562,10 @@ static void fts5ModuleDestroy(void *pCtx){ sqlite3_free(pGlobal); } +/* +** Implementation of the fts5() function used by clients to obtain the +** API pointer. +*/ static void fts5Fts5Func( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 050509fb37..6384095067 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -312,7 +312,6 @@ do_execsql_test 13.1 { INSERT INTO xy(rowid, x) VALUES(3, '3 4 5'); } -breakpoint do_execsql_test 13.2 { UPDATE OR REPLACE xy SET rowid=3 WHERE rowid = 2; SELECT rowid, x FROM xy; diff --git a/manifest b/manifest index 238fedebb5..8e8fa479e7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\sdocumentation\scomments\sto\sfts5_main.c. -D 2024-08-12T18:39:13.026 +C Add\stests\sand\sfix\sminor\sissues\swith\sthe\scode\son\sthis\sbranch. +D 2024-08-13T15:04:00.350 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215 F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 93468b6f48aa7600e46e940918186b74c79388487ea85790ebab8dab133e8468 +F ext/fts5/fts5_main.c 42860180de19a159dd821e83450916ddfae92a6aeb8cd357c8c93ef10d3dec0e F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -224,7 +224,7 @@ F ext/fts5/test/fts5secure6.test 74bf04733cc523bccca519bb03d3b4e2ed6f6e3db7c59bf F ext/fts5/test/fts5secure7.test fd03d0868d64340a1db8615b02e5508fea409de13910114e4f19eaefc120777a F ext/fts5/test/fts5secure8.test e68c0ac4447f415ff3e4e82531e99548289286f9f3a29c8cd53036113fe28602 F ext/fts5/test/fts5securefault.test c34a28c7cd2f31a8b8907563889e1329a97da975c08df2d951422bcef8e2ebc5 -F ext/fts5/test/fts5simple.test 453b2348193911c2d51c208bfe247a09b936c4ddd9a836160495a5554340c256 +F ext/fts5/test/fts5simple.test 847fb828262328744733847dc76d6b5d4a6bd4c5d9b282cb819f6504340e061a F ext/fts5/test/fts5simple2.test d10d963a357b8ec77b99032e4c816459b4dbdb1f6eee25eada7ef3ed245cb2dc F ext/fts5/test/fts5simple3.test 146ec3dc8f5763d6212641c9f0a2f1cba41679353d2add7b963beceb115dc7f4 F ext/fts5/test/fts5synonym.test becc8cea6cfc958a50b30c572c68cbfdf7455971d0fe988202ce67638d2c6cf6 @@ -2207,8 +2207,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bf116dec6fb20cce69099cb8c031b0de511195482919a99ccfb3c498e9bf8125 -R bb64d9fe4ea841aa0ab73938efab7522 +P 1a7a9bd3f6a2b9347720f7f0386399e7f14b428500acf07d7c55b9dde1ec233a +R 3ca8b15875339dd4f641808ef826812c U dan -Z 8f8f9d2cf7c267c2be98bbe165feb5ff +Z 64c2a3f3ef9fc7e9fed1ba5b27ea297b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5f0fdf183c..80e74cf5f3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a7a9bd3f6a2b9347720f7f0386399e7f14b428500acf07d7c55b9dde1ec233a +def5243a7b4f1d50427ba607d31332db2d6ac34b181b0cbd2ed4911064f5637a From 797fcb8433301d995dbe7731765833c82a74a1da Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 13 Aug 2024 21:04:00 +0000 Subject: [PATCH 0657/1030] Add the sha3_agg() aggregate to the shathree extension. FossilOrigin-Name: c4d7f9996ce4f5f6d08d83fc3abdb81b6825cfb556318f90c6896736a1da5175 --- ext/misc/shathree.c | 153 ++++++++++++++++++++++++++++++-------------- manifest | 12 ++-- manifest.uuid | 2 +- 3 files changed, 112 insertions(+), 55 deletions(-) diff --git a/ext/misc/shathree.c b/ext/misc/shathree.c index ba3ea581f8..46a864af4e 100644 --- a/ext/misc/shathree.c +++ b/ext/misc/shathree.c @@ -75,6 +75,7 @@ struct SHA3Context { unsigned nRate; /* Bytes of input accepted per Keccak iteration */ unsigned nLoaded; /* Input bytes loaded into u.x[] so far this cycle */ unsigned ixMask; /* Insert next input into u.x[nLoaded^ixMask]. */ + unsigned iSize; /* 224, 256, 358, or 512 */ }; /* @@ -404,6 +405,7 @@ static void KeccakF1600Step(SHA3Context *p){ */ static void SHA3Init(SHA3Context *p, int iSize){ memset(p, 0, sizeof(*p)); + p->iSize = iSize; if( iSize>=128 && iSize<=512 ){ p->nRate = (1600 - ((iSize + 31)&~31)*2)/8; }else{ @@ -547,6 +549,60 @@ static void sha3_step_vformat( SHA3Update(p, (unsigned char*)zBuf, n); } +/* +** Update a SHA3Context using a single sqlite3_value. +*/ +static void sha3UpdateFromValue(SHA3Context *p, sqlite3_value *pVal){ + switch( sqlite3_value_type(pVal) ){ + case SQLITE_NULL: { + SHA3Update(p, (const unsigned char*)"N",1); + break; + } + case SQLITE_INTEGER: { + sqlite3_uint64 u; + int j; + unsigned char x[9]; + sqlite3_int64 v = sqlite3_value_int64(pVal); + memcpy(&u, &v, 8); + for(j=8; j>=1; j--){ + x[j] = u & 0xff; + u >>= 8; + } + x[0] = 'I'; + SHA3Update(p, x, 9); + break; + } + case SQLITE_FLOAT: { + sqlite3_uint64 u; + int j; + unsigned char x[9]; + double r = sqlite3_value_double(pVal); + memcpy(&u, &r, 8); + for(j=8; j>=1; j--){ + x[j] = u & 0xff; + u >>= 8; + } + x[0] = 'F'; + SHA3Update(p,x,9); + break; + } + case SQLITE_TEXT: { + int n2 = sqlite3_value_bytes(pVal); + const unsigned char *z2 = sqlite3_value_text(pVal); + sha3_step_vformat(p,"T%d:",n2); + SHA3Update(p, z2, n2); + break; + } + case SQLITE_BLOB: { + int n2 = sqlite3_value_bytes(pVal); + const unsigned char *z2 = sqlite3_value_blob(pVal); + sha3_step_vformat(p,"B%d:",n2); + SHA3Update(p, z2, n2); + break; + } + } +} + /* ** Implementation of the sha3_query(SQL,SIZE) function. ** @@ -636,54 +692,7 @@ static void sha3QueryFunc( while( SQLITE_ROW==sqlite3_step(pStmt) ){ SHA3Update(&cx,(const unsigned char*)"R",1); for(i=0; i=1; j--){ - x[j] = u & 0xff; - u >>= 8; - } - x[0] = 'I'; - SHA3Update(&cx, x, 9); - break; - } - case SQLITE_FLOAT: { - sqlite3_uint64 u; - int j; - unsigned char x[9]; - double r = sqlite3_column_double(pStmt,i); - memcpy(&u, &r, 8); - for(j=8; j>=1; j--){ - x[j] = u & 0xff; - u >>= 8; - } - x[0] = 'F'; - SHA3Update(&cx,x,9); - break; - } - case SQLITE_TEXT: { - int n2 = sqlite3_column_bytes(pStmt, i); - const unsigned char *z2 = sqlite3_column_text(pStmt, i); - sha3_step_vformat(&cx,"T%d:",n2); - SHA3Update(&cx, z2, n2); - break; - } - case SQLITE_BLOB: { - int n2 = sqlite3_column_bytes(pStmt, i); - const unsigned char *z2 = sqlite3_column_blob(pStmt, i); - sha3_step_vformat(&cx,"B%d:",n2); - SHA3Update(&cx, z2, n2); - break; - } - } + sha3UpdateFromValue(&cx, sqlite3_column_value(pStmt,i)); } } sqlite3_finalize(pStmt); @@ -691,6 +700,44 @@ static void sha3QueryFunc( sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT); } +/* +** xStep function for sha3_agg(). +*/ +static void sha3AggStep( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + SHA3Context *p; + p = (SHA3Context*)sqlite3_aggregate_context(context, sizeof(*p)); + if( p==0 ) return; + if( p->nRate==0 ){ + int sz = 256; + if( argc==2 ){ + sz = sqlite3_value_int(argv[1]); + if( sz!=224 && sz!=384 && sz!=512 ){ + sz = 256; + } + } + SHA3Init(p, sz); + } + sha3UpdateFromValue(p, argv[0]); +} + + +/* +** xFinal function for sha3_agg(). +*/ +static void sha3AggFinal(sqlite3_context *context){ + SHA3Context *p; + p = (SHA3Context*)sqlite3_aggregate_context(context, sizeof(*p)); + if( p==0 ) return; + if( p->iSize ){ + sqlite3_result_blob(context, SHA3Final(p), p->iSize/8, SQLITE_TRANSIENT); + } +} + + #ifdef _WIN32 __declspec(dllexport) @@ -711,6 +758,16 @@ int sqlite3_shathree_init( SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC, 0, sha3Func, 0, 0); } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "sha3_agg", 1, + SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC, + 0, 0, sha3AggStep, sha3AggFinal); + } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "sha3_agg", 2, + SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC, + 0, 0, sha3AggStep, sha3AggFinal); + } if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "sha3_query", 1, SQLITE_UTF8 | SQLITE_DIRECTONLY, diff --git a/manifest b/manifest index 159330c456..13c566c83d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Resolve\sparameters\sBind\s$int_N\sand\s$test_T\sin\sfuzzcheck\sinputs. -D 2024-08-12T09:49:02.212 +C Add\sthe\ssha3_agg()\saggregate\sto\sthe\sshathree\sextension. +D 2024-08-13T21:04:00.686 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -415,7 +415,7 @@ F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d385 F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 F ext/misc/series.c d96e5aac21658c6b5d54f918ac140460ec7197734c1a4fba806950831a7b1e7a F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d -F ext/misc/shathree.c 543af7ce71d391cd3a9ab6924a6a1124efc63211fd0f2e240dc4b56077ba88ac +F ext/misc/shathree.c 24e890cb209272379f8d0823fb278d24bd3dca35d5ea565aa0b2794cd36d6197 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c c0aa7b80d6df45f7da59d912b38752bcac1af53a5766966160e6c5cdd397dbea F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d4014c87ba9b011a6a04c2bf85879b668dc762ebcbbfb50a2f8a417ce594ef88 -R 33ab7e360692d6ed2c1cd4d18565e8ac +P 9c10664416274df6f8da53ddd86f6356c9704ad798fd4034d2784ae433c1c056 +R 3605902adbab51926bad4083cbf76d2c U drh -Z 32b23835ef00f951c0107d2a77ff843c +Z fc4daf336fe8a5609f55ae8abc7ca9b2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ef73d7fbbd..6054597565 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c10664416274df6f8da53ddd86f6356c9704ad798fd4034d2784ae433c1c056 +c4d7f9996ce4f5f6d08d83fc3abdb81b6825cfb556318f90c6896736a1da5175 From a7384e0de2df5371e069b37f8705259159fe418b Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 13 Aug 2024 21:15:43 +0000 Subject: [PATCH 0658/1030] More tests for the new code on this branch. FossilOrigin-Name: 00792e807f1dde750e6ac9f9b0095cf60b9fa6ff7cf4b14440600a21de2ee61a --- ext/fts5/fts5_main.c | 19 ++++---- ext/fts5/test/fts5blob.test | 17 ++++++++ ext/fts5/test/fts5faultI.test | 67 +++++++++++++++++++++++++++++ ext/fts5/test/fts5locale.test | 81 ++++++++++++++++++++++++++++++++++- ext/fts5/test/fts5misc.test | 5 +++ manifest | 19 ++++---- manifest.uuid | 2 +- 7 files changed, 189 insertions(+), 21 deletions(-) create mode 100644 ext/fts5/test/fts5faultI.test diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index a70dad4b20..80fe73a2fa 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1992,12 +1992,11 @@ static int fts5UpdateMethod( } } + assert( eType1==SQLITE_INTEGER || eType1==SQLITE_NULL ); if( eType0!=SQLITE_INTEGER ){ /* An INSERT statement. If the conflict-mode is REPLACE, first remove ** the current entry (if any). */ - if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){ - rc = SQLITE_MISMATCH; - }else if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ + if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0); bUpdateOrDelete = 1; @@ -2726,7 +2725,7 @@ static int fts5ApiColumnLocale( if( pConfig->eContent==FTS5_CONTENT_EXTERNAL ){ const int SZHDR = sizeof(FTS5_LOCALE_HEADER)-1; if( nBlobeContent==FTS5_CONTENT_EXTERNAL ){ if( nBlob', '') FROM t1('*reads')); } {1 {no such cursor: 1}} +fts5_aux_test_functions db +do_catchsql_test 1.3.4 { + SELECT fts5_columntext(t1) FROM t1('*reads'); +} {1 {no such cursor: 1}} + #------------------------------------------------------------------------- reset_db do_execsql_test 2.0 { diff --git a/manifest b/manifest index 8e8fa479e7..318eb8554f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sand\sfix\sminor\sissues\swith\sthe\scode\son\sthis\sbranch. -D 2024-08-13T15:04:00.350 +C More\stests\sfor\sthe\snew\scode\son\sthis\sbranch. +D 2024-08-13T21:15:43.313 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215 F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 42860180de19a159dd821e83450916ddfae92a6aeb8cd357c8c93ef10d3dec0e +F ext/fts5/fts5_main.c f8eae223ce93aad7c503a76872267e0e6d288b54ccb4d9bfe894c4ed365f8d3c F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -132,7 +132,7 @@ F ext/fts5/test/fts5auxdata.test 372549088ff792655f73e62b9dfaf4863ce74f5e604c06c F ext/fts5/test/fts5bigid.test 2860854c2561a57594192b00c33a29f91cb85e25f3d6c03b5c2b8f62708f39dd F ext/fts5/test/fts5bigpl.test 8f09858aab866c33593560e6480b2b6975ae7ff29ca32ad7b77e2da61402f8ef F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36 -F ext/fts5/test/fts5blob.test 2f84ef3591dd3eb0efa686a3615e9ed5c5005462c663c7c72c350692b99f91f5 +F ext/fts5/test/fts5blob.test caa33369e93e99ff494cd1103506ae34c5afbc0bcc369ed5e58e135144e33689 F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62 F ext/fts5/test/fts5colset.test 544f4998cdbfe06a3123887fc0221612e8aa8192cdaff152872f1aadb10e6897 @@ -177,6 +177,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d +F ext/fts5/test/fts5faultI.test bfaf9b94888ef604bd8034a3edd1bbdeb626c07337376b9b66d6171b28ee7931 F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -186,11 +187,11 @@ F ext/fts5/test/fts5interrupt.test 20d04204d3e341b104c0c24a41596b6393a3a81eba104 F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 1f08fb39af3c0cb49ce48ec1212308db4b0105a38ff1a6864c8ef73abffb5431 +F ext/fts5/test/fts5locale.test f58ac6ab539d3813556646f7d4b1e19f7e3b1a56ca4439349eb8099d6a821ff6 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test b88aa28ff20238b394495b0795cddca1a62b98fa09b99e462a8abc572d04ee88 +F ext/fts5/test/fts5misc.test 946abba0b45298e3d9d7a98e19eb4ac5384e8f2848ce1888c7ab3f62645efd2f F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -2207,8 +2208,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1a7a9bd3f6a2b9347720f7f0386399e7f14b428500acf07d7c55b9dde1ec233a -R 3ca8b15875339dd4f641808ef826812c +P def5243a7b4f1d50427ba607d31332db2d6ac34b181b0cbd2ed4911064f5637a +R 4b120525083c8e765eb88ddcda2d97e2 U dan -Z 64c2a3f3ef9fc7e9fed1ba5b27ea297b +Z aad3d9cc9413a3fb75b2e684b7b3f795 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 80e74cf5f3..154fd54b3f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -def5243a7b4f1d50427ba607d31332db2d6ac34b181b0cbd2ed4911064f5637a +00792e807f1dde750e6ac9f9b0095cf60b9fa6ff7cf4b14440600a21de2ee61a From 8ff952773df34ee2fa4395e5e1fa8a36717354aa Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 14 Aug 2024 14:26:02 +0000 Subject: [PATCH 0659/1030] Fix an assert() in fts5 that might fail with an expression like "... NOT ''". FossilOrigin-Name: 317c91edfc69d1d47e233bb6ac13934241742fda1ba03a88fd51bdf98fcbc463 --- ext/fts5/fts5_expr.c | 7 ++++++- ext/fts5/test/fts5misc.test | 22 ++++++++++++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index a39cc16bbf..1f089d8757 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -54,7 +54,7 @@ struct Fts5Expr { /* ** eType: -** Expression node type. Always one of: +** Expression node type. Usually one of: ** ** FTS5_AND (nChild, apChild valid) ** FTS5_OR (nChild, apChild valid) @@ -62,6 +62,10 @@ struct Fts5Expr { ** FTS5_STRING (pNear valid) ** FTS5_TERM (pNear valid) ** +** An expression node with eType==0 may also exist. It always matches zero +** rows. This is created when a phrase containing no tokens is parsed. +** e.g. "". +** ** iHeight: ** Distance from this node to furthest leaf. This is always 0 for nodes ** of type FTS5_STRING and FTS5_TERM. For all other nodes it is one @@ -3112,6 +3116,7 @@ static int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){ pNode->iRowid = iRowid; pNode->bEof = 0; switch( pNode->eType ){ + case 0: case FTS5_TERM: case FTS5_STRING: return (pNode->pNear->apPhrase[0]->poslist.n>0); diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index e4903d067a..abd4fdaf89 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -21,6 +21,8 @@ ifcapable !fts5 { return } +if 0 { + do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a); } @@ -566,5 +568,25 @@ do_execsql_test 20.5 { SELECT rowid FROM x1 WHERE x1 MATCH 'z' OR (x1 MATCH 'a' AND x1 MATCH 'd'); } {3 1} +#------------------------------------------------------------------------- +} +reset_db +do_execsql_test 21.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail='none'); + INSERT INTO t1(a) VALUES('a'); +} + +do_execsql_test 21.2 { + SELECT rank FROM ( SELECT rank FROM t1('a NOT "" NOT def') ) ORDER BY 1; +} {-1e-06} + +do_execsql_test 21.3 { + SELECT rank FROM ( SELECT rank FROM t1('a NOT � NOT def') ) ORDER BY 1; +} {-1e-06} + +do_execsql_test 21.4 { + SELECT rank FROM ( SELECT rank FROM t1('a NOT "" NOT def') ); +} {-1e-06} + finish_test diff --git a/manifest b/manifest index 13c566c83d..d30fe768b9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssha3_agg()\saggregate\sto\sthe\sshathree\sextension. -D 2024-08-13T21:04:00.686 +C Fix\san\sassert()\sin\sfts5\sthat\smight\sfail\swith\san\sexpression\slike\s"...\sNOT\s''". +D 2024-08-14T14:26:02.443 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -97,7 +97,7 @@ F ext/fts5/fts5Int.h 41fb3a2dd40e818cc96c6f4176dbdf2aaa8f57043cfc9a8f2676e7e6a72 F ext/fts5/fts5_aux.c 4584e88878e54828bf7d4d0d83deedd232ec60628b7731be02bad6adb62304b1 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 68cb87a49215f8e7028000b681df4057c430a4a6afbd676463886da94c9e1c37 -F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 +F ext/fts5/fts5_expr.c 4b7734db98393d6f7fbc5c9c71ebcabe70110f7df08f6b136d096a1eaee0f56a F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 6ec7a7d005c632d86e510ddfaca56b197a5b20b61848415764b91bd27d1e4f84 @@ -188,7 +188,7 @@ F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fc F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test b88aa28ff20238b394495b0795cddca1a62b98fa09b99e462a8abc572d04ee88 +F ext/fts5/test/fts5misc.test b1682a40061bc58dcc62bbad48938fc5214d2ac6a868a8899c0c3d1930f1115d F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9c10664416274df6f8da53ddd86f6356c9704ad798fd4034d2784ae433c1c056 -R 3605902adbab51926bad4083cbf76d2c -U drh -Z fc4daf336fe8a5609f55ae8abc7ca9b2 +P c4d7f9996ce4f5f6d08d83fc3abdb81b6825cfb556318f90c6896736a1da5175 +R 8f6bb730f0c3b63cb61a6b0c78a6a7c9 +U dan +Z 146061b654867fea67c05bd71b2b625a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6054597565..c281d62fd8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c4d7f9996ce4f5f6d08d83fc3abdb81b6825cfb556318f90c6896736a1da5175 +317c91edfc69d1d47e233bb6ac13934241742fda1ba03a88fd51bdf98fcbc463 From 78f9ba9774883d56ff6384c5173ff7e1ac42cb88 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 14 Aug 2024 17:58:46 +0000 Subject: [PATCH 0660/1030] Improved documentation for the sha3() SQL functions in the shathree.c extension in ext/misc. FossilOrigin-Name: 0ce609103eb35cfa26d9b6fa1769679be7e2b9032c37cc8c00a194fe355b06a4 --- ext/misc/shathree.c | 76 +++++++++++++++++++++++++++++++++++++++++++-- manifest | 14 ++++----- manifest.uuid | 2 +- 3 files changed, 82 insertions(+), 10 deletions(-) diff --git a/ext/misc/shathree.c b/ext/misc/shathree.c index 46a864af4e..5cb3198805 100644 --- a/ext/misc/shathree.c +++ b/ext/misc/shathree.c @@ -15,10 +15,20 @@ ** Two SQL functions are implemented: ** ** sha3(X,SIZE) -** sha3_query(Y,SIZE) +** sha3_agg(Y,SIZE) +** sha3_query(Z,SIZE) ** ** The sha3(X) function computes the SHA3 hash of the input X, or NULL if -** X is NULL. +** X is NULL. If inputs X is text, the UTF-8 rendering of that text is +** used to compute the hash. If X is a BLOB, then the binary data of the +** blob is used to compute the hash. If X is an integer or real number, +** then that number if converted into UTF-8 text and the hash is computed +** over the text. +** +** The sha3_agg(Y) function computes the SHA3 hash of all Y inputs. Since +** order is important for the hash, it is recommended that the Y expression +** by followed by an ORDER BY clause to guarantee that the inputs occur +** in the desired order. ** ** The sha3_query(Y) function evaluates all queries in the SQL statements of Y ** and returns a hash of their results. @@ -26,6 +36,68 @@ ** The SIZE argument is optional. If omitted, the SHA3-256 hash algorithm ** is used. If SIZE is included it must be one of the integers 224, 256, ** 384, or 512, to determine SHA3 hash variant that is computed. +** +** Because the sha3_agg() and sha3_query() functions compute a hash over +** multiple values, the values are encode to use include type information. +** +** In sha3_agg(), the sequence of bytes that gets hashed for each input +** Y depends on the datatype of Y: +** +** typeof(Y)='null' A single "N" is hashed. (One byte) +** +** typeof(Y)='integer' The data hash is the character "I" followed +** by an 8-byte big-endian binary of the +** 64-bit signed integer. (Nine bytes total.) +** +** typeof(Y)='real' The character "F" followed by an 8-byte +** big-ending binary of the double. (Nine +** bytes total.) +** +** typeof(Y)='text' The hash is over prefix "Tnnn:" followed +** by the UTF8 encoding of the text. The "nnn" +** in the prefix is the minimum-length decimal +** representation of the octet_length of the text. +** Notice the ":" at the end of the prefix, which +** is needed to separate the prefix from the +** content in cases where the content starts +** with a digit. +** +** typeof(Y)='blob' The hash is taken over prefix "Bnnn:" followed +** by the binary content of the blob. The "nnn" +** in the prefix is the mimimum-length decimal +** representation of the byte-length of the blob. +** +** According to the rules above, all of the following SELECT statements +** should return TRUE: +** +** SELECT sha3(1) = sha3('1'); +** +** SELECT sha3('hello') = sha3(x'68656c6c6f'); +** +** WITH a(x) AS (VALUES('xyzzy')) +** SELECT sha3_agg(x) = sha3('T5:xyzzy') FROM a; +** +** WITH a(x) AS (VALUES(x'010203')) +** SELECT sha3_agg(x) = sha3(x'42333a010203') FROM a; +** +** WITH a(x) AS (VALUES(0x123456)) +** SELECT sha3_agg(x) = sha3(x'490000000000123456') FROM a; +** +** WITH a(x) AS (VALUES(100.015625)) +** SELECT sha3_agg(x) = sha3(x'464059010000000000') FROM a; +** +** WITH a(x) AS (VALUES(NULL)) +** SELECT sha3_agg(x) = sha3('N') FROM a; +** +** +** In sha3_query(), individual column values are encoded as with +** sha3_agg(), but with the addition that a single "R" character is +** inserted at the start of each row. +** +** Note that sha3_agg() hashes rows for which Y is NULL. Add a FILTER +** clause if NULL rows should be excluded: +** +** SELECT sha3_agg(x ORDER BY rowid) FILTER(x NOT NULL) FROM t1; */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 diff --git a/manifest b/manifest index d30fe768b9..8ae446ea1a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sassert()\sin\sfts5\sthat\smight\sfail\swith\san\sexpression\slike\s"...\sNOT\s''". -D 2024-08-14T14:26:02.443 +C Improved\sdocumentation\sfor\sthe\ssha3()\sSQL\sfunctions\sin\sthe\sshathree.c\nextension\sin\sext/misc. +D 2024-08-14T17:58:46.321 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -415,7 +415,7 @@ F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d385 F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 F ext/misc/series.c d96e5aac21658c6b5d54f918ac140460ec7197734c1a4fba806950831a7b1e7a F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d -F ext/misc/shathree.c 24e890cb209272379f8d0823fb278d24bd3dca35d5ea565aa0b2794cd36d6197 +F ext/misc/shathree.c 811540cb7eb6f34ccf6ce6f6713c3896d38cbed20d46cb3c7c48d90e3251a7f4 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c c0aa7b80d6df45f7da59d912b38752bcac1af53a5766966160e6c5cdd397dbea F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c4d7f9996ce4f5f6d08d83fc3abdb81b6825cfb556318f90c6896736a1da5175 -R 8f6bb730f0c3b63cb61a6b0c78a6a7c9 -U dan -Z 146061b654867fea67c05bd71b2b625a +P 317c91edfc69d1d47e233bb6ac13934241742fda1ba03a88fd51bdf98fcbc463 +R 99e8cbe80cd01ac20616f63cdd8dbbda +U drh +Z c4d9af30409bcf77d9189a2bdac49004 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c281d62fd8..e1862fcd06 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -317c91edfc69d1d47e233bb6ac13934241742fda1ba03a88fd51bdf98fcbc463 +0ce609103eb35cfa26d9b6fa1769679be7e2b9032c37cc8c00a194fe355b06a4 From ff7200e75b360bddecfde77f22945925dc643808 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 14 Aug 2024 20:00:03 +0000 Subject: [PATCH 0661/1030] Doc typo correction reported in the forum. FossilOrigin-Name: 48900a867cc4b6d733d2a3533a553af3dfadf96d3ef7ddf4c72bd432e7bf0f76 --- ext/misc/shathree.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/misc/shathree.c b/ext/misc/shathree.c index 5cb3198805..72ca7278ca 100644 --- a/ext/misc/shathree.c +++ b/ext/misc/shathree.c @@ -97,7 +97,7 @@ ** Note that sha3_agg() hashes rows for which Y is NULL. Add a FILTER ** clause if NULL rows should be excluded: ** -** SELECT sha3_agg(x ORDER BY rowid) FILTER(x NOT NULL) FROM t1; +** SELECT sha3_agg(x ORDER BY rowid) FILTER(WHERE x NOT NULL) FROM t1; */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 diff --git a/manifest b/manifest index 8ae446ea1a..7f02d94ff2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sdocumentation\sfor\sthe\ssha3()\sSQL\sfunctions\sin\sthe\sshathree.c\nextension\sin\sext/misc. -D 2024-08-14T17:58:46.321 +C Doc\stypo\scorrection\sreported\sin\sthe\sforum. +D 2024-08-14T20:00:03.801 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -415,7 +415,7 @@ F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d385 F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 F ext/misc/series.c d96e5aac21658c6b5d54f918ac140460ec7197734c1a4fba806950831a7b1e7a F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d -F ext/misc/shathree.c 811540cb7eb6f34ccf6ce6f6713c3896d38cbed20d46cb3c7c48d90e3251a7f4 +F ext/misc/shathree.c 1821d90a0040c9accdbe3e3527d378d30569475d758aa70f6848924c0b430e8c F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c c0aa7b80d6df45f7da59d912b38752bcac1af53a5766966160e6c5cdd397dbea F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 317c91edfc69d1d47e233bb6ac13934241742fda1ba03a88fd51bdf98fcbc463 -R 99e8cbe80cd01ac20616f63cdd8dbbda -U drh -Z c4d9af30409bcf77d9189a2bdac49004 +P 0ce609103eb35cfa26d9b6fa1769679be7e2b9032c37cc8c00a194fe355b06a4 +R 4c6d39820af9105b6fe92615708e9032 +U stephan +Z 73f13f9927a4c31a02bcb28fc941f7df # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e1862fcd06..cc7e9327e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0ce609103eb35cfa26d9b6fa1769679be7e2b9032c37cc8c00a194fe355b06a4 +48900a867cc4b6d733d2a3533a553af3dfadf96d3ef7ddf4c72bd432e7bf0f76 From 3f138e1d8f7bd97e66bffd41a59c435ffd3bd1d5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 15 Aug 2024 15:23:33 +0000 Subject: [PATCH 0662/1030] Reinstate the --disable-tcl option on ./configure. [forum:/forumpost/845d4a57becc7f3c|Forum thread 845d4a57becc7f3c]. FossilOrigin-Name: de927016aadd7ee55d947134e3540907a3ea5ab4015034c5d088e3a84905d98a --- configure | 138 +++++++++++++++++++++++++++----------------------- configure.ac | 106 ++++++++++++++++++++------------------ manifest | 16 +++--- manifest.uuid | 2 +- 4 files changed, 141 insertions(+), 121 deletions(-) diff --git a/configure b/configure index 2c57d6ac3a..43952440a8 100755 --- a/configure +++ b/configure @@ -888,6 +888,7 @@ enable_libtool_lock enable_largefile with_tclsh with_tcl +enable_tcl with_wasi_sdk enable_threadsafe enable_releasemode @@ -1543,6 +1544,7 @@ Optional Features: optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-largefile omit support for large files + --disable-tcl do not build TCL extension --disable-threadsafe Disable mutexing --enable-releasemode Support libtool link to release mode --enable-tempstore Use an in-ram database for temporary tables @@ -3936,13 +3938,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3939: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3941: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3942: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3944: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3945: output\"" >&5) + (eval echo "\"\$as_me:3947: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5148,7 +5150,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5151 "configure"' > conftest.$ac_ext + echo '#line 5153 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6673,11 +6675,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6676: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6678: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6680: \$? = $ac_status" >&5 + echo "$as_me:6682: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7012,11 +7014,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7015: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7017: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7019: \$? = $ac_status" >&5 + echo "$as_me:7021: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7117,11 +7119,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7120: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7122: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7124: \$? = $ac_status" >&5 + echo "$as_me:7126: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7172,11 +7174,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7175: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7177: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7179: \$? = $ac_status" >&5 + echo "$as_me:7181: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9552,7 +9554,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9555 "configure" +#line 9557 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9648,7 +9650,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9651 "configure" +#line 9653 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10320,6 +10322,13 @@ if test "${with_tcl+set}" = set; then : withval=$with_tcl; fi +# Check whether --enable-tcl was given. +if test "${enable_tcl+set}" = set; then : + enableval=$enable_tcl; use_tcl=$enableval +else + use_tcl=yes +fi + if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then for ac_prog in tclsh8.6 tclsh tclsh9.0 do @@ -10370,60 +10379,69 @@ if test x"${with_tclsh}" != x -a x"${with_tclsh}" != xnone; then TCLSH_CMD=${with_tclsh} { $as_echo "$as_me:${as_lineno-$LINENO}: result: using tclsh at \"$TCLSH_CMD\"" >&5 $as_echo "using tclsh at \"$TCLSH_CMD\"" >&6; } - with_tcl=`${with_tclsh} <${srcdir}/tool/find_tclconfig.tcl` - if test x"${with_tcl}" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&5 + if test x"${use_tcl}" = "xyes"; then + with_tcl=`${with_tclsh} <${srcdir}/tool/find_tclconfig.tcl` + if test x"${with_tcl}" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&5 $as_echo "$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $TCLSH_CMD is unable to recommend a tclConfig.sh" >&5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $TCLSH_CMD is unable to recommend a tclConfig.sh" >&5 $as_echo "$as_me: WARNING: $TCLSH_CMD is unable to recommend a tclConfig.sh" >&2;} + fi fi fi -if test x"${with_tcl}" != x; then - if test -r ${with_tcl}/tclConfig.sh; then - tclconfig="${with_tcl}/tclConfig.sh" - else - for i in tcl8.6 tcl9.0 lib; do - if test -r ${with_tcl}/$i/tclConfig.sh; then - tclconfig=${with_tcl}/$i/tclConfig.sh - break - fi - done - fi - if test ! -r "${tclconfig}"; then - as_fn_error $? "no tclConfig.sh file found under ${with_tcl}" "$LINENO" 5 - fi -else - # If we have not yet found a tclConfig.sh file, look in $libdir whic is - # set automatically by autoconf or by the --prefix command-line option. - # See https://sqlite.org/forum/forumpost/e04e693439a22457 - libdir=${prefix}/lib - if test -r ${libdir}/tclConfig.sh; then - tclconfig=${libdir}/tclConfig.sh +if test x"${use_tcl}" = "xyes"; then + if test x"${with_tcl}" != x; then + if test -r ${with_tcl}/tclConfig.sh; then + tclconfig="${with_tcl}/tclConfig.sh" + else + for i in tcl8.6 tcl9.0 lib; do + if test -r ${with_tcl}/$i/tclConfig.sh; then + tclconfig=${with_tcl}/$i/tclConfig.sh + break + fi + done + fi + if test ! -r "${tclconfig}"; then + as_fn_error $? "no tclConfig.sh file found under ${with_tcl}" "$LINENO" 5 + fi else - for i in tcl8.6 tcl9.0 lib; do - if test -r ${libdir}/$i/tclConfig.sh; then - tclconfig=${libdir}/$i/tclConfig.sh - break - fi - done - fi - if test ! -r "${tclconfig}"; then - as_fn_error $? "cannot find a usable tclConfig.sh file. - Use --with-tcl=DIR to specify a directory where tclConfig.sh can be found. - SQLite does not use TCL internally, but TCL is required to build SQLite - from canonical sources and TCL is required for testing." "$LINENO" 5 + # If we have not yet found a tclConfig.sh file, look in $libdir whic is + # set automatically by autoconf or by the --prefix command-line option. + # See https://sqlite.org/forum/forumpost/e04e693439a22457 + libdir=${prefix}/lib + if test -r ${libdir}/tclConfig.sh; then + tclconfig=${libdir}/tclConfig.sh + else + for i in tcl8.6 tcl9.0 lib; do + if test -r ${libdir}/$i/tclConfig.sh; then + tclconfig=${libdir}/$i/tclConfig.sh + break + fi + done + fi + if test ! -r "${tclconfig}"; then + as_fn_error $? "cannot find a usable tclConfig.sh file. + Use --with-tcl=DIR to specify a directory where tclConfig.sh can be found. + SQLite does not use TCL internally, but TCL is required to build SQLite + from canonical sources and TCL is required for testing." "$LINENO" 5 + fi fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: loading TCL configuration from ${tclconfig}" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading TCL configuration from ${tclconfig}" >&5 $as_echo "loading TCL configuration from ${tclconfig}" >&6; } -. ${tclconfig} + . ${tclconfig} -# There are lots of other configuration variables that are provided by the -# tclConfig.sh file and that could be included here. But as of right now, -# TCL_LIB_SPEC is the only what that the Makefile uses. + # There are lots of other configuration variables that are provided by the + # tclConfig.sh file and that could be included here. But as of right now, + # TCL_LIB_SPEC is the only what that the Makefile uses. + HAVE_TCL=1 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unable to run tests because of --disable-tcl" >&5 +$as_echo "unable to run tests because of --disable-tcl" >&6; } + HAVE_TCL=0 +fi if test x"$TCLSH_CMD" == x; then TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} @@ -10445,14 +10463,10 @@ if test "$TCLSH_CMD" = "none"; then $as_echo "$as_me: WARNING: Warning: can't find tclsh - defaulting to non-amalgamation build." >&2;} USE_AMALGAMATION=0 TCLSH_CMD="tclsh" - HAVE_TCL=0 -else - HAVE_TCL=1 fi - if test "x${TCLLIBDIR+set}" != "xset" ; then for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` ; do if test -d $i ; then diff --git a/configure.ac b/configure.ac index 095df5e4f6..88a8654fc0 100644 --- a/configure.ac +++ b/configure.ac @@ -121,6 +121,8 @@ USE_AMALGAMATION=1 # AC_ARG_WITH(tclsh, AS_HELP_STRING([--with-tclsh=PATHNAME],[full pathname of a tclsh to use])) AC_ARG_WITH(tcl, AS_HELP_STRING([--with-tcl=DIR],[directory containing (tclConfig.sh)])) +AC_ARG_ENABLE(tcl, AS_HELP_STRING([--disable-tcl],[do not build TCL extension]), + [use_tcl=$enableval],[use_tcl=yes]) if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh tclsh9.0],none) with_tclsh=${TCLSH_CMD} @@ -128,58 +130,66 @@ fi if test x"${with_tclsh}" != x -a x"${with_tclsh}" != xnone; then TCLSH_CMD=${with_tclsh} AC_MSG_RESULT([using tclsh at "$TCLSH_CMD"]) - with_tcl=`${with_tclsh} <${srcdir}/tool/find_tclconfig.tcl` - if test x"${with_tcl}" != x; then - AC_MSG_RESULT([$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}]) - else - AC_MSG_WARN([$TCLSH_CMD is unable to recommend a tclConfig.sh]) + if test x"${use_tcl}" = "xyes"; then + with_tcl=`${with_tclsh} <${srcdir}/tool/find_tclconfig.tcl` + if test x"${with_tcl}" != x; then + AC_MSG_RESULT([$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}]) + else + AC_MSG_WARN([$TCLSH_CMD is unable to recommend a tclConfig.sh]) + fi fi fi -if test x"${with_tcl}" != x; then - if test -r ${with_tcl}/tclConfig.sh; then - tclconfig="${with_tcl}/tclConfig.sh" +if test x"${use_tcl}" = "xyes"; then + if test x"${with_tcl}" != x; then + if test -r ${with_tcl}/tclConfig.sh; then + tclconfig="${with_tcl}/tclConfig.sh" + else + for i in tcl8.6 tcl9.0 lib; do + if test -r ${with_tcl}/$i/tclConfig.sh; then + tclconfig=${with_tcl}/$i/tclConfig.sh + break + fi + done + fi + if test ! -r "${tclconfig}"; then + AC_MSG_ERROR([no tclConfig.sh file found under ${with_tcl}]) + fi else - for i in tcl8.6 tcl9.0 lib; do - if test -r ${with_tcl}/$i/tclConfig.sh; then - tclconfig=${with_tcl}/$i/tclConfig.sh - break - fi - done - fi - if test ! -r "${tclconfig}"; then - AC_MSG_ERROR([no tclConfig.sh file found under ${with_tcl}]) + # If we have not yet found a tclConfig.sh file, look in $libdir whic is + # set automatically by autoconf or by the --prefix command-line option. + # See https://sqlite.org/forum/forumpost/e04e693439a22457 + libdir=${prefix}/lib + if test -r ${libdir}/tclConfig.sh; then + tclconfig=${libdir}/tclConfig.sh + else + for i in tcl8.6 tcl9.0 lib; do + if test -r ${libdir}/$i/tclConfig.sh; then + tclconfig=${libdir}/$i/tclConfig.sh + break + fi + done + fi + if test ! -r "${tclconfig}"; then + AC_MSG_ERROR([cannot find a usable tclConfig.sh file. + Use --with-tcl=DIR to specify a directory where tclConfig.sh can be found. + SQLite does not use TCL internally, but TCL is required to build SQLite + from canonical sources and TCL is required for testing.]) + fi fi + AC_MSG_RESULT([loading TCL configuration from ${tclconfig}]) + . ${tclconfig} + AC_SUBST(TCL_INCLUDE_SPEC) + AC_SUBST(TCL_LIB_SPEC) + AC_SUBST(TCL_STUB_LIB_SPEC) + # There are lots of other configuration variables that are provided by the + # tclConfig.sh file and that could be included here. But as of right now, + # TCL_LIB_SPEC is the only what that the Makefile uses. + HAVE_TCL=1 else - # If we have not yet found a tclConfig.sh file, look in $libdir whic is - # set automatically by autoconf or by the --prefix command-line option. - # See https://sqlite.org/forum/forumpost/e04e693439a22457 - libdir=${prefix}/lib - if test -r ${libdir}/tclConfig.sh; then - tclconfig=${libdir}/tclConfig.sh - else - for i in tcl8.6 tcl9.0 lib; do - if test -r ${libdir}/$i/tclConfig.sh; then - tclconfig=${libdir}/$i/tclConfig.sh - break - fi - done - fi - if test ! -r "${tclconfig}"; then - AC_MSG_ERROR([cannot find a usable tclConfig.sh file. - Use --with-tcl=DIR to specify a directory where tclConfig.sh can be found. - SQLite does not use TCL internally, but TCL is required to build SQLite - from canonical sources and TCL is required for testing.]) - fi + AC_MSG_RESULT([unable to run tests because of --disable-tcl]) + HAVE_TCL=0 fi -AC_MSG_RESULT([loading TCL configuration from ${tclconfig}]) -. ${tclconfig} -AC_SUBST(TCL_INCLUDE_SPEC) -AC_SUBST(TCL_LIB_SPEC) -AC_SUBST(TCL_STUB_LIB_SPEC) -# There are lots of other configuration variables that are provided by the -# tclConfig.sh file and that could be included here. But as of right now, -# TCL_LIB_SPEC is the only what that the Makefile uses. - +AC_SUBST(HAVE_TCL) if test x"$TCLSH_CMD" == x; then TCLSH_CMD=${TCL_EXEC_PREFIX}/bin/tclsh${TCL_VERSION} if test ! -x ${TCLSH_CMD}; then @@ -198,12 +208,8 @@ if test "$TCLSH_CMD" = "none"; then AC_MSG_WARN([Warning: can't find tclsh - defaulting to non-amalgamation build.]) USE_AMALGAMATION=0 TCLSH_CMD="tclsh" - HAVE_TCL=0 -else - HAVE_TCL=1 fi AC_SUBST(TCLSH_CMD) -AC_SUBST(HAVE_TCL) AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin]) if test "x${TCLLIBDIR+set}" != "xset" ; then diff --git a/manifest b/manifest index 7f02d94ff2..e5f56697c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Doc\stypo\scorrection\sreported\sin\sthe\sforum. -D 2024-08-14T20:00:03.801 +C Reinstate\sthe\s--disable-tcl\soption\son\s./configure.\n[forum:/forumpost/845d4a57becc7f3c|Forum\sthread\s845d4a57becc7f3c]. +D 2024-08-15T15:23:33.404 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 8c74221e3e3af939270c27f0600281a5485ac2e5014dd7581b056e24a528d625 x -F configure.ac 9a3d92b38ad56456d09c1272f83131794f73110437f0f53fb94c90ce0d7a351a +F configure 6255dfc962e2e5ed0a16ccc5aa39444f693692721ffe1d365ba091d8fe21c7e2 x +F configure.ac bce81466694af143776724dd483cbc9e1f1288e41d2d0f46e56965be3deacfc5 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0ce609103eb35cfa26d9b6fa1769679be7e2b9032c37cc8c00a194fe355b06a4 -R 4c6d39820af9105b6fe92615708e9032 -U stephan -Z 73f13f9927a4c31a02bcb28fc941f7df +P 48900a867cc4b6d733d2a3533a553af3dfadf96d3ef7ddf4c72bd432e7bf0f76 +R 13d05cfcaef8f5c3cbdcd475a1199700 +U drh +Z 4a60d69549ab00c925ad79ae1e45201c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cc7e9327e6..ac4f295436 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48900a867cc4b6d733d2a3533a553af3dfadf96d3ef7ddf4c72bd432e7bf0f76 +de927016aadd7ee55d947134e3540907a3ea5ab4015034c5d088e3a84905d98a From 7c5a829025914550de138aab2a8cf3f8090b7c3e Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 15 Aug 2024 15:31:46 +0000 Subject: [PATCH 0663/1030] Improved help message for --disable-tcl on the configure script. FossilOrigin-Name: 96e6cfb211f7f1aab50f997f4bc61dfb9701beb720c59bc413a4285c1ae5e20d --- configure | 31 ++++++++++++++++--------------- configure.ac | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/configure b/configure index 43952440a8..50d9e2b3d0 100755 --- a/configure +++ b/configure @@ -1544,7 +1544,8 @@ Optional Features: optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-largefile omit support for large files - --disable-tcl do not build TCL extension + --disable-tcl omit building accessory programs that require + TCL-dev --disable-threadsafe Disable mutexing --enable-releasemode Support libtool link to release mode --enable-tempstore Use an in-ram database for temporary tables @@ -3938,13 +3939,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3941: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3942: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3944: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3945: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3947: output\"" >&5) + (eval echo "\"\$as_me:3948: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5150,7 +5151,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5153 "configure"' > conftest.$ac_ext + echo '#line 5154 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6675,11 +6676,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6678: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6679: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6682: \$? = $ac_status" >&5 + echo "$as_me:6683: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7014,11 +7015,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7017: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7018: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7021: \$? = $ac_status" >&5 + echo "$as_me:7022: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7119,11 +7120,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7122: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7123: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7126: \$? = $ac_status" >&5 + echo "$as_me:7127: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7174,11 +7175,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7177: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7178: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7181: \$? = $ac_status" >&5 + echo "$as_me:7182: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9554,7 +9555,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9557 "configure" +#line 9558 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9650,7 +9651,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9653 "configure" +#line 9654 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/configure.ac b/configure.ac index 88a8654fc0..4f95a5c08c 100644 --- a/configure.ac +++ b/configure.ac @@ -121,7 +121,7 @@ USE_AMALGAMATION=1 # AC_ARG_WITH(tclsh, AS_HELP_STRING([--with-tclsh=PATHNAME],[full pathname of a tclsh to use])) AC_ARG_WITH(tcl, AS_HELP_STRING([--with-tcl=DIR],[directory containing (tclConfig.sh)])) -AC_ARG_ENABLE(tcl, AS_HELP_STRING([--disable-tcl],[do not build TCL extension]), +AC_ARG_ENABLE(tcl, AS_HELP_STRING([--disable-tcl],[omit building accessory programs that require TCL-dev]), [use_tcl=$enableval],[use_tcl=yes]) if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh tclsh9.0],none) diff --git a/manifest b/manifest index e5f56697c4..22a05bc11b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reinstate\sthe\s--disable-tcl\soption\son\s./configure.\n[forum:/forumpost/845d4a57becc7f3c|Forum\sthread\s845d4a57becc7f3c]. -D 2024-08-15T15:23:33.404 +C Improved\shelp\smessage\sfor\s--disable-tcl\son\sthe\sconfigure\sscript. +D 2024-08-15T15:31:46.143 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 6255dfc962e2e5ed0a16ccc5aa39444f693692721ffe1d365ba091d8fe21c7e2 x -F configure.ac bce81466694af143776724dd483cbc9e1f1288e41d2d0f46e56965be3deacfc5 +F configure 2e5058c2ba2c6b50a01cf50c158180c4ec969b2068c2e361dfbfc875ec3f9d1c x +F configure.ac b7e26a699a2ffc5eb7a25636f32755c27bbb665777b68ef35a90c1ee9bd9d469 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48900a867cc4b6d733d2a3533a553af3dfadf96d3ef7ddf4c72bd432e7bf0f76 -R 13d05cfcaef8f5c3cbdcd475a1199700 +P de927016aadd7ee55d947134e3540907a3ea5ab4015034c5d088e3a84905d98a +R fa965b3cf027827ab805def1d12c22e4 U drh -Z 4a60d69549ab00c925ad79ae1e45201c +Z a05ca4fe471b9ed0243c4a5725784485 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ac4f295436..dd4cda6e20 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de927016aadd7ee55d947134e3540907a3ea5ab4015034c5d088e3a84905d98a +96e6cfb211f7f1aab50f997f4bc61dfb9701beb720c59bc413a4285c1ae5e20d From 189c41221d499fb97bd0bac6d1e1f955b8a1afab Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 15 Aug 2024 18:50:13 +0000 Subject: [PATCH 0664/1030] Further tests and fixes for this branch. FossilOrigin-Name: d27985245a0e8c0d6b04323c98b26b6a8fb4e489fa8f5f3234252c7c198f23c8 --- ext/fts5/fts5_main.c | 22 +++++++----------- ext/fts5/test/fts5ah.test | 11 +++++++++ ext/fts5/test/fts5al.test | 10 +++++++++ ext/fts5/test/fts5faultI.test | 41 +++++++++++++++++++++++++++++++++- ext/fts5/test/fts5misc.test | 8 +++---- ext/fts5/test/fts5simple.test | 29 ++++++++++++++++++++++++ ext/fts5/test/fts5trigram.test | 31 +++++++++++++++++++++++++ manifest | 24 ++++++++++---------- manifest.uuid | 2 +- 9 files changed, 146 insertions(+), 32 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 80fe73a2fa..d03bd2513e 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -630,7 +630,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ if( bSeenRank ) continue; idxStr[iIdxStr++] = 'r'; bSeenRank = 1; - }else if( iCol>=0 ){ + }else{ nSeenMatch++; idxStr[iIdxStr++] = 'M'; sqlite3_snprintf(6, &idxStr[iIdxStr], "%d", iCol); @@ -1468,13 +1468,7 @@ static int fts5FilterMethod( int iIdxStr = 0; Fts5Expr *pExpr = 0; - if( pConfig->bLock ){ - pTab->p.base.zErrMsg = sqlite3_mprintf( - "recursively defined fts5 content table" - ); - return SQLITE_ERROR; - } - + assert( pConfig->bLock==0 ); if( pCsr->ePlan ){ fts5FreeCursorComponents(pCsr); memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr)); @@ -1992,7 +1986,6 @@ static int fts5UpdateMethod( } } - assert( eType1==SQLITE_INTEGER || eType1==SQLITE_NULL ); if( eType0!=SQLITE_INTEGER ){ /* An INSERT statement. If the conflict-mode is REPLACE, first remove ** the current entry (if any). */ @@ -2186,11 +2179,11 @@ static int fts5ApiColumnText( int rc = SQLITE_OK; Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); + + assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL ); if( iCol<0 || iCol>=pTab->pConfig->nCol ){ rc = SQLITE_RANGE; - }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) - || pCsr->ePlan==FTS5_PLAN_SPECIAL - ){ + }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) ){ *pz = 0; *pn = 0; }else{ @@ -2701,11 +2694,11 @@ static int fts5ApiColumnLocale( *pzLocale = 0; *pnLocale = 0; + assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL ); if( iCol<0 || iCol>=pConfig->nCol ){ rc = SQLITE_RANGE; }else if( pConfig->abUnindexed[iCol]==0 - && pCsr->ePlan!=FTS5_PLAN_SPECIAL && pConfig->eContent!=FTS5_CONTENT_NONE && pConfig->bLocale ){ @@ -2823,6 +2816,7 @@ static void fts5ApiInvoke( sqlite3_value **argv ){ assert( pCsr->pAux==0 ); + assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL ); pCsr->pAux = pAux; pAux->xFunc(&sFts5Api, (Fts5Context*)pCsr, context, argc, argv); pCsr->pAux = 0; @@ -2866,7 +2860,7 @@ static void fts5ApiCallback( iCsrId = sqlite3_value_int64(argv[0]); pCsr = fts5CursorFromCsrid(pAux->pGlobal, iCsrId); - if( pCsr==0 || pCsr->ePlan==0 ){ + if( pCsr==0 || (pCsr->ePlan==0 || pCsr->ePlan==FTS5_PLAN_SPECIAL) ){ fts5ResultError(context, "no such cursor: %lld", iCsrId); }else{ sqlite3_vtab *pTab = pCsr->base.pVtab; diff --git a/ext/fts5/test/fts5ah.test b/ext/fts5/test/fts5ah.test index bc80057833..bf9c9e9dbc 100644 --- a/ext/fts5/test/fts5ah.test +++ b/ext/fts5/test/fts5ah.test @@ -163,6 +163,17 @@ do_execsql_test 1.8.2 { SELECT count(*) FROM t1 WHERE t1 MATCH 'x' AND rowid < 'text'; } {10000} +do_execsql_test 1.8.3 { + SELECT count(*) FROM t1 WHERE t1 MATCH 'x' AND rowid<5000 AND rowid < 'text'; +} {4999} +do_execsql_test 1.8.4 { + SELECT count(*) FROM t1 WHERE t1 MATCH 'x' AND rowid>5000 AND rowid > 'text'; +} {0} + +do_catchsql_test 1.9 { + SELECT * FROM t1('*xy'); +} {1 {unknown special query: xy}} + } ;# foreach_detail_mode #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t1_data} {puts $r} diff --git a/ext/fts5/test/fts5al.test b/ext/fts5/test/fts5al.test index b344e0d2ea..7187ad67c7 100644 --- a/ext/fts5/test/fts5al.test +++ b/ext/fts5/test/fts5al.test @@ -293,6 +293,16 @@ do_catchsql_test 4.4.4 { SELECT *, rank FROM t3 WHERE t3 MATCH 'a' AND rank MATCH NULL } {1 {parse error in rank function: }} +# Check that the second and subsequent rank= constraints are ignored. +# +do_catchsql_test 4.3.3 { + SELECT *, rank FROM t3 + WHERE t3 MATCH 'a' AND + rank MATCH 'nosuch()' AND + rank MATCH 'rowidmod(3)' + ORDER BY rank ASC +} {1 {unable to use function MATCH in the requested context}} + } ;# foreach_detail_mode diff --git a/ext/fts5/test/fts5faultI.test b/ext/fts5/test/fts5faultI.test index 0d5ef4a54a..b64f27c1fc 100644 --- a/ext/fts5/test/fts5faultI.test +++ b/ext/fts5/test/fts5faultI.test @@ -60,7 +60,46 @@ do_faultsim_test 3 -faults oom* -prep { SELECT fts5_columnlocale(t1, 0) FROM t1('unicode*'); } } -test { - faultsim_test_result {0 {{}}} + faultsim_test_result {0 {{}}} {1 SQLITE_NOMEM} +} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 4.0 { + CREATE VIRTUAL TABLE w1 USING fts5(a); +} +faultsim_save_and_close + +do_faultsim_test 4 -faults oom* -prep { + faultsim_restore_and_reopen + execsql { + BEGIN; + INSERT INTO w1 VALUES('token token token'); + } +} -body { + execsql { + INSERT INTO w1(w1, rank) VALUES('rank', 'bm25()'); + } +} -test { + faultsim_test_result {0 {}} +} + +do_faultsim_test 5 -faults oom* -prep { + faultsim_restore_and_reopen + execsql { + BEGIN; + INSERT INTO w1 VALUES('one'); + SAVEPOINT one; + INSERT INTO w1 VALUES('two'); + ROLLBACK TO one; + } + +} -body { + execsql { + INSERT INTO w1 VALUES('string'); + } +} -test { + faultsim_test_result {0 {}} } finish_test diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index a9806ff8bc..e5f43d69c5 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -35,21 +35,21 @@ do_catchsql_test 1.1.2 { do_catchsql_test 1.2.1 { SELECT highlight(t1, 4, '', '') FROM t1('*id'); -} {0 {{}}} +} {1 {no such cursor: 4}} do_catchsql_test 1.2.2 { SELECT a FROM t1 WHERE rank = (SELECT highlight(t1, 4, '', '') FROM t1('*id')); -} {0 {}} +} {1 {no such cursor: 6}} do_catchsql_test 1.3.1 { SELECT highlight(t1, 4, '', '') FROM t1('*reads'); -} {1 {no such cursor: 2}} +} {1 {no such cursor: 1}} do_catchsql_test 1.3.2 { SELECT a FROM t1 WHERE rank = (SELECT highlight(t1, 4, '', '') FROM t1('*reads')); -} {1 {no such cursor: 2}} +} {1 {no such cursor: 1}} db close sqlite3 db test.db diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 6384095067..60ccb5a9c5 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -480,4 +480,33 @@ do_execsql_test 22.0 { do_catchsql_test 22.1 {SELECT * FROM x1('')} {1 {fts5: syntax error near ""}} do_catchsql_test 22.2 {SELECT * FROM x1(NULL)} {1 {fts5: syntax error near ""}} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 23.0 { + CREATE VIRTUAL TABLE x1 USING fts5(x); + SELECT count(*) FROM x1_data; +} {2} + +do_execsql_test 23.1 { + BEGIN; + INSERT INTO x1 VALUES('a b c d'); + INSERT INTO x1 VALUES('a b c d'); + INSERT INTO x1 VALUES('a b c d'); +} + +do_execsql_test 23.2 { + SELECT count(*) FROM x1_data; +} {2} + +do_execsql_test 23.3 { + INSERT INTO x1(x1) VALUES('flush'); + SELECT count(*) FROM x1_data; +} {3} + +do_execsql_test 23.4 { + ROLLBACK; + SELECT count(*) FROM x1_data; +} {2} + + finish_test diff --git a/ext/fts5/test/fts5trigram.test b/ext/fts5/test/fts5trigram.test index 752686620c..b76dbda063 100644 --- a/ext/fts5/test/fts5trigram.test +++ b/ext/fts5/test/fts5trigram.test @@ -200,6 +200,12 @@ do_eqp_test 6.3 { do_eqp_test 6.4 { SELECT * FROM ci1 WHERE x GLOB ? } {VIRTUAL TABLE INDEX 0:G0} +do_eqp_test 6.5 { + SELECT * FROM ci1 WHERE x < ? +} {{SCAN ci1 VIRTUAL TABLE INDEX 0:}} +do_eqp_test 6.6 { + SELECT * FROM ci0 WHERE x < ? +} {{SCAN ci0 VIRTUAL TABLE INDEX 0:}} reset_db do_execsql_test 7.0 { @@ -256,4 +262,29 @@ do_execsql_test 8.3 { {[abcde]} } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 9.0 { + CREATE VIRTUAL TABLE t1 USING fts5( + a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, + tokenize=trigram + ); + + INSERT INTO t1(rowid, a12) VALUES(111, 'thats a tricky case though'); + INSERT INTO t1(rowid, a12) VALUES(222, 'the query planner cannot do'); +} + +do_execsql_test 9.1 { + SELECT rowid FROM t1 WHERE a12 LIKE '%tricky%' +} {111} + +do_execsql_test 9.2 { + SELECT rowid FROM t1 WHERE a12 LIKE '%tricky%' AND a12 LIKE '%case%' +} {111} + +do_execsql_test 9.3 { + SELECT rowid FROM t1 WHERE a12 LIKE NULL +} {} + + finish_test diff --git a/manifest b/manifest index 318eb8554f..4071c7a84b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\stests\sfor\sthe\snew\scode\son\sthis\sbranch. -D 2024-08-13T21:15:43.313 +C Further\stests\sand\sfixes\sfor\sthis\sbranch. +D 2024-08-15T18:50:13.581 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215 F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c f8eae223ce93aad7c503a76872267e0e6d288b54ccb4d9bfe894c4ed365f8d3c +F ext/fts5/fts5_main.c 21160a392addf6921e380090984aed88bbb6d88c33a7d03187997c9c8f666e49 F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -119,11 +119,11 @@ F ext/fts5/test/fts5ad.test 058e616612964e61d19f70295f0e6eaedceb4b29b1fbf4f85961 F ext/fts5/test/fts5ae.test 3d49edbd50bb0684199a2e7568aeb30d1d29718f5c0f61751983740fa836d15f F ext/fts5/test/fts5af.test ae81f08b8da4c5f9b3ec1ef538a4ab6b7c278e92fa9058d6dc5d842c5d9771b9 F ext/fts5/test/fts5ag.test 6667807b5d3fbf460892e756763fbe3d87a2fffe345a06514ba010ca6f6641f7 -F ext/fts5/test/fts5ah.test ac327281c8910cf9b85738a2655003fd0c6a8a76189ef34f3d086b8f9e54263b +F ext/fts5/test/fts5ah.test e1f01314b35745a30e1b494b46045b82005d71cae74f1ebd9f1338566b77f9fc F ext/fts5/test/fts5ai.test cbe26d78030998f535bc103f37915350b137a822c71a9db439a077d7666a3539 F ext/fts5/test/fts5aj.test 53c8508dab4acca3e691a4c51eca4b3b018319ab8635e540103d5bbdc91543c9 F ext/fts5/test/fts5ak.test 25e2f8afdcff30d98ca9dee8c5cacca2f26db17501c9401f16d99ee036f70e8d -F ext/fts5/test/fts5al.test 842c50fd9b287e3fa988dfcab436b27c432866f7406a56aaf3c67f316952cc02 +F ext/fts5/test/fts5al.test f0e655606771b2b5dbaf70e7f0044d560257cf3531d5eea40df58d0d7add8c39 F ext/fts5/test/fts5alter.test ebbee06419c2d3cee5ef7ebb5ba6a9996f1aa374035361c0acd37368cc5f64f3 F ext/fts5/test/fts5auto.test 2278de323172ced485d2844cb1357d00036ac1665f27e70fa1a48ce57bf31c2c F ext/fts5/test/fts5aux.test 27210687338133b1e9bc0dd669322fca59fd432439f40b126895e2d7c2f899d6 @@ -177,7 +177,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5faultI.test bfaf9b94888ef604bd8034a3edd1bbdeb626c07337376b9b66d6171b28ee7931 +F ext/fts5/test/fts5faultI.test 6aa7c42a9c14f00b90e7b33412d98153c0ca1534c5ab11db25e39b4d63f88795 F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -191,7 +191,7 @@ F ext/fts5/test/fts5locale.test f58ac6ab539d3813556646f7d4b1e19f7e3b1a56ca443934 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test 946abba0b45298e3d9d7a98e19eb4ac5384e8f2848ce1888c7ab3f62645efd2f +F ext/fts5/test/fts5misc.test 281a55fc3b41543c4a7fc30b0d4c703a819ce659f04553a4840a5dc8ec277397 F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -225,7 +225,7 @@ F ext/fts5/test/fts5secure6.test 74bf04733cc523bccca519bb03d3b4e2ed6f6e3db7c59bf F ext/fts5/test/fts5secure7.test fd03d0868d64340a1db8615b02e5508fea409de13910114e4f19eaefc120777a F ext/fts5/test/fts5secure8.test e68c0ac4447f415ff3e4e82531e99548289286f9f3a29c8cd53036113fe28602 F ext/fts5/test/fts5securefault.test c34a28c7cd2f31a8b8907563889e1329a97da975c08df2d951422bcef8e2ebc5 -F ext/fts5/test/fts5simple.test 847fb828262328744733847dc76d6b5d4a6bd4c5d9b282cb819f6504340e061a +F ext/fts5/test/fts5simple.test ed7c3815c9fa1c16166258cb98edb2e014c63c7589958d76c5487df0df913d61 F ext/fts5/test/fts5simple2.test d10d963a357b8ec77b99032e4c816459b4dbdb1f6eee25eada7ef3ed245cb2dc F ext/fts5/test/fts5simple3.test 146ec3dc8f5763d6212641c9f0a2f1cba41679353d2add7b963beceb115dc7f4 F ext/fts5/test/fts5synonym.test becc8cea6cfc958a50b30c572c68cbfdf7455971d0fe988202ce67638d2c6cf6 @@ -235,7 +235,7 @@ F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test 7937cec672b148223fff8746d21d3e7ed0965fd7caf35ccdc888a005bb452f98 F ext/fts5/test/fts5tokenizer2.test ddb8b10fbe4b84b2a75812671f127774c1d2e3e2bf82d2e0e4f0bb1cd8a2b2d6 F ext/fts5/test/fts5tokenizer3.test eea778f7bb7024c3e904e28915f9d53286141671b138722148be22a9c758bdc3 -F ext/fts5/test/fts5trigram.test be914555deb8504dde682bd5aa343d00c4da37dfad20709a5bac30d5f97f2ef5 +F ext/fts5/test/fts5trigram.test f99fc0235e967826e556de9aee959d3cb8eae2e9abff37b5fe2732fd7052dac2 F ext/fts5/test/fts5trigram2.test 6fde9de7f63a6b4aa18dc731be56dbd6be4e755c9b13dcd55479e200d1df0e61 F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 @@ -2208,8 +2208,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P def5243a7b4f1d50427ba607d31332db2d6ac34b181b0cbd2ed4911064f5637a -R 4b120525083c8e765eb88ddcda2d97e2 +P 00792e807f1dde750e6ac9f9b0095cf60b9fa6ff7cf4b14440600a21de2ee61a +R 26644a6a4d254f87e6d210a1b5d5866f U dan -Z aad3d9cc9413a3fb75b2e684b7b3f795 +Z 43505ba0ff6d8eb4d2d57750e91b3ee5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 154fd54b3f..4334ad1f96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00792e807f1dde750e6ac9f9b0095cf60b9fa6ff7cf4b14440600a21de2ee61a +d27985245a0e8c0d6b04323c98b26b6a8fb4e489fa8f5f3234252c7c198f23c8 From 41ebf965cd1e80d72dfb4535e9c0143fed0435c7 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 15 Aug 2024 20:33:05 +0000 Subject: [PATCH 0665/1030] Extra tests. FossilOrigin-Name: fb257540d32ced4a5fe0759d3ad9c1b36fd2b7d64d93cb0a0ecdb48355a68b7a --- ext/fts5/fts5Int.h | 2 +- ext/fts5/fts5_main.c | 3 ++- ext/fts5/test/fts5_common.tcl | 5 ++++ ext/fts5/test/fts5faultI.test | 44 +++++++++++++++++++++++++++++++ ext/fts5/test/fts5misc.test | 20 ++++++++++++++ ext/fts5/test/fts5origintext.test | 9 +++++++ manifest | 22 ++++++++-------- manifest.uuid | 2 +- 8 files changed, 93 insertions(+), 14 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 7e42ea82c1..7e41119572 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -345,7 +345,7 @@ char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); void sqlite3Fts5Put32(u8*, int); int sqlite3Fts5Get32(const u8*); -#define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32) +#define FTS5_POS2COLUMN(iPos) (int)((iPos >> 32) & 0x7FFFFFFF) #define FTS5_POS2OFFSET(iPos) (int)(iPos & 0x7FFFFFFF) typedef struct Fts5PoslistReader Fts5PoslistReader; diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index d03bd2513e..06833a98b2 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2330,7 +2330,8 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){ aInst[0] = iBest; aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos); aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos); - if( aInst[1]<0 || aInst[1]>=nCol ){ + assert( aInst[1]>=0 ); + if( aInst[1]>=nCol ){ rc = FTS5_CORRUPT; break; } diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index b78064e8d8..8ea87dbdd1 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -51,6 +51,10 @@ proc fts5_test_poslist2 {cmd} { sort_poslist $res } +proc fts5_test_insttoken {cmd iInst iToken} { + $cmd xInstToken $iInst $iToken +} + proc fts5_test_collist {cmd} { set res [list] @@ -181,6 +185,7 @@ proc fts5_aux_test_functions {db} { fts5_test_poslist fts5_test_poslist2 fts5_test_collist + fts5_test_insttoken fts5_test_tokenize fts5_test_rowcount fts5_test_rowid diff --git a/ext/fts5/test/fts5faultI.test b/ext/fts5/test/fts5faultI.test index b64f27c1fc..33c93c63af 100644 --- a/ext/fts5/test/fts5faultI.test +++ b/ext/fts5/test/fts5faultI.test @@ -102,5 +102,49 @@ do_faultsim_test 5 -faults oom* -prep { faultsim_test_result {0 {}} } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 5.0 { + CREATE VIRTUAL TABLE w1 USING fts5(a); + INSERT INTO w1 VALUES('one two three'); +} +fts5_aux_test_functions db + +do_faultsim_test 5 -faults oom* -prep { +} -body { + execsql { + SELECT fts5_test_insttoken(w1, 0, 0) FROM w1('two'); + } +} -test { + faultsim_test_result {0 two} {1 SQLITE_NOMEM} +} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 6.0 { + CREATE VIRTUAL TABLE w1 USING fts5(a); + INSERT INTO w1 VALUES('one two three'); +} +fts5_aux_test_functions db +faultsim_save_and_close + +do_faultsim_test 6 -faults oom* -prep { + faultsim_restore_and_reopen + db eval { + BEGIN; + INSERT INTO w1 VALUES('four five six'); + SAVEPOINT abc; + INSERT INTO w1 VALUES('seven eight nine'); + SAVEPOINT def; + INSERT INTO w1 VALUES('ten eleven twelve'); + } +} -body { + execsql { + RELEASE abc; + } +} -test { + faultsim_test_result {0 {}} +} + finish_test diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index e5f43d69c5..4b943c3488 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -571,5 +571,25 @@ do_execsql_test 20.5 { SELECT rowid FROM x1 WHERE x1 MATCH 'z' OR (x1 MATCH 'a' AND x1 MATCH 'd'); } {3 1} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 21.0 { + CREATE TABLE t1(ii INTEGER, x TEXT, y TEXT); + CREATE VIRTUAL TABLE xyz USING fts5(content_rowid=ii, content=t1, x, y); + INSERT INTO t1 VALUES(1, 'one', 'i'); + INSERT INTO t1 VALUES(2, 'two', 'ii'); + INSERT INTO t1 VALUES(3, 'tree', 'iii'); + INSERT INTO xyz(xyz) VALUES('rebuild'); +} + +do_execsql_test 21.1 { + UPDATE xyz SET y='TWO' WHERE rowid=2; + UPDATE t1 SET y='TWO' WHERE ii=2; +} + +do_execsql_test 21.2 { + PRAGMA integrity_check +} {ok} + finish_test diff --git a/ext/fts5/test/fts5origintext.test b/ext/fts5/test/fts5origintext.test index cc9d99e2d9..1612b0d7f4 100644 --- a/ext/fts5/test/fts5origintext.test +++ b/ext/fts5/test/fts5origintext.test @@ -291,6 +291,15 @@ do_execsql_test 6.3 { SELECT rowid, tokens(ft) FROM ft('Three*'); } {1 {{}} 2 {{}}} +fts5_aux_test_functions db +do_catchsql_test 6.4 { + SELECT fts5_test_insttoken(ft, -1, 0) FROM ft('one'); +} {1 SQLITE_RANGE} + +do_catchsql_test 6.5 { + SELECT fts5_test_insttoken(ft, 1, 0) FROM ft('one'); +} {1 SQLITE_RANGE} + } finish_test diff --git a/manifest b/manifest index 4071c7a84b..28ab5391d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\stests\sand\sfixes\sfor\sthis\sbranch. -D 2024-08-15T18:50:13.581 +C Extra\stests. +D 2024-08-15T20:33:05.956 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,14 +93,14 @@ F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6d F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h 4c6998c6186268b4dbe9baef2c0d2ab974bd90996d61d4dbe801367249be6de4 -F ext/fts5/fts5Int.h 776b21159eef8d30379e5bc4627eae9e841d36e43f19dc8908c786e62aaf9e38 +F ext/fts5/fts5Int.h 26a71a09cefa4ef6b4516b204ed48da3e1380970a19b3482eea7c5d805655360 F ext/fts5/fts5_aux.c 12cd2512f869217c38b70c31de5b5f741812734fafa80f55b32ea9bbd96e2152 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215549a24a2a F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 21160a392addf6921e380090984aed88bbb6d88c33a7d03187997c9c8f666e49 +F ext/fts5/fts5_main.c 23029229021240dc21a69eb749305316103d183375413e2090c064b74b03b7f8 F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -111,7 +111,7 @@ F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d0988 F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl 48c0855d235a2f141e5519d3170bad7cddcc53ad3a16ac8ef952ba61048c2958 +F ext/fts5/test/fts5_common.tcl c5aa7cf7148b6dcffb5b61520ae18212baf169936af734ab265143f59db328fe F ext/fts5/test/fts5aa.test 015c81b84d53bfcedd77d624202c8b02e9f0cbbb4b51688e3a9c9f90bccbb4ac F ext/fts5/test/fts5ab.test 4bdb619fee409e11417e8827e320b857e42e926a01a0408fc9f143ec870a6ced F ext/fts5/test/fts5ac.test 4a73626de86f3d17c95738034880c4f0de8d54741fb943d819b528373657e59b @@ -177,7 +177,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5faultI.test 6aa7c42a9c14f00b90e7b33412d98153c0ca1534c5ab11db25e39b4d63f88795 +F ext/fts5/test/fts5faultI.test d9e8c4b0b42910fa447a0e148236def618e7decbf3a334c7933a95e36410f772 F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -191,7 +191,7 @@ F ext/fts5/test/fts5locale.test f58ac6ab539d3813556646f7d4b1e19f7e3b1a56ca443934 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test 281a55fc3b41543c4a7fc30b0d4c703a819ce659f04553a4840a5dc8ec277397 +F ext/fts5/test/fts5misc.test b49a3afbda6de02970560c1cd3b804a4896b9f30ce5d75a5f215fa972537b26b F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -199,7 +199,7 @@ F ext/fts5/test/fts5onepass.test f9b7d9b2c334900c6542a869760290e2ab5382af8fbd618 F ext/fts5/test/fts5optimize.test 264b9101721c17d06d1d174feb743fda3ddc89fad41dee980fef821428258e47 F ext/fts5/test/fts5optimize2.test 795d4ae5f66a7239cf8d5aef4c2ea96aeb8bcd907bd9be0cfe22064fc71a44ed F ext/fts5/test/fts5optimize3.test 1653029284e10e0715246819893ba30565c4ead0d0fc470adae92c353ea857d3 -F ext/fts5/test/fts5origintext.test 87c34c78f201b1e22ac93ac6bbe6196dde59f0a7266b1aeb938604a0eb9d5552 +F ext/fts5/test/fts5origintext.test 002abba00b334cb4b3f957f940f75b9ab53f4caae97aa753e19da285c245e463 F ext/fts5/test/fts5origintext2.test f4505ff79bf7369f2b8b10b9cef7476049d844e20b37f29cad3a8b8d5ac6f9ba F ext/fts5/test/fts5origintext3.test 45c33cf0c91a9ca0e36d298462db3edc7c8fe45fd185649a9dbfd66bb670058b F ext/fts5/test/fts5origintext4.test 0d3ef0a8038f471dbc83001c34fe5f7ae39b571bfc209670771eb28bc0fc50e8 @@ -2208,8 +2208,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 00792e807f1dde750e6ac9f9b0095cf60b9fa6ff7cf4b14440600a21de2ee61a -R 26644a6a4d254f87e6d210a1b5d5866f +P d27985245a0e8c0d6b04323c98b26b6a8fb4e489fa8f5f3234252c7c198f23c8 +R c260c68d60eebc40b0c96509388ca9e3 U dan -Z 43505ba0ff6d8eb4d2d57750e91b3ee5 +Z d7c15a75ca8b075cfcf78184db374c6a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4334ad1f96..83c523a401 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d27985245a0e8c0d6b04323c98b26b6a8fb4e489fa8f5f3234252c7c198f23c8 +fb257540d32ced4a5fe0759d3ad9c1b36fd2b7d64d93cb0a0ecdb48355a68b7a From 235b5d0ac57950437262c40bb92624670dd02a90 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 15 Aug 2024 23:38:52 +0000 Subject: [PATCH 0666/1030] If a subquery is materialized due to an ORDER BY and that ordering is useful in helping to satisfy the ORDER BY or GROUP BY in the order query without doing an extra sort, then omit the extra sort. FossilOrigin-Name: 2fbb4dc2327ee435cb2b7a4adcddf5a9cee6dff7de96e2ecb761166427b5ddea --- manifest | 29 +++++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 1 + src/test1.c | 1 + src/where.c | 79 +++++++++++++++++++++++++++++++++++++++++-- src/whereInt.h | 4 ++- test/eqp.test | 53 +++++++++++++++++++++++++++++ test/skipscan1.test | 4 +-- test/windowpushd.test | 6 +++- test/with6.test | 44 ++++++++++++++++++++++++ 10 files changed, 203 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 22a05bc11b..e19579238d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\shelp\smessage\sfor\s--disable-tcl\son\sthe\sconfigure\sscript. -D 2024-08-15T15:31:46.143 +C If\sa\ssubquery\sis\smaterialized\sdue\sto\san\sORDER\sBY\sand\sthat\sordering\sis\suseful\nin\shelping\sto\ssatisfy\sthe\sORDER\sBY\sor\sGROUP\sBY\sin\sthe\sorder\squery\swithout\ndoing\san\sextra\ssort,\sthen\somit\sthe\sextra\ssort. +D 2024-08-15T23:38:52.210 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -765,13 +765,13 @@ F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab6770 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h e3f3b3d80a666a7c5c85b4db102d41ca831c5624f0b3001814479d376f00c19d +F src/sqliteInt.h 128b9004698cc79993d5369d7d1763deaf8bbf26e5e8931ec540707e5a7238df F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c c6888598f08dee3d9112a38ef42c8f5c89ca7f3190f4694744d0b84250f4bf8c F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 -F src/test1.c be8cc208c0d50b3a7e570049e55f25ae40c1dfec8165b7ce12c2c8ed9f5b3030 +F src/test1.c 3f18399557d954bc85f4564aec8ea1777d2161a81d98a3ff6c9e9046bf3554c1 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d @@ -846,8 +846,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 3556ef464ac78f4730f40c085aa0b6729ffe44306c0daaaffe9370c981a66d1d -F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65 +F src/where.c c59dffd249e5daa335bc43c2b87ffacc25dce995e3600a2b7bcdbcc55a68c985 +F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 F src/window.c 1e40ffc509bae21e466f6106382d238e91eb73edd4ba10e66ca4fd7af2b96896 @@ -1113,7 +1113,7 @@ F test/enc.test 9a7be5479da985381d740b15f432800f65e2c87029ee57a318f42cb2eb43763a F test/enc2.test 848bf05f15b011719f478dddb7b5e9aea35e39e457493cba4c4eef75d849a5ec F test/enc3.test 55ef64416d72975c66167310a51dc9fc544ba3ae4858b8d5ab22f4cb6500b087 F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020 -F test/eqp.test 815418b69f6be3a27037b1736c54699c72cc3e2e6b0bc878c01464d1dcec65fe +F test/eqp.test 82f221e8cd588434d7f3bba9a0f4c78cbe7a541615a41632e12f50608bfb4a99 F test/eqp2.test 6e8996148de88f0e7670491e92e712a2920a369b4406f21a27c3c9b6a46b68dd F test/errmsg.test eae9f091eb39ce7e20305de45d8e5d115b68fa856fba4ea6757b6ca3705ff7f9 F test/eval.test 73969a2d43a511bf44080c44485a8c4d796b6a4f038d19e491867081155692c0 @@ -1632,7 +1632,7 @@ F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 2668e607dcdfa19c52828c09b69685b38da793856582ae31debf79d90c7bbbdc F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329 -F test/skipscan1.test e03ba5b977da6fd71662a4b0a668f04053bda4b187ff3214db7533e28c732279 +F test/skipscan1.test 9cbbb6575517b15292bd87ee85b853bbd3cd4b4735d69b0f083020cec16ff304 F test/skipscan2.test b032ed3e0ba5caa4df6c43ef22c31566aac67783bc031869155989a7ccdb5bd5 F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 0672103fd2c8f96bd114133f356192b35ece45c794fe3677e1d9e5e3104a608e @@ -2067,13 +2067,13 @@ F test/windowE.test 6ba0c8048e4cc02b942e56640f8fcd50fd7ca72c876656c40f6baf42e316 F test/windowerr.tcl f5acd6fbc210d7b5546c0e879d157888455cd4a17a1d3f28f07c1c8a387019e0 F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3cc1819b F test/windowfault.test 15094c1529424e62f798bc679e3fe9dfab6e8ba2f7dfe8c923b6248c31660a7c -F test/windowpushd.test d8895d08870b7226f7693665bd292eb177e62ca06799184957b3ca7dc03067df +F test/windowpushd.test c420e2265f0e09a0e798d0513a660d71b51602088d81b3dbd038918ee1339dcc F test/with1.test b93833890e5d2a368e78747f124503a0159aa029b98e9ed4795ebf630b2efd3d F test/with2.test a1df41b987198383b9b70bf5e5fda390582e46398653858dbc6ceb24253b28df F test/with3.test e30369ea27aa27eb1bda4c5e510c8a9f782c8afd2ab99d1a02b8a7f25a5d3e65 F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205 F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8 -F test/with6.test e097a03e5c898a8cd8f3a2d6a994ec510ea4376b5d484c2b669a41001e7758c8 +F test/with6.test 9ff3503c3ff7cd459dc4852a02aaefa998dccace53f4142a0eb726174ad5984a F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64 F test/without_rowid1.test a5210b8770dc4736bca4e74bc96588f43025ad03ad6a80f885afd36d9890e217 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99 @@ -2204,8 +2204,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P de927016aadd7ee55d947134e3540907a3ea5ab4015034c5d088e3a84905d98a -R fa965b3cf027827ab805def1d12c22e4 +P 96e6cfb211f7f1aab50f997f4bc61dfb9701beb720c59bc413a4285c1ae5e20d +R cc9a8ceafd2a9a7a7cbd542af1820055 +T *branch * order-by-subquery +T *sym-order-by-subquery * +T -sym-trunk * U drh -Z a05ca4fe471b9ed0243c4a5725784485 +Z 66dcbf2773ae39411ce78a1d9346e7ac # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dd4cda6e20..8f936c703f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96e6cfb211f7f1aab50f997f4bc61dfb9701beb720c59bc413a4285c1ae5e20d +2fbb4dc2327ee435cb2b7a4adcddf5a9cee6dff7de96e2ecb761166427b5ddea diff --git a/src/sqliteInt.h b/src/sqliteInt.h index dca5bb150d..ebd0f01b26 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1927,6 +1927,7 @@ struct sqlite3 { #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */ #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */ #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */ +#define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */ #define SQLITE_AllOpts 0xffffffff /* All optimizations */ /* diff --git a/src/test1.c b/src/test1.c index 9def739f4c..177091a0e1 100644 --- a/src/test1.c +++ b/src/test1.c @@ -8100,6 +8100,7 @@ static int SQLITE_TCLAPI optimization_control( { "distinct-opt", SQLITE_DistinctOpt }, { "cover-idx-scan", SQLITE_CoverIdxScan }, { "order-by-idx-join", SQLITE_OrderByIdxJoin }, + { "order-by-subquery", SQLITE_OrderBySubq }, { "transitive", SQLITE_Transitive }, { "omit-noop-join", SQLITE_OmitNoopJoin }, { "stat4", SQLITE_Stat4 }, diff --git a/src/where.c b/src/where.c index 98e9f117f9..b119301e13 100644 --- a/src/where.c +++ b/src/where.c @@ -4010,6 +4010,10 @@ static int whereLoopAddBtree( #endif ApplyCostMultiplier(pNew->rRun, pTab->costMult); whereLoopOutputAdjust(pWC, pNew, rSize); + if( pSrc->pSelect ){ + if( pSrc->fg.viaCoroutine ) pNew->wsFlags |= WHERE_COROUTINE; + pNew->u.btree.pOrderBy = pSrc->pSelect->pOrderBy; + } rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; if( rc ) break; @@ -4843,6 +4847,69 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){ return rc; } +/* +** WhereLoop pLoop, which the iLoop-th term of the nested loop, is really +** a subquery or CTE that has an ORDER BY clause. See if any of the terms +** in the subquery ORDER BY clause will satisfy pOrderBy from the outer +** query. Mark off all satisfied terms (by setting bits in *pOBSat) and +** return TRUE if they do. If not, return false. +** +** Example: +** +** CREATE TABLE t1(a,b,c, PRIMARY KEY(a,b)); +** CREATE TABLE t2(x,y); +** WITH t3(p,q) AS MATERIALIZED (SELECT x+y, x-y FROM t2 ORDER BY x+y) +** SELECT * FROM t3 JOIN t1 ON a=q ORDER BY p, b; +** +** The CTE named "t3" comes out in the natural order of "p", so the first +** first them of "ORDER BY p,b" is satisfied by a sequential scan of "t3". +** +*/ +static SQLITE_NOINLINE int wherePathMatchSubqueryOB( + WhereLoop *pLoop, /* The nested loop term that is a subquery */ + int iLoop, /* Which level of the nested loop. 0==outermost */ + int iCur, /* Cursor used by the this loop */ + int wctrlFlags, /* Flags determining sort behavior */ + ExprList *pOrderBy, /* The ORDER BY clause on the whole query */ + Bitmask *pRevMask, /* When loops need to go in reverse order */ + Bitmask *pOBSat /* Which terms of pOrderBy are satisfied so far */ +){ + int i, j; + u8 rev = 0; + u8 revIdx = 0; + Expr *pOBExpr; + ExprList *pSubOB = pLoop->u.btree.pOrderBy; + assert( pSubOB!=0 ); + for(i=0; (MASKBIT(i) & *pOBSat)!=0; i++){} + for(j=0; jnExpr && inExpr; j++, i++){ + if( pSubOB->a[j].u.x.iOrderByCol==0 ) break; + pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[j].pExpr); + if( pOBExpr->op!=TK_COLUMN && pOBExpr->op!=TK_AGG_COLUMN ) break; + if( pOBExpr->iTable!=iCur ) break; + if( pOBExpr->iColumn!=pSubOB->a[j].u.x.iOrderByCol-1 ) break; + if( pSubOB->a[j].fg.sortFlags & KEYINFO_ORDER_BIGNULL ) break; + revIdx = pSubOB->a[j].fg.sortFlags & KEYINFO_ORDER_DESC; + if( wctrlFlags & WHERE_GROUPBY ){ + /* Sort order does not matter for GROUP BY */ + }else if( j>0 ){ + if( (rev ^ revIdx) != (pOrderBy->a[i].fg.sortFlags&KEYINFO_ORDER_DESC) ){ + break; + } + }else{ + rev = revIdx ^ (pOrderBy->a[i].fg.sortFlags & KEYINFO_ORDER_DESC); + if( rev ){ + if( (pLoop->wsFlags & WHERE_COROUTINE)!=0 ){ + /* Cannot run a co-routine in reverse order */ + break; + } + *pRevMask |= MASKBIT(iLoop); + } + } + *pOBSat |= MASKBIT(i); + } + return j>0; +} + /* ** Examine a WherePath (with the addition of the extra WhereLoop of the 6th ** parameters) to see if it outputs rows in the requested ORDER BY @@ -4988,9 +5055,17 @@ static i8 wherePathSatisfiesOrderBy( if( (pLoop->wsFlags & WHERE_ONEROW)==0 ){ if( pLoop->wsFlags & WHERE_IPK ){ + if( pLoop->u.btree.pOrderBy + && OptimizationEnabled(db, SQLITE_OrderBySubq) + && wherePathMatchSubqueryOB(pLoop,iLoop,iCur,wctrlFlags, + pOrderBy,pRevMask, &obSat) + ){ + nColumn = 0; + }else{ + nColumn = 1; + } pIndex = 0; nKeyCol = 0; - nColumn = 1; }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){ return 0; }else{ @@ -5085,7 +5160,7 @@ static i8 wherePathSatisfiesOrderBy( } /* Find the ORDER BY term that corresponds to the j-th column - ** of the index and mark that ORDER BY term off + ** of the index and mark that ORDER BY term having been satisfied. */ isMatch = 0; for(i=0; bOnce && i 0 AND nFin > 0; +} { + QUERY PLAN + |--MATERIALIZE sums + | |--MATERIALIZE src + | | |--MATERIALIZE init + | | | `--SCAN raw USING INDEX sqlite_autoindex_raw_1 + | | |--SCAN i + | | |--SEARCH raw USING COVERING INDEX sqlite_autoindex_raw_1 (country=? AND date>?) + | | `--USE TEMP B-TREE FOR ORDER BY + | |--SCAN src + | `--SEARCH raw USING INDEX sqlite_autoindex_raw_1 (country=? AND date>? AND date 0 GROUP BY country), + src(country, date) AS (SELECT raw.country, raw.date + FROM raw JOIN init i on raw.country = i.country AND raw.date > i.date + ORDER BY raw.country, raw.date), + vals(country, date, x, y) AS (SELECT src.country, src.date, julianday(raw.date) - julianday(src.date), log(delta+1) + FROM src JOIN raw on raw.country = src.country AND raw.date > date(src.date,'-7 days') AND raw.date <= src.date AND delta >= 0), + sums(country, date, x2, x, n, xy, y) AS (SELECT country, date, sum(x*x*1.0), sum(x*1.0), sum(1.0), sum(x*y*1.0), sum(y*1.0) FROM vals GROUP BY 1, 2), + mult(country, date, m) AS (SELECT country, date, 1.0/(x2 * n - x * x) FROM sums), + inv(country, date, a,b,c,d) AS (SELECT mult.country, mult.date, n * m, -x * m, -x * m, x2 * m + FROM mult JOIN sums on sums.country=mult.country AND mult.date=sums.date), + fit(country, date, a, b) AS (SELECT inv.country, inv.date, a * xy + b * y, c * xy + d * y + FROM inv + JOIN mult on mult.country = inv.country AND mult.date = inv.date + JOIN sums on sums.country = mult.country AND sums.date = mult.date + ) + SELECT *, nFin/nPrev - 1 AS growth, log(2)/log(nFin/nPrev) AS doubling + FROM (SELECT f.*, exp(b) - 1 AS nFin, exp(a* (-1) + b) - 1 AS nPrev + FROM fit f JOIN init i on i.country = f.country AND f.date <= date(i.fin,'-3 days')) + WHERE nPrev > 0 AND nFin > 0; } { QUERY PLAN |--MATERIALIZE sums From 743188642de006de77e282cac6af4d3fc1baa293 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 16 Aug 2024 00:37:54 +0000 Subject: [PATCH 0667/1030] Improvements to the subquery ORDER BY decision algorithm. Fewer false-negatives. FossilOrigin-Name: b82421e3f5811946e9d60b845fc882b6ea5c53c648695654c6900754427bf9bf --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/where.c | 27 +++++++++++++++------------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index e19579238d..ce77ec7858 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\ssubquery\sis\smaterialized\sdue\sto\san\sORDER\sBY\sand\sthat\sordering\sis\suseful\nin\shelping\sto\ssatisfy\sthe\sORDER\sBY\sor\sGROUP\sBY\sin\sthe\sorder\squery\swithout\ndoing\san\sextra\ssort,\sthen\somit\sthe\sextra\ssort. -D 2024-08-15T23:38:52.210 +C Improvements\sto\sthe\ssubquery\sORDER\sBY\sdecision\salgorithm.\sFewer\sfalse-negatives. +D 2024-08-16T00:37:54.145 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -846,7 +846,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c c59dffd249e5daa335bc43c2b87ffacc25dce995e3600a2b7bcdbcc55a68c985 +F src/where.c c6b742473a627bb0ff2aa1f05f3daaa7fc974b05fe4f84ae8a2d07fd7b92393c F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -2204,11 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 96e6cfb211f7f1aab50f997f4bc61dfb9701beb720c59bc413a4285c1ae5e20d -R cc9a8ceafd2a9a7a7cbd542af1820055 -T *branch * order-by-subquery -T *sym-order-by-subquery * -T -sym-trunk * +P 2fbb4dc2327ee435cb2b7a4adcddf5a9cee6dff7de96e2ecb761166427b5ddea +R 4f42ef8d0868b345800db6a42ea20509 U drh -Z 66dcbf2773ae39411ce78a1d9346e7ac +Z a8bc8a8b808f8550328f0344d9e7735f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8f936c703f..95e076fb40 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2fbb4dc2327ee435cb2b7a4adcddf5a9cee6dff7de96e2ecb761166427b5ddea +b82421e3f5811946e9d60b845fc882b6ea5c53c648695654c6900754427bf9bf diff --git a/src/where.c b/src/where.c index b119301e13..561091e0a0 100644 --- a/src/where.c +++ b/src/where.c @@ -4887,22 +4887,25 @@ static SQLITE_NOINLINE int wherePathMatchSubqueryOB( if( pOBExpr->op!=TK_COLUMN && pOBExpr->op!=TK_AGG_COLUMN ) break; if( pOBExpr->iTable!=iCur ) break; if( pOBExpr->iColumn!=pSubOB->a[j].u.x.iOrderByCol-1 ) break; - if( pSubOB->a[j].fg.sortFlags & KEYINFO_ORDER_BIGNULL ) break; - revIdx = pSubOB->a[j].fg.sortFlags & KEYINFO_ORDER_DESC; - if( wctrlFlags & WHERE_GROUPBY ){ - /* Sort order does not matter for GROUP BY */ - }else if( j>0 ){ - if( (rev ^ revIdx) != (pOrderBy->a[i].fg.sortFlags&KEYINFO_ORDER_DESC) ){ + if( (wctrlFlags & WHERE_GROUPBY)==0 ){ + if( (pSubOB->a[j].fg.sortFlags & KEYINFO_ORDER_BIGNULL) + != (pOrderBy->a[j].fg.sortFlags & KEYINFO_ORDER_BIGNULL) ){ break; } - }else{ - rev = revIdx ^ (pOrderBy->a[i].fg.sortFlags & KEYINFO_ORDER_DESC); - if( rev ){ - if( (pLoop->wsFlags & WHERE_COROUTINE)!=0 ){ - /* Cannot run a co-routine in reverse order */ + revIdx = pSubOB->a[j].fg.sortFlags & KEYINFO_ORDER_DESC; + if( j>0 ){ + if( (rev ^ revIdx)!=(pOrderBy->a[i].fg.sortFlags&KEYINFO_ORDER_DESC) ){ break; } - *pRevMask |= MASKBIT(iLoop); + }else{ + rev = revIdx ^ (pOrderBy->a[i].fg.sortFlags & KEYINFO_ORDER_DESC); + if( rev ){ + if( (pLoop->wsFlags & WHERE_COROUTINE)!=0 ){ + /* Cannot run a co-routine in reverse order */ + break; + } + *pRevMask |= MASKBIT(iLoop); + } } } *pOBSat |= MASKBIT(i); From 42f997d768f3853c9d5bca5e3e07878236ee698b Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 16 Aug 2024 02:19:17 +0000 Subject: [PATCH 0668/1030] Bug fix in the subquery ORDER BY propagator. FossilOrigin-Name: 5a9a3b8af7ac0aa1c04ad2d735e341c92d67952acb9a1d30217c0471e92cd468 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index ce77ec7858..b8037df583 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\ssubquery\sORDER\sBY\sdecision\salgorithm.\sFewer\sfalse-negatives. -D 2024-08-16T00:37:54.145 +C Bug\sfix\sin\sthe\ssubquery\sORDER\sBY\spropagator. +D 2024-08-16T02:19:17.392 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -846,7 +846,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c c6b742473a627bb0ff2aa1f05f3daaa7fc974b05fe4f84ae8a2d07fd7b92393c +F src/where.c 154533a45da7b54f460d7415b0ea3aea59855a58460cf1356175b0045ff30c26 F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2fbb4dc2327ee435cb2b7a4adcddf5a9cee6dff7de96e2ecb761166427b5ddea -R 4f42ef8d0868b345800db6a42ea20509 +P b82421e3f5811946e9d60b845fc882b6ea5c53c648695654c6900754427bf9bf +R 41797d101dab015774684ce7d95aeefd U drh -Z a8bc8a8b808f8550328f0344d9e7735f +Z c79ab6ee6fe9513aaffefd02f00f8786 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 95e076fb40..77af5ed578 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b82421e3f5811946e9d60b845fc882b6ea5c53c648695654c6900754427bf9bf +5a9a3b8af7ac0aa1c04ad2d735e341c92d67952acb9a1d30217c0471e92cd468 diff --git a/src/where.c b/src/where.c index 561091e0a0..442904a654 100644 --- a/src/where.c +++ b/src/where.c @@ -5064,6 +5064,7 @@ static i8 wherePathSatisfiesOrderBy( pOrderBy,pRevMask, &obSat) ){ nColumn = 0; + isOrderDistinct = 0; }else{ nColumn = 1; } From 2ed4f5016a591b5aaabe4a80fc073faab4ad907d Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 16 Aug 2024 11:26:21 +0000 Subject: [PATCH 0669/1030] Fix handling of COLLATE. Add test cases for the same. Code cleanup for improved understandability and maintainability. FossilOrigin-Name: 41a41c173a9d15d94f23d73a5c04bfb1616cb9223bc81d41808f9b4d00817fbf --- manifest | 15 ++++---- manifest.uuid | 2 +- src/where.c | 73 +++++++++++++++++++++++------------ test/orderbyB.test | 94 ++++++++++++++++++++++++++++++++++++++++++++++ test/tester.tcl | 23 ++++++++++++ 5 files changed, 175 insertions(+), 32 deletions(-) create mode 100644 test/orderbyB.test diff --git a/manifest b/manifest index b8037df583..3d86a9c04b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bug\sfix\sin\sthe\ssubquery\sORDER\sBY\spropagator. -D 2024-08-16T02:19:17.392 +C Fix\shandling\sof\sCOLLATE.\s\sAdd\stest\scases\sfor\sthe\ssame.\s\sCode\scleanup\sfor\nimproved\sunderstandability\sand\smaintainability. +D 2024-08-16T11:26:21.307 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -846,7 +846,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 154533a45da7b54f460d7415b0ea3aea59855a58460cf1356175b0045ff30c26 +F src/where.c f5be664f3379c9f930696e339ec4ef4c1187af860cca727411156101fae6b677 F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 @@ -1493,6 +1493,7 @@ F test/orderby7.test 3d1383d52ade5b9eb3a173b3147fdd296f0202da F test/orderby8.test 23ef1a5d72bd3adcc2f65561c654295d1b8047bd F test/orderby9.test 87fb9548debcc2cd141c5299002dd94672fa76a3 F test/orderbyA.test df608e59efc2ef50c1eddf1a773b272de3252e9401bfec86d04b52fd973866d5 +F test/orderbyB.test 32576c7b138105bc72f7fbf33bd320ca3a7d303641fc939e0e56af6cba884b3d F test/oserror.test 1fc9746b83d778e70d115049747ba19c7fba154afce7cc165b09feb6ca6abbc5 F test/ossfuzz.c 9636dad2092a05a32110df0ca06713038dd0c43dd89a77dabe4b8b0d71096715 F test/ossshell.c f125c5bd16e537a2549aa579b328dd1c59905e7ab1338dfc210e755bb7b69f17 @@ -1706,7 +1707,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d1631311a16 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc -F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef +F test/tester.tcl e88c498c369cff6bf0898db6d04088685066730be51821ef775ef13fd2b1d077 F test/testrunner.tcl 5d02deeba7a53baeadae6aa7641d90aac58fdfa3a7bcac85cfcfd752b1aab87c F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 @@ -2204,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b82421e3f5811946e9d60b845fc882b6ea5c53c648695654c6900754427bf9bf -R 41797d101dab015774684ce7d95aeefd +P 5a9a3b8af7ac0aa1c04ad2d735e341c92d67952acb9a1d30217c0471e92cd468 +R 7950e16a6ca37805979b1472a80cc190 U drh -Z c79ab6ee6fe9513aaffefd02f00f8786 +Z 14a0d323dd6fe70b6ed40930f5fa77fd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 77af5ed578..b684817cd4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a9a3b8af7ac0aa1c04ad2d735e341c92d67952acb9a1d30217c0471e92cd468 +41a41c173a9d15d94f23d73a5c04bfb1616cb9223bc81d41808f9b4d00817fbf diff --git a/src/where.c b/src/where.c index 442904a654..631b7581fb 100644 --- a/src/where.c +++ b/src/where.c @@ -4847,7 +4847,8 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){ return rc; } -/* +/* Implementation of the order-by-subquery optimization: +** ** WhereLoop pLoop, which the iLoop-th term of the nested loop, is really ** a subquery or CTE that has an ORDER BY clause. See if any of the terms ** in the subquery ORDER BY clause will satisfy pOrderBy from the outer @@ -4862,43 +4863,67 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){ ** SELECT * FROM t3 JOIN t1 ON a=q ORDER BY p, b; ** ** The CTE named "t3" comes out in the natural order of "p", so the first -** first them of "ORDER BY p,b" is satisfied by a sequential scan of "t3". -** +** first them of "ORDER BY p,b" is satisfied by a sequential scan of "t3" +** and sorting only needs to occur on the second term "b". +** +** Limitations: +** +** (1) The optimization is not applied if the outer ORDER BY contains +** a COLLATE clause. The optimization might be applied if the +** outer ORDER BY uses NULLS FIRST, NULLS LAST, ASC, and/or DESC as +** long as the subquery ORDER BY does the same. But if the +** outer ORDER BY uses COLLATE, even a redundant COLLATE, the +** optimization is bypassed. +** +** (2) The subquery ORDER BY terms must exactly match subquery result +** columns, including any COLLATE annotations. This routine relies +** on iOrderByCol to do matching between order by terms and result +** columns, and iOrderByCol will not be set if the result column +** and ORDER BY collations differ. +** +** (3) The subquery and outer ORDER BY can be in opposite directions as +** long as the subquery is materialized. If the subquery is +** implemented as a co-routine, the sort orders must be in the same +** direction because there is no way to run a co-routine backwards. */ static SQLITE_NOINLINE int wherePathMatchSubqueryOB( + WhereInfo *pWInfo, /* The WHERE clause */ WhereLoop *pLoop, /* The nested loop term that is a subquery */ int iLoop, /* Which level of the nested loop. 0==outermost */ int iCur, /* Cursor used by the this loop */ - int wctrlFlags, /* Flags determining sort behavior */ ExprList *pOrderBy, /* The ORDER BY clause on the whole query */ Bitmask *pRevMask, /* When loops need to go in reverse order */ Bitmask *pOBSat /* Which terms of pOrderBy are satisfied so far */ ){ - int i, j; - u8 rev = 0; - u8 revIdx = 0; - Expr *pOBExpr; - ExprList *pSubOB = pLoop->u.btree.pOrderBy; + int iOB; /* Index into pOrderBy->a[] */ + int jSub; /* Index into pSubOB->a[] */ + u8 rev = 0; /* True if iOB and jSub sort in opposite directions */ + u8 revIdx = 0; /* Sort direction for jSub */ + Expr *pOBExpr; /* Current term of outer ORDER BY */ + ExprList *pSubOB; /* Complete ORDER BY on the subquery */ + + pSubOB = pLoop->u.btree.pOrderBy; assert( pSubOB!=0 ); - for(i=0; (MASKBIT(i) & *pOBSat)!=0; i++){} - for(j=0; jnExpr && inExpr; j++, i++){ - if( pSubOB->a[j].u.x.iOrderByCol==0 ) break; - pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[j].pExpr); + for(iOB=0; (MASKBIT(iOB) & *pOBSat)!=0; iOB++){} + for(jSub=0; jSubnExpr && iOBnExpr; jSub++, iOB++){ + if( pSubOB->a[jSub].u.x.iOrderByCol==0 ) break; + pOBExpr = pOrderBy->a[iOB].pExpr; if( pOBExpr->op!=TK_COLUMN && pOBExpr->op!=TK_AGG_COLUMN ) break; if( pOBExpr->iTable!=iCur ) break; - if( pOBExpr->iColumn!=pSubOB->a[j].u.x.iOrderByCol-1 ) break; - if( (wctrlFlags & WHERE_GROUPBY)==0 ){ - if( (pSubOB->a[j].fg.sortFlags & KEYINFO_ORDER_BIGNULL) - != (pOrderBy->a[j].fg.sortFlags & KEYINFO_ORDER_BIGNULL) ){ + if( pOBExpr->iColumn!=pSubOB->a[jSub].u.x.iOrderByCol-1 ) break; + if( (pWInfo->wctrlFlags & WHERE_GROUPBY)==0 ){ + u8 sfOB = pOrderBy->a[iOB].fg.sortFlags; /* sortFlags for iOB */ + u8 sfSub = pSubOB->a[jSub].fg.sortFlags; /* sortFlags for jSub */ + if( (sfSub & KEYINFO_ORDER_BIGNULL) != (sfOB & KEYINFO_ORDER_BIGNULL) ){ break; } - revIdx = pSubOB->a[j].fg.sortFlags & KEYINFO_ORDER_DESC; - if( j>0 ){ - if( (rev ^ revIdx)!=(pOrderBy->a[i].fg.sortFlags&KEYINFO_ORDER_DESC) ){ + revIdx = sfSub & KEYINFO_ORDER_DESC; + if( jSub>0 ){ + if( (rev^revIdx)!=(sfOB & KEYINFO_ORDER_DESC) ){ break; } }else{ - rev = revIdx ^ (pOrderBy->a[i].fg.sortFlags & KEYINFO_ORDER_DESC); + rev = revIdx ^ (sfOB & KEYINFO_ORDER_DESC); if( rev ){ if( (pLoop->wsFlags & WHERE_COROUTINE)!=0 ){ /* Cannot run a co-routine in reverse order */ @@ -4908,9 +4933,9 @@ static SQLITE_NOINLINE int wherePathMatchSubqueryOB( } } } - *pOBSat |= MASKBIT(i); + *pOBSat |= MASKBIT(iOB); } - return j>0; + return jSub>0; } /* @@ -5060,7 +5085,7 @@ static i8 wherePathSatisfiesOrderBy( if( pLoop->wsFlags & WHERE_IPK ){ if( pLoop->u.btree.pOrderBy && OptimizationEnabled(db, SQLITE_OrderBySubq) - && wherePathMatchSubqueryOB(pLoop,iLoop,iCur,wctrlFlags, + && wherePathMatchSubqueryOB(pWInfo,pLoop,iLoop,iCur, pOrderBy,pRevMask, &obSat) ){ nColumn = 0; diff --git a/test/orderbyB.test b/test/orderbyB.test new file mode 100644 index 0000000000..42d2de7982 --- /dev/null +++ b/test/orderbyB.test @@ -0,0 +1,94 @@ +# 2024-08-15 +# +# 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. +# +# Specifically, it tests cases with order-by-subquery optimization in which +# an ORDER BY in a subquery is used to help resolve an ORDER BY in the +# outer query without having to do an extra sort. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix orderbyb + +db null NULL +do_execsql_test 1.0 { + CREATE TABLE t1(a TEXT, b TEXT, c INT); + INSERT INTO t1 VALUES(NULL,NULL,NULL); + WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<7) + INSERT INTO t1(a,b,c) SELECT char(p,p), char(q,q), n FROM + (SELECT ((n-1)%4)+0x61 AS p, abs(n*2-9+(n>=5))+0x60 AS q, n FROM c); + UPDATE t1 SET b=upper(b) WHERE c=1; + CREATE TABLE t2(k TEXT PRIMARY KEY, v INT) WITHOUT ROWID; + WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<7) + INSERT INTO t2(k,v) SELECT char(0x60+n,0x60+n), n FROM c; + WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<7) + INSERT INTO t2(k,v) SELECT char(0x40+n,0x40+n), n FROM c; + SELECT a,b,c,tx.v AS 'v-a', ty.v AS 'v-b' + FROM t1 LEFT JOIN t2 AS tx ON tx.k=a + LEFT JOIN t2 AS ty ON ty.k=b + ORDER BY c; +} { + NULL NULL NULL NULL NULL + aa GG 1 1 7 + bb ee 2 2 5 + cc cc 3 3 3 + dd aa 4 4 1 + aa bb 5 1 2 + bb dd 6 2 4 + cc ff 7 3 6 +} + +do_eqp_execsql_test 1.1 { + WITH t3(x,y) AS (SELECT a, b FROM t1 ORDER BY a, b LIMIT 8) + SELECT x, y, v FROM t3 LEFT JOIN t2 ON k=t3.y ORDER BY x, y COLLATE nocase; +} { + QUERY PLAN + |--CO-ROUTINE t3 + | |--SCAN t1 + | `--USE TEMP B-TREE FOR ORDER BY + |--SCAN t3 + |--SEARCH t2 USING PRIMARY KEY (k=?) LEFT-JOIN + `--USE TEMP B-TREE FOR LAST TERM OF ORDER BY +} { + NULL NULL NULL + aa bb 2 + aa GG 7 + bb dd 4 + bb ee 5 + cc cc 3 + cc ff 6 + dd aa 1 +} + +do_eqp_execsql_test 1.2 { + WITH t3(x,y) AS MATERIALIZED (SELECT a, b COLLATE nocase FROM t1 ORDER BY 1,2) + SELECT x, y, v FROM t3 LEFT JOIN t2 ON k=t3.y ORDER BY x,y; +} { + QUERY PLAN + |--MATERIALIZE t3 + | |--SCAN t1 + | `--USE TEMP B-TREE FOR ORDER BY + |--SCAN t3 + `--SEARCH t2 USING PRIMARY KEY (k=?) LEFT-JOIN +} { + NULL NULL NULL + aa bb 2 + aa GG 7 + bb dd 4 + bb ee 5 + cc cc 3 + cc ff 6 + dd aa 1 +} + + +finish_test diff --git a/test/tester.tcl b/test/tester.tcl index 63c83187aa..43f7c7a047 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -1056,6 +1056,29 @@ proc do_eqp_test {name sql res} { } } +# Do both an eqp_test and an execsql_test on the same SQL. +# +proc do_eqp_execsql_test {name sql res1 res2} { + if {[regexp {^\s+QUERY PLAN\n} $res1]} { + + set query_plan [query_plan_graph $sql] + + if {[list {*}$query_plan]==[list {*}$res1]} { + uplevel [list do_test ${name}a [list set {} ok] ok] + } else { + uplevel [list \ + do_test ${name}a [list query_plan_graph $sql] $res1 + ] + } + } else { + if {[string index $res 0]!="/"} { + set res1 "/*$res1*/" + } + uplevel do_execsql_test ${name}a [list "EXPLAIN QUERY PLAN $sql"] [list $res1] + } + uplevel do_execsql_test ${name}b [list $sql] [list $res2] +} + #------------------------------------------------------------------------- # Usage: do_select_tests PREFIX ?SWITCHES? TESTLIST From b8123415b2952793279bad794680c14e191d7ca5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 16 Aug 2024 15:35:20 +0000 Subject: [PATCH 0670/1030] Ensure that memory allocations in ANALYZE are always 8-byte aligned in order to satisfy a new assert() added by [539e4f661767ef90]. FossilOrigin-Name: a1915cbdeccac2ed49fb8a9733abf2c6239396e3174fed2ff275f66b606c48b6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/analyze.c | 19 +++++++++++-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 22a05bc11b..6e81c8e8bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\shelp\smessage\sfor\s--disable-tcl\son\sthe\sconfigure\sscript. -D 2024-08-15T15:31:46.143 +C Ensure\sthat\smemory\sallocations\sin\sANALYZE\sare\salways\s8-byte\saligned\sin\sorder\nto\ssatisfy\sa\snew\sassert()\sadded\sby\s[539e4f661767ef90]. +D 2024-08-16T15:35:20.377 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -693,7 +693,7 @@ F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 F src/alter.c bb663fddf1fe0e2e6d8758b2b7fb6374e7c057a6ca3955f37a48986806029765 -F src/analyze.c 5c4e2bfd0aa8e5157f7fb91a17d86905510a74397326dc5767ec4e0588a4eea5 +F src/analyze.c 30bf40ec4208ead9e977bec017bccc8a9681820936e38ca5a4a7443100a6d5c5 F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39 F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 @@ -2204,8 +2204,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P de927016aadd7ee55d947134e3540907a3ea5ab4015034c5d088e3a84905d98a -R fa965b3cf027827ab805def1d12c22e4 +P 96e6cfb211f7f1aab50f997f4bc61dfb9701beb720c59bc413a4285c1ae5e20d +R 19ca743d0eb81a004946ea85e6f05b5d U drh -Z a05ca4fe471b9ed0243c4a5725784485 +Z b629a1d86492e4c09b552ad5721d3d89 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dd4cda6e20..edb9927377 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96e6cfb211f7f1aab50f997f4bc61dfb9701beb720c59bc413a4285c1ae5e20d +a1915cbdeccac2ed49fb8a9733abf2c6239396e3174fed2ff275f66b606c48b6 diff --git a/src/analyze.c b/src/analyze.c index 774eeeed26..fc8680d78d 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1797,12 +1797,13 @@ static int loadStatTbl( while( sqlite3_step(pStmt)==SQLITE_ROW ){ int nIdxCol = 1; /* Number of columns in stat4 records */ - char *zIndex; /* Index name */ - Index *pIdx; /* Pointer to the index object */ - int nSample; /* Number of samples */ - int nByte; /* Bytes of space required */ - int i; /* Bytes of space required */ - tRowcnt *pSpace; + char *zIndex; /* Index name */ + Index *pIdx; /* Pointer to the index object */ + int nSample; /* Number of samples */ + int nByte; /* Bytes of space required */ + int i; /* Bytes of space required */ + tRowcnt *pSpace; /* Available allocated memory space */ + u8 *pPtr; /* Available memory as a u8 for easier manipulation */ zIndex = (char *)sqlite3_column_text(pStmt, 0); if( zIndex==0 ) continue; @@ -1822,7 +1823,7 @@ static int loadStatTbl( } pIdx->nSampleCol = nIdxCol; pIdx->mxSample = nSample; - nByte = sizeof(IndexSample) * nSample; + nByte = ROUND8(sizeof(IndexSample) * nSample); nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample; nByte += nIdxCol * sizeof(tRowcnt); /* Space for Index.aAvgEq[] */ @@ -1831,7 +1832,9 @@ static int loadStatTbl( sqlite3_finalize(pStmt); return SQLITE_NOMEM_BKPT; } - pSpace = (tRowcnt*)&pIdx->aSample[nSample]; + pPtr = (u8*)pIdx->aSample; + pPtr += ROUND8(nSample*sizeof(pIdx->aSample[0])); + pSpace = (tRowcnt*)pPtr; assert( EIGHT_BYTE_ALIGNMENT( pSpace ) ); pIdx->aAvgEq = pSpace; pSpace += nIdxCol; pIdx->pTable->tabFlags |= TF_HasStat4; From db79dd1f88e27fda30b27f52e6512897e6c98c72 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 16 Aug 2024 16:20:43 +0000 Subject: [PATCH 0671/1030] Add tests to restore coverage of fts5_main.c. FossilOrigin-Name: 681edd08ab7024ddcd6447a64d8aad581b47b039481b697d91d26e6c6660f373 --- ext/fts5/fts5_tcl.c | 38 +++++++++++++++++------ ext/fts5/test/fts5faultI.test | 58 ++++++++++++++++++++++++++++++++++- ext/fts5/test/fts5locale.test | 9 ++++++ ext/fts5/test/fts5misc.test | 22 +++++++++++++ manifest | 18 +++++------ manifest.uuid | 2 +- 6 files changed, 127 insertions(+), 20 deletions(-) diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 60b3f0e9ef..1e9f7bbb60 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -890,15 +890,17 @@ static int f5tTokenizerCreate( static void f5tTokenizerDelete(Fts5Tokenizer *p){ F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)p; - if( pInst->pParent ){ - if( pInst->pModule->parent_v2.xDelete ){ - pInst->pModule->parent_v2.xDelete(pInst->pParent); - }else{ - pInst->pModule->parent.xDelete(pInst->pParent); + if( pInst ){ + if( pInst->pParent ){ + if( pInst->pModule->parent_v2.xDelete ){ + pInst->pModule->parent_v2.xDelete(pInst->pParent); + }else{ + pInst->pModule->parent.xDelete(pInst->pParent); + } } + Tcl_DecrRefCount(pInst->pScript); + ckfree((char *)pInst); } - Tcl_DecrRefCount(pInst->pScript); - ckfree((char *)pInst); } @@ -1146,6 +1148,7 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( F5tTokenizerModule *pMod; int rc = SQLITE_OK; int bV2 = 0; /* True to use _v2 API */ + int iVersion = 2; /* Value for _v2.iVersion */ const char *zParent = 0; /* Name of parent tokenizer, if any */ int ii = 0; @@ -1157,7 +1160,7 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( /* Parse any options. Set stack variables bV2 and zParent. */ for(ii=1; iixFindTokenizer_v2(pApi, zParent, &pMod->pParentCtx, &pParent); if( rc==SQLITE_OK ){ memcpy(&pMod->parent_v2, pParent, sizeof(fts5_tokenizer_v2)); + pMod->parent_v2.xDelete(0); } }else{ rc = pApi->xFindTokenizer(pApi, zParent, &pMod->pParentCtx,&pMod->parent); + if( rc==SQLITE_OK ){ + pMod->parent.xDelete(0); + } } } @@ -1218,7 +1238,7 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( }else{ fts5_tokenizer_v2 t2; memset(&t2, 0, sizeof(t2)); - t2.iVersion = 2; + t2.iVersion = iVersion; t2.xCreate = f5tTokenizerCreate; t2.xTokenize = f5tTokenizerTokenize_v2; t2.xDelete = f5tTokenizerDelete; diff --git a/ext/fts5/test/fts5faultI.test b/ext/fts5/test/fts5faultI.test index 33c93c63af..ab641b6514 100644 --- a/ext/fts5/test/fts5faultI.test +++ b/ext/fts5/test/fts5faultI.test @@ -20,7 +20,9 @@ ifcapable !fts5 { return } -set ::testprefix fts5faultH +set ::testprefix fts5faultI + +if 0 { do_execsql_test 1.0 { PRAGMA encoding = utf16; @@ -146,5 +148,59 @@ do_faultsim_test 6 -faults oom* -prep { faultsim_test_result {0 {}} } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 7.0 { + CREATE VIRTUAL TABLE w1 USING fts5(a); + INSERT INTO w1 VALUES('one two three'); + INSERT INTO w1 VALUES('three two one'); + DELETE FROM w1_content WHERE rowid=1; +} + +faultsim_save_and_close + +do_faultsim_test 7 -faults oom* -prep { + faultsim_restore_and_reopen + db eval { SELECT * FROM w1 } +} -body { + execsql { + PRAGMA integrity_check; + } +} -test { +} +} +#------------------------------------------------------------------------- +reset_db +fts5_tclnum_register db +fts5_aux_test_functions db + +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE ft USING fts5( + x, tokenize = "tclnum query", detail=columns + ); + INSERT INTO ft VALUES('one two three i ii iii'); + INSERT INTO ft VALUES('four five six iv v vi'); + INSERT INTO ft VALUES('eight nine ten viii ix x'); +} {} + +do_faultsim_test 8.1 -faults oom* -prep { +} -body { + execsql { + SELECT fts5_test_collist (ft) FROM ft('one two'); + } +} -test { + faultsim_test_result {0 {{0.0 1.0}}} {1 {SQL logic error}} {1 SQLITE_NOMEM} +} + +do_faultsim_test 8.2 -faults oom* -prep { +} -body { + execsql { + SELECT rowid FROM ft('one two') ORDER BY rank; + } +} -test { + faultsim_test_result {0 1} {1 {SQL logic error}} {1 SQLITE_NOMEM} +} + + finish_test diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index a07f4ccfa8..f647317c3b 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -521,5 +521,14 @@ do_catchsql_test 11.2 { SELECT fts5_columnlocale(x1, 1) FROM x1('two'); } {1 SQLITE_RANGE} +#------------------------------------------------------------------------- +# +reset_db +do_test 12.0 { + list [catch { + sqlite3_fts5_create_tokenizer -v2 -version 3 db tcl tcl_create + } msg] $msg +} {1 {error in fts5_api.xCreateTokenizer_v2()}} + finish_test diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index 4b943c3488..c7f4a53e38 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -591,5 +591,27 @@ do_execsql_test 21.2 { PRAGMA integrity_check } {ok} +breakpoint +sqlite3_db_config db DEFENSIVE 1 +do_execsql_test 21.3 { + CREATE TABLE xyz_notashadow(x, y); + DROP TABLE xyz_notashadow; +} +sqlite3_db_config db DEFENSIVE 0 + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 22.0 { + SELECT fts5(NULL); +} {{}} +do_execsql_test 22.1 { + SELECT count(*) FROM ( + SELECT fts5_source_id() + ) +} {1} +execsql_pp { + SELECT fts5_source_id() +} + finish_test diff --git a/manifest b/manifest index 28ab5391d0..5847c8b75f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Extra\stests. -D 2024-08-15T20:33:05.956 +C Add\stests\sto\srestore\scoverage\sof\sfts5_main.c. +D 2024-08-16T16:20:43.666 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -102,7 +102,7 @@ F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 23029229021240dc21a69eb749305316103d183375413e2090c064b74b03b7f8 F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 -F ext/fts5/fts5_tcl.c 50c7e16753fde0c4d80d8abd00a4ed2b0e998d5d3899a484510d01923c5da43b +F ext/fts5/fts5_tcl.c 1dcf08028141c40a32634bdcf2d5601622ce4edc48f82ac4ce0cbe0a92a6961d F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c 96efa85a21a85276680ce3fb19dc5dd8d6b6541b2c37f953ee55bc15092262e1 @@ -177,7 +177,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5faultI.test d9e8c4b0b42910fa447a0e148236def618e7decbf3a334c7933a95e36410f772 +F ext/fts5/test/fts5faultI.test eb0910ec0fa57b4e06241c58252124155e689770b4dd2d8f4f3fc74185be934e F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -187,11 +187,11 @@ F ext/fts5/test/fts5interrupt.test 20d04204d3e341b104c0c24a41596b6393a3a81eba104 F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test f58ac6ab539d3813556646f7d4b1e19f7e3b1a56ca4439349eb8099d6a821ff6 +F ext/fts5/test/fts5locale.test 5ad9f1b66db4d698c67284f3495007be94f8c6ed183688e64defed72a169b6c0 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test b49a3afbda6de02970560c1cd3b804a4896b9f30ce5d75a5f215fa972537b26b +F ext/fts5/test/fts5misc.test c860b75721d162d7a4f2856322e55e814c2cf0bc45f93ef4388551b54e61a0a0 F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -2208,8 +2208,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d27985245a0e8c0d6b04323c98b26b6a8fb4e489fa8f5f3234252c7c198f23c8 -R c260c68d60eebc40b0c96509388ca9e3 +P fb257540d32ced4a5fe0759d3ad9c1b36fd2b7d64d93cb0a0ecdb48355a68b7a +R 067a05b128f4dcdbb34743e9c0788abc U dan -Z d7c15a75ca8b075cfcf78184db374c6a +Z 1b380833fd7dd34e177f4e045cee1c46 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 83c523a401..e93e9346cb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fb257540d32ced4a5fe0759d3ad9c1b36fd2b7d64d93cb0a0ecdb48355a68b7a +681edd08ab7024ddcd6447a64d8aad581b47b039481b697d91d26e6c6660f373 From f0f240c0d83903f4222d39131df4d9719272a4a0 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 16 Aug 2024 17:54:00 +0000 Subject: [PATCH 0672/1030] Add tests to restore coverage of fts5_storage.c. FossilOrigin-Name: 38841881a08f4d75c2dfcbc1b2b45e311d7dda1287780f8ba1c8388f7adc1629 --- ext/fts5/fts5_storage.c | 46 +++++++++++++++++----------------- ext/fts5/test/fts5corrupt.test | 21 ++++++++++++++++ ext/fts5/test/fts5faultI.test | 28 ++++++++++++++++++--- ext/fts5/test/fts5locale.test | 42 +++++++++++++++++++++++++++++++ manifest | 18 ++++++------- manifest.uuid | 2 +- 6 files changed, 120 insertions(+), 37 deletions(-) diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 76f57499df..03af105a75 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -526,7 +526,7 @@ static int fts5StorageDeleteFromIndex( pText, nText, (void*)&ctx, fts5StorageInsertCallback ); p->aTotalSize[iCol-1] -= (i64)ctx.szCol; - if( p->aTotalSize[iCol-1]<0 && rc==SQLITE_OK ){ + if( rc==SQLITE_OK && p->aTotalSize[iCol-1]<0 ){ rc = FTS5_CORRUPT; } if( bReset ) sqlite3Fts5ClearLocale(pConfig); @@ -618,12 +618,12 @@ static int fts5StorageInsertDocsize( rc = sqlite3Fts5IndexGetOrigin(p->pIndex, &iOrigin); sqlite3_bind_int64(pReplace, 3, iOrigin); } - if( rc==SQLITE_OK ){ - sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC); - sqlite3_step(pReplace); - rc = sqlite3_reset(pReplace); - sqlite3_bind_null(pReplace, 2); - } + } + if( rc==SQLITE_OK ){ + sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC); + sqlite3_step(pReplace); + rc = sqlite3_reset(pReplace); + sqlite3_bind_null(pReplace, 2); } } return rc; @@ -887,28 +887,28 @@ int sqlite3Fts5StorageContentInsert( rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0); for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){ sqlite3_value *pVal = apVal[i]; - if( sqlite3_value_nochange(pVal) && p->pSavedRow ){ + if( sqlite3_value_nochange(pVal) ){ /* This is an UPDATE statement, and column (i-2) was not modified. ** Retrieve the value from Fts5Storage.pSavedRow instead. */ + assert( p->pSavedRow ); pVal = sqlite3_column_value(p->pSavedRow, i-1); }else if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE ){ assert( pConfig->bLocale ); - if( i>1 ){ - if( pConfig->abUnindexed[i-2] ){ - /* At attempt to insert an fts5_locale() value into an UNINDEXED - ** column. Strip the locale away and just bind the text. */ - const char *pText = 0; - int nText = 0; - rc = sqlite3Fts5ExtractText(pConfig, pVal, 0, 0, &pText, &nText); - sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); - }else{ - const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); - int nBlob = sqlite3_value_bytes(pVal); - assert( nBlob>4 ); - sqlite3_bind_blob(pInsert, i, pBlob+4, nBlob-4, SQLITE_TRANSIENT); - } - continue; + assert( i>1 ); + if( pConfig->abUnindexed[i-2] ){ + /* At attempt to insert an fts5_locale() value into an UNINDEXED + ** column. Strip the locale away and just bind the text. */ + const char *pText = 0; + int nText = 0; + rc = sqlite3Fts5ExtractText(pConfig, pVal, 0, 0, &pText, &nText); + sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); + }else{ + const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); + int nBlob = sqlite3_value_bytes(pVal); + assert( nBlob>4 ); + sqlite3_bind_blob(pInsert, i, pBlob+4, nBlob-4, SQLITE_TRANSIENT); } + continue; } rc = sqlite3_bind_value(pInsert, i, pVal); diff --git a/ext/fts5/test/fts5corrupt.test b/ext/fts5/test/fts5corrupt.test index ae07383b23..0abd8b86de 100644 --- a/ext/fts5/test/fts5corrupt.test +++ b/ext/fts5/test/fts5corrupt.test @@ -101,4 +101,25 @@ do_catchsql_test 3.1 { SELECT * FROM t3 WHERE t3 MATCH 'o'; } {1 {fts5: missing row 3 from content table 'main'.'t3_content'}} +#-------------------------------------------------------------------- +# +reset_db +do_execsql_test 4.0 { + CREATE VIRTUAL TABLE t2 USING fts5(x); + INSERT INTO t2 VALUES('one two three'); + INSERT INTO t2 VALUES('four five six'); + INSERT INTO t2 VALUES('seven eight nine'); + INSERT INTO t2 VALUES('ten eleven twelve'); +} +do_execsql_test 4.1 { + SELECT hex(block) FROM t2_data WHERE id=1; +} {040C} +do_execsql_test 4.2 { + UPDATE t2_data SET block = X'0402' WHERE id=1 +} +breakpoint +do_catchsql_test 4.3 { + DELETE FROM t2 WHERE rowid=3 +} {1 {database disk image is malformed}} + finish_test diff --git a/ext/fts5/test/fts5faultI.test b/ext/fts5/test/fts5faultI.test index ab641b6514..d35cdc3800 100644 --- a/ext/fts5/test/fts5faultI.test +++ b/ext/fts5/test/fts5faultI.test @@ -22,8 +22,6 @@ ifcapable !fts5 { set ::testprefix fts5faultI -if 0 { - do_execsql_test 1.0 { PRAGMA encoding = utf16; CREATE VIRTUAL TABLE t1 USING fts5(x, locale=1); @@ -168,13 +166,13 @@ do_faultsim_test 7 -faults oom* -prep { } } -test { } -} + #------------------------------------------------------------------------- reset_db fts5_tclnum_register db fts5_aux_test_functions db -do_execsql_test 2.0 { +do_execsql_test 8.0 { CREATE VIRTUAL TABLE ft USING fts5( x, tokenize = "tclnum query", detail=columns ); @@ -201,6 +199,28 @@ do_faultsim_test 8.2 -faults oom* -prep { faultsim_test_result {0 1} {1 {SQL logic error}} {1 SQLITE_NOMEM} } +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 9.0 { + CREATE VIRTUAL TABLE ft USING fts5(x); + INSERT INTO ft VALUES('one two three i ii iii'); + INSERT INTO ft VALUES('four five six iv v vi'); + INSERT INTO ft VALUES('eight nine ten viii ix x'); +} {} + +faultsim_save_and_close + +do_faultsim_test 9 -faults oom* -prep { + faultsim_restore_and_reopen +} -body { + execsql { + UPDATE ft SET rowid=4 WHERE rowid=1 + } +} -test { + faultsim_test_result {0 {}} +} + finish_test diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index f647317c3b..d64df18491 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -145,6 +145,13 @@ do_execsql_test 2.17 { INSERT INTO b1(b1) VALUES('integrity-check'); } +do_execsql_test 2.18 { + INSERT INTO b1(rowid, x, y) VALUES( + test_setsubtype(45, 76), 'abc def', 'def abc' + ); + INSERT INTO b1(b1) VALUES('integrity-check'); +} + #------------------------------------------------------------------------- # Test the 'delete' command with contentless tables. # @@ -459,6 +466,10 @@ foreach_detail_mode $::testprefix { CREATE VIRTUAL TABLE ft USING fts5(x, content=x1, content_rowid=ii, locale=1, detail=%DETAIL%, columnsize=0 ); + + CREATE VIRTUAL TABLE ft2 USING fts5( + x, locale=1, detail=%DETAIL%, columnsize=0 + ); } foreach {tn v} { @@ -500,6 +511,37 @@ foreach_detail_mode $::testprefix { do_catchsql_test 10.2.$tn.8 { SELECT * FROM ft('hello') } {1 {SQL logic error}} + + do_catchsql_test 10.2.$tn.9 { + PRAGMA integrity_check; + } {0 ok} + + do_execsql_test 10.2.$tn.10 { + DELETE FROM x1; + INSERT INTO x1(ii, x) VALUES(1, 'hello world'); + } + + do_catchsql_test 10.2.$tn.11 " + INSERT INTO ft(ft, rowid, x) VALUES('delete', 1, test_setsubtype($v,76) ) + " {1 {SQL logic error}} + + do_catchsql_test 10.2.$tn.12 " + INSERT INTO ft(rowid, x) VALUES(2, test_setsubtype($v,76) ) + " {1 {SQL logic error}} + + do_execsql_test 10.2.$tn.13 { + INSERT INTO ft2(rowid, x) VALUES(1, 'hello world'); + } + do_execsql_test 10.2.$tn.14 "UPDATE ft2_content SET c0=$v" + + do_catchsql_test 10.2.$tn.15 { + PRAGMA integrity_check; + } {1 {SQL logic error}} + + do_execsql_test 10.2.$tn.16 { + DELETE FROM ft2_content; + INSERT INTO ft2(ft2) VALUES('rebuild'); + } } } diff --git a/manifest b/manifest index 5847c8b75f..1c1eedf452 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\srestore\scoverage\sof\sfts5_main.c. -D 2024-08-16T16:20:43.666 +C Add\stests\sto\srestore\scoverage\sof\sfts5_storage.c. +D 2024-08-16T17:54:00.409 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -101,7 +101,7 @@ F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 23029229021240dc21a69eb749305316103d183375413e2090c064b74b03b7f8 -F ext/fts5/fts5_storage.c 5bf88213ff5911625c142ac332ddba10dcd0869e757f91f2a3d27f27ba595992 +F ext/fts5/fts5_storage.c acece8abf1b4b2012bdad93aa2d2cf6fc0d1da919763479c7055f699c2cde96c F ext/fts5/fts5_tcl.c 1dcf08028141c40a32634bdcf2d5601622ce4edc48f82ac4ce0cbe0a92a6961d F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -146,7 +146,7 @@ F ext/fts5/test/fts5contentless2.test 70ffe6c611d8f278240da56734df8a77948f04e273 F ext/fts5/test/fts5contentless3.test 75eaae5ad6b284ee447788943974d323228f27cc35a1681da997135cff95bc6a F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b05ea89964c863833b6eff8 F ext/fts5/test/fts5contentless5.test 40cdcb4fe751672450829c5a96bd32c25fc2f6076279dd2ce5c58ac9a390132a -F ext/fts5/test/fts5corrupt.test a9bda1ded5112ebf1ee85c5381bd1fe8974952e2523cede4d5072804d2011503 +F ext/fts5/test/fts5corrupt.test 6485f721b88ba355ca5d701e7ee87a4efa3ea578d8e6adb26f51ef956c8328bd F ext/fts5/test/fts5corrupt2.test 335911e3f68b9625d850325f9e29a128db3f4276a8c9d4e32134580da8f924c4 F ext/fts5/test/fts5corrupt3.test b5f35d72af85b1d5a092b3d5e437f7944d142dd0b0c87b928fd0436a0aec6987 F ext/fts5/test/fts5corrupt4.test dc08d19f5b8943e95a7778a7d8da592042504faf18dd93f68f7d7a0d7d7dd733 @@ -177,7 +177,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5faultI.test eb0910ec0fa57b4e06241c58252124155e689770b4dd2d8f4f3fc74185be934e +F ext/fts5/test/fts5faultI.test e57fa07b771565fcb7aa2b2c349a5104812b4edd86d09ca531afd9b247cf36dd F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -187,7 +187,7 @@ F ext/fts5/test/fts5interrupt.test 20d04204d3e341b104c0c24a41596b6393a3a81eba104 F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 5ad9f1b66db4d698c67284f3495007be94f8c6ed183688e64defed72a169b6c0 +F ext/fts5/test/fts5locale.test 79cbd3000ae269de50826f6061c81f7c9fdb21dd9954c0b7f9485263482c539d F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2208,8 +2208,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fb257540d32ced4a5fe0759d3ad9c1b36fd2b7d64d93cb0a0ecdb48355a68b7a -R 067a05b128f4dcdbb34743e9c0788abc +P 681edd08ab7024ddcd6447a64d8aad581b47b039481b697d91d26e6c6660f373 +R 39ee8d76619b01513c02abf781a1c1d5 U dan -Z 1b380833fd7dd34e177f4e045cee1c46 +Z 17e6bca1c1b4a8da8fc2bb9198c32b95 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e93e9346cb..9ad6542d4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -681edd08ab7024ddcd6447a64d8aad581b47b039481b697d91d26e6c6660f373 +38841881a08f4d75c2dfcbc1b2b45e311d7dda1287780f8ba1c8388f7adc1629 From 342984075b04c9edc5f719091bd187c56a07089e Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 16 Aug 2024 19:05:47 +0000 Subject: [PATCH 0673/1030] Add tests to restore coverage of fts5_config.c. FossilOrigin-Name: 9d971b31df7ad4d68eb348f95d8f996071cf87d41c47033bde3fcc4dba732e06 --- ext/fts5/fts5_config.c | 11 ++++------- ext/fts5/test/fts5contentless.test | 20 ++++++++++++++++++++ ext/fts5/test/fts5origintext.test | 11 +++++++++-- ext/fts5/test/fts5secure8.test | 4 ++++ manifest | 18 +++++++++--------- manifest.uuid | 2 +- 6 files changed, 47 insertions(+), 19 deletions(-) diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index b11193ec23..3cb1bd3bea 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -1031,13 +1031,10 @@ int sqlite3Fts5ConfigLoad(Fts5Config *pConfig, int iCookie){ && iVersion!=FTS5_CURRENT_VERSION_SECUREDELETE ){ rc = SQLITE_ERROR; - if( pConfig->pzErrmsg ){ - assert( 0==*pConfig->pzErrmsg ); - sqlite3Fts5ConfigErrmsg(pConfig, "invalid fts5 file format " - "(found %d, expected %d or %d) - run 'rebuild'", - iVersion, FTS5_CURRENT_VERSION, FTS5_CURRENT_VERSION_SECUREDELETE - ); - } + sqlite3Fts5ConfigErrmsg(pConfig, "invalid fts5 file format " + "(found %d, expected %d or %d) - run 'rebuild'", + iVersion, FTS5_CURRENT_VERSION, FTS5_CURRENT_VERSION_SECUREDELETE + ); }else{ pConfig->iVersion = iVersion; } diff --git a/ext/fts5/test/fts5contentless.test b/ext/fts5/test/fts5contentless.test index eb6b928ab8..991e9888fc 100644 --- a/ext/fts5/test/fts5contentless.test +++ b/ext/fts5/test/fts5contentless.test @@ -267,4 +267,24 @@ do_execsql_test 8.2 { SELECT rowid FROM ft('four'); } {} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 9.0 { + CREATE VIRTUAL TABLE ft USING fts5(x, content='', contentless_delete=0); + INSERT INTO ft VALUES('hello world'); + INSERT INTO ft VALUES('one two three'); +} + +do_catchsql_test 9.1 { + INSERT INTO ft(ft, rowid, x) VALUES('delete', 1, 'hello world'); +} {0 {}} + +do_catchsql_test 9.2 { + CREATE VIRTUAL TABLE ft2 USING fts5(x, content='', contentless_delete=2); +} {1 {malformed contentless_delete=... directive}} + +do_catchsql_test 9.3 { + CREATE VIRTUAL TABLE ft2 USING fts5(x, content='', contentless_delete=11); +} {1 {malformed contentless_delete=... directive}} + finish_test diff --git a/ext/fts5/test/fts5origintext.test b/ext/fts5/test/fts5origintext.test index 1612b0d7f4..8e975fa17c 100644 --- a/ext/fts5/test/fts5origintext.test +++ b/ext/fts5/test/fts5origintext.test @@ -261,8 +261,8 @@ do_execsql_test 5.3 { reset_db sqlite3_fts5_register_origintext db do_execsql_test 6.0 { - CREATE VIRTUAL TABLE ft USING fts5( - x, y, tokenize='origintext unicode61', detail=%DETAIL% + CREATE VIRTUAL TABLE ft USING fts5( + x, y, tokenize='origintext unicode61', detail=%DETAIL%, tokendata=0 ); INSERT INTO ft VALUES('One Two', 'Three two'); @@ -300,6 +300,13 @@ do_catchsql_test 6.5 { SELECT fts5_test_insttoken(ft, 1, 0) FROM ft('one'); } {1 SQLITE_RANGE} +do_catchsql_test 6.6 { + CREATE VIRTUAL TABLE ft2 USING fts5(x, tokendata=2); +} {1 {malformed tokendata=... directive}} +do_catchsql_test 6.7 { + CREATE VIRTUAL TABLE ft2 USING fts5(x, content='', tokendata=11); +} {1 {malformed tokendata=... directive}} + } finish_test diff --git a/ext/fts5/test/fts5secure8.test b/ext/fts5/test/fts5secure8.test index 0216bb6ea1..8b65b7c59f 100644 --- a/ext/fts5/test/fts5secure8.test +++ b/ext/fts5/test/fts5secure8.test @@ -58,6 +58,10 @@ do_execsql_test 2.1 { pragma quick_check; } {ok} +do_catchsql_test 2.2 { + INSERT INTO xyz(xyz, rank) VALUES('secure-delete', 'hello world'); +} {1 {SQL logic error}} + diff --git a/manifest b/manifest index 1c1eedf452..8e78f14e63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\srestore\scoverage\sof\sfts5_storage.c. -D 2024-08-16T17:54:00.409 +C Add\stests\sto\srestore\scoverage\sof\sfts5_config.c. +D 2024-08-16T19:05:47.160 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -96,7 +96,7 @@ F ext/fts5/fts5.h 4c6998c6186268b4dbe9baef2c0d2ab974bd90996d61d4dbe801367249be6d F ext/fts5/fts5Int.h 26a71a09cefa4ef6b4516b204ed48da3e1380970a19b3482eea7c5d805655360 F ext/fts5/fts5_aux.c 12cd2512f869217c38b70c31de5b5f741812734fafa80f55b32ea9bbd96e2152 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 187f7ffa5eddd6539ffa592de85e95b18be951728491390121bb215549a24a2a +F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81cbefc109ea F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe @@ -141,7 +141,7 @@ F ext/fts5/test/fts5config.test 017daf10d2642496e97402baa0134de8b5b46b9c37e53c22 F ext/fts5/test/fts5conflict.test bf6030a77dbb1bedfcc42e589ed7980846c995765d77460551e448b56d741244 F ext/fts5/test/fts5connect.test 08030168fc96fc278fa81f28654fb7e90566f33aff269c073e19b3ae9126b2f4 F ext/fts5/test/fts5content.test d5c0c2142e64cb305f0968de70c01f8e59dbc3ecc56520c22e739e5dd99ea3bb -F ext/fts5/test/fts5contentless.test b107465f8cd27dde6313b9c60b61d7158a7753b9c663c5c553695f826bb3c0a5 +F ext/fts5/test/fts5contentless.test 606f063b29ba0f46d4b79aa36cdd1ef4dab5de53eae8c881d731af75a4894aca F ext/fts5/test/fts5contentless2.test 70ffe6c611d8f278240da56734df8a77948f04e2739b358439e9bdcf56ced35f F ext/fts5/test/fts5contentless3.test 75eaae5ad6b284ee447788943974d323228f27cc35a1681da997135cff95bc6a F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b05ea89964c863833b6eff8 @@ -199,7 +199,7 @@ F ext/fts5/test/fts5onepass.test f9b7d9b2c334900c6542a869760290e2ab5382af8fbd618 F ext/fts5/test/fts5optimize.test 264b9101721c17d06d1d174feb743fda3ddc89fad41dee980fef821428258e47 F ext/fts5/test/fts5optimize2.test 795d4ae5f66a7239cf8d5aef4c2ea96aeb8bcd907bd9be0cfe22064fc71a44ed F ext/fts5/test/fts5optimize3.test 1653029284e10e0715246819893ba30565c4ead0d0fc470adae92c353ea857d3 -F ext/fts5/test/fts5origintext.test 002abba00b334cb4b3f957f940f75b9ab53f4caae97aa753e19da285c245e463 +F ext/fts5/test/fts5origintext.test 2015f69bc8abd111152a8e66211fd2d45026378001e07c054159aa4f84e6691d F ext/fts5/test/fts5origintext2.test f4505ff79bf7369f2b8b10b9cef7476049d844e20b37f29cad3a8b8d5ac6f9ba F ext/fts5/test/fts5origintext3.test 45c33cf0c91a9ca0e36d298462db3edc7c8fe45fd185649a9dbfd66bb670058b F ext/fts5/test/fts5origintext4.test 0d3ef0a8038f471dbc83001c34fe5f7ae39b571bfc209670771eb28bc0fc50e8 @@ -223,7 +223,7 @@ F ext/fts5/test/fts5secure4.test 0d10a80590c07891478700af7793b232962042677432b98 F ext/fts5/test/fts5secure5.test c07a68ced5951567ac116c22f2d2aafae497e47fe9fcb6a335c22f9c7a4f2c3a F ext/fts5/test/fts5secure6.test 74bf04733cc523bccca519bb03d3b4e2ed6f6e3db7c59bf6be82c88a0ac857fd F ext/fts5/test/fts5secure7.test fd03d0868d64340a1db8615b02e5508fea409de13910114e4f19eaefc120777a -F ext/fts5/test/fts5secure8.test e68c0ac4447f415ff3e4e82531e99548289286f9f3a29c8cd53036113fe28602 +F ext/fts5/test/fts5secure8.test 808ade9d172ed07b24b85c57dd53b6d2b1aba018b4e634d267ce572221de80e0 F ext/fts5/test/fts5securefault.test c34a28c7cd2f31a8b8907563889e1329a97da975c08df2d951422bcef8e2ebc5 F ext/fts5/test/fts5simple.test ed7c3815c9fa1c16166258cb98edb2e014c63c7589958d76c5487df0df913d61 F ext/fts5/test/fts5simple2.test d10d963a357b8ec77b99032e4c816459b4dbdb1f6eee25eada7ef3ed245cb2dc @@ -2208,8 +2208,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 681edd08ab7024ddcd6447a64d8aad581b47b039481b697d91d26e6c6660f373 -R 39ee8d76619b01513c02abf781a1c1d5 +P 38841881a08f4d75c2dfcbc1b2b45e311d7dda1287780f8ba1c8388f7adc1629 +R d19b3ba3504e0807fa9fc6488171b084 U dan -Z 17e6bca1c1b4a8da8fc2bb9198c32b95 +Z 92294a85664ab83f8a52ccaa818e0f8f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9ad6542d4f..cd18c0e49e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38841881a08f4d75c2dfcbc1b2b45e311d7dda1287780f8ba1c8388f7adc1629 +9d971b31df7ad4d68eb348f95d8f996071cf87d41c47033bde3fcc4dba732e06 From 52d03102562a4a141357cc3a48f4b903df3aa3bb Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Aug 2024 14:59:26 +0000 Subject: [PATCH 0674/1030] Fix a typo in an "ifdef" that broke SQLITE_OMIT_ANALYZE builds. FossilOrigin-Name: c09da26cb6f772a18c595ff0eb55d8345a377c3ef5ed02a5e539ffdbe9d07f85 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index dd7e947eb5..704cb20843 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\ssubquery\shas\san\sORDER\sBY\sclause\sand\sthat\sordering\sis\shelpfile\sin\nsatisfying\sthe\sORDER\sBY\sor\sGROUP\sBY\sof\sthe\souter\squery\swithout\sdoing\san\nextra\ssort,\sthen\somit\sor\sreduce\sthe\ssort\sin\sthe\souter\squery.\s\sCall\nthis\sthe\s"order-by-subquery\soptimization". -D 2024-08-16T18:51:46.975 +C Fix\sa\stypo\sin\san\s"ifdef"\sthat\sbroke\sSQLITE_OMIT_ANALYZE\sbuilds. +D 2024-08-17T14:59:26.789 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -831,7 +831,7 @@ F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 -F src/vdbe.c de13de572eccb688b2b7cf50e2f9005c44bf9ae89e35245ef8eadfc60dfd2764 +F src/vdbe.c be5f58bc29f60252e041a618eae59e8d57d460ba136c5403cf0abf955560c457 F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df @@ -2205,9 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a1915cbdeccac2ed49fb8a9733abf2c6239396e3174fed2ff275f66b606c48b6 41a41c173a9d15d94f23d73a5c04bfb1616cb9223bc81d41808f9b4d00817fbf -R a24a84e9d7ceff04c159b78242edac9d -T +closed 41a41c173a9d15d94f23d73a5c04bfb1616cb9223bc81d41808f9b4d00817fbf -U drh -Z 169fa841b16225f819f8996d6765647e +P 7a0cdc7edb704a88a77b748cd28f6e00c49849cc2c1af838b95b34232ecc21f9 +R 501e32d0617414047f040d4ae2e8bb39 +U dan +Z 4ff808b9d2897218daeb3b1363a873d1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d32d2498e4..a4764edcfc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a0cdc7edb704a88a77b748cd28f6e00c49849cc2c1af838b95b34232ecc21f9 +c09da26cb6f772a18c595ff0eb55d8345a377c3ef5ed02a5e539ffdbe9d07f85 diff --git a/src/vdbe.c b/src/vdbe.c index d097bfd8b9..ea69c759c2 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2096,7 +2096,7 @@ case OP_RealAffinity: { /* in1 */ } #endif -#if !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_ANALYZE) +#if !defined(SQLITE_OMIT_CAST) || !defined(SQLITE_OMIT_ANALYZE) /* Opcode: Cast P1 P2 * * * ** Synopsis: affinity(r[P1]) ** From f87a54ab41de3d7a276059c19f47aa1f9c93ecff Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 17 Aug 2024 15:52:21 +0000 Subject: [PATCH 0675/1030] Adjust the "configure" script so that it just disables the ability to run tests rather than erroring out if tclsh is unable to recommend a suitable tclConfig.sh. FossilOrigin-Name: 793ff83d09bea165c8cedc978afd3fcfb1a4cee894c5914aa1d92416afce963d --- configure | 8 +++++++- configure.ac | 7 ++++++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 50d9e2b3d0..5f60385c28 100755 --- a/configure +++ b/configure @@ -10330,6 +10330,7 @@ else use_tcl=yes fi +original_use_tcl=${use_tcl} if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then for ac_prog in tclsh8.6 tclsh tclsh9.0 do @@ -10388,6 +10389,7 @@ $as_echo "$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $TCLSH_CMD is unable to recommend a tclConfig.sh" >&5 $as_echo "$as_me: WARNING: $TCLSH_CMD is unable to recommend a tclConfig.sh" >&2;} + use_tcl=no fi fi fi @@ -10438,10 +10440,14 @@ $as_echo "loading TCL configuration from ${tclconfig}" >&6; } # tclConfig.sh file and that could be included here. But as of right now, # TCL_LIB_SPEC is the only what that the Makefile uses. HAVE_TCL=1 -else +elif test x"${original_use_tcl}" = "xno"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: unable to run tests because of --disable-tcl" >&5 $as_echo "unable to run tests because of --disable-tcl" >&6; } HAVE_TCL=0 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unable to run tests because no tclConfig.sh file could be located" >&5 +$as_echo "unable to run tests because no tclConfig.sh file could be located" >&6; } + HAVE_TCL=0 fi if test x"$TCLSH_CMD" == x; then diff --git a/configure.ac b/configure.ac index 4f95a5c08c..2936c4ab5a 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,7 @@ AC_ARG_WITH(tclsh, AS_HELP_STRING([--with-tclsh=PATHNAME],[full pathname of a tc AC_ARG_WITH(tcl, AS_HELP_STRING([--with-tcl=DIR],[directory containing (tclConfig.sh)])) AC_ARG_ENABLE(tcl, AS_HELP_STRING([--disable-tcl],[omit building accessory programs that require TCL-dev]), [use_tcl=$enableval],[use_tcl=yes]) +original_use_tcl=${use_tcl} if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh tclsh9.0],none) with_tclsh=${TCLSH_CMD} @@ -136,6 +137,7 @@ if test x"${with_tclsh}" != x -a x"${with_tclsh}" != xnone; then AC_MSG_RESULT([$TCLSH_CMD recommends the tclConfig.sh at ${with_tcl}]) else AC_MSG_WARN([$TCLSH_CMD is unable to recommend a tclConfig.sh]) + use_tcl=no fi fi fi @@ -185,9 +187,12 @@ if test x"${use_tcl}" = "xyes"; then # tclConfig.sh file and that could be included here. But as of right now, # TCL_LIB_SPEC is the only what that the Makefile uses. HAVE_TCL=1 -else +elif test x"${original_use_tcl}" = "xno"; then AC_MSG_RESULT([unable to run tests because of --disable-tcl]) HAVE_TCL=0 +else + AC_MSG_RESULT([unable to run tests because no tclConfig.sh file could be located]) + HAVE_TCL=0 fi AC_SUBST(HAVE_TCL) if test x"$TCLSH_CMD" == x; then diff --git a/manifest b/manifest index 704cb20843..8b5e68507a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\san\s"ifdef"\sthat\sbroke\sSQLITE_OMIT_ANALYZE\sbuilds. -D 2024-08-17T14:59:26.789 +C Adjust\sthe\s"configure"\sscript\sso\sthat\sit\sjust\sdisables\sthe\sability\sto\nrun\stests\srather\sthan\serroring\sout\sif\stclsh\sis\sunable\sto\srecommend\sa\nsuitable\stclConfig.sh. +D 2024-08-17T15:52:21.666 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 2e5058c2ba2c6b50a01cf50c158180c4ec969b2068c2e361dfbfc875ec3f9d1c x -F configure.ac b7e26a699a2ffc5eb7a25636f32755c27bbb665777b68ef35a90c1ee9bd9d469 +F configure 956e132a3e2481e5016e9ecaa0a2bdd9df95c1d923fa4fb2aa2cf9f0b3a54ad9 x +F configure.ac fd9ff064b142682964971fec3d867235e51e1f6de30a031e33f683b7699338ff F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7a0cdc7edb704a88a77b748cd28f6e00c49849cc2c1af838b95b34232ecc21f9 -R 501e32d0617414047f040d4ae2e8bb39 -U dan -Z 4ff808b9d2897218daeb3b1363a873d1 +P c09da26cb6f772a18c595ff0eb55d8345a377c3ef5ed02a5e539ffdbe9d07f85 +R 8082c14d3791ff31a3c70ef600eeef0f +U drh +Z 2bdc019c3dd756a5d860815c6dd9a72b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a4764edcfc..1e3ae45cbc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c09da26cb6f772a18c595ff0eb55d8345a377c3ef5ed02a5e539ffdbe9d07f85 +793ff83d09bea165c8cedc978afd3fcfb1a4cee894c5914aa1d92416afce963d From 21363ac78df6751655c33372a7277512531b9570 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 17 Aug 2024 16:17:16 +0000 Subject: [PATCH 0676/1030] Adjust Makefile.in so that it outputs a slightly better error message on an attempt to build something that requires TCL libraries when HAVE_TCL is false. FossilOrigin-Name: a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 --- Makefile.in | 14 +++++++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index 7ff6e901e4..44665184fc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -796,6 +796,10 @@ has_tclsh85: sh $(TOP)/tool/cktclsh.sh 8.5 $(TCLSH_CMD) touch has_tclsh85 +has_tclconfig: + @ if test x"$(HAVE_TCL)" != "x1"; then echo 'ERROR: Requires access to "tclConfig.sh" which "configure" was not able to locate'; exit 1; fi + touch has_tclconfig + # This target creates a directory named "tsrc" and fills it with # copies of all of the C source code and header files needed to @@ -1118,7 +1122,7 @@ tclsqlite-shell.lo: $(TOP)/src/tclsqlite.c $(HDR) tclsqlite-stubs.lo: $(TOP)/src/tclsqlite.c $(HDR) $(LTCOMPILE) -DUSE_TCL_STUBS=1 -o $@ -c $(TOP)/src/tclsqlite.c -tclsqlite3$(TEXE): tclsqlite-shell.lo libsqlite3.la +tclsqlite3$(TEXE): has_tclconfig tclsqlite-shell.lo libsqlite3.la $(LTLINK) -o $@ tclsqlite-shell.lo \ libsqlite3.la $(LIBTCL) @@ -1305,7 +1309,7 @@ TESTFIXTURE_SRC1 = sqlite3.c TESTFIXTURE_SRC = $(TESTSRC) $(TOP)/src/tclsqlite.c TESTFIXTURE_SRC += $(TESTFIXTURE_SRC$(USE_AMALGAMATION)) -testfixture$(TEXE): has_tclsh85 $(TESTFIXTURE_SRC) +testfixture$(TEXE): has_tclconfig has_tclsh85 $(TESTFIXTURE_SRC) $(LTLINK) -DSQLITE_NO_SYNC=1 $(TEMP_STORE) $(TESTFIXTURE_FLAGS) \ -o $@ $(TESTFIXTURE_SRC) $(LIBTCL) $(TLIBS) @@ -1404,13 +1408,13 @@ shelltest: $(TESTPROGS) sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in has_tclsh85 $(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in >sqlite3_analyzer.c -sqlite3_analyzer$(TEXE): sqlite3_analyzer.c +sqlite3_analyzer$(TEXE): has_tclconfig sqlite3_analyzer.c $(LTLINK) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS) sqltclsh.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/ext/misc/appendvfs.c $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in has_tclsh85 $(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in >sqltclsh.c -sqltclsh$(TEXE): sqltclsh.c +sqltclsh$(TEXE): has_tclconfig sqltclsh.c $(LTLINK) sqltclsh.c -o $@ $(LIBTCL) $(TLIBS) sqlite3_expert$(TEXE): $(TOP)/ext/expert/sqlite3expert.h $(TOP)/ext/expert/sqlite3expert.c $(TOP)/ext/expert/expert.c sqlite3.c @@ -1429,7 +1433,7 @@ CHECKER_DEPS =\ sqlite3_checker.c: $(CHECKER_DEPS) has_tclsh85 $(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/ext/repair/sqlite3_checker.c.in >$@ -sqlite3_checker$(TEXE): sqlite3_checker.c +sqlite3_checker$(TEXE): has_tclconfig sqlite3_checker.c $(LTLINK) sqlite3_checker.c -o $@ $(LIBTCL) $(TLIBS) dbdump$(TEXE): $(TOP)/ext/misc/dbdump.c sqlite3.lo diff --git a/manifest b/manifest index 8b5e68507a..bd4f4cbe1c 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Adjust\sthe\s"configure"\sscript\sso\sthat\sit\sjust\sdisables\sthe\sability\sto\nrun\stests\srather\sthan\serroring\sout\sif\stclsh\sis\sunable\sto\srecommend\sa\nsuitable\stclConfig.sh. -D 2024-08-17T15:52:21.666 +C Adjust\sMakefile.in\sso\sthat\sit\soutputs\sa\sslightly\sbetter\serror\smessage\son\san\nattempt\sto\sbuild\ssomething\sthat\srequires\sTCL\slibraries\swhen\sHAVE_TCL\sis\sfalse. +D 2024-08-17T16:17:16.045 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in cf96aa7d2682650dec56dc2f03cfe463feb101a1be594e4929bcd38662bc2ea8 +F Makefile.in 209e9c64edf499b0ea7a15448699101c01d15828af35a3439d32fc25fdf1b787 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 6c3fe8b6ce60e73f34a148c957d78b4648745c8d30e792423aa1a8d8bf12d065 F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c09da26cb6f772a18c595ff0eb55d8345a377c3ef5ed02a5e539ffdbe9d07f85 -R 8082c14d3791ff31a3c70ef600eeef0f +P 793ff83d09bea165c8cedc978afd3fcfb1a4cee894c5914aa1d92416afce963d +R be5ece8b231f01bec02cbe9ef4eda884 U drh -Z 2bdc019c3dd756a5d860815c6dd9a72b +Z 6d429e685f531219ca0d0afba9760eb7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e3ae45cbc..a5034c9d32 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -793ff83d09bea165c8cedc978afd3fcfb1a4cee894c5914aa1d92416afce963d +a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 From b651084713e8bb9a6a7a0399a00677604d157b2f Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Aug 2024 17:22:49 +0000 Subject: [PATCH 0677/1030] Add tests to restore coverage of fts5_tokenizer.c. FossilOrigin-Name: 8f9257361b05e368bf433e56d0698923b0f97d12e7c0ad7760aaab6746c0e467 --- ext/fts3/unicode/mkunicode.tcl | 3 ++ ext/fts5/fts5_tokenize.c | 68 +++++++++++++++++---------------- ext/fts5/fts5_unicode2.c | 3 ++ ext/fts5/test/fts5cat.test | 17 +++++++++ ext/fts5/test/fts5trigram.test | 56 +++++++++++++++++++++++++++ ext/fts5/test/fts5unicode2.test | 20 ++++++++++ manifest | 22 +++++------ manifest.uuid | 2 +- 8 files changed, 146 insertions(+), 45 deletions(-) diff --git a/ext/fts3/unicode/mkunicode.tcl b/ext/fts3/unicode/mkunicode.tcl index 58d90c68c7..1306629da8 100644 --- a/ext/fts3/unicode/mkunicode.tcl +++ b/ext/fts3/unicode/mkunicode.tcl @@ -628,6 +628,9 @@ proc print_categories {lMap} { $caseP $caseS $caseZ + + default: + return 1; } return 0; } diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index 7a36b750a1..f92529b840 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -79,7 +79,7 @@ static int fts5AsciiCreate( int i; memset(p, 0, sizeof(AsciiTokenizer)); memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar)); - for(i=0; rc==SQLITE_OK && ibFold = 1; - pNew->iFoldParam = 0; - for(i=0; rc==SQLITE_OK && ibFold = 1; + pNew->iFoldParam = 0; + + for(i=0; rc==SQLITE_OK && ibFold = (zArg[0]=='0'); + } + }else if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){ + if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){ + rc = SQLITE_ERROR; + }else{ + pNew->iFoldParam = (zArg[0]!='0') ? 2 : 0; + } }else{ - pNew->bFold = (zArg[0]=='0'); - } - }else if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){ - if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){ rc = SQLITE_ERROR; - }else{ - pNew->iFoldParam = (zArg[0]!='0') ? 2 : 0; } - }else{ + } + + if( pNew->iFoldParam!=0 && pNew->bFold==0 ){ rc = SQLITE_ERROR; } - } - if( iiFoldParam!=0 && pNew->bFold==0 ){ - rc = SQLITE_ERROR; - } - - if( rc!=SQLITE_OK ){ - fts5TriDelete((Fts5Tokenizer*)pNew); - pNew = 0; + + if( rc!=SQLITE_OK ){ + fts5TriDelete((Fts5Tokenizer*)pNew); + pNew = 0; + } } } *ppOut = (Fts5Tokenizer*)pNew; diff --git a/ext/fts5/fts5_unicode2.c b/ext/fts5/fts5_unicode2.c index 3e97264fa8..cc164a4569 100644 --- a/ext/fts5/fts5_unicode2.c +++ b/ext/fts5/fts5_unicode2.c @@ -364,6 +364,9 @@ int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){ default: return 1; } break; + + default: + return 1; } return 0; } diff --git a/ext/fts5/test/fts5cat.test b/ext/fts5/test/fts5cat.test index 483f64bfef..71e2abe3ae 100644 --- a/ext/fts5/test/fts5cat.test +++ b/ext/fts5/test/fts5cat.test @@ -55,5 +55,22 @@ do_execsql_test 1.5 { SELECT * FROM t4t } {สนามกีฬา 1 1} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 " + CREATE VIRTUAL TABLE x1 USING fts5(c, + tokenize=\"unicode61 categories ' \t'\"); +" + +do_catchsql_test 2.1 " + CREATE VIRTUAL TABLE x2 USING fts5(c, + tokenize=\"unicode61 categories 'N*\t\tMYZ'\"); +" {1 {error in tokenizer constructor}} + +do_catchsql_test 2.2 " + CREATE VIRTUAL TABLE x2 USING fts5(c, + tokenize=\"unicode61 categories 'N*\t\tXYZ'\"); +" {1 {error in tokenizer constructor}} + finish_test diff --git a/ext/fts5/test/fts5trigram.test b/ext/fts5/test/fts5trigram.test index b76dbda063..b06d35d6d1 100644 --- a/ext/fts5/test/fts5trigram.test +++ b/ext/fts5/test/fts5trigram.test @@ -286,5 +286,61 @@ do_execsql_test 9.3 { SELECT rowid FROM t1 WHERE a12 LIKE NULL } {} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 10.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, tokenize=trigram); +} + +do_test 10.1 { + foreach {val} { + "abc \UFFjkl\UFF" + "abc \UFFFjkl\UFFF" + "abc \UFFFFjkl\UFFFF" + "abc \UFFFFFjkl\UFFFFF" + "\UFFjkl\UFF abc" + "\UFFFjkl\UFFF abc" + "\UFFFFjkl\UFFFF abc" + "\UFFFFFjkl\UFFFFF abc" + "\U10001jkl\U10001 abc" + } { + execsql { INSERT INTO t1 VALUES( $val ) } + } +} {} + +do_test 10.2 { + foreach {val} { + X'E18000626320646566' + X'61EDA0806320646566' + X'61EDA0806320646566' + X'61EFBFBE6320646566' + X'76686920E18000626320646566' + X'7668692061EDA0806320646566' + X'7668692061EDA0806320646566' + X'7668692061EFBFBE6320646566' + } { + execsql " INSERT INTO t1 VALUES( $val ) " + } +} {} + +do_test 10.3 { + set a [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0x62}] + set b [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0x62}] + set c [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}] + set d [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}] + execsql { + INSERT INTO t1 VALUES($a); + INSERT INTO t1 VALUES($b); + INSERT INTO t1 VALUES($c); + INSERT INTO t1 VALUES($d); + + INSERT INTO t1 VALUES('abcd' || $a); + INSERT INTO t1 VALUES('abcd' || $b); + INSERT INTO t1 VALUES('abcd' || $c); + INSERT INTO t1 VALUES('abcd' || $d); + } +} {} + + finish_test diff --git a/ext/fts5/test/fts5unicode2.test b/ext/fts5/test/fts5unicode2.test index 3fc1f673a4..7a49a1d83f 100644 --- a/ext/fts5/test/fts5unicode2.test +++ b/ext/fts5/test/fts5unicode2.test @@ -470,4 +470,24 @@ do_execsql_test 8.2.3 { SELECT rowid FROM t4 WHERE t4 MATCH 'a' ORDER BY rowid ASC; } {2 4} +#------------------------------------------------------------------------- + +foreach {tn val bErr} { + 1 0 0 + 2 1 0 + 3 2 0 + 4 3 1 + 5 11 1 +} { + reset_db + set aRes(0) {0 {}} + set aRes(1) {1 {error in tokenizer constructor}} + set res $aRes($bErr) + do_catchsql_test 9.1.$tn " + CREATE VIRTUAL TABLE bl USING fts5( + s, tokenize='trigram remove_diacritics $val' + ); + " $res +} + finish_test diff --git a/manifest b/manifest index 8e78f14e63..4a616cffcb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\srestore\scoverage\sof\sfts5_config.c. -D 2024-08-16T19:05:47.160 +C Add\stests\sto\srestore\scoverage\sof\sfts5_tokenizer.c. +D 2024-08-17T17:22:49.665 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -89,7 +89,7 @@ F ext/fts3/tool/fts3cov.sh c331d006359456cf6f8f953e37f2b9c7d568f3863f00bb5f7eb87 F ext/fts3/tool/fts3view.c 413c346399159df81f86c4928b7c4a455caab73bfbc8cd68f950f632e5751674 F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 -F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 +F ext/fts3/unicode/mkunicode.tcl 63db9624ccf70d4887836c320eda93ab552f21008f3be7ede551eac3ead62baa F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e F ext/fts5/fts5.h 4c6998c6186268b4dbe9baef2c0d2ab974bd90996d61d4dbe801367249be6de4 @@ -105,8 +105,8 @@ F ext/fts5/fts5_storage.c acece8abf1b4b2012bdad93aa2d2cf6fc0d1da919763479c7055f6 F ext/fts5/fts5_tcl.c 1dcf08028141c40a32634bdcf2d5601622ce4edc48f82ac4ce0cbe0a92a6961d F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b -F ext/fts5/fts5_tokenize.c 96efa85a21a85276680ce3fb19dc5dd8d6b6541b2c37f953ee55bc15092262e1 -F ext/fts5/fts5_unicode2.c eca63dbc797f8ff0572e97caf4631389c0ab900d6364861b915bdd4735973f00 +F ext/fts5/fts5_tokenize.c ae9c4fa93174ef06ffc138bd4280a1c37f7e13624d3d2706aad4b80573f23c41 +F ext/fts5/fts5_unicode2.c 6f9b0fb79a8facaed76628ffd4eb9c16d7f2b84b52872784f617cf3422a9b043 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 @@ -133,7 +133,7 @@ F ext/fts5/test/fts5bigid.test 2860854c2561a57594192b00c33a29f91cb85e25f3d6c03b5 F ext/fts5/test/fts5bigpl.test 8f09858aab866c33593560e6480b2b6975ae7ff29ca32ad7b77e2da61402f8ef F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36 F ext/fts5/test/fts5blob.test caa33369e93e99ff494cd1103506ae34c5afbc0bcc369ed5e58e135144e33689 -F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a +F ext/fts5/test/fts5cat.test bf67dd335f964482ee658287521b81e2b88697b45eb7f73933e15f198ed447cb F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62 F ext/fts5/test/fts5colset.test 544f4998cdbfe06a3123887fc0221612e8aa8192cdaff152872f1aadb10e6897 F ext/fts5/test/fts5columnsize.test 0af91d63985afdf663455d4b572b935238380140d74079eac362760866d3297b @@ -235,12 +235,12 @@ F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test 7937cec672b148223fff8746d21d3e7ed0965fd7caf35ccdc888a005bb452f98 F ext/fts5/test/fts5tokenizer2.test ddb8b10fbe4b84b2a75812671f127774c1d2e3e2bf82d2e0e4f0bb1cd8a2b2d6 F ext/fts5/test/fts5tokenizer3.test eea778f7bb7024c3e904e28915f9d53286141671b138722148be22a9c758bdc3 -F ext/fts5/test/fts5trigram.test f99fc0235e967826e556de9aee959d3cb8eae2e9abff37b5fe2732fd7052dac2 +F ext/fts5/test/fts5trigram.test fcb6b93510b917add63aee8f363c466ac406528822951e76e0980ce6f5170978 F ext/fts5/test/fts5trigram2.test 6fde9de7f63a6b4aa18dc731be56dbd6be4e755c9b13dcd55479e200d1df0e61 F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 F ext/fts5/test/fts5unicode.test 41898f7e476e6515cd4b737c02a442cda5a580a74509788aa9072a2074948e0e -F ext/fts5/test/fts5unicode2.test a5c38179b311a188b24376772309389b073c996f52b79bb9ca760a19e62043ea +F ext/fts5/test/fts5unicode2.test 3bbd30152f9f760bf13886e5b1e5ec23ff62f56758ddda5d9c775a6082fb4c7c F ext/fts5/test/fts5unicode3.test f4891a3dac3b49c3d7c0fdb29566e9eb0ecff35263370c89f9661b1952b20818 F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8df04eff87923c74b4d0 F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae @@ -2208,8 +2208,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38841881a08f4d75c2dfcbc1b2b45e311d7dda1287780f8ba1c8388f7adc1629 -R d19b3ba3504e0807fa9fc6488171b084 +P 9d971b31df7ad4d68eb348f95d8f996071cf87d41c47033bde3fcc4dba732e06 +R 00d1f889322bc8b1a7560fd99767ae0b U dan -Z 92294a85664ab83f8a52ccaa818e0f8f +Z 653dde5241b23832e0da59a6216ceb6f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cd18c0e49e..c8caf8375f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d971b31df7ad4d68eb348f95d8f996071cf87d41c47033bde3fcc4dba732e06 +8f9257361b05e368bf433e56d0698923b0f97d12e7c0ad7760aaab6746c0e467 From ef2401f66978d62187859c1039dc7e385dbb51c6 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Aug 2024 19:07:13 +0000 Subject: [PATCH 0678/1030] Tests to improve coverage of fts5_expr.c. FossilOrigin-Name: f4b839e5265700b1a89066d1b6e0d0d010852a69c5da3d75d2c41624dbf3c0af --- ext/fts5/fts5_expr.c | 18 ++++-------------- ext/fts5/test/fts5expr.test | 4 ++++ ext/fts5/test/fts5faultI.test | 13 ++++++++++++- ext/fts5/test/fts5misc.test | 21 +++++++++++++++++++++ ext/fts5/test/fts5trigram.test | 1 + manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 7 files changed, 53 insertions(+), 26 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index a39cc16bbf..d3b6598172 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -282,11 +282,12 @@ int sqlite3Fts5ExprNew( }while( sParse.rc==SQLITE_OK && t!=FTS5_EOF ); sqlite3Fts5ParserFree(pEngine, fts5ParseFree); + assert( sParse.pExpr || sParse.rc!=SQLITE_OK ); assert_expr_depth_ok(sParse.rc, sParse.pExpr); /* If the LHS of the MATCH expression was a user column, apply the ** implicit column-filter. */ - if( iColnCol && sParse.pExpr && sParse.rc==SQLITE_OK ){ + if( sParse.rc==SQLITE_OK && iColnCol ){ int n = sizeof(Fts5Colset); Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&sParse.rc, n); if( pColset ){ @@ -303,15 +304,7 @@ int sqlite3Fts5ExprNew( sParse.rc = SQLITE_NOMEM; sqlite3Fts5ParseNodeFree(sParse.pExpr); }else{ - if( !sParse.pExpr ){ - const int nByte = sizeof(Fts5ExprNode); - pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&sParse.rc, nByte); - if( pNew->pRoot ){ - pNew->pRoot->bEof = 1; - } - }else{ - pNew->pRoot = sParse.pExpr; - } + pNew->pRoot = sParse.pExpr; pNew->pIndex = 0; pNew->pConfig = pConfig; pNew->apExprPhrase = sParse.apPhrase; @@ -1129,7 +1122,7 @@ static int fts5ExprNodeTest_STRING( } }else{ Fts5IndexIter *pIter = pPhrase->aTerm[j].pIter; - if( pIter->iRowid==iLast || pIter->bEof ) continue; + if( pIter->iRowid==iLast ) continue; bMatch = 0; if( fts5ExprAdvanceto(pIter, bDesc, &iLast, &rc, &pNode->bEof) ){ return rc; @@ -1651,9 +1644,6 @@ Fts5ExprNearset *sqlite3Fts5ParseNearset( Fts5ExprNearset *pRet = 0; if( pParse->rc==SQLITE_OK ){ - if( pPhrase==0 ){ - return pNear; - } if( pNear==0 ){ sqlite3_int64 nByte; nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*); diff --git a/ext/fts5/test/fts5expr.test b/ext/fts5/test/fts5expr.test index e3938beb0f..49be61d9c4 100644 --- a/ext/fts5/test/fts5expr.test +++ b/ext/fts5/test/fts5expr.test @@ -44,5 +44,9 @@ for {set ii 0} {$ii < 300} {incr ii} { } $res } +do_execsql_test 1.2 { + SELECT rowid FROM x1 WHERE a MATCH '"..."' +} {} + finish_test diff --git a/ext/fts5/test/fts5faultI.test b/ext/fts5/test/fts5faultI.test index d35cdc3800..08a6bf056b 100644 --- a/ext/fts5/test/fts5faultI.test +++ b/ext/fts5/test/fts5faultI.test @@ -211,7 +211,7 @@ do_execsql_test 9.0 { faultsim_save_and_close -do_faultsim_test 9 -faults oom* -prep { +do_faultsim_test 9.1 -faults oom* -prep { faultsim_restore_and_reopen } -body { execsql { @@ -221,6 +221,17 @@ do_faultsim_test 9 -faults oom* -prep { faultsim_test_result {0 {}} } +do_faultsim_test 9.2 -faults oom* -prep { + faultsim_restore_and_reopen +} -body { + execsql { + SELECT rowid FROM ft WHERE x MATCH 'one AND two AND three' + } +} -test { + faultsim_test_result {0 1} +} + + finish_test diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index c7f4a53e38..71ad421c45 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -613,5 +613,26 @@ execsql_pp { SELECT fts5_source_id() } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 23.0 { + CREATE VIRTUAL TABLE x1 USING fts5(x); + INSERT INTO x1 VALUES('one + two + three'); + INSERT INTO x1 VALUES('one + xyz + three'); + INSERT INTO x1 VALUES('xyz + two + xyz'); +} +do_execsql_test 23.1 { + SELECT rowid FROM x1('one + two + three'); +} {1} + +do_execsql_test 23.2 { + SELECT rowid FROM x1('^".." AND one'); +} {} + +do_execsql_test 23.3 { + SELECT rowid FROM x1('abc NEAR ".." NEAR def'); +} {} + + finish_test diff --git a/ext/fts5/test/fts5trigram.test b/ext/fts5/test/fts5trigram.test index b06d35d6d1..3742c647f0 100644 --- a/ext/fts5/test/fts5trigram.test +++ b/ext/fts5/test/fts5trigram.test @@ -56,6 +56,7 @@ foreach {tn like res} { 7 {ABCDEFG%} 1 8 {%รุงเ%} 2 9 {%งเ%} 2 + 10 {%"งเ"%} {} } { do_execsql_test 1.3.$tn { SELECT rowid FROM t1 WHERE y LIKE $like diff --git a/manifest b/manifest index 4a616cffcb..46056ef32c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\srestore\scoverage\sof\sfts5_tokenizer.c. -D 2024-08-17T17:22:49.665 +C Tests\sto\simprove\scoverage\sof\sfts5_expr.c. +D 2024-08-17T19:07:13.921 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -97,7 +97,7 @@ F ext/fts5/fts5Int.h 26a71a09cefa4ef6b4516b204ed48da3e1380970a19b3482eea7c5d8056 F ext/fts5/fts5_aux.c 12cd2512f869217c38b70c31de5b5f741812734fafa80f55b32ea9bbd96e2152 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81cbefc109ea -F ext/fts5/fts5_expr.c 3a24c6ab5b7545312a5ec03085ae705ede820a08f9a63f1d72829ed4a35da6f6 +F ext/fts5/fts5_expr.c 2667e822e90da6c41485b13ad8aa81e7e8768ff9018743a96fac6ddd76ecd0b9 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 23029229021240dc21a69eb749305316103d183375413e2090c064b74b03b7f8 @@ -160,7 +160,7 @@ F ext/fts5/test/fts5dlidx.test a7c42b0a74dc7c8aa1a46d586e0aadda4b6cc42c24450f8d3 F ext/fts5/test/fts5doclist.test b7cb84758504519746957802db9cd31187bb4e0028b89d9087ba06e26cc4155f F ext/fts5/test/fts5ea.test cefdf66024550fa7920c03395c71ce5046235ed1a1a7a469d79b19e7aad5afb5 F ext/fts5/test/fts5eb.test 401f756fdb77083aeba8b696c1e0ad4d834c39dbd6f17e492bb55a2ad64b4296 -F ext/fts5/test/fts5expr.test 7e1b2d075b63b727a624a378c2c09f94296a93dc4ae968aad67f8d9f3810c266 +F ext/fts5/test/fts5expr.test c7e208813df7a90badc856fde3796da79569b39382e0fdb43042127f3b8e06a7 F ext/fts5/test/fts5fault1.test d28a65caee75db6897c3cf1358c5230d3bb2a3bf7fb31062c19c7e5382b3d2bd F ext/fts5/test/fts5fault2.test 69c8fdbef830cd0d450908d4504d5bb86609e255af99c421c20a0756251fe344 F ext/fts5/test/fts5fault3.test da2f9e3e56ff5740d68ebdd6877c97089e7ed28ddff28a0da87a6afea27e5522 @@ -177,7 +177,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5faultI.test e57fa07b771565fcb7aa2b2c349a5104812b4edd86d09ca531afd9b247cf36dd +F ext/fts5/test/fts5faultI.test fbc65a64944fb747f6d3fb30628a807d5cce1bca43c11df40e7770ad7a7ed593 F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -191,7 +191,7 @@ F ext/fts5/test/fts5locale.test 79cbd3000ae269de50826f6061c81f7c9fdb21dd9954c0b7 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test c860b75721d162d7a4f2856322e55e814c2cf0bc45f93ef4388551b54e61a0a0 +F ext/fts5/test/fts5misc.test 558bc33c7b0b987b95e16c927f8a21e42f9a625eafad806b37f44008f5bf6314 F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -235,7 +235,7 @@ F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test 7937cec672b148223fff8746d21d3e7ed0965fd7caf35ccdc888a005bb452f98 F ext/fts5/test/fts5tokenizer2.test ddb8b10fbe4b84b2a75812671f127774c1d2e3e2bf82d2e0e4f0bb1cd8a2b2d6 F ext/fts5/test/fts5tokenizer3.test eea778f7bb7024c3e904e28915f9d53286141671b138722148be22a9c758bdc3 -F ext/fts5/test/fts5trigram.test fcb6b93510b917add63aee8f363c466ac406528822951e76e0980ce6f5170978 +F ext/fts5/test/fts5trigram.test fb9ee982edd76280ce979905a2251081cd04ae4c470248bd5d391b2d096430ab F ext/fts5/test/fts5trigram2.test 6fde9de7f63a6b4aa18dc731be56dbd6be4e755c9b13dcd55479e200d1df0e61 F ext/fts5/test/fts5ubsan.test 9a2dcf399dc8d0e0de661f0d93884d1d27e5b7f0693cfceb97dd24d818df5dd2 F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 @@ -2208,8 +2208,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9d971b31df7ad4d68eb348f95d8f996071cf87d41c47033bde3fcc4dba732e06 -R 00d1f889322bc8b1a7560fd99767ae0b +P 8f9257361b05e368bf433e56d0698923b0f97d12e7c0ad7760aaab6746c0e467 +R f8d6b944dbf347c8074787f443d7147c U dan -Z 653dde5241b23832e0da59a6216ceb6f +Z d2bdd09fc432aeea5dfb2a1dda9df33e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c8caf8375f..50b3e4e2a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f9257361b05e368bf433e56d0698923b0f97d12e7c0ad7760aaab6746c0e467 +f4b839e5265700b1a89066d1b6e0d0d010852a69c5da3d75d2c41624dbf3c0af From 6c796631fc6371b19fa506eef86810453eb14b80 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Aug 2024 19:40:15 +0000 Subject: [PATCH 0679/1030] Fix a broken assert() in fts5_storage.c. FossilOrigin-Name: 01116e32797e1b127ba79059d890fbe5075eee2b6e3ce4468e82862b0fc3aa46 --- ext/fts5/fts5_storage.c | 3 +- ext/fts5/test/fts5corrupt3.test | 154 ++++++++++++++++++++++++++++++++ manifest | 14 +-- manifest.uuid | 2 +- 4 files changed, 163 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 03af105a75..cf25eb361e 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -887,10 +887,9 @@ int sqlite3Fts5StorageContentInsert( rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0); for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){ sqlite3_value *pVal = apVal[i]; - if( sqlite3_value_nochange(pVal) ){ + if( sqlite3_value_nochange(pVal) && p->pSavedRow ){ /* This is an UPDATE statement, and column (i-2) was not modified. ** Retrieve the value from Fts5Storage.pSavedRow instead. */ - assert( p->pSavedRow ); pVal = sqlite3_column_value(p->pSavedRow, i-1); }else if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE ){ assert( pConfig->bLocale ); diff --git a/ext/fts5/test/fts5corrupt3.test b/ext/fts5/test/fts5corrupt3.test index cfe1438eda..c5faaa87b1 100644 --- a/ext/fts5/test/fts5corrupt3.test +++ b/ext/fts5/test/fts5corrupt3.test @@ -15524,6 +15524,160 @@ do_catchsql_test 80.1 { SELECT snippet(rowid, -1, '.', '..', '[', '(]'),snippet(rowid, -1, '.', '.', '', '(]'), highlight(t1, 29, 1 , '') FROM t1('g+ h') WHERE rank MATCH 'bm25(1.0, 10)' ORDER BY NOT (SELECT 1 FROM t1('g+ æ') WHERE rank MATCH 'bm25(1.0, 10)' ORDER BY rank); } {1 {database disk image is malformed}} +#------------------------------------------------------------------------- +reset_db +do_test 81.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +.open --hexdb +| size 40960 pagesize 4096 filename crash-44e8035a976422.db +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 0a .....@ ........ +| 32: 00 00 00 00 00 00 00 00 00 00 00 0d 00 00 00 04 ................ +| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ +| 96: 00 00 00 00 0d 00 00 00 0d 0b 6e 00 0f a3 0f 4c ..........n....L +| 112: 0e e1 0e 81 0e 24 0d cc 0d 72 0d 1b 0c b0 0c 50 .....$...r.....P +| 128: 0b f8 0b b3 0b 6e 00 00 00 00 00 00 00 00 00 00 .....n.......... +| 2912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 0d ..............C. +| 2928: 06 17 11 11 08 75 74 61 62 6c 65 74 34 74 34 43 .....utablet4t4C +| 2944: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA +| 2960: 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66 74 73 BLE t4 USING fts +| 2976: 35 76 6f 63 61 62 28 27 74 32 27 2c 20 27 72 6f 5vocab('t2', 'ro +| 2992: 77 27 29 43 0c 06 17 11 11 08 75 74 61 62 6c 65 w')C......utable +| 3008: 74 33 74 33 43 52 45 41 54 45 20 56 49 52 54 55 t3t3CREATE VIRTU +| 3024: 41 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e AL TABLE t3 USIN +| 3040: 47 20 66 74 73 35 76 6f 63 61 62 28 27 74 31 27 G fts5vocab('t1' +| 3056: 2c 20 27 72 6f 77 27 29 56 0b 06 17 1f 1f 01 7d , 'row')V....... +| 3072: 74 61 62 6c 65 74 32 5f 63 6f 6e 66 69 67 74 32 tablet2_configt2 +| 3088: 5f 63 6f 6e 66 69 67 0a 43 52 45 41 54 45 20 54 _config.CREATE T +| 3104: 41 42 4c 45 20 27 74 32 5f 63 6f 6e 66 69 67 27 ABLE 't2_config' +| 3120: 28 6b 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 (k PRIMARY KEY, +| 3136: 76 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 v) WITHOUT ROWID +| 3152: 5e 0a 07 17 21 21 01 81 07 74 61 62 6c 65 74 32 ^...!!...tablet2 +| 3168: 5f 63 6f 6e 74 65 6e 74 74 32 5f 63 6f 6e 74 65 _contentt2_conte +| 3184: 6e 74 09 43 52 45 41 54 45 20 54 41 42 4c 45 20 nt.CREATE TABLE +| 3200: 27 74 32 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20 't2_content'(id +| 3216: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 INTEGER PRIMARY +| 3232: 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32 29 KEY, c0, c1, c2) +| 3248: 69 09 07 17 19 19 01 81 2d 74 61 62 6c 65 74 32 i.......-tablet2 +| 3264: 5f 69 64 78 74 32 5f 69 64 78 08 43 52 45 41 54 _idxt2_idx.CREAT +| 3280: 45 20 54 41 42 4c 45 20 27 74 32 5f 69 64 78 27 E TABLE 't2_idx' +| 3296: 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67 (segid, term, pg +| 3312: 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28 no, PRIMARY KEY( +| 3328: 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49 segid, term)) WI +| 3344: 54 48 4f 55 54 20 52 4f 57 49 44 55 08 07 17 1b THOUT ROWIDU.... +| 3360: 1b 01 81 01 74 61 62 6c 65 74 32 5f 64 61 74 61 ....tablet2_data +| 3376: 74 32 5f 64 61 74 61 07 43 52 45 41 54 45 20 54 t2_data.CREATE T +| 3392: 41 42 4c 45 20 27 74 32 5f 64 61 74 61 27 28 69 ABLE 't2_data'(i +| 3408: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR +| 3424: 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f Y KEY, block BLO +| 3440: 42 29 58 07 07 17 11 11 08 81 1d 74 61 62 6c 65 B)X........table +| 3456: 74 32 74 32 43 52 45 41 54 45 20 56 49 52 54 55 t2t2CREATE VIRTU +| 3472: 41 4c 20 54 41 42 4c 45 20 74 32 20 55 53 49 4e AL TABLE t2 USIN +| 3488: 47 20 66 74 73 35 28 27 61 27 2c 5b 62 5d 2c 22 G fts5('a',[b],. +| 3504: 63 22 2c 64 65 74 61 69 6c 3d 6e 6f 6e 65 2c 63 c.,detail=none,c +| 3520: 6f 6c 75 6d 6e 73 69 7a 65 3d 30 29 56 06 06 17 olumnsize=0)V... +| 3536: 1f 1f 01 7d 74 61 62 6c 65 74 31 5f 63 6f 6e 66 ....tablet1_conf +| 3552: 69 67 74 31 5f 63 6f 6e 66 69 67 06 43 52 45 41 igt1_config.CREA +| 3568: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e TE TABLE 't1_con +| 3584: 66 69 67 27 28 6b 20 50 52 49 4d 41 52 59 20 4b fig'(k PRIMARY K +| 3600: 45 59 2c 20 76 29 20 57 49 54 48 4f 55 54 20 52 EY, v) WITHOUT R +| 3616: 4f 57 49 44 5b 05 07 17 21 21 01 81 01 74 61 62 OWID[...!!...tab +| 3632: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64 let1_docsizet1_d +| 3648: 6f 63 73 69 7a 65 05 43 52 45 41 54 45 20 54 41 ocsize.CREATE TA +| 3664: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27 BLE 't1_docsize' +| 3680: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM +| 3696: 41 52 59 20 4b 45 59 2c 20 73 7a 20 42 4c 4f 42 ARY KEY, sz BLOB +| 3712: 29 5e 04 07 17 21 21 01 81 07 74 61 62 6c 65 74 )^...!!...tablet +| 3728: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont +| 3744: 65 6e 74 04 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE +| 3760: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 69 64 't1_content'(id +| 3776: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY +| 3792: 20 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32 KEY, c0, c1, c2 +| 3808: 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74 )i.......-tablet +| 3824: 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45 41 1_idxt1_idx.CREA +| 3840: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64 78 TE TABLE 't1_idx +| 3856: 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 '(segid, term, p +| 3872: 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 gno, PRIMARY KEY +| 3888: 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 (segid, term)) W +| 3904: 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07 17 ITHOUT ROWIDU... +| 3920: 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61 74 .....tablet1_dat +| 3936: 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45 20 at1_data.CREATE +| 3952: 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27 28 TABLE 't1_data'( +| 3968: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 id INTEGER PRIMA +| 3984: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c RY KEY, block BL +| 4000: 4f 42 29 5b 01 07 17 11 11 08 81 23 74 61 62 6c OB)[.......#tabl +| 4016: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54 et1t1CREATE VIRT +| 4032: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49 UAL TABLE t1 USI +| 4048: 4e 47 20 66 74 73 35 28 61 2c 62 20 75 6e 69 6e NG fts5(a,b unin +| 4064: 64 65 78 65 64 2c 63 2c 74 6f 6b 65 6e 69 7a 65 dexed,c,tokenize +| 4080: 3d 22 70 6f 72 74 65 72 20 61 73 63 69 69 22 29 =.porter ascii.) +| page 2 offset 4096 +| 0: 0d 0f 68 00 05 0f 13 00 0f e6 0f 13 0f a8 0f 7c ..h............| +| 16: 0f 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .*.............. +| 3856: 00 00 00 15 0a 03 00 30 00 00 00 00 01 03 03 00 .......0........ +| 3872: 03 01 01 01 02 01 01 03 01 01 37 8c 80 80 80 80 ..........7..... +| 3888: 01 03 00 74 00 00 00 2e 02 30 61 03 02 02 01 01 ...t.....0a..... +| 3904: 62 03 02 03 01 01 63 03 02 04 01 01 67 03 06 01 b.....c.....g... +| 3920: 02 02 01 01 68 03 06 01 02 03 01 01 69 03 06 01 ....h.......i... +| 3936: 02 04 04 06 06 06 08 08 0f ef 00 14 2a 00 00 00 ............*... +| 3952: 00 01 02 02 00 02 01 01 01 02 01 01 25 88 80 80 ............%... +| 3968: 80 80 01 03 00 50 00 00 00 1f 02 30 67 02 08 02 .....P.....0g... +| 3984: 01 02 02 01 01 68 02 08 03 8d 02 03 01 01 6a 42 .....h........jB +| 4000: 08 04 01 02 04 04 09 09 37 84 80 80 80 80 01 03 ........7....... +| 4016: 00 74 00 00 00 2e 02 30 61 01 12 02 01 01 62 01 .t.....0a.....b. +| 4032: 02 03 01 01 63 01 02 04 01 01 67 01 06 01 02 02 ....c.....g..... +| 4048: 01 01 68 01 05 01 02 03 01 01 69 01 06 01 02 04 ..h.......i..... +| 4064: 04 06 06 06 08 08 07 01 03 00 14 03 09 00 09 00 ................ +| 4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01 ...$............ +| page 3 offset 8192 +| 0: 0a 00 00 00 03 0f ec 00 0f fa 0f f3 0f ec 00 00 ................ +| 4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c ................ +| 4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02 ................ +| page 4 offset 12288 +| 0: 0d 00 00 00 03 0f be 00 0f ea 00 00 00 00 00 00 ................ +| 4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03 ................ +| 4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67 .....a b cg h ig +| 4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69 h i.......g h i +| 4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17 a b cg h i...... +| 4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69 .a b cd e fg h i +| page 5 offset 16384 +| 0: 0d 00 00 00 03 0f e8 00 0f f8 0f f0 0f e8 00 00 ................ +| 4064: 00 00 00 00 00 00 00 00 06 03 03 00 12 03 00 03 ................ +| 4080: 06 02 03 00 12 03 00 03 06 01 03 00 12 03 00 03 ................ +| page 6 offset 20480 +| 0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00 ................ +| 4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04 ........version. +| page 7 offset 24576 +| 0: 0d 00 00 00 03 0f 9e 00 0f e6 0f ef 0f 9e 00 00 ................ +| 3984: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 84 ..............A. +| 4000: 80 80 80 80 01 04 00 81 06 00 00 00 34 02 30 61 ............4.0a +| 4016: 01 01 01 01 01 62 01 01 01 01 01 63 01 01 01 01 .....b.....c.... +| 4032: e6 64 01 01 01 65 01 01 01 66 01 01 01 67 01 01 .d...e...f...g.. +| 4048: 01 01 01 68 01 01 01 01 01 69 01 01 01 04 06 06 ...h.....i...... +| 4064: 06 04 04 04 06 06 07 01 03 00 14 03 09 09 09 0f ................ +| 4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01 ...$............ +| page 8 offset 28672 +| 0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00 ................ +| 4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02 ................ +| page 9 offset 32768 +| 0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00 ................ +| 4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03 ................ +| 4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67 .....a b cg h ig +| 4048: 20 68 21 69 14 02 05 00 17 17 17 67 20 68 20 69 h!i.......g h i +| 4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17 a b cg h i...... +| 4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69 .a b cd e fg h i +| page 10 offset 36864 +| 0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00 ................ +| 4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04 ........version. +| end crash-44e8035a976422.db +}]} {} + +do_catchsql_test 81.2 { + UPDATE t1 SET b=zeroblob(299); +} {1 {database disk image is malformed}} + sqlite3_fts5_may_be_corrupt 0 finish_test diff --git a/manifest b/manifest index 6ad1c9d6c6..a12f78027e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\schanges\sinto\sthis\sbranch. -D 2024-08-17T19:11:09.556 +C Fix\sa\sbroken\sassert()\sin\sfts5_storage.c. +D 2024-08-17T19:40:15.498 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -101,7 +101,7 @@ F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 23029229021240dc21a69eb749305316103d183375413e2090c064b74b03b7f8 -F ext/fts5/fts5_storage.c acece8abf1b4b2012bdad93aa2d2cf6fc0d1da919763479c7055f699c2cde96c +F ext/fts5/fts5_storage.c 9a9b880be12901f1962ae2a5a7e1b74348b3099a1e728764e419f75d98e3e612 F ext/fts5/fts5_tcl.c 1dcf08028141c40a32634bdcf2d5601622ce4edc48f82ac4ce0cbe0a92a6961d F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -148,7 +148,7 @@ F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b F ext/fts5/test/fts5contentless5.test 40cdcb4fe751672450829c5a96bd32c25fc2f6076279dd2ce5c58ac9a390132a F ext/fts5/test/fts5corrupt.test 6485f721b88ba355ca5d701e7ee87a4efa3ea578d8e6adb26f51ef956c8328bd F ext/fts5/test/fts5corrupt2.test 335911e3f68b9625d850325f9e29a128db3f4276a8c9d4e32134580da8f924c4 -F ext/fts5/test/fts5corrupt3.test b5f35d72af85b1d5a092b3d5e437f7944d142dd0b0c87b928fd0436a0aec6987 +F ext/fts5/test/fts5corrupt3.test 621e9bca3e7299f487e1b29ff4179d9fc9560f5847dfc5b50a16010c9d2a0e5f F ext/fts5/test/fts5corrupt4.test dc08d19f5b8943e95a7778a7d8da592042504faf18dd93f68f7d7a0d7d7dd733 F ext/fts5/test/fts5corrupt5.test 11b47126f5772cc37b67e3e8b2ed05895c4d07c05338bc07e4eea225bfe32c76 F ext/fts5/test/fts5corrupt6.test 2d72db743db7b5d9c9a6d0cfef24d799ed1aa5e8192b66c40e871a37ed9eed06 @@ -2209,8 +2209,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f4b839e5265700b1a89066d1b6e0d0d010852a69c5da3d75d2c41624dbf3c0af a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 -R 49e782c5b107501b250d5b7832f0211a +P 6a8ff9ba5e71d817489093d8dff0a8d77365b4222773b941accbd58558d24379 +R 9367527e69e79bca7a5a92aed8bd4950 U dan -Z 89224bb8e19ae56a7b37235b096e6728 +Z 275daf935ae7d8dde2bbfa29a46fdb3e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b7bf2f3e64..0408009dda 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a8ff9ba5e71d817489093d8dff0a8d77365b4222773b941accbd58558d24379 +01116e32797e1b127ba79059d890fbe5075eee2b6e3ce4468e82862b0fc3aa46 From 8797bd695f97db094bf10e546170d7b1e266867c Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 17 Aug 2024 19:46:49 +0000 Subject: [PATCH 0680/1030] Reduce the size of the SrcItem object by combining fields into a union. FossilOrigin-Name: a4c59ac3c6ec979c25b544d29e47b8e39f6439c098eed8f84b3bd506c9adf047 --- manifest | 35 +++++++++++++++++++---------------- manifest.uuid | 2 +- src/attach.c | 13 +++++++------ src/build.c | 24 ++++++++++++++---------- src/delete.c | 3 ++- src/expr.c | 7 +++++-- src/fkey.c | 3 ++- src/parse.y | 5 +++-- src/printf.c | 4 ++-- src/select.c | 23 +++++++++++++++++------ src/sqliteInt.h | 18 +++++++++++------- src/trigger.c | 13 ++++++++----- test/with2.test | 1 + 13 files changed, 92 insertions(+), 59 deletions(-) diff --git a/manifest b/manifest index bd4f4cbe1c..6e192bd300 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sMakefile.in\sso\sthat\sit\soutputs\sa\sslightly\sbetter\serror\smessage\son\san\nattempt\sto\sbuild\ssomething\sthat\srequires\sTCL\slibraries\swhen\sHAVE_TCL\sis\sfalse. -D 2024-08-17T16:17:16.045 +C Reduce\sthe\ssize\sof\sthe\sSrcItem\sobject\sby\scombining\sfields\sinto\sa\sunion. +D 2024-08-17T19:46:49.038 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -694,7 +694,7 @@ F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 F src/alter.c bb663fddf1fe0e2e6d8758b2b7fb6374e7c057a6ca3955f37a48986806029765 F src/analyze.c 30bf40ec4208ead9e977bec017bccc8a9681820936e38ca5a4a7443100a6d5c5 -F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39 +F src/attach.c d778bacb2ee5bc6a74c81a17376064e6a16ee447d82ee4ad1f7717a320d5a232 F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 @@ -702,17 +702,17 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 237ccc0290d131d646be722f418e92ee0a38043aee25e7dfdc75f8ce5b3abe4e +F src/build.c 8d853f7900dee57d9b3281d71b772f80c45798a3dd782e5e0b6e732ddfe31fe4 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 -F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 -F src/expr.c fe958028b36af640b70b2174354c044f75b8c4a4645c921592122aa2a022083a +F src/delete.c 9999f697346ae1bf4e31ed5d5049ab31d023f290f7f9e86df550f8c269904f4d +F src/expr.c 737704d4ce25bb1f0724702dfa52a5850f28792a5631c7476ef2204e2bee2985 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 -F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a +F src/fkey.c d27603c782215c4e001745768dc6abb2c6394e9f3f47909c9e00502177462ac3 F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 @@ -749,23 +749,23 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 318ef86fbe358b1a93262a42e152f37b97b3fddae8d319dffbd24ce2300f6c88 +F src/parse.y 9eac03d271c6b4a626125de5ce15fdb62e99f4542c1c93bf04cbc57b91d2b2b1 F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce -F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 +F src/printf.c 3820e4fbb96a76ad5799ed4d949f53a1eb61b5e029a172740ee98538f0e57406 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 0aee8a2e5340ba95a966917305dfaff5147fcad78d0839cd364b16e4746b8bcb F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e +F src/select.c 18325f3c24d3b75ce102694f3eb96d6d8dd74ac9b0d10525758ed673c7728bee F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 128b9004698cc79993d5369d7d1763deaf8bbf26e5e8931ec540707e5a7238df +F src/sqliteInt.h dab52ce59c82852105ac40e058c0097368c6a6dce47da2ef68471312b7643ad2 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -825,7 +825,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 F src/treeview.c 774838df4e25956ca34ff79bef150266412cfc2640620d04e22d5c8a55a98992 -F src/trigger.c 0858f75818ed1580332db274f1032bcc5effe567cb132df5c5be8b1d800ca97f +F src/trigger.c 423b50d4eea6b6e59bfadcaa0e3806b10fc21a55e5a5d2f73094ba4a76a70ab8 F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e @@ -2070,7 +2070,7 @@ F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3c F test/windowfault.test 15094c1529424e62f798bc679e3fe9dfab6e8ba2f7dfe8c923b6248c31660a7c F test/windowpushd.test c420e2265f0e09a0e798d0513a660d71b51602088d81b3dbd038918ee1339dcc F test/with1.test b93833890e5d2a368e78747f124503a0159aa029b98e9ed4795ebf630b2efd3d -F test/with2.test a1df41b987198383b9b70bf5e5fda390582e46398653858dbc6ceb24253b28df +F test/with2.test 5885f0ef250504096ea4c0c6350ef2f2ab09b9e2dc2bc691e182f773db3aabb2 F test/with3.test e30369ea27aa27eb1bda4c5e510c8a9f782c8afd2ab99d1a02b8a7f25a5d3e65 F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205 F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8 @@ -2205,8 +2205,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 793ff83d09bea165c8cedc978afd3fcfb1a4cee894c5914aa1d92416afce963d -R be5ece8b231f01bec02cbe9ef4eda884 +P a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 +R d143d0c065164b192322cbf1e4e8b378 +T *branch * srcitem-opt +T *sym-srcitem-opt * +T -sym-trunk * U drh -Z 6d429e685f531219ca0d0afba9760eb7 +Z c1a523f650613fd8f9b88c0821d4d359 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a5034c9d32..2ba642c078 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 +a4c59ac3c6ec979c25b544d29e47b8e39f6439c098eed8f84b3bd506c9adf047 diff --git a/src/attach.c b/src/attach.c index 4a6a25bf04..65b492474e 100644 --- a/src/attach.c +++ b/src/attach.c @@ -480,19 +480,20 @@ static int fixSelectCb(Walker *p, Select *pSelect){ if( NEVER(pList==0) ) return WRC_Continue; for(i=0, pItem=pList->a; inSrc; i++, pItem++){ if( pFix->bTemp==0 ){ - if( pItem->zDatabase ){ - if( iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){ + if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ + if( iDb!=sqlite3FindDbName(db, pItem->u4.zDatabase) ){ sqlite3ErrorMsg(pFix->pParse, "%s %T cannot reference objects in database %s", - pFix->zType, pFix->pName, pItem->zDatabase); + pFix->zType, pFix->pName, pItem->u4.zDatabase); return WRC_Abort; } - sqlite3DbFree(db, pItem->zDatabase); - pItem->zDatabase = 0; + sqlite3DbFree(db, pItem->u4.zDatabase); pItem->fg.notCte = 1; + pItem->fg.hadSchema = 1; } - pItem->pSchema = pFix->pSchema; + pItem->u4.pSchema = pFix->pSchema; pItem->fg.fromDDL = 1; + pItem->fg.fixedSchema = 1; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) if( pList->a[i].fg.isUsing==0 diff --git a/src/build.c b/src/build.c index 9747810e82..a0c4b493f0 100644 --- a/src/build.c +++ b/src/build.c @@ -497,12 +497,11 @@ Table *sqlite3LocateTableItem( SrcItem *p ){ const char *zDb; - assert( p->pSchema==0 || p->zDatabase==0 ); - if( p->pSchema ){ - int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema); + if( p->fg.fixedSchema ){ + int iDb = sqlite3SchemaToIndex(pParse->db, p->u4.pSchema); zDb = pParse->db->aDb[iDb].zDbSName; }else{ - zDb = p->zDatabase; + zDb = p->u4.zDatabase; } return sqlite3LocateTable(pParse, flags, p->zName, zDb); } @@ -3487,6 +3486,7 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){ } assert( pParse->nErr==0 ); assert( pName->nSrc==1 ); + assert( pName->a[0].fg.fixedSchema==0 ); if( sqlite3ReadSchema(pParse) ) goto exit_drop_table; if( noErr ) db->suppressErr++; assert( isView==0 || isView==LOCATE_VIEW ); @@ -3495,7 +3495,7 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){ if( pTab==0 ){ if( noErr ){ - sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); + sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].u4.zDatabase); sqlite3ForceNotReadOnly(pParse); } goto exit_drop_table; @@ -4586,15 +4586,16 @@ void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){ } assert( pParse->nErr==0 ); /* Never called with prior non-OOM errors */ assert( pName->nSrc==1 ); + assert( pName->a[0].fg.fixedSchema==0 ); if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ goto exit_drop_index; } - pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase); + pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].u4.zDatabase); if( pIndex==0 ){ if( !ifExists ){ sqlite3ErrorMsg(pParse, "no such index: %S", pName->a); }else{ - sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); + sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].u4.zDatabase); sqlite3ForceNotReadOnly(pParse); } pParse->checkSchema = 1; @@ -4891,12 +4892,13 @@ SrcList *sqlite3SrcListAppend( if( pDatabase && pDatabase->z==0 ){ pDatabase = 0; } + assert( pItem->fg.fixedSchema==0 ); if( pDatabase ){ pItem->zName = sqlite3NameFromToken(db, pDatabase); - pItem->zDatabase = sqlite3NameFromToken(db, pTable); + pItem->u4.zDatabase = sqlite3NameFromToken(db, pTable); }else{ pItem->zName = sqlite3NameFromToken(db, pTable); - pItem->zDatabase = 0; + pItem->u4.zDatabase = 0; } return pList; } @@ -4928,9 +4930,11 @@ void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ assert( db!=0 ); if( pList==0 ) return; for(pItem=pList->a, i=0; inSrc; i++, pItem++){ - if( pItem->zDatabase ) sqlite3DbNNFreeNN(db, pItem->zDatabase); if( pItem->zName ) sqlite3DbNNFreeNN(db, pItem->zName); if( pItem->zAlias ) sqlite3DbNNFreeNN(db, pItem->zAlias); + if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ + sqlite3DbNNFreeNN(db, pItem->u4.zDatabase); + } if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy); if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg); sqlite3DeleteTable(db, pItem->pTab); diff --git a/src/delete.c b/src/delete.c index 2baff5b3d4..bc7a7a3f53 100644 --- a/src/delete.c +++ b/src/delete.c @@ -156,7 +156,8 @@ void sqlite3MaterializeView( if( pFrom ){ assert( pFrom->nSrc==1 ); pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName); - pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); + assert( pFrom->a[0].fg.fixedSchema==0 ); + pFrom->a[0].u4.zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); assert( pFrom->a[0].fg.isUsing==0 ); assert( pFrom->a[0].u3.pOn==0 ); } diff --git a/src/expr.c b/src/expr.c index 53b0170ab4..d0fa4b5007 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1877,8 +1877,11 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int flags){ SrcItem *pNewItem = &pNew->a[i]; const SrcItem *pOldItem = &p->a[i]; Table *pTab; - pNewItem->pSchema = pOldItem->pSchema; - pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase); + if( pOldItem->fg.fixedSchema ){ + pNewItem->u4.pSchema = pOldItem->u4.pSchema; + }else{ + pNewItem->u4.zDatabase = sqlite3DbStrDup(db, pOldItem->u4.zDatabase); + } pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName); pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias); pNewItem->fg = pOldItem->fg; diff --git a/src/fkey.c b/src/fkey.c index 1efdc0bba1..c68037a654 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1337,7 +1337,8 @@ static Trigger *fkActionTrigger( if( pSrc ){ assert( pSrc->nSrc==1 ); pSrc->a[0].zName = sqlite3DbStrDup(db, zFrom); - pSrc->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); + assert( pSrc->a[0].fg.fixedSchema==0 ); + pSrc->a[0].u4.zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); } pSelect = sqlite3SelectNew(pParse, sqlite3ExprListAppend(pParse, 0, pRaise), diff --git a/src/parse.y b/src/parse.y index 68c00f0a7f..a605ad6912 100644 --- a/src/parse.y +++ b/src/parse.y @@ -740,8 +740,9 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z) on_using(N if( A ){ SrcItem *pNew = &A->a[A->nSrc-1]; SrcItem *pOld = F->a; + assert( pOld->fg.fixedSchema==0 ); pNew->zName = pOld->zName; - pNew->zDatabase = pOld->zDatabase; + pNew->u4.zDatabase = pOld->u4.zDatabase; pNew->pSelect = pOld->pSelect; if( pNew->pSelect && (pNew->pSelect->selFlags & SF_NestedFrom)!=0 ){ pNew->fg.isNestedFrom = 1; @@ -752,7 +753,7 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z) on_using(N pOld->fg.isTabFunc = 0; pNew->fg.isTabFunc = 1; } - pOld->zName = pOld->zDatabase = 0; + pOld->zName = pOld->u4.zDatabase = 0; pOld->pSelect = 0; } sqlite3SrcListDelete(pParse->db, F); diff --git a/src/printf.c b/src/printf.c index c0dcc5d0fa..12dd91a781 100644 --- a/src/printf.c +++ b/src/printf.c @@ -848,8 +848,8 @@ void sqlite3_str_vappendf( if( pItem->zAlias && !flag_altform2 ){ sqlite3_str_appendall(pAccum, pItem->zAlias); }else if( pItem->zName ){ - if( pItem->zDatabase ){ - sqlite3_str_appendall(pAccum, pItem->zDatabase); + if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ + sqlite3_str_appendall(pAccum, pItem->u4.zDatabase); sqlite3_str_append(pAccum, ".", 1); } sqlite3_str_appendall(pAccum, pItem->zName); diff --git a/src/select.c b/src/select.c index 4b0b554295..634f06e301 100644 --- a/src/select.c +++ b/src/select.c @@ -4506,10 +4506,12 @@ static int flattenSubquery( /* Delete the transient structures associated with the subquery */ pSub1 = pSubitem->pSelect; - sqlite3DbFree(db, pSubitem->zDatabase); + if( pSubitem->fg.fixedSchema==0 ){ + sqlite3DbFree(db, pSubitem->u4.zDatabase); + pSubitem->u4.zDatabase = 0; + } sqlite3DbFree(db, pSubitem->zName); sqlite3DbFree(db, pSubitem->zAlias); - pSubitem->zDatabase = 0; pSubitem->zName = 0; pSubitem->zAlias = 0; pSubitem->pSelect = 0; @@ -5637,7 +5639,7 @@ static struct Cte *searchWith( ){ const char *zName = pItem->zName; With *p; - assert( pItem->zDatabase==0 ); + assert( pItem->fg.fixedSchema || pItem->u4.zDatabase==0 ); assert( zName!=0 ); for(p=pWith; p; p=p->pOuter){ int i; @@ -5717,7 +5719,8 @@ static int resolveFromTermToCte( ** go no further. */ return 0; } - if( pFrom->zDatabase!=0 ){ + assert( pFrom->fg.hadSchema==0 || pFrom->fg.notCte!=0 ); + if( pFrom->fg.fixedSchema==0 && pFrom->u4.zDatabase!=0 ){ /* The FROM term contains a schema qualifier (ex: main.t1) and so ** it cannot possibly be a CTE reference. */ return 0; @@ -5794,7 +5797,8 @@ static int resolveFromTermToCte( assert( pRecTerm->pPrior!=0 ); for(i=0; inSrc; i++){ SrcItem *pItem = &pSrc->a[i]; - if( pItem->zDatabase==0 + if( ((pItem->fg.fixedSchema==0 && pItem->u4.zDatabase==0) + || pItem->fg.hadSchema==0) && pItem->zName!=0 && 0==sqlite3StrICmp(pItem->zName, pCte->zName) ){ @@ -7681,7 +7685,14 @@ int sqlite3Select( ** string for the fake column name seems safer. */ if( pItem->colUsed==0 && pItem->zName!=0 ){ - sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase); + const char *zDb; + if( pItem->fg.fixedSchema ){ + int iDb = sqlite3SchemaToIndex(pParse->db, pItem->u4.pSchema); + zDb = db->aDb[iDb].zDbSName; + }else{ + zDb = pItem->u4.zDatabase; + } + sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", zDb); } #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ebd0f01b26..75e1f61201 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3297,13 +3297,11 @@ struct IdList { ** u2.pCteUse fg.isCte && !fg.isIndexedBy */ struct SrcItem { - Schema *pSchema; /* Schema to which this item is fixed */ - char *zDatabase; /* Name of database holding this table */ char *zName; /* Name of the table */ char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ Table *pTab; /* An SQL table corresponding to zName */ Select *pSelect; /* A SELECT statement used in place of a table name */ - int addrFillSub; /* Address of subroutine to manifest a subquery */ + int addrFillSub; /* Address of subroutine to initialize a subquery */ int regReturn; /* Register holding return address of addrFillSub */ int regResult; /* Registers holding results of a co-routine */ struct { @@ -3323,12 +3321,10 @@ struct SrcItem { unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */ unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */ unsigned rowidUsed :1; /* The ROWID of this table is referenced */ + unsigned fixedSchema :1; /* Uses u4.pSchema, not u4.zDatabase */ + unsigned hadSchema :1; /* Has u4.zDatabase before u4.pSchema */ } fg; int iCursor; /* The VDBE cursor number used to access this table */ - union { - Expr *pOn; /* fg.isUsing==0 => The ON clause of a join */ - IdList *pUsing; /* fg.isUsing==1 => The USING clause of a join */ - } u3; Bitmask colUsed; /* Bit N set if column N used. Details above for N>62 */ union { char *zIndexedBy; /* Identifier from "INDEXED BY " clause */ @@ -3339,6 +3335,14 @@ struct SrcItem { Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */ CteUse *pCteUse; /* CTE Usage info when fg.isCte is true */ } u2; + union { + Expr *pOn; /* fg.isUsing==0 => The ON clause of a join */ + IdList *pUsing; /* fg.isUsing==1 => The USING clause of a join */ + } u3; + union { + Schema *pSchema; /* Schema to which this item is fixed */ + char *zDatabase; /* Name of database holding this table */ + } u4; }; /* diff --git a/src/trigger.c b/src/trigger.c index 98e8da58c1..a5a57abf16 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -151,9 +151,9 @@ void sqlite3BeginTrigger( ** To maintain backwards compatibility, ignore the database ** name on pTableName if we are reparsing out of the schema table */ - if( db->init.busy && iDb!=1 ){ - sqlite3DbFree(db, pTableName->a[0].zDatabase); - pTableName->a[0].zDatabase = 0; + if( db->init.busy && iDb!=1 && ALWAYS(pTableName->a[0].fg.fixedSchema==0) ){ + sqlite3DbFree(db, pTableName->a[0].u4.zDatabase); + pTableName->a[0].u4.zDatabase = 0; } /* If the trigger name was unqualified, and the table is a temp table, @@ -631,7 +631,8 @@ void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){ } assert( pName->nSrc==1 ); - zDb = pName->a[0].zDatabase; + assert( pName->a[0].fg.fixedSchema==0 ); + zDb = pName->a[0].u4.zDatabase; zName = pName->a[0].zName; assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) ); for(i=OMIT_TEMPDB; inDb; i++){ @@ -868,7 +869,9 @@ SrcList *sqlite3TriggerStepSrc( Schema *pSchema = pStep->pTrig->pSchema; pSrc->a[0].zName = zName; if( pSchema!=db->aDb[1].pSchema ){ - pSrc->a[0].pSchema = pSchema; + assert( pSrc->a[0].fg.fixedSchema || pSrc->a[0].u4.zDatabase==0 ); + pSrc->a[0].u4.pSchema = pSchema; + pSrc->a[0].fg.fixedSchema = 1; } if( pStep->pFrom ){ SrcList *pDup = sqlite3SrcListDup(db, pStep->pFrom, 0); diff --git a/test/with2.test b/test/with2.test index 660df52b77..ad1753d659 100644 --- a/test/with2.test +++ b/test/with2.test @@ -146,6 +146,7 @@ do_execsql_test 1.14 { SELECT * FROM t4; } {4 5 6 7 8 9 10} +exit do_execsql_test 1.15 { WITH t4(x) AS ( From b204b6aa7bd94252c8043f53701f314ee433bafd Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 17 Aug 2024 23:23:23 +0000 Subject: [PATCH 0681/1030] Give unique names to fields in the SrcItem object, to facilitate analysis of how those fields are used using "grep". FossilOrigin-Name: 9f5aeef3cbc2c95267c8f7bf60d5c66971a76789669fb0e8f853273ff6f616f2 --- manifest | 55 +++++++------ manifest.uuid | 2 +- src/alter.c | 8 +- src/auth.c | 2 +- src/build.c | 19 +++-- src/delete.c | 4 +- src/expr.c | 16 ++-- src/fkey.c | 4 +- src/insert.c | 33 ++++---- src/parse.y | 6 +- src/printf.c | 2 +- src/resolve.c | 39 +++++----- src/select.c | 199 ++++++++++++++++++++++++------------------------ src/sqliteInt.h | 18 +++-- src/treeview.c | 16 ++-- src/trigger.c | 4 +- src/update.c | 6 +- src/upsert.c | 4 +- src/walker.c | 2 +- src/where.c | 94 +++++++++++------------ src/wherecode.c | 27 +++---- src/whereexpr.c | 10 +-- src/window.c | 8 +- 23 files changed, 299 insertions(+), 279 deletions(-) diff --git a/manifest b/manifest index 6e192bd300..ef77b8894d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reduce\sthe\ssize\sof\sthe\sSrcItem\sobject\sby\scombining\sfields\sinto\sa\sunion. -D 2024-08-17T19:46:49.038 +C Give\sunique\snames\sto\sfields\sin\sthe\sSrcItem\sobject,\sto\sfacilitate\sanalysis\sof\nhow\sthose\sfields\sare\sused\susing\s"grep". +D 2024-08-17T23:23:23.271 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -692,34 +692,34 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 -F src/alter.c bb663fddf1fe0e2e6d8758b2b7fb6374e7c057a6ca3955f37a48986806029765 +F src/alter.c b73964bd6bc3122e884993c0666bae96d4e1e50a94b6f9008df32e6a18e99cd0 F src/analyze.c 30bf40ec4208ead9e977bec017bccc8a9681820936e38ca5a4a7443100a6d5c5 F src/attach.c d778bacb2ee5bc6a74c81a17376064e6a16ee447d82ee4ad1f7717a320d5a232 -F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4 +F src/auth.c 4c1ea890e0069ad73bead5d17a5b12c34cfa4f1a24175c8147ea439b64be271c F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 8d853f7900dee57d9b3281d71b772f80c45798a3dd782e5e0b6e732ddfe31fe4 +F src/build.c 664804cbefaf43c13fcb369474609cf8befa4d89933804dc276d0a15fbd66c34 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 -F src/delete.c 9999f697346ae1bf4e31ed5d5049ab31d023f290f7f9e86df550f8c269904f4d -F src/expr.c 737704d4ce25bb1f0724702dfa52a5850f28792a5631c7476ef2204e2bee2985 +F src/delete.c 8aaf9d05d6ff6349a7a6001cbf90c7a46b19b9f52ef2e47aa0415a529d5307a1 +F src/expr.c 835b637da89fe20a1ff90bd372904fd421ff92d1dfb9bbea9c81bbffbea46715 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 -F src/fkey.c d27603c782215c4e001745768dc6abb2c6394e9f3f47909c9e00502177462ac3 +F src/fkey.c 849049c74a4c68961154c124087b5c67d277217a2e642570d0c1bd6336859940 F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 8ff11e9e54c5fc1fe89707b3d41cf44ad2822f712bd3b5da68338ea42518847e +F src/insert.c 2152b159ac214519e778b6996a85b9073ace054f5c9d430b375852e343a5ec92 F src/json.c 5b6a1d6015997b9ee848a32948720bdb26a0ef2de5a2127ebf7355ce66dbdc0d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -749,23 +749,23 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 9eac03d271c6b4a626125de5ce15fdb62e99f4542c1c93bf04cbc57b91d2b2b1 +F src/parse.y bc8df5d36afd06d50c1828072e4f3120d892af685436db3b8e776288803535e0 F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce -F src/printf.c 3820e4fbb96a76ad5799ed4d949f53a1eb61b5e029a172740ee98538f0e57406 +F src/printf.c efa3973bdcacdbc8cf0ff3b3a58e16a105319eac8819823f5807579dc2fa4138 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 0aee8a2e5340ba95a966917305dfaff5147fcad78d0839cd364b16e4746b8bcb +F src/resolve.c d25fc99cd54d2acf4c655f942dd48ee60e3ada94d73c8b992487515f1295a3bc F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 18325f3c24d3b75ce102694f3eb96d6d8dd74ac9b0d10525758ed673c7728bee +F src/select.c 10ff02352f4c6eb7bc8d5711f0f74199b94ae9adc346f10391931f5c55d1c68f F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h dab52ce59c82852105ac40e058c0097368c6a6dce47da2ef68471312b7643ad2 +F src/sqliteInt.h 95186ebaf79560fa44b1a05bd7b4b14846e037a285177ca65082a9ae952a6c29 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -824,10 +824,10 @@ F src/test_window.c 6d80e11fba89a1796525e6f0048ff0c7789aa2c6b0b11c80827dc1437bd8 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c 774838df4e25956ca34ff79bef150266412cfc2640620d04e22d5c8a55a98992 -F src/trigger.c 423b50d4eea6b6e59bfadcaa0e3806b10fc21a55e5a5d2f73094ba4a76a70ab8 -F src/update.c 732404a04d1737ef14bb6ec6b84f74edf28b3c102a92ae46b4855438a710efe7 -F src/upsert.c 2e60567a0e9e8520c18671b30712a88dc73534474304af94f32bb5f3ef65ac65 +F src/treeview.c a337ab329f94e627c9a5efee0326d3359e352c4f0c0bb5c8f4b686fe03e6e7e8 +F src/trigger.c 68d849ea6ccab67beb450d1a0d065c6118f0884a779388b07f0d9a27dbda38c9 +F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 +F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 @@ -845,12 +845,12 @@ F src/vtab.c 5fb499d20494b7eecaadb7584634af9afcb374cb0524912b475fcb1712458a1b F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 -F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c f5be664f3379c9f930696e339ec4ef4c1187af860cca727411156101fae6b677 +F src/walker.c e5898234c5920481d962e29b96ecf403b992b12ae243ad0e53659386a1b3e554 +F src/where.c d0140395a35fbc451e9d07c9816895d399f02ae76cbcd255e8ce1069548b02c8 F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e -F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c -F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 -F src/window.c 1e40ffc509bae21e466f6106382d238e91eb73edd4ba10e66ca4fd7af2b96896 +F src/wherecode.c 3e130abafc185a29c8dbdcc33e6150dff2aa884f75483e159feef170961af65d +F src/whereexpr.c 784f641ba3d6f1fdb4f65e3891daa50067a4c51f1acd11b461397f7d4c622907 +F src/window.c ffbf65ba62ce329e2fd68b35f11e920121fac45dab0f9a4bbc486125ccc98b6c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 F test/affinity3.test f094773025eddf31135c7ad4cde722b7696f8eb07b97511f98585addf2a510a9 @@ -2205,11 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 -R d143d0c065164b192322cbf1e4e8b378 -T *branch * srcitem-opt -T *sym-srcitem-opt * -T -sym-trunk * +P a4c59ac3c6ec979c25b544d29e47b8e39f6439c098eed8f84b3bd506c9adf047 +R 1d81e98efd997ac91c2ceea4c803b7e6 U drh -Z c1a523f650613fd8f9b88c0821d4d359 +Z 8ec986f4842c563a443c2f1a23450bf4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2ba642c078..0e51ef0919 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4c59ac3c6ec979c25b544d29e47b8e39f6439c098eed8f84b3bd506c9adf047 +9f5aeef3cbc2c95267c8f7bf60d5c66971a76789669fb0e8f853273ff6f616f2 diff --git a/src/alter.c b/src/alter.c index a8556d115e..41146f54e9 100644 --- a/src/alter.c +++ b/src/alter.c @@ -1366,8 +1366,8 @@ static int renameResolveTrigger(Parse *pParse){ int i; for(i=0; ipFrom->nSrc && rc==SQLITE_OK; i++){ SrcItem *p = &pStep->pFrom->a[i]; - if( p->pSelect ){ - sqlite3SelectPrep(pParse, p->pSelect, 0); + if( p->sq.pSelect ){ + sqlite3SelectPrep(pParse, p->sq.pSelect, 0); } } } @@ -1436,7 +1436,7 @@ static void renameWalkTrigger(Walker *pWalker, Trigger *pTrigger){ if( pStep->pFrom ){ int i; for(i=0; ipFrom->nSrc; i++){ - sqlite3WalkSelect(pWalker, pStep->pFrom->a[i].pSelect); + sqlite3WalkSelect(pWalker, pStep->pFrom->a[i].sq.pSelect); } } } @@ -1683,7 +1683,7 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ } for(i=0; inSrc; i++){ SrcItem *pItem = &pSrc->a[i]; - if( pItem->pTab==p->pTab ){ + if( pItem->pSTab==p->pTab ){ renameTokenFind(pWalker->pParse, p, pItem->zName); } } diff --git a/src/auth.c b/src/auth.c index fa6c82d85d..fba2c09905 100644 --- a/src/auth.c +++ b/src/auth.c @@ -165,7 +165,7 @@ void sqlite3AuthRead( assert( pTabList ); for(iSrc=0; iSrcnSrc; iSrc++){ if( pExpr->iTable==pTabList->a[iSrc].iCursor ){ - pTab = pTabList->a[iSrc].pTab; + pTab = pTabList->a[iSrc].pSTab; break; } } diff --git a/src/build.c b/src/build.c index a0c4b493f0..ff798087af 100644 --- a/src/build.c +++ b/src/build.c @@ -4914,8 +4914,8 @@ void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){ for(i=0, pItem=pList->a; inSrc; i++, pItem++){ if( pItem->iCursor>=0 ) continue; pItem->iCursor = pParse->nTab++; - if( pItem->pSelect ){ - sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc); + if( pItem->sq.pSelect ){ + sqlite3SrcListAssignCursors(pParse, pItem->sq.pSelect->pSrc); } } } @@ -4930,6 +4930,15 @@ void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ assert( db!=0 ); if( pList==0 ) return; for(pItem=pList->a, i=0; inSrc; i++, pItem++){ + + /* Check invariants on SrcItem */ + assert( pItem->sq.pSelect==0 + || (pItem->sq.pSelect->selFlags & SF_MultiValue)==0 + || (pItem->fg.hadSchema==0 + && (pItem->fg.fixedSchema || pItem->u4.zDatabase==0)) ); + assert( pItem->fg.hadSchema==0 || pItem->fg.fixedSchema==1 ); + + if( pItem->zName ) sqlite3DbNNFreeNN(db, pItem->zName); if( pItem->zAlias ) sqlite3DbNNFreeNN(db, pItem->zAlias); if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ @@ -4937,8 +4946,8 @@ void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ } if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy); if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg); - sqlite3DeleteTable(db, pItem->pTab); - if( pItem->pSelect ) sqlite3SelectDelete(db, pItem->pSelect); + sqlite3DeleteTable(db, pItem->pSTab); + if( pItem->sq.pSelect ) sqlite3SelectDelete(db, pItem->sq.pSelect); if( pItem->fg.isUsing ){ sqlite3IdListDelete(db, pItem->u3.pUsing); }else if( pItem->u3.pOn ){ @@ -4998,7 +5007,7 @@ SrcList *sqlite3SrcListAppendFromTerm( pItem->zAlias = sqlite3NameFromToken(db, pAlias); } if( pSubquery ){ - pItem->pSelect = pSubquery; + pItem->sq.pSelect = pSubquery; if( pSubquery->selFlags & SF_NestedFrom ){ pItem->fg.isNestedFrom = 1; } diff --git a/src/delete.c b/src/delete.c index bc7a7a3f53..010a900191 100644 --- a/src/delete.c +++ b/src/delete.c @@ -33,8 +33,8 @@ Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){ Table *pTab; assert( pItem && pSrc->nSrc>=1 ); pTab = sqlite3LocateTableItem(pParse, 0, pItem); - if( pItem->pTab ) sqlite3DeleteTable(pParse->db, pItem->pTab); - pItem->pTab = pTab; + if( pItem->pSTab ) sqlite3DeleteTable(pParse->db, pItem->pSTab); + pItem->pSTab = pTab; pItem->fg.notCte = 1; if( pTab ){ pTab->nTabRef++; diff --git a/src/expr.c b/src/expr.c index d0fa4b5007..6ad789a3d8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1886,9 +1886,9 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int flags){ pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias); pNewItem->fg = pOldItem->fg; pNewItem->iCursor = pOldItem->iCursor; - pNewItem->addrFillSub = pOldItem->addrFillSub; - pNewItem->regReturn = pOldItem->regReturn; - pNewItem->regResult = pOldItem->regResult; + pNewItem->sq.addrFillSub = pOldItem->sq.addrFillSub; + pNewItem->sq.regReturn = pOldItem->sq.regReturn; + pNewItem->sq.regResult = pOldItem->sq.regResult; if( pNewItem->fg.isIndexedBy ){ pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy); }else if( pNewItem->fg.isTabFunc ){ @@ -1901,11 +1901,11 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int flags){ if( pNewItem->fg.isCte ){ pNewItem->u2.pCteUse->nUse++; } - pTab = pNewItem->pTab = pOldItem->pTab; + pTab = pNewItem->pSTab = pOldItem->pSTab; if( pTab ){ pTab->nTabRef++; } - pNewItem->pSelect = sqlite3SelectDup(db, pOldItem->pSelect, flags); + pNewItem->sq.pSelect = sqlite3SelectDup(db, pOldItem->sq.pSelect, flags); if( pOldItem->fg.isUsing ){ assert( pNewItem->fg.isUsing ); pNewItem->u3.pUsing = sqlite3IdListDup(db, pOldItem->u3.pUsing); @@ -2999,8 +2999,8 @@ static Select *isCandidateForInOpt(const Expr *pX){ pSrc = p->pSrc; assert( pSrc!=0 ); if( pSrc->nSrc!=1 ) return 0; /* Single term in FROM clause */ - if( pSrc->a[0].pSelect ) return 0; /* FROM is not a subquery or view */ - pTab = pSrc->a[0].pTab; + if( pSrc->a[0].sq.pSelect ) return 0; /* FROM is not a subquery or view */ + pTab = pSrc->a[0].pSTab; assert( pTab!=0 ); assert( !IsView(pTab) ); /* FROM clause is not a view */ if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */ @@ -3183,7 +3183,7 @@ int sqlite3FindInIndex( assert( p->pEList!=0 ); /* Because of isCandidateForInOpt(p) */ assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */ assert( p->pSrc!=0 ); /* Because of isCandidateForInOpt(p) */ - pTab = p->pSrc->a[0].pTab; + pTab = p->pSrc->a[0].pSTab; /* Code an OP_Transaction and OP_TableLock for . */ iDb = sqlite3SchemaToIndex(db, pTab->pSchema); diff --git a/src/fkey.c b/src/fkey.c index c68037a654..cd1f88502e 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1043,9 +1043,9 @@ void sqlite3FkCheck( pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); if( pSrc ){ SrcItem *pItem = pSrc->a; - pItem->pTab = pFKey->pFrom; + pItem->pSTab = pFKey->pFrom; pItem->zName = pFKey->pFrom->zName; - pItem->pTab->nTabRef++; + pItem->pSTab->nTabRef++; pItem->iCursor = pParse->nTab++; if( regNew!=0 ){ diff --git a/src/insert.c b/src/insert.c index a7e94420bf..4447cdc22e 100644 --- a/src/insert.c +++ b/src/insert.c @@ -585,8 +585,8 @@ void sqlite3AutoincrementEnd(Parse *pParse){ void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ if( ALWAYS(pVal) && pVal->pSrc->nSrc>0 ){ SrcItem *pItem = &pVal->pSrc->a[0]; - sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->regReturn); - sqlite3VdbeJumpHere(pParse->pVdbe, pItem->addrFillSub - 1); + sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->sq.regReturn); + sqlite3VdbeJumpHere(pParse->pVdbe, pItem->sq.addrFillSub - 1); } } @@ -723,14 +723,15 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ assert( pLeft->pNext==0 ); assert( pRet->pNext==0 ); p = &pRet->pSrc->a[0]; - p->pSelect = pLeft; + p->sq.pSelect = pLeft; p->fg.viaCoroutine = 1; - p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; - p->regReturn = ++pParse->nMem; + p->sq.addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; + p->sq.regReturn = ++pParse->nMem; p->iCursor = -1; p->u1.nRow = 2; - sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub); - sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn); + sqlite3VdbeAddOp3(v, OP_InitCoroutine, + p->sq.regReturn, 0, p->sq.addrFillSub); + sqlite3SelectDestInit(&dest, SRT_Coroutine, p->sq.regReturn); /* Allocate registers for the output of the co-routine. Do so so ** that there are two unused registers immediately before those @@ -743,7 +744,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ pLeft->selFlags |= SF_MultiValue; sqlite3Select(pParse, pLeft, &dest); - p->regResult = dest.iSdst; + p->sq.regResult = dest.iSdst; assert( pParse->nErr || dest.iSdst>0 ); pLeft = pRet; } @@ -755,11 +756,11 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ if( pParse->nErr==0 ){ assert( p!=0 ); - if( p->pSelect->pEList->nExpr!=pRow->nExpr ){ - sqlite3SelectWrongNumTermsError(pParse, p->pSelect); + if( p->sq.pSelect->pEList->nExpr!=pRow->nExpr ){ + sqlite3SelectWrongNumTermsError(pParse, p->sq.pSelect); }else{ - sqlite3ExprCodeExprList(pParse, pRow, p->regResult, 0, 0); - sqlite3VdbeAddOp1(pParse->pVdbe, OP_Yield, p->regReturn); + sqlite3ExprCodeExprList(pParse, pRow, p->sq.regResult, 0, 0); + sqlite3VdbeAddOp1(pParse->pVdbe, OP_Yield, p->sq.regReturn); } } sqlite3ExprListDelete(pParse->db, pRow); @@ -1110,9 +1111,9 @@ void sqlite3Insert( && pSelect->pPrior==0 ){ SrcItem *pItem = &pSelect->pSrc->a[0]; - dest.iSDParm = pItem->regReturn; - regFromSelect = pItem->regResult; - nColumn = pItem->pSelect->pEList->nExpr; + dest.iSDParm = pItem->sq.regReturn; + regFromSelect = pItem->sq.regResult; + nColumn = pItem->sq.pSelect->pEList->nExpr; ExplainQueryPlan((pParse, 0, "SCAN %S", pItem)); if( bIdListInOrder && nColumn==pTab->nCol ){ regData = regFromSelect; @@ -3032,7 +3033,7 @@ static int xferOptimization( if( pSelect->pSrc->nSrc!=1 ){ return 0; /* FROM clause must have exactly one term */ } - if( pSelect->pSrc->a[0].pSelect ){ + if( pSelect->pSrc->a[0].sq.pSelect ){ return 0; /* FROM clause cannot contain a subquery */ } if( pSelect->pWhere ){ diff --git a/src/parse.y b/src/parse.y index a605ad6912..9e656d0bc7 100644 --- a/src/parse.y +++ b/src/parse.y @@ -743,8 +743,8 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z) on_using(N assert( pOld->fg.fixedSchema==0 ); pNew->zName = pOld->zName; pNew->u4.zDatabase = pOld->u4.zDatabase; - pNew->pSelect = pOld->pSelect; - if( pNew->pSelect && (pNew->pSelect->selFlags & SF_NestedFrom)!=0 ){ + pNew->sq.pSelect = pOld->sq.pSelect; + if( pNew->sq.pSelect && (pNew->sq.pSelect->selFlags & SF_NestedFrom)!=0 ){ pNew->fg.isNestedFrom = 1; } if( pOld->fg.isTabFunc ){ @@ -754,7 +754,7 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z) on_using(N pNew->fg.isTabFunc = 1; } pOld->zName = pOld->u4.zDatabase = 0; - pOld->pSelect = 0; + pOld->sq.pSelect = 0; } sqlite3SrcListDelete(pParse->db, F); }else{ diff --git a/src/printf.c b/src/printf.c index 12dd91a781..027905d26f 100644 --- a/src/printf.c +++ b/src/printf.c @@ -856,7 +856,7 @@ void sqlite3_str_vappendf( }else if( pItem->zAlias ){ sqlite3_str_appendall(pAccum, pItem->zAlias); }else{ - Select *pSel = pItem->pSelect; + Select *pSel = pItem->sq.pSelect; assert( pSel!=0 ); /* Because of tag-20240424-1 */ if( pSel->selFlags & SF_NestedFrom ){ sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId); diff --git a/src/resolve.c b/src/resolve.c index dbb54198cb..02a48d6993 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -215,7 +215,7 @@ static void extendFJMatch( if( pNew ){ pNew->iTable = pMatch->iCursor; pNew->iColumn = iColumn; - pNew->y.pTab = pMatch->pTab; + pNew->y.pTab = pMatch->pSTab; assert( (pMatch->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 ); ExprSetProperty(pNew, EP_CanBeNull); *ppList = sqlite3ExprListAppend(pParse, *ppList, pNew); @@ -346,10 +346,10 @@ static int lookupName( if( pSrcList ){ for(i=0, pItem=pSrcList->a; inSrc; i++, pItem++){ u8 hCol; - pTab = pItem->pTab; + pTab = pItem->pSTab; assert( pTab!=0 && pTab->zName!=0 ); assert( pTab->nCol>0 || pParse->nErr ); - assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); + assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->sq.pSelect)); if( pItem->fg.isNestedFrom ){ /* In this case, pItem is a subquery that has been formed from a ** parenthesized subset of the FROM clause terms. Example: @@ -358,8 +358,8 @@ static int lookupName( ** This pItem -------------^ */ int hit = 0; - assert( pItem->pSelect!=0 ); - pEList = pItem->pSelect->pEList; + assert( pItem->sq.pSelect!=0 ); + pEList = pItem->sq.pSelect->pEList; assert( pEList!=0 ); assert( pEList->nExpr==pTab->nCol ); for(j=0; jnExpr; j++){ @@ -483,8 +483,8 @@ static int lookupName( if( cntTab==0 || (cntTab==1 && ALWAYS(pMatch!=0) - && ALWAYS(pMatch->pTab!=0) - && (pMatch->pTab->tabFlags & TF_Ephemeral)!=0 + && ALWAYS(pMatch->pSTab!=0) + && (pMatch->pSTab->tabFlags & TF_Ephemeral)!=0 && (pTab->tabFlags & TF_Ephemeral)==0) ){ cntTab = 1; @@ -505,7 +505,7 @@ static int lookupName( if( pMatch ){ pExpr->iTable = pMatch->iCursor; assert( ExprUseYTab(pExpr) ); - pExpr->y.pTab = pMatch->pTab; + pExpr->y.pTab = pMatch->pSTab; if( (pMatch->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 ){ ExprSetProperty(pExpr, EP_CanBeNull); } @@ -547,7 +547,7 @@ static int lookupName( if( (pNC->ncFlags & NC_UUpsert)!=0 && zTab!=0 ){ Upsert *pUpsert = pNC->uNC.pUpsert; if( pUpsert && sqlite3StrICmp("excluded",zTab)==0 ){ - pTab = pUpsert->pUpsertSrc->a[0].pTab; + pTab = pUpsert->pUpsertSrc->a[0].pSTab; pExpr->iTable = EXCLUDED_TABLE_NUMBER; } } @@ -630,11 +630,11 @@ static int lookupName( && pMatch && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 && sqlite3IsRowid(zCol) - && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom) + && ALWAYS(VisibleRowid(pMatch->pSTab) || pMatch->fg.isNestedFrom) ){ cnt = cntTab; #if SQLITE_ALLOW_ROWID_IN_VIEW+0==2 - if( pMatch->pTab!=0 && IsView(pMatch->pTab) ){ + if( pMatch->pSTab!=0 && IsView(pMatch->pSTab) ){ eNewExprOp = TK_NULL; } #endif @@ -871,7 +871,7 @@ Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){ SrcItem *pItem = &pSrc->a[iSrc]; Table *pTab; assert( ExprUseYTab(p) ); - pTab = p->y.pTab = pItem->pTab; + pTab = p->y.pTab = pItem->pSTab; p->iTable = pItem->iCursor; if( p->y.pTab->iPKey==iCol ){ p->iColumn = -1; @@ -990,7 +990,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ pItem = pSrcList->a; pExpr->op = TK_COLUMN; assert( ExprUseYTab(pExpr) ); - pExpr->y.pTab = pItem->pTab; + pExpr->y.pTab = pItem->pSTab; pExpr->iTable = pItem->iCursor; pExpr->iColumn--; pExpr->affExpr = SQLITE_AFF_INTEGER; @@ -1880,7 +1880,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ ** moves the pOrderBy down to the sub-query. It will be moved back ** after the names have been resolved. */ if( p->selFlags & SF_Converted ){ - Select *pSub = p->pSrc->a[0].pSelect; + Select *pSub = p->pSrc->a[0].sq.pSelect; assert( p->pSrc->nSrc==1 && p->pOrderBy ); assert( pSub->pPrior && pSub->pOrderBy==0 ); pSub->pOrderBy = p->pOrderBy; @@ -1892,13 +1892,14 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ if( pOuterNC ) pOuterNC->nNestedSelect++; for(i=0; ipSrc->nSrc; i++){ SrcItem *pItem = &p->pSrc->a[i]; - assert( pItem->zName!=0 || pItem->pSelect!=0 );/* Test of tag-20240424-1*/ - if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ + assert( pItem->zName!=0 + || pItem->sq.pSelect!=0 ); /* Test of tag-20240424-1*/ + if( pItem->sq.pSelect && (pItem->sq.pSelect->selFlags & SF_Resolved)==0 ){ int nRef = pOuterNC ? pOuterNC->nRef : 0; const char *zSavedContext = pParse->zAuthContext; if( pItem->zName ) pParse->zAuthContext = pItem->zName; - sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC); + sqlite3ResolveSelectNames(pParse, pItem->sq.pSelect, pOuterNC); pParse->zAuthContext = zSavedContext; if( pParse->nErr ) return WRC_Abort; assert( db->mallocFailed==0 ); @@ -2000,7 +2001,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ ** These integers will be replaced by copies of the corresponding result ** set expressions by the call to resolveOrderGroupBy() below. */ if( p->selFlags & SF_Converted ){ - Select *pSub = p->pSrc->a[0].pSelect; + Select *pSub = p->pSrc->a[0].sq.pSelect; p->pOrderBy = pSub->pOrderBy; pSub->pOrderBy = 0; } @@ -2267,7 +2268,7 @@ int sqlite3ResolveSelfReference( if( pTab ){ sSrc.nSrc = 1; sSrc.a[0].zName = pTab->zName; - sSrc.a[0].pTab = pTab; + sSrc.a[0].pSTab = pTab; sSrc.a[0].iCursor = -1; if( pTab->pSchema!=pParse->db->aDb[1].pSchema ){ /* Cause EP_FromDDL to be set on TK_FUNCTION nodes of non-TEMP diff --git a/src/select.c b/src/select.c index 634f06e301..5f55b402cf 100644 --- a/src/select.c +++ b/src/select.c @@ -332,11 +332,11 @@ int sqlite3ColumnIndex(Table *pTab, const char *zCol){ */ void sqlite3SrcItemColumnUsed(SrcItem *pItem, int iCol){ assert( pItem!=0 ); - assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); + assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->sq.pSelect) ); if( pItem->fg.isNestedFrom ){ ExprList *pResults; - assert( pItem->pSelect!=0 ); - pResults = pItem->pSelect->pEList; + assert( pItem->sq.pSelect!=0 ); + pResults = pItem->sq.pSelect->pEList; assert( pResults!=0 ); assert( iCol>=0 && iColnExpr ); pResults->a[iCol].fg.bUsed = 1; @@ -370,9 +370,9 @@ static int tableAndColumnIndex( assert( (piTab==0)==(piCol==0) ); /* Both or neither are NULL */ for(i=iStart; i<=iEnd; i++){ - iCol = sqlite3ColumnIndex(pSrc->a[i].pTab, zCol); + iCol = sqlite3ColumnIndex(pSrc->a[i].pSTab, zCol); if( iCol>=0 - && (bIgnoreHidden==0 || IsHiddenColumn(&pSrc->a[i].pTab->aCol[iCol])==0) + && (bIgnoreHidden==0 || IsHiddenColumn(&pSrc->a[i].pSTab->aCol[iCol])==0) ){ if( piTab ){ sqlite3SrcItemColumnUsed(&pSrc->a[i], iCol); @@ -501,10 +501,10 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){ pLeft = &pSrc->a[0]; pRight = &pLeft[1]; for(i=0; inSrc-1; i++, pRight++, pLeft++){ - Table *pRightTab = pRight->pTab; + Table *pRightTab = pRight->pSTab; u32 joinType; - if( NEVER(pLeft->pTab==0 || pRightTab==0) ) continue; + if( NEVER(pLeft->pSTab==0 || pRightTab==0) ) continue; joinType = (pRight->fg.jointype & JT_OUTER)!=0 ? EP_OuterON : EP_InnerON; /* If this is a NATURAL join, synthesize an appropriate USING clause @@ -1930,8 +1930,8 @@ static const char *columnTypeImpl( SrcList *pTabList = pNC->pSrcList; for(j=0;jnSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++); if( jnSrc ){ - pTab = pTabList->a[j].pTab; - pS = pTabList->a[j].pSelect; + pTab = pTabList->a[j].pSTab; + pS = pTabList->a[j].sq.pSelect; }else{ pNC = pNC->pNext; } @@ -3983,7 +3983,7 @@ static void substSelect( pSrc = p->pSrc; assert( pSrc!=0 ); for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ - substSelect(pSubst, pItem->pSelect, 1); + substSelect(pSubst, pItem->sq.pSelect, 1); if( pItem->fg.isTabFunc ){ substExprList(pSubst, pItem->u1.pFuncArg); } @@ -4014,7 +4014,7 @@ static void recomputeColumnsUsed( SrcItem *pSrcItem /* Which FROM clause item to recompute */ ){ Walker w; - if( NEVER(pSrcItem->pTab==0) ) return; + if( NEVER(pSrcItem->pSTab==0) ) return; memset(&w, 0, sizeof(w)); w.xExprCallback = recomputeColumnsUsedExpr; w.xSelectCallback = sqlite3SelectWalkNoop; @@ -4054,7 +4054,7 @@ static void srclistRenumberCursors( aCsrMap[pItem->iCursor+1] = pParse->nTab++; } pItem->iCursor = aCsrMap[pItem->iCursor+1]; - for(p=pItem->pSelect; p; p=p->pPrior){ + for(p=pItem->sq.pSelect; p; p=p->pPrior){ srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); } } @@ -4366,7 +4366,7 @@ static int flattenSubquery( assert( pSrc && iFrom>=0 && iFromnSrc ); pSubitem = &pSrc->a[iFrom]; iParent = pSubitem->iCursor; - pSub = pSubitem->pSelect; + pSub = pSubitem->sq.pSelect; assert( pSub!=0 ); #ifndef SQLITE_OMIT_WINDOWFUNC @@ -4419,7 +4419,7 @@ static int flattenSubquery( */ if( (pSubitem->fg.jointype & (JT_OUTER|JT_LTORJ))!=0 ){ if( pSubSrc->nSrc>1 /* (3a) */ - || IsVirtual(pSubSrc->a[0].pTab) /* (3b) */ + || IsVirtual(pSubSrc->a[0].pSTab) /* (3b) */ || (p->selFlags & SF_Distinct)!=0 /* (3d) */ || (pSubitem->fg.jointype & JT_RIGHT)!=0 /* (26) */ ){ @@ -4505,7 +4505,7 @@ static int flattenSubquery( pParse->zAuthContext = zSavedAuthContext; /* Delete the transient structures associated with the subquery */ - pSub1 = pSubitem->pSelect; + pSub1 = pSubitem->sq.pSelect; if( pSubitem->fg.fixedSchema==0 ){ sqlite3DbFree(db, pSubitem->u4.zDatabase); pSubitem->u4.zDatabase = 0; @@ -4514,7 +4514,7 @@ static int flattenSubquery( sqlite3DbFree(db, pSubitem->zAlias); pSubitem->zName = 0; pSubitem->zAlias = 0; - pSubitem->pSelect = 0; + pSubitem->sq.pSelect = 0; assert( pSubitem->fg.isUsing!=0 || pSubitem->u3.pOn==0 ); /* If the sub-query is a compound SELECT statement, then (by restrictions @@ -4555,8 +4555,8 @@ static int flattenSubquery( ExprList *pOrderBy = p->pOrderBy; Expr *pLimit = p->pLimit; Select *pPrior = p->pPrior; - Table *pItemTab = pSubitem->pTab; - pSubitem->pTab = 0; + Table *pItemTab = pSubitem->pSTab; + pSubitem->pSTab = 0; p->pOrderBy = 0; p->pPrior = 0; p->pLimit = 0; @@ -4564,7 +4564,7 @@ static int flattenSubquery( p->pLimit = pLimit; p->pOrderBy = pOrderBy; p->op = TK_ALL; - pSubitem->pTab = pItemTab; + pSubitem->pSTab = pItemTab; if( pNew==0 ){ p->pPrior = pPrior; }else{ @@ -4579,11 +4579,11 @@ static int flattenSubquery( TREETRACE(0x4,pParse,p,("compound-subquery flattener" " creates %u as peer\n",pNew->selId)); } - assert( pSubitem->pSelect==0 ); + assert( pSubitem->sq.pSelect==0 ); } sqlite3DbFree(db, aCsrMap); if( db->mallocFailed ){ - pSubitem->pSelect = pSub1; + pSubitem->sq.pSelect = pSub1; return 1; } @@ -4594,8 +4594,8 @@ static int flattenSubquery( ** ** pSubitem->pTab is always non-NULL by test restrictions and tests above. */ - if( ALWAYS(pSubitem->pTab!=0) ){ - Table *pTabToDel = pSubitem->pTab; + if( ALWAYS(pSubitem->pSTab!=0) ){ + Table *pTabToDel = pSubitem->pSTab; if( pTabToDel->nTabRef==1 ){ Parse *pToplevel = sqlite3ParseToplevel(pParse); sqlite3ParserAddCleanup(pToplevel, sqlite3DeleteTableGeneric, pTabToDel); @@ -4603,7 +4603,7 @@ static int flattenSubquery( }else{ pTabToDel->nTabRef--; } - pSubitem->pTab = 0; + pSubitem->pSTab = 0; } /* The following loop runs once for each term in a compound-subquery @@ -5344,10 +5344,10 @@ static int disableUnusedSubqueryResultColumns(SrcItem *pItem){ if( pItem->fg.isCorrelated || pItem->fg.isCte ){ return 0; } - assert( pItem->pTab!=0 ); - pTab = pItem->pTab; - assert( pItem->pSelect!=0 ); - pSub = pItem->pSelect; + assert( pItem->pSTab!=0 ); + pTab = pItem->pSTab; + assert( pItem->sq.pSelect!=0 ); + pSub = pItem->sq.pSelect; assert( pSub->pEList->nExpr==pTab->nCol ); for(pX=pSub; pX; pX=pX->pPrior){ if( (pX->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ @@ -5476,13 +5476,13 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ if( p->pWhere || p->pEList->nExpr!=1 || p->pSrc->nSrc!=1 - || p->pSrc->a[0].pSelect + || p->pSrc->a[0].sq.pSelect || pAggInfo->nFunc!=1 || p->pHaving ){ return 0; } - pTab = p->pSrc->a[0].pTab; + pTab = p->pSrc->a[0].pSTab; assert( pTab!=0 ); assert( !IsView(pTab) ); if( !IsOrdinaryTable(pTab) ) return 0; @@ -5507,7 +5507,7 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ ** pFrom->pIndex and return SQLITE_OK. */ int sqlite3IndexedByLookup(Parse *pParse, SrcItem *pFrom){ - Table *pTab = pFrom->pTab; + Table *pTab = pFrom->pSTab; char *zIndexedBy = pFrom->u1.zIndexedBy; Index *pIdx; assert( pTab!=0 ); @@ -5709,7 +5709,7 @@ static int resolveFromTermToCte( Cte *pCte; /* Matched CTE (or NULL if no match) */ With *pWith; /* The matching WITH */ - assert( pFrom->pTab==0 ); + assert( pFrom->pSTab==0 ); if( pParse->pWith==0 ){ /* There are no WITH clauses in the stack. No match is possible */ return 0; @@ -5756,7 +5756,7 @@ static int resolveFromTermToCte( } if( cannotBeFunction(pParse, pFrom) ) return 2; - assert( pFrom->pTab==0 ); + assert( pFrom->pSTab==0 ); pTab = sqlite3DbMallocZero(db, sizeof(Table)); if( pTab==0 ) return 2; pCteUse = pCte->pUse; @@ -5770,16 +5770,16 @@ static int resolveFromTermToCte( } pCteUse->eM10d = pCte->eM10d; } - pFrom->pTab = pTab; + pFrom->pSTab = pTab; pTab->nTabRef = 1; pTab->zName = sqlite3DbStrDup(db, pCte->zName); pTab->iPKey = -1; pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; - pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); + pFrom->sq.pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); if( db->mallocFailed ) return 2; - pFrom->pSelect->selFlags |= SF_CopyCte; - assert( pFrom->pSelect ); + assert( pFrom->sq.pSelect ); + pFrom->sq.pSelect->selFlags |= SF_CopyCte; if( pFrom->fg.isIndexedBy ){ sqlite3ErrorMsg(pParse, "no such index: \"%s\"", pFrom->u1.zIndexedBy); return 2; @@ -5789,7 +5789,7 @@ static int resolveFromTermToCte( pCteUse->nUse++; /* Check if this is a recursive CTE. */ - pRecTerm = pSel = pFrom->pSelect; + pRecTerm = pSel = pFrom->sq.pSelect; bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION ); while( bMayRecursive && pRecTerm->op==pSel->op ){ int i; @@ -5802,7 +5802,7 @@ static int resolveFromTermToCte( && pItem->zName!=0 && 0==sqlite3StrICmp(pItem->zName, pCte->zName) ){ - pItem->pTab = pTab; + pItem->pSTab = pTab; pTab->nTabRef++; pItem->fg.isRecursive = 1; if( pRecTerm->selFlags & SF_Recursive ){ @@ -5904,11 +5904,11 @@ void sqlite3SelectPopWith(Walker *pWalker, Select *p){ ** SQLITE_NOMEM. */ int sqlite3ExpandSubquery(Parse *pParse, SrcItem *pFrom){ - Select *pSel = pFrom->pSelect; + Select *pSel = pFrom->sq.pSelect; Table *pTab; assert( pSel ); - pFrom->pTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table)); + pFrom->pSTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table)); if( pTab==0 ) return SQLITE_NOMEM; pTab->nTabRef = 1; if( pFrom->zAlias ){ @@ -6028,33 +6028,33 @@ static int selectExpander(Walker *pWalker, Select *p){ */ for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ Table *pTab; - assert( pFrom->fg.isRecursive==0 || pFrom->pTab!=0 ); - if( pFrom->pTab ) continue; + assert( pFrom->fg.isRecursive==0 || pFrom->pSTab!=0 ); + if( pFrom->pSTab ) continue; assert( pFrom->fg.isRecursive==0 ); if( pFrom->zName==0 ){ #ifndef SQLITE_OMIT_SUBQUERY - Select *pSel = pFrom->pSelect; + Select *pSel = pFrom->sq.pSelect; /* A sub-query in the FROM clause of a SELECT */ assert( pSel!=0 ); - assert( pFrom->pTab==0 ); + assert( pFrom->pSTab==0 ); if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort; if( sqlite3ExpandSubquery(pParse, pFrom) ) return WRC_Abort; #endif #ifndef SQLITE_OMIT_CTE }else if( (rc = resolveFromTermToCte(pParse, pWalker, pFrom))!=0 ){ if( rc>1 ) return WRC_Abort; - pTab = pFrom->pTab; + pTab = pFrom->pSTab; assert( pTab!=0 ); #endif }else{ /* An ordinary table or view name in the FROM clause */ - assert( pFrom->pTab==0 ); - pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom); + assert( pFrom->pSTab==0 ); + pFrom->pSTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom); if( pTab==0 ) return WRC_Abort; if( pTab->nTabRef>=0xffff ){ sqlite3ErrorMsg(pParse, "too many references to \"%s\": max 65535", pTab->zName); - pFrom->pTab = 0; + pFrom->pSTab = 0; return WRC_Abort; } pTab->nTabRef++; @@ -6066,7 +6066,7 @@ static int selectExpander(Walker *pWalker, Select *p){ i16 nCol; u8 eCodeOrig = pWalker->eCode; if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; - assert( pFrom->pSelect==0 ); + assert( pFrom->sq.pSelect==0 ); if( IsView(pTab) ){ if( (db->flags & SQLITE_EnableView)==0 && pTab->pSchema!=db->aDb[1].pSchema @@ -6074,7 +6074,7 @@ static int selectExpander(Walker *pWalker, Select *p){ sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", pTab->zName); } - pFrom->pSelect = sqlite3SelectDup(db, pTab->u.view.pSelect, 0); + pFrom->sq.pSelect = sqlite3SelectDup(db, pTab->u.view.pSelect, 0); } #ifndef SQLITE_OMIT_VIRTUALTABLE else if( ALWAYS(IsVirtual(pTab)) @@ -6090,7 +6090,7 @@ static int selectExpander(Walker *pWalker, Select *p){ nCol = pTab->nCol; pTab->nCol = -1; pWalker->eCode = 1; /* Turn on Select.selId renumbering */ - sqlite3WalkSelect(pWalker, pFrom->pSelect); + sqlite3WalkSelect(pWalker, pFrom->sq.pSelect); pWalker->eCode = eCodeOrig; pTab->nCol = nCol; } @@ -6177,7 +6177,7 @@ static int selectExpander(Walker *pWalker, Select *p){ } for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ int nAdd; /* Number of cols including rowid */ - Table *pTab = pFrom->pTab; /* Table for this data source */ + Table *pTab = pFrom->pSTab; /* Table for this data source */ ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ char *zTabName; /* AS name for this data source */ const char *zSchemaName = 0; /* Schema name for this data source */ @@ -6188,10 +6188,11 @@ static int selectExpander(Walker *pWalker, Select *p){ zTabName = pTab->zName; } if( db->mallocFailed ) break; - assert( (int)pFrom->fg.isNestedFrom == IsNestedFrom(pFrom->pSelect) ); + assert( (int)pFrom->fg.isNestedFrom == + IsNestedFrom(pFrom->sq.pSelect) ); if( pFrom->fg.isNestedFrom ){ - assert( pFrom->pSelect!=0 ); - pNestedFrom = pFrom->pSelect->pEList; + assert( pFrom->sq.pSelect!=0 ); + pNestedFrom = pFrom->sq.pSelect->pEList; assert( pNestedFrom!=0 ); assert( pNestedFrom->nExpr==pTab->nCol ); assert( VisibleRowid(pTab)==0 || ViewCanHaveRowid ); @@ -6430,11 +6431,11 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ assert( (p->selFlags & SF_Resolved) ); pTabList = p->pSrc; for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ - Table *pTab = pFrom->pTab; + Table *pTab = pFrom->pSTab; assert( pTab!=0 ); if( (pTab->tabFlags & TF_Ephemeral)!=0 ){ /* A sub-query in the FROM clause of a SELECT */ - Select *pSel = pFrom->pSelect; + Select *pSel = pFrom->sq.pSelect; if( pSel ){ sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_NONE); } @@ -7084,25 +7085,25 @@ static SrcItem *isSelfJoinView( int iFirst, int iEnd /* Range of FROM-clause entries to search. */ ){ SrcItem *pItem; - assert( pThis->pSelect!=0 ); - if( pThis->pSelect->selFlags & SF_PushDown ) return 0; + assert( pThis->sq.pSelect!=0 ); + if( pThis->sq.pSelect->selFlags & SF_PushDown ) return 0; while( iFirsta[iFirst++]; - if( pItem->pSelect==0 ) continue; + if( pItem->sq.pSelect==0 ) continue; if( pItem->fg.viaCoroutine ) continue; if( pItem->zName==0 ) continue; - assert( pItem->pTab!=0 ); - assert( pThis->pTab!=0 ); - if( pItem->pTab->pSchema!=pThis->pTab->pSchema ) continue; + assert( pItem->pSTab!=0 ); + assert( pThis->pSTab!=0 ); + if( pItem->pSTab->pSchema!=pThis->pSTab->pSchema ) continue; if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue; - pS1 = pItem->pSelect; - if( pItem->pTab->pSchema==0 && pThis->pSelect->selId!=pS1->selId ){ + pS1 = pItem->sq.pSelect; + if( pItem->pSTab->pSchema==0 && pThis->sq.pSelect->selId!=pS1->selId ){ /* The query flattener left two different CTE tables with identical ** names in the same FROM clause. */ continue; } - if( pItem->pSelect->selFlags & SF_PushDown ){ + if( pItem->sq.pSelect->selFlags & SF_PushDown ){ /* The view was modified by some other optimization such as ** pushDownWhereTerms() */ continue; @@ -7160,7 +7161,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */ if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */ if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */ - pSub = p->pSrc->a[0].pSelect; + pSub = p->pSrc->a[0].sq.pSelect; if( pSub==0 ) return 0; /* The FROM is a subquery */ if( pSub->pPrior==0 ) return 0; /* Must be a compound */ if( pSub->selFlags & SF_CopyCte ) return 0; /* Not a CTE */ @@ -7178,8 +7179,8 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ db = pParse->db; pCount = pExpr; pExpr = 0; - pSub = p->pSrc->a[0].pSelect; - p->pSrc->a[0].pSelect = 0; + pSub = p->pSrc->a[0].sq.pSelect; + p->pSrc->a[0].sq.pSelect = 0; sqlite3SrcListDelete(db, p->pSrc); p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*p->pSrc)); while( pSub ){ @@ -7224,12 +7225,12 @@ static int sameSrcAlias(SrcItem *p0, SrcList *pSrc){ for(i=0; inSrc; i++){ SrcItem *p1 = &pSrc->a[i]; if( p1==p0 ) continue; - if( p0->pTab==p1->pTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){ + if( p0->pSTab==p1->pSTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){ return 1; } - if( p1->pSelect - && (p1->pSelect->selFlags & SF_NestedFrom)!=0 - && sameSrcAlias(p0, p1->pSelect->pSrc) + if( p1->sq.pSelect + && (p1->sq.pSelect->selFlags & SF_NestedFrom)!=0 + && sameSrcAlias(p0, p1->sq.pSelect->pSrc) ){ return 1; } @@ -7294,7 +7295,7 @@ static int fromClauseTermCanBeCoroutine( if( i==0 ) break; i--; pItem--; - if( pItem->pSelect!=0 ) return 0; /* (1c-i) */ + if( pItem->sq.pSelect!=0 ) return 0; /* (1c-i) */ } return 1; } @@ -7405,7 +7406,7 @@ int sqlite3Select( if( sameSrcAlias(p0, p->pSrc) ){ sqlite3ErrorMsg(pParse, "target object/alias may not appear in FROM clause: %s", - p0->zAlias ? p0->zAlias : p0->pTab->zName + p0->zAlias ? p0->zAlias : p0->pSTab->zName ); goto select_end; } @@ -7444,8 +7445,8 @@ int sqlite3Select( #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) for(i=0; !p->pPrior && inSrc; i++){ SrcItem *pItem = &pTabList->a[i]; - Select *pSub = pItem->pSelect; - Table *pTab = pItem->pTab; + Select *pSub = pItem->sq.pSelect; + Table *pTab = pItem->pSTab; /* The expander should have already created transient Table objects ** even for FROM clause elements such as subqueries that do not correspond @@ -7698,11 +7699,11 @@ int sqlite3Select( #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) /* Generate code for all sub-queries in the FROM clause */ - pSub = pItem->pSelect; - if( pSub==0 || pItem->addrFillSub!=0 ) continue; + pSub = pItem->sq.pSelect; + if( pSub==0 || pItem->sq.addrFillSub!=0 ) continue; /* The code for a subquery should only be generated once. */ - assert( pItem->addrFillSub==0 ); + assert( pItem->sq.addrFillSub==0 ); /* Increment Parse.nHeight by the height of the largest expression ** tree referred to by this, the parent select. The child select @@ -7728,7 +7729,8 @@ int sqlite3Select( sqlite3TreeViewSelect(0, p, 0); } #endif - assert( pItem->pSelect && (pItem->pSelect->selFlags & SF_PushDown)!=0 ); + assert( pItem->sq.pSelect + && (pItem->sq.pSelect->selFlags & SF_PushDown)!=0 ); }else{ TREETRACE(0x4000,pParse,p,("WHERE-lcause push-down not possible\n")); } @@ -7760,17 +7762,17 @@ int sqlite3Select( */ int addrTop = sqlite3VdbeCurrentAddr(v)+1; - pItem->regReturn = ++pParse->nMem; - sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop); + pItem->sq.regReturn = ++pParse->nMem; + sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->sq.regReturn, 0, addrTop); VdbeComment((v, "%!S", pItem)); - pItem->addrFillSub = addrTop; - sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn); + pItem->sq.addrFillSub = addrTop; + sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->sq.regReturn); ExplainQueryPlan((pParse, 1, "CO-ROUTINE %!S", pItem)); sqlite3Select(pParse, pSub, &dest); - pItem->pTab->nRowLogEst = pSub->nSelectRow; + pItem->pSTab->nRowLogEst = pSub->nSelectRow; pItem->fg.viaCoroutine = 1; - pItem->regResult = dest.iSdst; - sqlite3VdbeEndCoroutine(v, pItem->regReturn); + pItem->sq.regResult = dest.iSdst; + sqlite3VdbeEndCoroutine(v, pItem->sq.regReturn); sqlite3VdbeJumpHere(v, addrTop-1); sqlite3ClearTempRegCache(pParse); }else if( pItem->fg.isCte && pItem->u2.pCteUse->addrM9e>0 ){ @@ -7788,11 +7790,12 @@ int sqlite3Select( }else if( (pPrior = isSelfJoinView(pTabList, pItem, 0, i))!=0 ){ /* This view has already been materialized by a prior entry in ** this same FROM clause. Reuse it. */ - if( pPrior->addrFillSub ){ - sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub); + if( pPrior->sq.addrFillSub ){ + sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->sq.regReturn, + pPrior->sq.addrFillSub); } sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); - pSub->nSelectRow = pPrior->pSelect->nSelectRow; + pSub->nSelectRow = pPrior->sq.pSelect->nSelectRow; }else{ /* Materialize the view. If the view is not correlated, generate a ** subroutine to do the materialization so that subsequent uses of @@ -7803,9 +7806,9 @@ int sqlite3Select( int addrExplain; #endif - pItem->regReturn = ++pParse->nMem; + pItem->sq.regReturn = ++pParse->nMem; topAddr = sqlite3VdbeAddOp0(v, OP_Goto); - pItem->addrFillSub = topAddr+1; + pItem->sq.addrFillSub = topAddr+1; pItem->fg.isMaterialized = 1; if( pItem->fg.isCorrelated==0 ){ /* If the subquery is not correlated and if we are not inside of @@ -7820,17 +7823,17 @@ int sqlite3Select( ExplainQueryPlan2(addrExplain, (pParse, 1, "MATERIALIZE %!S", pItem)); sqlite3Select(pParse, pSub, &dest); - pItem->pTab->nRowLogEst = pSub->nSelectRow; + pItem->pSTab->nRowLogEst = pSub->nSelectRow; if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr); - sqlite3VdbeAddOp2(v, OP_Return, pItem->regReturn, topAddr+1); + sqlite3VdbeAddOp2(v, OP_Return, pItem->sq.regReturn, topAddr+1); VdbeComment((v, "end %!S", pItem)); sqlite3VdbeScanStatusRange(v, addrExplain, addrExplain, -1); sqlite3VdbeJumpHere(v, topAddr); sqlite3ClearTempRegCache(pParse); if( pItem->fg.isCte && pItem->fg.isCorrelated==0 ){ CteUse *pCteUse = pItem->u2.pCteUse; - pCteUse->addrM9e = pItem->addrFillSub; - pCteUse->regRtn = pItem->regReturn; + pCteUse->addrM9e = pItem->sq.addrFillSub; + pCteUse->regRtn = pItem->sq.regReturn; pCteUse->iCur = pItem->iCursor; pCteUse->nRowEst = pSub->nSelectRow; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 75e1f61201..54e4f2db73 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3295,15 +3295,23 @@ struct IdList { ** ** u2.pIBIndex fg.isIndexedBy && !fg.isCte ** u2.pCteUse fg.isCte && !fg.isIndexedBy +** +** u3.pOn fg.isUsing==0 +** u3.pUsing fg.isUsing==1 +** +** u4.zDatabase fg.fixedSchema==0 +** u4.pSchema fg.fixedSchema==1 */ struct SrcItem { char *zName; /* Name of the table */ char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ - Table *pTab; /* An SQL table corresponding to zName */ - Select *pSelect; /* A SELECT statement used in place of a table name */ - int addrFillSub; /* Address of subroutine to initialize a subquery */ - int regReturn; /* Register holding return address of addrFillSub */ - int regResult; /* Registers holding results of a co-routine */ + Table *pSTab; /* Table object for zName. Mnemonic: Srcitem-TABle */ + struct SrcItemSubquery { + Select *pSelect; /* A SELECT statement used in place of a table name */ + int addrFillSub; /* Address of subroutine to initialize a subquery */ + int regReturn; /* Register holding return address of addrFillSub */ + int regResult; /* Registers holding results of a co-routine */ + } sq; struct { u8 jointype; /* Type of join between this table and the previous */ unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ diff --git a/src/treeview.c b/src/treeview.c index 3960d2859e..0c9fdc5266 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -193,9 +193,9 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); x.printfFlags |= SQLITE_PRINTF_INTERNAL; sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem); - if( pItem->pTab ){ + if( pItem->pSTab ){ sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx%s", - pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, + pItem->pSTab->zName, pItem->pSTab->nCol, pItem->pSTab, pItem->colUsed, pItem->fg.rowidUsed ? "+rowid" : ""); } @@ -230,19 +230,19 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ sqlite3StrAccumFinish(&x); sqlite3TreeViewItem(pView, zLine, inSrc-1); n = 0; - if( pItem->pSelect ) n++; + if( pItem->sq.pSelect ) n++; if( pItem->fg.isTabFunc ) n++; if( pItem->fg.isUsing ) n++; if( pItem->fg.isUsing ){ sqlite3TreeViewIdList(pView, pItem->u3.pUsing, (--n)>0, "USING"); } - if( pItem->pSelect ){ - if( pItem->pTab ){ - Table *pTab = pItem->pTab; + if( pItem->sq.pSelect ){ + if( pItem->pSTab ){ + Table *pTab = pItem->pSTab; sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1); } - assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); - sqlite3TreeViewSelect(pView, pItem->pSelect, (--n)>0); + assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->sq.pSelect) ); + sqlite3TreeViewSelect(pView, pItem->sq.pSelect, (--n)>0); } if( pItem->fg.isTabFunc ){ sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); diff --git a/src/trigger.c b/src/trigger.c index a5a57abf16..170f094eab 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -984,7 +984,7 @@ static int sqlite3ReturningSubqueryCorrelated(Walker *pWalker, Select *pSelect){ pSrc = pSelect->pSrc; assert( pSrc!=0 ); for(i=0; inSrc; i++){ - if( pSrc->a[i].pTab==pWalker->u.pTab ){ + if( pSrc->a[i].pSTab==pWalker->u.pTab ){ testcase( pSelect->selFlags & SF_Correlated ); pSelect->selFlags |= SF_Correlated; pWalker->eCode = 1; @@ -1055,7 +1055,7 @@ static void codeReturningTrigger( sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); sSelect.pSrc = &sFrom; sFrom.nSrc = 1; - sFrom.a[0].pTab = pTab; + sFrom.a[0].pSTab = pTab; sFrom.a[0].zName = pTab->zName; /* tag-20240424-1 */ sFrom.a[0].iCursor = -1; sqlite3SelectPrep(pParse, &sSelect, 0); diff --git a/src/update.c b/src/update.c index b6068caa79..a8e7f77803 100644 --- a/src/update.c +++ b/src/update.c @@ -202,7 +202,7 @@ static void updateFromSelect( Expr *pLimit2 = 0; ExprList *pOrderBy2 = 0; sqlite3 *db = pParse->db; - Table *pTab = pTabList->a[0].pTab; + Table *pTab = pTabList->a[0].pSTab; SrcList *pSrc; Expr *pWhere2; int eDest; @@ -226,8 +226,8 @@ static void updateFromSelect( if( pSrc ){ assert( pSrc->a[0].fg.notCte ); pSrc->a[0].iCursor = -1; - pSrc->a[0].pTab->nTabRef--; - pSrc->a[0].pTab = 0; + pSrc->a[0].pSTab->nTabRef--; + pSrc->a[0].pSTab = 0; } if( pPk ){ for(i=0; inKeyCol; i++){ diff --git a/src/upsert.c b/src/upsert.c index f74d4fabf5..82295d52ae 100644 --- a/src/upsert.c +++ b/src/upsert.c @@ -104,7 +104,7 @@ int sqlite3UpsertAnalyzeTarget( int nClause = 0; /* Counter of ON CONFLICT clauses */ assert( pTabList->nSrc==1 ); - assert( pTabList->a[0].pTab!=0 ); + assert( pTabList->a[0].pSTab!=0 ); assert( pUpsert!=0 ); assert( pUpsert->pUpsertTarget!=0 ); @@ -123,7 +123,7 @@ int sqlite3UpsertAnalyzeTarget( if( rc ) return rc; /* Check to see if the conflict target matches the rowid. */ - pTab = pTabList->a[0].pTab; + pTab = pTabList->a[0].pSTab; pTarget = pUpsert->pUpsertTarget; iCursor = pTabList->a[0].iCursor; if( HasRowid(pTab) diff --git a/src/walker.c b/src/walker.c index 0fe4a1d379..27963c2234 100644 --- a/src/walker.c +++ b/src/walker.c @@ -171,7 +171,7 @@ int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){ pSrc = p->pSrc; if( ALWAYS(pSrc) ){ for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ - if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){ + if( pItem->sq.pSelect && sqlite3WalkSelect(pWalker, pItem->sq.pSelect) ){ return WRC_Abort; } if( pItem->fg.isTabFunc diff --git a/src/where.c b/src/where.c index 631b7581fb..ded5f06816 100644 --- a/src/where.c +++ b/src/where.c @@ -644,7 +644,7 @@ static int isDistinctRedundant( ** clause is redundant. */ if( pTabList->nSrc!=1 ) return 0; iBase = pTabList->a[0].iCursor; - pTab = pTabList->a[0].pTab; + pTab = pTabList->a[0].pSTab; /* If any of the expressions is an IPK column on table iBase, then return ** true. Note: The (p->iTable==iBase) part of this test may be false if the @@ -908,10 +908,10 @@ static int termCanDriveIndex( assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); leftCol = pTerm->u.x.leftColumn; if( leftCol<0 ) return 0; - aff = pSrc->pTab->aCol[leftCol].affinity; + aff = pSrc->pSTab->aCol[leftCol].affinity; if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; testcase( pTerm->pExpr->op==TK_IS ); - return columnIsGoodIndexCandidate(pSrc->pTab, leftCol); + return columnIsGoodIndexCandidate(pSrc->pSTab, leftCol); } #endif @@ -1019,7 +1019,7 @@ static SQLITE_NOINLINE void constructAutomaticIndex( nKeyCol = 0; pTabList = pWC->pWInfo->pTabList; pSrc = &pTabList->a[pLevel->iFrom]; - pTable = pSrc->pTab; + pTable = pSrc->pSTab; pWCEnd = &pWC->a[pWC->nTerm]; pLoop = pLevel->pWLoop; idxCols = 0; @@ -1161,12 +1161,12 @@ static SQLITE_NOINLINE void constructAutomaticIndex( /* Fill the automatic index with content */ assert( pSrc == &pWC->pWInfo->pTabList->a[pLevel->iFrom] ); if( pSrc->fg.viaCoroutine ){ - int regYield = pSrc->regReturn; + int regYield = pSrc->sq.regReturn; addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0); - sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSrc->addrFillSub); + sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSrc->sq.addrFillSub); addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield); VdbeCoverage(v); - VdbeComment((v, "next row of %s", pSrc->pTab->zName)); + VdbeComment((v, "next row of %s", pSrc->pSTab->zName)); }else{ addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v); } @@ -1192,7 +1192,7 @@ static SQLITE_NOINLINE void constructAutomaticIndex( testcase( pParse->db->mallocFailed ); assert( pLevel->iIdxCur>0 ); translateColumnToCopy(pParse, addrTop, pLevel->iTabCur, - pSrc->regResult, pLevel->iIdxCur); + pSrc->sq.regResult, pLevel->iIdxCur); sqlite3VdbeGoto(v, addrTop); pSrc->fg.viaCoroutine = 0; }else{ @@ -1283,7 +1283,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter( iSrc = pLevel->iFrom; pItem = &pTabList->a[iSrc]; assert( pItem!=0 ); - pTab = pItem->pTab; + pTab = pItem->pSTab; assert( pTab!=0 ); sz = sqlite3LogEstToInt(pTab->nRowLogEst); if( sz<10000 ){ @@ -1314,7 +1314,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter( int r1 = sqlite3GetTempRange(pParse, n); int jj; for(jj=0; jjpTable==pItem->pTab ); + assert( pIdx->pTable==pItem->pSTab ); sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iCur, jj, r1+jj); } sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, n); @@ -1395,7 +1395,7 @@ static sqlite3_index_info *allocateIndexInfo( WhereClause *p; assert( pSrc!=0 ); - pTab = pSrc->pTab; + pTab = pSrc->pSTab; assert( pTab!=0 ); assert( IsVirtual(pTab) ); @@ -2403,7 +2403,7 @@ void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){ WhereInfo *pWInfo = pWC->pWInfo; int nb = 1+(pWInfo->pTabList->nSrc+3)/4; SrcItem *pItem = pWInfo->pTabList->a + p->iTab; - Table *pTab = pItem->pTab; + Table *pTab = pItem->pSTab; Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1; sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId, p->iTab, nb, p->maskSelf, nb, p->prereq & mAll); @@ -3391,7 +3391,7 @@ static int whereLoopAddBtreeIndex( ** 2. Stepping forward in the index pNew->nOut times to find all ** additional matching entries. */ - assert( pSrc->pTab->szTabRow>0 ); + assert( pSrc->pSTab->szTabRow>0 ); if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){ /* The pProbe->szIdxRow is low for an IPK table since the interior ** pages are small. Thus szIdxRow gives a good estimate of seek cost. @@ -3399,7 +3399,7 @@ static int whereLoopAddBtreeIndex( ** under-estimate the scanning cost. */ rCostIdx = pNew->nOut + 16; }else{ - rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow; + rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pSTab->szTabRow; } rCostIdx = sqlite3LogEstAdd(rLogSize, rCostIdx); @@ -3864,9 +3864,9 @@ static int whereLoopAddBtree( pWInfo = pBuilder->pWInfo; pTabList = pWInfo->pTabList; pSrc = pTabList->a + pNew->iTab; - pTab = pSrc->pTab; + pTab = pSrc->pSTab; pWC = pBuilder->pWC; - assert( !IsVirtual(pSrc->pTab) ); + assert( !IsVirtual(pSrc->pSTab) ); if( pSrc->fg.isIndexedBy ){ assert( pSrc->fg.isCte==0 ); @@ -3891,7 +3891,7 @@ static int whereLoopAddBtree( sPk.idxType = SQLITE_IDXTYPE_IPK; aiRowEstPk[0] = pTab->nRowLogEst; aiRowEstPk[1] = 0; - pFirst = pSrc->pTab->pIndex; + pFirst = pSrc->pSTab->pIndex; if( pSrc->fg.notIndexed==0 ){ /* The real indices of the table are only considered if the ** NOT INDEXED qualifier is omitted from the FROM clause */ @@ -4010,9 +4010,9 @@ static int whereLoopAddBtree( #endif ApplyCostMultiplier(pNew->rRun, pTab->costMult); whereLoopOutputAdjust(pWC, pNew, rSize); - if( pSrc->pSelect ){ + if( pSrc->sq.pSelect ){ if( pSrc->fg.viaCoroutine ) pNew->wsFlags |= WHERE_COROUTINE; - pNew->u.btree.pOrderBy = pSrc->pSelect->pOrderBy; + pNew->u.btree.pOrderBy = pSrc->sq.pSelect->pOrderBy; } rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; @@ -4238,7 +4238,7 @@ static int whereLoopAddVirtualOne( pHidden->mHandleIn = 0; /* Invoke the virtual table xBestIndex() method */ - rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo); + rc = vtabBestIndex(pParse, pSrc->pSTab, pIdxInfo); if( rc ){ if( rc==SQLITE_CONSTRAINT ){ /* If the xBestIndex method returns SQLITE_CONSTRAINT, that means @@ -4268,7 +4268,7 @@ static int whereLoopAddVirtualOne( || pNew->aLTerm[iTerm]!=0 || pIdxCons->usable==0 ){ - sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName); + sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pSTab->zName); freeIdxStr(pIdxInfo); return SQLITE_ERROR; } @@ -4331,7 +4331,7 @@ static int whereLoopAddVirtualOne( if( pNew->aLTerm[i]==0 ){ /* The non-zero argvIdx values must be contiguous. Raise an ** error if they are not */ - sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName); + sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pSTab->zName); freeIdxStr(pIdxInfo); return SQLITE_ERROR; } @@ -4533,7 +4533,7 @@ static int whereLoopAddVirtual( pWC = pBuilder->pWC; pNew = pBuilder->pNew; pSrc = &pWInfo->pTabList->a[pNew->iTab]; - assert( IsVirtual(pSrc->pTab) ); + assert( IsVirtual(pSrc->pSTab) ); p = allocateIndexInfo(pWInfo, pWC, mUnusable, pSrc, &mNoOmit); if( p==0 ) return SQLITE_NOMEM_BKPT; pNew->rSetup = 0; @@ -4547,7 +4547,7 @@ static int whereLoopAddVirtual( } /* First call xBestIndex() with all constraints usable. */ - WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName)); + WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pSTab->zName)); WHERETRACE(0x800, (" VirtualOne: all usable\n")); rc = whereLoopAddVirtualOne( pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn, &bRetry @@ -4629,7 +4629,7 @@ static int whereLoopAddVirtual( } freeIndexInfo(pParse->db, p); - WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc)); + WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pSTab->zName, rc)); return rc; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ @@ -4701,7 +4701,7 @@ static int whereLoopAddOr( } #endif #ifndef SQLITE_OMIT_VIRTUALTABLE - if( IsVirtual(pItem->pTab) ){ + if( IsVirtual(pItem->pSTab) ){ rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable); }else #endif @@ -4815,7 +4815,7 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){ mPrereq = 0; } #ifndef SQLITE_OMIT_VIRTUALTABLE - if( IsVirtual(pItem->pTab) ){ + if( IsVirtual(pItem->pSTab) ){ SrcItem *p; for(p=&pItem[1]; pfg.jointype & (JT_OUTER|JT_CROSS)) ){ @@ -5451,7 +5451,7 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ if( sqlite3WhereTrace&0x4 ){ SrcItem *pItem = pWInfo->pTabList->a + iLoop; sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n", - pItem->zAlias ? pItem->zAlias : pItem->pTab->zName, + pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName, nDep, rDelta); } #endif @@ -6001,7 +6001,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0; assert( pWInfo->pTabList->nSrc>=1 ); pItem = pWInfo->pTabList->a; - pTab = pItem->pTab; + pTab = pItem->pSTab; if( IsVirtual(pTab) ) return 0; if( pItem->fg.isIndexedBy || pItem->fg.notIndexed ){ testcase( pItem->fg.isIndexedBy ); @@ -6264,7 +6264,7 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful( WhereLoop *pLoop = pWInfo->a[i].pWLoop; const unsigned int reqFlags = (WHERE_SELFCULL|WHERE_COLUMN_EQ); SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab]; - Table *pTab = pItem->pTab; + Table *pTab = pItem->pSTab; if( (pTab->tabFlags & TF_HasStat1)==0 ) break; pTab->tabFlags |= TF_MaybeReanalyze; if( i>=1 @@ -6421,8 +6421,8 @@ static SQLITE_NOINLINE void whereReverseScanOrder(WhereInfo *pWInfo){ SrcItem *pItem = &pWInfo->pTabList->a[ii]; if( !pItem->fg.isCte || pItem->u2.pCteUse->eM10d!=M10d_Yes - || NEVER(pItem->pSelect==0) - || pItem->pSelect->pOrderBy==0 + || NEVER(pItem->sq.pSelect==0) + || pItem->sq.pSelect->pOrderBy==0 ){ pWInfo->revMask |= MASKBIT(ii); } @@ -6912,15 +6912,15 @@ WhereInfo *sqlite3WhereBegin( if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){ int wsFlags = pWInfo->a[0].pWLoop->wsFlags; int bOnerow = (wsFlags & WHERE_ONEROW)!=0; - assert( !(wsFlags & WHERE_VIRTUALTABLE) || IsVirtual(pTabList->a[0].pTab) ); + assert( !(wsFlags&WHERE_VIRTUALTABLE) || IsVirtual(pTabList->a[0].pSTab) ); if( bOnerow || ( 0!=(wctrlFlags & WHERE_ONEPASS_MULTIROW) - && !IsVirtual(pTabList->a[0].pTab) + && !IsVirtual(pTabList->a[0].pSTab) && (0==(wsFlags & WHERE_MULTI_OR) || (wctrlFlags & WHERE_DUPLICATES_OK)) && OptimizationEnabled(db, SQLITE_OnePass) )){ pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI; - if( HasRowid(pTabList->a[0].pTab) && (wsFlags & WHERE_IDX_ONLY) ){ + if( HasRowid(pTabList->a[0].pSTab) && (wsFlags & WHERE_IDX_ONLY) ){ if( wctrlFlags & WHERE_ONEPASS_MULTIROW ){ bFordelete = OPFLAG_FORDELETE; } @@ -6938,7 +6938,7 @@ WhereInfo *sqlite3WhereBegin( SrcItem *pTabItem; pTabItem = &pTabList->a[pLevel->iFrom]; - pTab = pTabItem->pTab; + pTab = pTabItem->pSTab; iDb = sqlite3SchemaToIndex(db, pTab->pSchema); pLoop = pLevel->pWLoop; if( (pTab->tabFlags & TF_Ephemeral)!=0 || IsView(pTab) ){ @@ -7009,7 +7009,7 @@ WhereInfo *sqlite3WhereBegin( iIndexCur = pLevel->iTabCur; op = 0; }else if( pWInfo->eOnePass!=ONEPASS_OFF ){ - Index *pJ = pTabItem->pTab->pIndex; + Index *pJ = pTabItem->pSTab->pIndex; iIndexCur = iAuxArg; assert( wctrlFlags & WHERE_ONEPASS_DESIRED ); while( ALWAYS(pJ) && pJ!=pIx ){ @@ -7076,7 +7076,7 @@ WhereInfo *sqlite3WhereBegin( sqlite3VdbeAddOp2(v, OP_Blob, 65536, pRJ->regBloom); pRJ->regReturn = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Null, 0, pRJ->regReturn); - assert( pTab==pTabItem->pTab ); + assert( pTab==pTabItem->pSTab ); if( HasRowid(pTab) ){ KeyInfo *pInfo; sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRJ->iMatch, 1); @@ -7116,10 +7116,10 @@ WhereInfo *sqlite3WhereBegin( pSrc = &pTabList->a[pLevel->iFrom]; if( pSrc->fg.isMaterialized ){ if( pSrc->fg.isCorrelated ){ - sqlite3VdbeAddOp2(v, OP_Gosub, pSrc->regReturn, pSrc->addrFillSub); + sqlite3VdbeAddOp2(v, OP_Gosub, pSrc->sq.regReturn,pSrc->sq.addrFillSub); }else{ int iOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); - sqlite3VdbeAddOp2(v, OP_Gosub, pSrc->regReturn, pSrc->addrFillSub); + sqlite3VdbeAddOp2(v, OP_Gosub, pSrc->sq.regReturn,pSrc->sq.addrFillSub); sqlite3VdbeJumpHere(v, iOnce); } } @@ -7334,9 +7334,9 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ assert( pLevel->iTabCur==pSrc->iCursor ); if( pSrc->fg.viaCoroutine ){ int m, n; - n = pSrc->regResult; - assert( pSrc->pTab!=0 ); - m = pSrc->pTab->nCol; + n = pSrc->sq.regResult; + assert( pSrc->pSTab!=0 ); + m = pSrc->pSTab->nCol; sqlite3VdbeAddOp3(v, OP_Null, 0, n, n+m-1); } sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur); @@ -7360,7 +7360,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ sqlite3VdbeJumpHere(v, addr); } VdbeModuleComment((v, "End WHERE-loop%d: %s", i, - pWInfo->pTabList->a[pLevel->iFrom].pTab->zName)); + pWInfo->pTabList->a[pLevel->iFrom].pSTab->zName)); } assert( pWInfo->nLevel<=pTabList->nSrc ); @@ -7369,7 +7369,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ VdbeOp *pOp, *pLastOp; Index *pIdx = 0; SrcItem *pTabItem = &pTabList->a[pLevel->iFrom]; - Table *pTab = pTabItem->pTab; + Table *pTab = pTabItem->pSTab; assert( pTab!=0 ); pLoop = pLevel->pWLoop; @@ -7388,9 +7388,9 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ */ if( pTabItem->fg.viaCoroutine ){ testcase( pParse->db->mallocFailed ); - assert( pTabItem->regResult>=0 ); + assert( pTabItem->sq.regResult>=0 ); translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur, - pTabItem->regResult, 0); + pTabItem->sq.regResult, 0); continue; } diff --git a/src/wherecode.c b/src/wherecode.c index 098af7375e..ebc71d1102 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -157,7 +157,7 @@ int sqlite3WhereExplainOneScan( assert( pLoop->u.btree.pIndex!=0 ); pIdx = pLoop->u.btree.pIndex; assert( !(flags&WHERE_AUTO_INDEX) || (flags&WHERE_IDX_ONLY) ); - if( !HasRowid(pItem->pTab) && IsPrimaryKeyIndex(pIdx) ){ + if( !HasRowid(pItem->pSTab) && IsPrimaryKeyIndex(pIdx) ){ if( isSearch ){ zFmt = "PRIMARY KEY"; } @@ -254,7 +254,7 @@ int sqlite3WhereExplainBloomFilter( sqlite3_str_appendf(&str, "BLOOM FILTER ON %S (", pItem); pLoop = pLevel->pWLoop; if( pLoop->wsFlags & WHERE_IPK ){ - const Table *pTab = pItem->pTab; + const Table *pTab = pItem->pSTab; if( pTab->iPKey>=0 ){ sqlite3_str_appendf(&str, "%s=?", pTab->aCol[pTab->iPKey].zCnName); }else{ @@ -317,7 +317,7 @@ void sqlite3WhereAddScanStatus( sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iIdxCur); } }else{ - int addr = pSrclist->a[pLvl->iFrom].addrFillSub; + int addr = pSrclist->a[pLvl->iFrom].sq.addrFillSub; VdbeOp *pOp = sqlite3VdbeGetOp(v, addr-1); assert( sqlite3VdbeDb(v)->mallocFailed || pOp->opcode==OP_InitCoroutine ); assert( sqlite3VdbeDb(v)->mallocFailed || pOp->p2>addr ); @@ -1454,7 +1454,8 @@ Bitmask sqlite3WhereCodeOneLoopStart( iCur = pTabItem->iCursor; pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); bRev = (pWInfo->revMask>>iLevel)&1; - VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName)); + VdbeModuleComment((v, "Begin WHERE-loop%d: %s", + iLevel, pTabItem->pSTab->zName)); #if WHERETRACE_ENABLED /* 0x4001 */ if( sqlite3WhereTrace & 0x1 ){ sqlite3DebugPrintf("Coding level %d of %d: notReady=%llx iFrom=%d\n", @@ -1509,11 +1510,11 @@ Bitmask sqlite3WhereCodeOneLoopStart( /* Special case of a FROM clause subquery implemented as a co-routine */ if( pTabItem->fg.viaCoroutine ){ - int regYield = pTabItem->regReturn; - sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub); + int regYield = pTabItem->sq.regReturn; + sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield,0,pTabItem->sq.addrFillSub); pLevel->p2 = sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk); VdbeCoverage(v); - VdbeComment((v, "next row of %s", pTabItem->pTab->zName)); + VdbeComment((v, "next row of %s", pTabItem->pSTab->zName)); pLevel->op = OP_Goto; }else @@ -2242,7 +2243,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( int untestedTerms = 0; /* Some terms not completely tested */ int ii; /* Loop counter */ Expr *pAndExpr = 0; /* An ".. AND (...)" expression */ - Table *pTab = pTabItem->pTab; + Table *pTab = pTabItem->pSTab; pTerm = pLoop->aLTerm[0]; assert( pTerm!=0 ); @@ -2701,7 +2702,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( ** least once. This is accomplished by storing the PK for the row in ** both the iMatch index and the regBloom Bloom filter. */ - pTab = pWInfo->pTabList->a[pLevel->iFrom].pTab; + pTab = pWInfo->pTabList->a[pLevel->iFrom].pSTab; if( HasRowid(pTab) ){ r = sqlite3GetTempRange(pParse, 2); sqlite3ExprCodeGetColumnOfTable(v, pTab, pLevel->iTabCur, -1, r+1); @@ -2808,7 +2809,7 @@ SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( Bitmask mAll = 0; int k; - ExplainQueryPlan((pParse, 1, "RIGHT-JOIN %s", pTabItem->pTab->zName)); + ExplainQueryPlan((pParse, 1, "RIGHT-JOIN %s", pTabItem->pSTab->zName)); sqlite3VdbeNoJumpsOutsideSubrtn(v, pRJ->addrSubrtn, pRJ->endSubrtn, pRJ->regReturn); for(k=0; ka[k].pWLoop->maskSelf; if( pRight->fg.viaCoroutine ){ sqlite3VdbeAddOp3( - v, OP_Null, 0, pRight->regResult, - pRight->regResult + pRight->pSelect->pEList->nExpr-1 + v, OP_Null, 0, pRight->sq.regResult, + pRight->sq.regResult + pRight->sq.pSelect->pEList->nExpr-1 ); } sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); @@ -2858,7 +2859,7 @@ SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( int nPk; int jmp; int addrCont = sqlite3WhereContinueLabel(pSubWInfo); - Table *pTab = pTabItem->pTab; + Table *pTab = pTabItem->pSTab; if( HasRowid(pTab) ){ sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, -1, r); nPk = 1; diff --git a/src/whereexpr.c b/src/whereexpr.c index dcda75d264..766754828d 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -958,7 +958,7 @@ static Bitmask exprSelectUsage(WhereMaskSet *pMaskSet, Select *pS){ if( ALWAYS(pSrc!=0) ){ int i; for(i=0; inSrc; i++){ - mask |= exprSelectUsage(pMaskSet, pSrc->a[i].pSelect); + mask |= exprSelectUsage(pMaskSet, pSrc->a[i].sq.pSelect); if( pSrc->a[i].fg.isUsing==0 ){ mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].u3.pOn); } @@ -996,7 +996,7 @@ static SQLITE_NOINLINE int exprMightBeIndexed2( int iCur; do{ iCur = pFrom->a[j].iCursor; - for(pIdx=pFrom->a[j].pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + for(pIdx=pFrom->a[j].pSTab->pIndex; pIdx; pIdx=pIdx->pNext){ if( pIdx->aColExpr==0 ) continue; for(i=0; inKeyCol; i++){ if( pIdx->aiColumn[i]!=XN_EXPR ) continue; @@ -1040,7 +1040,7 @@ static int exprMightBeIndexed( for(i=0; inSrc; i++){ Index *pIdx; - for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + for(pIdx=pFrom->a[i].pSTab->pIndex; pIdx; pIdx=pIdx->pNext){ if( pIdx->aColExpr ){ return exprMightBeIndexed2(pFrom,aiCurCol,pExpr,i); } @@ -1628,7 +1628,7 @@ void SQLITE_NOINLINE sqlite3WhereAddLimit(WhereClause *pWC, Select *p){ assert( p!=0 && p->pLimit!=0 ); /* 1 -- checked by caller */ if( p->pGroupBy==0 && (p->selFlags & (SF_Distinct|SF_Aggregate))==0 /* 2 */ - && (p->pSrc->nSrc==1 && IsVirtual(p->pSrc->a[0].pTab)) /* 3 */ + && (p->pSrc->nSrc==1 && IsVirtual(p->pSrc->a[0].pSTab)) /* 3 */ ){ ExprList *pOrderBy = p->pOrderBy; int iCsr = p->pSrc->a[0].iCursor; @@ -1849,7 +1849,7 @@ void sqlite3WhereTabFuncArgs( Expr *pColRef; Expr *pTerm; if( pItem->fg.isTabFunc==0 ) return; - pTab = pItem->pTab; + pTab = pItem->pSTab; assert( pTab!=0 ); pArgs = pItem->u1.pFuncArg; if( pArgs==0 ) return; diff --git a/src/window.c b/src/window.c index e5a78e37d2..9829d1740b 100644 --- a/src/window.c +++ b/src/window.c @@ -1079,7 +1079,7 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){ ** sqlite3SrcListAppend() */ if( p->pSrc ){ Table *pTab2; - p->pSrc->a[0].pSelect = pSub; + p->pSrc->a[0].sq.pSelect = pSub; p->pSrc->a[0].fg.isCorrelated = 1; sqlite3SrcListAssignCursors(pParse, p->pSrc); pSub->selFlags |= SF_Expanded|SF_OrderByReqd; @@ -1093,7 +1093,7 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){ }else{ memcpy(pTab, pTab2, sizeof(Table)); pTab->tabFlags |= TF_Ephemeral; - p->pSrc->a[0].pTab = pTab; + p->pSrc->a[0].pSTab = pTab; pTab = pTab2; memset(&w, 0, sizeof(w)); w.xExprCallback = sqlite3WindowExtraAggFuncDepth; @@ -1389,7 +1389,7 @@ int sqlite3WindowCompare( ** and initialize registers and cursors used by sqlite3WindowCodeStep(). */ void sqlite3WindowCodeInit(Parse *pParse, Select *pSelect){ - int nEphExpr = pSelect->pSrc->a[0].pSelect->pEList->nExpr; + int nEphExpr = pSelect->pSrc->a[0].sq.pSelect->pEList->nExpr; Window *pMWin = pSelect->pWin; Window *pWin; Vdbe *v = sqlite3GetVdbe(pParse); @@ -2789,7 +2789,7 @@ void sqlite3WindowCodeStep( Vdbe *v = sqlite3GetVdbe(pParse); int csrWrite; /* Cursor used to write to eph. table */ int csrInput = p->pSrc->a[0].iCursor; /* Cursor of sub-select */ - int nInput = p->pSrc->a[0].pTab->nCol; /* Number of cols returned by sub */ + int nInput = p->pSrc->a[0].pSTab->nCol; /* Number of cols returned by sub */ int iInput; /* To iterate through sub cols */ int addrNe; /* Address of OP_Ne */ int addrGosubFlush = 0; /* Address of OP_Gosub to flush: */ From 901b6714555f90ac38421cc5b97e532367e9bccb Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 18 Aug 2024 09:53:37 +0000 Subject: [PATCH 0682/1030] Automatically disable directory fsync when compiling for AIX. FossilOrigin-Name: 8d170e07e20c21a5bb97fdc8c2d01d92178f5fe740e60d203e4621747cfce33e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index bd4f4cbe1c..15c9bb1203 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sMakefile.in\sso\sthat\sit\soutputs\sa\sslightly\sbetter\serror\smessage\son\san\nattempt\sto\sbuild\ssomething\sthat\srequires\sTCL\slibraries\swhen\sHAVE_TCL\sis\sfalse. -D 2024-08-17T16:17:16.045 +C Automatically\sdisable\sdirectory\sfsync\swhen\scompiling\sfor\sAIX. +D 2024-08-18T09:53:37.962 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -744,7 +744,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c 2ea8d3ed496b8d1f9332a9505653424e5464fd797ea9d91f8e2e62f9dd0298d0 +F src/os_unix.c 6e3e4fc75904ff85184091dbab996e6e35c1799e771788961cc3b4fcbe8f852c F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 793ff83d09bea165c8cedc978afd3fcfb1a4cee894c5914aa1d92416afce963d -R be5ece8b231f01bec02cbe9ef4eda884 +P a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 +R cd57173ec450b44036cf8242b7c2fe1f U drh -Z 6d429e685f531219ca0d0afba9760eb7 +Z a06494827a8461d8ba3867ea1f761ae1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a5034c9d32..1dca61d1bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 +8d170e07e20c21a5bb97fdc8c2d01d92178f5fe740e60d203e4621747cfce33e diff --git a/src/os_unix.c b/src/os_unix.c index c94c0c111f..5d1dc9ac6b 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -322,7 +322,7 @@ static pid_t randomnessPid = 0; #define UNIXFILE_EXCL 0x01 /* Connections from one process only */ #define UNIXFILE_RDONLY 0x02 /* Connection is read only */ #define UNIXFILE_PERSIST_WAL 0x04 /* Persistent WAL mode */ -#ifndef SQLITE_DISABLE_DIRSYNC +#if !defined(SQLITE_DISABLE_DIRSYNC) && !defined(_AIX) # define UNIXFILE_DIRSYNC 0x08 /* Directory sync needed */ #else # define UNIXFILE_DIRSYNC 0x00 From dd9a7e45409f9f94a59165ddfd9379c5e1a14350 Mon Sep 17 00:00:00 2001 From: dan Date: Sun, 18 Aug 2024 14:46:13 +0000 Subject: [PATCH 0683/1030] Fix a problem with detail=none, content='' tables. FossilOrigin-Name: 4b8070816ada3f269d53c9cee20669f59e19a23c31c8509fc397c21dd097ec9f --- ext/fts5/fts5_main.c | 7 +++++++ ext/fts5/test/fts5misc.test | 13 +++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 06833a98b2..e271402ecf 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2217,10 +2217,17 @@ static int fts5CsrPoslist( if( iPhrase<0 || iPhrase>=sqlite3Fts5ExprPhraseCount(pCsr->pExpr) ){ rc = SQLITE_RANGE; + }else if( pConfig->eDetail!=FTS5_DETAIL_FULL + && pConfig->eContent==FTS5_CONTENT_NONE + ){ + *pa = 0; + *pn = 0; + return SQLITE_OK; }else if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){ if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ Fts5PoslistPopulator *aPopulator; int i; + aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr, bLive); if( aPopulator==0 ) rc = SQLITE_NOMEM; if( rc==SQLITE_OK ){ diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index 0da071192d..534c42fff6 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -652,5 +652,18 @@ do_execsql_test 24.4 { SELECT rank FROM ( SELECT rank FROM t1('a NOT "" NOT def') ); } {-1e-06} +#------------------------------------------------------------------------- +reset_db +fts5_aux_test_functions db + +do_execsql_test 25.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail='none', content=''); + INSERT INTO t1(a) VALUES('a b c'); +} + +do_execsql_test 25.0 { + SELECT fts5_test_poslist(t1) FROM t1('b') ORDER BY rank; +} {{}} + finish_test diff --git a/manifest b/manifest index a12f78027e..9d907ad392 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbroken\sassert()\sin\sfts5_storage.c. -D 2024-08-17T19:40:15.498 +C Fix\sa\sproblem\swith\sdetail=none,\scontent=''\stables. +D 2024-08-18T14:46:13.208 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81c F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 23029229021240dc21a69eb749305316103d183375413e2090c064b74b03b7f8 +F ext/fts5/fts5_main.c 5ea7ab0c9967594e73b7dd0ad737595922a14f175aa4b486dc2992a3e3138b68 F ext/fts5/fts5_storage.c 9a9b880be12901f1962ae2a5a7e1b74348b3099a1e728764e419f75d98e3e612 F ext/fts5/fts5_tcl.c 1dcf08028141c40a32634bdcf2d5601622ce4edc48f82ac4ce0cbe0a92a6961d F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -191,7 +191,7 @@ F ext/fts5/test/fts5locale.test 79cbd3000ae269de50826f6061c81f7c9fdb21dd9954c0b7 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test c0521e173b16d40b5a37e7e436459028403be1e6d3a5f4dfb2ef515d4486124b +F ext/fts5/test/fts5misc.test 60bb2be4a2d83d7a45047c1812781e2e337a27efa539d86356ef7f4acaf08eab F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -2209,8 +2209,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a8ff9ba5e71d817489093d8dff0a8d77365b4222773b941accbd58558d24379 -R 9367527e69e79bca7a5a92aed8bd4950 +P 01116e32797e1b127ba79059d890fbe5075eee2b6e3ce4468e82862b0fc3aa46 +R 502de970004bd002cb48fa6eef375d2c U dan -Z 275daf935ae7d8dde2bbfa29a46fdb3e +Z 7efc0e935f060687a4e12ab8572c886e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0408009dda..43ca2661de 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -01116e32797e1b127ba79059d890fbe5075eee2b6e3ce4468e82862b0fc3aa46 +4b8070816ada3f269d53c9cee20669f59e19a23c31c8509fc397c21dd097ec9f From aa2258e35b3df3dcd49220f2fed53725b150ac2b Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Aug 2024 12:54:12 +0000 Subject: [PATCH 0684/1030] Attempt to fix date/time calculations for days earlier than 0400-03-01. See [forum:/forumpost/eaa0a09786c6368b|forum thread eaa0a09786c6368b]. FossilOrigin-Name: 00cae11fffaf50e2133915e851d41098d00b6b1458e1438bcb6664e1411d8498 --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/date.c | 10 +++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 15c9bb1203..7e115d9526 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Automatically\sdisable\sdirectory\sfsync\swhen\scompiling\sfor\sAIX. -D 2024-08-18T09:53:37.962 +C Attempt\sto\sfix\sdate/time\scalculations\sfor\sdays\searlier\sthan\s0400-03-01.\nSee\s[forum:/forumpost/eaa0a09786c6368b|forum\sthread\seaa0a09786c6368b]. +D 2024-08-19T12:54:12.528 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -706,7 +706,7 @@ F src/build.c 237ccc0290d131d646be722f418e92ee0a38043aee25e7dfdc75f8ce5b3abe4e F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 -F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e +F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -2205,8 +2205,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a4043cbeb8a08fca2fdd2ea703e030d3a5574cc6002292ecc6f0e88c116472a3 -R cd57173ec450b44036cf8242b7c2fe1f +P 8d170e07e20c21a5bb97fdc8c2d01d92178f5fe740e60d203e4621747cfce33e +R 63b5eb42616efb9e489a03771c227de0 +T *branch * ancient-date-fix +T *sym-ancient-date-fix * +T -sym-trunk * U drh -Z a06494827a8461d8ba3867ea1f761ae1 +Z baa6c6f17edc1a9ecec4f4cec4c126b5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1dca61d1bd..358b550bd1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8d170e07e20c21a5bb97fdc8c2d01d92178f5fe740e60d203e4621747cfce33e +00cae11fffaf50e2133915e851d41098d00b6b1458e1438bcb6664e1411d8498 diff --git a/src/date.c b/src/date.c index 8a609ae3cc..8c48a81fa5 100644 --- a/src/date.c +++ b/src/date.c @@ -271,8 +271,8 @@ static void computeJD(DateTime *p){ Y--; M += 12; } - A = Y/100; - B = 2 - A + (A/4); + A = (Y+4800)/100; + B = 38 - A + (A/4); X1 = 36525*(Y+4716)/100; X2 = 306001*(M+1)/10000; p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000); @@ -456,7 +456,7 @@ static int validJulianDay(sqlite3_int64 iJD){ ** Compute the Year, Month, and Day from the julian day number. */ static void computeYMD(DateTime *p){ - int Z, A, B, C, D, E, X1; + int Z, alpha, A, B, C, D, E, X1; if( p->validYMD ) return; if( !p->validJD ){ p->Y = 2000; @@ -467,8 +467,8 @@ static void computeYMD(DateTime *p){ return; }else{ Z = (int)((p->iJD + 43200000)/86400000); - A = (int)((Z - 1867216.25)/36524.25); - A = Z + 1 + A - (A/4); + alpha = (int)((Z + 32044.75)/36524.25) - 52; + A = Z + 1 + alpha - ((alpha+100)/4) + 25; B = A + 1524; C = (int)((B - 122.1)/365.25); D = (36525*(C&32767))/100; From 5a18c1f9cd79150dbf263295467fde646d74f2b9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Aug 2024 13:53:49 +0000 Subject: [PATCH 0685/1030] New date/time test cases to validate ancient dates. FossilOrigin-Name: 82719074f090d9d0a0b9baea0dee7b1dd40a272e3f3e45043d4a640c07989d5d --- manifest | 14 ++++---- manifest.uuid | 2 +- test/date5.test | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 test/date5.test diff --git a/manifest b/manifest index 7e115d9526..912b177c84 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Attempt\sto\sfix\sdate/time\scalculations\sfor\sdays\searlier\sthan\s0400-03-01.\nSee\s[forum:/forumpost/eaa0a09786c6368b|forum\sthread\seaa0a09786c6368b]. -D 2024-08-19T12:54:12.528 +C New\sdate/time\stest\scases\sto\svalidate\sancient\sdates. +D 2024-08-19T13:53:49.904 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1060,6 +1060,7 @@ F test/date.test c8ff835023f2107b57ce7a45c92265d51c98a23fc93231e998f12d850831aad F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1 F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5 F test/date4.test 75dc8401e8c0639a228cd26a6eaa4ff5ea8ccda912b9853d1c9462c476670e17 +F test/date5.test 14ba189bc4d03efc371dd5302e035764f6633355a3e13acb4a45e7b33530231e F test/dbdata.test 042f49acff3438f940eeba5868d3af080ae64ddf26ae78f80c92bec3ca7d8603 F test/dbfuzz.c 73047c920d6210e5912c87cdffd9a1c281d4252e F test/dbfuzz001.test 6c9a4622029d69dc38926f115864b055cb2f39badd25ec22cbfb130c8ba8e9c3 @@ -2205,11 +2206,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8d170e07e20c21a5bb97fdc8c2d01d92178f5fe740e60d203e4621747cfce33e -R 63b5eb42616efb9e489a03771c227de0 -T *branch * ancient-date-fix -T *sym-ancient-date-fix * -T -sym-trunk * +P 00cae11fffaf50e2133915e851d41098d00b6b1458e1438bcb6664e1411d8498 +R 020e143aeb047149147ee2aa5a7ba85f U drh -Z baa6c6f17edc1a9ecec4f4cec4c126b5 +Z d05bb26a1492de783006f86a1565084e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 358b550bd1..40201f610b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00cae11fffaf50e2133915e851d41098d00b6b1458e1438bcb6664e1411d8498 +82719074f090d9d0a0b9baea0dee7b1dd40a272e3f3e45043d4a640c07989d5d diff --git a/test/date5.test b/test/date5.test new file mode 100644 index 0000000000..688f84d0f1 --- /dev/null +++ b/test/date5.test @@ -0,0 +1,86 @@ +# 2024-08-19 +# +# 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. +# +#*********************************************************************** +# +# https://sqlite.org/forum/forumpost/eaa0a09786c6368b +# +# Apparently SQLite has been miscomputing leap-year dates before +# the year 0400. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Skip this whole file if date and time functions are omitted +# at compile-time +# +ifcapable {!datetime} { + finish_test + return +} + +# Data sources: +# 1-10 https://ssd.jpl.nasa.gov/tools/jdc/#/cd +# 11 Jean Meeus, Astronomical Algorithms, ISBN 0-943396-61-1, p.59 +# 12 https://en.wikipedia.org/wiki/Julian_day +# +# ID YEAR MONTH DAY JD +set date5data { + 1 2024 2 29 2460369.5 + 2 2024 3 1 2460370.5 + 3 2023 2 28 2460003.5 + 4 2023 3 1 2460004.5 + 5 2000 2 29 2451603.5 + 6 2000 3 1 2451604.5 + 7 1900 2 28 2415078.5 + 8 1900 3 1 2415079.5 + 9 1712 2 29 2346413.5 + 10 1712 3 1 2346414.5 + 11 1977 4 26 2443259.5 + 12 2013 1 1 2456293.5 +} + +foreach {id y m d jd} $date5data { + set date [format %04d-%02d-%02d $y $m $d] + do_execsql_test date5-jd$jd { + SELECT date($::jd); + } $date + do_execsql_test date5-cal/$date { + SELECT julianday($::date); + } $jd + for {set i 1} {$y+400*$i<=9999} {incr i} { + set y2 [expr {$y+400*$i}] + set date2 [format %04d-%02d-%02d $y2 $m $d] + set jd2 [expr {$jd+146097*$i}] + do_execsql_test date5-jd$jd2 { + SELECT date($::jd2); + } $date2 + do_execsql_test date5-cal/$date2 { + SELECT julianday($::date2); + } $jd2 + } + for {set i 1} {$y-400*$i>=-4712} {incr i} { + set y2 [expr {$y-400*$i}] + if {$y2<0} { + set date2 [format -%04d-%02d-%02d [expr {-$y2}] $m $d] + } else { + set date2 [format %04d-%02d-%02d $y2 $m $d] + } + set jd2 [expr {$jd-146097*$i}] + do_execsql_test date5-jd$jd2 { + SELECT date($::jd2); + } $date2 + do_execsql_test date5-cal/$date2 { + SELECT julianday($::date2); + } $jd2 + } +} + +finish_test From 127812e64534ea80b0e2281f234370d9b02fa0b2 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 19 Aug 2024 20:35:30 +0000 Subject: [PATCH 0686/1030] Update some comments that are processed into the fts5.html webpage. FossilOrigin-Name: 3e06ab218bbd1ed75a24afb44e8df9ce84e9fc24701428cb8b3459760f44006d --- ext/fts5/extract_api_docs.tcl | 5 ++++- ext/fts5/fts5.h | 24 +++++++++++++++++++++++- manifest | 15 +++++++-------- manifest.uuid | 2 +- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/ext/fts5/extract_api_docs.tcl b/ext/fts5/extract_api_docs.tcl index 6762a036d5..634dc70cbd 100644 --- a/ext/fts5/extract_api_docs.tcl +++ b/ext/fts5/extract_api_docs.tcl @@ -108,8 +108,11 @@ proc get_tokenizer_docs {data} { append res "
    $line

    \n" continue } + if {[regexp {FTS5_TOKENIZER} $line]} { + set line

    + } if {[regexp {SYNONYM SUPPORT} $line]} { - set line "

    Synonym Support

    " + set line "

    Synonym Support

    " } if {[string trim $line] == ""} { append res "

    \n" diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index dfa075f0a9..682a8da386 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -429,7 +429,7 @@ struct Fts5ExtensionApi { ** argument passed to this function is a pointer to an Fts5Tokenizer object ** returned by an earlier call to xCreate(). ** -** The second argument indicates the reason that FTS5 is requesting +** The third argument indicates the reason that FTS5 is requesting ** tokenization of the supplied text. This is always one of the following ** four values: ** @@ -453,6 +453,13 @@ struct Fts5ExtensionApi { ** on a columnsize=0 database. ** ** +** The sixth and seventh arguments passed to xTokenize() - pLocale and +** nLocale - are a pointer to a buffer containing the locale to use for +** tokenization (e.g. "en_US") and its size in bytes, respectively. The +** pLocale buffer is not nul-terminated. pLocale may be passed NULL (in +** which case nLocale is always 0) to indicate that the tokenizer should +** use its default locale. +** ** For each token in the input string, the supplied callback xToken() must ** be invoked. The first argument to it should be a copy of the pointer ** passed as the second argument to xTokenize(). The third and fourth @@ -484,6 +491,21 @@ struct Fts5ExtensionApi { ** an nLocale byte buffer containing the name of the locale to use as utf-8 ** text. pLocale is not nul-terminated. ** +** FTS5_TOKENIZER +** +** There is also an fts5_tokenizer object. This is an older version of +** fts5_tokenizer_v2. It is similar except that: +** +**

      +**
    • There is no "iVersion" field, and +**
    • The xTokenize() method does not take a locale argument. +**
    +** +** fts5_tokenizer tokenizers should be registered with the xCreateTokenizer() +** function, instead of xCreateTokenizer_v2(). Tokenizers implementations +** registered using either API may be retrieved using both xFindTokenizer() +** and xFindTokenizer_v2(). +** ** SYNONYM SUPPORT ** ** Custom tokenizers may also support synonyms. Consider a case in which a diff --git a/manifest b/manifest index 72992c9562..f8108ac374 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sfts5_locale()\sfunction\sand\srelated\sfunctionality\sto\sfts5. -D 2024-08-19T14:33:39.681 +C Update\ssome\scomments\sthat\sare\sprocessed\sinto\sthe\sfts5.html\swebpage. +D 2024-08-19T20:35:30.209 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -91,8 +91,8 @@ F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 63db9624ccf70d4887836c320eda93ab552f21008f3be7ede551eac3ead62baa F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb -F ext/fts5/extract_api_docs.tcl bc3a0ca78be7d3df08e7602c00ca48021ebae40682d75eb001bfdf6e54ffb44e -F ext/fts5/fts5.h 4c6998c6186268b4dbe9baef2c0d2ab974bd90996d61d4dbe801367249be6de4 +F ext/fts5/extract_api_docs.tcl 1db7f85f4d84b7b6f33336155d5053fafc3c8debd074422d8003c8f7fa4d0fdb +F ext/fts5/fts5.h c65fc7799a4cd6774628da4fa9408955623e504d7369ab5b89c4413fdfe11eb5 F ext/fts5/fts5Int.h 26a71a09cefa4ef6b4516b204ed48da3e1380970a19b3482eea7c5d805655360 F ext/fts5/fts5_aux.c 12cd2512f869217c38b70c31de5b5f741812734fafa80f55b32ea9bbd96e2152 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 @@ -2210,9 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 474b7e34b83bc5e85854bc3b386f31ff39b390549d89b94921f33bbc5b658d1d 6787603bd0d8117e41e6b572c0d7cada0f6d7266a4ff2ad79f9471b9beb28a9e -R 2c3030846c904496873c37b37c82be1d -T +closed 6787603bd0d8117e41e6b572c0d7cada0f6d7266a4ff2ad79f9471b9beb28a9e +P b9632900100bdbc913f83bfb03b32585cf07a192b9a7f26b9bebc7d91e63a610 +R ea532ddb7482adbca514ac43836cd1cf U dan -Z fdb5bbd69f79c041555a00a73e5efcdd +Z 0d4360caeae428f14a1f60694bd440b2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 43438a3211..39ef92242c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9632900100bdbc913f83bfb03b32585cf07a192b9a7f26b9bebc7d91e63a610 +3e06ab218bbd1ed75a24afb44e8df9ce84e9fc24701428cb8b3459760f44006d From 1521ca4c20c7ade39c671291b2214096c74cacd0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Aug 2024 22:48:30 +0000 Subject: [PATCH 0687/1030] Refactor the SrcItem object so that information about subqueries is stored in a separately allocated Subquery object. This reduces the memory requirements for SrcItem and makes the code run faster. It also provides an expansion path for subquery processing that does not burden simple queries. The current checking mostly works, but there are still issues that need to be tracked down and fixed. FossilOrigin-Name: 8ff5dda8448d7e1a533d7f27db2573ce68fa9956b9d9847ced45e83c1f06bab0 --- manifest | 42 ++++++------ manifest.uuid | 2 +- src/alter.c | 13 ++-- src/attach.c | 2 +- src/build.c | 96 ++++++++++++++++++++++---- src/expr.c | 26 ++++--- src/insert.c | 75 ++++++++++++-------- src/parse.y | 21 ++++-- src/printf.c | 13 ++-- src/resolve.c | 29 +++++--- src/select.c | 179 +++++++++++++++++++++++++++++------------------- src/sqliteInt.h | 40 ++++++++--- src/treeview.c | 8 +-- src/walker.c | 4 +- src/where.c | 35 ++++++---- src/wherecode.c | 20 ++++-- src/whereexpr.c | 4 +- src/window.c | 18 +++-- 18 files changed, 421 insertions(+), 206 deletions(-) diff --git a/manifest b/manifest index ef77b8894d..30b1edeab1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Give\sunique\snames\sto\sfields\sin\sthe\sSrcItem\sobject,\sto\sfacilitate\sanalysis\sof\nhow\sthose\sfields\sare\sused\susing\s"grep". -D 2024-08-17T23:23:23.271 +C Refactor\sthe\sSrcItem\sobject\sso\sthat\sinformation\sabout\ssubqueries\sis\sstored\nin\sa\sseparately\sallocated\sSubquery\sobject.\s\sThis\sreduces\sthe\smemory\srequirements\nfor\sSrcItem\sand\smakes\sthe\scode\srun\sfaster.\s\sIt\salso\sprovides\san\sexpansion\spath\nfor\ssubquery\sprocessing\sthat\sdoes\snot\sburden\ssimple\squeries.\s\sThe\scurrent\nchecking\smostly\sworks,\sbut\sthere\sare\sstill\sissues\sthat\sneed\sto\sbe\stracked\ndown\sand\sfixed. +D 2024-08-19T22:48:30.539 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -692,9 +692,9 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2 -F src/alter.c b73964bd6bc3122e884993c0666bae96d4e1e50a94b6f9008df32e6a18e99cd0 +F src/alter.c aa93e37e4a36a0525bbb2a2aeda20d2018f0aa995542c7dc658e031375e3f532 F src/analyze.c 30bf40ec4208ead9e977bec017bccc8a9681820936e38ca5a4a7443100a6d5c5 -F src/attach.c d778bacb2ee5bc6a74c81a17376064e6a16ee447d82ee4ad1f7717a320d5a232 +F src/attach.c 08235ab62ed5ccc93c22bf36e640d19effcd632319615851bccf724ec9341333 F src/auth.c 4c1ea890e0069ad73bead5d17a5b12c34cfa4f1a24175c8147ea439b64be271c F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 @@ -702,7 +702,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 664804cbefaf43c13fcb369474609cf8befa4d89933804dc276d0a15fbd66c34 +F src/build.c d243a17292e027c1d662e992fbd395123aacc4b74a4a9419d0b010088ba318dd F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 @@ -710,7 +710,7 @@ F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c 8aaf9d05d6ff6349a7a6001cbf90c7a46b19b9f52ef2e47aa0415a529d5307a1 -F src/expr.c 835b637da89fe20a1ff90bd372904fd421ff92d1dfb9bbea9c81bbffbea46715 +F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 849049c74a4c68961154c124087b5c67d277217a2e642570d0c1bd6336859940 F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f @@ -719,7 +719,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 2152b159ac214519e778b6996a85b9073ace054f5c9d430b375852e343a5ec92 +F src/insert.c b07865339e67869ff12d2eee3a1417f4779c742e2a51ae3d14ad45e5168f6f41 F src/json.c 5b6a1d6015997b9ee848a32948720bdb26a0ef2de5a2127ebf7355ce66dbdc0d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -749,23 +749,23 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y bc8df5d36afd06d50c1828072e4f3120d892af685436db3b8e776288803535e0 +F src/parse.y 967e0a712de8bee4b2cf82bd9efa36b68afd03cc486d4ea77a945feb49b057dc F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce -F src/printf.c efa3973bdcacdbc8cf0ff3b3a58e16a105319eac8819823f5807579dc2fa4138 +F src/printf.c 17054fb94ffcf7a28362e9a5af4a0f813bd0c52200ae408eeebddc81feed9274 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c d25fc99cd54d2acf4c655f942dd48ee60e3ada94d73c8b992487515f1295a3bc +F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 10ff02352f4c6eb7bc8d5711f0f74199b94ae9adc346f10391931f5c55d1c68f +F src/select.c 3e284895745f57de3b37b17fce9eb0e26bc54fccc94ea1ff5342be4360e3674b F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 95186ebaf79560fa44b1a05bd7b4b14846e037a285177ca65082a9ae952a6c29 +F src/sqliteInt.h 630e356b7d94df1dcbc32d4f7d4569725a12c6de014fe064311219c22d9cbd54 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -824,7 +824,7 @@ F src/test_window.c 6d80e11fba89a1796525e6f0048ff0c7789aa2c6b0b11c80827dc1437bd8 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c a337ab329f94e627c9a5efee0326d3359e352c4f0c0bb5c8f4b686fe03e6e7e8 +F src/treeview.c e98dbc8068d27f3d0bd2a4cebfce6a7c21c776edc23d80e12c67a70cd2ba3fe5 F src/trigger.c 68d849ea6ccab67beb450d1a0d065c6118f0884a779388b07f0d9a27dbda38c9 F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 @@ -845,12 +845,12 @@ F src/vtab.c 5fb499d20494b7eecaadb7584634af9afcb374cb0524912b475fcb1712458a1b F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 -F src/walker.c e5898234c5920481d962e29b96ecf403b992b12ae243ad0e53659386a1b3e554 -F src/where.c d0140395a35fbc451e9d07c9816895d399f02ae76cbcd255e8ce1069548b02c8 +F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 +F src/where.c b6f79b189fcba459bb80420d3b4102f42a399be36ff29a3deff4ae4888fee46d F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e -F src/wherecode.c 3e130abafc185a29c8dbdcc33e6150dff2aa884f75483e159feef170961af65d -F src/whereexpr.c 784f641ba3d6f1fdb4f65e3891daa50067a4c51f1acd11b461397f7d4c622907 -F src/window.c ffbf65ba62ce329e2fd68b35f11e920121fac45dab0f9a4bbc486125ccc98b6c +F src/wherecode.c 137797b0de9ddf1ff43e5b0edffcc76fb05184ed651fc4f5a0a01a45c0b89d04 +F src/whereexpr.c 6a72cf607548765a262f216e87373fd675a4646f9cc4278fc519b66cf03dbc13 +F src/window.c 499d48f315a09242dc68f2fac635ed27dcf6bbb0d9ab9084857898c64489e975 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 F test/affinity3.test f094773025eddf31135c7ad4cde722b7696f8eb07b97511f98585addf2a510a9 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a4c59ac3c6ec979c25b544d29e47b8e39f6439c098eed8f84b3bd506c9adf047 -R 1d81e98efd997ac91c2ceea4c803b7e6 +P 9f5aeef3cbc2c95267c8f7bf60d5c66971a76789669fb0e8f853273ff6f616f2 +R 0dac77664f5c62d0dcc882ea3148d6f4 U drh -Z 8ec986f4842c563a443c2f1a23450bf4 +Z a11cd0d49c593b1144d9510fd31aa2a7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0e51ef0919..ca5d536722 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f5aeef3cbc2c95267c8f7bf60d5c66971a76789669fb0e8f853273ff6f616f2 +8ff5dda8448d7e1a533d7f27db2573ce68fa9956b9d9847ced45e83c1f06bab0 diff --git a/src/alter.c b/src/alter.c index 41146f54e9..ff20757589 100644 --- a/src/alter.c +++ b/src/alter.c @@ -1366,8 +1366,9 @@ static int renameResolveTrigger(Parse *pParse){ int i; for(i=0; ipFrom->nSrc && rc==SQLITE_OK; i++){ SrcItem *p = &pStep->pFrom->a[i]; - if( p->sq.pSelect ){ - sqlite3SelectPrep(pParse, p->sq.pSelect, 0); + if( p->fg.isSubquery ){ + assert( p->u4.pSubq!=0 ); + sqlite3SelectPrep(pParse, p->u4.pSubq->pSelect, 0); } } } @@ -1435,8 +1436,12 @@ static void renameWalkTrigger(Walker *pWalker, Trigger *pTrigger){ } if( pStep->pFrom ){ int i; - for(i=0; ipFrom->nSrc; i++){ - sqlite3WalkSelect(pWalker, pStep->pFrom->a[i].sq.pSelect); + SrcList *pFrom = pStep->pFrom; + for(i=0; inSrc; i++){ + if( pFrom->a[i].fg.isSubquery ){ + assert( pFrom->a[i].u4.pSubq!=0 ); + sqlite3WalkSelect(pWalker, pFrom->a[i].u4.pSubq->pSelect); + } } } } diff --git a/src/attach.c b/src/attach.c index 65b492474e..76476685fb 100644 --- a/src/attach.c +++ b/src/attach.c @@ -479,7 +479,7 @@ static int fixSelectCb(Walker *p, Select *pSelect){ if( NEVER(pList==0) ) return WRC_Continue; for(i=0, pItem=pList->a; inSrc; i++, pItem++){ - if( pFix->bTemp==0 ){ + if( pFix->bTemp==0 && pItem->fg.isSubquery==0 ){ if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ if( iDb!=sqlite3FindDbName(db, pItem->u4.zDatabase) ){ sqlite3ErrorMsg(pFix->pParse, diff --git a/src/build.c b/src/build.c index ff798087af..b585c19719 100644 --- a/src/build.c +++ b/src/build.c @@ -4914,13 +4914,40 @@ void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){ for(i=0, pItem=pList->a; inSrc; i++, pItem++){ if( pItem->iCursor>=0 ) continue; pItem->iCursor = pParse->nTab++; - if( pItem->sq.pSelect ){ - sqlite3SrcListAssignCursors(pParse, pItem->sq.pSelect->pSrc); + if( pItem->fg.isSubquery ){ + assert( pItem->u4.pSubq!=0 ); + assert( pItem->u4.pSubq->pSelect!=0 ); + assert( pItem->u4.pSubq->pSelect->pSrc!=0 ); + sqlite3SrcListAssignCursors(pParse, pItem->u4.pSubq->pSelect->pSrc); } } } } +/* +** Delete a Subquery object and its substructure. +*/ +void sqlite3SubqueryDelete(sqlite3 *db, Subquery *pSubq){ + assert( pSubq!=0 && pSubq->pSelect!=0 ); + sqlite3SelectDelete(db, pSubq->pSelect); + sqlite3DbFree(db, pSubq); +} + +/* +** Remove a Subquery from a SrcItem. Return the associated Select object. +** The returned Select becomes the responsibility of the caller. +*/ +Select *sqlite3SubqueryDetach(sqlite3 *db, SrcItem *pItem){ + Select *pSel; + assert( pItem!=0 ); + assert( pItem->fg.isSubquery ); + pSel = pItem->u4.pSubq->pSelect; + sqlite3DbFree(db, pItem->u4.pSubq); + pItem->u4.pSubq = 0; + pItem->fg.isSubquery = 0; + return pSel; +} + /* ** Delete an entire SrcList including all its substructure. */ @@ -4932,22 +4959,19 @@ void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ for(pItem=pList->a, i=0; inSrc; i++, pItem++){ /* Check invariants on SrcItem */ - assert( pItem->sq.pSelect==0 - || (pItem->sq.pSelect->selFlags & SF_MultiValue)==0 - || (pItem->fg.hadSchema==0 - && (pItem->fg.fixedSchema || pItem->u4.zDatabase==0)) ); + assert( !pItem->fg.hadSchema || !pItem->fg.isSubquery ); assert( pItem->fg.hadSchema==0 || pItem->fg.fixedSchema==1 ); - if( pItem->zName ) sqlite3DbNNFreeNN(db, pItem->zName); if( pItem->zAlias ) sqlite3DbNNFreeNN(db, pItem->zAlias); - if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ + if( pItem->fg.isSubquery ){ + sqlite3SubqueryDelete(db, pItem->u4.pSubq); + }else if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ sqlite3DbNNFreeNN(db, pItem->u4.zDatabase); } if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy); if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg); sqlite3DeleteTable(db, pItem->pSTab); - if( pItem->sq.pSelect ) sqlite3SelectDelete(db, pItem->sq.pSelect); if( pItem->fg.isUsing ){ sqlite3IdListDelete(db, pItem->u3.pUsing); }else if( pItem->u3.pOn ){ @@ -4957,6 +4981,52 @@ void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ sqlite3DbNNFreeNN(db, pList); } +/* +** Attach a Subquery object to pItem->uv.pSubq. Set the +** pSelect value but leave all the other values initialized +** to zero. +** +** A copy of the Select object is made if dupSelect is true, and the +** SrcItem takes responsibility for deleting the copy. If dupSelect is +** false, ownership of the Select passes to the SrcItem. Either way, +** the SrcItem will take responsibility for deleting the Select. +** +** When dupSelect is zero, that means the Select might get deleted right +** away if there is an OOM error. Beware. +** +** Return non-zero on success. Return zero on an OOM error. +*/ +int sqlite3SrcItemAttachSubquery( + Parse *pParse, /* Parsing context */ + SrcItem *pItem, /* Item to which the subquery is to be attached */ + Select *pSelect, /* The subquery SELECT. Must be non-NULL */ + int dupSelect /* If true, attach a copy of pSelect, not pSelect itself.*/ +){ + Subquery *p; + if( pSelect==0 ) return SQLITE_OK; + assert( pItem->fg.isSubquery==0 ); + if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ + sqlite3DbFree(pParse->db, pItem->u4.zDatabase); + pItem->u4.zDatabase = 0; + } + pItem->fg.fixedSchema = 0; + if( dupSelect ){ + pSelect = sqlite3SelectDup(pParse->db, pSelect, 0); + if( pSelect==0 ) return 0; + } + p = pItem->u4.pSubq = sqlite3DbMallocRawNN(pParse->db, sizeof(Subquery)); + if( p==0 ){ + sqlite3SelectDelete(pParse->db, pSelect); + return 0; + } + pItem->fg.isSubquery = 1; + p->pSelect = pSelect; + assert( offsetof(Subquery, pSelect)==0 ); + memset(((char*)p)+sizeof(p->pSelect), 0, sizeof(*p)-sizeof(p->pSelect)); + return 1; +} + + /* ** This routine is called by the parser to add a new term to the ** end of a growing FROM clause. The "p" parameter is the part of @@ -5006,10 +5076,12 @@ SrcList *sqlite3SrcListAppendFromTerm( if( pAlias->n ){ pItem->zAlias = sqlite3NameFromToken(db, pAlias); } + assert( pSubquery==0 || pDatabase==0 ); if( pSubquery ){ - pItem->sq.pSelect = pSubquery; - if( pSubquery->selFlags & SF_NestedFrom ){ - pItem->fg.isNestedFrom = 1; + if( sqlite3SrcItemAttachSubquery(pParse, pItem, pSubquery, 0) ){ + if( pSubquery->selFlags & SF_NestedFrom ){ + pItem->fg.isNestedFrom = 1; + } } } assert( pOnUsing==0 || pOnUsing->pOn==0 || pOnUsing->pUsing==0 ); diff --git a/src/expr.c b/src/expr.c index 6ad789a3d8..1b18828dd6 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1877,18 +1877,30 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int flags){ SrcItem *pNewItem = &pNew->a[i]; const SrcItem *pOldItem = &p->a[i]; Table *pTab; - if( pOldItem->fg.fixedSchema ){ + pNewItem->fg = pOldItem->fg; + if( pOldItem->fg.isSubquery ){ + Subquery *pNewSubq = sqlite3DbMallocRaw(db, sizeof(Subquery)); + if( pNewSubq==0 ){ + assert( db->mallocFailed ); + pNewItem->fg.isSubquery = 0; + }else{ + memcpy(pNewSubq, pOldItem->u4.pSubq, sizeof(*pNewSubq)); + pNewSubq->pSelect = sqlite3SelectDup(db, pNewSubq->pSelect, flags); + if( pNewSubq->pSelect==0 ){ + sqlite3DbFree(db, pNewSubq); + pNewSubq = 0; + pNewItem->fg.isSubquery = 0; + } + } + pNewItem->u4.pSubq = pNewSubq; + }else if( pOldItem->fg.fixedSchema ){ pNewItem->u4.pSchema = pOldItem->u4.pSchema; }else{ pNewItem->u4.zDatabase = sqlite3DbStrDup(db, pOldItem->u4.zDatabase); } pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName); pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias); - pNewItem->fg = pOldItem->fg; pNewItem->iCursor = pOldItem->iCursor; - pNewItem->sq.addrFillSub = pOldItem->sq.addrFillSub; - pNewItem->sq.regReturn = pOldItem->sq.regReturn; - pNewItem->sq.regResult = pOldItem->sq.regResult; if( pNewItem->fg.isIndexedBy ){ pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy); }else if( pNewItem->fg.isTabFunc ){ @@ -1905,7 +1917,6 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int flags){ if( pTab ){ pTab->nTabRef++; } - pNewItem->sq.pSelect = sqlite3SelectDup(db, pOldItem->sq.pSelect, flags); if( pOldItem->fg.isUsing ){ assert( pNewItem->fg.isUsing ); pNewItem->u3.pUsing = sqlite3IdListDup(db, pOldItem->u3.pUsing); @@ -1979,7 +1990,6 @@ Select *sqlite3SelectDup(sqlite3 *db, const Select *pDup, int flags){ pp = &pNew->pPrior; pNext = pNew; } - return pRet; } #else @@ -2999,7 +3009,7 @@ static Select *isCandidateForInOpt(const Expr *pX){ pSrc = p->pSrc; assert( pSrc!=0 ); if( pSrc->nSrc!=1 ) return 0; /* Single term in FROM clause */ - if( pSrc->a[0].sq.pSelect ) return 0; /* FROM is not a subquery or view */ + if( pSrc->a[0].fg.isSubquery) return 0;/* FROM is not a subquery or view */ pTab = pSrc->a[0].pSTab; assert( pTab!=0 ); assert( !IsView(pTab) ); /* FROM clause is not a view */ diff --git a/src/insert.c b/src/insert.c index 4447cdc22e..d65ead2a0b 100644 --- a/src/insert.c +++ b/src/insert.c @@ -585,8 +585,9 @@ void sqlite3AutoincrementEnd(Parse *pParse){ void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ if( ALWAYS(pVal) && pVal->pSrc->nSrc>0 ){ SrcItem *pItem = &pVal->pSrc->a[0]; - sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->sq.regReturn); - sqlite3VdbeJumpHere(pParse->pVdbe, pItem->sq.addrFillSub - 1); + assert( pItem->fg.isSubquery && pItem->u4.pSubq!=0 ); + sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->u4.pSubq->regReturn); + sqlite3VdbeJumpHere(pParse->pVdbe, pItem->u4.pSubq->addrFillSub - 1); } } @@ -714,6 +715,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ if( pRet ){ SelectDest dest; + Subquery *pSubq; pRet->pSrc->nSrc = 1; pRet->pPrior = pLeft->pPrior; pRet->op = pLeft->op; @@ -723,29 +725,31 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ assert( pLeft->pNext==0 ); assert( pRet->pNext==0 ); p = &pRet->pSrc->a[0]; - p->sq.pSelect = pLeft; p->fg.viaCoroutine = 1; - p->sq.addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; - p->sq.regReturn = ++pParse->nMem; p->iCursor = -1; p->u1.nRow = 2; - sqlite3VdbeAddOp3(v, OP_InitCoroutine, - p->sq.regReturn, 0, p->sq.addrFillSub); - sqlite3SelectDestInit(&dest, SRT_Coroutine, p->sq.regReturn); - - /* Allocate registers for the output of the co-routine. Do so so - ** that there are two unused registers immediately before those - ** used by the co-routine. This allows the code in sqlite3Insert() - ** to use these registers directly, instead of copying the output - ** of the co-routine to a separate array for processing. */ - dest.iSdst = pParse->nMem + 3; - dest.nSdst = pLeft->pEList->nExpr; - pParse->nMem += 2 + dest.nSdst; - - pLeft->selFlags |= SF_MultiValue; - sqlite3Select(pParse, pLeft, &dest); - p->sq.regResult = dest.iSdst; - assert( pParse->nErr || dest.iSdst>0 ); + if( sqlite3SrcItemAttachSubquery(pParse, p, pLeft, 0) ){ + pSubq = p->u4.pSubq; + pSubq->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1; + pSubq->regReturn = ++pParse->nMem; + sqlite3VdbeAddOp3(v, OP_InitCoroutine, + pSubq->regReturn, 0, pSubq->addrFillSub); + sqlite3SelectDestInit(&dest, SRT_Coroutine, pSubq->regReturn); + + /* Allocate registers for the output of the co-routine. Do so so + ** that there are two unused registers immediately before those + ** used by the co-routine. This allows the code in sqlite3Insert() + ** to use these registers directly, instead of copying the output + ** of the co-routine to a separate array for processing. */ + dest.iSdst = pParse->nMem + 3; + dest.nSdst = pLeft->pEList->nExpr; + pParse->nMem += 2 + dest.nSdst; + + pLeft->selFlags |= SF_MultiValue; + sqlite3Select(pParse, pLeft, &dest); + pSubq->regResult = dest.iSdst; + assert( pParse->nErr || dest.iSdst>0 ); + } pLeft = pRet; } }else{ @@ -755,12 +759,18 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ } if( pParse->nErr==0 ){ + Subquery *pSubq; assert( p!=0 ); - if( p->sq.pSelect->pEList->nExpr!=pRow->nExpr ){ - sqlite3SelectWrongNumTermsError(pParse, p->sq.pSelect); + assert( p->fg.isSubquery ); + pSubq = p->u4.pSubq; + assert( pSubq!=0 ); + assert( pSubq->pSelect!=0 ); + assert( pSubq->pSelect->pEList!=0 ); + if( pSubq->pSelect->pEList->nExpr!=pRow->nExpr ){ + sqlite3SelectWrongNumTermsError(pParse, pSubq->pSelect); }else{ - sqlite3ExprCodeExprList(pParse, pRow, p->sq.regResult, 0, 0); - sqlite3VdbeAddOp1(pParse->pVdbe, OP_Yield, p->sq.regReturn); + sqlite3ExprCodeExprList(pParse, pRow, pSubq->regResult, 0, 0); + sqlite3VdbeAddOp1(pParse->pVdbe, OP_Yield, pSubq->regReturn); } } sqlite3ExprListDelete(pParse->db, pRow); @@ -1111,9 +1121,14 @@ void sqlite3Insert( && pSelect->pPrior==0 ){ SrcItem *pItem = &pSelect->pSrc->a[0]; - dest.iSDParm = pItem->sq.regReturn; - regFromSelect = pItem->sq.regResult; - nColumn = pItem->sq.pSelect->pEList->nExpr; + Subquery *pSubq; + assert( pItem->fg.isSubquery ); + pSubq = pItem->u4.pSubq; + dest.iSDParm = pSubq->regReturn; + regFromSelect = pSubq->regResult; + assert( pSubq->pSelect!=0 ); + assert( pSubq->pSelect->pEList!=0 ); + nColumn = pSubq->pSelect->pEList->nExpr; ExplainQueryPlan((pParse, 0, "SCAN %S", pItem)); if( bIdListInOrder && nColumn==pTab->nCol ){ regData = regFromSelect; @@ -3033,7 +3048,7 @@ static int xferOptimization( if( pSelect->pSrc->nSrc!=1 ){ return 0; /* FROM clause must have exactly one term */ } - if( pSelect->pSrc->a[0].sq.pSelect ){ + if( pSelect->pSrc->a[0].fg.isSubquery ){ return 0; /* FROM clause cannot contain a subquery */ } if( pSelect->pWhere ){ diff --git a/src/parse.y b/src/parse.y index 9e656d0bc7..a47c587547 100644 --- a/src/parse.y +++ b/src/parse.y @@ -742,10 +742,20 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z) on_using(N SrcItem *pOld = F->a; assert( pOld->fg.fixedSchema==0 ); pNew->zName = pOld->zName; - pNew->u4.zDatabase = pOld->u4.zDatabase; - pNew->sq.pSelect = pOld->sq.pSelect; - if( pNew->sq.pSelect && (pNew->sq.pSelect->selFlags & SF_NestedFrom)!=0 ){ - pNew->fg.isNestedFrom = 1; + assert( pOld->fg.fixedSchema==0 ); + if( pOld->fg.isSubquery ){ + pNew->fg.isSubquery = 1; + pNew->u4.pSubq = pOld->u4.pSubq; + pOld->u4.pSubq = 0; + pOld->fg.isSubquery = 0; + if( pNew->u4.pSubq->pSelect + && (pNew->u4.pSubq->pSelect->selFlags & SF_NestedFrom)!=0 + ){ + pNew->fg.isNestedFrom = 1; + } + }else{ + pNew->u4.zDatabase = pOld->u4.zDatabase; + pOld->u4.zDatabase = 0; } if( pOld->fg.isTabFunc ){ pNew->u1.pFuncArg = pOld->u1.pFuncArg; @@ -753,8 +763,7 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z) on_using(N pOld->fg.isTabFunc = 0; pNew->fg.isTabFunc = 1; } - pOld->zName = pOld->u4.zDatabase = 0; - pOld->sq.pSelect = 0; + pOld->zName = 0; } sqlite3SrcListDelete(pParse->db, F); }else{ diff --git a/src/printf.c b/src/printf.c index 027905d26f..be7ffc8c76 100644 --- a/src/printf.c +++ b/src/printf.c @@ -848,16 +848,19 @@ void sqlite3_str_vappendf( if( pItem->zAlias && !flag_altform2 ){ sqlite3_str_appendall(pAccum, pItem->zAlias); }else if( pItem->zName ){ - if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ + if( pItem->fg.fixedSchema==0 + && pItem->fg.isSubquery==0 + && pItem->u4.zDatabase!=0 + ){ sqlite3_str_appendall(pAccum, pItem->u4.zDatabase); sqlite3_str_append(pAccum, ".", 1); } sqlite3_str_appendall(pAccum, pItem->zName); }else if( pItem->zAlias ){ sqlite3_str_appendall(pAccum, pItem->zAlias); - }else{ - Select *pSel = pItem->sq.pSelect; - assert( pSel!=0 ); /* Because of tag-20240424-1 */ + }else if( pItem->fg.isSubquery ){/* Because of tag-20240424-1 */ + Select *pSel = pItem->u4.pSubq->pSelect; + assert( pSel!=0 ); if( pSel->selFlags & SF_NestedFrom ){ sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId); }else if( pSel->selFlags & SF_MultiValue ){ @@ -867,6 +870,8 @@ void sqlite3_str_vappendf( }else{ sqlite3_str_appendf(pAccum, "(subquery-%u)", pSel->selId); } + }else{ + sqlite3_str_appendf(pAccum, "(unknown-data-source-%p)", pItem); } length = width = 0; break; diff --git a/src/resolve.c b/src/resolve.c index 02a48d6993..6dcb4e7322 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -349,7 +349,7 @@ static int lookupName( pTab = pItem->pSTab; assert( pTab!=0 && pTab->zName!=0 ); assert( pTab->nCol>0 || pParse->nErr ); - assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->sq.pSelect)); + assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem)); if( pItem->fg.isNestedFrom ){ /* In this case, pItem is a subquery that has been formed from a ** parenthesized subset of the FROM clause terms. Example: @@ -358,8 +358,12 @@ static int lookupName( ** This pItem -------------^ */ int hit = 0; - assert( pItem->sq.pSelect!=0 ); - pEList = pItem->sq.pSelect->pEList; + Select *pSel; + assert( pItem->fg.isSubquery ); + assert( pItem->u4.pSubq!=0 ); + pSel = pItem->u4.pSubq->pSelect; + assert( pSel!=0 ); + pEList = pSel->pEList; assert( pEList!=0 ); assert( pEList->nExpr==pTab->nCol ); for(j=0; jnExpr; j++){ @@ -1880,7 +1884,11 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ ** moves the pOrderBy down to the sub-query. It will be moved back ** after the names have been resolved. */ if( p->selFlags & SF_Converted ){ - Select *pSub = p->pSrc->a[0].sq.pSelect; + Select *pSub; + assert( p->pSrc->a[0].fg.isSubquery ); + assert( p->pSrc->a[0].u4.pSubq!=0 ); + pSub = p->pSrc->a[0].u4.pSubq->pSelect; + assert( pSub!=0 ); assert( p->pSrc->nSrc==1 && p->pOrderBy ); assert( pSub->pPrior && pSub->pOrderBy==0 ); pSub->pOrderBy = p->pOrderBy; @@ -1893,13 +1901,15 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ for(i=0; ipSrc->nSrc; i++){ SrcItem *pItem = &p->pSrc->a[i]; assert( pItem->zName!=0 - || pItem->sq.pSelect!=0 ); /* Test of tag-20240424-1*/ - if( pItem->sq.pSelect && (pItem->sq.pSelect->selFlags & SF_Resolved)==0 ){ + || pItem->fg.isSubquery ); /* Test of tag-20240424-1*/ + if( pItem->fg.isSubquery + && (pItem->u4.pSubq->pSelect->selFlags & SF_Resolved)==0 + ){ int nRef = pOuterNC ? pOuterNC->nRef : 0; const char *zSavedContext = pParse->zAuthContext; if( pItem->zName ) pParse->zAuthContext = pItem->zName; - sqlite3ResolveSelectNames(pParse, pItem->sq.pSelect, pOuterNC); + sqlite3ResolveSelectNames(pParse, pItem->u4.pSubq->pSelect, pOuterNC); pParse->zAuthContext = zSavedContext; if( pParse->nErr ) return WRC_Abort; assert( db->mallocFailed==0 ); @@ -2001,7 +2011,10 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ ** These integers will be replaced by copies of the corresponding result ** set expressions by the call to resolveOrderGroupBy() below. */ if( p->selFlags & SF_Converted ){ - Select *pSub = p->pSrc->a[0].sq.pSelect; + Select *pSub; + assert( p->pSrc->a[0].fg.isSubquery ); + pSub = p->pSrc->a[0].u4.pSubq->pSelect; + assert( pSub!=0 ); p->pOrderBy = pSub->pOrderBy; pSub->pOrderBy = 0; } diff --git a/src/select.c b/src/select.c index 5f55b402cf..8bddc03bb4 100644 --- a/src/select.c +++ b/src/select.c @@ -332,11 +332,13 @@ int sqlite3ColumnIndex(Table *pTab, const char *zCol){ */ void sqlite3SrcItemColumnUsed(SrcItem *pItem, int iCol){ assert( pItem!=0 ); - assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->sq.pSelect) ); + assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem) ); if( pItem->fg.isNestedFrom ){ ExprList *pResults; - assert( pItem->sq.pSelect!=0 ); - pResults = pItem->sq.pSelect->pEList; + assert( pItem->fg.isSubquery ); + assert( pItem->u4.pSubq!=0 ); + assert( pItem->u4.pSubq->pSelect!=0 ); + pResults = pItem->u4.pSubq->pSelect->pEList; assert( pResults!=0 ); assert( iCol>=0 && iColnExpr ); pResults->a[iCol].fg.bUsed = 1; @@ -1931,7 +1933,11 @@ static const char *columnTypeImpl( for(j=0;jnSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++); if( jnSrc ){ pTab = pTabList->a[j].pSTab; - pS = pTabList->a[j].sq.pSelect; + if( pTabList->a[j].fg.isSubquery ){ + pS = pTabList->a[j].u4.pSubq->pSelect; + }else{ + pS = 0; + } }else{ pNC = pNC->pNext; } @@ -3983,7 +3989,9 @@ static void substSelect( pSrc = p->pSrc; assert( pSrc!=0 ); for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ - substSelect(pSubst, pItem->sq.pSelect, 1); + if( pItem->fg.isSubquery ){ + substSelect(pSubst, pItem->u4.pSubq->pSelect, 1); + } if( pItem->fg.isTabFunc ){ substExprList(pSubst, pItem->u1.pFuncArg); } @@ -4054,8 +4062,10 @@ static void srclistRenumberCursors( aCsrMap[pItem->iCursor+1] = pParse->nTab++; } pItem->iCursor = aCsrMap[pItem->iCursor+1]; - for(p=pItem->sq.pSelect; p; p=p->pPrior){ - srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); + if( pItem->fg.isSubquery ){ + for(p=pItem->u4.pSubq->pSelect; p; p=p->pPrior){ + srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); + } } } } @@ -4366,7 +4376,8 @@ static int flattenSubquery( assert( pSrc && iFrom>=0 && iFromnSrc ); pSubitem = &pSrc->a[iFrom]; iParent = pSubitem->iCursor; - pSub = pSubitem->sq.pSelect; + assert( pSubitem->fg.isSubquery ); + pSub = pSubitem->u4.pSubq->pSelect; assert( pSub!=0 ); #ifndef SQLITE_OMIT_WINDOWFUNC @@ -4505,7 +4516,12 @@ static int flattenSubquery( pParse->zAuthContext = zSavedAuthContext; /* Delete the transient structures associated with the subquery */ - pSub1 = pSubitem->sq.pSelect; + + if( ALWAYS(pSubitem->fg.isSubquery) ){ + pSub1 = sqlite3SubqueryDetach(db, pSubitem); + }else{ + pSub1 = 0; + } if( pSubitem->fg.fixedSchema==0 ){ sqlite3DbFree(db, pSubitem->u4.zDatabase); pSubitem->u4.zDatabase = 0; @@ -4514,7 +4530,6 @@ static int flattenSubquery( sqlite3DbFree(db, pSubitem->zAlias); pSubitem->zName = 0; pSubitem->zAlias = 0; - pSubitem->sq.pSelect = 0; assert( pSubitem->fg.isUsing!=0 || pSubitem->u3.pOn==0 ); /* If the sub-query is a compound SELECT statement, then (by restrictions @@ -4579,11 +4594,14 @@ static int flattenSubquery( TREETRACE(0x4,pParse,p,("compound-subquery flattener" " creates %u as peer\n",pNew->selId)); } - assert( pSubitem->sq.pSelect==0 ); + assert( pSubitem->fg.isSubquery==0 ); } sqlite3DbFree(db, aCsrMap); if( db->mallocFailed ){ - pSubitem->sq.pSelect = pSub1; + assert( pSubitem->fg.fixedSchema==0 ); + assert( pSubitem->fg.isSubquery==0 ); + assert( pSubitem->u4.zDatabase==0 ); + sqlite3SrcItemAttachSubquery(pParse, pSubitem, pSub1, 0); return 1; } @@ -4659,8 +4677,11 @@ static int flattenSubquery( */ for(i=0; ia[i+iFrom]; - if( pItem->fg.isUsing ) sqlite3IdListDelete(db, pItem->u3.pUsing); assert( pItem->fg.isTabFunc==0 ); + assert( pItem->fg.isSubquery + || pItem->fg.fixedSchema + || pItem->u4.zDatabase==0 ); + if( pItem->fg.isUsing ) sqlite3IdListDelete(db, pItem->u3.pUsing); *pItem = pSubSrc->a[i]; pItem->fg.jointype |= ltorj; iNewParent = pSubSrc->a[i].iCursor; @@ -5346,8 +5367,8 @@ static int disableUnusedSubqueryResultColumns(SrcItem *pItem){ } assert( pItem->pSTab!=0 ); pTab = pItem->pSTab; - assert( pItem->sq.pSelect!=0 ); - pSub = pItem->sq.pSelect; + assert( pItem->fg.isSubquery ); + pSub = pItem->u4.pSubq->pSelect; assert( pSub->pEList->nExpr==pTab->nCol ); for(pX=pSub; pX; pX=pX->pPrior){ if( (pX->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ @@ -5476,7 +5497,7 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ if( p->pWhere || p->pEList->nExpr!=1 || p->pSrc->nSrc!=1 - || p->pSrc->a[0].sq.pSelect + || p->pSrc->a[0].fg.isSubquery || pAggInfo->nFunc!=1 || p->pHaving ){ @@ -5776,10 +5797,12 @@ static int resolveFromTermToCte( pTab->iPKey = -1; pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; - pFrom->sq.pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); + sqlite3SrcItemAttachSubquery(pParse, pFrom, pCte->pSelect, 1); if( db->mallocFailed ) return 2; - assert( pFrom->sq.pSelect ); - pFrom->sq.pSelect->selFlags |= SF_CopyCte; + assert( pFrom->fg.isSubquery && pFrom->u4.pSubq ); + pSel = pFrom->u4.pSubq->pSelect; + assert( pSel!=0 ); + pSel->selFlags |= SF_CopyCte; if( pFrom->fg.isIndexedBy ){ sqlite3ErrorMsg(pParse, "no such index: \"%s\"", pFrom->u1.zIndexedBy); return 2; @@ -5789,7 +5812,7 @@ static int resolveFromTermToCte( pCteUse->nUse++; /* Check if this is a recursive CTE. */ - pRecTerm = pSel = pFrom->sq.pSelect; + pRecTerm = pSel; bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION ); while( bMayRecursive && pRecTerm->op==pSel->op ){ int i; @@ -5904,9 +5927,12 @@ void sqlite3SelectPopWith(Walker *pWalker, Select *p){ ** SQLITE_NOMEM. */ int sqlite3ExpandSubquery(Parse *pParse, SrcItem *pFrom){ - Select *pSel = pFrom->sq.pSelect; + Select *pSel; Table *pTab; + assert( pFrom->fg.isSubquery ); + assert( pFrom->u4.pSubq!=0 ); + pSel = pFrom->u4.pSubq->pSelect; assert( pSel ); pFrom->pSTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table)); if( pTab==0 ) return SQLITE_NOMEM; @@ -6033,7 +6059,9 @@ static int selectExpander(Walker *pWalker, Select *p){ assert( pFrom->fg.isRecursive==0 ); if( pFrom->zName==0 ){ #ifndef SQLITE_OMIT_SUBQUERY - Select *pSel = pFrom->sq.pSelect; + Select *pSel; + assert( pFrom->fg.isSubquery && pFrom->u4.pSubq!=0 ); + pSel = pFrom->u4.pSubq->pSelect; /* A sub-query in the FROM clause of a SELECT */ assert( pSel!=0 ); assert( pFrom->pSTab==0 ); @@ -6066,7 +6094,7 @@ static int selectExpander(Walker *pWalker, Select *p){ i16 nCol; u8 eCodeOrig = pWalker->eCode; if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; - assert( pFrom->sq.pSelect==0 ); + assert( pFrom->fg.isSubquery==0 ); if( IsView(pTab) ){ if( (db->flags & SQLITE_EnableView)==0 && pTab->pSchema!=db->aDb[1].pSchema @@ -6074,7 +6102,7 @@ static int selectExpander(Walker *pWalker, Select *p){ sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", pTab->zName); } - pFrom->sq.pSelect = sqlite3SelectDup(db, pTab->u.view.pSelect, 0); + sqlite3SrcItemAttachSubquery(pParse, pFrom, pTab->u.view.pSelect, 1); } #ifndef SQLITE_OMIT_VIRTUALTABLE else if( ALWAYS(IsVirtual(pTab)) @@ -6090,7 +6118,9 @@ static int selectExpander(Walker *pWalker, Select *p){ nCol = pTab->nCol; pTab->nCol = -1; pWalker->eCode = 1; /* Turn on Select.selId renumbering */ - sqlite3WalkSelect(pWalker, pFrom->sq.pSelect); + if( pFrom->fg.isSubquery ){ + sqlite3WalkSelect(pWalker, pFrom->u4.pSubq->pSelect); + } pWalker->eCode = eCodeOrig; pTab->nCol = nCol; } @@ -6188,11 +6218,11 @@ static int selectExpander(Walker *pWalker, Select *p){ zTabName = pTab->zName; } if( db->mallocFailed ) break; - assert( (int)pFrom->fg.isNestedFrom == - IsNestedFrom(pFrom->sq.pSelect) ); + assert( (int)pFrom->fg.isNestedFrom == IsNestedFrom(pFrom) ); if( pFrom->fg.isNestedFrom ){ - assert( pFrom->sq.pSelect!=0 ); - pNestedFrom = pFrom->sq.pSelect->pEList; + assert( pFrom->fg.isSubquery && pFrom->u4.pSubq ); + assert( pFrom->u4.pSubq->pSelect!=0 ); + pNestedFrom = pFrom->u4.pSubq->pSelect->pEList; assert( pNestedFrom!=0 ); assert( pNestedFrom->nExpr==pTab->nCol ); assert( VisibleRowid(pTab)==0 || ViewCanHaveRowid ); @@ -6433,12 +6463,10 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ Table *pTab = pFrom->pSTab; assert( pTab!=0 ); - if( (pTab->tabFlags & TF_Ephemeral)!=0 ){ + if( (pTab->tabFlags & TF_Ephemeral)!=0 && pFrom->fg.isSubquery ){ /* A sub-query in the FROM clause of a SELECT */ - Select *pSel = pFrom->sq.pSelect; - if( pSel ){ - sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_NONE); - } + Select *pSel = pFrom->u4.pSubq->pSelect; + sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_NONE); } } } @@ -7085,25 +7113,28 @@ static SrcItem *isSelfJoinView( int iFirst, int iEnd /* Range of FROM-clause entries to search. */ ){ SrcItem *pItem; - assert( pThis->sq.pSelect!=0 ); - if( pThis->sq.pSelect->selFlags & SF_PushDown ) return 0; + Select *pSel; + assert( pThis->fg.isSubquery ); + pSel = pThis->u4.pSubq->pSelect; + assert( pSel!=0 ); + if( pSel->selFlags & SF_PushDown ) return 0; while( iFirsta[iFirst++]; - if( pItem->sq.pSelect==0 ) continue; + if( !pItem->fg.isSubquery ) continue; if( pItem->fg.viaCoroutine ) continue; if( pItem->zName==0 ) continue; assert( pItem->pSTab!=0 ); assert( pThis->pSTab!=0 ); if( pItem->pSTab->pSchema!=pThis->pSTab->pSchema ) continue; if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue; - pS1 = pItem->sq.pSelect; - if( pItem->pSTab->pSchema==0 && pThis->sq.pSelect->selId!=pS1->selId ){ + pS1 = pItem->u4.pSubq->pSelect; + if( pItem->pSTab->pSchema==0 && pSel->selId!=pS1->selId ){ /* The query flattener left two different CTE tables with identical ** names in the same FROM clause. */ continue; } - if( pItem->sq.pSelect->selFlags & SF_PushDown ){ + if( pS1->selFlags & SF_PushDown ){ /* The view was modified by some other optimization such as ** pushDownWhereTerms() */ continue; @@ -7147,6 +7178,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ Expr *pExpr; Expr *pCount; sqlite3 *db; + SrcItem *pFrom; if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate */ if( p->pEList->nExpr!=1 ) return 0; /* Single result column */ if( p->pWhere ) return 0; @@ -7161,8 +7193,9 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */ if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */ if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */ - pSub = p->pSrc->a[0].sq.pSelect; - if( pSub==0 ) return 0; /* The FROM is a subquery */ + pFrom = p->pSrc->a; + if( pFrom->fg.isSubquery==0 ) return 0; /* FROM is a subquery */ + pSub = pFrom->u4.pSubq->pSelect; if( pSub->pPrior==0 ) return 0; /* Must be a compound */ if( pSub->selFlags & SF_CopyCte ) return 0; /* Not a CTE */ do{ @@ -7171,7 +7204,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ if( pSub->pLimit ) return 0; /* No LIMIT clause */ if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */ assert( pSub->pHaving==0 ); /* Due to the previous */ - pSub = pSub->pPrior; /* Repeat over compound */ + pSub = pSub->pPrior; /* Repeat over compound */ }while( pSub ); /* If we reach this point then it is OK to perform the transformation */ @@ -7179,8 +7212,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ db = pParse->db; pCount = pExpr; pExpr = 0; - pSub = p->pSrc->a[0].sq.pSelect; - p->pSrc->a[0].sq.pSelect = 0; + pSub = sqlite3SubqueryDetach(db, pFrom); sqlite3SrcListDelete(db, p->pSrc); p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*p->pSrc)); while( pSub ){ @@ -7228,9 +7260,9 @@ static int sameSrcAlias(SrcItem *p0, SrcList *pSrc){ if( p0->pSTab==p1->pSTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){ return 1; } - if( p1->sq.pSelect - && (p1->sq.pSelect->selFlags & SF_NestedFrom)!=0 - && sameSrcAlias(p0, p1->sq.pSelect->pSrc) + if( p1->fg.isSubquery + && (p1->u4.pSubq->pSelect->selFlags & SF_NestedFrom)!=0 + && sameSrcAlias(p0, p1->u4.pSubq->pSelect->pSrc) ){ return 1; } @@ -7295,7 +7327,7 @@ static int fromClauseTermCanBeCoroutine( if( i==0 ) break; i--; pItem--; - if( pItem->sq.pSelect!=0 ) return 0; /* (1c-i) */ + if( pItem->fg.isSubquery ) return 0; /* (1c-i) */ } return 1; } @@ -7445,7 +7477,7 @@ int sqlite3Select( #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) for(i=0; !p->pPrior && inSrc; i++){ SrcItem *pItem = &pTabList->a[i]; - Select *pSub = pItem->sq.pSelect; + Select *pSub = pItem->fg.isSubquery ? pItem->u4.pSubq->pSelect : 0; Table *pTab = pItem->pSTab; /* The expander should have already created transient Table objects @@ -7664,6 +7696,7 @@ int sqlite3Select( SrcItem *pItem = &pTabList->a[i]; SrcItem *pPrior; SelectDest dest; + Subquery *pSubq; Select *pSub; #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) const char *zSavedAuthContext; @@ -7699,11 +7732,14 @@ int sqlite3Select( #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) /* Generate code for all sub-queries in the FROM clause */ - pSub = pItem->sq.pSelect; - if( pSub==0 || pItem->sq.addrFillSub!=0 ) continue; + if( pItem->fg.isSubquery==0 ) continue; + pSubq = pItem->u4.pSubq; + assert( pSubq!=0 ); + pSub = pSubq->pSelect; + if( pSubq->addrFillSub!=0 ) continue; /* The code for a subquery should only be generated once. */ - assert( pItem->sq.addrFillSub==0 ); + assert( pSubq->addrFillSub==0 ); /* Increment Parse.nHeight by the height of the largest expression ** tree referred to by this, the parent select. The child select @@ -7729,8 +7765,7 @@ int sqlite3Select( sqlite3TreeViewSelect(0, p, 0); } #endif - assert( pItem->sq.pSelect - && (pItem->sq.pSelect->selFlags & SF_PushDown)!=0 ); + assert( pSubq->pSelect && (pSub->selFlags & SF_PushDown)!=0 ); }else{ TREETRACE(0x4000,pParse,p,("WHERE-lcause push-down not possible\n")); } @@ -7762,17 +7797,17 @@ int sqlite3Select( */ int addrTop = sqlite3VdbeCurrentAddr(v)+1; - pItem->sq.regReturn = ++pParse->nMem; - sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->sq.regReturn, 0, addrTop); + pSubq->regReturn = ++pParse->nMem; + sqlite3VdbeAddOp3(v, OP_InitCoroutine, pSubq->regReturn, 0, addrTop); VdbeComment((v, "%!S", pItem)); - pItem->sq.addrFillSub = addrTop; - sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->sq.regReturn); + pSubq->addrFillSub = addrTop; + sqlite3SelectDestInit(&dest, SRT_Coroutine, pSubq->regReturn); ExplainQueryPlan((pParse, 1, "CO-ROUTINE %!S", pItem)); sqlite3Select(pParse, pSub, &dest); pItem->pSTab->nRowLogEst = pSub->nSelectRow; pItem->fg.viaCoroutine = 1; - pItem->sq.regResult = dest.iSdst; - sqlite3VdbeEndCoroutine(v, pItem->sq.regReturn); + pSubq->regResult = dest.iSdst; + sqlite3VdbeEndCoroutine(v, pSubq->regReturn); sqlite3VdbeJumpHere(v, addrTop-1); sqlite3ClearTempRegCache(pParse); }else if( pItem->fg.isCte && pItem->u2.pCteUse->addrM9e>0 ){ @@ -7790,12 +7825,16 @@ int sqlite3Select( }else if( (pPrior = isSelfJoinView(pTabList, pItem, 0, i))!=0 ){ /* This view has already been materialized by a prior entry in ** this same FROM clause. Reuse it. */ - if( pPrior->sq.addrFillSub ){ - sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->sq.regReturn, - pPrior->sq.addrFillSub); + Subquery *pPriorSubq; + assert( pPrior->fg.isSubquery ); + pPriorSubq = pPrior->u4.pSubq; + assert( pPriorSubq!=0 ); + if( pPriorSubq->addrFillSub ){ + sqlite3VdbeAddOp2(v, OP_Gosub, pPriorSubq->regReturn, + pPriorSubq->addrFillSub); } sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); - pSub->nSelectRow = pPrior->sq.pSelect->nSelectRow; + pSub->nSelectRow = pPriorSubq->pSelect->nSelectRow; }else{ /* Materialize the view. If the view is not correlated, generate a ** subroutine to do the materialization so that subsequent uses of @@ -7806,9 +7845,9 @@ int sqlite3Select( int addrExplain; #endif - pItem->sq.regReturn = ++pParse->nMem; + pSubq->regReturn = ++pParse->nMem; topAddr = sqlite3VdbeAddOp0(v, OP_Goto); - pItem->sq.addrFillSub = topAddr+1; + pSubq->addrFillSub = topAddr+1; pItem->fg.isMaterialized = 1; if( pItem->fg.isCorrelated==0 ){ /* If the subquery is not correlated and if we are not inside of @@ -7825,15 +7864,15 @@ int sqlite3Select( sqlite3Select(pParse, pSub, &dest); pItem->pSTab->nRowLogEst = pSub->nSelectRow; if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr); - sqlite3VdbeAddOp2(v, OP_Return, pItem->sq.regReturn, topAddr+1); + sqlite3VdbeAddOp2(v, OP_Return, pSubq->regReturn, topAddr+1); VdbeComment((v, "end %!S", pItem)); sqlite3VdbeScanStatusRange(v, addrExplain, addrExplain, -1); sqlite3VdbeJumpHere(v, topAddr); sqlite3ClearTempRegCache(pParse); if( pItem->fg.isCte && pItem->fg.isCorrelated==0 ){ CteUse *pCteUse = pItem->u2.pCteUse; - pCteUse->addrM9e = pItem->sq.addrFillSub; - pCteUse->regRtn = pItem->sq.regReturn; + pCteUse->addrM9e = pSubq->addrFillSub; + pCteUse->regRtn = pSubq->regReturn; pCteUse->iCur = pItem->iCursor; pCteUse->nRowEst = pSub->nSelectRow; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 54e4f2db73..c282023de4 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1335,6 +1335,7 @@ typedef struct Savepoint Savepoint; typedef struct Select Select; typedef struct SQLiteThread SQLiteThread; typedef struct SelectDest SelectDest; +typedef struct Subquery Subquery; typedef struct SrcItem SrcItem; typedef struct SrcList SrcList; typedef struct sqlite3_str StrAccum; /* Internal alias for sqlite3_str */ @@ -3275,6 +3276,16 @@ struct IdList { #define EU4_IDX 1 /* Uses IdList.a.u4.idx */ #define EU4_EXPR 2 /* Uses IdList.a.u4.pExpr -- NOT CURRENTLY USED */ +/* +** Details of the implementation of a subquery. +*/ +struct Subquery { + Select *pSelect; /* A SELECT statement used in place of a table name */ + int addrFillSub; /* Address of subroutine to initialize a subquery */ + int regReturn; /* Register holding return address of addrFillSub */ + int regResult; /* Registers holding results of a co-routine */ +}; + /* ** The SrcItem object represents a single term in the FROM clause of a query. ** The SrcList object is mostly an array of SrcItems. @@ -3287,10 +3298,15 @@ struct IdList { ** In the colUsed field, the high-order bit (bit 63) is set if the table ** contains more than 63 columns and the 64-th or later column is used. ** +** Intenstive use of "union" helps keep the size of the object small. This +** has been shown to boost performance due to less time spend initializing +** fields to zero when a new instance of this object is allocated. The unions +** also help SrcItem, and hence SrcList and Select, use less memory. +** ** Union member validity: ** -** u1.zIndexedBy fg.isIndexedBy && !fg.isTabFunc -** u1.pFuncArg fg.isTabFunc && !fg.isIndexedBy +** u1.zIndexedBy fg.isIndexedBy +** u1.pFuncArg fg.isTabFunc ** u1.nRow !fg.isTabFunc && !fg.isIndexedBy ** ** u2.pIBIndex fg.isIndexedBy && !fg.isCte @@ -3299,23 +3315,19 @@ struct IdList { ** u3.pOn fg.isUsing==0 ** u3.pUsing fg.isUsing==1 ** -** u4.zDatabase fg.fixedSchema==0 +** u4.zDatabase fg.fixedSchema==0 && !fg.isSubquery ** u4.pSchema fg.fixedSchema==1 +** u4.pSubq fg.isSubquery */ struct SrcItem { char *zName; /* Name of the table */ char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ Table *pSTab; /* Table object for zName. Mnemonic: Srcitem-TABle */ - struct SrcItemSubquery { - Select *pSelect; /* A SELECT statement used in place of a table name */ - int addrFillSub; /* Address of subroutine to initialize a subquery */ - int regReturn; /* Register holding return address of addrFillSub */ - int regResult; /* Registers holding results of a co-routine */ - } sq; struct { u8 jointype; /* Type of join between this table and the previous */ unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */ + unsigned isSubquery :1; /* True if this term is a subquery */ unsigned isTabFunc :1; /* True if table-valued-function syntax */ unsigned isCorrelated :1; /* True if sub-query is correlated */ unsigned isMaterialized:1; /* This is a materialized view */ @@ -3350,6 +3362,7 @@ struct SrcItem { union { Schema *pSchema; /* Schema to which this item is fixed */ char *zDatabase; /* Name of database holding this table */ + Subquery *pSubq; /* Description of a subquery */ } u4; }; @@ -3610,8 +3623,10 @@ struct Select { #define SF_UpdateFrom 0x10000000 /* Query originates with UPDATE FROM */ #define SF_Correlated 0x20000000 /* True if references the outer context */ -/* True if S exists and has SF_NestedFrom */ -#define IsNestedFrom(S) ((S)!=0 && ((S)->selFlags&SF_NestedFrom)!=0) +/* True if SrcList item X is a subquery that has SF_NestedFrom */ +#define IsNestedFrom(X) \ + ((X)->fg.isSubquery && \ + ((X)->u4.pSubq->pSelect->selFlags&SF_NestedFrom)!=0) /* ** The results of a SELECT can be distributed in several ways, as defined @@ -5003,6 +5018,9 @@ int sqlite3IdListIndex(IdList*,const char*); SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int); SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2); SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*); +void sqlite3SubqueryDelete(sqlite3*,Subquery*); +Select *sqlite3SubqueryDetach(sqlite3*,SrcItem*); +int sqlite3SrcItemAttachSubquery(Parse*, SrcItem*, Select*, int); SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, Token*, Select*, OnOrUsing*); void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *); diff --git a/src/treeview.c b/src/treeview.c index 0c9fdc5266..dbd54b3466 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -230,19 +230,19 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ sqlite3StrAccumFinish(&x); sqlite3TreeViewItem(pView, zLine, inSrc-1); n = 0; - if( pItem->sq.pSelect ) n++; + if( pItem->fg.isSubquery ) n++; if( pItem->fg.isTabFunc ) n++; if( pItem->fg.isUsing ) n++; if( pItem->fg.isUsing ){ sqlite3TreeViewIdList(pView, pItem->u3.pUsing, (--n)>0, "USING"); } - if( pItem->sq.pSelect ){ + if( pItem->fg.isSubquery ){ if( pItem->pSTab ){ Table *pTab = pItem->pSTab; sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1); } - assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->sq.pSelect) ); - sqlite3TreeViewSelect(pView, pItem->sq.pSelect, (--n)>0); + assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem) ); + sqlite3TreeViewSelect(pView, pItem->u4.pSubq->pSelect, (--n)>0); } if( pItem->fg.isTabFunc ){ sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); diff --git a/src/walker.c b/src/walker.c index 27963c2234..c8735e39b8 100644 --- a/src/walker.c +++ b/src/walker.c @@ -171,7 +171,9 @@ int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){ pSrc = p->pSrc; if( ALWAYS(pSrc) ){ for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ - if( pItem->sq.pSelect && sqlite3WalkSelect(pWalker, pItem->sq.pSelect) ){ + if( pItem->fg.isSubquery + && sqlite3WalkSelect(pWalker, pItem->u4.pSubq->pSelect) + ){ return WRC_Abort; } if( pItem->fg.isTabFunc diff --git a/src/where.c b/src/where.c index ded5f06816..c9f6b97c94 100644 --- a/src/where.c +++ b/src/where.c @@ -1161,9 +1161,14 @@ static SQLITE_NOINLINE void constructAutomaticIndex( /* Fill the automatic index with content */ assert( pSrc == &pWC->pWInfo->pTabList->a[pLevel->iFrom] ); if( pSrc->fg.viaCoroutine ){ - int regYield = pSrc->sq.regReturn; + int regYield; + Subquery *pSubq; + assert( pSrc->fg.isSubquery ); + pSubq = pSrc->u4.pSubq; + assert( pSubq!=0 ); + regYield = pSubq->regReturn; addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0); - sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSrc->sq.addrFillSub); + sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSubq->addrFillSub); addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield); VdbeCoverage(v); VdbeComment((v, "next row of %s", pSrc->pSTab->zName)); @@ -1188,11 +1193,12 @@ static SQLITE_NOINLINE void constructAutomaticIndex( sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue); if( pSrc->fg.viaCoroutine ){ + assert( pSrc->fg.isSubquery && pSrc->u4.pSubq!=0 ); sqlite3VdbeChangeP2(v, addrCounter, regBase+n); testcase( pParse->db->mallocFailed ); assert( pLevel->iIdxCur>0 ); translateColumnToCopy(pParse, addrTop, pLevel->iTabCur, - pSrc->sq.regResult, pLevel->iIdxCur); + pSrc->u4.pSubq->regResult, pLevel->iIdxCur); sqlite3VdbeGoto(v, addrTop); pSrc->fg.viaCoroutine = 0; }else{ @@ -4010,9 +4016,9 @@ static int whereLoopAddBtree( #endif ApplyCostMultiplier(pNew->rRun, pTab->costMult); whereLoopOutputAdjust(pWC, pNew, rSize); - if( pSrc->sq.pSelect ){ + if( pSrc->fg.isSubquery ){ if( pSrc->fg.viaCoroutine ) pNew->wsFlags |= WHERE_COROUTINE; - pNew->u.btree.pOrderBy = pSrc->sq.pSelect->pOrderBy; + pNew->u.btree.pOrderBy = pSrc->u4.pSubq->pSelect->pOrderBy; } rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; @@ -6421,8 +6427,8 @@ static SQLITE_NOINLINE void whereReverseScanOrder(WhereInfo *pWInfo){ SrcItem *pItem = &pWInfo->pTabList->a[ii]; if( !pItem->fg.isCte || pItem->u2.pCteUse->eM10d!=M10d_Yes - || NEVER(pItem->sq.pSelect==0) - || pItem->sq.pSelect->pOrderBy==0 + || NEVER(pItem->fg.isSubquery==0) + || pItem->u4.pSubq->pSelect->pOrderBy==0 ){ pWInfo->revMask |= MASKBIT(ii); } @@ -7115,11 +7121,14 @@ WhereInfo *sqlite3WhereBegin( wsFlags = pLevel->pWLoop->wsFlags; pSrc = &pTabList->a[pLevel->iFrom]; if( pSrc->fg.isMaterialized ){ + Subquery *pSubq; + assert( pSrc->fg.isSubquery ); + pSubq = pSrc->u4.pSubq; if( pSrc->fg.isCorrelated ){ - sqlite3VdbeAddOp2(v, OP_Gosub, pSrc->sq.regReturn,pSrc->sq.addrFillSub); + sqlite3VdbeAddOp2(v, OP_Gosub, pSubq->regReturn, pSubq->addrFillSub); }else{ int iOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); - sqlite3VdbeAddOp2(v, OP_Gosub, pSrc->sq.regReturn,pSrc->sq.addrFillSub); + sqlite3VdbeAddOp2(v, OP_Gosub, pSubq->regReturn, pSubq->addrFillSub); sqlite3VdbeJumpHere(v, iOnce); } } @@ -7334,7 +7343,8 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ assert( pLevel->iTabCur==pSrc->iCursor ); if( pSrc->fg.viaCoroutine ){ int m, n; - n = pSrc->sq.regResult; + assert( pSrc->fg.isSubquery ); + n = pSrc->u4.pSubq->regResult; assert( pSrc->pSTab!=0 ); m = pSrc->pSTab->nCol; sqlite3VdbeAddOp3(v, OP_Null, 0, n, n+m-1); @@ -7388,9 +7398,10 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ */ if( pTabItem->fg.viaCoroutine ){ testcase( pParse->db->mallocFailed ); - assert( pTabItem->sq.regResult>=0 ); + assert( pTabItem->fg.isSubquery ); + assert( pTabItem->u4.pSubq->regResult>=0 ); translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur, - pTabItem->sq.regResult, 0); + pTabItem->u4.pSubq->regResult, 0); continue; } diff --git a/src/wherecode.c b/src/wherecode.c index ebc71d1102..b0c0d9aedd 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -317,7 +317,9 @@ void sqlite3WhereAddScanStatus( sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iIdxCur); } }else{ - int addr = pSrclist->a[pLvl->iFrom].sq.addrFillSub; + int addr; + assert( pSrclist->a[pLvl->iFrom].fg.isSubquery ); + addr = pSrclist->a[pLvl->iFrom].u4.pSubq->addrFillSub; VdbeOp *pOp = sqlite3VdbeGetOp(v, addr-1); assert( sqlite3VdbeDb(v)->mallocFailed || pOp->opcode==OP_InitCoroutine ); assert( sqlite3VdbeDb(v)->mallocFailed || pOp->p2>addr ); @@ -1510,8 +1512,12 @@ Bitmask sqlite3WhereCodeOneLoopStart( /* Special case of a FROM clause subquery implemented as a co-routine */ if( pTabItem->fg.viaCoroutine ){ - int regYield = pTabItem->sq.regReturn; - sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield,0,pTabItem->sq.addrFillSub); + int regYield; + Subquery *pSubq; + assert( pTabItem->fg.isSubquery && pTabItem->u4.pSubq!=0 ); + pSubq = pTabItem->u4.pSubq; + regYield = pSubq->regReturn; + sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSubq->addrFillSub); pLevel->p2 = sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk); VdbeCoverage(v); VdbeComment((v, "next row of %s", pTabItem->pSTab->zName)); @@ -2819,9 +2825,13 @@ SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( pRight = &pWInfo->pTabList->a[pWInfo->a[k].iFrom]; mAll |= pWInfo->a[k].pWLoop->maskSelf; if( pRight->fg.viaCoroutine ){ + Subquery *pSubq; + assert( pRight->fg.isSubquery && pRight->u4.pSubq!=0 ); + pSubq = pRight->u4.pSubq; + assert( pSubq->pSelect!=0 && pSubq->pSelect->pEList!=0 ); sqlite3VdbeAddOp3( - v, OP_Null, 0, pRight->sq.regResult, - pRight->sq.regResult + pRight->sq.pSelect->pEList->nExpr-1 + v, OP_Null, 0, pSubq->regResult, + pSubq->regResult + pSubq->pSelect->pEList->nExpr-1 ); } sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); diff --git a/src/whereexpr.c b/src/whereexpr.c index 766754828d..ae26e85d25 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -958,7 +958,9 @@ static Bitmask exprSelectUsage(WhereMaskSet *pMaskSet, Select *pS){ if( ALWAYS(pSrc!=0) ){ int i; for(i=0; inSrc; i++){ - mask |= exprSelectUsage(pMaskSet, pSrc->a[i].sq.pSelect); + if( pSrc->a[i].fg.isSubquery ){ + mask |= exprSelectUsage(pMaskSet, pSrc->a[i].u4.pSubq->pSelect); + } if( pSrc->a[i].fg.isUsing==0 ){ mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].u3.pOn); } diff --git a/src/window.c b/src/window.c index 9829d1740b..d4083beeb3 100644 --- a/src/window.c +++ b/src/window.c @@ -1077,9 +1077,10 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){ assert( pSub!=0 || p->pSrc==0 ); /* Due to db->mallocFailed test inside ** of sqlite3DbMallocRawNN() called from ** sqlite3SrcListAppend() */ - if( p->pSrc ){ + if( p->pSrc==0 ){ + sqlite3SelectDelete(db, pSub); + }else if( sqlite3SrcItemAttachSubquery(pParse, &p->pSrc->a[0], pSub, 0) ){ Table *pTab2; - p->pSrc->a[0].sq.pSelect = pSub; p->pSrc->a[0].fg.isCorrelated = 1; sqlite3SrcListAssignCursors(pParse, p->pSrc); pSub->selFlags |= SF_Expanded|SF_OrderByReqd; @@ -1101,8 +1102,6 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){ w.xSelectCallback2 = sqlite3WalkerDepthDecrease; sqlite3WalkSelect(&w, pSub); } - }else{ - sqlite3SelectDelete(db, pSub); } if( db->mallocFailed ) rc = SQLITE_NOMEM; @@ -1389,10 +1388,15 @@ int sqlite3WindowCompare( ** and initialize registers and cursors used by sqlite3WindowCodeStep(). */ void sqlite3WindowCodeInit(Parse *pParse, Select *pSelect){ - int nEphExpr = pSelect->pSrc->a[0].sq.pSelect->pEList->nExpr; - Window *pMWin = pSelect->pWin; Window *pWin; - Vdbe *v = sqlite3GetVdbe(pParse); + int nEphExpr; + Window *pMWin; + Vdbe *v; + + assert( pSelect->pSrc->a[0].fg.isSubquery ); + nEphExpr = pSelect->pSrc->a[0].u4.pSubq->pSelect->pEList->nExpr; + pMWin = pSelect->pWin; + v = sqlite3GetVdbe(pParse); sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, nEphExpr); sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+1, pMWin->iEphCsr); From 1c8ed5fa43a0d588874ab9006faf584e88303714 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 19 Aug 2024 23:43:08 +0000 Subject: [PATCH 0688/1030] Earlier error detection while processing complex aggregate queries. dbsqlfuzz 5242c2f07f4aa031aa3c80461f18e9b7619ede9b FossilOrigin-Name: 70f4973078ffc72f4ff247234e6f8e695b40803c3e7c9ed12050d97195728352 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f8108ac374..07c8d04347 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\ssome\scomments\sthat\sare\sprocessed\sinto\sthe\sfts5.html\swebpage. -D 2024-08-19T20:35:30.209 +C Earlier\serror\sdetection\swhile\sprocessing\scomplex\saggregate\nqueries.\s\sdbsqlfuzz\s5242c2f07f4aa031aa3c80461f18e9b7619ede9b +D 2024-08-19T23:43:08.285 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -764,7 +764,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 0aee8a2e5340ba95a966917305dfaff5147fcad78d0839cd364b16e4746b8bcb F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 6a95a2bffa6c09584dea99db5a7ae10c813305c09c92920ffc54f6eae2ba399e +F src/select.c 7e907830b01c7fd34968514067aed1eac13e47da4bc1a936ef2020c6b866cc08 F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b9632900100bdbc913f83bfb03b32585cf07a192b9a7f26b9bebc7d91e63a610 -R ea532ddb7482adbca514ac43836cd1cf -U dan -Z 0d4360caeae428f14a1f60694bd440b2 +P 3e06ab218bbd1ed75a24afb44e8df9ce84e9fc24701428cb8b3459760f44006d +R 2c7a18e25ae50797bdba35997432ce72 +U drh +Z 62ca2500b12eeccb94ffabbf52380d6e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 39ef92242c..ea720a0f9c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e06ab218bbd1ed75a24afb44e8df9ce84e9fc24701428cb8b3459760f44006d +70f4973078ffc72f4ff247234e6f8e695b40803c3e7c9ed12050d97195728352 diff --git a/src/select.c b/src/select.c index 4b0b554295..c1246d3c2a 100644 --- a/src/select.c +++ b/src/select.c @@ -6747,6 +6747,7 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ for(i=0, pF=pAggInfo->aFunc; inFunc; i++, pF++){ ExprList *pList; assert( ExprUseXList(pF->pFExpr) ); + if( pParse->nErr ) return; pList = pF->pFExpr->x.pList; if( pF->iOBTab>=0 ){ /* For an ORDER BY aggregate, calls to OP_AggStep were deferred. Inputs @@ -6956,6 +6957,7 @@ static void updateAccumulator( if( addrNext ){ sqlite3VdbeResolveLabel(v, addrNext); } + if( pParse->nErr ) return; } if( regHit==0 && pAggInfo->nAccumulator ){ regHit = regAcc; @@ -6965,6 +6967,7 @@ static void updateAccumulator( } for(i=0, pC=pAggInfo->aCol; inAccumulator; i++, pC++){ sqlite3ExprCode(pParse, pC->pCExpr, AggInfoColumnReg(pAggInfo,i)); + if( pParse->nErr ) return; } pAggInfo->directMode = 0; From 6ad4e9fd2a45bd5204b55c73179c6e06689312eb Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 12:09:55 +0000 Subject: [PATCH 0689/1030] Fix for the UTF-16LE problem reporte by [forum:/forumpost/dc7e1b7527e84343|forum post dc7e1b7527e84343]. Because of the unexpected ordering of characters using the default collation (memcmp() order) in UTF-16LE, the LIKE/GLOB optimization restricts its attention to the pattern prefix that is all ASCII, which is the common case. FossilOrigin-Name: a5797ebdea423afc3d2d3bd8adaf1575d33a01f594c0c315afcb1499f1718e9b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 13 +++++++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 07c8d04347..a5207a4320 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Earlier\serror\sdetection\swhile\sprocessing\scomplex\saggregate\nqueries.\s\sdbsqlfuzz\s5242c2f07f4aa031aa3c80461f18e9b7619ede9b -D 2024-08-19T23:43:08.285 +C Fix\sfor\sthe\sUTF-16LE\sproblem\sreporte\sby\n[forum:/forumpost/dc7e1b7527e84343|forum\spost\sdc7e1b7527e84343].\s\sBecause\sof\nthe\sunexpected\sordering\sof\scharacters\susing\sthe\sdefault\scollation\s(memcmp()\norder)\sin\sUTF-16LE,\sthe\sLIKE/GLOB\soptimization\srestricts\sits\sattention\sto\nthe\spattern\sprefix\sthat\sis\sall\sASCII,\swhich\sis\sthe\scommon\scase. +D 2024-08-20T12:09:55.604 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -853,7 +853,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c f5be664f3379c9f930696e339ec4ef4c1187af860cca727411156101fae6b677 F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c -F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290 +F src/whereexpr.c f8a4fa8846aa65289be2077f66c58487ec3a00579426117170438501b5d8a7df F src/window.c 1e40ffc509bae21e466f6106382d238e91eb73edd4ba10e66ca4fd7af2b96896 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3e06ab218bbd1ed75a24afb44e8df9ce84e9fc24701428cb8b3459760f44006d -R 2c7a18e25ae50797bdba35997432ce72 +P 70f4973078ffc72f4ff247234e6f8e695b40803c3e7c9ed12050d97195728352 +R 300d8d51d39fe8e4da3c8738b6efbd9d U drh -Z 62ca2500b12eeccb94ffabbf52380d6e +Z bb9edd492b1f36638d01451d6aaeeec1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ea720a0f9c..d71d3e2329 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -70f4973078ffc72f4ff247234e6f8e695b40803c3e7c9ed12050d97195728352 +a5797ebdea423afc3d2d3bd8adaf1575d33a01f594c0c315afcb1499f1718e9b diff --git a/src/whereexpr.c b/src/whereexpr.c index dcda75d264..4a7cdb3ed7 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -220,11 +220,20 @@ static int isLikeOrGlob( } if( z ){ - /* Count the number of prefix characters prior to the first wildcard */ + /* Count the number of prefix characters prior to the first wildcard. + ** If the underlying database has a UTF16LE encoding, then only consider + ** ASCII characters. Note that the encoding of z[] is UTF8 - we are + ** dealing with only UTF8 here in this code, but the database engine + ** itself might be processing content using a different encoding. */ cnt = 0; while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ cnt++; - if( c==wc[3] && z[cnt]!=0 ) cnt++; + if( c==wc[3] && z[cnt]!=0 ){ + cnt++; + }else if( c>=0x80 && ENC(db)==SQLITE_UTF16LE ){ + cnt--; + break; + } } /* The optimization is possible only if (1) the pattern does not begin From 781163aa9dce91608ba33af479564f83dda1bd40 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 14:12:16 +0000 Subject: [PATCH 0690/1030] When the database encoding is UTF-16LE and the GLOB optimization is used, it is ok to use the range search over an index, but it is not ok to disable the actual GLOB function call. FossilOrigin-Name: 3399698376761ab8c422f8ea02bfa2759afb606f08bedbd1cf7eee834229a9aa --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a5207a4320..e5de88085a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfor\sthe\sUTF-16LE\sproblem\sreporte\sby\n[forum:/forumpost/dc7e1b7527e84343|forum\spost\sdc7e1b7527e84343].\s\sBecause\sof\nthe\sunexpected\sordering\sof\scharacters\susing\sthe\sdefault\scollation\s(memcmp()\norder)\sin\sUTF-16LE,\sthe\sLIKE/GLOB\soptimization\srestricts\sits\sattention\sto\nthe\spattern\sprefix\sthat\sis\sall\sASCII,\swhich\sis\sthe\scommon\scase. -D 2024-08-20T12:09:55.604 +C When\sthe\sdatabase\sencoding\sis\sUTF-16LE\sand\sthe\sGLOB\soptimization\sis\sused,\nit\sis\sok\sto\suse\sthe\srange\ssearch\sover\san\sindex,\sbut\sit\sis\snot\sok\sto\ndisable\sthe\sactual\sGLOB\sfunction\scall. +D 2024-08-20T14:12:16.713 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -853,7 +853,7 @@ F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c f5be664f3379c9f930696e339ec4ef4c1187af860cca727411156101fae6b677 F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e F src/wherecode.c c9cac0b0b8e809c5e7e79d7796918907fb685ad99be2aaa9737f9787aa47349c -F src/whereexpr.c f8a4fa8846aa65289be2077f66c58487ec3a00579426117170438501b5d8a7df +F src/whereexpr.c 26a5a798b3f676447ae54a27584c43b32abfebb8bbcaf6faffbb7ee1da486f2d F src/window.c 1e40ffc509bae21e466f6106382d238e91eb73edd4ba10e66ca4fd7af2b96896 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 70f4973078ffc72f4ff247234e6f8e695b40803c3e7c9ed12050d97195728352 -R 300d8d51d39fe8e4da3c8738b6efbd9d +P a5797ebdea423afc3d2d3bd8adaf1575d33a01f594c0c315afcb1499f1718e9b +R 0a328206336eacdda27ba4526bd5a010 U drh -Z bb9edd492b1f36638d01451d6aaeeec1 +Z 4c7bd06b974e78d392c3b37a21911656 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d71d3e2329..7fb9914a05 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a5797ebdea423afc3d2d3bd8adaf1575d33a01f594c0c315afcb1499f1718e9b +3399698376761ab8c422f8ea02bfa2759afb606f08bedbd1cf7eee834229a9aa diff --git a/src/whereexpr.c b/src/whereexpr.c index 4a7cdb3ed7..d44085a783 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -248,7 +248,7 @@ static int isLikeOrGlob( Expr *pPrefix; /* A "complete" match if the pattern ends with "*" or "%" */ - *pisComplete = c==wc[0] && z[cnt+1]==0; + *pisComplete = c==wc[0] && z[cnt+1]==0 && ENC(db)!=SQLITE_UTF16LE; /* Get the pattern prefix. Remove all escapes from the prefix. */ pPrefix = sqlite3Expr(db, TK_STRING, (char*)z); From ff4ad29d05156598d70b8328cbfb352114446bc3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 16:50:21 +0000 Subject: [PATCH 0691/1030] Memory issues fixes so that mdevtest now passes. FossilOrigin-Name: b249516f6a6650808e035ec219e762bf24dcb7c32a6235984b995d08d07d35d8 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 6 ++++-- src/insert.c | 8 +++++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 30b1edeab1..06a26110e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Refactor\sthe\sSrcItem\sobject\sso\sthat\sinformation\sabout\ssubqueries\sis\sstored\nin\sa\sseparately\sallocated\sSubquery\sobject.\s\sThis\sreduces\sthe\smemory\srequirements\nfor\sSrcItem\sand\smakes\sthe\scode\srun\sfaster.\s\sIt\salso\sprovides\san\sexpansion\spath\nfor\ssubquery\sprocessing\sthat\sdoes\snot\sburden\ssimple\squeries.\s\sThe\scurrent\nchecking\smostly\sworks,\sbut\sthere\sare\sstill\sissues\sthat\sneed\sto\sbe\stracked\ndown\sand\sfixed. -D 2024-08-19T22:48:30.539 +C Memory\sissues\sfixes\sso\sthat\smdevtest\snow\spasses. +D 2024-08-20T16:50:21.429 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -702,7 +702,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c d243a17292e027c1d662e992fbd395123aacc4b74a4a9419d0b010088ba318dd +F src/build.c 29ebc26d90a9d6e860a3018a6d61fb667c80ec8e80e3798c4164d2349ba28650 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 @@ -719,7 +719,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c b07865339e67869ff12d2eee3a1417f4779c742e2a51ae3d14ad45e5168f6f41 +F src/insert.c 37c0c12c6eea72c4dad77699b963be370ca6cbd7d18270ff04f5fe9d6031622d F src/json.c 5b6a1d6015997b9ee848a32948720bdb26a0ef2de5a2127ebf7355ce66dbdc0d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9f5aeef3cbc2c95267c8f7bf60d5c66971a76789669fb0e8f853273ff6f616f2 -R 0dac77664f5c62d0dcc882ea3148d6f4 +P 8ff5dda8448d7e1a533d7f27db2573ce68fa9956b9d9847ced45e83c1f06bab0 +R c585d13f1a80cb4428e40ac20e746454 U drh -Z a11cd0d49c593b1144d9510fd31aa2a7 +Z ce4831b3d2660999f30841c855773e8f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ca5d536722..90e67e8d3a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ff5dda8448d7e1a533d7f27db2573ce68fa9956b9d9847ced45e83c1f06bab0 +b249516f6a6650808e035ec219e762bf24dcb7c32a6235984b995d08d07d35d8 diff --git a/src/build.c b/src/build.c index b585c19719..9cbedf1ec4 100644 --- a/src/build.c +++ b/src/build.c @@ -5005,11 +5005,13 @@ int sqlite3SrcItemAttachSubquery( Subquery *p; if( pSelect==0 ) return SQLITE_OK; assert( pItem->fg.isSubquery==0 ); - if( pItem->fg.fixedSchema==0 && pItem->u4.zDatabase!=0 ){ + if( pItem->fg.fixedSchema ){ + pItem->u4.pSchema = 0; + pItem->fg.fixedSchema = 0; + }else if( pItem->u4.zDatabase!=0 ){ sqlite3DbFree(pParse->db, pItem->u4.zDatabase); pItem->u4.zDatabase = 0; } - pItem->fg.fixedSchema = 0; if( dupSelect ){ pSelect = sqlite3SelectDup(pParse->db, pSelect, 0); if( pSelect==0 ) return 0; diff --git a/src/insert.c b/src/insert.c index d65ead2a0b..8214cd9c5c 100644 --- a/src/insert.c +++ b/src/insert.c @@ -585,9 +585,11 @@ void sqlite3AutoincrementEnd(Parse *pParse){ void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){ if( ALWAYS(pVal) && pVal->pSrc->nSrc>0 ){ SrcItem *pItem = &pVal->pSrc->a[0]; - assert( pItem->fg.isSubquery && pItem->u4.pSubq!=0 ); - sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->u4.pSubq->regReturn); - sqlite3VdbeJumpHere(pParse->pVdbe, pItem->u4.pSubq->addrFillSub - 1); + assert( (pItem->fg.isSubquery && pItem->u4.pSubq!=0) || pParse->nErr ); + if( pItem->fg.isSubquery ){ + sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->u4.pSubq->regReturn); + sqlite3VdbeJumpHere(pParse->pVdbe, pItem->u4.pSubq->addrFillSub - 1); + } } } From 27c680cc69f181a548d942168e45e37b498684a5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 17:24:42 +0000 Subject: [PATCH 0692/1030] Fix a memory leak so that now all dev tests (including TH3) are passing. FossilOrigin-Name: 3995c45fff0e4bd10bcf49cc16eb1050216426723c63ba56d3ae5ba738c34019 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 7 ++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 06a26110e0..a976440679 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Memory\sissues\sfixes\sso\sthat\smdevtest\snow\spasses. -D 2024-08-20T16:50:21.429 +C Fix\sa\smemory\sleak\sso\sthat\snow\sall\sdev\stests\s(including\sTH3)\sare\spassing. +D 2024-08-20T17:24:42.323 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/printf.c 17054fb94ffcf7a28362e9a5af4a0f813bd0c52200ae408eeebddc81feed9274 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 3e284895745f57de3b37b17fce9eb0e26bc54fccc94ea1ff5342be4360e3674b +F src/select.c 9aa44e562f2fbfa33e600e3f935369dd9a07e4beb89b344dfc7187dc2adc19ce F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8ff5dda8448d7e1a533d7f27db2573ce68fa9956b9d9847ced45e83c1f06bab0 -R c585d13f1a80cb4428e40ac20e746454 +P b249516f6a6650808e035ec219e762bf24dcb7c32a6235984b995d08d07d35d8 +R 5330111931e3ecff89186b5f2d6b0982 U drh -Z ce4831b3d2660999f30841c855773e8f +Z d58fa1c081ceed524dfd09ccfa304c4e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 90e67e8d3a..0ffd5cf0fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b249516f6a6650808e035ec219e762bf24dcb7c32a6235984b995d08d07d35d8 +3995c45fff0e4bd10bcf49cc16eb1050216426723c63ba56d3ae5ba738c34019 diff --git a/src/select.c b/src/select.c index 8bddc03bb4..0c10550fac 100644 --- a/src/select.c +++ b/src/select.c @@ -5600,12 +5600,17 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){ /* If we reach this point, that means the transformation is required. */ pParse = pWalker->pParse; + if( pParse->nErr ) return WRC_Abort; db = pParse->db; pNew = sqlite3DbMallocZero(db, sizeof(*pNew) ); if( pNew==0 ) return WRC_Abort; memset(&dummy, 0, sizeof(dummy)); pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0); - if( pNewSrc==0 ) return WRC_Abort; + assert( pNewSrc!=0 || pParse->nErr ); + if( pParse->nErr ){ + sqlite3SrcListDelete(db, pNewSrc); + return WRC_Abort; + } *pNew = *p; p->pSrc = pNewSrc; p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ASTERISK, 0)); From ff176231da8496e9fec72fe147eb60316f9c7f60 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 17:41:44 +0000 Subject: [PATCH 0693/1030] Fix some stray SrcItem field name fixes. FossilOrigin-Name: bc5f5ce59e1e4323422bda7d002310923f927a03b4fd42749bf04f6c9853956b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/delete.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index a976440679..614e098984 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sleak\sso\sthat\snow\sall\sdev\stests\s(including\sTH3)\sare\spassing. -D 2024-08-20T17:24:42.323 +C Fix\ssome\sstray\sSrcItem\sfield\sname\sfixes. +D 2024-08-20T17:41:44.355 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 -F src/delete.c 8aaf9d05d6ff6349a7a6001cbf90c7a46b19b9f52ef2e47aa0415a529d5307a1 +F src/delete.c 3638367ea4ed5d422ee1728a74f0b7a2973af9d7eef9b8b959c9c1f6e761ab8d F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 849049c74a4c68961154c124087b5c67d277217a2e642570d0c1bd6336859940 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b249516f6a6650808e035ec219e762bf24dcb7c32a6235984b995d08d07d35d8 -R 5330111931e3ecff89186b5f2d6b0982 +P 3995c45fff0e4bd10bcf49cc16eb1050216426723c63ba56d3ae5ba738c34019 +R 652ce342076e266e8f982c0969e3c6bc U drh -Z d58fa1c081ceed524dfd09ccfa304c4e +Z ae5f81dac74fb395c307223c199b02f0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0ffd5cf0fb..fa4bad2218 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3995c45fff0e4bd10bcf49cc16eb1050216426723c63ba56d3ae5ba738c34019 +bc5f5ce59e1e4323422bda7d002310923f927a03b4fd42749bf04f6c9853956b diff --git a/src/delete.c b/src/delete.c index 010a900191..1aa67c6a62 100644 --- a/src/delete.c +++ b/src/delete.c @@ -24,7 +24,7 @@ ** ** The following fields are initialized appropriate in pSrc: ** -** pSrc->a[0].pTab Pointer to the Table object +** pSrc->a[0].spTab Pointer to the Table object ** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one ** */ @@ -219,7 +219,7 @@ Expr *sqlite3LimitWhere( ** ); */ - pTab = pSrc->a[0].pTab; + pTab = pSrc->a[0].pSTab; if( HasRowid(pTab) ){ pLhs = sqlite3PExpr(pParse, TK_ROW, 0, 0); pEList = sqlite3ExprListAppend( @@ -252,9 +252,9 @@ Expr *sqlite3LimitWhere( /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree ** and the SELECT subtree. */ - pSrc->a[0].pTab = 0; + pSrc->a[0].pSTab = 0; pSelectSrc = sqlite3SrcListDup(db, pSrc, 0); - pSrc->a[0].pTab = pTab; + pSrc->a[0].pSTab = pTab; if( pSrc->a[0].fg.isIndexedBy ){ assert( pSrc->a[0].fg.isCte==0 ); pSrc->a[0].u2.pIBIndex = 0; From 692c160360c688c4bee3dd13d5293f2c416ad92f Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 19:09:59 +0000 Subject: [PATCH 0694/1030] Tighter checking of access constraints on union members in SrcItem. Improved invariant checking. FossilOrigin-Name: fd72d3400a8fe5747f494eee81654698acee350bb95b9db269e87d857af03492 --- manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/build.c | 11 ++++++++++- src/delete.c | 2 +- src/fkey.c | 2 +- src/insert.c | 1 + src/select.c | 4 ++++ src/sqliteInt.h | 30 +++++++++++++++++------------- src/trigger.c | 6 ++++-- 9 files changed, 51 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index 614e098984..298d9f0ab3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sstray\sSrcItem\sfield\sname\sfixes. -D 2024-08-20T17:41:44.355 +C Tighter\schecking\sof\saccess\sconstraints\son\sunion\smembers\sin\sSrcItem.\nImproved\sinvariant\schecking. +D 2024-08-20T19:09:59.313 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -702,24 +702,24 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 29ebc26d90a9d6e860a3018a6d61fb667c80ec8e80e3798c4164d2349ba28650 +F src/build.c 69d79a255a6a0547f5e99a1726c3cbd363fa221c4f0458425abc7ba59efb9f83 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 -F src/delete.c 3638367ea4ed5d422ee1728a74f0b7a2973af9d7eef9b8b959c9c1f6e761ab8d +F src/delete.c cfe1a09cd67e3c8aef51ef928c69ba2824e6e2439f451e990afbb89e774add01 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 -F src/fkey.c 849049c74a4c68961154c124087b5c67d277217a2e642570d0c1bd6336859940 +F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f F src/func.c 1f61e32e7a357e615b5d2e774bee563761fce4f2fd97ecb0f72c33e62a2ada5f F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 37c0c12c6eea72c4dad77699b963be370ca6cbd7d18270ff04f5fe9d6031622d +F src/insert.c f8d1a0f8ee258411009c6b7f2d93170e351bd19f5ad89d57e1180644297cbe70 F src/json.c 5b6a1d6015997b9ee848a32948720bdb26a0ef2de5a2127ebf7355ce66dbdc0d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -760,12 +760,12 @@ F src/printf.c 17054fb94ffcf7a28362e9a5af4a0f813bd0c52200ae408eeebddc81feed9274 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 9aa44e562f2fbfa33e600e3f935369dd9a07e4beb89b344dfc7187dc2adc19ce +F src/select.c 7addcd53d8f9bef2d47a7e47faeb1f6e401dba02f1f338f532298a24657ea4e6 F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 630e356b7d94df1dcbc32d4f7d4569725a12c6de014fe064311219c22d9cbd54 +F src/sqliteInt.h 521a9abd808e2b6c2e377cfc85b5ad5508202c33f878f929dccf60d6aca13034 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -825,7 +825,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 F src/treeview.c e98dbc8068d27f3d0bd2a4cebfce6a7c21c776edc23d80e12c67a70cd2ba3fe5 -F src/trigger.c 68d849ea6ccab67beb450d1a0d065c6118f0884a779388b07f0d9a27dbda38c9 +F src/trigger.c 0bb986a5b96047fd597c6aac28588853df56064e576e6b81ba777ef2ccaac461 F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3995c45fff0e4bd10bcf49cc16eb1050216426723c63ba56d3ae5ba738c34019 -R 652ce342076e266e8f982c0969e3c6bc +P bc5f5ce59e1e4323422bda7d002310923f927a03b4fd42749bf04f6c9853956b +R ee08ce1ecc132f8a5f905e65ae160cc1 U drh -Z ae5f81dac74fb395c307223c199b02f0 +Z 01685802d904a82a17f4e5855c564d7e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fa4bad2218..06a9d2670a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc5f5ce59e1e4323422bda7d002310923f927a03b4fd42749bf04f6c9853956b +fd72d3400a8fe5747f494eee81654698acee350bb95b9db269e87d857af03492 diff --git a/src/build.c b/src/build.c index 9cbedf1ec4..b2386035d8 100644 --- a/src/build.c +++ b/src/build.c @@ -501,6 +501,7 @@ Table *sqlite3LocateTableItem( int iDb = sqlite3SchemaToIndex(pParse->db, p->u4.pSchema); zDb = pParse->db->aDb[iDb].zDbSName; }else{ + assert( !p->fg.isSubquery ); zDb = p->u4.zDatabase; } return sqlite3LocateTable(pParse, flags, p->zName, zDb); @@ -3487,6 +3488,7 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){ assert( pParse->nErr==0 ); assert( pName->nSrc==1 ); assert( pName->a[0].fg.fixedSchema==0 ); + assert( pName->a[0].fg.isSubquery==0 ); if( sqlite3ReadSchema(pParse) ) goto exit_drop_table; if( noErr ) db->suppressErr++; assert( isView==0 || isView==LOCATE_VIEW ); @@ -4587,6 +4589,7 @@ void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){ assert( pParse->nErr==0 ); /* Never called with prior non-OOM errors */ assert( pName->nSrc==1 ); assert( pName->a[0].fg.fixedSchema==0 ); + assert( pName->a[0].fg.isSubquery==0 ); if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ goto exit_drop_index; } @@ -4893,6 +4896,7 @@ SrcList *sqlite3SrcListAppend( pDatabase = 0; } assert( pItem->fg.fixedSchema==0 ); + assert( pItem->fg.isSubquery==0 ); if( pDatabase ){ pItem->zName = sqlite3NameFromToken(db, pDatabase); pItem->u4.zDatabase = sqlite3NameFromToken(db, pTable); @@ -4959,8 +4963,13 @@ void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ for(pItem=pList->a, i=0; inSrc; i++, pItem++){ /* Check invariants on SrcItem */ + assert( !pItem->fg.isIndexedBy || !pItem->fg.isTabFunc ); + assert( !pItem->fg.isCte || !pItem->fg.isIndexedBy ); assert( !pItem->fg.hadSchema || !pItem->fg.isSubquery ); - assert( pItem->fg.hadSchema==0 || pItem->fg.fixedSchema==1 ); + assert( !pItem->fg.hadSchema || pItem->fg.fixedSchema ); + assert( !pItem->fg.fixedSchema || !pItem->fg.isSubquery ); + assert( !pItem->fg.isSubquery || (pItem->u4.pSubq!=0 && + pItem->u4.pSubq->pSelect!=0) ); if( pItem->zName ) sqlite3DbNNFreeNN(db, pItem->zName); if( pItem->zAlias ) sqlite3DbNNFreeNN(db, pItem->zAlias); diff --git a/src/delete.c b/src/delete.c index 1aa67c6a62..1d7ba66a22 100644 --- a/src/delete.c +++ b/src/delete.c @@ -156,7 +156,7 @@ void sqlite3MaterializeView( if( pFrom ){ assert( pFrom->nSrc==1 ); pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName); - assert( pFrom->a[0].fg.fixedSchema==0 ); + assert( pFrom->a[0].fg.fixedSchema==0 && pFrom->a[0].fg.isSubquery==0 ); pFrom->a[0].u4.zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); assert( pFrom->a[0].fg.isUsing==0 ); assert( pFrom->a[0].u3.pOn==0 ); diff --git a/src/fkey.c b/src/fkey.c index cd1f88502e..f1117a8845 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1337,7 +1337,7 @@ static Trigger *fkActionTrigger( if( pSrc ){ assert( pSrc->nSrc==1 ); pSrc->a[0].zName = sqlite3DbStrDup(db, zFrom); - assert( pSrc->a[0].fg.fixedSchema==0 ); + assert( pSrc->a[0].fg.fixedSchema==0 && pSrc->a[0].fg.isSubquery==0 ); pSrc->a[0].u4.zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); } pSelect = sqlite3SelectNew(pParse, diff --git a/src/insert.c b/src/insert.c index 8214cd9c5c..d380281bed 100644 --- a/src/insert.c +++ b/src/insert.c @@ -729,6 +729,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ p = &pRet->pSrc->a[0]; p->fg.viaCoroutine = 1; p->iCursor = -1; + assert( !p->fg.isIndexedBy && !p->fg.isTabFunc ); p->u1.nRow = 2; if( sqlite3SrcItemAttachSubquery(pParse, p, pLeft, 0) ){ pSubq = p->u4.pSubq; diff --git a/src/select.c b/src/select.c index 0c10550fac..39955dd60a 100644 --- a/src/select.c +++ b/src/select.c @@ -4522,6 +4522,7 @@ static int flattenSubquery( }else{ pSub1 = 0; } + assert( pSubitem->fg.isSubquery==0 ); if( pSubitem->fg.fixedSchema==0 ){ sqlite3DbFree(db, pSubitem->u4.zDatabase); pSubitem->u4.zDatabase = 0; @@ -5812,6 +5813,7 @@ static int resolveFromTermToCte( sqlite3ErrorMsg(pParse, "no such index: \"%s\"", pFrom->u1.zIndexedBy); return 2; } + assert( !pFrom->fg.isIndexedBy ); pFrom->fg.isCte = 1; pFrom->u2.pCteUse = pCteUse; pCteUse->nUse++; @@ -7728,6 +7730,8 @@ int sqlite3Select( if( pItem->fg.fixedSchema ){ int iDb = sqlite3SchemaToIndex(pParse->db, pItem->u4.pSchema); zDb = db->aDb[iDb].zDbSName; + }else if( pItem->fg.isSubquery ){ + zDb = 0; }else{ zDb = pItem->u4.zDatabase; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c282023de4..9e0faf9cc1 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3298,26 +3298,30 @@ struct Subquery { ** In the colUsed field, the high-order bit (bit 63) is set if the table ** contains more than 63 columns and the 64-th or later column is used. ** -** Intenstive use of "union" helps keep the size of the object small. This -** has been shown to boost performance due to less time spend initializing -** fields to zero when a new instance of this object is allocated. The unions -** also help SrcItem, and hence SrcList and Select, use less memory. -** -** Union member validity: +** Aggressive use of "union" helps keep the size of the object small. This +** has been shown to boost performance, in addition to saving memory. +** Access to union elements is gated by the following rules which should +** always be checked, either by an if-statement or by an assert(). ** +** Field Only access if this is true +** --------------- ----------------------------------- ** u1.zIndexedBy fg.isIndexedBy ** u1.pFuncArg fg.isTabFunc ** u1.nRow !fg.isTabFunc && !fg.isIndexedBy ** -** u2.pIBIndex fg.isIndexedBy && !fg.isCte -** u2.pCteUse fg.isCte && !fg.isIndexedBy +** u2.pIBIndex fg.isIndexedBy +** u2.pCteUse fg.isCte ** -** u3.pOn fg.isUsing==0 -** u3.pUsing fg.isUsing==1 +** u3.pOn !fg.isUsing +** u3.pUsing fg.isUsing ** -** u4.zDatabase fg.fixedSchema==0 && !fg.isSubquery -** u4.pSchema fg.fixedSchema==1 +** u4.zDatabase !fg.fixedSchema && !fg.isSubquery +** u4.pSchema fg.fixedSchema ** u4.pSubq fg.isSubquery +** +** See also the sqlite3SrcListDelete() routine for assert() statements that +** check invariants on the fields of this object, especially the flags +** inside the fg struct. */ struct SrcItem { char *zName; /* Name of the table */ @@ -3342,7 +3346,7 @@ struct SrcItem { unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */ unsigned rowidUsed :1; /* The ROWID of this table is referenced */ unsigned fixedSchema :1; /* Uses u4.pSchema, not u4.zDatabase */ - unsigned hadSchema :1; /* Has u4.zDatabase before u4.pSchema */ + unsigned hadSchema :1; /* Had u4.zDatabase before u4.pSchema */ } fg; int iCursor; /* The VDBE cursor number used to access this table */ Bitmask colUsed; /* Bit N set if column N used. Details above for N>62 */ diff --git a/src/trigger.c b/src/trigger.c index 170f094eab..ff2df82cbc 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -151,7 +151,9 @@ void sqlite3BeginTrigger( ** To maintain backwards compatibility, ignore the database ** name on pTableName if we are reparsing out of the schema table */ - if( db->init.busy && iDb!=1 && ALWAYS(pTableName->a[0].fg.fixedSchema==0) ){ + if( db->init.busy && iDb!=1 ){ + assert( pTableName->a[0].fg.fixedSchema==0 ); + assert( pTableName->a[0].fg.isSubquery==0 ); sqlite3DbFree(db, pTableName->a[0].u4.zDatabase); pTableName->a[0].u4.zDatabase = 0; } @@ -631,7 +633,7 @@ void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){ } assert( pName->nSrc==1 ); - assert( pName->a[0].fg.fixedSchema==0 ); + assert( pName->a[0].fg.fixedSchema==0 && pName->a[0].fg.isSubquery==0 ); zDb = pName->a[0].u4.zDatabase; zName = pName->a[0].zName; assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) ); From 0766cbf51157671e39e9109303bf315c661616ac Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 20:01:21 +0000 Subject: [PATCH 0695/1030] Remove unreachable code. FossilOrigin-Name: 17699329aa8e234c6793a38db5ca05def9395b287bcc8bc05493b824327edb59 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/build.c | 2 +- src/parse.y | 5 ++--- src/printf.c | 4 +--- src/select.c | 6 +----- 6 files changed, 15 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 298d9f0ab3..347a5b8ce1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tighter\schecking\sof\saccess\sconstraints\son\sunion\smembers\sin\sSrcItem.\nImproved\sinvariant\schecking. -D 2024-08-20T19:09:59.313 +C Remove\sunreachable\scode. +D 2024-08-20T20:01:21.013 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -702,7 +702,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c 69d79a255a6a0547f5e99a1726c3cbd363fa221c4f0458425abc7ba59efb9f83 +F src/build.c c5522b5faf8128227678e194275cefaeb4d063f55dbe70bcff745f1b63a187cf F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 @@ -749,18 +749,18 @@ F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a -F src/parse.y 967e0a712de8bee4b2cf82bd9efa36b68afd03cc486d4ea77a945feb49b057dc +F src/parse.y 5972b7d00af4c8d96fdad781af1ea1d5d51fc3b907ad61bda60e49503274e5ed F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce -F src/printf.c 17054fb94ffcf7a28362e9a5af4a0f813bd0c52200ae408eeebddc81feed9274 +F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 7addcd53d8f9bef2d47a7e47faeb1f6e401dba02f1f338f532298a24657ea4e6 +F src/select.c 6f1651ca254a6856c2ec5b8a0188bc226e7a454d6741d3f71ebcd631ce147807 F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bc5f5ce59e1e4323422bda7d002310923f927a03b4fd42749bf04f6c9853956b -R ee08ce1ecc132f8a5f905e65ae160cc1 +P fd72d3400a8fe5747f494eee81654698acee350bb95b9db269e87d857af03492 +R ed1ab5c9cb5cf9505f2201c6b302f119 U drh -Z 01685802d904a82a17f4e5855c564d7e +Z 40ddef7af9ce2e2b1803942ebd50a97a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 06a9d2670a..33f57517e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd72d3400a8fe5747f494eee81654698acee350bb95b9db269e87d857af03492 +17699329aa8e234c6793a38db5ca05def9395b287bcc8bc05493b824327edb59 diff --git a/src/build.c b/src/build.c index b2386035d8..74577ed0d5 100644 --- a/src/build.c +++ b/src/build.c @@ -5012,7 +5012,7 @@ int sqlite3SrcItemAttachSubquery( int dupSelect /* If true, attach a copy of pSelect, not pSelect itself.*/ ){ Subquery *p; - if( pSelect==0 ) return SQLITE_OK; + assert( pSelect!=0 ); assert( pItem->fg.isSubquery==0 ); if( pItem->fg.fixedSchema ){ pItem->u4.pSchema = 0; diff --git a/src/parse.y b/src/parse.y index a47c587547..926dd6e7d1 100644 --- a/src/parse.y +++ b/src/parse.y @@ -748,9 +748,8 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z) on_using(N pNew->u4.pSubq = pOld->u4.pSubq; pOld->u4.pSubq = 0; pOld->fg.isSubquery = 0; - if( pNew->u4.pSubq->pSelect - && (pNew->u4.pSubq->pSelect->selFlags & SF_NestedFrom)!=0 - ){ + assert( pNew->u4.pSubq!=0 && pNew->u4.pSubq->pSelect!=0 ); + if( (pNew->u4.pSubq->pSelect->selFlags & SF_NestedFrom)!=0 ){ pNew->fg.isNestedFrom = 1; } }else{ diff --git a/src/printf.c b/src/printf.c index be7ffc8c76..a140565146 100644 --- a/src/printf.c +++ b/src/printf.c @@ -858,7 +858,7 @@ void sqlite3_str_vappendf( sqlite3_str_appendall(pAccum, pItem->zName); }else if( pItem->zAlias ){ sqlite3_str_appendall(pAccum, pItem->zAlias); - }else if( pItem->fg.isSubquery ){/* Because of tag-20240424-1 */ + }else if( ALWAYS(pItem->fg.isSubquery) ){/* Because of tag-20240424-1 */ Select *pSel = pItem->u4.pSubq->pSelect; assert( pSel!=0 ); if( pSel->selFlags & SF_NestedFrom ){ @@ -870,8 +870,6 @@ void sqlite3_str_vappendf( }else{ sqlite3_str_appendf(pAccum, "(subquery-%u)", pSel->selId); } - }else{ - sqlite3_str_appendf(pAccum, "(unknown-data-source-%p)", pItem); } length = width = 0; break; diff --git a/src/select.c b/src/select.c index 39955dd60a..655221b067 100644 --- a/src/select.c +++ b/src/select.c @@ -4523,10 +4523,7 @@ static int flattenSubquery( pSub1 = 0; } assert( pSubitem->fg.isSubquery==0 ); - if( pSubitem->fg.fixedSchema==0 ){ - sqlite3DbFree(db, pSubitem->u4.zDatabase); - pSubitem->u4.zDatabase = 0; - } + assert( pSubitem->fg.fixedSchema==0 ); sqlite3DbFree(db, pSubitem->zName); sqlite3DbFree(db, pSubitem->zAlias); pSubitem->zName = 0; @@ -5601,7 +5598,6 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){ /* If we reach this point, that means the transformation is required. */ pParse = pWalker->pParse; - if( pParse->nErr ) return WRC_Abort; db = pParse->db; pNew = sqlite3DbMallocZero(db, sizeof(*pNew) ); if( pNew==0 ) return WRC_Abort; From bb36d55e638fb7f8ba1c1ce787b835f398fc98d3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 22:05:01 +0000 Subject: [PATCH 0696/1030] Fix minor comment issues. FossilOrigin-Name: c1bbed19f4348ec31c3cb4723eaa8f1554bb58ef4de7feb3a0f39612785f13d5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/delete.c | 4 ++-- src/sqliteInt.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 347a5b8ce1..72fecdb486 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunreachable\scode. -D 2024-08-20T20:01:21.013 +C Fix\sminor\scomment\sissues. +D 2024-08-20T22:05:01.213 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -709,7 +709,7 @@ F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 F src/date.c 13dd752847afb32ed70510ad7345a5b9c841f51ad904dba5d010f1fa3a6a324e F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 -F src/delete.c cfe1a09cd67e3c8aef51ef928c69ba2824e6e2439f451e990afbb89e774add01 +F src/delete.c 444c4d1eaac40103461e3b6f0881846dd3aafc1cec1dd169d3482fa331667da7 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f @@ -765,7 +765,7 @@ F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab6770 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 521a9abd808e2b6c2e377cfc85b5ad5508202c33f878f929dccf60d6aca13034 +F src/sqliteInt.h 28c878bdf528879afefe1994ac007d094f8061f2fdacdc55d6055d7e9341151e F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fd72d3400a8fe5747f494eee81654698acee350bb95b9db269e87d857af03492 -R ed1ab5c9cb5cf9505f2201c6b302f119 +P 17699329aa8e234c6793a38db5ca05def9395b287bcc8bc05493b824327edb59 +R 0e51c42305c6bc1152097a45ebccdb0d U drh -Z 40ddef7af9ce2e2b1803942ebd50a97a +Z a6fa404293297d6b35cfa7a7af20f07b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 33f57517e4..b77c8e18bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -17699329aa8e234c6793a38db5ca05def9395b287bcc8bc05493b824327edb59 +c1bbed19f4348ec31c3cb4723eaa8f1554bb58ef4de7feb3a0f39612785f13d5 diff --git a/src/delete.c b/src/delete.c index 1d7ba66a22..4cdb3946e3 100644 --- a/src/delete.c +++ b/src/delete.c @@ -24,8 +24,8 @@ ** ** The following fields are initialized appropriate in pSrc: ** -** pSrc->a[0].spTab Pointer to the Table object -** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one +** pSrc->a[0].spTab Pointer to the Table object +** pSrc->a[0].u2.pIBIndex Pointer to the INDEXED BY index, if there is one ** */ Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 9e0faf9cc1..d1ffce6d87 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3627,7 +3627,7 @@ struct Select { #define SF_UpdateFrom 0x10000000 /* Query originates with UPDATE FROM */ #define SF_Correlated 0x20000000 /* True if references the outer context */ -/* True if SrcList item X is a subquery that has SF_NestedFrom */ +/* True if SrcItem X is a subquery that has SF_NestedFrom */ #define IsNestedFrom(X) \ ((X)->fg.isSubquery && \ ((X)->u4.pSubq->pSelect->selFlags&SF_NestedFrom)!=0) From a0651b370706e58f9014453c5f36124ca8a738c9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 20 Aug 2024 22:44:40 +0000 Subject: [PATCH 0697/1030] Fix a name resolution issue with CTEs. FossilOrigin-Name: 4fa8235dd59cd683d6c6c97bfe181a9637be7c054d435323c903b9dbd74aff02 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 7 ++++--- test/with2.test | 11 ++++++++++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 72fecdb486..7ee60fbf49 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sminor\scomment\sissues. -D 2024-08-20T22:05:01.213 +C Fix\sa\sname\sresolution\sissue\swith\sCTEs. +D 2024-08-20T22:44:40.653 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -760,7 +760,7 @@ F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 6f1651ca254a6856c2ec5b8a0188bc226e7a454d6741d3f71ebcd631ce147807 +F src/select.c c1c28650d3ea5dc0670dd658600b963c29a5c31b685941a5df583b02631d04ff F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2070,7 +2070,7 @@ F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3c F test/windowfault.test 15094c1529424e62f798bc679e3fe9dfab6e8ba2f7dfe8c923b6248c31660a7c F test/windowpushd.test c420e2265f0e09a0e798d0513a660d71b51602088d81b3dbd038918ee1339dcc F test/with1.test b93833890e5d2a368e78747f124503a0159aa029b98e9ed4795ebf630b2efd3d -F test/with2.test 5885f0ef250504096ea4c0c6350ef2f2ab09b9e2dc2bc691e182f773db3aabb2 +F test/with2.test 181674a6cc86a601ca2ac052741cdfad5b529e07e870435d2f6cdb92d589ff17 F test/with3.test e30369ea27aa27eb1bda4c5e510c8a9f782c8afd2ab99d1a02b8a7f25a5d3e65 F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205 F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8 @@ -2205,8 +2205,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 17699329aa8e234c6793a38db5ca05def9395b287bcc8bc05493b824327edb59 -R 0e51c42305c6bc1152097a45ebccdb0d +P c1bbed19f4348ec31c3cb4723eaa8f1554bb58ef4de7feb3a0f39612785f13d5 +R 1c80ace1a0877505f5ca5ebb5b98295b U drh -Z a6fa404293297d6b35cfa7a7af20f07b +Z ef82496d97c0311a270f63ff1146b092 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b77c8e18bf..53632b3479 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c1bbed19f4348ec31c3cb4723eaa8f1554bb58ef4de7feb3a0f39612785f13d5 +4fa8235dd59cd683d6c6c97bfe181a9637be7c054d435323c903b9dbd74aff02 diff --git a/src/select.c b/src/select.c index 655221b067..b76e42b74c 100644 --- a/src/select.c +++ b/src/select.c @@ -5823,9 +5823,10 @@ static int resolveFromTermToCte( assert( pRecTerm->pPrior!=0 ); for(i=0; inSrc; i++){ SrcItem *pItem = &pSrc->a[i]; - if( ((pItem->fg.fixedSchema==0 && pItem->u4.zDatabase==0) - || pItem->fg.hadSchema==0) - && pItem->zName!=0 + if( pItem->zName!=0 + && !pItem->fg.hadSchema + && ALWAYS( !pItem->fg.isSubquery ) + && (pItem->fg.fixedSchema || pItem->u4.zDatabase==0) && 0==sqlite3StrICmp(pItem->zName, pCte->zName) ){ pItem->pSTab = pTab; diff --git a/test/with2.test b/test/with2.test index ad1753d659..68790fe860 100644 --- a/test/with2.test +++ b/test/with2.test @@ -146,7 +146,6 @@ do_execsql_test 1.14 { SELECT * FROM t4; } {4 5 6 7 8 9 10} -exit do_execsql_test 1.15 { WITH t4(x) AS ( @@ -157,6 +156,16 @@ do_execsql_test 1.15 { SELECT * FROM t4; } {4 5} +do_execsql_test 1.15.2 { + WITH + t4(x) AS ( + VALUES(4) + UNION ALL + SELECT x+1 FROM (SELECT * FROM main.t4) WHERE x<10 + ) + SELECT * FROM t4; +} {4 5} + do_catchsql_test 1.16 { WITH t4(x) AS ( From 8c58fd78c39baca9820ed4c6d6a74ad16e08c9d6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Aug 2024 07:38:14 +0000 Subject: [PATCH 0698/1030] Remove incorrect assert() statements in the SrcItem invariant validator. dbsqlfuzz 7f908865436ce531b0ace55c97a1c71d05c4e76c. FossilOrigin-Name: 81a1ede38823b8d50e221ecb6ce52a05d82a856099002a71d9f1ac561a587f05 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/build.c | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index de163306d5..0d53a2be4d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Refactor\sthe\sSrcItem\sobject\sto\smove\sfields\sassociated\swith\ssubqueries\sout\ninto\sa\sseparate\sobject\snamed\sSubquery.\s\sThis\sreduces\sthe\ssize\sof\sthe\sSrcItem\nobject\sby\sabout\s1/3rd\sand\sprovides\simproved\sperformance. -D 2024-08-20T23:11:28.443 +C Remove\sincorrect\sassert()\sstatements\sin\sthe\sSrcItem\sinvariant\svalidator.\ndbsqlfuzz\s7f908865436ce531b0ace55c97a1c71d05c4e76c. +D 2024-08-21T07:38:14.508 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -706,7 +706,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c c5522b5faf8128227678e194275cefaeb4d063f55dbe70bcff745f1b63a187cf +F src/build.c 3a1840d9d171ce2d24f4c1f7acda7266ab796c664290c1acba65ff98ce2bd01e F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3399698376761ab8c422f8ea02bfa2759afb606f08bedbd1cf7eee834229a9aa 4fa8235dd59cd683d6c6c97bfe181a9637be7c054d435323c903b9dbd74aff02 -R 82a6023b6446e680173d0de603e0e98e +P 484bcd75bc95491d8540c791c1c4d40d996cb465839564662e14f98739699bf1 +R 136086d644c5a2efc92647bc4c586910 U drh -Z cc2792cc7e3d54684569210f9c97c9df +Z 029346cb8d0ee71c8f522bf954942df0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c96f758867..326f56a63a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -484bcd75bc95491d8540c791c1c4d40d996cb465839564662e14f98739699bf1 +81a1ede38823b8d50e221ecb6ce52a05d82a856099002a71d9f1ac561a587f05 diff --git a/src/build.c b/src/build.c index 74577ed0d5..943d862e97 100644 --- a/src/build.c +++ b/src/build.c @@ -4965,8 +4965,6 @@ void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ /* Check invariants on SrcItem */ assert( !pItem->fg.isIndexedBy || !pItem->fg.isTabFunc ); assert( !pItem->fg.isCte || !pItem->fg.isIndexedBy ); - assert( !pItem->fg.hadSchema || !pItem->fg.isSubquery ); - assert( !pItem->fg.hadSchema || pItem->fg.fixedSchema ); assert( !pItem->fg.fixedSchema || !pItem->fg.isSubquery ); assert( !pItem->fg.isSubquery || (pItem->u4.pSubq!=0 && pItem->u4.pSubq->pSelect!=0) ); From fb7d0c3c01ce94e2704e6e9878bde247daa156d8 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 21 Aug 2024 09:56:45 +0000 Subject: [PATCH 0699/1030] De-duplicate some error-output code in shell.c.in as part of tracking down the cause of [forum:5647ca2af1|forum post 5647ca2af1]. FossilOrigin-Name: fd5904495e0c775174f9380bc6877fb9def3d30dec1c9315979ad4503a18d70b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 35 ++++++++++++++++++++--------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 0d53a2be4d..3c85ec36eb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sincorrect\sassert()\sstatements\sin\sthe\sSrcItem\sinvariant\svalidator.\ndbsqlfuzz\s7f908865436ce531b0ace55c97a1c71d05c4e76c. -D 2024-08-21T07:38:14.508 +C De-duplicate\ssome\serror-output\scode\sin\sshell.c.in\sas\spart\sof\stracking\sdown\sthe\scause\sof\s[forum:5647ca2af1|forum\spost\s5647ca2af1]. +D 2024-08-21T09:56:45.002 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -765,7 +765,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 44d135bbea93872a7318f048d9d6e566b1c3eaa92d6dabe06e4741aa78d1c1ec -F src/shell.c.in 94571558b0fb28c37a5cf6dbd6ea27285341023a28a8cb5795cd2768fab67704 +F src/shell.c.in fb7fe0a39473e7a3ad5ad7076ff49d87aa8ed7fdd98a1595345747ac5d78ac2b F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 484bcd75bc95491d8540c791c1c4d40d996cb465839564662e14f98739699bf1 -R 136086d644c5a2efc92647bc4c586910 -U drh -Z 029346cb8d0ee71c8f522bf954942df0 +P 81a1ede38823b8d50e221ecb6ce52a05d82a856099002a71d9f1ac561a587f05 +R 7dfeb7387454a33b7099aec64d81efae +U stephan +Z b55d6e3262271daffaa830513ab83e17 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 326f56a63a..f487a539aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -81a1ede38823b8d50e221ecb6ce52a05d82a856099002a71d9f1ac561a587f05 +fd5904495e0c775174f9380bc6877fb9def3d30dec1c9315979ad4503a18d70b diff --git a/src/shell.c.in b/src/shell.c.in index 5b0a1a84b0..8c4fcc4e12 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -6343,12 +6343,17 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){ } #endif /* SQLITE_SHELL_HAVE_RECOVER */ +/* +** Print the given string as an error message. +*/ +static void shellEmitError(const char *zErr){ + eputf("Error: %s\n", zErr); +} /* ** Print the current sqlite3_errmsg() value to stderr and return 1. */ static int shellDatabaseError(sqlite3 *db){ - const char *zErr = sqlite3_errmsg(db); - eputf("Error: %s\n", zErr); + shellEmitError(sqlite3_errmsg(db)); return 1; } @@ -6893,7 +6898,7 @@ static int arErrorMsg(ArCommand *pAr, const char *zFmt, ...){ va_start(ap, zFmt); z = sqlite3_vmprintf(zFmt, ap); va_end(ap); - eputf("Error: %s\n", z); + shellEmitError(z); if( pAr->fromCmdLine ){ eputz("Use \"-A\" for more help\n"); }else{ @@ -8124,7 +8129,7 @@ static int do_meta_command(char *zLine, ShellState *p){ open_db(p, 0); pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb); if( pBackup==0 ){ - eputf("Error: %s\n", sqlite3_errmsg(pDest)); + shellDatabaseError(pDest); close_db(pDest); return 1; } @@ -8133,7 +8138,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( rc==SQLITE_DONE ){ rc = 0; }else{ - eputf("Error: %s\n", sqlite3_errmsg(pDest)); + shellDatabaseError(pDest); rc = 1; } close_db(pDest); @@ -8309,7 +8314,7 @@ static int do_meta_command(char *zLine, ShellState *p){ open_db(p, 0); rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0); if( rc ){ - eputf("Error: %s\n", sqlite3_errmsg(p->db)); + shellDatabaseError(p->db); rc = 1; }else{ while( sqlite3_step(pStmt)==SQLITE_ROW ){ @@ -9005,7 +9010,7 @@ static int do_meta_command(char *zLine, ShellState *p){ zSql = 0; if( rc ){ if (pStmt) sqlite3_finalize(pStmt); - eputf("Error: %s\n", sqlite3_errmsg(p->db)); + shellDatabaseError(p->db); import_cleanup(&sCtx); rc = 1; goto meta_command_exit; @@ -9049,7 +9054,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_free(zSql); zSql = 0; if( rc ){ - eputf("Error: %s\n", sqlite3_errmsg(p->db)); + shellDatabaseError(p->db); if (pStmt) sqlite3_finalize(pStmt); import_cleanup(&sCtx); rc = 1; @@ -9343,7 +9348,7 @@ static int do_meta_command(char *zLine, ShellState *p){ open_db(p, 0); rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg); if( rc!=SQLITE_OK ){ - eputf("Error: %s\n", zErrMsg); + shellEmitError(zErrMsg); sqlite3_free(zErrMsg); rc = 1; } @@ -9965,7 +9970,7 @@ static int do_meta_command(char *zLine, ShellState *p){ open_db(p, 0); pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main"); if( pBackup==0 ){ - eputf("Error: %s\n", sqlite3_errmsg(p->db)); + shellDatabaseError(p->db); close_db(pSrc); return 1; } @@ -9983,7 +9988,7 @@ static int do_meta_command(char *zLine, ShellState *p){ eputz("Error: source database is busy\n"); rc = 1; }else{ - eputf("Error: %s\n", sqlite3_errmsg(p->db)); + shellDatabaseError(p->db); rc = 1; } close_db(pSrc); @@ -10080,7 +10085,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = sqlite3_prepare_v2(p->db, "SELECT name FROM pragma_database_list", -1, &pStmt, 0); if( rc ){ - eputf("Error: %s\n", sqlite3_errmsg(p->db)); + shellDatabaseError(p->db); sqlite3_finalize(pStmt); rc = 1; goto meta_command_exit; @@ -10149,7 +10154,7 @@ static int do_meta_command(char *zLine, ShellState *p){ freeText(&sSelect); } if( zErrMsg ){ - eputf("Error: %s\n", zErrMsg); + shellEmitError(zErrMsg); sqlite3_free(zErrMsg); rc = 1; }else if( rc != SQLITE_OK ){ @@ -12728,7 +12733,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ open_db(&data, 0); rc = shell_exec(&data, z, &zErrMsg); if( zErrMsg!=0 ){ - eputf("Error: %s\n", zErrMsg); + shellEmitError(zErrMsg); if( bail_on_error ) return rc!=0 ? rc : 1; }else if( rc!=0 ){ eputf("Error: unable to process SQL \"%s\"\n", z); @@ -12782,7 +12787,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ rc = shell_exec(&data, azCmd[i], &zErrMsg); if( zErrMsg || rc ){ if( zErrMsg!=0 ){ - eputf("Error: %s\n", zErrMsg); + shellEmitError(zErrMsg); }else{ eputf("Error: unable to process SQL: %s\n", azCmd[i]); } From 01972f55fe9e73b0cc20d71d156aae3473af3d06 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Aug 2024 10:32:00 +0000 Subject: [PATCH 0700/1030] Improvements to treetrace output for subqueries. Debug code only. FossilOrigin-Name: 0a835d18d9063b17a1d506fd989ebcf7f0d76593978a3bd5981be59618335f21 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/treeview.c | 9 ++++++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 3c85ec36eb..e8e708addf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C De-duplicate\ssome\serror-output\scode\sin\sshell.c.in\sas\spart\sof\stracking\sdown\sthe\scause\sof\s[forum:5647ca2af1|forum\spost\s5647ca2af1]. -D 2024-08-21T09:56:45.002 +C Improvements\sto\streetrace\soutput\sfor\ssubqueries.\s\sDebug\scode\sonly. +D 2024-08-21T10:32:00.693 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -828,7 +828,7 @@ F src/test_window.c 6d80e11fba89a1796525e6f0048ff0c7789aa2c6b0b11c80827dc1437bd8 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3f703cacdab728d7741e5a6ac242006d74fe1c2754d4f03ed889d7253259bd68 -F src/treeview.c e98dbc8068d27f3d0bd2a4cebfce6a7c21c776edc23d80e12c67a70cd2ba3fe5 +F src/treeview.c 88aa39b754f5ef7214385c1bbbdd2f3dc20efafeed0cf590e8d1199b9c6e44aa F src/trigger.c 0bb986a5b96047fd597c6aac28588853df56064e576e6b81ba777ef2ccaac461 F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 81a1ede38823b8d50e221ecb6ce52a05d82a856099002a71d9f1ac561a587f05 -R 7dfeb7387454a33b7099aec64d81efae -U stephan -Z b55d6e3262271daffaa830513ab83e17 +P fd5904495e0c775174f9380bc6877fb9def3d30dec1c9315979ad4503a18d70b +R 9b61fbb833ee0abcfc996b0de63e571b +U drh +Z 56e8c0285d76008f8c95bfad3d078586 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f487a539aa..0090278b24 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd5904495e0c775174f9380bc6877fb9def3d30dec1c9315979ad4503a18d70b +0a835d18d9063b17a1d506fd989ebcf7f0d76593978a3bd5981be59618335f21 diff --git a/src/treeview.c b/src/treeview.c index dbd54b3466..de67161229 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -226,6 +226,9 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ if( pItem->fg.viaCoroutine ) sqlite3_str_appendf(&x, " viaCoroutine"); if( pItem->fg.notCte ) sqlite3_str_appendf(&x, " notCte"); if( pItem->fg.isNestedFrom ) sqlite3_str_appendf(&x, " isNestedFrom"); + if( pItem->fg.fixedSchema ) sqlite3_str_appendf(&x, " fixedSchema"); + if( pItem->fg.hadSchema ) sqlite3_str_appendf(&x, " hadSchema"); + if( pItem->fg.isSubquery ) sqlite3_str_appendf(&x, " isSubquery"); sqlite3StrAccumFinish(&x); sqlite3TreeViewItem(pView, zLine, inSrc-1); @@ -237,12 +240,16 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ sqlite3TreeViewIdList(pView, pItem->u3.pUsing, (--n)>0, "USING"); } if( pItem->fg.isSubquery ){ + assert( n==1 ); if( pItem->pSTab ){ Table *pTab = pItem->pSTab; sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1); } assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem) ); - sqlite3TreeViewSelect(pView, pItem->u4.pSubq->pSelect, (--n)>0); + sqlite3TreeViewPush(&pView, 0); + sqlite3TreeViewLine(pView, "SUBQUERY"); + sqlite3TreeViewPop(&pView); + sqlite3TreeViewSelect(pView, pItem->u4.pSubq->pSelect, 0); } if( pItem->fg.isTabFunc ){ sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); From 91937a6961e2277f11b029aacf6a45bb52a1a0d5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Aug 2024 10:37:59 +0000 Subject: [PATCH 0701/1030] Fix a minor typo in a comment. FossilOrigin-Name: 92c80af1129051c9eded8df170730ad6366b4f7715dead34c4364c8149d0dce9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e8e708addf..dccf0d0c1f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\streetrace\soutput\sfor\ssubqueries.\s\sDebug\scode\sonly. -D 2024-08-21T10:32:00.693 +C Fix\sa\sminor\stypo\sin\sa\scomment. +D 2024-08-21T10:37:59.175 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -764,7 +764,7 @@ F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 44d135bbea93872a7318f048d9d6e566b1c3eaa92d6dabe06e4741aa78d1c1ec +F src/select.c 534eccfb8e3879cc54d93a55ca5118cf72ed9c5337456c217cc0424da33b87a7 F src/shell.c.in fb7fe0a39473e7a3ad5ad7076ff49d87aa8ed7fdd98a1595345747ac5d78ac2b F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fd5904495e0c775174f9380bc6877fb9def3d30dec1c9315979ad4503a18d70b -R 9b61fbb833ee0abcfc996b0de63e571b +P 0a835d18d9063b17a1d506fd989ebcf7f0d76593978a3bd5981be59618335f21 +R 3a629ede216b591a2dde1a6c7535f80d U drh -Z 56e8c0285d76008f8c95bfad3d078586 +Z d8ab38fee62be945af061484336e5eb9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0090278b24..ba3b844e79 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a835d18d9063b17a1d506fd989ebcf7f0d76593978a3bd5981be59618335f21 +92c80af1129051c9eded8df170730ad6366b4f7715dead34c4364c8149d0dce9 diff --git a/src/select.c b/src/select.c index 87bf7fac2f..18fc9d3be6 100644 --- a/src/select.c +++ b/src/select.c @@ -7696,7 +7696,7 @@ int sqlite3Select( } /* For each term in the FROM clause, do two things: - ** (1) Authorized unreferenced tables + ** (1) Authorize unreferenced tables ** (2) Generate code for all sub-queries */ for(i=0; inSrc; i++){ From 4cc86b6e9246c4b85cbad7161f48b4c5c2b9cf43 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Aug 2024 12:01:46 +0000 Subject: [PATCH 0702/1030] Add code comments for a "table-of-contents" and various milestone marks in the 1300+ line long sqlite3Select() function, to help improve readiability and maintainability. Comment changes only - no functional changes. FossilOrigin-Name: 00cfbb9fa5136e6a7847da4e4ab30d320ca79c22acda9db2030e558d59b8c744 --- manifest | 12 +++--- manifest.uuid | 2 +- src/select.c | 109 +++++++++++++++++++++++++++++++++++++------------- 3 files changed, 89 insertions(+), 34 deletions(-) diff --git a/manifest b/manifest index dccf0d0c1f..ed35eeaa1c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sminor\stypo\sin\sa\scomment. -D 2024-08-21T10:37:59.175 +C Add\scode\scomments\sfor\sa\s"table-of-contents"\sand\svarious\smilestone\smarks\sin\nthe\s1300+\sline\slong\ssqlite3Select()\sfunction,\sto\shelp\simprove\sreadiability\nand\smaintainability.\s\sComment\schanges\sonly\s-\sno\sfunctional\schanges. +D 2024-08-21T12:01:46.057 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -764,7 +764,7 @@ F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 534eccfb8e3879cc54d93a55ca5118cf72ed9c5337456c217cc0424da33b87a7 +F src/select.c 26bd0ce6e8816f8968f50a377dc4255da4b392793e87ae27acd7276b56a447ce F src/shell.c.in fb7fe0a39473e7a3ad5ad7076ff49d87aa8ed7fdd98a1595345747ac5d78ac2b F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0a835d18d9063b17a1d506fd989ebcf7f0d76593978a3bd5981be59618335f21 -R 3a629ede216b591a2dde1a6c7535f80d +P 92c80af1129051c9eded8df170730ad6366b4f7715dead34c4364c8149d0dce9 +R 96f2b1d6b34bcd20452ccf075e5a2b9a U drh -Z d8ab38fee62be945af061484336e5eb9 +Z 790a1d73ddaf8f8dea50d658062e6edf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ba3b844e79..a4857cf3eb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -92c80af1129051c9eded8df170730ad6366b4f7715dead34c4364c8149d0dce9 +00cfbb9fa5136e6a7847da4e4ab30d320ca79c22acda9db2030e558d59b8c744 diff --git a/src/select.c b/src/select.c index 18fc9d3be6..0bb033785c 100644 --- a/src/select.c +++ b/src/select.c @@ -7340,7 +7340,7 @@ static int fromClauseTermCanBeCoroutine( } /* -** Generate code for the SELECT statement given in the p argument. +** Generate byte-code for the SELECT statement given in the p argument. ** ** The results are returned according to the SelectDest structure. ** See comments in sqliteInt.h for further information. @@ -7351,6 +7351,40 @@ static int fromClauseTermCanBeCoroutine( ** ** This routine does NOT free the Select structure passed in. The ** calling function needs to do that. +** +** This is a long function. The following is an outline of the processing +** steps, with tags referencing various milestones: +** +** * Resolve names and similar preparation tag-select-0100 +** * Scan of the FROM clause tag-select-0200 +** + OUTER JOIN strength reduction tag-select-0220 +** + Sub-query ORDER BY removal tag-select-0230 +** + Query flattening tag-select-0240 +** * Separate subroutine for compound-SELECT tag-select-0300 +** * WHERE-clause constant propagation tag-select-0330 +** * Count()-of-VIEW optimization tag-select-0350 +** * Scan of the FROM clause again tag-select-0400 +** + Authorize unreferenced tables tag-select-0410 +** + Predicate push-down optimization tag-select-0420 +** + Omit unused subquery columns optimization tag-select-0440 +** + Generate code to implement subqueries tag-select-0480 +** - Co-routines tag-select-0482 +** - Reuse previously computed CTE tag-select-0484 +** - REuse previously computed VIEW tag-select-0486 +** - Materialize a VIEW or CTE tag-select-0488 +** * DISTINCT ORDER BY -> GROUP BY optimization tag-select-0500 +** * Set up for ORDER BY tag-select-0600 +** * Create output table tag-select-0630 +** * Prepare registers for LIMIT tag-select-0650 +** * Setup for DISTINCT tag-select-0680 +** * Generate code for non-aggregate and non-GROUP BY tag-select-0700 +** * Generate code for aggregate and/or GROUP BY tag-select-0800 +** + GROUP BY queries tag-select-0810 +** + non-GROUP BY queries tag-select-0820 +** - Special case of count() w/o GROUP BY tag-select-0821 +** - General case of non-GROUP BY aggregates tag-select-0822 +** * Sort results, as needed tag-select-0900 +** * Internal self-checks tag-select-1000 */ int sqlite3Select( Parse *pParse, /* The parser context */ @@ -7394,6 +7428,7 @@ int sqlite3Select( } #endif + /* tag-select-0100 */ assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo ); assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo ); assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistQueue ); @@ -7480,6 +7515,7 @@ int sqlite3Select( /* Try to do various optimizations (flattening subqueries, and strength ** reduction of join operators) in the FROM clause up into the main query + ** tag-select-0200 */ #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) for(i=0; !p->pPrior && inSrc; i++){ @@ -7502,6 +7538,7 @@ int sqlite3Select( ** way that the i-th table cannot be the NULL row of a join, then ** perform the appropriate simplification. This is called ** "OUTER JOIN strength reduction" in the SQLite documentation. + ** tag-select-0220 */ if( (pItem->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 && sqlite3ExprImpliesNonNullRow(p->pWhere, pItem->iCursor, @@ -7572,7 +7609,8 @@ int sqlite3Select( if( (pSub->selFlags & SF_Aggregate)!=0 ) continue; assert( pSub->pGroupBy==0 ); - /* If a FROM-clause subquery has an ORDER BY clause that is not + /* tag-select-0230: + ** If a FROM-clause subquery has an ORDER BY clause that is not ** really doing anything, then delete it now so that it does not ** interfere with query flattening. See the discussion at ** https://sqlite.org/forum/forumpost/2d76f2bcf65d256a @@ -7638,6 +7676,7 @@ int sqlite3Select( continue; } + /* tag-select-0240 */ if( flattenSubquery(pParse, p, i, isAgg) ){ if( pParse->nErr ) goto select_end; /* This subquery can be absorbed into its parent. */ @@ -7653,7 +7692,7 @@ int sqlite3Select( #ifndef SQLITE_OMIT_COMPOUND_SELECT /* Handle compound SELECT statements using the separate multiSelect() - ** procedure. + ** procedure. tag-select-0300 */ if( p->pPrior ){ rc = multiSelect(pParse, p, pDest); @@ -7669,9 +7708,9 @@ int sqlite3Select( #endif /* Do the WHERE-clause constant propagation optimization if this is - ** a join. No need to speed time on this operation for non-join queries + ** a join. No need to spend time on this operation for non-join queries ** as the equivalent optimization will be handled by query planner in - ** sqlite3WhereBegin(). + ** sqlite3WhereBegin(). tag-select-0330 */ if( p->pWhere!=0 && p->pWhere->op==TK_AND @@ -7688,6 +7727,7 @@ int sqlite3Select( TREETRACE(0x2000,pParse,p,("Constant propagation not helpful\n")); } + /* tag-select-0350 */ if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView) && countOfViewOptimization(pParse, p) ){ @@ -7695,9 +7735,12 @@ int sqlite3Select( pTabList = p->pSrc; } - /* For each term in the FROM clause, do two things: - ** (1) Authorize unreferenced tables - ** (2) Generate code for all sub-queries + /* Loop over all terms in the FROM clause and do two things for each term: + ** + ** (1) Authorize unreferenced tables + ** (2) Generate code for all sub-queries + ** + ** tag-select-0400 */ for(i=0; inSrc; i++){ SrcItem *pItem = &pTabList->a[i]; @@ -7709,7 +7752,9 @@ int sqlite3Select( const char *zSavedAuthContext; #endif - /* Issue SQLITE_READ authorizations with a fake column name for any + /* Authorized unreferenced tables. tag-select-0410 + ** + ** Issue SQLITE_READ authorizations with a fake column name for any ** tables that are referenced but from which no values are extracted. ** Examples of where these kinds of null SQLITE_READ authorizations ** would occur: @@ -7745,10 +7790,9 @@ int sqlite3Select( pSubq = pItem->u4.pSubq; assert( pSubq!=0 ); pSub = pSubq->pSelect; - if( pSubq->addrFillSub!=0 ) continue; /* The code for a subquery should only be generated once. */ - assert( pSubq->addrFillSub==0 ); + if( pSubq->addrFillSub!=0 ) continue; /* Increment Parse.nHeight by the height of the largest expression ** tree referred to by this, the parent select. The child select @@ -7761,6 +7805,7 @@ int sqlite3Select( /* Make copies of constant WHERE-clause terms in the outer query down ** inside the subquery. This can help the subquery to run more efficiently. + ** This is the "predicate push-down optimization". tag-select-0420 */ if( OptimizationEnabled(db, SQLITE_PushDown) && (pItem->fg.isCte==0 @@ -7781,6 +7826,7 @@ int sqlite3Select( /* Convert unused result columns of the subquery into simple NULL ** expressions, to avoid unneeded searching and computation. + ** tag-select-0440 */ if( OptimizationEnabled(db, SQLITE_NullUnusedCols) && disableUnusedSubqueryResultColumns(pItem) @@ -7798,11 +7844,11 @@ int sqlite3Select( zSavedAuthContext = pParse->zAuthContext; pParse->zAuthContext = pItem->zName; - /* Generate code to implement the subquery + /* Generate byte-code to implement the subquery tag-select-0480 */ if( fromClauseTermCanBeCoroutine(pParse, pTabList, i, p->selFlags) ){ /* Implement a co-routine that will return a single row of the result - ** set on each invocation. + ** set on each invocation. tag-select-0482 */ int addrTop = sqlite3VdbeCurrentAddr(v)+1; @@ -7822,8 +7868,8 @@ int sqlite3Select( }else if( pItem->fg.isCte && pItem->u2.pCteUse->addrM9e>0 ){ /* This is a CTE for which materialization code has already been ** generated. Invoke the subroutine to compute the materialization, - ** the make the pItem->iCursor be a copy of the ephemeral table that - ** holds the result of the materialization. */ + ** then make the pItem->iCursor be a copy of the ephemeral table that + ** holds the result of the materialization. tag-select-0484 */ CteUse *pCteUse = pItem->u2.pCteUse; sqlite3VdbeAddOp2(v, OP_Gosub, pCteUse->regRtn, pCteUse->addrM9e); if( pItem->iCursor!=pCteUse->iCur ){ @@ -7833,7 +7879,7 @@ int sqlite3Select( pSub->nSelectRow = pCteUse->nRowEst; }else if( (pPrior = isSelfJoinView(pTabList, pItem, 0, i))!=0 ){ /* This view has already been materialized by a prior entry in - ** this same FROM clause. Reuse it. */ + ** this same FROM clause. Reuse it. tag-select-0486 */ Subquery *pPriorSubq; assert( pPrior->fg.isSubquery ); pPriorSubq = pPrior->u4.pSubq; @@ -7847,7 +7893,7 @@ int sqlite3Select( }else{ /* Materialize the view. If the view is not correlated, generate a ** subroutine to do the materialization so that subsequent uses of - ** the same view can reuse the materialization. */ + ** the same view can reuse the materialization. tag-select-0488 */ int topAddr; int onceAddr = 0; #ifdef SQLITE_ENABLE_STMT_SCANSTATUS @@ -7907,7 +7953,9 @@ int sqlite3Select( } #endif - /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and + /* tag-select-0500 + ** + ** If the query is DISTINCT with an ORDER BY but is not an aggregate, and ** if the select-list is the same as the ORDER BY list, then this query ** can be rewritten as a GROUP BY. In other words, this: ** @@ -7957,7 +8005,7 @@ int sqlite3Select( ** If that is the case, then the OP_OpenEphemeral instruction will be ** changed to an OP_Noop once we figure out that the sorting index is ** not needed. The sSort.addrSortIndex variable is used to facilitate - ** that change. + ** that change. tag-select-0600 */ if( sSort.pOrderBy ){ KeyInfo *pKeyInfo; @@ -7974,6 +8022,7 @@ int sqlite3Select( } /* If the output is destined for a temporary table, open that table. + ** tag-select-0630 */ if( pDest->eDest==SRT_EphemTab ){ sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr); @@ -7991,7 +8040,7 @@ int sqlite3Select( } } - /* Set the limiter. + /* Set the limiter. tag-select-0650 */ iEnd = sqlite3VdbeMakeLabel(pParse); if( (p->selFlags & SF_FixedLimit)==0 ){ @@ -8003,7 +8052,7 @@ int sqlite3Select( sSort.sortFlags |= SORTFLAG_UseSorter; } - /* Open an ephemeral index to use for the distinct set. + /* Open an ephemeral index to use for the distinct set. tag-select-0680 */ if( p->selFlags & SF_Distinct ){ sDistinct.tabTnct = pParse->nTab++; @@ -8018,7 +8067,7 @@ int sqlite3Select( } if( !isAgg && pGroupBy==0 ){ - /* No aggregate functions and no GROUP BY clause */ + /* No aggregate functions and no GROUP BY clause. tag-select-0700 */ u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0) | (p->selFlags & SF_FixedLimit); #ifndef SQLITE_OMIT_WINDOWFUNC @@ -8091,8 +8140,8 @@ int sqlite3Select( sqlite3WhereEnd(pWInfo); } }else{ - /* This case when there exist aggregate functions or a GROUP BY clause - ** or both */ + /* This case is for when there exist aggregate functions or a GROUP BY + ** clause or both. tag-select-0800 */ NameContext sNC; /* Name context for processing aggregate information */ int iAMem; /* First Mem address for storing current GROUP BY */ int iBMem; /* First Mem address for previous GROUP BY */ @@ -8211,7 +8260,7 @@ int sqlite3Select( /* Processing for aggregates with GROUP BY is very different and - ** much more complex than aggregates without a GROUP BY. + ** much more complex than aggregates without a GROUP BY. tag-select-0810 */ if( pGroupBy ){ KeyInfo *pKeyInfo; /* Keying information for the group by clause */ @@ -8508,9 +8557,12 @@ int sqlite3Select( } } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */ else { + /* Aggregate functions without GROUP BY. tag-select-0820 */ Table *pTab; if( (pTab = isSimpleCount(p, pAggInfo))!=0 ){ - /* If isSimpleCount() returns a pointer to a Table structure, then + /* tag-select-0821 + ** + ** If isSimpleCount() returns a pointer to a Table structure, then ** the SQL statement is of the form: ** ** SELECT count(*) FROM @@ -8569,6 +8621,8 @@ int sqlite3Select( sqlite3VdbeAddOp1(v, OP_Close, iCsr); explainSimpleCount(pParse, pTab, pBest); }else{ + /* The general case of an aggregate query without GROUP BY + ** tag-select-0822 */ int regAcc = 0; /* "populate accumulators" flag */ ExprList *pDistinct = 0; u16 distFlag = 0; @@ -8657,7 +8711,7 @@ int sqlite3Select( } /* If there is an ORDER BY clause, then we need to sort the results - ** and send them to the callback one by one. + ** and send them to the callback one by one. tag-select-0900 */ if( sSort.pOrderBy ){ assert( p->pEList==pEList ); @@ -8680,6 +8734,7 @@ int sqlite3Select( assert( db->mallocFailed==0 || pParse->nErr!=0 ); sqlite3ExprListDelete(db, pMinMaxOrderBy); #ifdef SQLITE_DEBUG + /* Internal self-checks. tag-select-1000 */ if( pAggInfo && !db->mallocFailed ){ #if TREETRACE_ENABLED if( sqlite3TreeTrace & 0x20 ){ From 59b171172f55351bb35f5954007395f3464a7ab1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Aug 2024 13:44:40 +0000 Subject: [PATCH 0703/1030] Updates and enhancements to the README.md file. No code changes. FossilOrigin-Name: 3161b8028916bff9a13a04bfb1996bce7e1274a3c403fc58f4d798afd30c528f --- README.md | 161 ++++++++++++++++++++++++++++++++------------------ manifest | 12 ++-- manifest.uuid | 2 +- 3 files changed, 111 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 0975a32d9a..3d8b5379b0 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@

    SQLite Source Repository

    This repository contains the complete source code for the -[SQLite database engine](https://sqlite.org/). Some test scripts -are also included. However, many other test scripts +[SQLite database engine](https://sqlite.org/), including +many test scripts. However, other test scripts and most of the documentation are managed separately. +See the [on-line documentation](https://sqlite.org/) for more information +about what SQLite is and how it works from a user's perspective. This +README file is about the source code that goes into building SQLite, +not about how SQLite is used. + ## Version Control SQLite sources are managed using -[Fossil](https://www.fossil-scm.org/), a distributed version control system +[Fossil](https://fossil-scm.org/), a distributed version control system that was specifically designed and written to support SQLite development. The [Fossil repository](https://sqlite.org/src/timeline) contains the urtext. @@ -68,12 +73,11 @@ archives or [SQLite archives](https://sqlite.org/cli.html#sqlar) as follows: then click on the "Tarball" or "ZIP Archive" links on the information page. -If you do want to use Fossil to check out the source tree, -first install Fossil version 2.0 or later. -(Source tarballs and precompiled binaries available -[here](https://www.fossil-scm.org/fossil/uv/download.html). Fossil is +To access sources directly using Fossil, first install Fossil version 2.0 or later. +Source tarballs and precompiled binaries available +[here](https://www.fossil-scm.org/fossil/uv/download.html. Fossil is a stand-alone program. To install, simply download or build the single -executable file and put that file someplace on your $PATH.) +executable file and put that file someplace on your $PATH. Then run commands like this: mkdir -p ~/sqlite ~/Fossils @@ -81,8 +85,8 @@ Then run commands like this: fossil clone https://www.sqlite.org/src ~/Fossils/sqlite.fossil fossil open ~/Fossils/sqlite.fossil -After setting up a repository using the steps above, you can always -update to the latest version using: +After setting up a repository using the steps above, you can do +bandwidth-efficient updates to the latest version using: fossil update trunk ;# latest trunk check-in fossil update release ;# latest official release @@ -99,15 +103,30 @@ script found at the root of the source tree. Then run "make". For example: - tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" - mkdir bld ;# Build will occur in a sibling directory - cd bld ;# Change to the build directory - ../sqlite/configure ;# Run the configure script - make ;# Builds the "sqlite3" command-line tool - make sqlite3.c ;# Build the "amalgamation" source file - make devtest ;# Run some tests (requires Tcl) + tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" + mkdir bld ;# Build will occur in a sibling directory + cd bld ;# Change to the build directory + ../sqlite/configure ;# Run the configure script + make sqlite3 ;# Builds the "sqlite3" command-line tool + make sqlite3.c ;# Build the "amalgamation" source file + make mdevtest ;# Run development tests (requires tcl-dev) + make releasetest ;# Run full release tests (requires tcl-dev) + make sqldiff ;# Builds the "sqldiff" command-line tool + make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool (requires tcl-dev) + make tclextension-install ;# Build and install the SQLite TCL extension + +See the makefile for additional targets. For debugging builds, the +core developers typically run "configure" with options like this: + + ../sqlite/configure --enable-all --enable-debug CFLAGS='-O0 -g' + +For release builds, the core developers usually do: -See the makefile for additional targets. + ../sqlite/configure --enable-all + +Almost all makefile targets require a "tclsh" TCL interpreter +version 8.6 or later. The targets marked with "(requires tcl-dev)" also require +the TCL development libraries. The configure script uses autoconf 2.61 and libtool. If the configure script does not work out for you, there is a generic makefile named @@ -128,48 +147,61 @@ TCL library, using a command like this: set TCLDIR=c:\Tcl -SQLite uses "tclsh.exe" as part of the build process, and so that utility -program will need to be somewhere on your %PATH%. The finished SQLite library -does not contain any TCL code, but it does use TCL to help with the build process -and to run tests. +SQLite uses "tclsh.exe" as part of the build process, and so that +program will need to be somewhere on your %PATH%. SQLite itself +does not contain any TCL code, but it does use TCL to help with the +build process and to run tests. Build using Makefile.msc. Example: - nmake /f Makefile.msc + nmake /f Makefile.msc sqlite3.exe nmake /f Makefile.msc sqlite3.c - nmake /f Makefile.msc devtest + nmake /f Makefile.msc mdevtest nmake /f Makefile.msc releasetest + nmake /f Makefile.msc tclextension-install There are many other makefile targets. See comments in Makefile.msc for details. -## Source Code Tour - -Most of the core source files are in the **src/** subdirectory. The -**src/** folder also contains files used to build the "testfixture" test -harness. The names of the source files used by "testfixture" all begin -with "test". -The **src/** also contains the "shell.c" file -which is the main program for the "sqlite3.exe" -[command-line shell](https://sqlite.org/cli.html) and -the "tclsqlite.c" file which implements the -[Tcl bindings](https://sqlite.org/tclsqlite.html) for SQLite. -(Historical note: SQLite began as a Tcl -extension and only later escaped to the wild as an independent library.) - -Test scripts and programs are found in the **test/** subdirectory. -Additional test code is found in other source repositories. -See [How SQLite Is Tested](https://www.sqlite.org/testing.html) for -additional information. - -The **ext/** subdirectory contains code for extensions. The -Full-text search engine is in **ext/fts3**. The R-Tree engine is in -**ext/rtree**. The **ext/misc** subdirectory contains a number of -smaller, single-file extensions, such as a REGEXP operator. - -The **tool/** subdirectory contains various scripts and programs used -for building generated source code files or for testing or for generating -accessory programs such as "sqlite3_analyzer(.exe)". +## Source Tree Map + + * **src/** - This directory contains the primary source code for the + SQLite core. For historical reasons, C-code used for testing is + also found here. Source files intended for testing begin with "`test`". + The `tclsqlite3.c` and `tclsqlite3.h` files are the TCL interface + for SQLite and are also not part of the core. + + * **test/** - This directory and its subdirectories contains code used + for testing. Files that end in "`.test`" are TCL scripts that run + tests using an augmented TCL interpreter named "testfixture". Use + a command like "`make testfixture`" (unix) or + "`nmake /f Makefile.msc testfixture.exe`" (windows) to build that + augmented TCL interpreter, then run individual tests using commands like + "`testfixture test/main.test`". This test/ subdirectory also contains + additional C code modules and scripts for other kinds of testing. + + * **tool/** - This directory contains programs and scripts used to + build some of the machine-generated code that goes into the SQLite + core, as well as to build and run tests and perform diagnostics. + The source code to [the Lemon parser generator](./doc/lemon.html) is + found here. There are also TCL scripts used to build and/or transform + source code files. For example, the tool/mksqlite3h.tcl script reads + the src/sqlite.h.in file and uses it as a template to construct + the deliverable "sqlite3.h" file that defines the SQLite interface. + + * **ext/** - Various extensions to SQLite are found under this + directory. For example, the FTS5 subsystem is in "ext/fts5/". + Some of these extensions (ex: FTS3/4, FTS5, RTREE) might get built + into the SQLite amalgamation, but not all of them. The + "ext/misc/" subdirectory contains an assortment of one-file extensions, + many of which are omitted from the SQLite core, but which are included + in the [SQLite CLI](https://sqlite.org/cli.html). + + * **doc/** - Some documentation files about SQLite internals are found + here. Note, however, that the primary documentation designed for + application developers and users of SQLite is in a completely separate + repository. Note also that the primary API documentation is derived + from specially constructed comments in the src/sqlite.h.in file. ### Generated Source Code Files @@ -252,31 +284,37 @@ individual source file exceeds 32K lines in length. SQLite is modular in design. See the [architectural description](https://www.sqlite.org/arch.html) for details. Other documents that are useful in -(helping to understand how SQLite works include the +helping to understand how SQLite works include the [file format](https://www.sqlite.org/fileformat2.html) description, the [virtual machine](https://www.sqlite.org/opcode.html) that runs prepared statements, the description of [how transactions work](https://www.sqlite.org/atomiccommit.html), and the [overview of the query planner](https://www.sqlite.org/optoverview.html). -Years of effort have gone into optimizing SQLite, both +Decades of effort have gone into optimizing SQLite, both for small size and high performance. And optimizations tend to result in complex code. So there is a lot of complexity in the current SQLite implementation. It will not be the easiest library in the world to hack. -Key files: +### Key source code files * **sqlite.h.in** - This file defines the public interface to the SQLite library. Readers will need to be familiar with this interface before - trying to understand how the library works internally. + trying to understand how the library works internally. This file is + really a template that is transformed into the "sqlite3.h" deliverable + using a script invoked by the makefile. * **sqliteInt.h** - this header file defines many of the data objects used internally by SQLite. In addition to "sqliteInt.h", some - subsystems have their own header files. + subsystems inside of sQLite have their own header files. These internal + interfaces are not for use by applications. They can and do change + from one release of SQLite to the next. * **parse.y** - This file describes the LALR(1) grammar that SQLite uses to parse SQL statements, and the actions that are taken at each step - in the parsing process. + in the parsing process. The file is processed by the + [Lemon Parser Generator](./doc/lemon.html) to produce the actual C code + used for parsing. * **vdbe.c** - This file implements the virtual machine that runs prepared statements. There are various helper files whose names @@ -319,6 +357,11 @@ Key files: (and some other test programs too) is built and run when you type "make test". + * **VERSION**, **manifest**, and **manifest.uuid** - These files define + the current SQLite version number. The "VERSION" file is human generated, + but the "manifest" and "manifest.uuid" files are automatically generated + by the [Fossil version control system](https://fossil-scm/). + There are many other source files. Each has a succinct header comment that describes its purpose and role within the larger system. @@ -357,3 +400,7 @@ The main SQLite website is [https://sqlite.org/](https://sqlite.org/) with geographically distributed backups at [https://www2.sqlite.org/](https://www2.sqlite.org) and [https://www3.sqlite.org/](https://www3.sqlite.org). + +Contact the SQLite developers through the +[SQLite Forum](https://sqlite.org/forum/). In an emergency, you +can send private email to the lead developer at drh at sqlite dot org. diff --git a/manifest b/manifest index ed35eeaa1c..a806c63448 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Add\scode\scomments\sfor\sa\s"table-of-contents"\sand\svarious\smilestone\smarks\sin\nthe\s1300+\sline\slong\ssqlite3Select()\sfunction,\sto\shelp\simprove\sreadiability\nand\smaintainability.\s\sComment\schanges\sonly\s-\sno\sfunctional\schanges. -D 2024-08-21T12:01:46.057 +C Updates\sand\senhancements\sto\sthe\sREADME.md\sfile.\s\sNo\scode\schanges. +D 2024-08-21T13:44:40.490 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in 209e9c64edf499b0ea7a15448699101c01d15828af35a3439d32fc25fdf1b787 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 6c3fe8b6ce60e73f34a148c957d78b4648745c8d30e792423aa1a8d8bf12d065 -F README.md 6358805260a03ebead84e168bbf3740ddf3f683b477e478567186aa7afb490d3 +F README.md 0f063e8688bf418c131b10b738cb0cb565188718152cc1ab59fa764396f0221d F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 92c80af1129051c9eded8df170730ad6366b4f7715dead34c4364c8149d0dce9 -R 96f2b1d6b34bcd20452ccf075e5a2b9a +P 00cfbb9fa5136e6a7847da4e4ab30d320ca79c22acda9db2030e558d59b8c744 +R 4f9e7c4307cf2bdaee18c0795e924886 U drh -Z 790a1d73ddaf8f8dea50d658062e6edf +Z 75d46cf029113e1403bee9c72a50cf8b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a4857cf3eb..5fe891c876 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00cfbb9fa5136e6a7847da4e4ab30d320ca79c22acda9db2030e558d59b8c744 +3161b8028916bff9a13a04bfb1996bce7e1274a3c403fc58f4d798afd30c528f From 5b5625f679aa130d5a16204bc06ce7e99b2f869f Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 21 Aug 2024 13:57:30 +0000 Subject: [PATCH 0704/1030] README.md: a markup link fix and use the canonical URL for Fossil. FossilOrigin-Name: c49bfee6b878bd96adfc852fdc76e98bf81e2fb82be8325672fbc7af04e7dffa --- README.md | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3d8b5379b0..4cddb47752 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ archives or [SQLite archives](https://sqlite.org/cli.html#sqlar) as follows: To access sources directly using Fossil, first install Fossil version 2.0 or later. Source tarballs and precompiled binaries available -[here](https://www.fossil-scm.org/fossil/uv/download.html. Fossil is +[here](https://www.fossil-scm.org/home/uv/download.html). Fossil is a stand-alone program. To install, simply download or build the single executable file and put that file someplace on your $PATH. Then run commands like this: @@ -379,7 +379,7 @@ The `manifest.uuid` file should contain the SHA3-256 hash of the `manifest` file. If all of the above hash comparisons are correct, then you can be confident that your source tree is authentic and unadulterated. Details on the format for the `manifest` files are available -[on the Fossil website](https://fossil-scm.org/fossil/doc/trunk/www/fileformat.wiki#manifest). +[on the Fossil website](https://fossil-scm.org/home/doc/trunk/www/fileformat.wiki#manifest). The process of checking source code authenticity is automated by the makefile: diff --git a/manifest b/manifest index a806c63448..e6ceef9686 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Updates\sand\senhancements\sto\sthe\sREADME.md\sfile.\s\sNo\scode\schanges. -D 2024-08-21T13:44:40.490 +C README.md:\sa\smarkup\slink\sfix\sand\suse\sthe\scanonical\sURL\sfor\sFossil. +D 2024-08-21T13:57:30.455 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in 209e9c64edf499b0ea7a15448699101c01d15828af35a3439d32fc25fdf1b787 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 6c3fe8b6ce60e73f34a148c957d78b4648745c8d30e792423aa1a8d8bf12d065 -F README.md 0f063e8688bf418c131b10b738cb0cb565188718152cc1ab59fa764396f0221d +F README.md 3d47ef5758e2de29d6f4e1aca714d51424baba86c8b561fef330f6ef2dc9282c F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 00cfbb9fa5136e6a7847da4e4ab30d320ca79c22acda9db2030e558d59b8c744 -R 4f9e7c4307cf2bdaee18c0795e924886 -U drh -Z 75d46cf029113e1403bee9c72a50cf8b +P 3161b8028916bff9a13a04bfb1996bce7e1274a3c403fc58f4d798afd30c528f +R 2e449f153f783008445322155cf77dd3 +U stephan +Z fedf47a9f8fa7c0c7d99b3ea8b72d3a3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5fe891c876..04eae5dbf7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3161b8028916bff9a13a04bfb1996bce7e1274a3c403fc58f4d798afd30c528f +c49bfee6b878bd96adfc852fdc76e98bf81e2fb82be8325672fbc7af04e7dffa From 9904d824b890b9b30c514c14f2c5fcbc4118f456 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Aug 2024 17:38:50 +0000 Subject: [PATCH 0705/1030] Improved comments on byte-code subroutine calls to materialize subqueries. Should not affect production builds. FossilOrigin-Name: 6b024c85ef856e26cddac8ad862e16909b5149c3e3efb4e73ba54c97291f1cc4 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 1 + src/where.c | 12 +++++++----- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index e6ceef9686..eba71f8794 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C README.md:\sa\smarkup\slink\sfix\sand\suse\sthe\scanonical\sURL\sfor\sFossil. -D 2024-08-21T13:57:30.455 +C Improved\scomments\son\sbyte-code\ssubroutine\scalls\sto\smaterialize\ssubqueries.\nShould\snot\saffect\sproduction\sbuilds. +D 2024-08-21T17:38:50.489 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -764,7 +764,7 @@ F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 26bd0ce6e8816f8968f50a377dc4255da4b392793e87ae27acd7276b56a447ce +F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in fb7fe0a39473e7a3ad5ad7076ff49d87aa8ed7fdd98a1595345747ac5d78ac2b F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -850,7 +850,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c b6f79b189fcba459bb80420d3b4102f42a399be36ff29a3deff4ae4888fee46d +F src/where.c 61fea6c34c9c2350b114a4f64dce51ec073c2d8c50ca0734a0882ba6ab531805 F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e F src/wherecode.c 137797b0de9ddf1ff43e5b0edffcc76fb05184ed651fc4f5a0a01a45c0b89d04 F src/whereexpr.c 44f41ae554c7572e1de1485b3169b233ee04d464b2ee5881687ede3bf07cacfa @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3161b8028916bff9a13a04bfb1996bce7e1274a3c403fc58f4d798afd30c528f -R 2e449f153f783008445322155cf77dd3 -U stephan -Z fedf47a9f8fa7c0c7d99b3ea8b72d3a3 +P c49bfee6b878bd96adfc852fdc76e98bf81e2fb82be8325672fbc7af04e7dffa +R 862ab59c7e7e7a7369184a7d27a7302b +U drh +Z 51170964494b840c9c6cd6315a6727db # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 04eae5dbf7..2c55f6f94e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c49bfee6b878bd96adfc852fdc76e98bf81e2fb82be8325672fbc7af04e7dffa +6b024c85ef856e26cddac8ad862e16909b5149c3e3efb4e73ba54c97291f1cc4 diff --git a/src/select.c b/src/select.c index 0bb033785c..9fcf30ff4a 100644 --- a/src/select.c +++ b/src/select.c @@ -7863,6 +7863,7 @@ int sqlite3Select( pItem->fg.viaCoroutine = 1; pSubq->regResult = dest.iSdst; sqlite3VdbeEndCoroutine(v, pSubq->regReturn); + VdbeComment((v, "end %!S", pItem)); sqlite3VdbeJumpHere(v, addrTop-1); sqlite3ClearTempRegCache(pParse); }else if( pItem->fg.isCte && pItem->u2.pCteUse->addrM9e>0 ){ diff --git a/src/where.c b/src/where.c index c9f6b97c94..6e494850c3 100644 --- a/src/where.c +++ b/src/where.c @@ -7122,15 +7122,17 @@ WhereInfo *sqlite3WhereBegin( pSrc = &pTabList->a[pLevel->iFrom]; if( pSrc->fg.isMaterialized ){ Subquery *pSubq; + int iOnce = 0; assert( pSrc->fg.isSubquery ); pSubq = pSrc->u4.pSubq; - if( pSrc->fg.isCorrelated ){ - sqlite3VdbeAddOp2(v, OP_Gosub, pSubq->regReturn, pSubq->addrFillSub); + if( pSrc->fg.isCorrelated==0 ){ + iOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); }else{ - int iOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); - sqlite3VdbeAddOp2(v, OP_Gosub, pSubq->regReturn, pSubq->addrFillSub); - sqlite3VdbeJumpHere(v, iOnce); + iOnce = 0; } + sqlite3VdbeAddOp2(v, OP_Gosub, pSubq->regReturn, pSubq->addrFillSub); + VdbeComment((v, "materialize %!S", pSrc)); + if( iOnce ) sqlite3VdbeJumpHere(v, iOnce); } assert( pTabList == pWInfo->pTabList ); if( (wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))!=0 ){ From be1fdbd272588cc61359dd3baf755bf8e857cf54 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Aug 2024 18:57:55 +0000 Subject: [PATCH 0706/1030] Add the new SQLITE_TESTCTRL_OPTGET that retrieves the current optimization setting. Use this in the CLI to provide symbolic fine-grain control over optimization settings using the ".testctrl opt" dot-command. FossilOrigin-Name: 0ea4e1e8fc689cb1af3a8d21dd6af9d483115412b414e85e8a42480f50d65af2 --- manifest | 19 ++++---- manifest.uuid | 2 +- src/main.c | 12 +++++ src/shell.c.in | 114 +++++++++++++++++++++++++++++++++++++++++++++++- src/sqlite.h.in | 1 + 5 files changed, 137 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index eba71f8794..a206e45d7b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\scomments\son\sbyte-code\ssubroutine\scalls\sto\smaterialize\ssubqueries.\nShould\snot\saffect\sproduction\sbuilds. -D 2024-08-21T17:38:50.489 +C Add\sthe\snew\sSQLITE_TESTCTRL_OPTGET\sthat\sretrieves\sthe\scurrent\soptimization\nsetting.\s\sUse\sthis\sin\sthe\sCLI\sto\sprovide\ssymbolic\sfine-grain\scontrol\nover\soptimization\ssettings\susing\sthe\s".testctrl\sopt"\sdot-command. +D 2024-08-21T18:57:55.594 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -727,7 +727,7 @@ F src/insert.c f8d1a0f8ee258411009c6b7f2d93170e351bd19f5ad89d57e1180644297cbe70 F src/json.c 5b6a1d6015997b9ee848a32948720bdb26a0ef2de5a2127ebf7355ce66dbdc0d F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c 8a59d297ec77e6b78550433bfccb95a1b26f2fb69aaaf233206e21579a1cfcc1 +F src/main.c a520c325c7400b249242945f2c602acb19662c40f5db1c04d88664cfaa8b85ac F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -765,8 +765,8 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in fb7fe0a39473e7a3ad5ad7076ff49d87aa8ed7fdd98a1595345747ac5d78ac2b -F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 +F src/shell.c.in 9a45cd618ed3cd09927e04bb0ccfd929fb5efa03a7166daec4645d230b7267f3 +F src/sqlite.h.in c6512f60f9fe06de46e49161e3f8fca72f3875f67dad8eaf469622567f434e48 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 28c878bdf528879afefe1994ac007d094f8061f2fdacdc55d6055d7e9341151e @@ -2210,8 +2210,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c49bfee6b878bd96adfc852fdc76e98bf81e2fb82be8325672fbc7af04e7dffa -R 862ab59c7e7e7a7369184a7d27a7302b +P 6b024c85ef856e26cddac8ad862e16909b5149c3e3efb4e73ba54c97291f1cc4 +R 5688f40bf117ffce0b629c4446a727b9 +T *branch * optimization-onoff +T *sym-optimization-onoff * +T -sym-trunk * U drh -Z 51170964494b840c9c6cd6315a6727db +Z b26803088924fd26f08434065f39c8bf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2c55f6f94e..6e30e87c81 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b024c85ef856e26cddac8ad862e16909b5149c3e3efb4e73ba54c97291f1cc4 +0ea4e1e8fc689cb1af3a8d21dd6af9d483115412b414e85e8a42480f50d65af2 diff --git a/src/main.c b/src/main.c index bff801a87d..5d6212208e 100644 --- a/src/main.c +++ b/src/main.c @@ -4393,6 +4393,18 @@ int sqlite3_test_control(int op, ...){ break; } + /* sqlite3_test_control(SQLITE_TESTCTRL_GETOPT, sqlite3 *db, int *N) + ** + ** Write the current optimization settings into *N. A zero bit means that + ** the optimization is on, and a 1 bit means that the optimization is off. + */ + case SQLITE_TESTCTRL_GETOPT: { + sqlite3 *db = va_arg(ap, sqlite3*); + int *pN = va_arg(ap, int*); + *pN = db->dbOptFlags; + break; + } + /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, onoff, xAlt); ** ** If parameter onoff is 1, subsequent calls to localtime() fail. diff --git a/src/shell.c.in b/src/shell.c.in index 8c4fcc4e12..a75b511903 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -10925,7 +10925,7 @@ static int do_meta_command(char *zLine, ShellState *p){ {"json_selfcheck", SQLITE_TESTCTRL_JSON_SELFCHECK ,0,"BOOLEAN" }, {"localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,0,"BOOLEAN" }, {"never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT,1, "BOOLEAN" }, - {"optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS,0,"DISABLE-MASK" }, + {"optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS,0,"DISABLE-MASK ..."}, #ifdef YYCOVERAGE {"parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE,0,"" }, #endif @@ -10989,8 +10989,118 @@ static int do_meta_command(char *zLine, ShellState *p){ }else{ switch(testctrl){ + /* Special processing for .testctrl opt MASK ... + ** Each MASK argument can be one of: + ** + ** +LABEL Enable the named optimization + ** + ** -LABEL Disable the named optimization + ** + ** INTEGER Mask of optimizations to disable + */ + case SQLITE_TESTCTRL_OPTIMIZATIONS: { + static const struct { + unsigned int mask; /* Mask for this optimization */ + unsigned int bDsply; /* Display this on output */ + const char *zLabel; /* Name of optimization */ + } aLabel[] = { + { 0x00000001, 1, "QueryFlattener" }, + { 0x00000001, 0, "Flatten" }, + { 0x00000002, 1, "WindowFunc" }, + { 0x00000004, 1, "GroupByOrder" }, + { 0x00000008, 1, "FactorOutConst" }, + { 0x00000010, 1, "DistinctOpt" }, + { 0x00000020, 1, "CoverIdxScan" }, + { 0x00000040, 1, "OrderByIdxJoin" }, + { 0x00000080, 1, "Transitive" }, + { 0x00000100, 1, "OmitNoopJoin" }, + { 0x00000200, 1, "CountOfView" }, + { 0x00000400, 1, "CurosrHints" }, + { 0x00000800, 1, "Stat4" }, + { 0x00001000, 1, "PushDown" }, + { 0x00002000, 1, "SimplifyJoin" }, + { 0x00004000, 1, "SkipScan" }, + { 0x00008000, 1, "PropagateConst" }, + { 0x00010000, 1, "MinMaxOpt" }, + { 0x00020000, 1, "SeekScan" }, + { 0x00040000, 1, "OmitOrderBy" }, + { 0x00080000, 1, "BloomFilter" }, + { 0x00100000, 1, "BloomPulldown" }, + { 0x00200000, 1, "BalancedMerge" }, + { 0x00400000, 1, "ReleaseReg" }, + { 0x00800000, 1, "FlttnUnionAll" }, + { 0x01000000, 1, "IndexedEXpr" }, + { 0x02000000, 1, "Coroutines" }, + { 0x04000000, 1, "NullUnusedCols" }, + { 0x08000000, 1, "OnePass" }, + { 0x10000000, 1, "OrderBySubq" }, + { 0xffffffff, 0, "All" }, + }; + unsigned int curOpt; + unsigned int newOpt; + int ii; + sqlite3_test_control(SQLITE_TESTCTRL_GETOPT, p->db, &curOpt); + newOpt = curOpt; + for(ii=2; ii=ArraySize(aLabel) ){ + eputf("Error: no such optimization: \"%s\"\n", zLabel); + eputf("Should be one of:"); + for(jj=0; jjdb,newOpt); + }else if( nArg<3 ){ + curOpt = ~newOpt; + } + if( newOpt==0 ){ + oputf("+All\n"); + }else if( newOpt==0xffffffff ){ + oputf("-All\n"); + }else{ + int jj; + for(jj=0; jj Date: Thu, 22 Aug 2024 16:22:08 +0000 Subject: [PATCH 0707/1030] Add the SQLITE_INDEX_SCAN_HEX bit to the sqlite3_index_info.idxFlags bitmask. When set, this bit causes the EXPLAIN QUERY PLAN output to show the idxNum value in hex rather than in decimal. This is purely a debugging aid. FossilOrigin-Name: 6c00e88ebdb41d6317bb8758825521614dedc2e6e6289ff415c5f0406eed815b --- manifest | 21 ++++++++++----------- manifest.uuid | 2 +- src/dbstat.c | 1 + src/sqlite.h.in | 12 ++++++++---- src/where.c | 1 + src/whereInt.h | 1 + src/wherecode.c | 4 +++- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index e659774b46..1cf656fb1c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sSQLITE_TESTCTRL_GETOPT.\s\sUse\sit\sto\simplement\simprovements\sto\sthe\n".testctrl\sopt"\sdot-command\sin\sthe\sCLI,\sand\ssimilar\senhancements\sto\sTH3. -D 2024-08-21T20:25:31.840 +C Add\sthe\sSQLITE_INDEX_SCAN_HEX\sbit\sto\sthe\ssqlite3_index_info.idxFlags\sbitmask.\nWhen\sset,\sthis\sbit\scauses\sthe\sEXPLAIN\sQUERY\sPLAN\soutput\sto\sshow\sthe\sidxNum\nvalue\sin\shex\srather\sthan\sin\sdecimal.\s\sThis\sis\spurely\sa\sdebugging\said. +D 2024-08-22T16:22:08.900 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -712,7 +712,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3 F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 -F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 +F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 444c4d1eaac40103461e3b6f0881846dd3aafc1cec1dd169d3482fa331667da7 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 @@ -766,7 +766,7 @@ F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 9a45cd618ed3cd09927e04bb0ccfd929fb5efa03a7166daec4645d230b7267f3 -F src/sqlite.h.in c6512f60f9fe06de46e49161e3f8fca72f3875f67dad8eaf469622567f434e48 +F src/sqlite.h.in f07bff4225a1244efd604a0ffef81ed69f29d3dbaed7e22f906f26229ba3ca9e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 28c878bdf528879afefe1994ac007d094f8061f2fdacdc55d6055d7e9341151e @@ -850,9 +850,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 61fea6c34c9c2350b114a4f64dce51ec073c2d8c50ca0734a0882ba6ab531805 -F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e -F src/wherecode.c 137797b0de9ddf1ff43e5b0edffcc76fb05184ed651fc4f5a0a01a45c0b89d04 +F src/where.c 70392f65e2c76a27ab1faed05892c2402ce547e574074a4f10282b3bc1ffe4eb +F src/whereInt.h a5d079c346a658b7a6e9e47bb943d021e02fa1e6aed3b964ca112112a4892192 +F src/wherecode.c 5172d647798134e7c92536ddffe7e530c393d79b5dedd648b88faf2646c65baf F src/whereexpr.c 44f41ae554c7572e1de1485b3169b233ee04d464b2ee5881687ede3bf07cacfa F src/window.c 499d48f315a09242dc68f2fac635ed27dcf6bbb0d9ab9084857898c64489e975 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -2210,9 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6b024c85ef856e26cddac8ad862e16909b5149c3e3efb4e73ba54c97291f1cc4 0ea4e1e8fc689cb1af3a8d21dd6af9d483115412b414e85e8a42480f50d65af2 -R 5688f40bf117ffce0b629c4446a727b9 -T +closed 0ea4e1e8fc689cb1af3a8d21dd6af9d483115412b414e85e8a42480f50d65af2 +P 6500baa9914b08ce19c361a69f19a80e5d800fcb82579d1c1e03601c7a664338 +R 7b7b9fd0e23c278e007dcb15333f71d2 U drh -Z 0dda3a273baa063a0338cbb5653c54ad +Z e92224536d6b88aa809210ea20e1cd7b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b34147cbe2..a3815e38d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6500baa9914b08ce19c361a69f19a80e5d800fcb82579d1c1e03601c7a664338 +6c00e88ebdb41d6317bb8758825521614dedc2e6e6289ff415c5f0406eed815b diff --git a/src/dbstat.c b/src/dbstat.c index c70d806370..d635a82975 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -279,6 +279,7 @@ static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ pIdxInfo->orderByConsumed = 1; pIdxInfo->idxNum |= 0x08; } + pIdxInfo->idxFlags |= SQLITE_INDEX_SCAN_HEX; return SQLITE_OK; } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 3c98e95d9f..810ccecc96 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7427,9 +7427,11 @@ struct sqlite3_module { ** will be returned by the strategy. ** ** The xBestIndex method may optionally populate the idxFlags field with a -** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag - -** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite -** assumes that the strategy may visit at most one row. +** mask of SQLITE_INDEX_SCAN_* flags. One such flag is +** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN] +** output to show the idxNum has hex instead of as decimal. Another flag is +** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will +** return at most one row. ** ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then ** SQLite also assumes that if a call to the xUpdate() method is made as @@ -7493,7 +7495,9 @@ struct sqlite3_index_info { ** [sqlite3_index_info].idxFlags field to some combination of ** these bits. */ -#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */ +#define SQLITE_INDEX_SCAN_UNIQUE 0x00000001 /* Scan visits at most 1 row */ +#define SQLITE_INDEX_SCAN_HEX 0x00000002 /* Display idxNum as hex */ + /* in EXPLAIN QUERY PLAN */ /* ** CAPI3REF: Virtual Table Constraint Operator Codes diff --git a/src/where.c b/src/where.c index 6e494850c3..a82f0305b4 100644 --- a/src/where.c +++ b/src/where.c @@ -4349,6 +4349,7 @@ static int whereLoopAddVirtualOne( pNew->u.vtab.idxStr = pIdxInfo->idxStr; pNew->u.vtab.isOrdered = (i8)(pIdxInfo->orderByConsumed ? pIdxInfo->nOrderBy : 0); + pNew->u.vtab.bIdxNumHex = (pIdxInfo->idxFlags&SQLITE_INDEX_SCAN_HEX)!=0; pNew->rSetup = 0; pNew->rRun = sqlite3LogEstFromDouble(pIdxInfo->estimatedCost); pNew->nOut = sqlite3LogEst(pIdxInfo->estimatedRows); diff --git a/src/whereInt.h b/src/whereInt.h index c9afed267b..8247528a93 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -149,6 +149,7 @@ struct WhereLoop { int idxNum; /* Index number */ u32 needFree : 1; /* True if sqlite3_free(idxStr) is needed */ u32 bOmitOffset : 1; /* True to let virtual table handle offset */ + u32 bIdxNumHex : 1; /* Show idxNum as hex in EXPLAIN QUERY PLAN */ i8 isOrdered; /* True if satisfies ORDER BY */ u16 omitMask; /* Terms that may be omitted */ char *idxStr; /* Index identifier string */ diff --git a/src/wherecode.c b/src/wherecode.c index b0c0d9aedd..0951e5e204 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -200,7 +200,9 @@ int sqlite3WhereExplainOneScan( } #ifndef SQLITE_OMIT_VIRTUALTABLE else if( (flags & WHERE_VIRTUALTABLE)!=0 ){ - sqlite3_str_appendf(&str, " VIRTUAL TABLE INDEX %d:%s", + sqlite3_str_appendall(&str, " VIRTUAL TABLE INDEX "); + sqlite3_str_appendf(&str, + pLoop->u.vtab.bIdxNumHex ? "0x%x:%s" : "%d:%s", pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr); } #endif From 5804da02182927dafae24a83bfe4176bb1746118 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 22 Aug 2024 18:12:10 +0000 Subject: [PATCH 0708/1030] Enhance the generate_series() table-valued function such that it is able to recognize equality and inequality constraints on the "value" column and optimize its operating accordingly. FossilOrigin-Name: d50b784807333c5461a2d027778c746c799285b95bb1952f142b317ea2846460 --- ext/misc/series.c | 254 ++++++++++++++++++++++++++++++++++++++------ manifest | 18 ++-- manifest.uuid | 2 +- test/merge1.test | 24 ++--- test/tabfunc01.test | 12 +-- test/tester.tcl | 2 +- 6 files changed, 252 insertions(+), 60 deletions(-) diff --git a/ext/misc/series.c b/ext/misc/series.c index 0dfed181f6..f2ca75c253 100644 --- a/ext/misc/series.c +++ b/ext/misc/series.c @@ -90,6 +90,26 @@ ** and a very large cost if either start or stop are unavailable. This ** encourages the query planner to order joins such that the bounds of the ** series are well-defined. +** +** Update on 2024-08-22: +** xBestIndex now also looks for equality and inequality constraints against +** the value column and uses those constraints as additional bounds against +** the sequence range. Thus, a query like this: +** +** SELECT value FROM generate_series($SA,$EA) +** WHERE value BETWEEN $SB AND $EB; +** +** Is logically the same as: +** +** SELECT value FROM generate_series(max($SA,$SB),min($EA,$EB)); +** +** Constraints on the value column can server as substitutes for constraints +** on the hidden start and stop columns. So, the following two queries +** are equivalent: +** +** SELECT value FROM generate_series($S,$E); +** SELECT value FROM generate_series WHERE value BETWEEN $S and $E; +** */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 @@ -131,8 +151,10 @@ static sqlite3_int64 genSeqMember( typedef unsigned char u8; typedef struct SequenceSpec { - sqlite3_int64 iBase; /* Starting value ("start") */ - sqlite3_int64 iTerm; /* Given terminal value ("stop") */ + sqlite3_int64 iOBase; /* Original starting value ("start") */ + sqlite3_int64 iOTerm; /* Original terminal value ("stop") */ + sqlite3_int64 iBase; /* Starting value to actually use */ + sqlite3_int64 iTerm; /* Terminal value to actually use */ sqlite3_int64 iStep; /* Increment ("step") */ sqlite3_uint64 uSeqIndexMax; /* maximum sequence index (aka "n") */ sqlite3_uint64 uSeqIndexNow; /* Current index during generation */ @@ -325,9 +347,9 @@ static int seriesColumn( series_cursor *pCur = (series_cursor*)cur; sqlite3_int64 x = 0; switch( i ){ - case SERIES_COLUMN_START: x = pCur->ss.iBase; break; - case SERIES_COLUMN_STOP: x = pCur->ss.iTerm; break; - case SERIES_COLUMN_STEP: x = pCur->ss.iStep; break; + case SERIES_COLUMN_START: x = pCur->ss.iOBase; break; + case SERIES_COLUMN_STOP: x = pCur->ss.iOTerm; break; + case SERIES_COLUMN_STEP: x = pCur->ss.iStep; break; default: x = pCur->ss.iValueNow; break; } sqlite3_result_int64(ctx, x); @@ -335,7 +357,9 @@ static int seriesColumn( } #ifndef LARGEST_UINT64 +#define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) #define LARGEST_UINT64 (0xffffffff|(((sqlite3_uint64)0xffffffff)<<32)) +#define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) #endif /* @@ -376,13 +400,18 @@ static int seriesEof(sqlite3_vtab_cursor *cur){ ** parameter. (idxStr is not used in this implementation.) idxNum ** is a bitmask showing which constraints are available: ** -** 0x01: start=VALUE -** 0x02: stop=VALUE -** 0x04: step=VALUE -** 0x08: descending order -** 0x10: ascending order -** 0x20: LIMIT VALUE -** 0x40: OFFSET VALUE +** 0x0001: start=VALUE +** 0x0002: stop=VALUE +** 0x0004: step=VALUE +** 0x0008: descending order +** 0x0010: ascending order +** 0x0020: LIMIT VALUE +** 0x0040: OFFSET VALUE +** 0x0080: value=VALUE +** 0x0100: value>=VALUE +** 0x0200: value>VALUE +** 0x1000: value<=VALUE +** 0x2000: valuess.iBase = sqlite3_value_int64(argv[i++]); @@ -416,16 +451,98 @@ static int seriesFilter( }else{ pCur->ss.iStep = 1; } + + /* If there are constraints on the value column but there are + ** no constraints on the start, stop, and step columns, then + ** initialize the default range to be the entire range of 64-bit signed + ** integers. This range will contracted by the value column constraints + ** further below. + */ + if( (idxNum & 0x05)==0 && (idxNum & 0x0380)!=0 ){ + pCur->ss.iBase = SMALLEST_INT64; + } + if( (idxNum & 0x06)==0 && (idxNum & 0x3080)!=0 ){ + pCur->ss.iTerm = LARGEST_INT64; + } + pCur->ss.iOBase = pCur->ss.iBase; + pCur->ss.iOTerm = pCur->ss.iTerm; + + /* Extract the LIMIT and OFFSET values, but do not apply them yet. + ** The range must first be constrained by the limits on value. + */ if( idxNum & 0x20 ){ - sqlite3_int64 iLimit = sqlite3_value_int64(argv[i++]); - sqlite3_int64 iTerm; + iLimit = sqlite3_value_int64(argv[i++]); if( idxNum & 0x40 ){ - sqlite3_int64 iOffset = sqlite3_value_int64(argv[i++]); - if( iOffset>0 ){ - pCur->ss.iBase += pCur->ss.iStep*iOffset; + iOffset = sqlite3_value_int64(argv[i++]); + } + } + + if( idxNum & 0x3380 ){ + /* Extract the maximum range of output values determined by + ** constraints on the "value" column. + */ + if( idxNum & 0x0080 ){ + iMin = iMax = sqlite3_value_int64(argv[i++]); + }else{ + if( idxNum & 0x0300 ){ + iMin = sqlite3_value_int64(argv[i++]); + if( idxNum & 0x0200 ){ + if( iMin==LARGEST_INT64 ){ + returnNoRows = 1; + }else{ + iMin++; + } + } + } + if( idxNum & 0x3000 ){ + iMax = sqlite3_value_int64(argv[i++]); + if( idxNum & 0x2000 ){ + if( iMax==SMALLEST_INT64 ){ + returnNoRows = 1; + }else{ + iMax--; + } + } + } + if( iMin>iMax ){ + returnNoRows = 1; } } + + /* Try to reduce the range of values to be generated based on + ** constraints on the "value" column. + */ + if( pCur->ss.iStep>0 ){ + sqlite3_int64 szStep = pCur->ss.iStep; + if( pCur->ss.iBasess.iBase; + pCur->ss.iBase += ((d+szStep-1)/szStep)*szStep; + } + if( pCur->ss.iTerm>iMax ){ + sqlite3_uint64 d = pCur->ss.iTerm - iMax; + pCur->ss.iTerm -= ((d+szStep-1)/szStep)*szStep; + } + }else{ + sqlite3_int64 szStep = -pCur->ss.iStep; + assert( szStep>0 ); + if( pCur->ss.iBase>iMax ){ + sqlite3_uint64 d = pCur->ss.iBase - iMax; + pCur->ss.iBase -= ((d+szStep-1)/szStep)*szStep; + } + if( pCur->ss.iTermss.iTerm; + pCur->ss.iTerm += ((d+szStep-1)/szStep)*szStep; + } + } + } + + /* Apply LIMIT and OFFSET constraints, if any */ + if( idxNum & 0x20 ){ + if( iOffset>0 ){ + pCur->ss.iBase += pCur->ss.iStep*iOffset; + } if( iLimit>=0 ){ + sqlite3_int64 iTerm; iTerm = pCur->ss.iBase + (iLimit - 1)*pCur->ss.iStep; if( pCur->ss.iStep<0 ){ if( iTerm>pCur->ss.iTerm ) pCur->ss.iTerm = iTerm; @@ -434,16 +551,21 @@ static int seriesFilter( } } } + + for(i=0; iss.iBase = 1; - pCur->ss.iTerm = 0; - pCur->ss.iStep = 1; + returnNoRows = 1; break; } } + if( returnNoRows ){ + pCur->ss.iBase = 1; + pCur->ss.iTerm = 0; + pCur->ss.iStep = 1; + } if( idxNum & 0x08 ){ pCur->ss.isReversing = pCur->ss.iStep > 0; }else{ @@ -464,13 +586,35 @@ static int seriesFilter( ** ** The query plan is represented by bits in idxNum: ** -** 0x01 start = $value -- constraint exists -** 0x02 stop = $value -- constraint exists -** 0x04 step = $value -- constraint exists -** 0x08 output is in descending order -** 0x10 output is in ascending order -** 0x20 LIMIT $value -- constraint exists -** 0x40 OFFSET $value -- constraint exists +** 0x0001 start = $num +** 0x0002 stop = $num +** 0x0004 step = $num +** 0x0008 output is in descending order +** 0x0010 output is in ascending order +** 0x0020 LIMIT $num +** 0x0040 OFFSET $num +** 0x0080 value = $num +** 0x0100 value >= $num +** 0x0200 value > $num +** 0x1000 value <= $num +** 0x2000 value < $num +** +** Only one of 0x0100 or 0x0200 will be returned. Similarly, only +** one of 0x1000 or 0x2000 will be returned. If the 0x0080 is set, then +** none of the 0xff00 bits will be set. +** +** The order of parameters passed to xFilter is as follows: +** +** * The argument to start= if bit 0x0001 is in the idxNum mask +** * The argument to stop= if bit 0x0002 is in the idxNum mask +** * The argument to step= if bit 0x0004 is in the idxNum mask +** * The argument to LIMIT if bit 0x0020 is in the idxNum mask +** * The argument to OFFSET if bit 0x0040 is in the idxNum mask +** * The argument to value=, or value>= or value> if any of +** bits 0x0380 are in the idxNum mask +** * The argument to value<= or value< if either of bits 0x3000 +** are in the mask +** */ static int seriesBestIndex( sqlite3_vtab *pVTab, @@ -483,7 +627,9 @@ static int seriesBestIndex( #endif int unusableMask = 0; /* Mask of unusable constraints */ int nArg = 0; /* Number of arguments that seriesFilter() expects */ - int aIdx[5]; /* Constraints on start, stop, step, LIMIT, OFFSET */ + int aIdx[7]; /* Constraints on start, stop, step, LIMIT, OFFSET, + ** and value. aIdx[5] covers value=, value>=, and + ** value>, aIdx[6] covers value<= and value< */ const struct sqlite3_index_constraint *pConstraint; /* This implementation assumes that the start, stop, and step columns @@ -491,7 +637,7 @@ static int seriesBestIndex( assert( SERIES_COLUMN_STOP == SERIES_COLUMN_START+1 ); assert( SERIES_COLUMN_STEP == SERIES_COLUMN_START+2 ); - aIdx[0] = aIdx[1] = aIdx[2] = aIdx[3] = aIdx[4] = -1; + aIdx[0] = aIdx[1] = aIdx[2] = aIdx[3] = aIdx[4] = aIdx[5] = aIdx[6] = -1; pConstraint = pIdxInfo->aConstraint; for(i=0; inConstraint; i++, pConstraint++){ int iCol; /* 0 for start, 1 for stop, 2 for step */ @@ -512,7 +658,50 @@ static int seriesBestIndex( } continue; } - if( pConstraint->iColumniColumn==SERIES_COLUMN_VALUE ){ + switch( op ){ + case SQLITE_INDEX_CONSTRAINT_EQ: + case SQLITE_INDEX_CONSTRAINT_IS: { + idxNum |= 0x0080; + idxNum &= ~0x3300; + aIdx[5] = i; + aIdx[6] = -1; + bStartSeen = 1; + break; + } + case SQLITE_INDEX_CONSTRAINT_GE: { + if( idxNum & 0x0080 ) break; + idxNum |= 0x0100; + idxNum &= ~0x0200; + aIdx[5] = i; + bStartSeen = 1; + break; + } + case SQLITE_INDEX_CONSTRAINT_GT: { + if( idxNum & 0x0080 ) break; + idxNum |= 0x0200; + idxNum &= ~0x0100; + aIdx[5] = i; + bStartSeen = 1; + break; + } + case SQLITE_INDEX_CONSTRAINT_LE: { + if( idxNum & 0x0080 ) break; + idxNum |= 0x1000; + idxNum &= ~0x2000; + aIdx[6] = i; + break; + } + case SQLITE_INDEX_CONSTRAINT_LT: { + if( idxNum & 0x0080 ) break; + idxNum |= 0x2000; + idxNum &= ~0x1000; + aIdx[6] = i; + break; + } + } + continue; + } iCol = pConstraint->iColumn - SERIES_COLUMN_START; assert( iCol>=0 && iCol<=2 ); iMask = 1 << iCol; @@ -534,7 +723,7 @@ static int seriesBestIndex( idxNum &= ~0x60; aIdx[4] = 0; } - for(i=0; i<5; i++){ + for(i=0; i<7; i++){ if( (j = aIdx[i])>=0 ){ pIdxInfo->aConstraintUsage[j].argvIndex = ++nArg; pIdxInfo->aConstraintUsage[j].omit = @@ -582,6 +771,9 @@ static int seriesBestIndex( pIdxInfo->estimatedRows = 2147483647; } pIdxInfo->idxNum = idxNum; +#ifdef SQLITE_INDEX_SCAN_HEX + pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_HEX; +#endif return SQLITE_OK; } diff --git a/manifest b/manifest index 1cf656fb1c..2c5b73a1b1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_INDEX_SCAN_HEX\sbit\sto\sthe\ssqlite3_index_info.idxFlags\sbitmask.\nWhen\sset,\sthis\sbit\scauses\sthe\sEXPLAIN\sQUERY\sPLAN\soutput\sto\sshow\sthe\sidxNum\nvalue\sin\shex\srather\sthan\sin\sdecimal.\s\sThis\sis\spurely\sa\sdebugging\said. -D 2024-08-22T16:22:08.900 +C Enhance\sthe\sgenerate_series()\stable-valued\sfunction\ssuch\sthat\sit\sis\sable\sto\nrecognize\sequality\sand\sinequality\sconstraints\son\sthe\s"value"\scolumn\sand\noptimize\sits\soperating\saccordingly. +D 2024-08-22T18:12:10.402 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -417,7 +417,7 @@ F ext/misc/regexp.c 4bdd0045912f81c84908bd535ec5ad3b1c8540b4287c70ab840709636240 F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 -F ext/misc/series.c d96e5aac21658c6b5d54f918ac140460ec7197734c1a4fba806950831a7b1e7a +F ext/misc/series.c a6089b5e8e3002bd1e5d9877cee6aead0b9a6426e406c09a399817db9e9ae823 F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d F ext/misc/shathree.c 1821d90a0040c9accdbe3e3527d378d30569475d758aa70f6848924c0b430e8c F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 @@ -1441,7 +1441,7 @@ F test/memjournal2.test dbc2c5cb5f7b38950f4f6dc3e73fcecf0fcbed3fc32c7ce913bba164 F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2 F test/memsubsys1.test 86b8158752af9188ed5b32a30674a1ef71183e6bc4e6808e815cd658ca9058a6 F test/memsubsys2.test 774b93cb09ca50d1b759bb7c645baa2a9ce172edc3a3da67d5150a26a9fc2a08 -F test/merge1.test 2de6d6ef8d25402764b1aab49d8f9d7f89208c89a6674e437f76de4c812157b8 +F test/merge1.test 7dd9dc6838bcd0623a069485fe3a8dd498a051c16e1877cf84f506c0d6a29b43 F test/minmax.test fe638b55d77d2375531a8f549b338eafcd9adfbd2f72df37ed77d9b26ca0a71a F test/minmax2.test cf9311babb6f0518d04e42fd6a42c619531c4309a9dd790a2c4e9b3bc595e0de F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 @@ -1700,7 +1700,7 @@ F test/sync.test 89539f4973c010eda5638407e71ca7fddbcd8e0594f4c9980229f804d433309 F test/sync2.test 8f9f7d4f6d5be8ca8941a8dadcc4299e558cb6a1ff653a9469146c7a76ef2039 F test/syscall.test a067468b43b8cb2305e9f9fe414e5f40c875bb5d2cba5f00b8154396e95fcf37 F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test f150d206294471d20f50029e6b46b76b87a7a010b16dc57eb44245c76dd02802 +F test/tabfunc01.test 6002a5f37b76355f173c75c2b3b03173b19d6a8b078c5baaa4c78bbcd0fa6323 F test/table.test 7862a00b58b5541511a26757ea9c5c7c3f8298766e98aa099deec703d9c0a8e0 F test/tableapi.test ecbcc29c4ab62c1912c3717c48ea5c5e59f7d64e4a91034e6148bd2b82f177f4 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -1712,7 +1712,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d1631311a16 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc -F test/tester.tcl e88c498c369cff6bf0898db6d04088685066730be51821ef775ef13fd2b1d077 +F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 F test/testrunner.tcl 5d02deeba7a53baeadae6aa7641d90aac58fdfa3a7bcac85cfcfd752b1aab87c F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6500baa9914b08ce19c361a69f19a80e5d800fcb82579d1c1e03601c7a664338 -R 7b7b9fd0e23c278e007dcb15333f71d2 +P 6c00e88ebdb41d6317bb8758825521614dedc2e6e6289ff415c5f0406eed815b +R c06569ccdd3e5d2b3b096a4379f23ac8 U drh -Z e92224536d6b88aa809210ea20e1cd7b +Z e410ad1cfdbbb6e926b30bd406bc8816 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a3815e38d9..b90e36fb5a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c00e88ebdb41d6317bb8758825521614dedc2e6e6289ff415c5f0406eed815b +d50b784807333c5461a2d027778c746c799285b95bb1952f142b317ea2846460 diff --git a/test/merge1.test b/test/merge1.test index 7ec4dab108..686271648a 100644 --- a/test/merge1.test +++ b/test/merge1.test @@ -64,21 +64,21 @@ do_eqp_test 101 { | |--LEFT | | `--MERGE (UNION ALL) | | |--LEFT - | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | | | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: | | `--RIGHT - | | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: | `--RIGHT - | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: `--RIGHT `--MERGE (UNION ALL) |--LEFT | `--MERGE (UNION ALL) | |--LEFT - | | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: | `--RIGHT - | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: `--RIGHT - `--SCAN generate_series VIRTUAL TABLE INDEX 23: + `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: } # Same test with the blanced-merge optimization @@ -129,17 +129,17 @@ do_eqp_test 111 { | | | |--LEFT | | | | `--MERGE (UNION ALL) | | | | |--LEFT - | | | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | | | | | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: | | | | `--RIGHT - | | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | | | | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: | | | `--RIGHT - | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | | | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: | | `--RIGHT - | | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: | `--RIGHT - | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: `--RIGHT - `--SCAN generate_series VIRTUAL TABLE INDEX 23: + `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: } finish_test diff --git a/test/tabfunc01.test b/test/tabfunc01.test index 3a62b81f99..8c24198e1d 100644 --- a/test/tabfunc01.test +++ b/test/tabfunc01.test @@ -121,26 +121,26 @@ do_eqp_test tabfunc01-3.10 { SELECT value FROM generate_series(1,10) ORDER BY value; } { QUERY PLAN - `--SCAN generate_series VIRTUAL TABLE INDEX 19: + `--SCAN generate_series VIRTUAL TABLE INDEX 0x13: } do_eqp_test tabfunc01-3.11 { SELECT value FROM generate_series(1,10) ORDER BY +value; } { QUERY PLAN - |--SCAN generate_series VIRTUAL TABLE INDEX 3: + |--SCAN generate_series VIRTUAL TABLE INDEX 0x3: `--USE TEMP B-TREE FOR ORDER BY } do_eqp_test tabfunc01-3.12 { SELECT value FROM generate_series(1,10) ORDER BY value, stop; } { QUERY PLAN - `--SCAN generate_series VIRTUAL TABLE INDEX 19: + `--SCAN generate_series VIRTUAL TABLE INDEX 0x13: } do_eqp_test tabfunc01-3.13 { SELECT value FROM generate_series(1,10) ORDER BY stop, value; } { QUERY PLAN - |--SCAN generate_series VIRTUAL TABLE INDEX 3: + |--SCAN generate_series VIRTUAL TABLE INDEX 0x3: `--USE TEMP B-TREE FOR ORDER BY } @@ -156,9 +156,9 @@ do_eqp_test tabfunc01-3.20 { QUERY PLAN `--MERGE (UNION ALL) |--LEFT - | `--SCAN generate_series VIRTUAL TABLE INDEX 23: + | `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: `--RIGHT - `--SCAN generate_series VIRTUAL TABLE INDEX 23: + `--SCAN generate_series VIRTUAL TABLE INDEX 0x17: } diff --git a/test/tester.tcl b/test/tester.tcl index 43f7c7a047..164ee47f42 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -985,7 +985,7 @@ proc query_plan_graph {sql} { } set a "\n QUERY PLAN\n" append a [append_graph " " dx cx 0] - regsub -all { 0x[A-F0-9]+\y} $a { xxxxxx} a + regsub -all {SUBQUERY 0x[A-F0-9]+\y} $a {SUBQUERY xxxxxx} a regsub -all {(MATERIALIZE|CO-ROUTINE|SUBQUERY) \d+\y} $a {\1 xxxxxx} a regsub -all {\((join|subquery)-\d+\)} $a {(\1-xxxxxx)} a return $a From 8d4edd0d67db8048f86426378ff8f7bba3c9e67b Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 23 Aug 2024 15:18:02 +0000 Subject: [PATCH 0709/1030] Add fts5 auxiliary function fts5_get_locale(). For querying the locale of a stored value. FossilOrigin-Name: 396f720f36a937145ac727c2750acfd26e4eda350b46d648d82a7e9985545a9f --- ext/fts5/fts5_aux.c | 54 +++++++++++++++++++-- ext/fts5/test/fts5faultI.test | 24 +++++++++ ext/fts5/test/fts5locale.test | 91 +++++++++++++++++++++++++++++++++++ manifest | 18 +++---- manifest.uuid | 2 +- 5 files changed, 176 insertions(+), 13 deletions(-) diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c index eb3f7e359d..ad578156da 100644 --- a/ext/fts5/fts5_aux.c +++ b/ext/fts5/fts5_aux.c @@ -746,6 +746,53 @@ static void fts5Bm25Function( } } +/* +** Implementation of fts5_get_locale() function. +*/ +static void fts5GetLocaleFunction( + const Fts5ExtensionApi *pApi, /* API offered by current FTS version */ + Fts5Context *pFts, /* First arg to pass to pApi functions */ + sqlite3_context *pCtx, /* Context for returning result/error */ + int nVal, /* Number of values in apVal[] array */ + sqlite3_value **apVal /* Array of trailing arguments */ +){ + int iCol = 0; + int eType = 0; + int rc = SQLITE_OK; + const char *zLocale = 0; + int nLocale = 0; + + /* xColumnLocale() must be available */ + assert( pApi->iVersion>=4 ); + + if( nVal!=1 ){ + const char *z = "wrong number of arguments to function fts5_get_locale()"; + sqlite3_result_error(pCtx, z, -1); + return; + } + + eType = sqlite3_value_numeric_type(apVal[0]); + if( eType!=SQLITE_INTEGER ){ + const char *z = "non-integer argument passed to function fts5_get_locale()"; + sqlite3_result_error(pCtx, z, -1); + return; + } + + iCol = sqlite3_value_int(apVal[0]); + if( iCol<0 || iCol>=pApi->xColumnCount(pFts) ){ + sqlite3_result_error_code(pCtx, SQLITE_RANGE); + return; + } + + rc = pApi->xColumnLocale(pFts, iCol, &zLocale, &nLocale); + if( rc!=SQLITE_OK ){ + sqlite3_result_error_code(pCtx, rc); + return; + } + + sqlite3_result_text(pCtx, zLocale, nLocale, SQLITE_TRANSIENT); +} + int sqlite3Fts5AuxInit(fts5_api *pApi){ struct Builtin { const char *zFunc; /* Function name (nul-terminated) */ @@ -753,9 +800,10 @@ int sqlite3Fts5AuxInit(fts5_api *pApi){ fts5_extension_function xFunc;/* Callback function */ void (*xDestroy)(void*); /* Destructor function */ } aBuiltin [] = { - { "snippet", 0, fts5SnippetFunction, 0 }, - { "highlight", 0, fts5HighlightFunction, 0 }, - { "bm25", 0, fts5Bm25Function, 0 }, + { "snippet", 0, fts5SnippetFunction, 0 }, + { "highlight", 0, fts5HighlightFunction, 0 }, + { "bm25", 0, fts5Bm25Function, 0 }, + { "fts5_get_locale", 0, fts5GetLocaleFunction, 0 }, }; int rc = SQLITE_OK; /* Return code */ int i; /* To iterate through builtin functions */ diff --git a/ext/fts5/test/fts5faultI.test b/ext/fts5/test/fts5faultI.test index 08a6bf056b..63bfdd68ac 100644 --- a/ext/fts5/test/fts5faultI.test +++ b/ext/fts5/test/fts5faultI.test @@ -231,6 +231,30 @@ do_faultsim_test 9.2 -faults oom* -prep { faultsim_test_result {0 1} } +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 10.0 { + CREATE VIRTUAL TABLE ft USING fts5(x, locale=1); + INSERT INTO ft VALUES(fts5_locale('hello', 'one two three i ii iii')); + INSERT INTO ft VALUES('four five six iv v vi'); + INSERT INTO ft VALUES('eight nine ten viii ix x'); +} {} + +do_execsql_test 10.1 { + SELECT fts5_get_locale(ft, 0) FROM ft WHERE x MATCH 'one AND two AND three' +} {hello} + +faultsim_save_and_close +do_faultsim_test 10 -faults oom* -prep { + faultsim_restore_and_reopen +} -body { + execsql { + SELECT fts5_get_locale(ft, 0) FROM ft WHERE x MATCH 'one AND two AND three' + } +} -test { + faultsim_test_result {0 hello} +} finish_test diff --git a/ext/fts5/test/fts5locale.test b/ext/fts5/test/fts5locale.test index d64df18491..684dcecd80 100644 --- a/ext/fts5/test/fts5locale.test +++ b/ext/fts5/test/fts5locale.test @@ -572,5 +572,96 @@ do_test 12.0 { } msg] $msg } {1 {error in fts5_api.xCreateTokenizer_v2()}} +#------------------------------------------------------------------------- +# Tests for auxiliary function fts5_get_locale(). +# +reset_db + +# Check that if the table does not support locale=1, fts5_get_locale() +# always returns NULL. +do_execsql_test 13.1.0 { + CREATE VIRTUAL TABLE nolocale USING fts5(a, b); + INSERT INTO nolocale VALUES('one two three', 'four five six'); + INSERT INTO nolocale VALUES('three two one', 'seven eight nine'); +} +do_execsql_test 13.1.1 { + SELECT fts5_get_locale(nolocale, 0) IS NULL FROM nolocale; +} {1 1} +do_execsql_test 13.1.2 { + SELECT fts5_get_locale(nolocale, 1) IS NULL FROM nolocale('one + two'); +} {1} +do_execsql_test 13.1.3 { + SELECT fts5_get_locale(nolocale, 0) IS NULL FROM nolocale('one AND two'); +} {1 1} +do_execsql_test 13.1.4 { + SELECT + fts5_get_locale(nolocale, 1) IS NULL + FROM nolocale('three AND two') ORDER BY rank +} {1 1} +do_catchsql_test 13.1.5 { + SELECT fts5_get_locale(nolocale, 2) IS NULL FROM nolocale('three AND two'); +} {1 {column index out of range}} +do_catchsql_test 13.1.6 { + SELECT fts5_get_locale(nolocale, -1) IS NULL FROM nolocale('three AND two'); +} {1 {column index out of range}} +do_catchsql_test 13.1.7 { + SELECT fts5_get_locale(nolocale) IS NULL FROM nolocale('three AND two'); +} {1 {wrong number of arguments to function fts5_get_locale()}} +do_catchsql_test 13.1.8 { + SELECT fts5_get_locale(nolocale, 0, 0) IS NULL FROM nolocale('three AND two'); +} {1 {wrong number of arguments to function fts5_get_locale()}} +do_catchsql_test 13.1.9 { + SELECT fts5_get_locale(nolocale, 'text') FROM nolocale('three AND two'); +} {1 {non-integer argument passed to function fts5_get_locale()}} + + +# Check that if the table does support locale=1, fts5_get_locale() +# returns the locale of the identified row/column. +do_execsql_test 13.2.0 { + CREATE VIRTUAL TABLE ft USING fts5(a, b, locale=1); + INSERT INTO ft VALUES( + fts5_locale('th_TH', 'one two three'), 'four five six seven' + ); + INSERT INTO ft VALUES( + 'three two one', fts5_locale('en_AU', 'seven eight nine') + ); +} + +do_execsql_test 13.2.1 { + SELECT quote(fts5_get_locale(ft, 0)), quote(fts5_get_locale(ft, 1)) FROM ft +} { 'th_TH' NULL NULL 'en_AU' } +do_execsql_test 13.2.2 { + SELECT + quote(fts5_get_locale(ft, 0)), quote(fts5_get_locale(ft, 1)) + FROM ft('one AND three') +} { 'th_TH' NULL NULL 'en_AU' } +do_execsql_test 13.2.3 { + SELECT + quote(fts5_get_locale(ft, 0)), quote(fts5_get_locale(ft, 1)) + FROM ft('one AND three') ORDER BY rank +} { NULL 'en_AU' 'th_TH' NULL } +do_execsql_test 13.2.4 { + SELECT + quote(fts5_get_locale(ft, 0)), quote(fts5_get_locale(ft, 1)) + FROM ft('one AND three') ORDER BY rowid +} { 'th_TH' NULL NULL 'en_AU' } + +do_execsql_test 13.2.5 { + SELECT + quote(fts5_get_locale(ft, '0')), quote(fts5_get_locale(ft, 1)) + FROM ft('one AND three') ORDER BY rowid +} { 'th_TH' NULL NULL 'en_AU' } + +do_catchsql_test 13.2.6 { + SELECT + quote(fts5_get_locale(ft, '0.0')), quote(fts5_get_locale(ft, 1)) + FROM ft('one AND three') ORDER BY rowid +} {1 {non-integer argument passed to function fts5_get_locale()}} +do_catchsql_test 13.2.7 { + SELECT + quote(fts5_get_locale(ft, 0.0)), quote(fts5_get_locale(ft, 1)) + FROM ft('one AND three') ORDER BY rowid +} {1 {non-integer argument passed to function fts5_get_locale()}} + finish_test diff --git a/manifest b/manifest index 2c5b73a1b1..3cfdd034e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sgenerate_series()\stable-valued\sfunction\ssuch\sthat\sit\sis\sable\sto\nrecognize\sequality\sand\sinequality\sconstraints\son\sthe\s"value"\scolumn\sand\noptimize\sits\soperating\saccordingly. -D 2024-08-22T18:12:10.402 +C Add\sfts5\sauxiliary\sfunction\sfts5_get_locale().\sFor\squerying\sthe\slocale\sof\sa\sstored\svalue. +D 2024-08-23T15:18:02.618 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -94,7 +94,7 @@ F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a0 F ext/fts5/extract_api_docs.tcl 1db7f85f4d84b7b6f33336155d5053fafc3c8debd074422d8003c8f7fa4d0fdb F ext/fts5/fts5.h c65fc7799a4cd6774628da4fa9408955623e504d7369ab5b89c4413fdfe11eb5 F ext/fts5/fts5Int.h 26a71a09cefa4ef6b4516b204ed48da3e1380970a19b3482eea7c5d805655360 -F ext/fts5/fts5_aux.c 12cd2512f869217c38b70c31de5b5f741812734fafa80f55b32ea9bbd96e2152 +F ext/fts5/fts5_aux.c 65a0468dd177d6093aa9ae1622e6d86b0136b8d267c62c0ad6493ad1e9a3d759 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81cbefc109ea F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 @@ -177,7 +177,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5faultI.test fbc65a64944fb747f6d3fb30628a807d5cce1bca43c11df40e7770ad7a7ed593 +F ext/fts5/test/fts5faultI.test e1e8a927122a8c3be8614a59717e838cad0505ba0a6f404983da8430e7aeb14d F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -187,7 +187,7 @@ F ext/fts5/test/fts5interrupt.test 20d04204d3e341b104c0c24a41596b6393a3a81eba104 F ext/fts5/test/fts5lastrowid.test f36298a1fb9f988bde060a274a7ce638faa9c38a31400f8d2d27ea9373e0c4a1 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fce79fa43004dff01c -F ext/fts5/test/fts5locale.test 79cbd3000ae269de50826f6061c81f7c9fdb21dd9954c0b7f9485263482c539d +F ext/fts5/test/fts5locale.test 797cf6f5e017462ab11313ce884b9f1df8ff063811e74ef42190cd19ed6b600b F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6c00e88ebdb41d6317bb8758825521614dedc2e6e6289ff415c5f0406eed815b -R c06569ccdd3e5d2b3b096a4379f23ac8 -U drh -Z e410ad1cfdbbb6e926b30bd406bc8816 +P d50b784807333c5461a2d027778c746c799285b95bb1952f142b317ea2846460 +R 7170ba769edcf90a031dd78df3acb3d2 +U dan +Z 6e0f0933950fea8415d62eb627301612 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b90e36fb5a..9c9dac50bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d50b784807333c5461a2d027778c746c799285b95bb1952f142b317ea2846460 +396f720f36a937145ac727c2750acfd26e4eda350b46d648d82a7e9985545a9f From 789da358487944d96eb3290e76d1c848b9c8faea Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 23 Aug 2024 17:40:29 +0000 Subject: [PATCH 0710/1030] Fix a problem in the ext/fts5/extract_api_docs.tcl script. FossilOrigin-Name: 9a9d0f6301faefe324261f03543023ffb6a90823349c6946abb0df2f69b31f96 --- ext/fts5/extract_api_docs.tcl | 2 +- ext/fts5/fts5.h | 6 +++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ext/fts5/extract_api_docs.tcl b/ext/fts5/extract_api_docs.tcl index 634dc70cbd..6ee71c262c 100644 --- a/ext/fts5/extract_api_docs.tcl +++ b/ext/fts5/extract_api_docs.tcl @@ -82,7 +82,7 @@ proc get_struct_docs {data names} { set current_doc "" } set subject n/a - regexp {^ *([[:alpha:]]*)} $line -> subject + regexp {^ *([[:alnum:]_]*)} $line -> subject if {[lsearch $names $subject]>=0} { set current_header $subject } else { diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 682a8da386..67adb40ac6 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -379,9 +379,9 @@ struct Fts5ExtensionApi { /* Below this point are iVersion>=4 only */ int (*xColumnLocale)(Fts5Context*, int iCol, const char **pz, int *pn); int (*xTokenize_v2)(Fts5Context*, - const char *pText, int nText, /* Text to tokenize */ - const char *pLoc, int nLoc, /* Locale to pass to tokenizer */ - void *pCtx, /* Context passed to xToken() */ + const char *pText, int nText, /* Text to tokenize */ + const char *pLocale, int nLocale, /* Locale to pass to tokenizer */ + void *pCtx, /* Context passed to xToken() */ int (*xToken)(void*, int, const char*, int, int, int) /* Callback */ ); }; diff --git a/manifest b/manifest index 3cfdd034e0..bb205d7a92 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfts5\sauxiliary\sfunction\sfts5_get_locale().\sFor\squerying\sthe\slocale\sof\sa\sstored\svalue. -D 2024-08-23T15:18:02.618 +C Fix\sa\sproblem\sin\sthe\sext/fts5/extract_api_docs.tcl\sscript. +D 2024-08-23T17:40:29.728 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -91,8 +91,8 @@ F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 63db9624ccf70d4887836c320eda93ab552f21008f3be7ede551eac3ead62baa F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb -F ext/fts5/extract_api_docs.tcl 1db7f85f4d84b7b6f33336155d5053fafc3c8debd074422d8003c8f7fa4d0fdb -F ext/fts5/fts5.h c65fc7799a4cd6774628da4fa9408955623e504d7369ab5b89c4413fdfe11eb5 +F ext/fts5/extract_api_docs.tcl 009cf59c77afa86d137b0cca3e3b1a5efbe2264faa2df233f9a7aa8563926d15 +F ext/fts5/fts5.h c72759fd15179934f10b71ae51ee999e8558f696335e4ec2d049243b764354ee F ext/fts5/fts5Int.h 26a71a09cefa4ef6b4516b204ed48da3e1380970a19b3482eea7c5d805655360 F ext/fts5/fts5_aux.c 65a0468dd177d6093aa9ae1622e6d86b0136b8d267c62c0ad6493ad1e9a3d759 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d50b784807333c5461a2d027778c746c799285b95bb1952f142b317ea2846460 -R 7170ba769edcf90a031dd78df3acb3d2 +P 396f720f36a937145ac727c2750acfd26e4eda350b46d648d82a7e9985545a9f +R 9811f59e13ff374b57741662af2d5cd0 U dan -Z 6e0f0933950fea8415d62eb627301612 +Z b44a5154d84ee4e53cef82c304d55edf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9c9dac50bd..be09817682 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -396f720f36a937145ac727c2750acfd26e4eda350b46d648d82a7e9985545a9f +9a9d0f6301faefe324261f03543023ffb6a90823349c6946abb0df2f69b31f96 From 7766c9943ebecbaa3320efcefa3afbec431f2b38 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 23 Aug 2024 21:20:50 +0000 Subject: [PATCH 0711/1030] Eliminate use of strcpy() in shell.c.in to squelch an unwarranted link-time warning on OpenBSD. FossilOrigin-Name: 32e9bf7f972144eacbb2580151220bc4fc1cbcc8bcf586ffd8e10762abf75c7e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 10 +++++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index bb205d7a92..5736796277 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\sext/fts5/extract_api_docs.tcl\sscript. -D 2024-08-23T17:40:29.728 +C Eliminate\suse\sof\sstrcpy()\sin\sshell.c.in\sto\ssquelch\san\sunwarranted\slink-time\swarning\son\sOpenBSD. +D 2024-08-23T21:20:50.763 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -765,7 +765,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 9a45cd618ed3cd09927e04bb0ccfd929fb5efa03a7166daec4645d230b7267f3 +F src/shell.c.in 990e77ca805273edd55071c71327d202f1854e19c2e9437c039d91ff3192d7c4 F src/sqlite.h.in f07bff4225a1244efd604a0ffef81ed69f29d3dbaed7e22f906f26229ba3ca9e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 396f720f36a937145ac727c2750acfd26e4eda350b46d648d82a7e9985545a9f -R 9811f59e13ff374b57741662af2d5cd0 -U dan -Z b44a5154d84ee4e53cef82c304d55edf +P 9a9d0f6301faefe324261f03543023ffb6a90823349c6946abb0df2f69b31f96 +R 0473ef71b70c85fedef9e64071463927 +U stephan +Z 10e164d89e2d1a1189bcd188933ef2aa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index be09817682..d54c88a271 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a9d0f6301faefe324261f03543023ffb6a90823349c6946abb0df2f69b31f96 +32e9bf7f972144eacbb2580151220bc4fc1cbcc8bcf586ffd8e10762abf75c7e diff --git a/src/shell.c.in b/src/shell.c.in index a75b511903..1a1d357749 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -534,6 +534,14 @@ static char *shell_strncpy(char *dest, const char *src, size_t n){ return dest; } +/* +** strcpy() workalike to squelch an unwarranted link-time warning +** from OpenBSD. +*/ +static void shell_strcpy(char *dest, const char *src){ + while( (*(dest++) = *(src++))!=0 ){} +} + /* ** Optionally disable dynamic continuation prompt. ** Unless disabled, the continuation prompt shows open SQL lexemes if any, @@ -599,7 +607,7 @@ static char *dynamicContinuePrompt(void){ size_t ncp = strlen(continuePrompt); size_t ndp = strlen(dynPrompt.zScannerAwaits); if( ndp > ncp-3 ) return continuePrompt; - strcpy(dynPrompt.dynamicPrompt, dynPrompt.zScannerAwaits); + shell_strcpy(dynPrompt.dynamicPrompt, dynPrompt.zScannerAwaits); while( ndp<3 ) dynPrompt.dynamicPrompt[ndp++] = ' '; shell_strncpy(dynPrompt.dynamicPrompt+3, continuePrompt+3, PROMPT_LEN_MAX-4); From 27095fc4a5ed21df5023c4fb35ebeef10d7894fc Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 24 Aug 2024 11:48:19 +0000 Subject: [PATCH 0712/1030] Ensure that the WhereLoop.u.btree.pOrderBy field added by the order-by-subquery optimization [7a0cdc7edb704a88] is correctly initialized. dbsqlfuzz 437be171a98687082a31ea6efc2fd5c5d64481c8. FossilOrigin-Name: b75f8b2252aefe7bb96fa237205a1a9dc88c46d9ec09bca7407e6c636b203e7e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5736796277..3751b90e1b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Eliminate\suse\sof\sstrcpy()\sin\sshell.c.in\sto\ssquelch\san\sunwarranted\slink-time\swarning\son\sOpenBSD. -D 2024-08-23T21:20:50.763 +C Ensure\sthat\sthe\sWhereLoop.u.btree.pOrderBy\sfield\sadded\sby\sthe\norder-by-subquery\soptimization\s[7a0cdc7edb704a88]\sis\scorrectly\ninitialized.\s\sdbsqlfuzz\s437be171a98687082a31ea6efc2fd5c5d64481c8. +D 2024-08-24T11:48:19.350 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -850,7 +850,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 70392f65e2c76a27ab1faed05892c2402ce547e574074a4f10282b3bc1ffe4eb +F src/where.c c046dd58c3410f7b7528e1e6317cb876398557bad346d568ed8562321a7d002d F src/whereInt.h a5d079c346a658b7a6e9e47bb943d021e02fa1e6aed3b964ca112112a4892192 F src/wherecode.c 5172d647798134e7c92536ddffe7e530c393d79b5dedd648b88faf2646c65baf F src/whereexpr.c 44f41ae554c7572e1de1485b3169b233ee04d464b2ee5881687ede3bf07cacfa @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9a9d0f6301faefe324261f03543023ffb6a90823349c6946abb0df2f69b31f96 -R 0473ef71b70c85fedef9e64071463927 -U stephan -Z 10e164d89e2d1a1189bcd188933ef2aa +P 32e9bf7f972144eacbb2580151220bc4fc1cbcc8bcf586ffd8e10762abf75c7e +R c767a4091aaf30f3cd810bce15db7a5b +U drh +Z 6904df1088a904060173307e81bc10aa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d54c88a271..b7454fff9f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32e9bf7f972144eacbb2580151220bc4fc1cbcc8bcf586ffd8e10762abf75c7e +b75f8b2252aefe7bb96fa237205a1a9dc88c46d9ec09bca7407e6c636b203e7e diff --git a/src/where.c b/src/where.c index a82f0305b4..2b835009db 100644 --- a/src/where.c +++ b/src/where.c @@ -3987,6 +3987,7 @@ static int whereLoopAddBtree( pNew->prereq = mPrereq; pNew->nOut = rSize; pNew->u.btree.pIndex = pProbe; + pNew->u.btree.pOrderBy = 0; b = indexMightHelpWithOrderBy(pBuilder, pProbe, pSrc->iCursor); /* The ONEPASS_DESIRED flags never occurs together with ORDER BY */ From 58b08d77029b63a80cc7bb920819b177c06bdfe6 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 24 Aug 2024 15:54:15 +0000 Subject: [PATCH 0713/1030] Avoid a stack overflow that could be caused by a recursively defined WINDOW() with a strategically embedded error. FossilOrigin-Name: bada54bd6bf54190e40aa721b77081015957d204c7b6a9fdbe8c67bcf20798f8 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/resolve.c | 2 +- test/windowE.test | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 3751b90e1b..d040579c44 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\sWhereLoop.u.btree.pOrderBy\sfield\sadded\sby\sthe\norder-by-subquery\soptimization\s[7a0cdc7edb704a88]\sis\scorrectly\ninitialized.\s\sdbsqlfuzz\s437be171a98687082a31ea6efc2fd5c5d64481c8. -D 2024-08-24T11:48:19.350 +C Avoid\sa\sstack\soverflow\sthat\scould\sbe\scaused\sby\sa\srecursively\sdefined\sWINDOW()\swith\sa\sstrategically\sembedded\serror. +D 2024-08-24T15:54:15.509 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -762,7 +762,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab +F src/resolve.c fc033f60ce022b1a18d441882965c77042a184d5ea14f8995b6984d38d8bb323 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 990e77ca805273edd55071c71327d202f1854e19c2e9437c039d91ff3192d7c4 @@ -2069,7 +2069,7 @@ F test/windowA.test 6d63dc1260daa17141a55007600581778523a8b420629f1282d2acfc36af F test/windowB.test aad7c31739999f68a98a813cfd78390918fc70f56d2d925317a1523cab548ecf F test/windowC.test 6fd75f5bb2f1343d34e470e36e68f0ff638d8a42f6aa7d99471261b31a0d42f2 F test/windowD.test 65cf5a765fb8072450e8a0de2979ce7f09a38d87724fe1280c6444073e3da49b -F test/windowE.test 6ba0c8048e4cc02b942e56640f8fcd50fd7ca72c876656c40f6baf42e316684c +F test/windowE.test c98507e0b0d95980ad25845db758557757be2d7054198ccf522c7d277057a3df F test/windowerr.tcl f5acd6fbc210d7b5546c0e879d157888455cd4a17a1d3f28f07c1c8a387019e0 F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3cc1819b F test/windowfault.test 15094c1529424e62f798bc679e3fe9dfab6e8ba2f7dfe8c923b6248c31660a7c @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 32e9bf7f972144eacbb2580151220bc4fc1cbcc8bcf586ffd8e10762abf75c7e -R c767a4091aaf30f3cd810bce15db7a5b -U drh -Z 6904df1088a904060173307e81bc10aa +P b75f8b2252aefe7bb96fa237205a1a9dc88c46d9ec09bca7407e6c636b203e7e +R 0795580169838cc9e02bb8801025ded0 +U dan +Z 355e8a98a035830f16c29e0d1fb54ccb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b7454fff9f..e2adcf6c6d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b75f8b2252aefe7bb96fa237205a1a9dc88c46d9ec09bca7407e6c636b203e7e +bada54bd6bf54190e40aa721b77081015957d204c7b6a9fdbe8c67bcf20798f8 diff --git a/src/resolve.c b/src/resolve.c index 6dcb4e7322..202e87db95 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1300,7 +1300,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ sqlite3WalkExprList(pWalker, pExpr->pLeft->x.pList); } #ifndef SQLITE_OMIT_WINDOWFUNC - if( pWin ){ + if( pWin && pParse->nErr==0 ){ Select *pSel = pNC->pWinSelect; assert( pWin==0 || (ExprUseYWin(pExpr) && pWin==pExpr->y.pWin) ); if( IN_RENAME_OBJECT==0 ){ diff --git a/test/windowE.test b/test/windowE.test index f20bcdaaa8..9128468b3c 100644 --- a/test/windowE.test +++ b/test/windowE.test @@ -54,5 +54,25 @@ do_execsql_test 1.3 { 5 5,4 5,4,1 5,4,1,6 5,4,1,6,3 5,4,1,6,3,2 } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 { + CREATE TABLE t1(x); +} + +sqlite3_create_aggregate db + +breakpoint +do_catchsql_test 2.1 { + SELECT min(x) OVER w1 FROM t1 + WINDOW w1 AS (PARTITION BY x_count(x) OVER w1); +} {1 {x_count() may not be used as a window function}} + +do_catchsql_test 2.2 { + SELECT min(x) FILTER (WHERE x_count(x) OVER w1) OVER w1 FROM t1 + WINDOW w1 AS (PARTITION BY x OVER w1); +} {1 {near "OVER": syntax error}} + + finish_test From f9eff9052d3574ee275823347d46792ada12f4be Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 24 Aug 2024 18:42:39 +0000 Subject: [PATCH 0714/1030] Remove a term from an assert() that is no longer relevant. FossilOrigin-Name: 8b4766252b80075354a6b1406c5430fe999a6490aa3e079893fcc682d88734f7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d040579c44..064ca3e7dd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sa\sstack\soverflow\sthat\scould\sbe\scaused\sby\sa\srecursively\sdefined\sWINDOW()\swith\sa\sstrategically\sembedded\serror. -D 2024-08-24T15:54:15.509 +C Remove\sa\sterm\sfrom\san\sassert()\sthat\sis\sno\slonger\srelevant. +D 2024-08-24T18:42:39.760 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -762,7 +762,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c fc033f60ce022b1a18d441882965c77042a184d5ea14f8995b6984d38d8bb323 +F src/resolve.c 2c127880c0634962837f16f2f48a295e514357af959330cc038de73015d5b5e8 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 990e77ca805273edd55071c71327d202f1854e19c2e9437c039d91ff3192d7c4 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b75f8b2252aefe7bb96fa237205a1a9dc88c46d9ec09bca7407e6c636b203e7e -R 0795580169838cc9e02bb8801025ded0 -U dan -Z 355e8a98a035830f16c29e0d1fb54ccb +P bada54bd6bf54190e40aa721b77081015957d204c7b6a9fdbe8c67bcf20798f8 +R 00dd14ae6fd191eb1e24d275e84ccb9b +U drh +Z 4d530e51c1fc3bb001032c5e8c4a226a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e2adcf6c6d..803a4f07f2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bada54bd6bf54190e40aa721b77081015957d204c7b6a9fdbe8c67bcf20798f8 +8b4766252b80075354a6b1406c5430fe999a6490aa3e079893fcc682d88734f7 diff --git a/src/resolve.c b/src/resolve.c index 202e87db95..b755cc8646 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1302,7 +1302,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ #ifndef SQLITE_OMIT_WINDOWFUNC if( pWin && pParse->nErr==0 ){ Select *pSel = pNC->pWinSelect; - assert( pWin==0 || (ExprUseYWin(pExpr) && pWin==pExpr->y.pWin) ); + assert( ExprUseYWin(pExpr) && pWin==pExpr->y.pWin ); if( IN_RENAME_OBJECT==0 ){ sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef); if( pParse->db->mallocFailed ) break; From 1d5a12e6a59263982cfcc3e8326c82a998e6c583 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 24 Aug 2024 19:02:33 +0000 Subject: [PATCH 0715/1030] New ./configure option --enable-test-status causes testrunner.tcl to be run with the --status option for targets like mdevtest and releasetest. FossilOrigin-Name: 9ca8513c26e54c97f2d3c6105c42144100044727f6fb4c28048f7cd7270dd35e --- Makefile.in | 11 ++++++++--- configure | 49 +++++++++++++++++++++++++++++++++++-------------- configure.ac | 12 ++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 64 insertions(+), 26 deletions(-) diff --git a/Makefile.in b/Makefile.in index 44665184fc..b8149f846f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -117,6 +117,11 @@ HAVE_TCL = @HAVE_TCL@ # TCLSH_CMD = @TCLSH_CMD@ +# Additional options when running tests using testrunner.tcl +# This is usually either blank, or else --status +# +TSTRNNR_OPTS = @TSTRNNR_OPTS@ + # Where do we want to install the tcl plugin # TCLLIBDIR = @TCLLIBDIR@ @@ -1363,10 +1368,10 @@ testrunner: testfixture$(TEXE) devtest: srctree-check testfixture$(TEXE) fuzztest testrunner mdevtest: srctree-check has_tclsh85 - $(TCLSH_CMD) $(TOP)/test/testrunner.tcl mdevtest + $(TCLSH_CMD) $(TOP)/test/testrunner.tcl mdevtest $(TSTRNNR_OPTS) sdevtest: has_tclsh85 - $(TCLSH_CMD) $(TOP)/test/testrunner.tcl sdevtest + $(TCLSH_CMD) $(TOP)/test/testrunner.tcl sdevtest $(TSTRNNR_OPTS) # Validate that various generated files in the source tree # are up-to-date. @@ -1377,7 +1382,7 @@ srctree-check: $(TOP)/tool/srctree-check.tcl # Testing for a release # releasetest: srctree-check testfixture$(TEXE) - ./testfixture$(TEXE) $(TOP)/test/testrunner.tcl release + ./testfixture$(TEXE) $(TOP)/test/testrunner.tcl release $(TSTRNNR_OPTS) # Minimal testing that runs in less than 3 minutes # diff --git a/configure b/configure index 5f60385c28..12f96ceba4 100755 --- a/configure +++ b/configure @@ -793,6 +793,7 @@ HAVE_WASI_SDK RELEASE VERSION program_prefix +TSTRNNR_OPTS TCLLIBDIR HAVE_TCL TCL_STUB_LIB_SPEC @@ -889,6 +890,7 @@ enable_largefile with_tclsh with_tcl enable_tcl +enable_test_status with_wasi_sdk enable_threadsafe enable_releasemode @@ -1546,6 +1548,8 @@ Optional Features: --disable-largefile omit support for large files --disable-tcl omit building accessory programs that require TCL-dev + --enable-test-status show status of testing targets using VT100 cursor + movment --disable-threadsafe Disable mutexing --enable-releasemode Support libtool link to release mode --enable-tempstore Use an in-ram database for temporary tables @@ -3939,13 +3943,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3942: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3946: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3945: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3949: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3948: output\"" >&5) + (eval echo "\"\$as_me:3952: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5151,7 +5155,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5154 "configure"' > conftest.$ac_ext + echo '#line 5158 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6676,11 +6680,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6679: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6683: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6683: \$? = $ac_status" >&5 + echo "$as_me:6687: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7015,11 +7019,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7018: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7022: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7022: \$? = $ac_status" >&5 + echo "$as_me:7026: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7120,11 +7124,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7123: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7127: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7127: \$? = $ac_status" >&5 + echo "$as_me:7131: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7175,11 +7179,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7178: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7182: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7182: \$? = $ac_status" >&5 + echo "$as_me:7186: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9555,7 +9559,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9558 "configure" +#line 9562 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9651,7 +9655,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9654 "configure" +#line 9658 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10484,6 +10488,23 @@ if test "x${TCLLIBDIR+set}" != "xset" ; then TCLLIBDIR="${TCLLIBDIR}/sqlite3" fi +######### +# Set up options for running tests. +# +# Check whether --enable-test-status was given. +if test "${enable_test_status+set}" = set; then : + enableval=$enable_test_status; use_vt100=$enableval +else + use_vt100=no +fi + +if test $use_vt100; then + TSTRNNR_OPTS=--status +else + TSTRNNR_OPTS= +fi + + ######### # Set up an appropriate program prefix diff --git a/configure.ac b/configure.ac index 2936c4ab5a..6df65b9f13 100644 --- a/configure.ac +++ b/configure.ac @@ -227,6 +227,18 @@ if test "x${TCLLIBDIR+set}" != "xset" ; then TCLLIBDIR="${TCLLIBDIR}/sqlite3" fi +######### +# Set up options for running tests. +# +AC_ARG_ENABLE(test-status, AS_HELP_STRING([--enable-test-status],[show status of testing targets using VT100 cursor movment]), + [use_vt100=$enableval],[use_vt100=no]) +if test $use_vt100; then + TSTRNNR_OPTS=--status +else + TSTRNNR_OPTS= +fi +AC_SUBST(TSTRNNR_OPTS) + ######### # Set up an appropriate program prefix diff --git a/manifest b/manifest index 064ca3e7dd..18db7ded47 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Remove\sa\sterm\sfrom\san\sassert()\sthat\sis\sno\slonger\srelevant. -D 2024-08-24T18:42:39.760 +C New\s./configure\soption\s--enable-test-status\scauses\stestrunner.tcl\sto\sbe\nrun\swith\sthe\s--status\soption\sfor\stargets\slike\smdevtest\sand\sreleasetest. +D 2024-08-24T19:02:33.721 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 209e9c64edf499b0ea7a15448699101c01d15828af35a3439d32fc25fdf1b787 +F Makefile.in 101cb90f75c16ca3f8e7088364322441f9b01d6fdcef4a9c7f5fdcf78a3601a4 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 6c3fe8b6ce60e73f34a148c957d78b4648745c8d30e792423aa1a8d8bf12d065 F README.md 3d47ef5758e2de29d6f4e1aca714d51424baba86c8b561fef330f6ef2dc9282c @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 956e132a3e2481e5016e9ecaa0a2bdd9df95c1d923fa4fb2aa2cf9f0b3a54ad9 x -F configure.ac fd9ff064b142682964971fec3d867235e51e1f6de30a031e33f683b7699338ff +F configure b4c3cbde74d7bf7a3c046e2b9641c2784f67b0d3a8e56235a107e0a230fb26b0 x +F configure.ac f084a0765a98bc76513d0fba69264164d72d20cbfbc84d85f0a4e8400425b8d5 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bada54bd6bf54190e40aa721b77081015957d204c7b6a9fdbe8c67bcf20798f8 -R 00dd14ae6fd191eb1e24d275e84ccb9b +P 8b4766252b80075354a6b1406c5430fe999a6490aa3e079893fcc682d88734f7 +R 624c0fde9a976c048fe809e58bc6f948 U drh -Z 4d530e51c1fc3bb001032c5e8c4a226a +Z a7b786c85627cbad9eafd537f720c473 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 803a4f07f2..af222d498c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b4766252b80075354a6b1406c5430fe999a6490aa3e079893fcc682d88734f7 +9ca8513c26e54c97f2d3c6105c42144100044727f6fb4c28048f7cd7270dd35e From 838d2d3078b9c746da75f76b20ab36ff40d3fd1d Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 24 Aug 2024 19:06:52 +0000 Subject: [PATCH 0716/1030] Improved help message for the --enable-test-status configuration option. Fix the build for when that option is omitted. FossilOrigin-Name: b404a5fe3f0532f6d56b5e65c44a59379c17d175c21ac69a1f2ba8aadf453313 --- configure | 33 ++++++++++++++++----------------- configure.ac | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/configure b/configure index 12f96ceba4..22b961e554 100755 --- a/configure +++ b/configure @@ -1548,8 +1548,7 @@ Optional Features: --disable-largefile omit support for large files --disable-tcl omit building accessory programs that require TCL-dev - --enable-test-status show status of testing targets using VT100 cursor - movment + --enable-test-status Full-screen status of tests --disable-threadsafe Disable mutexing --enable-releasemode Support libtool link to release mode --enable-tempstore Use an in-ram database for temporary tables @@ -3943,13 +3942,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3946: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3945: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3949: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3948: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3952: output\"" >&5) + (eval echo "\"\$as_me:3951: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5155,7 +5154,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5158 "configure"' > conftest.$ac_ext + echo '#line 5157 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6680,11 +6679,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6683: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6682: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6687: \$? = $ac_status" >&5 + echo "$as_me:6686: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7019,11 +7018,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7022: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7021: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7026: \$? = $ac_status" >&5 + echo "$as_me:7025: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7124,11 +7123,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7127: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7126: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7131: \$? = $ac_status" >&5 + echo "$as_me:7130: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7179,11 +7178,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7182: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7181: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7186: \$? = $ac_status" >&5 + echo "$as_me:7185: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9559,7 +9558,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9562 "configure" +#line 9561 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9655,7 +9654,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9658 "configure" +#line 9657 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10498,7 +10497,7 @@ else use_vt100=no fi -if test $use_vt100; then +if test $use_vt100 != no; then TSTRNNR_OPTS=--status else TSTRNNR_OPTS= diff --git a/configure.ac b/configure.ac index 6df65b9f13..b3a0dd299f 100644 --- a/configure.ac +++ b/configure.ac @@ -230,9 +230,9 @@ fi ######### # Set up options for running tests. # -AC_ARG_ENABLE(test-status, AS_HELP_STRING([--enable-test-status],[show status of testing targets using VT100 cursor movment]), +AC_ARG_ENABLE(test-status, AS_HELP_STRING([--enable-test-status],[Full-screen status of tests]), [use_vt100=$enableval],[use_vt100=no]) -if test $use_vt100; then +if test $use_vt100 != no; then TSTRNNR_OPTS=--status else TSTRNNR_OPTS= diff --git a/manifest b/manifest index 18db7ded47..da0380bd95 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\s./configure\soption\s--enable-test-status\scauses\stestrunner.tcl\sto\sbe\nrun\swith\sthe\s--status\soption\sfor\stargets\slike\smdevtest\sand\sreleasetest. -D 2024-08-24T19:02:33.721 +C Improved\shelp\smessage\sfor\sthe\s--enable-test-status\sconfiguration\soption.\nFix\sthe\sbuild\sfor\swhen\sthat\soption\sis\somitted. +D 2024-08-24T19:06:52.229 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure b4c3cbde74d7bf7a3c046e2b9641c2784f67b0d3a8e56235a107e0a230fb26b0 x -F configure.ac f084a0765a98bc76513d0fba69264164d72d20cbfbc84d85f0a4e8400425b8d5 +F configure 49523f0a070b583cea040d26eff53a65fb0893eca4663b1343a4d5a9a964da53 x +F configure.ac a100ebf7a07f5dedd319ef547dd467d1676ed059b85a7877aa9c44ac309f7000 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md e8635eea9153dcd6a51fd2740666ebc4492b3813cb1ac31cd8e99150df91762d @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8b4766252b80075354a6b1406c5430fe999a6490aa3e079893fcc682d88734f7 -R 624c0fde9a976c048fe809e58bc6f948 +P 9ca8513c26e54c97f2d3c6105c42144100044727f6fb4c28048f7cd7270dd35e +R af6e572379558bf7f71bf69d4df3ecc4 U drh -Z a7b786c85627cbad9eafd537f720c473 +Z 30edae94264472f64c3131f2153cb3fe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index af222d498c..f9406ce800 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ca8513c26e54c97f2d3c6105c42144100044727f6fb4c28048f7cd7270dd35e +b404a5fe3f0532f6d56b5e65c44a59379c17d175c21ac69a1f2ba8aadf453313 From 306a8dcf3e5b4e94156b208eb9f601990ac8ce99 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 24 Aug 2024 20:01:05 +0000 Subject: [PATCH 0717/1030] Fix compiler warnings in the CLI detected by MSVC. FossilOrigin-Name: 23ae505cbfde6dfd1dbb2216cf76c1e316b49f2ca84491a1aae28ad33f7777a9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 9 +++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index da0380bd95..ba33622d87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\shelp\smessage\sfor\sthe\s--enable-test-status\sconfiguration\soption.\nFix\sthe\sbuild\sfor\swhen\sthat\soption\sis\somitted. -D 2024-08-24T19:06:52.229 +C Fix\scompiler\swarnings\sin\sthe\sCLI\sdetected\sby\sMSVC. +D 2024-08-24T20:01:05.217 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -765,7 +765,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 2c127880c0634962837f16f2f48a295e514357af959330cc038de73015d5b5e8 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 990e77ca805273edd55071c71327d202f1854e19c2e9437c039d91ff3192d7c4 +F src/shell.c.in fa98789df3e106eac287b001decd28ef7fe703c119282f91294af32d5c18ce10 F src/sqlite.h.in f07bff4225a1244efd604a0ffef81ed69f29d3dbaed7e22f906f26229ba3ca9e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9ca8513c26e54c97f2d3c6105c42144100044727f6fb4c28048f7cd7270dd35e -R af6e572379558bf7f71bf69d4df3ecc4 +P b404a5fe3f0532f6d56b5e65c44a59379c17d175c21ac69a1f2ba8aadf453313 +R 1dc458f3efda36153cdb87bbe3ce0cfd U drh -Z 30edae94264472f64c3131f2153cb3fe +Z e6cd8d3cc158f5893ff38516ff50820a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f9406ce800..5d64c9e710 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b404a5fe3f0532f6d56b5e65c44a59379c17d175c21ac69a1f2ba8aadf453313 +23ae505cbfde6dfd1dbb2216cf76c1e316b49f2ca84491a1aae28ad33f7777a9 diff --git a/src/shell.c.in b/src/shell.c.in index 1a1d357749..ab17f46e14 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3556,10 +3556,11 @@ static void bind_prepared_stmt(ShellState *pArg, sqlite3_stmt *pStmt){ }else if( strncmp(zVar, "$int_", 5)==0 ){ sqlite3_bind_int(pStmt, i, atoi(&zVar[5])); }else if( strncmp(zVar, "$text_", 6)==0 ){ - char *zBuf = sqlite3_malloc64( strlen(zVar)-5 ); + size_t szVar = strlen(zVar); + char *zBuf = sqlite3_malloc64( szVar-5 ); if( zBuf ){ - memcpy(zBuf, &zVar[6], strlen(zVar)-5); - sqlite3_bind_text64(pStmt, i, zBuf, -1, sqlite3_free, SQLITE_UTF8); + memcpy(zBuf, &zVar[6], szVar-5); + sqlite3_bind_text64(pStmt, i, zBuf, szVar-6, sqlite3_free, SQLITE_UTF8); } }else{ sqlite3_bind_null(pStmt, i); @@ -11052,7 +11053,7 @@ static int do_meta_command(char *zLine, ShellState *p){ for(ii=2; ii Date: Sat, 24 Aug 2024 20:05:59 +0000 Subject: [PATCH 0718/1030] Fix harmless compiler warnings in fts5V2toV1Tokenize(). FossilOrigin-Name: df65d00f104f31741056686f2ba41ecb192c552012bffb17c2a8b5d4db058328 --- ext/fts5/fts5_main.c | 1 + manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index e271402ecf..4addc07294 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -3350,6 +3350,7 @@ static int fts5V2toV1Tokenize( Fts5VtoVTokenizer *p = (Fts5VtoVTokenizer*)pTok; Fts5TokenizerModule *pMod = p->pMod; assert( pMod->bV2Native==0 ); + UNUSED_PARAM2(pLocale,nLocale); return pMod->x1.xTokenize(p->pReal, pCtx, flags, pText, nText, xToken); } diff --git a/manifest b/manifest index ba33622d87..7dd86f3553 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarnings\sin\sthe\sCLI\sdetected\sby\sMSVC. -D 2024-08-24T20:01:05.217 +C Fix\sharmless\scompiler\swarnings\sin\sfts5V2toV1Tokenize(). +D 2024-08-24T20:05:59.988 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81c F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 5ea7ab0c9967594e73b7dd0ad737595922a14f175aa4b486dc2992a3e3138b68 +F ext/fts5/fts5_main.c 3d8b778f65fe5be218f6a8e4019048f092c0c09621b035ce3e8804093036b578 F ext/fts5/fts5_storage.c 9a9b880be12901f1962ae2a5a7e1b74348b3099a1e728764e419f75d98e3e612 F ext/fts5/fts5_tcl.c 1dcf08028141c40a32634bdcf2d5601622ce4edc48f82ac4ce0cbe0a92a6961d F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b404a5fe3f0532f6d56b5e65c44a59379c17d175c21ac69a1f2ba8aadf453313 -R 1dc458f3efda36153cdb87bbe3ce0cfd +P 23ae505cbfde6dfd1dbb2216cf76c1e316b49f2ca84491a1aae28ad33f7777a9 +R 3d0d5a942eeee701f351d015af5828aa U drh -Z e6cd8d3cc158f5893ff38516ff50820a +Z b6c5eb8f043c1d2348c0c60d14f2a5f6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5d64c9e710..fc66c305e9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -23ae505cbfde6dfd1dbb2216cf76c1e316b49f2ca84491a1aae28ad33f7777a9 +df65d00f104f31741056686f2ba41ecb192c552012bffb17c2a8b5d4db058328 From 87ebadbf4e0349b1987d89a2c8a9b3638a88667c Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 25 Aug 2024 11:59:29 +0000 Subject: [PATCH 0719/1030] shell.c.in: use eputz/oputz() instead of eputf/oputf() where appropriate to avoid compilation errors in -std=c99 mode (namely wasm builds). FossilOrigin-Name: 9ef8317faebc29d016bdf2e8c678fb21ca2cfa95272f1f18b461fcaf0e220ac5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 7dd86f3553..1153795db6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sfts5V2toV1Tokenize(). -D 2024-08-24T20:05:59.988 +C shell.c.in:\suse\seputz/oputz()\sinstead\sof\seputf/oputf()\swhere\sappropriate\sto\savoid\scompilation\serrors\sin\s-std=c99\smode\s(namely\swasm\sbuilds). +D 2024-08-25T11:59:29.477 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -765,7 +765,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 2c127880c0634962837f16f2f48a295e514357af959330cc038de73015d5b5e8 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in fa98789df3e106eac287b001decd28ef7fe703c119282f91294af32d5c18ce10 +F src/shell.c.in 5a05e1a1d187ab916afe9a628d7e9b20b5997273b595bd748db324814e0ccca9 F src/sqlite.h.in f07bff4225a1244efd604a0ffef81ed69f29d3dbaed7e22f906f26229ba3ca9e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 23ae505cbfde6dfd1dbb2216cf76c1e316b49f2ca84491a1aae28ad33f7777a9 -R 3d0d5a942eeee701f351d015af5828aa -U drh -Z b6c5eb8f043c1d2348c0c60d14f2a5f6 +P df65d00f104f31741056686f2ba41ecb192c552012bffb17c2a8b5d4db058328 +R 8d4b348b6bf673b94cab6e107b5bbb73 +U stephan +Z 5120e8419efd39e01384da30ed409ec4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fc66c305e9..4e98a04790 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -df65d00f104f31741056686f2ba41ecb192c552012bffb17c2a8b5d4db058328 +9ef8317faebc29d016bdf2e8c678fb21ca2cfa95272f1f18b461fcaf0e220ac5 diff --git a/src/shell.c.in b/src/shell.c.in index ab17f46e14..db10d21b8e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -283,7 +283,7 @@ INCLUDE ../ext/consio/console_io.c #else /* For Fiddle, all console handling and emit redirection is omitted. */ /* These next 3 macros are for emitting formatted output. When complaints - * from the WASM build are issued for non-formatted output, (when a mere + * from the WASM build are issued for non-formatted output, when a mere * string literal is to be emitted, the ?putz(z) forms should be used. * (This permits compile-time checking of format string / argument mismatch.) */ @@ -11070,11 +11070,11 @@ static int do_meta_command(char *zLine, ShellState *p){ } if( jj>=ArraySize(aLabel) ){ eputf("Error: no such optimization: \"%s\"\n", zLabel); - eputf("Should be one of:"); + eputz("Should be one of:"); for(jj=0; jj Date: Mon, 26 Aug 2024 17:35:32 +0000 Subject: [PATCH 0720/1030] Randomize the name of the attached database used to do VACUUM. FossilOrigin-Name: 0f4e65d73a2b95932f36768c0d9925a2d265d9b395b886d8e492d1d519b2093c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vacuum.c | 23 ++++++++++++++--------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 1153795db6..9b018b0b17 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C shell.c.in:\suse\seputz/oputz()\sinstead\sof\seputf/oputf()\swhere\sappropriate\sto\savoid\scompilation\serrors\sin\s-std=c99\smode\s(namely\swasm\sbuilds). -D 2024-08-25T11:59:29.477 +C Randomize\sthe\sname\sof\sthe\sattached\sdatabase\sused\sto\sdo\sVACUUM. +D 2024-08-26T17:35:32.270 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -834,7 +834,7 @@ F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 -F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104 +F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 F src/vdbe.c be5f58bc29f60252e041a618eae59e8d57d460ba136c5403cf0abf955560c457 F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P df65d00f104f31741056686f2ba41ecb192c552012bffb17c2a8b5d4db058328 -R 8d4b348b6bf673b94cab6e107b5bbb73 -U stephan -Z 5120e8419efd39e01384da30ed409ec4 +P 9ef8317faebc29d016bdf2e8c678fb21ca2cfa95272f1f18b461fcaf0e220ac5 +R f1ecfb99c58e61a39b55af180b76bb09 +U drh +Z 1c617d8c3be95e126399c709f0b8f264 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4e98a04790..dfaf3a1f10 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ef8317faebc29d016bdf2e8c678fb21ca2cfa95272f1f18b461fcaf0e220ac5 +0f4e65d73a2b95932f36768c0d9925a2d265d9b395b886d8e492d1d519b2093c diff --git a/src/vacuum.c b/src/vacuum.c index c0ae4bc1e1..e203f68c65 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -162,6 +162,9 @@ SQLITE_NOINLINE int sqlite3RunVacuum( const char *zDbMain; /* Schema name of database to vacuum */ const char *zOut; /* Name of output file */ u32 pgflags = PAGER_SYNCHRONOUS_OFF; /* sync flags for output db */ + u64 iRandom; /* Random value used for zDbVacuum[] */ + char zDbVacuum[42]; /* Name of the ATTACH-ed database used for vacuum */ + if( !db->autoCommit ){ sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction"); @@ -202,27 +205,29 @@ SQLITE_NOINLINE int sqlite3RunVacuum( pMain = db->aDb[iDb].pBt; isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain)); - /* Attach the temporary database as 'vacuum_db'. The synchronous pragma + /* Attach the temporary database as 'vacuum_XXXXXX'. The synchronous pragma ** can be set to 'off' for this file, as it is not recovered if a crash ** occurs anyway. The integrity of the database is maintained by a ** (possibly synchronous) transaction opened on the main database before ** sqlite3BtreeCopyFile() is called. ** ** An optimization would be to use a non-journaled pager. - ** (Later:) I tried setting "PRAGMA vacuum_db.journal_mode=OFF" but + ** (Later:) I tried setting "PRAGMA vacuum_XXXXXX.journal_mode=OFF" but ** that actually made the VACUUM run slower. Very little journalling ** actually occurs when doing a vacuum since the vacuum_db is initially ** empty. Only the journal header is written. Apparently it takes more ** time to parse and run the PRAGMA to turn journalling off than it does ** to write the journal header file. */ + sqlite3_randomness(sizeof(iRandom),&iRandom); + sqlite3_snprintf(sizeof(zDbVacuum), zDbVacuum, "vacuum_%016llx", iRandom); nDb = db->nDb; - rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut); + rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS %s", zOut, zDbVacuum); db->openFlags = saved_openFlags; if( rc!=SQLITE_OK ) goto end_of_vacuum; assert( (db->nDb-1)==nDb ); pDb = &db->aDb[nDb]; - assert( strcmp(pDb->zDbSName,"vacuum_db")==0 ); + assert( strcmp(pDb->zDbSName,zDbVacuum)==0 ); pTemp = pDb->pBt; if( pOut ){ sqlite3_file *id = sqlite3PagerFile(sqlite3BtreePager(pTemp)); @@ -299,11 +304,11 @@ SQLITE_NOINLINE int sqlite3RunVacuum( ** the contents to the temporary database. */ rc = execSqlF(db, pzErrMsg, - "SELECT'INSERT INTO vacuum_db.'||quote(name)" + "SELECT'INSERT INTO %s.'||quote(name)" "||' SELECT*FROM\"%w\".'||quote(name)" - "FROM vacuum_db.sqlite_schema " + "FROM %s.sqlite_schema " "WHERE type='table'AND coalesce(rootpage,1)>0", - zDbMain + zDbVacuum, zDbMain, zDbVacuum ); assert( (db->mDbFlags & DBFLAG_Vacuum)!=0 ); db->mDbFlags &= ~DBFLAG_Vacuum; @@ -315,11 +320,11 @@ SQLITE_NOINLINE int sqlite3RunVacuum( ** from the schema table. */ rc = execSqlF(db, pzErrMsg, - "INSERT INTO vacuum_db.sqlite_schema" + "INSERT INTO %s.sqlite_schema" " SELECT*FROM \"%w\".sqlite_schema" " WHERE type IN('view','trigger')" " OR(type='table'AND rootpage=0)", - zDbMain + zDbVacuum, zDbMain ); if( rc ) goto end_of_vacuum; From c013fa50db60dad905aff1c2202edfa7223bdd67 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 26 Aug 2024 19:08:54 +0000 Subject: [PATCH 0721/1030] Changes to documentation comments in fts5.h. FossilOrigin-Name: 886545a8d0e9cbf4911ecf747da0ea8aad702d79cb065dad01a04aa4f51da12b --- ext/fts5/fts5.h | 13 +++++++------ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 67adb40ac6..ea69f8f023 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -493,18 +493,19 @@ struct Fts5ExtensionApi { ** ** FTS5_TOKENIZER ** -** There is also an fts5_tokenizer object. This is an older version of -** fts5_tokenizer_v2. It is similar except that: +** There is also an fts5_tokenizer object. This is an older, deprecated, +** version of fts5_tokenizer_v2. It is similar except that: ** **
      **
    • There is no "iVersion" field, and **
    • The xTokenize() method does not take a locale argument. **
    ** -** fts5_tokenizer tokenizers should be registered with the xCreateTokenizer() -** function, instead of xCreateTokenizer_v2(). Tokenizers implementations -** registered using either API may be retrieved using both xFindTokenizer() -** and xFindTokenizer_v2(). +** Legacy fts5_tokenizer tokenizers must be registered using the +** legacy xCreateTokenizer() function, instead of xCreateTokenizer_v2(). +** +** Tokenizer implementations registered using either API may be retrieved +** using both xFindTokenizer() and xFindTokenizer_v2(). ** ** SYNONYM SUPPORT ** diff --git a/manifest b/manifest index 9b018b0b17..178aa88497 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Randomize\sthe\sname\sof\sthe\sattached\sdatabase\sused\sto\sdo\sVACUUM. -D 2024-08-26T17:35:32.270 +C Changes\sto\sdocumentation\scomments\sin\sfts5.h. +D 2024-08-26T19:08:54.811 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,7 +92,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 63db9624ccf70d4887836c320eda93ab552f21008f3be7ede551eac3ead62baa F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl 009cf59c77afa86d137b0cca3e3b1a5efbe2264faa2df233f9a7aa8563926d15 -F ext/fts5/fts5.h c72759fd15179934f10b71ae51ee999e8558f696335e4ec2d049243b764354ee +F ext/fts5/fts5.h efaaac0df3d3bc740383044c144b582f47921aafa21d7b10eb98f42c24c740b0 F ext/fts5/fts5Int.h 26a71a09cefa4ef6b4516b204ed48da3e1380970a19b3482eea7c5d805655360 F ext/fts5/fts5_aux.c 65a0468dd177d6093aa9ae1622e6d86b0136b8d267c62c0ad6493ad1e9a3d759 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9ef8317faebc29d016bdf2e8c678fb21ca2cfa95272f1f18b461fcaf0e220ac5 -R f1ecfb99c58e61a39b55af180b76bb09 -U drh -Z 1c617d8c3be95e126399c709f0b8f264 +P 0f4e65d73a2b95932f36768c0d9925a2d265d9b395b886d8e492d1d519b2093c +R 5eb525d2c75add4a5d571ba8012dc6b9 +U dan +Z dd80b3a4edb71c561dd200b24c9de74c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dfaf3a1f10..7c55e8d5d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f4e65d73a2b95932f36768c0d9925a2d265d9b395b886d8e492d1d519b2093c +886545a8d0e9cbf4911ecf747da0ea8aad702d79cb065dad01a04aa4f51da12b From 8aa9135f2cea08b1e8e6fb56dfe0fd6c3491605c Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Aug 2024 14:25:52 +0000 Subject: [PATCH 0722/1030] Only avoid all C-runtime I/O if the SQLITE_USE_ONLY_WIN32 flag is defined. FossilOrigin-Name: 164b1e1962aa1e16bdf52e9e86d4cf9c9e09220c0821932ac8e390e82074185f --- ext/consio/console_io.c | 4 +++- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ext/consio/console_io.c b/ext/consio/console_io.c index 40989e77b6..6b837cbafc 100755 --- a/ext/consio/console_io.c +++ b/ext/consio/console_io.c @@ -609,7 +609,9 @@ fFlushBuffer(FILE *pfOut){ } #endif -# if CIO_WIN_WC_XLATE && !defined(SHELL_OMIT_FIO_DUPE) +#if CIO_WIN_WC_XLATE \ + && !defined(SHELL_OMIT_FIO_DUPE) \ + && defined(SQLITE_USE_ONLY_WIN32) static struct FileAltIds { int fd; HANDLE fh; diff --git a/manifest b/manifest index 1e8d9272f2..ddb1f8bfb9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sall\sthe\slatests\strunk\senhancements\sinto\sthe\swin-dupe-crt-fio\sbranch. -D 2024-08-27T13:57:43.910 +C Only\savoid\sall\sC-runtime\sI/O\sif\sthe\sSQLITE_USE_ONLY_WIN32\sflag\sis\sdefined. +D 2024-08-27T14:25:52.592 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -53,7 +53,7 @@ F ext/README.md fd5f78013b0a2bc6f0067afb19e6ad040e89a10179b4f6f03eee58fac5f169bd F ext/async/README.txt e12275968f6fde133a80e04387d0e839b0c51f91 F ext/async/sqlite3async.c 6f247666b495c477628dd19364d279c78ea48cd90c72d9f9b98ad1aff3294f94 F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a49808287f04aa5309a -F ext/consio/console_io.c 7f3cb6490ea6e3bd51b606bd3a37cd1d26d0bf07ccec21dd75e20bf4ee1a2a59 x +F ext/consio/console_io.c 6e02dea912a49f55785b0027fe77960aafee6c236307c23f82ec86a69f1a2001 x F ext/consio/console_io.h b5ebe34aa15b357621ebbea3d3f2e2b24750d4280b5802516409e23947fd9ee5 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 @@ -607,7 +607,7 @@ F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ce F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth 7ac80cc3b6a6d52e041bb295e85555ce797be78c15ef2008a64ae58815014080 -F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 400213eb52a7e5ad5f448053d375cacf4dac2cf45d134f3edfe485ae4a49a183 w ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 400213eb52a7e5ad5f448053d375cacf4dac2cf45d134f3edfe485ae4a49a183 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate d1d62a2212099f2c0782d730beb8cb84a7a52d99c15ead2cb9b1411fff5fd6b1 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session 213b6c04267cb9bd760172db011eb1650732805fb3d01f9395478a8ceec18eb0 @@ -620,13 +620,13 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08 F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e -F ext/wasm/api/sqlite3-api-glue.c-pp.js 54b32b5321105a72d6f3d3e8b77f28f162d0367b08c63184263d3f85f3d7dbed w ext/wasm/api/sqlite3-api-glue.js -F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f w ext/wasm/api/sqlite3-api-oo1.js +F ext/wasm/api/sqlite3-api-glue.c-pp.js 54b32b5321105a72d6f3d3e8b77f28f162d0367b08c63184263d3f85f3d7dbed +F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 -F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d w ext/wasm/api/sqlite3-api-worker1.js +F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js e8f1df56e97a29004a95a2eddd26778f52c33b3e797d32d4b1b668a38e6493dd -F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d w ext/wasm/api/sqlite3-v-helper.js +F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 @@ -647,8 +647,8 @@ F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b823 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf F ext/wasm/demo-jsstorage.html 409c4be4af5f207fb2877160724b91b33ea36a3cd8c204e8da1acb828ffe588e F ext/wasm/demo-jsstorage.js 44e3ae7ec2483b6c511384c3c290beb6f305c721186bcf5398ca4e00004a06b8 -F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a9ef7c42ff04d7a125ddca7e5db8 w ext/wasm/demo-worker1-promiser.html -F ext/wasm/demo-worker1-promiser.c-pp.js fcc628cb42fcfaf07d250477801de1e6deb1e319d003976612a0db8d76b9fccc w ext/wasm/demo-worker1-promiser.js +F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a9ef7c42ff04d7a125ddca7e5db8 +F ext/wasm/demo-worker1-promiser.c-pp.js fcc628cb42fcfaf07d250477801de1e6deb1e319d003976612a0db8d76b9fccc F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2e74a938f771a889dd8c49648b5a125ff748835ba1925388cc6b379a0abde9ac 886545a8d0e9cbf4911ecf747da0ea8aad702d79cb065dad01a04aa4f51da12b -R 79479d743cc98e2dac5001e42c2a12ce +P 2d52db98f47fbcda0622c034b21c2fb19bf4345b88c5c565ae9e6f7128642e43 +R fe2336ed930d3088aea807bfa7c9e690 U drh -Z d5c2cd4bb2868922ff61d70f26a944a8 +Z dffceaa70fb90b81619d76d49bca0c7c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 179264e0ec..5430ab55f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2d52db98f47fbcda0622c034b21c2fb19bf4345b88c5c565ae9e6f7128642e43 +164b1e1962aa1e16bdf52e9e86d4cf9c9e09220c0821932ac8e390e82074185f From dac0d0b3102e3b0c1ba3ad41bbbd0b137bb82011 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Aug 2024 17:38:26 +0000 Subject: [PATCH 0723/1030] Updates to testrunner: (1) Omit all testing of User-Auth. (2) Automatically add the "*" wildcard before and after all pattern arguments. (3) Build the sqlite3 CLI for release tests. FossilOrigin-Name: d03d35eebaf82709414c87cfa6abc9d2baf8d7e64c2627bad0fd5bbda3e78d60 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- test/testrunner.tcl | 33 +++++++++++++++++---------------- test/testrunner_data.tcl | 7 +------ 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index fe2f58deba..3acb861a2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\sSQLITE_USE_ONLY_WIN32\sflag\sfor\sconsio\sinto\strunk. -D 2024-08-27T14:35:54.105 +C Updates\sto\stestrunner:\s\s(1)\sOmit\sall\stesting\sof\sUser-Auth.\n(2)\sAutomatically\sadd\sthe\s"*"\swildcard\sbefore\sand\safter\sall\spattern\narguments.\s\s(3)\sBuild\sthe\ssqlite3\sCLI\sfor\srelease\stests. +D 2024-08-27T17:38:26.497 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1713,8 +1713,8 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl 5d02deeba7a53baeadae6aa7641d90aac58fdfa3a7bcac85cfcfd752b1aab87c -F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf +F test/testrunner.tcl 74b569b553a85a10677e0f9b2f6d22d90d9f07255fbec545ec9438bed677e8e8 +F test/testrunner_data.tcl b281136c9a4a3cb2e6772a87c2e94efad0c12ea3e7d0710521a3cad964f879a1 F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2210,9 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 886545a8d0e9cbf4911ecf747da0ea8aad702d79cb065dad01a04aa4f51da12b 164b1e1962aa1e16bdf52e9e86d4cf9c9e09220c0821932ac8e390e82074185f -R fe2336ed930d3088aea807bfa7c9e690 -T +closed 164b1e1962aa1e16bdf52e9e86d4cf9c9e09220c0821932ac8e390e82074185f +P e9b03b082dcf141695140a6c2c50bf0dc577c3d64ab76f81dd22f0084eca26d6 +R 4a4a4d707423caa7361c65011daf0aec U drh -Z d17b3af74b4bff5f111775dd3cc3c9cb +Z 9d66ab840eaa6125582be7511985f53f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b2918befc9..0b87dcb672 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e9b03b082dcf141695140a6c2c50bf0dc577c3d64ab76f81dd22f0084eca26d6 +d03d35eebaf82709414c87cfa6abc9d2baf8d7e64c2627bad0fd5bbda3e78d60 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index d3a2c1f4c9..821ac6a951 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -89,7 +89,9 @@ Other PERMUTATION arguments must be run using testfixture, not tclsh: If no PATTERN arguments are present, all tests specified by the PERMUTATION are run. Otherwise, each pattern is interpreted as a glob pattern. Only those tcl tests for which the final component of the filename matches at -least one specified pattern are run. +least one specified pattern are run. The glob wildcard '*' is prepended +to the pattern if it does not start with '^' and appended to every +pattern that does not end with '$'. If no PATTERN arguments are present, then various fuzztest, threadtest and other tests are run as part of the "release" permutation. These are @@ -842,6 +844,17 @@ proc add_tcl_jobs {build config patternlist {shelldepid ""}} { if {[llength $patternlist]>0} { set bMatch 0 foreach p $patternlist { + set p [string trim $p *] + if {[string index $p 0]=="^"} { + set p [string range $p 1 end] + } else { + set p "*$p" + } + if {[string index $p end]=="\$"} { + set p [string range $p 0 end-1] + } else { + set p "$p*" + } if {[string match $p [file tail $f]]} { set bMatch 1 break @@ -1062,25 +1075,13 @@ proc add_jobs_from_cmdline {patternlist} { } release { - set patternlist [lrange $patternlist 1 end] + set config_set {} foreach b [trd_builds $TRG(platform)] { if {$TRG(config)!="" && ![regexp "\\y$b\\y" $TRG(config)]} continue if {[regexp "\\y$b\\y" $TRG(omitconfig)]} continue - set bld [add_build_job $b $TRG(testfixture)] - foreach c [trd_configs $TRG(platform) $b] { - add_tcl_jobs $bld $c $patternlist - } - - if {$patternlist==""} { - foreach e [trd_extras $TRG(platform) $b] { - if {$e=="fuzztest"} { - add_fuzztest_jobs $b - } else { - add_make_job $bld $e - } - } - } + lappend config_set $b } + add_devtest_jobs $config_set [lrange $patternlist 1 end] } list { diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index af480fc4cf..5ea03f0c00 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -16,7 +16,6 @@ namespace eval trd { set tcltest(linux.Have-Not) veryquick set tcltest(linux.Secure-Delete) veryquick set tcltest(linux.Unlock-Notify) veryquick - set tcltest(linux.User-Auth) veryquick set tcltest(linux.Update-Delete-Limit) veryquick set tcltest(linux.Extra-Robustness) veryquick set tcltest(linux.Device-Two) veryquick @@ -139,10 +138,6 @@ namespace eval trd { -DSQLITE_THREADSAFE -DSQLITE_TCL_DEFAULT_FULLMUTEX=1 } - set build(User-Auth) { - -O2 - -DSQLITE_USER_AUTHENTICATION=1 - } set build(Secure-Delete) { -O2 -DSQLITE_SECURE_DELETE=1 @@ -222,7 +217,7 @@ namespace eval trd { -DSQLITE_MAX_PAGE_SIZE=4096 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 - -DSQLITE_OMIT_VIRTUALTABLE=1 + -DSQLITE_OMIT_VIRTUALTABLEx=1 -DSQLITE_ENABLE_HIDDEN_COLUMNS -DSQLITE_TEMP_STORE=3 } From 3c39f1f5d6ebe8dcd13d1f513f045163926be5bb Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 27 Aug 2024 18:25:04 +0000 Subject: [PATCH 0724/1030] Add test code to drop an fts5 table with corrupt records in its shadow tables. FossilOrigin-Name: ca21c942c30a3dbff0e7d118e105b847d80b5388c74d19c2eeea71581f8f40b8 --- ext/fts5/fts5_tcl.c | 111 +++++++++++++++++++++++++++----- ext/fts5/test/fts5corrupt8.test | 103 +++++++++++++++++++++++++++++ manifest | 15 +++-- manifest.uuid | 2 +- 4 files changed, 208 insertions(+), 23 deletions(-) create mode 100644 ext/fts5/test/fts5corrupt8.test diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 1e9f7bbb60..a8ab44096b 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -96,14 +96,14 @@ static int SQLITE_TCLAPI f5tDbAndApi( rc = sqlite3_prepare_v2(db, "SELECT fts5(?1)", -1, &pStmt, 0); if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), 0); + Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), (char*)0); return TCL_ERROR; } sqlite3_bind_pointer(pStmt, 1, (void*)&pApi, "fts5_api_ptr", 0); sqlite3_step(pStmt); if( sqlite3_finalize(pStmt)!=SQLITE_OK ){ - Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), 0); + Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), (char*)0); return TCL_ERROR; } @@ -392,7 +392,7 @@ static int SQLITE_TCLAPI xF5tApi( CASE(12, "xSetAuxdata") { F5tAuxData *pData = (F5tAuxData*)sqlite3_malloc(sizeof(F5tAuxData)); if( pData==0 ){ - Tcl_AppendResult(interp, "out of memory", 0); + Tcl_AppendResult(interp, "out of memory", (char*)0); return TCL_ERROR; } pData->pObj = objv[2]; @@ -452,7 +452,7 @@ static int SQLITE_TCLAPI xF5tApi( rc = p->pApi->xPhraseFirst(p->pFts, iPhrase, &iter, &iCol, &iOff); if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); + Tcl_AppendResult(interp, sqlite3ErrName(rc), (char*)0); return TCL_ERROR; } for( ;iCol>=0; p->pApi->xPhraseNext(p->pFts, &iter, &iCol, &iOff) ){ @@ -683,7 +683,7 @@ static int SQLITE_TCLAPI f5tCreateFunction( pApi, zName, (void*)pCtx, xF5tFunction, xF5tDestroy ); if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), 0); + Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), (char*)0); return TCL_ERROR; } @@ -750,7 +750,7 @@ static int SQLITE_TCLAPI f5tTokenize( if( objc==5 ){ char *zOpt = Tcl_GetString(objv[1]); if( strcmp("-subst", zOpt) ){ - Tcl_AppendResult(interp, "unrecognized option: ", zOpt, 0); + Tcl_AppendResult(interp, "unrecognized option: ", zOpt, (char*)0); return TCL_ERROR; } } @@ -759,7 +759,7 @@ static int SQLITE_TCLAPI f5tTokenize( return TCL_ERROR; } if( nArg==0 ){ - Tcl_AppendResult(interp, "no such tokenizer: ", 0); + Tcl_AppendResult(interp, "no such tokenizer: ", (char*)0); Tcl_Free((void*)azArg); return TCL_ERROR; } @@ -767,13 +767,13 @@ static int SQLITE_TCLAPI f5tTokenize( rc = pApi->xFindTokenizer(pApi, azArg[0], &pUserdata, &tokenizer); if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, "no such tokenizer: ", azArg[0], 0); + Tcl_AppendResult(interp, "no such tokenizer: ", azArg[0], (char*)0); return TCL_ERROR; } rc = tokenizer.xCreate(pUserdata, &azArg[1], (int)(nArg-1), &pTok); if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, "error in tokenizer.xCreate()", 0); + Tcl_AppendResult(interp, "error in tokenizer.xCreate()", (char*)0); return TCL_ERROR; } @@ -787,7 +787,7 @@ static int SQLITE_TCLAPI f5tTokenize( ); tokenizer.xDelete(pTok); if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, "error in tokenizer.xTokenize()", 0); + Tcl_AppendResult(interp, "error in tokenizer.xTokenize()", (char*)0); Tcl_DecrRefCount(pRet); return TCL_ERROR; } @@ -1049,7 +1049,7 @@ static int SQLITE_TCLAPI f5tTokenizerLocale( if( p->xToken==0 ){ Tcl_AppendResult(interp, - "sqlite3_fts5_locale may only be used by tokenizer callback", 0 + "sqlite3_fts5_locale may only be used by tokenizer callback", (char*)0 ); return TCL_ERROR; } @@ -1098,7 +1098,7 @@ static int SQLITE_TCLAPI f5tTokenizerReturn( if( p->xToken==0 ){ Tcl_AppendResult(interp, - "sqlite3_fts5_token may only be used by tokenizer callback", 0 + "sqlite3_fts5_token may only be used by tokenizer callback", (char*)0 ); return TCL_ERROR; } @@ -1250,7 +1250,7 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( Tcl_AppendResult(interp, ( bV2 ? "error in fts5_api.xCreateTokenizer_v2()" : "error in fts5_api.xCreateTokenizer()" - ), 0); + ), (char*)0); return TCL_ERROR; } @@ -1540,12 +1540,92 @@ static int SQLITE_TCLAPI f5tRegisterOriginText( Tcl_ResetResult(interp); if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), 0); + Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), (void*)0); return TCL_ERROR; } return TCL_OK; } +/* +** This function is used to DROP an fts5 table. It works even if the data +** structures fts5 stores within the database are corrupt, which sometimes +** prevents a straight "DROP TABLE" command from succeeding. +** +** The first parameter is the database handle to use for the DROP TABLE +** operation. The second is the name of the database to drop the fts5 table +** from (i.e. "main", "temp" or the name of an attached database). The +** third parameter is the name of the fts5 table to drop. +** +** SQLITE_OK is returned if the table is successfully dropped. Or, if an +** error occurs, an SQLite error code. +*/ +static int sqlite3_fts5_drop_corrupt_table( + sqlite3 *db, /* Database handle */ + const char *zDb, /* Database name ("main", "temp" etc.) */ + const char *zTab /* Name of fts5 table to drop */ +){ + int rc = SQLITE_OK; + int bDef = 0; + + rc = sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, -1, &bDef); + if( rc==SQLITE_OK ){ + char *zScript = sqlite3_mprintf( + "DELETE FROM %Q.'%q_data';" + "DELETE FROM %Q.'%q_config';" + "INSERT INTO %Q.'%q_data' VALUES(10, X'0000000000');" + "INSERT INTO %Q.'%q_config' VALUES('version', 4);" + "DROP TABLE %Q.'%q';", + zDb, zTab, zDb, zTab, zDb, zTab, zDb, zTab, zDb, zTab + ); + + if( zScript==0 ){ + rc = SQLITE_NOMEM; + }else{ + if( bDef ) sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 0, 0); + rc = sqlite3_exec(db, zScript, 0, 0, 0); + if( bDef ) sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1, 0); + sqlite3_free(zScript); + } + } + + return rc; +} + +/* +** sqlite3_fts5_drop_corrupt_table DB DATABASE TABLE +** +** Description... +*/ +static int SQLITE_TCLAPI f5tDropCorruptTable( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3 *db = 0; + const char *zDb = 0; + const char *zTab = 0; + int rc = SQLITE_OK; + + if( objc!=4 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB DATABASE TABLE"); + return TCL_ERROR; + } + if( f5tDbPointer(interp, objv[1], &db) ){ + return TCL_ERROR; + } + zDb = Tcl_GetString(objv[2]); + zTab = Tcl_GetString(objv[3]); + + rc = sqlite3_fts5_drop_corrupt_table(db, zDb, zTab); + if( rc!=SQLITE_OK ){ + Tcl_AppendResult(interp, "error: ", sqlite3_errmsg(db), (void*)0); + return TCL_ERROR; + } + + return TCL_OK; +} + /* ** Entry point. */ @@ -1564,7 +1644,8 @@ int Fts5tcl_Init(Tcl_Interp *interp){ { "sqlite3_fts5_token_hash", f5tTokenHash, 0 }, { "sqlite3_fts5_register_matchinfo", f5tRegisterMatchinfo, 0 }, { "sqlite3_fts5_register_fts5tokenize", f5tRegisterTok, 0 }, - { "sqlite3_fts5_register_origintext",f5tRegisterOriginText, 0 } + { "sqlite3_fts5_register_origintext",f5tRegisterOriginText, 0 }, + { "sqlite3_fts5_drop_corrupt_table", f5tDropCorruptTable, 0 } }; int i; F5tTokenizerContext *pContext; diff --git a/ext/fts5/test/fts5corrupt8.test b/ext/fts5/test/fts5corrupt8.test new file mode 100644 index 0000000000..d3f0e3d514 --- /dev/null +++ b/ext/fts5/test/fts5corrupt8.test @@ -0,0 +1,103 @@ +# 2024 Aug 28 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5corrupt8 + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x); +} + +do_execsql_test 1.1 { + UPDATE t1_data SET block='hello world' WHERE id=10 +} + +db close +sqlite3 db test.db + +do_catchsql_test 1.2 { + SELECT * FROM t1 +} {1 {vtable constructor failed: t1}} +do_catchsql_test 1.3 { + DROP TABLE t1 +} {1 {vtable constructor failed: t1}} +do_test 1.4 { + sqlite3_db_config db DEFENSIVE 0 +} {0} +do_test 1.5 { + sqlite3_fts5_drop_corrupt_table db main t1 +} {} +do_test 1.6 { + sqlite3_db_config db DEFENSIVE -1 +} {0} +do_execsql_test 1.7 { + SELECT * FROM sqlite_schema +} + +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x); +} +do_execsql_test 2.1 { + UPDATE t1_config SET v=555 WHERE k='version' +} +db close +sqlite3 db test.db +do_catchsql_test 2.2 { + SELECT * FROM t1 +} {1 {invalid fts5 file format (found 555, expected 4 or 5) - run 'rebuild'}} +do_catchsql_test 2.3 { + DROP TABLE t1 +} {1 {invalid fts5 file format (found 555, expected 4 or 5) - run 'rebuild'}} +do_test 2.4 { + sqlite3_fts5_drop_corrupt_table db main t1 +} {} +do_execsql_test 2.5 { + SELECT * FROM sqlite_schema +} + +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x); +} +do_execsql_test 3.1 { + DELETE FROM t1_config; +} +db close +sqlite3 db test.db +do_catchsql_test 3.2 { + SELECT * FROM t1 +} {1 {invalid fts5 file format (found 0, expected 4 or 5) - run 'rebuild'}} +do_catchsql_test 3.3 { + DROP TABLE t1 +} {1 {invalid fts5 file format (found 0, expected 4 or 5) - run 'rebuild'}} + + +do_test 3.4 { + sqlite3_db_config db DEFENSIVE 1 +} {1} +do_test 3.5 { + sqlite3_fts5_drop_corrupt_table db main t1 +} {} +do_test 3.6 { + sqlite3_db_config db DEFENSIVE -1 +} {1} +do_execsql_test 3.7 { + SELECT * FROM sqlite_schema +} + +finish_test + diff --git a/manifest b/manifest index 3acb861a2b..acecee9702 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sto\stestrunner:\s\s(1)\sOmit\sall\stesting\sof\sUser-Auth.\n(2)\sAutomatically\sadd\sthe\s"*"\swildcard\sbefore\sand\safter\sall\spattern\narguments.\s\s(3)\sBuild\sthe\ssqlite3\sCLI\sfor\srelease\stests. -D 2024-08-27T17:38:26.497 +C Add\stest\scode\sto\sdrop\san\sfts5\stable\swith\scorrupt\srecords\sin\sits\sshadow\stables. +D 2024-08-27T18:25:04.935 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -102,7 +102,7 @@ F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe F ext/fts5/fts5_main.c 3d8b778f65fe5be218f6a8e4019048f092c0c09621b035ce3e8804093036b578 F ext/fts5/fts5_storage.c 9a9b880be12901f1962ae2a5a7e1b74348b3099a1e728764e419f75d98e3e612 -F ext/fts5/fts5_tcl.c 1dcf08028141c40a32634bdcf2d5601622ce4edc48f82ac4ce0cbe0a92a6961d +F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b F ext/fts5/fts5_tokenize.c ae9c4fa93174ef06ffc138bd4280a1c37f7e13624d3d2706aad4b80573f23c41 @@ -153,6 +153,7 @@ F ext/fts5/test/fts5corrupt4.test dc08d19f5b8943e95a7778a7d8da592042504faf18dd93 F ext/fts5/test/fts5corrupt5.test 11b47126f5772cc37b67e3e8b2ed05895c4d07c05338bc07e4eea225bfe32c76 F ext/fts5/test/fts5corrupt6.test 2d72db743db7b5d9c9a6d0cfef24d799ed1aa5e8192b66c40e871a37ed9eed06 F ext/fts5/test/fts5corrupt7.test 4e830875c33b9ea3c4cf1ba71e692b63893cbb4faae8c69b1071889dc26e211c +F ext/fts5/test/fts5corrupt8.test f78b6de9e4327e16ba7a7958b1ce576f9b5d886b4b97690f90b7f3cf654da458 F ext/fts5/test/fts5delete.test 619295b20dbc1d840b403ee07c878f52378849c3c02e44f2ee143b3e978a0aa7 F ext/fts5/test/fts5detail.test 54015e9c43ec4ba542cfb93268abdf280e0300f350efd08ee411284b03595cc4 F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3bf76a2c82b1c788d11 @@ -2210,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e9b03b082dcf141695140a6c2c50bf0dc577c3d64ab76f81dd22f0084eca26d6 -R 4a4a4d707423caa7361c65011daf0aec -U drh -Z 9d66ab840eaa6125582be7511985f53f +P d03d35eebaf82709414c87cfa6abc9d2baf8d7e64c2627bad0fd5bbda3e78d60 +R eae9b17364855941c00e92c86d398a4e +U dan +Z d07b6efd95ad4c9798aced1dad6099da # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0b87dcb672..6d952d91c5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d03d35eebaf82709414c87cfa6abc9d2baf8d7e64c2627bad0fd5bbda3e78d60 +ca21c942c30a3dbff0e7d118e105b847d80b5388c74d19c2eeea71581f8f40b8 From d9bc2bb638ba4d50c8cea1d5bdad94cb6c0aa479 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Aug 2024 19:17:29 +0000 Subject: [PATCH 0725/1030] Improvements to testrunner.tcl: Show elapse time in MM:SS or HH:MM:SS. Keep track of the total number of tests and the total number of errors and report those values on a summary line at the end. FossilOrigin-Name: 40b232924c973f8d94605946fff75acbe120d90634a2eaf38bd31649e9f1390b --- manifest | 14 +++++----- manifest.uuid | 2 +- test/testrunner.tcl | 63 ++++++++++++++++++++++++++++++++++++++------- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index acecee9702..e776cdf849 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scode\sto\sdrop\san\sfts5\stable\swith\scorrupt\srecords\sin\sits\sshadow\stables. -D 2024-08-27T18:25:04.935 +C Improvements\sto\stestrunner.tcl:\s\sShow\selapse\stime\sin\sMM:SS\sor\sHH:MM:SS.\nKeep\strack\sof\sthe\stotal\snumber\sof\stests\sand\sthe\stotal\snumber\sof\serrors\nand\sreport\sthose\svalues\son\sa\ssummary\sline\sat\sthe\send. +D 2024-08-27T19:17:29.271 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl 74b569b553a85a10677e0f9b2f6d22d90d9f07255fbec545ec9438bed677e8e8 +F test/testrunner.tcl 21449521b796376fb4341d84bdf9dae6befc409e2273f795b4bfda78644da22c F test/testrunner_data.tcl b281136c9a4a3cb2e6772a87c2e94efad0c12ea3e7d0710521a3cad964f879a1 F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d03d35eebaf82709414c87cfa6abc9d2baf8d7e64c2627bad0fd5bbda3e78d60 -R eae9b17364855941c00e92c86d398a4e -U dan -Z d07b6efd95ad4c9798aced1dad6099da +P ca21c942c30a3dbff0e7d118e105b847d80b5388c74d19c2eeea71581f8f40b8 +R e9d7eae7ed3949bc9ba3747c7b003f26 +U drh +Z 1e89338cdc3d7df9980ff860413d15b9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6d952d91c5..2d3f302a52 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ca21c942c30a3dbff0e7d118e105b847d80b5388c74d19c2eeea71581f8f40b8 +40b232924c973f8d94605946fff75acbe120d90634a2eaf38bd31649e9f1390b diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 821ac6a951..88acae3c0e 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -279,10 +279,12 @@ set TRG(schema) { priority INTEGER NOT NULL, -- higher priority jobs may run earlier /* Fields updated as jobs run */ - starttime INTEGER, - endtime INTEGER, + starttime INTEGER, -- Start time (milliseconds since 1970) + endtime INTEGER, -- End time state TEXT CHECK( state IN ('','ready','running','done','failed','omit') ), - output TEXT + ntest INT, -- Number of test cases run + nerr INT, -- Number of errors reported + output TEXT -- test output ); CREATE TABLE config( @@ -391,14 +393,34 @@ if {[string compare -nocase script [lindex $argv 0]]==0} { exit } +# Compute an elapse time string MM:SS or HH:MM:SS based on the +# number of milliseconds in the argument. +# +proc elapsetime {ms} { + set s [expr {int(($ms+500.0)*0.001)}] + set hr [expr {$s/3600}] + set mn [expr {($s/60)%60}] + set sc [expr {$s%60}] + if {$hr>0} { + return [format %02d:%02d:%02d $hr $mn $sc] + } else { + return [format %02d:%02d $mn $sc] + } +} + # Helper routine for show_status # proc display_job {jobdict {tm ""}} { array set job $jobdict - set dfname [format %-60s $job(displayname)] + if {[string length $job(displayname)]>65} { + set dfname [format %.65s... $job(displayname)] + } else { + set dfname [format %-68s $job(displayname)] + } set dtm "" if {$tm!=""} { - set dtm [format %-10s "\[[expr {$tm-$job(starttime)}]ms\]"] + set dtm [expr {$tm-$job(starttime)}] + set dtm [format %8s [elapsetime $dtm]] } puts " $dfname $dtm" } @@ -449,10 +471,10 @@ proc show_status {db cls} { if {$S(failed)>0} { set f "$S(failed) FAILED, " } - puts "Command line: \[testrunner.tcl$cmdline\]$clreol" - puts "Jobs: $nJob " - puts "Summary: ${tm}ms, ($fin/$total) finished,\ - ${f}$S(running) running " + puts [format %-79s "Command line: \[testrunner.tcl$cmdline\]$clreol"] + puts [format %-79s "Jobs: $nJob"] + puts [format %-79s "Summary: [elapsetime $tm], ($fin/$total) finished,\ + ${f}$S(running) running "] set srcdir [file dirname [file dirname $TRG(info_script)]] if {$S(running)>0} { @@ -1121,15 +1143,25 @@ proc make_new_testset {} { } proc mark_job_as_finished {jobid output state endtm} { + set ntest 1 + set nerr 0 + if {$endtm>0} { + if {[regexp {\y(\d+) errors out of (\d+) tests} $output all a b]} { + set nerr $a + set ntest $b + } + } r_write_db { if {$state=="failed"} { set childstate omit + if {$nerr<=0} {set nerr 1} } else { set childstate ready } trdb eval { UPDATE jobs - SET output=$output, state=$state, endtime=$endtm + SET output=$output, state=$state, endtime=$endtm, + ntest=$ntest, nerr=$nerr WHERE jobid=$jobid; UPDATE jobs SET state=$childstate WHERE depid=$jobid; } @@ -1372,6 +1404,17 @@ proc run_testset {} { puts "\nTest database is $TRG(dbname)" puts "Test log is $TRG(logname)" + trdb eval { + SELECT sum(ntest) AS totaltest, + sum(nerr) AS totalerr + FROM jobs + } break + trdb eval { + SELECT max(endtime)-min(starttime) AS totaltime + FROM jobs WHERE endtime>0 + } break; + set et [elapsetime $totaltime] + puts "$totalerr errors out of $totaltest tests in about $et" } # Handle the --buildonly option, if it was specified. From c8edf07ca73b6f85235e1df09ea3650e6688d402 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 27 Aug 2024 19:27:40 +0000 Subject: [PATCH 0726/1030] Modify the implementation of "wrapper" tokenizers to make them more robust in the case where the database connection is closed before the tokenizers are deleted. FossilOrigin-Name: 7c0001d6eb43f89144eb84d9e30f575a3feed401d685a0d1f260692e419b2df2 --- ext/fts5/fts5_main.c | 25 +++++++++++++------------ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 4addc07294..5a97930ef7 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -3267,7 +3267,9 @@ static int fts5NewTokenizerModule( */ typedef struct Fts5VtoVTokenizer Fts5VtoVTokenizer; struct Fts5VtoVTokenizer { - Fts5TokenizerModule *pMod; + int bV2Native; /* True if v2 native tokenizer */ + fts5_tokenizer x1; /* Tokenizer functions */ + fts5_tokenizer_v2 x2; /* V2 tokenizer functions */ Fts5Tokenizer *pReal; }; @@ -3287,7 +3289,9 @@ static int fts5VtoVCreate( pNew = (Fts5VtoVTokenizer*)sqlite3Fts5MallocZero(&rc, sizeof(*pNew)); if( rc==SQLITE_OK ){ - pNew->pMod = pMod; + pNew->x1 = pMod->x1; + pNew->x2 = pMod->x2; + pNew->bV2Native = pMod->bV2Native; if( pMod->bV2Native ){ rc = pMod->x2.xCreate(pMod->pUserData, azArg, nArg, &pNew->pReal); }else{ @@ -3309,11 +3313,10 @@ static int fts5VtoVCreate( static void fts5VtoVDelete(Fts5Tokenizer *pTok){ Fts5VtoVTokenizer *p = (Fts5VtoVTokenizer*)pTok; if( p ){ - Fts5TokenizerModule *pMod = p->pMod; - if( pMod->bV2Native ){ - pMod->x2.xDelete(p->pReal); + if( p->bV2Native ){ + p->x2.xDelete(p->pReal); }else{ - pMod->x1.xDelete(p->pReal); + p->x1.xDelete(p->pReal); } sqlite3_free(p); } @@ -3331,9 +3334,8 @@ static int fts5V1toV2Tokenize( int (*xToken)(void*, int, const char*, int, int, int) ){ Fts5VtoVTokenizer *p = (Fts5VtoVTokenizer*)pTok; - Fts5TokenizerModule *pMod = p->pMod; - assert( pMod->bV2Native ); - return pMod->x2.xTokenize(p->pReal, pCtx, flags, pText, nText, 0, 0, xToken); + assert( p->bV2Native ); + return p->x2.xTokenize(p->pReal, pCtx, flags, pText, nText, 0, 0, xToken); } /* @@ -3348,10 +3350,9 @@ static int fts5V2toV1Tokenize( int (*xToken)(void*, int, const char*, int, int, int) ){ Fts5VtoVTokenizer *p = (Fts5VtoVTokenizer*)pTok; - Fts5TokenizerModule *pMod = p->pMod; - assert( pMod->bV2Native==0 ); + assert( p->bV2Native==0 ); UNUSED_PARAM2(pLocale,nLocale); - return pMod->x1.xTokenize(p->pReal, pCtx, flags, pText, nText, xToken); + return p->x1.xTokenize(p->pReal, pCtx, flags, pText, nText, xToken); } /* diff --git a/manifest b/manifest index e776cdf849..95f0b78d9e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\stestrunner.tcl:\s\sShow\selapse\stime\sin\sMM:SS\sor\sHH:MM:SS.\nKeep\strack\sof\sthe\stotal\snumber\sof\stests\sand\sthe\stotal\snumber\sof\serrors\nand\sreport\sthose\svalues\son\sa\ssummary\sline\sat\sthe\send. -D 2024-08-27T19:17:29.271 +C Modify\sthe\simplementation\sof\s"wrapper"\stokenizers\sto\smake\sthem\smore\srobust\sin\sthe\scase\swhere\sthe\sdatabase\sconnection\sis\sclosed\sbefore\sthe\stokenizers\sare\sdeleted. +D 2024-08-27T19:27:40.626 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81c F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 3d8b778f65fe5be218f6a8e4019048f092c0c09621b035ce3e8804093036b578 +F ext/fts5/fts5_main.c 0dbe241c50b62e24a229a176d66d580e359b3c32cb0970c39bb6dd6b86e125d5 F ext/fts5/fts5_storage.c 9a9b880be12901f1962ae2a5a7e1b74348b3099a1e728764e419f75d98e3e612 F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ca21c942c30a3dbff0e7d118e105b847d80b5388c74d19c2eeea71581f8f40b8 -R e9d7eae7ed3949bc9ba3747c7b003f26 -U drh -Z 1e89338cdc3d7df9980ff860413d15b9 +P 40b232924c973f8d94605946fff75acbe120d90634a2eaf38bd31649e9f1390b +R 37747ff8c02c47392327f3909e12ba2c +U dan +Z 559c141ac65916995897dbbf28b9ea88 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2d3f302a52..b2a520b2f8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -40b232924c973f8d94605946fff75acbe120d90634a2eaf38bd31649e9f1390b +7c0001d6eb43f89144eb84d9e30f575a3feed401d685a0d1f260692e419b2df2 From 71475478a1f3c00043144164858802c65b4004c1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Aug 2024 19:28:21 +0000 Subject: [PATCH 0727/1030] Further improvement to the status display in testrunner.tcl. Show the number of errors and the number of test cases on the status summary. FossilOrigin-Name: dbc1ac8692feccde271eaca78f2833c8bb7bf620088c8f975692d6ae2c8ba53a --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/testrunner.tcl | 15 ++++++++------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 95f0b78d9e..e4f301cbb5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\simplementation\sof\s"wrapper"\stokenizers\sto\smake\sthem\smore\srobust\sin\sthe\scase\swhere\sthe\sdatabase\sconnection\sis\sclosed\sbefore\sthe\stokenizers\sare\sdeleted. -D 2024-08-27T19:27:40.626 +C Further\simprovement\sto\sthe\sstatus\sdisplay\sin\stestrunner.tcl.\s\sShow\sthe\nnumber\sof\serrors\sand\sthe\snumber\sof\stest\scases\son\sthe\sstatus\ssummary. +D 2024-08-27T19:28:21.475 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl 21449521b796376fb4341d84bdf9dae6befc409e2273f795b4bfda78644da22c +F test/testrunner.tcl dfb6049b07a44559a2cba909589d56bfe2d9f5ce1828ad3537e350183be3416f F test/testrunner_data.tcl b281136c9a4a3cb2e6772a87c2e94efad0c12ea3e7d0710521a3cad964f879a1 F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 40b232924c973f8d94605946fff75acbe120d90634a2eaf38bd31649e9f1390b -R 37747ff8c02c47392327f3909e12ba2c -U dan -Z 559c141ac65916995897dbbf28b9ea88 +P 7c0001d6eb43f89144eb84d9e30f575a3feed401d685a0d1f260692e419b2df2 +R 2b16d26e239f800d0fd65b874c223ff3 +U drh +Z 3e4827c72f9a5e7f0a58061fb0e5d912 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b2a520b2f8..f88cc1fe3b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c0001d6eb43f89144eb84d9e30f575a3feed401d685a0d1f260692e419b2df2 +dbc1ac8692feccde271eaca78f2833c8bb7bf620088c8f975692d6ae2c8ba53a diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 88acae3c0e..bf9e46d934 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -455,6 +455,11 @@ proc show_status {db cls} { incr S($state) $cnt incr total $cnt } + set nt 0 + set ne 0 + $db eval { + SELECT sum(ntest) AS nt, sum(nerr) AS ne FROM jobs HAVING nt>0 + } break set fin [expr $S(done)+$S(failed)] if {$cmdline!=""} {set cmdline " $cmdline"} @@ -467,14 +472,10 @@ proc show_status {db cls} { } else { set clreol "" } - set f "" - if {$S(failed)>0} { - set f "$S(failed) FAILED, " - } puts [format %-79s "Command line: \[testrunner.tcl$cmdline\]$clreol"] - puts [format %-79s "Jobs: $nJob"] - puts [format %-79s "Summary: [elapsetime $tm], ($fin/$total) finished,\ - ${f}$S(running) running "] + puts [format %-79s "Cores: $nJob max $S(running) active"] + puts [format %-79s "Summary: [elapsetime $tm], $fin/$total tasks,\ + $ne errors, $nt tests"] set srcdir [file dirname [file dirname $TRG(info_script)]] if {$S(running)>0} { From db05c66a16370cb336de662a597edee2c0b814f2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Aug 2024 19:43:21 +0000 Subject: [PATCH 0728/1030] In testrunner, when doing the --status updates to the screen, be sure to overwrite dead text at the end of each line with spaces. FossilOrigin-Name: 7c195f132cb48ee44124eb4af3532937493429f7c45f6ac611f7a9b128799ad7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e4f301cbb5..9a3d8d14ca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\simprovement\sto\sthe\sstatus\sdisplay\sin\stestrunner.tcl.\s\sShow\sthe\nnumber\sof\serrors\sand\sthe\snumber\sof\stest\scases\son\sthe\sstatus\ssummary. -D 2024-08-27T19:28:21.475 +C In\stestrunner,\swhen\sdoing\sthe\s--status\supdates\sto\sthe\sscreen,\sbe\ssure\sto\noverwrite\sdead\stext\sat\sthe\send\sof\seach\sline\swith\sspaces. +D 2024-08-27T19:43:21.041 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl dfb6049b07a44559a2cba909589d56bfe2d9f5ce1828ad3537e350183be3416f +F test/testrunner.tcl caa8c5d6cd61f0656b16fbd3e3207814d4aa1b320eedf0bdf1ac516963c7b8ae F test/testrunner_data.tcl b281136c9a4a3cb2e6772a87c2e94efad0c12ea3e7d0710521a3cad964f879a1 F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7c0001d6eb43f89144eb84d9e30f575a3feed401d685a0d1f260692e419b2df2 -R 2b16d26e239f800d0fd65b874c223ff3 +P dbc1ac8692feccde271eaca78f2833c8bb7bf620088c8f975692d6ae2c8ba53a +R ae9b21fe337c43816e809f3a8dafca48 U drh -Z 3e4827c72f9a5e7f0a58061fb0e5d912 +Z 306e9d99d5e1930ae9fd911a1e781c28 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f88cc1fe3b..f1d875d829 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dbc1ac8692feccde271eaca78f2833c8bb7bf620088c8f975692d6ae2c8ba53a +7c195f132cb48ee44124eb4af3532937493429f7c45f6ac611f7a9b128799ad7 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index bf9e46d934..53dead6bc9 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -421,6 +421,8 @@ proc display_job {jobdict {tm ""}} { if {$tm!=""} { set dtm [expr {$tm-$job(starttime)}] set dtm [format %8s [elapsetime $dtm]] + } else{ + set dtm [format %8s ""] } puts " $dfname $dtm" } @@ -495,7 +497,7 @@ proc show_status {db cls} { } set nOmit [$db one {SELECT count(*) FROM jobs WHERE state='omit'}] if {$nOmit} { - puts "$nOmit jobs omitted due to failures$clreol" + puts [format %-79s "$nOmit jobs omitted due to failures$clreol"] } } if {$cls} { From 1a7cfbebb01d3d34a388bed5617a28b9f993ebee Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Aug 2024 19:48:19 +0000 Subject: [PATCH 0729/1030] Fix typo in the previous check-in. Ensure that --status header lines do not overflow and wrap. FossilOrigin-Name: 2eaea67495fd9961b7145d829789889bf1d8fa7a834d40d1be43e7c74c233bc2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/testrunner.tcl | 10 +++++----- test/testrunner_data.tcl | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 9a3d8d14ca..000260da0a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\stestrunner,\swhen\sdoing\sthe\s--status\supdates\sto\sthe\sscreen,\sbe\ssure\sto\noverwrite\sdead\stext\sat\sthe\send\sof\seach\sline\swith\sspaces. -D 2024-08-27T19:43:21.041 +C Fix\stypo\sin\sthe\sprevious\scheck-in.\s\sEnsure\sthat\s--status\sheader\slines\sdo\snot\noverflow\sand\swrap. +D 2024-08-27T19:48:19.164 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,8 +1714,8 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl caa8c5d6cd61f0656b16fbd3e3207814d4aa1b320eedf0bdf1ac516963c7b8ae -F test/testrunner_data.tcl b281136c9a4a3cb2e6772a87c2e94efad0c12ea3e7d0710521a3cad964f879a1 +F test/testrunner.tcl c27905c57f54450411be922037d227fee65b08928d09715d784380a398b0e758 +F test/testrunner_data.tcl 6a0facfbff26f2f8573ebaeb209426bbb59809d5c0f6925f983bd030ab5248cd F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dbc1ac8692feccde271eaca78f2833c8bb7bf620088c8f975692d6ae2c8ba53a -R ae9b21fe337c43816e809f3a8dafca48 +P 7c195f132cb48ee44124eb4af3532937493429f7c45f6ac611f7a9b128799ad7 +R 15868716c90b102057036239341d8066 U drh -Z 306e9d99d5e1930ae9fd911a1e781c28 +Z fde036223228b7af985cf94952c295a1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f1d875d829..f21f71e7f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c195f132cb48ee44124eb4af3532937493429f7c45f6ac611f7a9b128799ad7 +2eaea67495fd9961b7145d829789889bf1d8fa7a834d40d1be43e7c74c233bc2 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 53dead6bc9..8d81469c02 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -421,7 +421,7 @@ proc display_job {jobdict {tm ""}} { if {$tm!=""} { set dtm [expr {$tm-$job(starttime)}] set dtm [format %8s [elapsetime $dtm]] - } else{ + } else { set dtm [format %8s ""] } puts " $dfname $dtm" @@ -474,10 +474,10 @@ proc show_status {db cls} { } else { set clreol "" } - puts [format %-79s "Command line: \[testrunner.tcl$cmdline\]$clreol"] - puts [format %-79s "Cores: $nJob max $S(running) active"] - puts [format %-79s "Summary: [elapsetime $tm], $fin/$total tasks,\ - $ne errors, $nt tests"] + puts [format %-79.79s "Command: \[testrunner.tcl$cmdline\]$clreol"] + puts [format %-79.79s "Cores: $nJob max $S(running) active"] + puts [format %-79.79s "Summary: [elapsetime $tm], $fin/$total tasks,\ + $ne errors, $nt tests"] set srcdir [file dirname [file dirname $TRG(info_script)]] if {$S(running)>0} { diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index 5ea03f0c00..48484a3e24 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -115,6 +115,7 @@ namespace eval trd { } set build(Stdcall) { -DUSE_STDCALL=1 + -DSQLITE_USE_ONLY_WIN32=1 -O2 } From f5a9b58c8bc6b159cb942dbdb2c71a402c0ce3bd Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 27 Aug 2024 20:37:30 +0000 Subject: [PATCH 0730/1030] Avoid reading the structure record from within the fts5 xConnect method. FossilOrigin-Name: 6a6ce343b249e269229867b2c2f107a49ac8a8f24ad66801718ef01159655319 --- ext/fts5/fts5_main.c | 3 +-- ext/fts5/test/fts5corrupt3.test | 14 +++++++------- ext/fts5/test/fts5corrupt8.test | 15 +++------------ ext/fts5/test/fts5fault4.test | 2 +- ext/fts5/test/fts5misc.test | 8 ++++---- ext/fts5/test/fts5simple.test | 2 +- manifest | 25 ++++++++++++------------- manifest.uuid | 2 +- 8 files changed, 30 insertions(+), 41 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 5a97930ef7..565b1ec305 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -427,8 +427,7 @@ static int fts5InitVtab( /* Load the initial configuration */ if( rc==SQLITE_OK ){ - rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); - sqlite3Fts5IndexRollback(pTab->p.pIndex); + rc = sqlite3Fts5ConfigLoad(pTab->p.pConfig, pTab->p.pConfig->iCookie-1); } if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ diff --git a/ext/fts5/test/fts5corrupt3.test b/ext/fts5/test/fts5corrupt3.test index c5faaa87b1..3e8b0377cc 100644 --- a/ext/fts5/test/fts5corrupt3.test +++ b/ext/fts5/test/fts5corrupt3.test @@ -680,11 +680,11 @@ do_test 12.0 { do_catchsql_test 11.1 { SELECT * FROM t1 WHERE t1 MATCH 'abandon'; -} {1 {vtable constructor failed: t1}} +} {1 {database disk image is malformed}} do_catchsql_test 11.2 { INSERT INTO t1(t1, rank) VALUES('merge', 500); -} {1 {vtable constructor failed: t1}} +} {1 {database disk image is malformed}} #------------------------------------------------------------------------- # @@ -1040,7 +1040,7 @@ do_test 16.0 { do_catchsql_test 16.1 { INSERT INTO t1(t1) VALUES('integrity-check'); -} {1 {vtable constructor failed: t1}} +} {1 {database disk image is malformed}} #-------------------------------------------------------------------------- reset_db @@ -1126,7 +1126,7 @@ do_test 17.0 { do_catchsql_test 17.1 { SELECT * FROM t1 WHERE t1 MATCH 'abandon'; -} {1 {vtable constructor failed: t1}} +} {1 {database disk image is malformed}} #-------------------------------------------------------------------------- reset_db @@ -1630,7 +1630,7 @@ do_test 20.0 { do_catchsql_test 20.1 { SELECT * FROM t1 WHERE t1 MATCH 'abandon'; -} {1 {vtable constructor failed: t1}} +} {1 {database disk image is malformed}} #------------------------------------------------------------------------- reset_db @@ -2100,7 +2100,7 @@ do_test 22.0 { do_catchsql_test 22.1 { INSERT INTO t1(t1) VALUES('optimize'); -} {1 {vtable constructor failed: t1}} +} {1 {database disk image is malformed}} #-------------------------------------------------------------------------- reset_db @@ -3700,7 +3700,7 @@ do_catchsql_test 32.1 { highlight(t1, 2, '[', ']') FROM t1('g + h') WHERE rank MATCH 'bm25(1.0, 1.0)' ORDER BY rank; -} {1 {vtable constructor failed: t1}} +} {1 {database disk image is malformed}} do_catchsql_test 32.2 { SELECT * FROM t3; diff --git a/ext/fts5/test/fts5corrupt8.test b/ext/fts5/test/fts5corrupt8.test index d3f0e3d514..d642920e45 100644 --- a/ext/fts5/test/fts5corrupt8.test +++ b/ext/fts5/test/fts5corrupt8.test @@ -32,20 +32,11 @@ sqlite3 db test.db do_catchsql_test 1.2 { SELECT * FROM t1 -} {1 {vtable constructor failed: t1}} +} {1 {database disk image is malformed}} do_catchsql_test 1.3 { DROP TABLE t1 -} {1 {vtable constructor failed: t1}} -do_test 1.4 { - sqlite3_db_config db DEFENSIVE 0 -} {0} -do_test 1.5 { - sqlite3_fts5_drop_corrupt_table db main t1 -} {} -do_test 1.6 { - sqlite3_db_config db DEFENSIVE -1 -} {0} -do_execsql_test 1.7 { +} {0 {}} +do_execsql_test 1.4 { SELECT * FROM sqlite_schema } diff --git a/ext/fts5/test/fts5fault4.test b/ext/fts5/test/fts5fault4.test index 1d0d5c9b7c..2b4f6c4d2a 100644 --- a/ext/fts5/test/fts5fault4.test +++ b/ext/fts5/test/fts5fault4.test @@ -90,7 +90,7 @@ set ::res [db eval {SELECT rowid, x1 FROM x1 WHERE x1 MATCH '*reads'}] do_faultsim_test 4 -faults oom-* -body { db eval {SELECT rowid, x, x1 FROM x1 WHERE x1 MATCH '*reads'} } -test { - faultsim_test_result {0 {0 {} 3}} + faultsim_test_result {0 {0 {} 2}} } #------------------------------------------------------------------------- diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index 534c42fff6..c2e580c564 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -44,12 +44,12 @@ do_catchsql_test 1.2.2 { do_catchsql_test 1.3.1 { SELECT highlight(t1, 4, '', '') FROM t1('*reads'); -} {1 {no such cursor: 1}} +} {1 {no such cursor: 0}} do_catchsql_test 1.3.2 { SELECT a FROM t1 WHERE rank = (SELECT highlight(t1, 4, '', '') FROM t1('*reads')); -} {1 {no such cursor: 1}} +} {1 {no such cursor: 0}} db close sqlite3 db test.db @@ -57,12 +57,12 @@ sqlite3 db test.db do_catchsql_test 1.3.3 { SELECT a FROM t1 WHERE rank = (SELECT highlight(t1, 4, '', '') FROM t1('*reads')); -} {1 {no such cursor: 1}} +} {1 {no such cursor: 0}} fts5_aux_test_functions db do_catchsql_test 1.3.4 { SELECT fts5_columntext(t1) FROM t1('*reads'); -} {1 {no such cursor: 1}} +} {1 {no such cursor: 0}} #------------------------------------------------------------------------- reset_db diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 60ccb5a9c5..ad59bf0d9e 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -350,7 +350,7 @@ do_execsql_test 14.3 { do_execsql_test 14.4 { SELECT rowid, x, x1 FROM x1 WHERE x1 MATCH '*reads' -} {0 {} 3} +} {0 {} 2} #------------------------------------------------------------------------- reset_db diff --git a/manifest b/manifest index 129a212ab1..a00129dc3c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\sminor\simprovements\sand\stweaks\sto\sthe\stestrunner\s--status\sdisplay. -D 2024-08-27T19:49:51.307 +C Avoid\sreading\sthe\sstructure\srecord\sfrom\swithin\sthe\sfts5\sxConnect\smethod. +D 2024-08-27T20:37:30.982 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81c F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c 0dbe241c50b62e24a229a176d66d580e359b3c32cb0970c39bb6dd6b86e125d5 +F ext/fts5/fts5_main.c bd41fc81751fc7cb666de7dee52cf9bb97c04ce06a8122e7e41bb7527bde54fc F ext/fts5/fts5_storage.c 9a9b880be12901f1962ae2a5a7e1b74348b3099a1e728764e419f75d98e3e612 F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -148,12 +148,12 @@ F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b F ext/fts5/test/fts5contentless5.test 40cdcb4fe751672450829c5a96bd32c25fc2f6076279dd2ce5c58ac9a390132a F ext/fts5/test/fts5corrupt.test 6485f721b88ba355ca5d701e7ee87a4efa3ea578d8e6adb26f51ef956c8328bd F ext/fts5/test/fts5corrupt2.test 335911e3f68b9625d850325f9e29a128db3f4276a8c9d4e32134580da8f924c4 -F ext/fts5/test/fts5corrupt3.test 621e9bca3e7299f487e1b29ff4179d9fc9560f5847dfc5b50a16010c9d2a0e5f +F ext/fts5/test/fts5corrupt3.test 4fc3bf129f1616bea00884a23fd9d7b0e46d01791d2b57fe8d68ac36e8d3ff7c F ext/fts5/test/fts5corrupt4.test dc08d19f5b8943e95a7778a7d8da592042504faf18dd93f68f7d7a0d7d7dd733 F ext/fts5/test/fts5corrupt5.test 11b47126f5772cc37b67e3e8b2ed05895c4d07c05338bc07e4eea225bfe32c76 F ext/fts5/test/fts5corrupt6.test 2d72db743db7b5d9c9a6d0cfef24d799ed1aa5e8192b66c40e871a37ed9eed06 F ext/fts5/test/fts5corrupt7.test 4e830875c33b9ea3c4cf1ba71e692b63893cbb4faae8c69b1071889dc26e211c -F ext/fts5/test/fts5corrupt8.test f78b6de9e4327e16ba7a7958b1ce576f9b5d886b4b97690f90b7f3cf654da458 +F ext/fts5/test/fts5corrupt8.test b81d802e41631e98100f49a1aadeeffef860e30a62d6ed7d743c2797c477239e F ext/fts5/test/fts5delete.test 619295b20dbc1d840b403ee07c878f52378849c3c02e44f2ee143b3e978a0aa7 F ext/fts5/test/fts5detail.test 54015e9c43ec4ba542cfb93268abdf280e0300f350efd08ee411284b03595cc4 F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3bf76a2c82b1c788d11 @@ -165,7 +165,7 @@ F ext/fts5/test/fts5expr.test c7e208813df7a90badc856fde3796da79569b39382e0fdb430 F ext/fts5/test/fts5fault1.test d28a65caee75db6897c3cf1358c5230d3bb2a3bf7fb31062c19c7e5382b3d2bd F ext/fts5/test/fts5fault2.test 69c8fdbef830cd0d450908d4504d5bb86609e255af99c421c20a0756251fe344 F ext/fts5/test/fts5fault3.test da2f9e3e56ff5740d68ebdd6877c97089e7ed28ddff28a0da87a6afea27e5522 -F ext/fts5/test/fts5fault4.test 87a10d0caee57da587c7588b0c8d25d2930197399b4812ad1e4d574c75324cee +F ext/fts5/test/fts5fault4.test a5c0e849127c24e1751bc453a817f09a1b8d460e75f9ae4764017e216a870db3 F ext/fts5/test/fts5fault5.test a336e4e11847de24c9497f80cce18e00bb3fab7fb11f97d04eb9af898900a762 F ext/fts5/test/fts5fault6.test 40f49976c6ca8927bf7d65d0b8df46009d7ea172e1d4050b294610e7ea0a2979 F ext/fts5/test/fts5fault7.test 0acbec416edb24b8881f154e99c31e9ccf73f539cfcd164090be139e9e97ed4c @@ -192,7 +192,7 @@ F ext/fts5/test/fts5locale.test 797cf6f5e017462ab11313ce884b9f1df8ff063811e74ef4 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test 60bb2be4a2d83d7a45047c1812781e2e337a27efa539d86356ef7f4acaf08eab +F ext/fts5/test/fts5misc.test 8c3cc771f773dc4bb4973620c51e7729e324ca2cc80eb8894f1c2c605e361f0b F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -226,7 +226,7 @@ F ext/fts5/test/fts5secure6.test 74bf04733cc523bccca519bb03d3b4e2ed6f6e3db7c59bf F ext/fts5/test/fts5secure7.test fd03d0868d64340a1db8615b02e5508fea409de13910114e4f19eaefc120777a F ext/fts5/test/fts5secure8.test 808ade9d172ed07b24b85c57dd53b6d2b1aba018b4e634d267ce572221de80e0 F ext/fts5/test/fts5securefault.test c34a28c7cd2f31a8b8907563889e1329a97da975c08df2d951422bcef8e2ebc5 -F ext/fts5/test/fts5simple.test ed7c3815c9fa1c16166258cb98edb2e014c63c7589958d76c5487df0df913d61 +F ext/fts5/test/fts5simple.test 302cdb4f8a3350b091f4f1bccd82d05610428657f6f9e81c17703ba48267ec40 F ext/fts5/test/fts5simple2.test d10d963a357b8ec77b99032e4c816459b4dbdb1f6eee25eada7ef3ed245cb2dc F ext/fts5/test/fts5simple3.test 146ec3dc8f5763d6212641c9f0a2f1cba41679353d2add7b963beceb115dc7f4 F ext/fts5/test/fts5synonym.test becc8cea6cfc958a50b30c572c68cbfdf7455971d0fe988202ce67638d2c6cf6 @@ -2211,9 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dbc1ac8692feccde271eaca78f2833c8bb7bf620088c8f975692d6ae2c8ba53a 2eaea67495fd9961b7145d829789889bf1d8fa7a834d40d1be43e7c74c233bc2 -R 15868716c90b102057036239341d8066 -T +closed 2eaea67495fd9961b7145d829789889bf1d8fa7a834d40d1be43e7c74c233bc2 -U drh -Z c190467c6ca0a01405f49df20c5de973 +P 7d1ccc6dfc9abe053baaf39f68e9fb14001f5032a52b85fe1e4b752e48317536 +R b2f3edb080a36a6c22913345d9099db8 +U dan +Z ae75f308e945276fc7d3f4e6bfacd7cd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bdd3c3e43e..7394734f08 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7d1ccc6dfc9abe053baaf39f68e9fb14001f5032a52b85fe1e4b752e48317536 +6a6ce343b249e269229867b2c2f107a49ac8a8f24ad66801718ef01159655319 From c3c645ef465767abc71b33533c1f576c35f84338 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Aug 2024 21:44:45 +0000 Subject: [PATCH 0731/1030] Improvements to --status overwrite in testrunner. FossilOrigin-Name: 26372762ab1451eb95d29367f5b2534bde616a37e5e757e72ba2cfe42571d180 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/testrunner.tcl | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index a00129dc3c..d025a4f329 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sreading\sthe\sstructure\srecord\sfrom\swithin\sthe\sfts5\sxConnect\smethod. -D 2024-08-27T20:37:30.982 +C Improvements\sto\s--status\soverwrite\sin\stestrunner. +D 2024-08-27T21:44:45.108 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl c27905c57f54450411be922037d227fee65b08928d09715d784380a398b0e758 +F test/testrunner.tcl 0a9e76679856e5782d520f8e4329c18ba655b6bbd19a154f44a4fb5e350be531 F test/testrunner_data.tcl 6a0facfbff26f2f8573ebaeb209426bbb59809d5c0f6925f983bd030ab5248cd F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7d1ccc6dfc9abe053baaf39f68e9fb14001f5032a52b85fe1e4b752e48317536 -R b2f3edb080a36a6c22913345d9099db8 -U dan -Z ae75f308e945276fc7d3f4e6bfacd7cd +P 6a6ce343b249e269229867b2c2f107a49ac8a8f24ad66801718ef01159655319 +R f5da9843604e1033edc0cf6e244622b0 +U drh +Z fa568405ca45a71e0343a4bd7c4efb05 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7394734f08..13a472ba51 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a6ce343b249e269229867b2c2f107a49ac8a8f24ad66801718ef01159655319 +26372762ab1451eb95d29367f5b2534bde616a37e5e757e72ba2cfe42571d180 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 8d81469c02..6344d0b0e2 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -481,7 +481,7 @@ proc show_status {db cls} { set srcdir [file dirname [file dirname $TRG(info_script)]] if {$S(running)>0} { - puts "Running: " + puts [format %-79s "Running:"] $db eval { SELECT * FROM jobs WHERE state='running' ORDER BY starttime } job { @@ -489,7 +489,7 @@ proc show_status {db cls} { } } if {$S(failed)>0} { - puts "Failures: " + puts [format %-79s "Failures:"] $db eval { SELECT * FROM jobs WHERE state='failed' ORDER BY starttime } job { From b5b4ca2a11f513d802c1eccea24fd5d128a324e8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 27 Aug 2024 22:28:03 +0000 Subject: [PATCH 0732/1030] Changes to the way "release" tests were constructed in [d03d35eebaf82709] were incorrect. Fixed here. Also enhance --explain to chose permutation configurations and so that PATTERNS on the the command line can match against permutation configurations. FossilOrigin-Name: 1f962ffc9e956a9d6311ed9c02fea13c0fe056283ee2c650a2312a258808b3b3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 40 ++++++++++++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index d025a4f329..de8374a5ce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\s--status\soverwrite\sin\stestrunner. -D 2024-08-27T21:44:45.108 +C Changes\sto\sthe\sway\s"release"\stests\swere\sconstructed\sin\s[d03d35eebaf82709]\nwere\sincorrect.\s\sFixed\shere.\s\sAlso\senhance\s--explain\sto\schose\spermutation\nconfigurations\sand\sso\sthat\sPATTERNS\son\sthe\sthe\scommand\sline\scan\smatch\nagainst\spermutation\sconfigurations. +D 2024-08-27T22:28:03.935 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl 0a9e76679856e5782d520f8e4329c18ba655b6bbd19a154f44a4fb5e350be531 +F test/testrunner.tcl de5deab405d25cdb0f85c4b75cc63dc1fa0571b099621b585f083647d7f6d75a F test/testrunner_data.tcl 6a0facfbff26f2f8573ebaeb209426bbb59809d5c0f6925f983bd030ab5248cd F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a6ce343b249e269229867b2c2f107a49ac8a8f24ad66801718ef01159655319 -R f5da9843604e1033edc0cf6e244622b0 +P 26372762ab1451eb95d29367f5b2534bde616a37e5e757e72ba2cfe42571d180 +R 66a023125402741fa708637568f51009 U drh -Z fa568405ca45a71e0343a4bd7c4efb05 +Z f1950a098efb328b04fe6e5b9690c497 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 13a472ba51..df0f6a1846 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -26372762ab1451eb95d29367f5b2534bde616a37e5e757e72ba2cfe42571d180 +1f962ffc9e956a9d6311ed9c02fea13c0fe056283ee2c650a2312a258808b3b3 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 6344d0b0e2..fcb46a9214 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -475,7 +475,7 @@ proc show_status {db cls} { set clreol "" } puts [format %-79.79s "Command: \[testrunner.tcl$cmdline\]$clreol"] - puts [format %-79.79s "Cores: $nJob max $S(running) active"] + puts [format %-79.79s "Jobs: $nJob max $S(running) active"] puts [format %-79.79s "Summary: [elapsetime $tm], $fin/$total tasks,\ $ne errors, $nt tests"] @@ -880,7 +880,7 @@ proc add_tcl_jobs {build config patternlist {shelldepid ""}} { } else { set p "$p*" } - if {[string match $p [file tail $f]]} { + if {[string match $p "$config [file tail $f]"]} { set bMatch 1 break } @@ -1100,13 +1100,34 @@ proc add_jobs_from_cmdline {patternlist} { } release { - set config_set {} + set patternlist [lrange $patternlist 1 end] foreach b [trd_builds $TRG(platform)] { if {$TRG(config)!="" && ![regexp "\\y$b\\y" $TRG(config)]} continue if {[regexp "\\y$b\\y" $TRG(omitconfig)]} continue - lappend config_set $b + set bld [add_build_job $b $TRG(testfixture)] + foreach c [trd_configs $TRG(platform) $b] { + add_tcl_jobs $bld $c $patternlist SHELL + } + + if {$patternlist==""} { + foreach e [trd_extras $TRG(platform) $b] { + if {$e=="fuzztest"} { + add_fuzztest_jobs $b + } else { + add_make_job $bld $e + } + } + } + + if {[trdb one "SELECT EXISTS(SELECT 1 + FROM jobs WHERE depid='SHELL')"]} { + set sbld [add_shell_build_job $b [lindex $bld 1] [lindex $bld 0]] + set sbldid [lindex $sbld 0] + trdb eval { + UPDATE jobs SET depid=$sbldid WHERE depid='SHELL' + } + } } - add_devtest_jobs $config_set [lrange $patternlist 1 end] } list { @@ -1448,7 +1469,14 @@ proc explain_layer {indent depid} { puts "${indent}$displayname in $dirname" explain_layer "${indent} " $jobid } elseif {$showtests} { - puts "${indent}[lindex $displayname end]" + set tail [lindex $displayname end] + set e1 [lindex $displayname 1] + if {[string match config=* $e1]} { + set cfg [string range $e1 7 end] + puts "${indent}($cfg) $tail" + } else { + puts "${indent}$tail" + } } } } From af43eddc232e2da4ab5c4d6f9fa084de1cd8fb8c Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 09:31:17 +0000 Subject: [PATCH 0733/1030] Reenable SQLITE_OMIT_VIRTUALTABLE on the Device-One alignment for testrunner. FossilOrigin-Name: 8f2cb357634ec0b5aef14f3d967e76db236f8899f3201efc80c264f548cc1b0b --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner_data.tcl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index de8374a5ce..a21b754312 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\sthe\sway\s"release"\stests\swere\sconstructed\sin\s[d03d35eebaf82709]\nwere\sincorrect.\s\sFixed\shere.\s\sAlso\senhance\s--explain\sto\schose\spermutation\nconfigurations\sand\sso\sthat\sPATTERNS\son\sthe\sthe\scommand\sline\scan\smatch\nagainst\spermutation\sconfigurations. -D 2024-08-27T22:28:03.935 +C Reenable\sSQLITE_OMIT_VIRTUALTABLE\son\sthe\sDevice-One\salignment\sfor\stestrunner. +D 2024-08-28T09:31:17.887 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1715,7 +1715,7 @@ F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 F test/testrunner.tcl de5deab405d25cdb0f85c4b75cc63dc1fa0571b099621b585f083647d7f6d75a -F test/testrunner_data.tcl 6a0facfbff26f2f8573ebaeb209426bbb59809d5c0f6925f983bd030ab5248cd +F test/testrunner_data.tcl f1cbff53fe42087cac3d43ca02f9574bd212c842307442e2b6fff2183f5ccbfe F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 26372762ab1451eb95d29367f5b2534bde616a37e5e757e72ba2cfe42571d180 -R 66a023125402741fa708637568f51009 +P 1f962ffc9e956a9d6311ed9c02fea13c0fe056283ee2c650a2312a258808b3b3 +R 8e623cc4a65f73a6029848f64a42525f U drh -Z f1950a098efb328b04fe6e5b9690c497 +Z 1895efedce008ae727a6effa6ee80029 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index df0f6a1846..59d2cc678e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f962ffc9e956a9d6311ed9c02fea13c0fe056283ee2c650a2312a258808b3b3 +8f2cb357634ec0b5aef14f3d967e76db236f8899f3201efc80c264f548cc1b0b diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index 48484a3e24..71a42ab404 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -218,7 +218,7 @@ namespace eval trd { -DSQLITE_MAX_PAGE_SIZE=4096 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 - -DSQLITE_OMIT_VIRTUALTABLEx=1 + -DSQLITE_OMIT_VIRTUALTABLE=1 -DSQLITE_ENABLE_HIDDEN_COLUMNS -DSQLITE_TEMP_STORE=3 } From a88d61824dfa5d896cf13eed7c984a09d1d5bd0c Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 09:47:29 +0000 Subject: [PATCH 0734/1030] Disable shell test cases that require virtual tables when testfixture is built using SQLITE_OMIT_VIRTUALTABLE. FossilOrigin-Name: 8c73d54fd1e250fcd7f30741cfbd169af9aaecc2096c0c8a9486abaa064d69af --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/shell2.test | 4 ++++ test/shell5.test | 8 ++++++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a21b754312..60890f8056 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reenable\sSQLITE_OMIT_VIRTUALTABLE\son\sthe\sDevice-One\salignment\sfor\stestrunner. -D 2024-08-28T09:31:17.887 +C Disable\sshell\stest\scases\sthat\srequire\svirtual\stables\swhen\stestfixture\sis\nbuilt\susing\sSQLITE_OMIT_VIRTUALTABLE. +D 2024-08-28T09:47:29.176 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1626,10 +1626,10 @@ F test/sharedB.test 1a84863d7a2204e0d42f2e1606577c5e92e4473fa37ea0f5bdf829e4bf8e F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 F test/shell1.test 490bf9d0c7c9564fea318c46d49369f4690b825b584c9a544dbdccf61bc0babc -F test/shell2.test 56da24128304c9ab67da2964cc80beff7b35761c446ec6e6e98bff2775b15026 +F test/shell2.test 01a01f76ed98088ce598794fbf5b359e148271541a8ddbf79d21cc353cc67a24 F test/shell3.test db1953a8e59d08e9240b7cc5948878e184f7eb2623591587f8fd1f1a5bd536d8 F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f807 -F test/shell5.test bafa4c0b67b7a8027e729970a625c9225cb7ef854acc4e52624c45074faaaddf +F test/shell5.test 0e5f8ce08206b9998a778cfe1989e20e47839153c05af2da29198150172e22fc F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bdbb8 F test/shell7.test 43fd8e511c533bab5232e95c7b4be93b243451709e89582600d4b6e67693d5c3 F test/shell8.test aea51ecbcd4494c746b096aeff51d841d04d5f0dc4b62eb42427f16109b87acd @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1f962ffc9e956a9d6311ed9c02fea13c0fe056283ee2c650a2312a258808b3b3 -R 8e623cc4a65f73a6029848f64a42525f +P 8f2cb357634ec0b5aef14f3d967e76db236f8899f3201efc80c264f548cc1b0b +R 6d8d08b44812eef81a87de61d7679ec8 U drh -Z 1895efedce008ae727a6effa6ee80029 +Z 9d65cc1858f9f46a1f30863c1abce3fa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 59d2cc678e..fb2482f0ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f2cb357634ec0b5aef14f3d967e76db236f8899f3201efc80c264f548cc1b0b +8c73d54fd1e250fcd7f30741cfbd169af9aaecc2096c0c8a9486abaa064d69af diff --git a/test/shell2.test b/test/shell2.test index c6c27d2165..ee5ae4bdd9 100644 --- a/test/shell2.test +++ b/test/shell2.test @@ -217,6 +217,7 @@ do_test shell2-1.4.9 { done 2}} +ifcapable vtab { # Verify that generate_series stays sane near 64-bit range boundaries. # See overflow report at https://sqlite.org/forum/forumpost/5d34ce5280 do_test shell2-1.4.10 { @@ -247,7 +248,9 @@ do_test shell2-1.4.10 { 0 1 2}} +} ;# ifcapable vtab +ifcapable vtab { # Bug discovered while messing around, .import hangs with # bit 7 set in column separator. do_test shell2-1.4.11 { @@ -262,6 +265,7 @@ do_test shell2-1.4.11 { .import dummy.csv t SELECT count(*) FROM t;}]] } {0 1} +} ;# ifcapable vtab # Bug from forum post 7cbe081746dd3803 # Keywords as column names were producing an error message. diff --git a/test/shell5.test b/test/shell5.test index 31d5449fdc..8eb905974b 100644 --- a/test/shell5.test +++ b/test/shell5.test @@ -84,6 +84,14 @@ do_test shell5-1.4.1 { .import FOO t1}] } {1 {Error: cannot open "FOO"}} +# the remainder of these test cases require virtual tables. +# +ifcapable !vtab { + puts "Skipping subsequent tests due to SQLITE_OMIT_VIRTUALTABLE" + finish_test + return +} + # empty import file do_test shell5-1.4.2 { forcedelete shell5.csv From 4a90f81a6d17af33dc689e4d32ee0091620b8cd9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 10:25:44 +0000 Subject: [PATCH 0735/1030] In the testrunner status display, limit the number of reported failed jobs to avoid overflowing the terminal when there are many failures. FossilOrigin-Name: ffeaa4d5d73871cbdf1ef70b9845d921ebdb96e964d232661a5048cab7d744ed --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 25 +++++++++++++++++++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 60890f8056..b36a4ba20f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sshell\stest\scases\sthat\srequire\svirtual\stables\swhen\stestfixture\sis\nbuilt\susing\sSQLITE_OMIT_VIRTUALTABLE. -D 2024-08-28T09:47:29.176 +C In\sthe\stestrunner\sstatus\sdisplay,\slimit\sthe\snumber\sof\sreported\sfailed\sjobs\nto\savoid\soverflowing\sthe\sterminal\swhen\sthere\sare\smany\sfailures. +D 2024-08-28T10:25:44.140 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl de5deab405d25cdb0f85c4b75cc63dc1fa0571b099621b585f083647d7f6d75a +F test/testrunner.tcl c3f6e70f02bc0257d2d66ac1fff7d26d76b1c4fcdd5e4b4d90faf2a126623587 F test/testrunner_data.tcl f1cbff53fe42087cac3d43ca02f9574bd212c842307442e2b6fff2183f5ccbfe F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8f2cb357634ec0b5aef14f3d967e76db236f8899f3201efc80c264f548cc1b0b -R 6d8d08b44812eef81a87de61d7679ec8 +P 8c73d54fd1e250fcd7f30741cfbd169af9aaecc2096c0c8a9486abaa064d69af +R c92552ba898da06e8effb71b87a3f9eb U drh -Z 9d65cc1858f9f46a1f30863c1abce3fa +Z 9fabe008bd6ec45672f53069445b0fd8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fb2482f0ae..c41d9ba427 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c73d54fd1e250fcd7f30741cfbd169af9aaecc2096c0c8a9486abaa064d69af +ffeaa4d5d73871cbdf1ef70b9845d921ebdb96e964d232661a5048cab7d744ed diff --git a/test/testrunner.tcl b/test/testrunner.tcl index fcb46a9214..a97983fac5 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -480,20 +480,37 @@ proc show_status {db cls} { $ne errors, $nt tests"] set srcdir [file dirname [file dirname $TRG(info_script)]] + set nrun 0 if {$S(running)>0} { - puts [format %-79s "Running:"] + puts [format %-79s "$S(running) Running:"] $db eval { SELECT * FROM jobs WHERE state='running' ORDER BY starttime } job { + incr nrun display_job [array get job] $now } } if {$S(failed)>0} { - puts [format %-79s "Failures:"] + puts [format %-79s "$S(failed) Failed:"] + set nfail 0 + + # $mxtoshow tries to limit the number of "Failures:" reported so that + # the status display does not overflow a 24-line terminal. But it will + # always show at least the most recent 4 failures, even if an overflow + # is needed. + set mxtoshow [expr {16-$nrun}] + if {$mxtoshow<4} {set mxtoshow 4} + $db eval { - SELECT * FROM jobs WHERE state='failed' ORDER BY starttime + SELECT * FROM jobs WHERE state='failed' ORDER BY endtime DESC } job { - display_job [array get job] + incr nfail + if {$nfail<=$mxtoshow} { + display_job [array get job] + } + } + if {$nfail>$mxtoshow} { + puts [format %-79s " ... plus [expr {$nfail-$mxtoshow}] more"] } set nOmit [$db one {SELECT count(*) FROM jobs WHERE state='omit'}] if {$nOmit} { From 242e06497855d5d4e3bf7376ac10bda024d3db47 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 10:36:18 +0000 Subject: [PATCH 0736/1030] Only limit the number of failures reported by testrunner status if using VT100 cursor movement. For a straight-up "status" command, show everything. FossilOrigin-Name: 791237e0f4b67f0197ae11e966554edeade0c443289d2ade00470d23bf5e8ec8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 10 +++++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index b36a4ba20f..5f2f3faa01 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\stestrunner\sstatus\sdisplay,\slimit\sthe\snumber\sof\sreported\sfailed\sjobs\nto\savoid\soverflowing\sthe\sterminal\swhen\sthere\sare\smany\sfailures. -D 2024-08-28T10:25:44.140 +C Only\slimit\sthe\snumber\sof\sfailures\sreported\sby\stestrunner\sstatus\sif\susing\nVT100\scursor\smovement.\s\sFor\sa\sstraight-up\s"status"\scommand,\sshow\severything. +D 2024-08-28T10:36:18.262 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl c3f6e70f02bc0257d2d66ac1fff7d26d76b1c4fcdd5e4b4d90faf2a126623587 +F test/testrunner.tcl cfe0f1dd8ce1da41ebc2238eabd2f9562e48162505eb6c4495eb9221e00a0c93 F test/testrunner_data.tcl f1cbff53fe42087cac3d43ca02f9574bd212c842307442e2b6fff2183f5ccbfe F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8c73d54fd1e250fcd7f30741cfbd169af9aaecc2096c0c8a9486abaa064d69af -R c92552ba898da06e8effb71b87a3f9eb +P ffeaa4d5d73871cbdf1ef70b9845d921ebdb96e964d232661a5048cab7d744ed +R 8085922607334118c1b73e04568394c4 U drh -Z 9fabe008bd6ec45672f53069445b0fd8 +Z 328eda1f95b36f3977ef4f1d3bbc3083 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c41d9ba427..6bcef0ddb0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ffeaa4d5d73871cbdf1ef70b9845d921ebdb96e964d232661a5048cab7d744ed +791237e0f4b67f0197ae11e966554edeade0c443289d2ade00470d23bf5e8ec8 diff --git a/test/testrunner.tcl b/test/testrunner.tcl index a97983fac5..1744af2ea7 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -497,9 +497,13 @@ proc show_status {db cls} { # $mxtoshow tries to limit the number of "Failures:" reported so that # the status display does not overflow a 24-line terminal. But it will # always show at least the most recent 4 failures, even if an overflow - # is needed. - set mxtoshow [expr {16-$nrun}] - if {$mxtoshow<4} {set mxtoshow 4} + # is needed. But, do not limit the length of the output of $cls is false. + if {$cls} { + set mxtoshow [expr {16-$nrun}] + if {$mxtoshow<4} {set mxtoshow 4} + } else { + set mxtoshow 9999999 + } $db eval { SELECT * FROM jobs WHERE state='failed' ORDER BY endtime DESC From 4f2f91bf08cb47ae7ac492f92b0cd2ffb894f3f1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 11:03:58 +0000 Subject: [PATCH 0737/1030] Further improvements to the status display in order to maximum the amount of information shown on the limited screen realestate available when running via "watch" or in continuous monitoring mode. All details are still shown when doing a stand-alone "status". FossilOrigin-Name: 557a2c65f5ae1d8cb1858c17da0fe64fbfba83d787cfb7f2f21582960a8b9eac --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 46 +++++++++++++++++++-------------------------- 3 files changed, 26 insertions(+), 34 deletions(-) diff --git a/manifest b/manifest index 5f2f3faa01..b367857848 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Only\slimit\sthe\snumber\sof\sfailures\sreported\sby\stestrunner\sstatus\sif\susing\nVT100\scursor\smovement.\s\sFor\sa\sstraight-up\s"status"\scommand,\sshow\severything. -D 2024-08-28T10:36:18.262 +C Further\simprovements\sto\sthe\sstatus\sdisplay\sin\sorder\sto\smaximum\sthe\samount\sof\ninformation\sshown\son\sthe\slimited\sscreen\srealestate\savailable\swhen\srunning\nvia\s"watch"\sor\sin\scontinuous\smonitoring\smode.\s\sAll\sdetails\sare\sstill\sshown\nwhen\sdoing\sa\sstand-alone\s"status". +D 2024-08-28T11:03:58.055 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl cfe0f1dd8ce1da41ebc2238eabd2f9562e48162505eb6c4495eb9221e00a0c93 +F test/testrunner.tcl 2345d50bca7a48fa3454cf088a2ec6978d8a0042feadc8e7336ac5d0dfe53b07 F test/testrunner_data.tcl f1cbff53fe42087cac3d43ca02f9574bd212c842307442e2b6fff2183f5ccbfe F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ffeaa4d5d73871cbdf1ef70b9845d921ebdb96e964d232661a5048cab7d744ed -R 8085922607334118c1b73e04568394c4 +P 791237e0f4b67f0197ae11e966554edeade0c443289d2ade00470d23bf5e8ec8 +R d373eef32be36327da73bfcab1a028e6 U drh -Z 328eda1f95b36f3977ef4f1d3bbc3083 +Z 38527615900da2d45d6401569f849a97 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6bcef0ddb0..7e1aedcbf9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -791237e0f4b67f0197ae11e966554edeade0c443289d2ade00470d23bf5e8ec8 +557a2c65f5ae1d8cb1858c17da0fe64fbfba83d787cfb7f2f21582960a8b9eac diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 1744af2ea7..5bddeee610 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -470,19 +470,15 @@ proc show_status {db cls} { # overwrite. puts -nonewline "\033\[H" flush stdout - set clreol "\033\[K" - } else { - set clreol "" } - puts [format %-79.79s "Command: \[testrunner.tcl$cmdline\]$clreol"] - puts [format %-79.79s "Jobs: $nJob max $S(running) active"] - puts [format %-79.79s "Summary: [elapsetime $tm], $fin/$total tasks,\ + puts [format %-79.79s "Command: \[testrunner.tcl$cmdline\]"] + puts [format %-79.79s "Summary: [elapsetime $tm], $fin/$total jobs,\ $ne errors, $nt tests"] set srcdir [file dirname [file dirname $TRG(info_script)]] set nrun 0 + puts [format %-79s "Running: $S(running) (max: $nJob)"] if {$S(running)>0} { - puts [format %-79s "$S(running) Running:"] $db eval { SELECT * FROM jobs WHERE state='running' ORDER BY starttime } job { @@ -491,34 +487,30 @@ proc show_status {db cls} { } } if {$S(failed)>0} { - puts [format %-79s "$S(failed) Failed:"] - set nfail 0 - - # $mxtoshow tries to limit the number of "Failures:" reported so that - # the status display does not overflow a 24-line terminal. But it will + # $toshow is the number of failures to report. In $cls mode, + # status tries to limit the number of failure reported so that + # the status display does not overflow a 24-line terminal. It will # always show at least the most recent 4 failures, even if an overflow - # is needed. But, do not limit the length of the output of $cls is false. - if {$cls} { - set mxtoshow [expr {16-$nrun}] - if {$mxtoshow<4} {set mxtoshow 4} + # is needed. No limit is imposed for a status within $cls. + # + if {$cls && $S(failed)>18-$S(running)} { + set toshow [expr {18-$S(running)}] + if {$toshow<4} {set toshow 4} + set shown " (must recent $toshow shown)" } else { - set mxtoshow 9999999 + set toshow $S(failed) + set shown "" } - + puts [format %-79s "Failed: $S(failed) $shown"] $db eval { - SELECT * FROM jobs WHERE state='failed' ORDER BY endtime DESC + SELECT * FROM jobs WHERE state='failed' + ORDER BY endtime DESC LIMIT $toshow } job { - incr nfail - if {$nfail<=$mxtoshow} { - display_job [array get job] - } - } - if {$nfail>$mxtoshow} { - puts [format %-79s " ... plus [expr {$nfail-$mxtoshow}] more"] + display_job [array get job] } set nOmit [$db one {SELECT count(*) FROM jobs WHERE state='omit'}] if {$nOmit} { - puts [format %-79s "$nOmit jobs omitted due to failures$clreol"] + puts [format %-79s " ... $nOmit jobs omitted due to failures"] } } if {$cls} { From d6b56d65a8c330c7310611f78d281cdc050e654b Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 12:10:51 +0000 Subject: [PATCH 0738/1030] Update the "make test" target so that it is really just "mdevtest" with "srctree-check" and "sourcetest". FossilOrigin-Name: 7420b13238da4e6bfb1589eaf3cfd842fe3c4b0f3b6a3b49c24cd70589bf4809 --- Makefile.in | 14 ++++++-------- Makefile.msc | 13 ++++++++++--- main.mk | 12 +++++++++--- manifest | 18 +++++++++--------- manifest.uuid | 2 +- tool/mkctimec.tcl | 1 + 6 files changed, 36 insertions(+), 24 deletions(-) diff --git a/Makefile.in b/Makefile.in index b8149f846f..d17d6830d0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1381,18 +1381,16 @@ srctree-check: $(TOP)/tool/srctree-check.tcl # Testing for a release # -releasetest: srctree-check testfixture$(TEXE) - ./testfixture$(TEXE) $(TOP)/test/testrunner.tcl release $(TSTRNNR_OPTS) +releasetest: srctree-check has_tclsh85 + $(TCLSH_CMD) $(TOP)/test/testrunner.tcl release $(TSTRNNR_OPTS) # Minimal testing that runs in less than 3 minutes # quicktest: ./testfixture$(TEXE) ./testfixture$(TEXE) $(TOP)/test/extraquick.test $(TESTOPTS) -# This is the common case. Run many tests that do not take too long, -# including fuzzcheck, sqlite3_analyzer, and sqldiff tests. -# -test: srctree-check fuzztest sourcetest $(TESTPROGS) tcltest +test: srctree-check sourcetest + $(TCLSH_CMD) $(TOP)/test/testrunner.tcl mdevtest $(TSTRNNR_OPTS) # Run a test using valgrind. This can take a really long time # because valgrind is so much slower than a native machine. @@ -1407,8 +1405,8 @@ valgrindtest: $(TESTPROGS) valgrindfuzz smoketest: $(TESTPROGS) fuzzcheck$(TEXE) ./testfixture$(TEXE) $(TOP)/test/main.test $(TESTOPTS) -shelltest: $(TESTPROGS) - ./testfixture$(TEXT) $(TOP)/test/permutations.test shell +shelltest: + $(TCLSH_CMD) $(TOP)/test/testrunner.tcl release shell sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in has_tclsh85 $(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in >sqlite3_analyzer.c diff --git a/Makefile.msc b/Makefile.msc index e31aee0899..e4420b1dea 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2544,7 +2544,8 @@ quicktest: testfixture.exe sourcetest # This is the common case. Run many tests that do not take too long, # including fuzzcheck, sqlite3_analyzer, and sqldiff tests. # -test: $(TESTPROGS) sourcetest fuzztest tcltest +test: srctree-check sourcetest + $(TCLSH_CMD) $(TOP)\test\testrunner.tcl mdevtest # The veryquick.test TCL tests. # @@ -2565,10 +2566,16 @@ devtest: testfixture.exe fuzztest testrunner mdevtest: $(TCLSH_CMD) $(TOP)\test\testrunner.tcl mdevtest +# Validate that various generated files in the source tree +# are up-to-date. +# +srctree-check: $(TOP)\tool\srctree-check.tcl + $(TCLSH_CMD) $(TOP)\tool\srctree-check.tcl + # Testing for a release # -releasetest: testfixture.exe - testfixture.exe $(TOP)\test\testrunner.tcl release +releasetest: + $(TCLSH_CMD) $(TOP)\test\testrunner.tcl release smoketest: $(TESTPROGS) diff --git a/main.mk b/main.mk index baf8260417..ea6b83d059 100644 --- a/main.mk +++ b/main.mk @@ -971,9 +971,15 @@ mdevtest: quicktest: ./testfixture$(EXE) ./testfixture$(EXE) $(TOP)/test/extraquick.test $(TESTOPTS) -# The default test case. Runs most of the faster standard TCL tests, -# and fuzz tests, and sqlite3_analyzer and sqldiff tests. -test: fuzztest sourcetest $(TESTPROGS) tcltest +# Validate that various generated files in the source tree +# are up-to-date. +# +srctree-check: $(TOP)/tool/srctree-check.tcl + tclsh $(TOP)/tool/srctree-check.tcl + +# The default test case. +test: srctree-check sourcetest + tclsh $(TOP)/test/testrunner.tcl mdevtest # Run a test using valgrind. This can take a really long time diff --git a/manifest b/manifest index b367857848..b4f5e7e97f 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Further\simprovements\sto\sthe\sstatus\sdisplay\sin\sorder\sto\smaximum\sthe\samount\sof\ninformation\sshown\son\sthe\slimited\sscreen\srealestate\savailable\swhen\srunning\nvia\s"watch"\sor\sin\scontinuous\smonitoring\smode.\s\sAll\sdetails\sare\sstill\sshown\nwhen\sdoing\sa\sstand-alone\s"status". -D 2024-08-28T11:03:58.055 +C Update\sthe\s"make\stest"\starget\sso\sthat\sit\sis\sreally\sjust\s"mdevtest"\swith\n"srctree-check"\sand\s"sourcetest". +D 2024-08-28T12:10:51.091 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 101cb90f75c16ca3f8e7088364322441f9b01d6fdcef4a9c7f5fdcf78a3601a4 +F Makefile.in d51de7cfc0500e54b7a8961218ce9d7fa115610f5353f98fd9b407a1a69dfdcc F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 6c3fe8b6ce60e73f34a148c957d78b4648745c8d30e792423aa1a8d8bf12d065 +F Makefile.msc fa422ec289537f61c5fe660e85ff4cab9389c3095a9071b5a0487aa521e657ba F README.md 3d47ef5758e2de29d6f4e1aca714d51424baba86c8b561fef330f6ef2dc9282c F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -685,7 +685,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 9541ffdce424ddddb463e2480c3f1cb4067bbd3a6d2c84b3f083cb128a2fa721 +F main.mk 7a70a20e224bf9cdf518cafe7738000ef7b2aec7b7de19d3e49700301d6ff130 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2131,7 +2131,7 @@ F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176 F tool/mkautoconfamal.sh cbdcf993fa83dccbef7fb77b39cdeb31ef9f77d9d88c9e343b58d35ca3898a6a F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x -F tool/mkctimec.tcl 060e9785e9503bf51f8b1b11b542bdeef90fd0ceb0738154f6762acec0c61e5f x +F tool/mkctimec.tcl 48ca8eefa9e615cb9057ce6485b9c9ae5801381f24690d7d60b3b2dc8e6b7457 x F tool/mkkeywordhash.c b9faa0ae7e14e4dbbcd951cddd786bf46b8a65bb07b129ba8c0cfade723aaffd F tool/mkmsvcmin.tcl d76c45efda1cce2d4005bcea7b8a22bb752e3256009f331120fb4fecb14ebb7a F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 791237e0f4b67f0197ae11e966554edeade0c443289d2ade00470d23bf5e8ec8 -R d373eef32be36327da73bfcab1a028e6 +P 557a2c65f5ae1d8cb1858c17da0fe64fbfba83d787cfb7f2f21582960a8b9eac +R 810ec2efa964f89a1c1304eac241e2a3 U drh -Z 38527615900da2d45d6401569f849a97 +Z a85e1bb31ced99882e1388879ef7a06f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7e1aedcbf9..4a6b864348 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -557a2c65f5ae1d8cb1858c17da0fe64fbfba83d787cfb7f2f21582960a8b9eac +7420b13238da4e6bfb1589eaf3cfd842fe3c4b0f3b6a3b49c24cd70589bf4809 diff --git a/tool/mkctimec.tcl b/tool/mkctimec.tcl index 135164e3d1..7ca664a37e 100755 --- a/tool/mkctimec.tcl +++ b/tool/mkctimec.tcl @@ -448,6 +448,7 @@ if {[catch {set cfd [open $destfile w]}]!=0} { puts stderr "File '$destfile' unwritable." exit 1; } +fconfigure $cfd -translation binary puts $cfd $::headWarning; puts $cfd $::headCode; From 3341f5ce85e9ad392c9828105e6d5a5cf5afb6fc Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 13:34:20 +0000 Subject: [PATCH 0739/1030] Minor wording change on testrunner output. FossilOrigin-Name: 115e68597957a9ee80de7f554ee3768c992051687c8f07eaf3a9fcaab7efd44e --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b4f5e7e97f..cf14534781 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\s"make\stest"\starget\sso\sthat\sit\sis\sreally\sjust\s"mdevtest"\swith\n"srctree-check"\sand\s"sourcetest". -D 2024-08-28T12:10:51.091 +C Minor\swording\schange\son\stestrunner\soutput. +D 2024-08-28T13:34:20.794 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl 2345d50bca7a48fa3454cf088a2ec6978d8a0042feadc8e7336ac5d0dfe53b07 +F test/testrunner.tcl ff5f42f683a9c868fe01a855d81b9f08e1afb031edc5c340e5cf0fe5deaa0041 F test/testrunner_data.tcl f1cbff53fe42087cac3d43ca02f9574bd212c842307442e2b6fff2183f5ccbfe F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 557a2c65f5ae1d8cb1858c17da0fe64fbfba83d787cfb7f2f21582960a8b9eac -R 810ec2efa964f89a1c1304eac241e2a3 +P 7420b13238da4e6bfb1589eaf3cfd842fe3c4b0f3b6a3b49c24cd70589bf4809 +R 203b7adbe6856a41e47a582ad4a2ff84 U drh -Z a85e1bb31ced99882e1388879ef7a06f +Z ec83570cfd83b688d421f55742cc81eb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4a6b864348..507c4e1143 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7420b13238da4e6bfb1589eaf3cfd842fe3c4b0f3b6a3b49c24cd70589bf4809 +115e68597957a9ee80de7f554ee3768c992051687c8f07eaf3a9fcaab7efd44e diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 5bddeee610..58c718fe47 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -1504,7 +1504,7 @@ if {$TRG(explain)} { explain_tests } else { if {$TRG(nJob)>1} { - puts "splitting work across $TRG(nJob) jobs" + puts "splitting work across $TRG(nJob) cores" } puts "built testset in [expr $tm/1000]ms.." handle_buildonly From ba5994b1818fea883217f0a930b0c819d0cfbed8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 13:51:51 +0000 Subject: [PATCH 0740/1030] Maybe [7420b13238da4e6b] was not such a good idea. Restore "make test" so that it works as before - running a single-threaded test over the source tree with options specified by ./configure and similar. Instead, change the "make devtest" target so that runs the automated multi-threaded tests on a standard configuration. FossilOrigin-Name: dc9fee980d4f4b5a569628702e52cef9e5d8e6c69c2b84546dce47e3e514775e --- Makefile.in | 18 ++++++++++++++---- Makefile.msc | 17 +++++++++++++---- main.mk | 20 ++++++++++++++------ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 50 insertions(+), 23 deletions(-) diff --git a/Makefile.in b/Makefile.in index d17d6830d0..6f41c9bf81 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1363,9 +1363,14 @@ tcltest: ./testfixture$(TEXE) testrunner: testfixture$(TEXE) ./testfixture$(TEXE) $(TOP)/test/testrunner.tcl -# Runs both fuzztest and testrunner, consecutively. +# This is the testing target preferred by the core SQLite developers. +# It runs tests under a standard configuration, regardless of how +# ./configure was run. The devs run "make devtest" prior to each +# check-in, at a minimum. Probably other tests too, but at least this +# one. # -devtest: srctree-check testfixture$(TEXE) fuzztest testrunner +devtest: srctree-check sourcetest + $(TCLSH_CMD) $(TOP)/test/testrunner.tcl mdevtest $(TSTRNNR_OPTS) mdevtest: srctree-check has_tclsh85 $(TCLSH_CMD) $(TOP)/test/testrunner.tcl mdevtest $(TSTRNNR_OPTS) @@ -1389,8 +1394,13 @@ releasetest: srctree-check has_tclsh85 quicktest: ./testfixture$(TEXE) ./testfixture$(TEXE) $(TOP)/test/extraquick.test $(TESTOPTS) -test: srctree-check sourcetest - $(TCLSH_CMD) $(TOP)/test/testrunner.tcl mdevtest $(TSTRNNR_OPTS) +# Try to run tests on whatever options are specified by the +# ./configure. The developers seldom use this target. Instead +# they use "make devtest" which runs tests on a standard set of +# options regardless of how SQLite is configured. This "test" +# target is provided for legacy only. +# +test: srctree-check fuzztest sourcetest $(TESTPROGS) tcltest # Run a test using valgrind. This can take a really long time # because valgrind is so much slower than a native machine. diff --git a/Makefile.msc b/Makefile.msc index e4420b1dea..64b63a704e 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2535,6 +2535,13 @@ queryplantest: testfixture.exe shell fuzztest: fuzzcheck.exe .\fuzzcheck.exe $(FUZZDATA) +# Legacy testing target for third-party integrators. The SQLite +# developers seldom use this target themselves. Instead +# they use "nmake /f Makefile.msc devtest" which runs tests on +# a standard set of options +# +test: $(TESTPROGS) sourcetest fuzztest tcltest + # Minimal testing that runs in less than 3 minutes (on a fast machine) # quicktest: testfixture.exe sourcetest @@ -2544,8 +2551,6 @@ quicktest: testfixture.exe sourcetest # This is the common case. Run many tests that do not take too long, # including fuzzcheck, sqlite3_analyzer, and sqldiff tests. # -test: srctree-check sourcetest - $(TCLSH_CMD) $(TOP)\test\testrunner.tcl mdevtest # The veryquick.test TCL tests. # @@ -2559,9 +2564,13 @@ tcltest: testfixture.exe testrunner: testfixture.exe .\testfixture.exe $(TOP)\test\testrunner.tcl -# Runs both fuzztest and testrunner, consecutively. +# This is the testing target preferred by the core SQLite developers. +# It runs tests under a standard configuration. The devs run +# "nmake /f Makefile.msc devtest" prior to each check-in, at a minimum. +# Probably other tests too, but at least this one. # -devtest: testfixture.exe fuzztest testrunner +devtest: srctree-check sourcetest + $(TCLSH_CMD) $(TOP)\test\testrunner.tcl mdevtest mdevtest: $(TCLSH_CMD) $(TOP)\test\testrunner.tcl mdevtest diff --git a/main.mk b/main.mk index ea6b83d059..7926dd0501 100644 --- a/main.mk +++ b/main.mk @@ -958,9 +958,14 @@ tcltest: ./testfixture$(EXE) testrunner: testfixture$(EXE) ./testfixture$(EXE) $(TOP)/test/testrunner.tcl -# Runs both fuzztest and testrunner, consecutively. +# This is the testing target preferred by the core SQLite developers. +# It runs tests under a standard configuration, regardless of how +# ./configure was run. The devs run "make devtest" prior to each +# check-in, at a minimum. Probably other tests too, but at least this +# one. # -devtest: testfixture$(EXE) fuzztest testrunner +devtest: srctree-check sourcetest + tclsh $(TOP)/test/testrunner.tcl mdevtest mdevtest: tclsh $(TOP)/test/testrunner.tcl mdevtest @@ -977,10 +982,13 @@ quicktest: ./testfixture$(EXE) srctree-check: $(TOP)/tool/srctree-check.tcl tclsh $(TOP)/tool/srctree-check.tcl -# The default test case. -test: srctree-check sourcetest - tclsh $(TOP)/test/testrunner.tcl mdevtest - +# Try to run tests on whatever options are specified by the +# environment variables. The SQLite developers seldom use this target. +# Instead# they use "make devtest" which runs tests on a standard set of +# options regardless of how SQLite is configured. This "test" +# target is provided for legacy only. +# +test: fuzztest sourcetest $(TESTPROGS) tcltest # Run a test using valgrind. This can take a really long time # because valgrind is so much slower than a native machine. diff --git a/manifest b/manifest index cf14534781..a66a4cd72d 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Minor\swording\schange\son\stestrunner\soutput. -D 2024-08-28T13:34:20.794 +C Maybe\s[7420b13238da4e6b]\swas\snot\ssuch\sa\sgood\sidea.\s\sRestore\s"make\stest"\sso\nthat\sit\sworks\sas\sbefore\s-\srunning\sa\ssingle-threaded\stest\sover\sthe\ssource\stree\nwith\soptions\sspecified\sby\s./configure\sand\ssimilar.\s\sInstead,\schange\sthe\n"make\sdevtest"\starget\sso\sthat\sruns\sthe\sautomated\smulti-threaded\stests\son\s\na\sstandard\sconfiguration. +D 2024-08-28T13:51:51.631 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in d51de7cfc0500e54b7a8961218ce9d7fa115610f5353f98fd9b407a1a69dfdcc +F Makefile.in 100a8ba2aee96203e57f0dfeb7c75befa7db0d9d17bdb5a7f814eaa60b974e16 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc fa422ec289537f61c5fe660e85ff4cab9389c3095a9071b5a0487aa521e657ba +F Makefile.msc 75946777a32696b6e894e686ba663f9dcdecea4730a827717e1b2be3b262234d F README.md 3d47ef5758e2de29d6f4e1aca714d51424baba86c8b561fef330f6ef2dc9282c F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -685,7 +685,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 7a70a20e224bf9cdf518cafe7738000ef7b2aec7b7de19d3e49700301d6ff130 +F main.mk 70366119ceca019c618ab9acb1b4e8cb1ab5d342a6c4884a9d514f264bc0f2ca F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7420b13238da4e6bfb1589eaf3cfd842fe3c4b0f3b6a3b49c24cd70589bf4809 -R 203b7adbe6856a41e47a582ad4a2ff84 +P 115e68597957a9ee80de7f554ee3768c992051687c8f07eaf3a9fcaab7efd44e +R 4897791cd3fac7134f1184e69605f11d U drh -Z ec83570cfd83b688d421f55742cc81eb +Z f3181ad81fdede715ff6716653ae5e00 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 507c4e1143..402ccd1247 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -115e68597957a9ee80de7f554ee3768c992051687c8f07eaf3a9fcaab7efd44e +dc9fee980d4f4b5a569628702e52cef9e5d8e6c69c2b84546dce47e3e514775e From 8db3fc548881727f5dac450e32222fe0ba116b17 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 13:55:46 +0000 Subject: [PATCH 0741/1030] Update the README.md file to recommend running "devtest" instead of "mdevtest". FossilOrigin-Name: eb016f66ea2c7ebacf8c57495843db3414602d062e4a430f2cc603c88b10c3f9 --- README.md | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4cddb47752..ca8f5a7bd2 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ For example: ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file - make mdevtest ;# Run development tests (requires tcl-dev) + make devtest ;# Run development tests (requires tcl-dev) make releasetest ;# Run full release tests (requires tcl-dev) make sqldiff ;# Builds the "sqldiff" command-line tool make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool (requires tcl-dev) @@ -156,7 +156,7 @@ Build using Makefile.msc. Example: nmake /f Makefile.msc sqlite3.exe nmake /f Makefile.msc sqlite3.c - nmake /f Makefile.msc mdevtest + nmake /f Makefile.msc devtest nmake /f Makefile.msc releasetest nmake /f Makefile.msc tclextension-install diff --git a/manifest b/manifest index a66a4cd72d..e4d95bda60 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Maybe\s[7420b13238da4e6b]\swas\snot\ssuch\sa\sgood\sidea.\s\sRestore\s"make\stest"\sso\nthat\sit\sworks\sas\sbefore\s-\srunning\sa\ssingle-threaded\stest\sover\sthe\ssource\stree\nwith\soptions\sspecified\sby\s./configure\sand\ssimilar.\s\sInstead,\schange\sthe\n"make\sdevtest"\starget\sso\sthat\sruns\sthe\sautomated\smulti-threaded\stests\son\s\na\sstandard\sconfiguration. -D 2024-08-28T13:51:51.631 +C Update\sthe\sREADME.md\sfile\sto\srecommend\srunning\s"devtest"\sinstead\sof\s"mdevtest". +D 2024-08-28T13:55:46.396 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in 100a8ba2aee96203e57f0dfeb7c75befa7db0d9d17bdb5a7f814eaa60b974e16 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 75946777a32696b6e894e686ba663f9dcdecea4730a827717e1b2be3b262234d -F README.md 3d47ef5758e2de29d6f4e1aca714d51424baba86c8b561fef330f6ef2dc9282c +F README.md 83335813752d41cd445c727b0918597d99e18e7de0e05024536f555a5f34cc56 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 115e68597957a9ee80de7f554ee3768c992051687c8f07eaf3a9fcaab7efd44e -R 4897791cd3fac7134f1184e69605f11d +P dc9fee980d4f4b5a569628702e52cef9e5d8e6c69c2b84546dce47e3e514775e +R 1aff88f40958f7cfa960a88f6231afc4 U drh -Z f3181ad81fdede715ff6716653ae5e00 +Z e14775f88501d5236fe68a1292e9a48b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 402ccd1247..fb81145c12 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dc9fee980d4f4b5a569628702e52cef9e5d8e6c69c2b84546dce47e3e514775e +eb016f66ea2c7ebacf8c57495843db3414602d062e4a430f2cc603c88b10c3f9 From 50ca8af6f2ff18c1e6e77cd5d0b8c60e26331b4c Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 28 Aug 2024 15:54:46 +0000 Subject: [PATCH 0742/1030] Fix a dropped error code in fts5. FossilOrigin-Name: df55502e4f412e5b1daccf82f11fa4eb932047d9972dcd16e36be00cf09f78e1 --- ext/fts5/fts5_main.c | 8 +++++--- ext/fts5/test/fts5faultI.test | 21 +++++++++++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 565b1ec305..03c1bb83fa 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2067,9 +2067,11 @@ static int fts5SyncMethod(sqlite3_vtab *pVtab){ ** Implementation of xBegin() method. */ static int fts5BeginMethod(sqlite3_vtab *pVtab){ - fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_BEGIN, 0); - fts5NewTransaction((Fts5FullTable*)pVtab); - return SQLITE_OK; + int rc = fts5NewTransaction((Fts5FullTable*)pVtab); + if( rc==SQLITE_OK ){ + fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_BEGIN, 0); + } + return rc; } /* diff --git a/ext/fts5/test/fts5faultI.test b/ext/fts5/test/fts5faultI.test index 63bfdd68ac..e74162ee35 100644 --- a/ext/fts5/test/fts5faultI.test +++ b/ext/fts5/test/fts5faultI.test @@ -256,6 +256,27 @@ do_faultsim_test 10 -faults oom* -prep { faultsim_test_result {0 hello} } +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 11.0 { + CREATE VIRTUAL TABLE f1 USING fts5(content); + CREATE TABLE g1(id, content); + INSERT INTO g1 VALUES(30000, 'a b c'); + INSERT INTO g1 VALUES(40000, 'd e f'); +} + +faultsim_save_and_close + +do_faultsim_test 11 -faults oom* -prep { + faultsim_restore_and_reopen +} -body { + execsql { + INSERT INTO f1(rowid, content) SELECT id, content FROM g1; + } +} -test { + faultsim_test_result {0 {}} +} finish_test diff --git a/manifest b/manifest index e4d95bda60..717ed83794 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sREADME.md\sfile\sto\srecommend\srunning\s"devtest"\sinstead\sof\s"mdevtest". -D 2024-08-28T13:55:46.396 +C Fix\sa\sdropped\serror\scode\sin\sfts5. +D 2024-08-28T15:54:46.677 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81c F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c eb9a0dda3bc6ef969a6be8d2746af56856e67251810ddba08622b45be8477abe -F ext/fts5/fts5_main.c bd41fc81751fc7cb666de7dee52cf9bb97c04ce06a8122e7e41bb7527bde54fc +F ext/fts5/fts5_main.c 1fddb53f495425d9314c74b30c5848a9dd254be0e5f445bfe38292d5ab21c288 F ext/fts5/fts5_storage.c 9a9b880be12901f1962ae2a5a7e1b74348b3099a1e728764e419f75d98e3e612 F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -178,7 +178,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5faultI.test e1e8a927122a8c3be8614a59717e838cad0505ba0a6f404983da8430e7aeb14d +F ext/fts5/test/fts5faultI.test ae4b83ac953200bd7b66d53038f7d6a4fc29cd64831b8e1795538babcea7c638 F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dc9fee980d4f4b5a569628702e52cef9e5d8e6c69c2b84546dce47e3e514775e -R 1aff88f40958f7cfa960a88f6231afc4 -U drh -Z e14775f88501d5236fe68a1292e9a48b +P eb016f66ea2c7ebacf8c57495843db3414602d062e4a430f2cc603c88b10c3f9 +R 78d4e3d98d20e086c6528776d2d5c051 +U dan +Z 1a3069fd43dc36b1a74436c6f020d339 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fb81145c12..183857bc4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb016f66ea2c7ebacf8c57495843db3414602d062e4a430f2cc603c88b10c3f9 +df55502e4f412e5b1daccf82f11fa4eb932047d9972dcd16e36be00cf09f78e1 From c1547d1f7acfdf7502f743529c6c9a1b7aefcf60 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 28 Aug 2024 19:13:16 +0000 Subject: [PATCH 0743/1030] Do not allow sqlite3_blob_open() to work on a any table that contains generated columns, even columns of the table which are not generated themselves, because such columns might be part of the expression of a STORED column. This restriction could be relaxed some, but that would be a lot of code for something that nobody ever uses. FossilOrigin-Name: 6e84947123339f0ea2b7dabc6134a621eed09317f81647f15870ed50a0f7d1bc --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeblob.c | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 717ed83794..d7b2d80921 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sdropped\serror\scode\sin\sfts5. -D 2024-08-28T15:54:46.677 +C Do\snot\sallow\ssqlite3_blob_open()\sto\swork\son\sa\sany\stable\sthat\scontains\ngenerated\scolumns,\seven\scolumns\sof\sthe\stable\swhich\sare\snot\sgenerated\sthemselves,\nbecause\ssuch\scolumns\smight\sbe\spart\sof\sthe\sexpression\sof\sa\sSTORED\scolumn.\nThis\srestriction\scould\sbe\srelaxed\ssome,\sbut\sthat\swould\sbe\sa\slot\sof\scode\nfor\ssomething\sthat\snobody\sever\suses. +D 2024-08-28T19:13:16.654 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -841,7 +841,7 @@ F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c F src/vdbeapi.c 80235ac380e9467fec1cb0883354d841f2a771976e766995f7e0c77f845406df F src/vdbeaux.c 25d685cafe119ff890c94345e884ea558a6b5d823bfa52ba708eb8ff3c70aa71 -F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5 +F src/vdbeblob.c 255be187436da38b01f276c02e6a08103489bbe2a7c6c21537b7aecbe0e1f797 F src/vdbemem.c 831a244831eaa45335f9ae276b50a7a82ee10d8c46c2c72492d4eb8c98d94d89 F src/vdbesort.c d0a3c7056c081703c8b6d91ad60f17da5e062a5c64bf568ed0fa1b5f4cae311f F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eb016f66ea2c7ebacf8c57495843db3414602d062e4a430f2cc603c88b10c3f9 -R 78d4e3d98d20e086c6528776d2d5c051 -U dan -Z 1a3069fd43dc36b1a74436c6f020d339 +P df55502e4f412e5b1daccf82f11fa4eb932047d9972dcd16e36be00cf09f78e1 +R e1af11959b2bec73273fe58897c14052 +U drh +Z 762ce3d8ddc624dbf22ecdf6a6f25bea # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 183857bc4a..aec5cf28d8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -df55502e4f412e5b1daccf82f11fa4eb932047d9972dcd16e36be00cf09f78e1 +6e84947123339f0ea2b7dabc6134a621eed09317f81647f15870ed50a0f7d1bc diff --git a/src/vdbeblob.c b/src/vdbeblob.c index 522447dbc1..6cb36da37a 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -167,6 +167,11 @@ int sqlite3_blob_open( pTab = 0; sqlite3ErrorMsg(&sParse, "cannot open table without rowid: %s", zTable); } + if( pTab && (pTab->tabFlags&TF_HasGenerated)!=0 ){ + pTab = 0; + sqlite3ErrorMsg(&sParse, "cannot open table with generated columns: %s", + zTable); + } #ifndef SQLITE_OMIT_VIEW if( pTab && IsView(pTab) ){ pTab = 0; From ccd34894e1a9e7895004867c3f3f4d0897b0dc30 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 29 Aug 2024 16:27:57 +0000 Subject: [PATCH 0744/1030] Fix a case where the BTCF_AtLast flag was being left set incorrectly. This was causing obscure window function queries to fail. FossilOrigin-Name: e042eb024738a83eed92cd2dfac3d2a50d2589715a3d81b1a494564dd7d8e7fa --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 2 +- test/windowE.test | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index d7b2d80921..c76c28e768 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sallow\ssqlite3_blob_open()\sto\swork\son\sa\sany\stable\sthat\scontains\ngenerated\scolumns,\seven\scolumns\sof\sthe\stable\swhich\sare\snot\sgenerated\sthemselves,\nbecause\ssuch\scolumns\smight\sbe\spart\sof\sthe\sexpression\sof\sa\sSTORED\scolumn.\nThis\srestriction\scould\sbe\srelaxed\ssome,\sbut\sthat\swould\sbe\sa\slot\sof\scode\nfor\ssomething\sthat\snobody\sever\suses. -D 2024-08-28T19:13:16.654 +C Fix\sa\scase\swhere\sthe\sBTCF_AtLast\sflag\swas\sbeing\sleft\sset\sincorrectly.\sThis\swas\scausing\sobscure\swindow\sfunction\squeries\sto\sfail. +D 2024-08-29T16:27:57.817 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -704,7 +704,7 @@ F src/auth.c 4c1ea890e0069ad73bead5d17a5b12c34cfa4f1a24175c8147ea439b64be271c F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 -F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333 +F src/btree.c 8c5592c618741c5fc9733e7efe3927bfafad3e999d15b0a0f3f1d3f3e17b919e F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c 3a1840d9d171ce2d24f4c1f7acda7266ab796c664290c1acba65ff98ce2bd01e @@ -2070,7 +2070,7 @@ F test/windowA.test 6d63dc1260daa17141a55007600581778523a8b420629f1282d2acfc36af F test/windowB.test aad7c31739999f68a98a813cfd78390918fc70f56d2d925317a1523cab548ecf F test/windowC.test 6fd75f5bb2f1343d34e470e36e68f0ff638d8a42f6aa7d99471261b31a0d42f2 F test/windowD.test 65cf5a765fb8072450e8a0de2979ce7f09a38d87724fe1280c6444073e3da49b -F test/windowE.test c98507e0b0d95980ad25845db758557757be2d7054198ccf522c7d277057a3df +F test/windowE.test d045a5fbaaf50ecac9483e1249dd317ba4f9d189c405a730ba6effdefb87b94f F test/windowerr.tcl f5acd6fbc210d7b5546c0e879d157888455cd4a17a1d3f28f07c1c8a387019e0 F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3cc1819b F test/windowfault.test 15094c1529424e62f798bc679e3fe9dfab6e8ba2f7dfe8c923b6248c31660a7c @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P df55502e4f412e5b1daccf82f11fa4eb932047d9972dcd16e36be00cf09f78e1 -R e1af11959b2bec73273fe58897c14052 -U drh -Z 762ce3d8ddc624dbf22ecdf6a6f25bea +P 6e84947123339f0ea2b7dabc6134a621eed09317f81647f15870ed50a0f7d1bc +R 842b0bd8861928ef2186779e003e3d2c +U dan +Z 8acde417655a8746f3e46d7a85e6d010 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aec5cf28d8..53067bc77e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6e84947123339f0ea2b7dabc6134a621eed09317f81647f15870ed50a0f7d1bc +e042eb024738a83eed92cd2dfac3d2a50d2589715a3d81b1a494564dd7d8e7fa diff --git a/src/btree.c b/src/btree.c index c752b0771b..f985ce3405 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5989,7 +5989,7 @@ int sqlite3BtreeIndexMoveto( && indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0 && pIdxKey->errCode==SQLITE_OK ){ - pCur->curFlags &= ~BTCF_ValidOvfl; + pCur->curFlags &= ~(BTCF_ValidOvfl|BTCF_AtLast); if( !pCur->pPage->isInit ){ return SQLITE_CORRUPT_BKPT; } diff --git a/test/windowE.test b/test/windowE.test index 9128468b3c..1cb67f56b0 100644 --- a/test/windowE.test +++ b/test/windowE.test @@ -73,6 +73,38 @@ do_catchsql_test 2.2 { WINDOW w1 AS (PARTITION BY x OVER w1); } {1 {near "OVER": syntax error}} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 3.0 { + BEGIN TRANSACTION; + CREATE TABLE t2(c1 INT, c2 REAL); + INSERT INTO t2 VALUES + (447,0.0), (448,0.0), (449,0.0), (452,0.0), (453,0.0), (454,0.0), (455,0.0), + (456,0.0), (459,0.0), (460,0.0), (462,0.0), (463,0.0), (466,0.0), (467,0.0), + (468,0.0), (469,0.0), (470,0.0), (473,0.0), (474,0.0), (475,0.0), (476,0.0), + (477,0.0), (480,0.0), (481,0.0), (482,0.0), (483,0.0), (484,0.0), (487,0.0), + (488,0.0), (489,0.0), (490,0.0), (491,0.0), (494,0.0), (495,0.0), (496,0.0), + (497,0.0), (498,0.0), (501,0.0), (502,0.0), (503,0.0), (504,0.0), (505,0.0), + (508,0.0), (509,0.0), (510,0.0), (511,0.0), (512,0.0), (515,0.0), (516,0.0), + (517,0.0), (518,0.0), (519,0.0), (522,0.0), (523,0.0), (524,0.0), (525,0.0), + (526,0.0), (529,0.0), (530,0.0), (531,0.0), (532,0.0), (533,0.0), (536,0.0), + (537,1.0), (538,0.0), (539,0.0), (540,0.0), (543,0.0), (544,0.0); + COMMIT; +} + +do_execsql_test 3.1 { + select c1, max(c2) over (order by c1 range 366.0 preceding) from t2; +} { + 447 0.0 448 0.0 449 0.0 452 0.0 453 0.0 454 0.0 455 0.0 456 0.0 459 0.0 + 460 0.0 462 0.0 463 0.0 466 0.0 467 0.0 468 0.0 469 0.0 470 0.0 473 0.0 + 474 0.0 475 0.0 476 0.0 477 0.0 480 0.0 481 0.0 482 0.0 483 0.0 484 0.0 + 487 0.0 488 0.0 489 0.0 490 0.0 491 0.0 494 0.0 495 0.0 496 0.0 497 0.0 + 498 0.0 501 0.0 502 0.0 503 0.0 504 0.0 505 0.0 508 0.0 509 0.0 510 0.0 + 511 0.0 512 0.0 515 0.0 516 0.0 517 0.0 518 0.0 519 0.0 522 0.0 523 0.0 + 524 0.0 525 0.0 526 0.0 529 0.0 530 0.0 531 0.0 532 0.0 533 0.0 536 0.0 + 537 1.0 538 1.0 539 1.0 540 1.0 543 1.0 544 1.0 +} + finish_test From 6a18c9e06a770357a74703f56dc26ab445bd7ccd Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 29 Aug 2024 18:32:56 +0000 Subject: [PATCH 0745/1030] All makefiles are responsive to OPTIONS=... command-line arguments, and add the RHS value of OPTIONS= to builds and to lemon and other build steps that might respond to -D or -U options. FossilOrigin-Name: 854b3776ee1fcaa5931e3a0ed104978ca350d218e553586d1c40c2420e1be498 --- Makefile.in | 8 ++++++-- Makefile.msc | 9 +++++++++ README.md | 12 ++++++++++++ main.mk | 4 ++++ manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Makefile.in b/Makefile.in index 6f41c9bf81..d230a40acb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -83,9 +83,13 @@ TEMP_STORE = -DSQLITE_TEMP_STORE=@TEMP_STORE@ # based on configuration. (-DSQLITE_OMIT*, -DSQLITE_ENABLE*). # The same set of OMIT and ENABLE flags should be passed to the # LEMON parser generator and the mkkeywordhash tool as well. -OPT_FEATURE_FLAGS = @OPT_FEATURE_FLAGS@ +# +# Add OPTIONS=... on the command line to append additional options +# to the OPT_FEATURE_FLAGS. +# +OPT_FEATURE_FLAGS = @OPT_FEATURE_FLAGS@ $(OPTIONS) -TCC += $(OPT_FEATURE_FLAGS) +TCC += $(OPT_FEATURE_FLAGS) # Add in any optional parameters specified on the make commane line # ie. make "OPTS=-DSQLITE_ENABLE_FOO=1 -DSQLITE_OMIT_FOO=1". diff --git a/Makefile.msc b/Makefile.msc index 64b63a704e..bf707edfd6 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -379,6 +379,7 @@ SQLITE_TCL_DEP = # the Windows platform. # !IFNDEF OPT_FEATURE_FLAGS +OPT_FEATURE_FLAGS = $(OPT_XTRA) !IF $(MINIMAL_AMALGAMATION)==0 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS5=1 @@ -392,6 +393,14 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_BYTECODE_VTAB=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1 !ENDIF +# Additional feature-options above and beyond what are normally used can be +# be added using OPTIONS=.... on the command-line. These values are +# appended to the OPT_FEATURE_FLAGS variable. +# +!IFDEF OPTIONS +OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) $(OPTIONS) +!ENDIF + # Should the session extension be enabled? If so, add compilation options # to enable it. # diff --git a/README.md b/README.md index ca8f5a7bd2..c208f11ea3 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,13 @@ Almost all makefile targets require a "tclsh" TCL interpreter version 8.6 or later. The targets marked with "(requires tcl-dev)" also require the TCL development libraries. +On "make" command-lines, one can add "OPTIONS=..." to specify additional +compile-time options over and above those set by ./configure. For example, +to compile with the SQLITE_OMIT_DEPRECATED compile-time option, one could say: + + ./configure --enable-all + make OPTIONS=-DSQLITE_OMIT_DEPRECATED sqlite3 + The configure script uses autoconf 2.61 and libtool. If the configure script does not work out for you, there is a generic makefile named "Makefile.linux-gcc" in the top directory of the source tree that you @@ -163,6 +170,11 @@ Build using Makefile.msc. Example: There are many other makefile targets. See comments in Makefile.msc for details. +As with the unix Makefile, the OPTIONS=... argument can be passed on the nmake +command-line to enable new compile-time options. For example: + + nmake /f Makefile.msc OPTIONS=-DSQLITE_OMIT_DEPRECATED sqlite3.exe + ## Source Tree Map * **src/** - This directory contains the primary source code for the diff --git a/main.mk b/main.mk index 7926dd0501..0c86c77181 100644 --- a/main.mk +++ b/main.mk @@ -42,6 +42,10 @@ # build the SQLite library and testing tools. ################################################################################ +# If OPTIONS... is specified on the command-line, append its value to OPTS +# +OPTS += $(OPTIONS) + # This is how we compile # TCCX = $(TCC) $(OPTS) -I. -I$(TOP)/src -I$(TOP) diff --git a/manifest b/manifest index c76c28e768..1a8810cd58 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Fix\sa\scase\swhere\sthe\sBTCF_AtLast\sflag\swas\sbeing\sleft\sset\sincorrectly.\sThis\swas\scausing\sobscure\swindow\sfunction\squeries\sto\sfail. -D 2024-08-29T16:27:57.817 +C All\smakefiles\sare\sresponsive\sto\sOPTIONS=...\scommand-line\sarguments,\sand\sadd\nthe\sRHS\svalue\sof\sOPTIONS=\sto\sbuilds\sand\sto\slemon\sand\sother\sbuild\ssteps\sthat\nmight\srespond\sto\s-D\sor\s-U\soptions. +D 2024-08-29T18:32:56.249 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 100a8ba2aee96203e57f0dfeb7c75befa7db0d9d17bdb5a7f814eaa60b974e16 +F Makefile.in f246a6d8a8a77c35d50d5494ee9bcd8fb6f90118eff46169427f9f404057b56e F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 75946777a32696b6e894e686ba663f9dcdecea4730a827717e1b2be3b262234d -F README.md 83335813752d41cd445c727b0918597d99e18e7de0e05024536f555a5f34cc56 +F Makefile.msc 47dfd26a401c5a33e237ecfe126c996977f34ac44e44a1a1ebf2204abb89d483 +F README.md 5b678e264236788390d11991f2c0052bd73f19790173883fc56d638bcb849154 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 @@ -685,7 +685,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 70366119ceca019c618ab9acb1b4e8cb1ab5d342a6c4884a9d514f264bc0f2ca +F main.mk 715c833f9733fd10b15d8773c59dd7535067d9d0f1a20073182069538f523bc7 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6e84947123339f0ea2b7dabc6134a621eed09317f81647f15870ed50a0f7d1bc -R 842b0bd8861928ef2186779e003e3d2c -U dan -Z 8acde417655a8746f3e46d7a85e6d010 +P e042eb024738a83eed92cd2dfac3d2a50d2589715a3d81b1a494564dd7d8e7fa +R f410afede94c7e996193f1f14e81b108 +U drh +Z d182fc30f4d0c921d3b91364d1eaed1e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 53067bc77e..21e3bcb9c3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e042eb024738a83eed92cd2dfac3d2a50d2589715a3d81b1a494564dd7d8e7fa +854b3776ee1fcaa5931e3a0ed104978ca350d218e553586d1c40c2420e1be498 From 494ba30c9b2f8c78ee6e25ca7bb8df8aa8acef87 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 29 Aug 2024 23:32:16 +0000 Subject: [PATCH 0746/1030] Sync the autoconf/Makefile.msc with the main ./Makefile.msc FossilOrigin-Name: 9de47c3611ca05e03a661807a06c6c5c0b5c6548ea7a8d73cb63832d2dff9d0e --- autoconf/Makefile.msc | 9 +++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index a4270fb2ae..f8a65e90cc 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -301,6 +301,7 @@ SQLITE3EXEPDB = /pdb:sqlite3sh.pdb # the Windows platform. # !IFNDEF OPT_FEATURE_FLAGS +OPT_FEATURE_FLAGS = $(OPT_XTRA) !IF $(MINIMAL_AMALGAMATION)==0 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS5=1 @@ -314,6 +315,14 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_BYTECODE_VTAB=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1 !ENDIF +# Additional feature-options above and beyond what are normally used can be +# be added using OPTIONS=.... on the command-line. These values are +# appended to the OPT_FEATURE_FLAGS variable. +# +!IFDEF OPTIONS +OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) $(OPTIONS) +!ENDIF + # Should the session extension be enabled? If so, add compilation options # to enable it. # diff --git a/manifest b/manifest index 1a8810cd58..7fda0fd8a5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C All\smakefiles\sare\sresponsive\sto\sOPTIONS=...\scommand-line\sarguments,\sand\sadd\nthe\sRHS\svalue\sof\sOPTIONS=\sto\sbuilds\sand\sto\slemon\sand\sother\sbuild\ssteps\sthat\nmight\srespond\sto\s-D\sor\s-U\soptions. -D 2024-08-29T18:32:56.249 +C Sync\sthe\sautoconf/Makefile.msc\swith\sthe\smain\s./Makefile.msc +D 2024-08-29T23:32:16.773 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -17,7 +17,7 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac -F autoconf/Makefile.msc 7ac6c331fc3b8aa57b6782db995b8c0e49230352decd4e2662fd07c06a9ed623 +F autoconf/Makefile.msc 2aced6442addab13ed115696eba28d9ed29caa3dd604a31392c2c7a5da301492 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 42cfd21d0b19dc7d5d85fb5c405c5f3c6a4c923021c39128f6ba685355d8fd56 F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e042eb024738a83eed92cd2dfac3d2a50d2589715a3d81b1a494564dd7d8e7fa -R f410afede94c7e996193f1f14e81b108 +P 854b3776ee1fcaa5931e3a0ed104978ca350d218e553586d1c40c2420e1be498 +R 2925596ad299ac71bd21ba5e19108337 U drh -Z d182fc30f4d0c921d3b91364d1eaed1e +Z afa5bee3192039d82a156b1fe821f6e2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 21e3bcb9c3..915840033d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -854b3776ee1fcaa5931e3a0ed104978ca350d218e553586d1c40c2420e1be498 +9de47c3611ca05e03a661807a06c6c5c0b5c6548ea7a8d73cb63832d2dff9d0e From 11397ce1048e3ae03b333d7b2428f3fe399ffd12 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 30 Aug 2024 01:11:19 +0000 Subject: [PATCH 0747/1030] In the testrunner.tcl status report, try to provide a rough estimate of the time remaining. FossilOrigin-Name: 90bc616d20e8c247691c45de2a28d41c1632b21152dc34253eefc179a90ab31f --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner.tcl | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 7fda0fd8a5..a27e71d2a3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Sync\sthe\sautoconf/Makefile.msc\swith\sthe\smain\s./Makefile.msc -D 2024-08-29T23:32:16.773 +C In\sthe\stestrunner.tcl\sstatus\sreport,\stry\sto\sprovide\sa\srough\sestimate\sof\nthe\stime\sremaining. +D 2024-08-30T01:11:19.367 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1714,7 +1714,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163 F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 2c203a2dd664298f239f0ec3ce22fbc65b5f021c1e09edbae8452af8a694e052 -F test/testrunner.tcl ff5f42f683a9c868fe01a855d81b9f08e1afb031edc5c340e5cf0fe5deaa0041 +F test/testrunner.tcl 662af46f1f0a41eb197f17583698853dd130ff3d47cf136dd519c3aecd9a9d7d F test/testrunner_data.tcl f1cbff53fe42087cac3d43ca02f9574bd212c842307442e2b6fff2183f5ccbfe F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 854b3776ee1fcaa5931e3a0ed104978ca350d218e553586d1c40c2420e1be498 -R 2925596ad299ac71bd21ba5e19108337 +P 9de47c3611ca05e03a661807a06c6c5c0b5c6548ea7a8d73cb63832d2dff9d0e +R c902a48c3428870b5b8747f7667d950b U drh -Z afa5bee3192039d82a156b1fe821f6e2 +Z 58e0a7f0d6d1a8c7bc1acf976af98f74 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 915840033d..c360e52b07 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9de47c3611ca05e03a661807a06c6c5c0b5c6548ea7a8d73cb63832d2dff9d0e +90bc616d20e8c247691c45de2a28d41c1632b21152dc34253eefc179a90ab31f diff --git a/test/testrunner.tcl b/test/testrunner.tcl index 58c718fe47..7ebb173c0c 100644 --- a/test/testrunner.tcl +++ b/test/testrunner.tcl @@ -476,13 +476,22 @@ proc show_status {db cls} { $ne errors, $nt tests"] set srcdir [file dirname [file dirname $TRG(info_script)]] - set nrun 0 - puts [format %-79s "Running: $S(running) (max: $nJob)"] + set line "Running: $S(running) (max: $nJob)" + if {$S(running)>0 && $fin>100 && $fin>0.05*$total} { + # Only estimate the time remaining after completing at least 100 + # jobs amounting to 10% of the total. Never estimate less than + # 2% of the total time used so far. + set tmleft [expr {($tm/$fin)*($total-$fin)}] + if {$tmleft<0.02*$tm} { + set tmleft [expr {$tm*0.02}] + } + append line " est time left [elapsetime $tmleft]" + } + puts [format %-79.79s $line] if {$S(running)>0} { $db eval { SELECT * FROM jobs WHERE state='running' ORDER BY starttime } job { - incr nrun display_job [array get job] $now } } From 28db1a68ba14eadc5452d0c59b03326190f2d022 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 30 Aug 2024 12:10:28 +0000 Subject: [PATCH 0748/1030] Improvements to "make clean" on unix. FossilOrigin-Name: a1d775f07528192b09566ff1546b067ffbee0db5812e424e6b7f3cc33a67dc83 --- Makefile.in | 46 ++++++++++++++--------------------------- main.mk | 57 +++++++++++++++++---------------------------------- manifest | 14 ++++++------- manifest.uuid | 2 +- 4 files changed, 42 insertions(+), 77 deletions(-) diff --git a/Makefile.in b/Makefile.in index d230a40acb..1be9ea8519 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1607,42 +1607,26 @@ tclextension-list: $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --info clean: - rm -f *.lo *.la *.o sqlite3$(TEXE) libsqlite3.la - rm -f sqlite3.h opcodes.* - rm -rf .libs .deps - rm -f lemon$(BEXE) lempar.c parse.* sqlite*.tar.gz - rm -f mkkeywordhash$(BEXE) keywordhash.h - rm -f mksourceid$(BEXE) - rm -f *.da *.bb *.bbg gmon.out - rm -rf tsrc .target_source + rm -f *.lo *.la *.o *.c *.h *.da *.bb *.bbg gmon.* *.rws sqlite3$(TEXE) + rm -rf .libs .deps tsrc libtool .target_source testrunner_* + rm -f lemon$(BEXE) sqlite*.tar.gz + rm -f mkkeywordhash$(BEXE) mksourceid$(BEXE) + rm -f parse.* fts5parse.* + rm -rf tsrc .target_source testrunner_bld_* testdir* rm -f tclsqlite3$(TEXE) - rm -f testfixture$(TEXE) test.db + rm -f $(TESTPROGS) testrunner.* rm -f LogEst$(TEXE) fts3view$(TEXE) rollback-test$(TEXE) showdb$(TEXE) rm -f showjournal$(TEXE) showstat4$(TEXE) showwal$(TEXE) speedtest1$(TEXE) - rm -f wordcount$(TEXE) changeset$(TEXE) - rm -f version-info$(TEXT) - rm -f sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def - rm -f sqlite3.c - rm -f sqlite3rc.h - rm -f shell.c sqlite3ext.h - rm -f sqlite3_analyzer$(TEXE) sqlite3_analyzer.c - rm -f sqlite-*-output.vsix - rm -f mptester mptester.exe - rm -f rbu rbu.exe - rm -f srcck1 srcck1.exe - rm -f fuzzershell fuzzershell.exe - rm -f fuzzcheck fuzzcheck.exe - rm -f sqldiff sqldiff.exe - rm -f dbhash dbhash.exe - rm -f fts5.* fts5parse.* - rm -f threadtest5 - rm -f src-verify - rm -f custom.rws - rm -f has_tclsh84 has_tclsh85 + rm -f wordcount$(TEXE) changeset$(TEXE) version-info$(TEXE) + rm -f *.dll *.lib *.exp *.def *.pc *.vsix + rm -f sqlite3_analyzer$(TEXE) + rm -f mptester$(TEXE) rbu$(TEXE) srcck1$(TEXE) + rm -f fuzzershell$(TEXE) fuzzcheck$(TEXE) sqldiff$(TEXE) dbhash$(TEXE) + rm -f threadtest5$(TEXE) + rm -f src-verify has_tclsh* distclean: clean - rm -f sqlite_cfg.h config.log config.status libtool Makefile sqlite3.pc \ - $(TESTPROGS) + rm -f config.log config.status Makefile # # Windows section diff --git a/main.mk b/main.mk index 0c86c77181..b1c86a1b76 100644 --- a/main.mk +++ b/main.mk @@ -1130,41 +1130,22 @@ install: sqlite3 libsqlite3.a sqlite3.h mv sqlite3.h /usr/include clean: - rm -f *.o sqlite3 sqlite3.exe libsqlite3.a sqlite3.h opcodes.* - rm -f lemon lemon.exe lempar.c parse.* sqlite*.tar.gz - rm -f mkkeywordhash mkkeywordhash.exe keywordhash.h - rm -f $(PUBLISH) - rm -f *.da *.bb *.bbg gmon.out - rm -rf tsrc target_source - rm -f testloadext.dll libtestloadext.so - rm -f amalgamation-testfixture amalgamation-testfixture.exe - rm -f fts3-testfixture fts3-testfixture.exe - rm -f testfixture testfixture.exe - rm -f threadtest3 threadtest3.exe - rm -f LogEst LogEst.exe - rm -f fts3view fts3view.exe - rm -f rollback-test rollback-test.exe - rm -f showdb showdb.exe - rm -f showjournal showjournal.exe - rm -f showstat4 showstat4.exe - rm -f showwal showwal.exe - rm -f changeset changeset.exe - rm -f speedtest1 speedtest1.exe - rm -f wordcount wordcount.exe - rm -f rbu rbu.exe - rm -f srcck1 srcck1.exe - rm -f sqlite3.c sqlite3-*.c fts?amal.c tclsqlite3.c - rm -f sqlite3rc.h - rm -f shell.c sqlite3ext.h - rm -f sqlite3_analyzer sqlite3_analyzer.exe sqlite3_analyzer.c - rm -f sqlite3_expert sqlite3_expert.exe - rm -f sqlite-*-output.vsix - rm -f mptester mptester.exe - rm -f fuzzershell fuzzershell.exe - rm -f fuzzcheck fuzzcheck.exe - rm -f sessionfuzz - rm -f sqldiff sqldiff.exe - rm -f fts5.* fts5parse.* - rm -f lsm.h lsm1.c - rm -f threadtest5 - rm -f src-verify + rm -f *.lo *.la *.o *.c *.h *.da *.bb *.bbg gmon.* *.rws sqlite3$(TEXE) + rm -rf .libs .deps tsrc libtool target_source testrunner_* + rm -f lemon$(BEXE) sqlite*.tar.gz + rm -f mkkeywordhash$(BEXE) mksourceid$(BEXE) + rm -f parse.* fts5parse.* + rm -rf tsrc .target_source testrunner_bld_* testdir* + rm -f tclsqlite3$(TEXE) + rm -f $(TESTPROGS) testrunner.* + rm -f LogEst$(TEXE) fts3view$(TEXE) rollback-test$(TEXE) showdb$(TEXE) + rm -f showjournal$(TEXE) showstat4$(TEXE) showwal$(TEXE) speedtest1$(TEXE) + rm -f wordcount$(TEXE) changeset$(TEXE) version-info$(TEXE) + rm -f *.dll *.lib *.exp *.def *.pc *.vsix + rm -f sqlite3_analyzer$(TEXE) + rm -f mptester$(TEXE) rbu$(TEXE) srcck1$(TEXE) + rm -f fuzzershell$(TEXE) fuzzcheck$(TEXE) sqldiff$(TEXE) dbhash$(TEXE) + rm -f threadtest5$(TEXE) + rm -f src-verify has_tclsh* + +distclean: clean diff --git a/manifest b/manifest index a27e71d2a3..8b0d758af3 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C In\sthe\stestrunner.tcl\sstatus\sreport,\stry\sto\sprovide\sa\srough\sestimate\sof\nthe\stime\sremaining. -D 2024-08-30T01:11:19.367 +C Improvements\sto\s"make\sclean"\son\sunix. +D 2024-08-30T12:10:28.233 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in f246a6d8a8a77c35d50d5494ee9bcd8fb6f90118eff46169427f9f404057b56e +F Makefile.in 294ce2b8b2736787ba138e22bee38f189b4543d8fdf0e9ac20227663a9b761ba F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 47dfd26a401c5a33e237ecfe126c996977f34ac44e44a1a1ebf2204abb89d483 F README.md 5b678e264236788390d11991f2c0052bd73f19790173883fc56d638bcb849154 @@ -685,7 +685,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 715c833f9733fd10b15d8773c59dd7535067d9d0f1a20073182069538f523bc7 +F main.mk 40f8cd07372d7eed2fe33403a42b82c3f5d2d46b59480444384326db70bb33f1 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9de47c3611ca05e03a661807a06c6c5c0b5c6548ea7a8d73cb63832d2dff9d0e -R c902a48c3428870b5b8747f7667d950b +P 90bc616d20e8c247691c45de2a28d41c1632b21152dc34253eefc179a90ab31f +R b70feb67084d54fbfa3c1f525e26b680 U drh -Z 58e0a7f0d6d1a8c7bc1acf976af98f74 +Z 53c8e68720f3dc2301be75bf174b1201 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c360e52b07..75f611deb5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -90bc616d20e8c247691c45de2a28d41c1632b21152dc34253eefc179a90ab31f +a1d775f07528192b09566ff1546b067ffbee0db5812e424e6b7f3cc33a67dc83 From c589d5ab06e5f98486bec6e2e402a46c456bc0ea Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 30 Aug 2024 16:24:49 +0000 Subject: [PATCH 0749/1030] Rework the tool/omittest.tcl script so that it works with the configure-generated Makefile, and requires no arguments. Update the configure-generated Makefile with a new "tidy" target which is like "clean" except that is preserves test logs. Use "make tidy" to force everything to be recompiled from scratch without destroying logs. FossilOrigin-Name: 99491df19d68df1f0515bd5ec9240ef3dd6e0fa38a6c837a38a16a873f8e2cbb --- Makefile.in | 27 ++- manifest | 14 +- manifest.uuid | 2 +- tool/omittest.tcl | 529 ++++++++++++++++------------------------------ 4 files changed, 209 insertions(+), 363 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1be9ea8519..188f94d701 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1606,15 +1606,21 @@ tclextension-uninstall: tclextension-list: $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --info -clean: - rm -f *.lo *.la *.o *.c *.h *.da *.bb *.bbg gmon.* *.rws sqlite3$(TEXE) - rm -rf .libs .deps tsrc libtool .target_source testrunner_* + +# Remove build products sufficient so that subsequent makes will recompile +# everything from scratch. Do not remove: +# +# * test results and test logs +# * output from ./configure +# +tidy: + rm -f *.lo *.la *.o *.c *.da *.bb *.bbg gmon.* *.rws sqlite3$(TEXE) + rm -f fts5.h keywordhash.h opcodes.h sqlite3.h sqlite3ext.h sqlite3session.h + rm -rf .libs .deps tsrc .target_source rm -f lemon$(BEXE) sqlite*.tar.gz rm -f mkkeywordhash$(BEXE) mksourceid$(BEXE) rm -f parse.* fts5parse.* - rm -rf tsrc .target_source testrunner_bld_* testdir* - rm -f tclsqlite3$(TEXE) - rm -f $(TESTPROGS) testrunner.* + rm -f tclsqlite3$(TEXE) $(TESTPROGS) rm -f LogEst$(TEXE) fts3view$(TEXE) rollback-test$(TEXE) showdb$(TEXE) rm -f showjournal$(TEXE) showstat4$(TEXE) showwal$(TEXE) speedtest1$(TEXE) rm -f wordcount$(TEXE) changeset$(TEXE) version-info$(TEXE) @@ -1625,8 +1631,15 @@ clean: rm -f threadtest5$(TEXE) rm -f src-verify has_tclsh* +# Removes build products and test logs. Retains ./configure outputs. +# +clean: tidy + rm -rf omittest* testrunner* testdir* + +# Clean up everything. No exceptions. +# distclean: clean - rm -f config.log config.status Makefile + rm -f sqlite_cfg.h config.log config.status Makefile $(LIBTOOL) # # Windows section diff --git a/manifest b/manifest index 8b0d758af3..f69905679b 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Improvements\sto\s"make\sclean"\son\sunix. -D 2024-08-30T12:10:28.233 +C Rework\sthe\stool/omittest.tcl\sscript\sso\sthat\sit\sworks\swith\sthe\nconfigure-generated\sMakefile,\sand\srequires\sno\sarguments.\nUpdate\sthe\sconfigure-generated\sMakefile\swith\sa\snew\s"tidy"\starget\swhich\nis\slike\s"clean"\sexcept\sthat\sis\spreserves\stest\slogs.\s\sUse\s"make\stidy"\sto\nforce\severything\sto\sbe\srecompiled\sfrom\sscratch\swithout\sdestroying\slogs. +D 2024-08-30T16:24:49.358 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 294ce2b8b2736787ba138e22bee38f189b4543d8fdf0e9ac20227663a9b761ba +F Makefile.in 77627cbeeffe23606da5663458c0f8bbb86d28e2aca270a5d9b0db8e39a54bb2 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 47dfd26a401c5a33e237ecfe126c996977f34ac44e44a1a1ebf2204abb89d483 F README.md 5b678e264236788390d11991f2c0052bd73f19790173883fc56d638bcb849154 @@ -2149,7 +2149,7 @@ F tool/mktoolzip.tcl c7a9b685f5131d755e7d941cec50cee7f34178b9e34c9a89811eeb08617 F tool/mkvsix.tcl 67b40996a50f985a573278eea32fc5a5eb6110bdf14d33f1d8086e48c69e540a F tool/offsets.c 8ed2b344d33f06e71366a9b93ccedaa38c096cc1dbd4c3c26ad08c6115285845 F tool/omittest-msvc.tcl d6b8f501ac1d7798c4126065030f89812379012cad98a1735d6d7221492abc08 -F tool/omittest.tcl e99c9fecc3f7a8ca2fa75d8ec8bdbb5acce33dc69f0c280aae53064693387f65 +F tool/omittest.tcl b8e9aae836d1659bf399f87d79f25c1b95b5db6f95338e94a0ff6ef73be6196e F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/replace.tcl 511c61acfe563dfb58675efb4628bb158a13d48ff8322123ac447e9d25a82d9a @@ -2211,8 +2211,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 90bc616d20e8c247691c45de2a28d41c1632b21152dc34253eefc179a90ab31f -R b70feb67084d54fbfa3c1f525e26b680 +P a1d775f07528192b09566ff1546b067ffbee0db5812e424e6b7f3cc33a67dc83 +R 2b82ff2fb12af001c7426b76114f4b10 U drh -Z 53c8e68720f3dc2301be75bf174b1201 +Z 20d7de6f9c6ec3afe4ba157bc5616eaa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 75f611deb5..a433ecb2c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a1d775f07528192b09566ff1546b067ffbee0db5812e424e6b7f3cc33a67dc83 +99491df19d68df1f0515bd5ec9240ef3dd6e0fa38a6c837a38a16a873f8e2cbb diff --git a/tool/omittest.tcl b/tool/omittest.tcl index 8862c685f8..6dc62d0884 100644 --- a/tool/omittest.tcl +++ b/tool/omittest.tcl @@ -1,370 +1,203 @@ -# Documentation for this script. This may be output to stderr +#!/usr/bin/tclsh +# +# Documentation for this script. This may be output to # if the script is invoked incorrectly. +# set ::USAGE_MESSAGE { This Tcl script is used to test the various compile time options -available for omitting code (the SQLITE_OMIT_xxx options). It -should be invoked as follows: - - -