From 87ac2b043a663720c84d0b7d923b7d9dca5391c1 Mon Sep 17 00:00:00 2001
From: stephan
Date: Sat, 2 Sep 2023 05:37:58 +0000
Subject: [PATCH 001/212] 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 002/212] 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 003/212] 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 004/212] 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 598328209f421d48e98115dd6816da5114403616 Mon Sep 17 00:00:00 2001
From: stephan
Date: Thu, 11 Jan 2024 12:31:58 +0000
Subject: [PATCH 005/212] 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 006/212] 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 007/212] 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 008/212] 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 f352e0a9cf3697c2bdb790705998121aa517fe36 Mon Sep 17 00:00:00 2001
From: drh <>
Date: Mon, 15 Jan 2024 17:01:13 +0000
Subject: [PATCH 009/212] Version 3.45.0
FossilOrigin-Name: 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d
---
manifest | 12 +++++++-----
manifest.uuid | 2 +-
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/manifest b/manifest
index 8c862e2c0c..c1d98bbfbd 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Have\sthe\sshell\stool\sautomatically\senable\sSQLITE_CONFIG_DQS_DDL\swhen\sexecuting\sa\s".dump"\sscript\sagainst\san\sempty\sdb.
-D 2024-01-12T11:44:49.861
+C Version\s3.45.0
+D 2024-01-15T17:01:13.164
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -2157,8 +2157,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b0eb6d3628c1f70399a22d9fd3b79a796bc343adfeba50515440db609565961a
+P f47a5f4e0ce078e6cc1183e6cbb3c4013af379b496efae94863a42e5c39928ed
R ab5a4296dc153e787688d4ab18626d94
-U dan
-Z 9795dc3f51dc5999429a02089c48c9c6
+T +sym-release *
+T +sym-version-3.45.0 *
+U drh
+Z fb1ecde834264212c972e5b30790a005
# Remove this line to create a well-formed Fossil manifest.
diff --git a/manifest.uuid b/manifest.uuid
index eaba41901e..b0eef83f1a 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-f47a5f4e0ce078e6cc1183e6cbb3c4013af379b496efae94863a42e5c39928ed
\ No newline at end of file
+1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d
\ 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 010/212] 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 011/212] 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 @@ json_parse_restart:
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 012/212] Ensure that the xIntegrity methods of fts3 and fts5
work on read-only databases.
FossilOrigin-Name: b855886c4ccce0745af6957943e77be18949722f09821688725d546d3d79b4fb
---
ext/fts3/fts3.c | 32 +++++++++++---------------------
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, 77 insertions(+), 48 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;
+ int bOk = 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 ){
+ 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 013/212] 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 014/212] 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 015/212] 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 016/212] 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 017/212] 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 018/212] 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 019/212] 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 020/212] 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 021/212] 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 022/212] 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 023/212] 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 024/212] 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 025/212] 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 | 11 +++++++++--
4 files changed, 22 insertions(+), 15 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.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 2.1 1_000 integer 1000
-
+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 026/212] 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 027/212] 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 dayOfWeek(DateTime *pDate){
- int w;
+static int daysAfterMonday(DateTime *pDate){
assert( pDate->validJD );
- w = ((pDate->iJD+129600000)/86400000) % 7;
- if( w==0 ) w = 7;
- return w;
+ 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 daysAfterSunday(DateTime *pDate){
+ assert( pDate->validJD );
+ 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 028/212] 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 029/212] 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 030/212] 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 031/212] 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 032/212] 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 033/212] 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 034/212] 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 035/212] 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 @@ jsonInsertIntoBlob_patherror:
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 @@ rebuild_from_cache:
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( jsonArgIsJsonb(pArg,p) ){
+ if( (flgs & JSON_EDITABLE)!=0 && jsonBlobMakeEditable(p, 0)==0 ){
+ goto json_pfa_oom;
+ }
+ return p;
}
- 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;
- }
- 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 036/212] 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 037/212] 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 038/212] 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 039/212] Allow underscores to occur in hex literals.
FossilOrigin-Name: 81a56229460cc5b6acfd3c3729fcf89ea3cccb546ca2b4f4035b140c60911e18
---
manifest | 20 +++++-----
manifest.uuid | 2 +-
src/tokenize.c | 96 ++++++++++++++++++++++++++--------------------
src/util.c | 10 +++--
test/literal2.tcl | 8 ++++
test/literal2.test | 18 +++++++++
test/misc1.test | 2 +-
7 files changed, 98 insertions(+), 58 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,58 +437,70 @@ 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;
+ for(i=3; 1; i++){
+ if( sqlite3Isxdigit(z[i])==0 ){
+ if( z[i]==SQLITE_DIGIT_SEPARATOR
+ && sqlite3Isxdigit(z[i-1])
+ && sqlite3Isxdigit(z[i+1])
+ ){
+ *tokenType = TK_QNUMBER;
+ }else{
+ break;
+ }
+ }
+ }
+ }else
+#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 ){
- if( z[i]==SQLITE_DIGIT_SEPARATOR
- && sqlite3Isdigit(z[i-1])
- && sqlite3Isdigit(z[i+1])
- ){
- *tokenType = TK_QNUMBER;
- }else{
- break;
+ 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;
+ 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 040/212] 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 | 15 ++++++++++-----
test/literal2.test | 26 ++++++++++++++++++++++----
5 files changed, 42 insertions(+), 19 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 }
+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_ }
-errorsql_test 3.2 { SELECT 0xFF__EF }
-# errorsql_test 3.3 { SELECT 0x_FFEF }
-errorsql_test 3.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 041/212] 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 042/212] 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 043/212] 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 044/212] 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 @@ rebuild_from_cache:
}
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 045/212] 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 046/212] 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 047/212] 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 048/212] 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 049/212] 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 050/212] 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 @@ other than that, the order of directives in Lemon is arbitrary.
%endif
%extra_argument
%fallback
+%free
%if
%ifdef
%ifndef
@@ -693,6 +694,7 @@ other than that, the order of directives in Lemon is arbitrary.
%parse_accept
%parse_failure
%right
+%realloc
%stack_overflow
%stack_size
%start_symbol
@@ -1200,6 +1202,21 @@ match any input token.
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 @@ to begin parsing a new file. This is what will happen at the very
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 051/212] 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 052/212] 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 053/212] 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 054/212] 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 055/212] 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 056/212] 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 057/212] 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 058/212] 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 059/212] 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 060/212] 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 061/212] 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 062/212] 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 063/212] 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 064/212] 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 065/212] 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 066/212] 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 @@ json_parse_restart:
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 067/212] 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 @@ json_parse_restart:
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 068/212] 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 069/212] 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 070/212] 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 071/212] 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 072/212] 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 073/212] 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 074/212] 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 075/212] 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 076/212] 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 077/212] 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 078/212] 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 079/212] 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 080/212] 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 081/212] 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 082/212] 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 083/212] 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 084/212] 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 085/212] 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 086/212] 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 087/212] 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 @@ rebuild_from_cache:
}
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 088/212] 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 @@ json_parse_restart:
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 089/212] 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 090/212] 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 091/212] 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 092/212] 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 093/212] 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 094/212] 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 @@ select_end:
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 095/212] 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 096/212] 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 @@ constraint:
*/
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 097/212] 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 098/212] 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 099/212] 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 100/212] 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 @@ constraint:
*/
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 101/212] 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 102/212] 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 103/212] 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 104/212] 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 105/212] 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 106/212] Retweak last check-in to retain compile-time checking
of xprintf() arguments.
FossilOrigin-Name: 670174916c660b24ba70e96a42984eb65ee52da50e9828bdeca4c9ff4bf92e20
---
manifest | 14 +++++++-------
manifest.uuid | 2 +-
src/shell.c.in | 21 +++++++++++++++------
3 files changed, 23 insertions(+), 14 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
-# define oputz(z) fputs(z,stdout)
-# define oputf printf
-# define eputz(z) fputs(z,stderr)
+/* 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 eputz(z) fputs(z,stderr)
+# 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 107/212] 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 108/212] 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 109/212] 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 110/212] 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 111/212] 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 112/212] 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 113/212] 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 114/212] 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 115/212] 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 | 85 ++++++++++++++++++++++++++++++++-------------------
3 files changed, 61 insertions(+), 38 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;
- /* 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
- ){
- continue;
- }
-
- /* Hold a write transaction open for efficiency */
- if( !once || 1 ){
- sqlite3BeginWriteOperation(pParse, 0, iDb);
- once = 1;
- }
-
- /* Reanalyze if the table is 10 times larger or smaller than
- ** the last analysis */
+ /* 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 ){
+ 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 ){
+ /* 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;
+ }
+
+ nCheck++;
+ if( nCheck==2 ){
+ /* If ANALYZE might be invoked two or more times, hold a write
+ ** transaction for efficiency */
+ sqlite3BeginWriteOperation(pParse, 0, iDb);
+ }
+
+ /* Reanalyze if the table is 10 times larger or smaller than
+ ** 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 116/212] 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 117/212] 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 118/212] 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 119/212] 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 120/212] 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 121/212] 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 122/212] 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 123/212] 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 124/212] 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 125/212] 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 126/212] 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 127/212] 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 128/212] 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 | 220 ++++++++++++++++++++++++++++++++-------
manifest | 12 +--
manifest.uuid | 2 +-
3 files changed, 190 insertions(+), 44 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,20 +95,119 @@ static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){
}
}
-static char *intckStrdup(sqlite3_intck *p, const char *zIn){
- char *zOut = 0;
+/*
+** 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 ){
- int nIn = strlen(zIn);
- zOut = sqlite3_malloc(nIn+1);
- if( zOut==0 ){
+ pRet = sqlite3_malloc64(nByte);
+ if( pRet==0 ){
p->rc = SQLITE_NOMEM;
- }else{
- memcpy(zOut, zIn, nIn+1);
}
}
+ 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 ){
+ if( zRet==0 ){
+ p->rc = SQLITE_NOMEM;
+ }
+ }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;
+ }
+}
+
+/*
+** 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){
sqlite3_stmt *pStmt = 0;
char *zPrev = p->zObj;
@@ -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 129/212] 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 130/212] 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 131/212] 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 132/212] Simplify the way the restart key is saved internally
by the intck extension.
FossilOrigin-Name: 0e39962baae8a82a3021077676b792ac30c79426bcd8c075b5e92bee55e8c3a5
---
ext/intck/sqlite3intck.c | 101 +++++++++++++--------------------------
manifest | 12 ++---
manifest.uuid | 2 +-
3 files changed, 41 insertions(+), 74 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;
- for(ii=0; iinKeyVal; ii++){
- zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep);
- zSep = " || ', ' || ";
- }
- zSql = intckMprintf(p, "%z || ')'", zSql);
+ assert( p->pCheck );
+ assert( p->zKey==0 );
- 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);
+
+ for(ii=0; iinKeyVal; ii++){
+ zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep);
+ zSep = " || ', ' || ";
}
- return zRet;
+ 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, sqlite3_column_value(p->pCheck, ii+1));
+ }
+ if( SQLITE_ROW==sqlite3_step(pStmt) ){
+ p->zKey = intckStrdup(p, (const char*)sqlite3_column_text(pStmt, 0));
+ }
+ intckFinalize(p, pStmt);
+ }
+ 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 133/212] 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 134/212] 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.
+** 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 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.
-*/
-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 135/212] 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 136/212] 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 @@ json_parse_restart:
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 137/212] 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 138/212] 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 139/212] 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 140/212] 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}
}
+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 141/212] 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 142/212] 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 143/212] 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$$Xm7ezkV=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<^zpxR(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-5q9uByDSD