From 290caec8e32bc00e9d5bc80c8b08736e820f0ea7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 14 Jan 2025 16:10:13 +0000 Subject: [PATCH 001/115] Trying to remove a warning from some compiler that I do not have access to. FossilOrigin-Name: bc6de90c7049dd429a82d32b186a838f4a21aa7b8a83418eaf0416d19771b41e --- ext/misc/base64.c | 2 +- manifest | 15 ++++++--------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ext/misc/base64.c b/ext/misc/base64.c index b8147707f9..17b3bbfc71 100644 --- a/ext/misc/base64.c +++ b/ext/misc/base64.c @@ -198,7 +198,7 @@ static u8* fromBase64( char *pIn, int ncIn, u8 *pOut ){ deliberate_fall_through; /* FALLTHRU */ case 1: pOut[0] = (qv>>16) & 0xff; - deliberate_fall_through; /* FALLTHRU */ + break; } pOut += nbo; } diff --git a/manifest b/manifest index 809b43bc20..bee17b3109 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.48.0 -D 2025-01-14T11:05:00.186 +C Trying\sto\sremove\sa\swarning\sfrom\ssome\scompiler\sthat\sI\sdo\snot\shave\saccess\sto. +D 2025-01-14T16:10:13.035 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -400,7 +400,7 @@ F ext/misc/README.md d6dd0fe1d8af77040216798a6a2b0c46c73054d2f0ea544fbbcdccf6f23 F ext/misc/amatch.c 5001711cbecdd57b288cb613386789f3034e5beb58fbe0c79f2b3d643ffd4e03 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb F ext/misc/appendvfs.c 9642c7a194a2a25dca7ad3e36af24a0a46d7702168c4ad7e59c9f9b0e16a3824 -F ext/misc/base64.c 95abb0547cb1799d9851f3357c8d7fc3c09a95c63c8772aa3acd5f65f12050f6 +F ext/misc/base64.c 73c31eb325c71bae2e27276565e3f674fc095d8b0d7a651becb3b241a4d2fa57 F ext/misc/base85.c a70c885c5c9350261ea6e7b166038eab21a09cf4fceae856ce41fae9c2213b60 F ext/misc/basexx.c 89ad6b76558efbceb627afd5e2ef1d84b2e96d9aaf9b7ecb20e3d00b51be6fcf F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0edb2a @@ -2205,11 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 315079b150b47e013e2cde4985bc39d24e0f6f6c6e60f9383fb8ea4ea897c67a -R 0ed0cfcc7f2bc831da5d62a3490571ed -T +sym-major-relase * -T +sym-relase * -T +sym-version-3.48.0 * +P d2fe6b05f38d9d7cd78c5d252e99ac59f1aea071d669830c1ffe4e8966e84010 +R aff0689df06812b91685e37aa2e42245 U drh -Z cc77aac977f98c5521d75f4212754ff8 +Z 834ff516b013f84167d7c9e70325f453 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 582262f689..747a460e8b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2fe6b05f38d9d7cd78c5d252e99ac59f1aea071d669830c1ffe4e8966e84010 +bc6de90c7049dd429a82d32b186a838f4a21aa7b8a83418eaf0416d19771b41e From 0609cf85fd252bd8529e5648095529a4a4e954c2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 14 Jan 2025 20:47:23 +0000 Subject: [PATCH 002/115] Change the version number to 3.49.0 to begin the next development cycle. Any patches to 3.48.0 will go on a branch. FossilOrigin-Name: 8165a3d3a40c5b43275fb4b1cdf57c44a57cd56c514bd2a550deac26a14795eb --- VERSION | 2 +- autoconf/tea/configure.ac | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 7dd5eda815..549b777ead 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.48.0 +3.49.0 diff --git a/autoconf/tea/configure.ac b/autoconf/tea/configure.ac index 8abf8ad02f..e653798fc5 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.48.0]) +AC_INIT([sqlite],[3.49.0]) #-------------------------------------------------------------------- # Call TEA_INIT as the first TEA_ macro to set up initial vars. diff --git a/manifest b/manifest index bee17b3109..16e144446c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Trying\sto\sremove\sa\swarning\sfrom\ssome\scompiler\sthat\sI\sdo\snot\shave\saccess\sto. -D 2025-01-14T16:10:13.035 +C Change\sthe\sversion\snumber\sto\s3.49.0\sto\sbegin\sthe\snext\sdevelopment\ncycle.\s\sAny\spatches\sto\s3.48.0\swill\sgo\son\sa\sbranch. +D 2025-01-14T20:47:23.128 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -7,7 +7,7 @@ F Makefile.in ad349acf91b3569033439fe498fa197aa530cafaa01362eb7daad2f84e43d265 F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0 F Makefile.msc 39785ec45f9ae0311e49094eff2ee079562246fed6be3b9f632a99d4df20056a F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 -F VERSION 8dc0c3df15fd5ff0622f88fc483533fce990b1cbb2f5fb9fdfb4dbd71eef2889 +F VERSION 01f7606130e48fd58a74d1e45e565f2674819d6eadbc219d328d94bb3362b818 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 F art/icon-80x90.gif 65509ce3e5f86a9cd64fe7fca2d23954199f31fe44c1e09e208c80fb83d87031 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 @@ -25,7 +25,7 @@ F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d F autoconf/tea/Makefile.in ba0556fee8da09c066bad85a4457904e46ee2c2eabaa309c0e83a78f2f151a8e F autoconf/tea/README.txt 61e62e519579e4a112791354d6d440f8b51ea6db3b0bab58d59f29df42d2dfe3 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 -F autoconf/tea/configure.ac ff2d745f88e493080810b67958d88b4f7a7d79f19e2ee8e7f72ffd6fc04eabc7 +F autoconf/tea/configure.ac d22326594f005a493a7857cb4ad2496b91480101be731d7f0541bb8d7eba22a2 F autoconf/tea/doc/sqlite3.n e1fe45d4f5286ee3d0ccc877aca2a0def488e9bb F autoconf/tea/license.terms 13bd403c9610fd2b76ece0ab50c4c5eda933d523 F autoconf/tea/pkgIndex.tcl.in 55aec3c6d7e9a1de9b8d2fdc9c27fd055da3ac3a51b572195e2ae7300bcfd3a2 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d2fe6b05f38d9d7cd78c5d252e99ac59f1aea071d669830c1ffe4e8966e84010 -R aff0689df06812b91685e37aa2e42245 +P bc6de90c7049dd429a82d32b186a838f4a21aa7b8a83418eaf0416d19771b41e +R 7be4e73ee614c5955da7d841289f67c4 U drh -Z 834ff516b013f84167d7c9e70325f453 +Z 4394aec1aff44c176b2cf58b3618b986 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 747a460e8b..6b616acf3d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc6de90c7049dd429a82d32b186a838f4a21aa7b8a83418eaf0416d19771b41e +8165a3d3a40c5b43275fb4b1cdf57c44a57cd56c514bd2a550deac26a14795eb From 4ea86ac0e398d20cefa211555a604fcdc55dc45e Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 15 Jan 2025 14:28:56 +0000 Subject: [PATCH 003/115] Disable the C-style comment stripper in the JS dist build, as explained in [forum:529c20d344|forum post 529c20d344]. FossilOrigin-Name: a9475e7614f8e44252abf273d0e0522c247df12624e40108ce98ad4aaf320f2d --- ext/wasm/dist.make | 13 +++++++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ext/wasm/dist.make b/ext/wasm/dist.make index e820e066d4..10c64e16d6 100644 --- a/ext/wasm/dist.make +++ b/ext/wasm/dist.make @@ -97,6 +97,15 @@ STRIP_K2.js := $(sqlite3.js) $(sqlite3.mjs) \ # Note that we require $(bin.version-info) in order to figure out the # dist file's name, so cannot (without a recursive make) have the # target name equal to the archive name. +# +# 2025-01-15: Emsdk 4.0.0 introduces, in its generated code, a regex +# which contains the pattern /*. That, of course, confuses any C-style +# comment-stripper which is not specifically JS-aware and smart enough +# to know that it's in a regex or string literal. Because of that, +# comment-stripping is currently disabled, which means the builds will +# be significantly larger than before. +apply_comment_stripper := false +# ^^^ shell command true or false dist: \ $(bin.stripccomments) $(bin.version-info) \ $(dist.build) $(STRIP_K1.js) $(STRIP_K2.js) \ @@ -109,8 +118,8 @@ dist: \ @cp -p README-dist.txt $(dist-dir.top)/README.txt @cp -p index-dist.html $(dist-dir.top)/index.html @cp -p $(dist.jswasm.extras) $(dist-dir.jswasm) - @$(foreach JS,$(STRIP_K1.js),$(call DIST_STRIP_COMMENTS,$(JS),-k)) - @$(foreach JS,$(STRIP_K2.js),$(call DIST_STRIP_COMMENTS,$(JS),-k -k)) + @if $(apply_comment_stripper); then $(foreach JS,$(STRIP_K1.js),$(call DIST_STRIP_COMMENTS,$(JS),-k)) fi + @if $(apply_comment_stripper); then $(foreach JS,$(STRIP_K2.js),$(call DIST_STRIP_COMMENTS,$(JS),-k -k)) fi @cp -p $(dist.common.extras) $(dist-dir.common) @set -e; \ vnum=$$($(bin.version-info) --download-version); \ diff --git a/manifest b/manifest index 16e144446c..89626587fd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sversion\snumber\sto\s3.49.0\sto\sbegin\sthe\snext\sdevelopment\ncycle.\s\sAny\spatches\sto\s3.48.0\swill\sgo\son\sa\sbranch. -D 2025-01-14T20:47:23.128 +C Disable\sthe\sC-style\scomment\sstripper\sin\sthe\sJS\sdist\sbuild,\sas\sexplained\sin\s[forum:529c20d344|forum\spost\s529c20d344]. +D 2025-01-15T14:28:56.143 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -668,7 +668,7 @@ F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a F ext/wasm/demo-worker1-promiser.c-pp.js fcc628cb42fcfaf07d250477801de1e6deb1e319d003976612a0db8d76b9fccc F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef -F ext/wasm/dist.make 653e212c1e84aa3be168d62a10616ccea45ee9585b0192745d2706707a5248ce +F ext/wasm/dist.make a5bed3b6e6d6a644e1cd416f18b799b956765333130f948d1065872a7f1ce199 F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle.make d4969f0322a582c57a22ce3541f10a5b09a609d14eab32891f613f43b3c14d8b F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bc6de90c7049dd429a82d32b186a838f4a21aa7b8a83418eaf0416d19771b41e -R 7be4e73ee614c5955da7d841289f67c4 -U drh -Z 4394aec1aff44c176b2cf58b3618b986 +P 8165a3d3a40c5b43275fb4b1cdf57c44a57cd56c514bd2a550deac26a14795eb +R a0a8bbc53f3c66c17e57addc303a0fb5 +U stephan +Z 1a15ad455819e4eca33993ca2fa2e2ed # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6b616acf3d..4894553b8b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8165a3d3a40c5b43275fb4b1cdf57c44a57cd56c514bd2a550deac26a14795eb +a9475e7614f8e44252abf273d0e0522c247df12624e40108ce98ad4aaf320f2d From 73d9eb1bb3fca5e9a1bdc83c2d827cb815bc1278 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 15 Jan 2025 15:27:02 +0000 Subject: [PATCH 004/115] Fix a typo in a wasm makefile var name, noting that this doesn't actually fix anything because the var in question is not used when building 'clean' or 'distclean'. FossilOrigin-Name: 7cfc75a625095e41c3e952d4a209fdbb344df0d3dd9b0103e9e6a986dfe53c89 --- 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 19ad759905..6f226fbb4f 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -185,7 +185,7 @@ endif # Find wasm-strip, which we need for release builds (see below for # why) but not strictly for non-release builds. ifeq (1,$(MAKING_CLEAN)) - wasm-strip-bin := irrelevant + wasm-strip.bin := irrelevant else wasm-strip.bin ?= $(shell which wasm-strip 2>/dev/null) ifeq (,$(wasm-strip.bin)) diff --git a/manifest b/manifest index 89626587fd..5a2e1a4442 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\sC-style\scomment\sstripper\sin\sthe\sJS\sdist\sbuild,\sas\sexplained\sin\s[forum:529c20d344|forum\spost\s529c20d344]. -D 2025-01-15T14:28:56.143 +C Fix\sa\stypo\sin\sa\swasm\smakefile\svar\sname,\snoting\sthat\sthis\sdoesn't\sactually\sfix\sanything\sbecause\sthe\svar\sin\squestion\sis\snot\sused\swhen\sbuilding\s'clean'\sor\s'distclean'. +D 2025-01-15T15:27:02.044 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -618,7 +618,7 @@ F ext/session/sqlite3session.c d6f5e3e83b9b0bbc4a8db4837284f0ecc6af5321d4c8e7136 F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 311aa0d5edc7006409962cc77cc26560d92f9be69c2c4302e8bbc68189fd02db +F ext/wasm/GNUmakefile 6b42d6de2316ae01a96d1b850932fcab0f2938affc27b48495776903f544a488 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8165a3d3a40c5b43275fb4b1cdf57c44a57cd56c514bd2a550deac26a14795eb -R a0a8bbc53f3c66c17e57addc303a0fb5 +P a9475e7614f8e44252abf273d0e0522c247df12624e40108ce98ad4aaf320f2d +R 1edfbe182664cb23963ce1c643c56290 U stephan -Z 1a15ad455819e4eca33993ca2fa2e2ed +Z 7b3481ce418acfe304612eaa50fc5d07 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4894553b8b..2e33fd143c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a9475e7614f8e44252abf273d0e0522c247df12624e40108ce98ad4aaf320f2d +7cfc75a625095e41c3e952d4a209fdbb344df0d3dd9b0103e9e6a986dfe53c89 From 874b5e9fbb22231b283ec5a56921fa9b418c5c8d Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 15 Jan 2025 19:30:10 +0000 Subject: [PATCH 005/115] Variable names and conditional logic simplified in where.c. These changes are cosmetic only and do not affect the resuling machine code. FossilOrigin-Name: dbc2d6a244fdafd208239894dbdd8f139db6ca20dd8f1ed00d87028e0cb60570 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 51 ++++++++++++++++++++++++-------------------------- src/whereInt.h | 2 +- 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/manifest b/manifest index 5a2e1a4442..c560adf18a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sa\swasm\smakefile\svar\sname,\snoting\sthat\sthis\sdoesn't\sactually\sfix\sanything\sbecause\sthe\svar\sin\squestion\sis\snot\sused\swhen\sbuilding\s'clean'\sor\s'distclean'. -D 2025-01-15T15:27:02.044 +C Variable\snames\sand\sconditional\slogic\ssimplified\sin\swhere.c.\s\sThese\nchanges\sare\scosmetic\sonly\sand\sdo\snot\saffect\sthe\sresuling\smachine\scode. +D 2025-01-15T19:30:10.144 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -862,8 +862,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 604f17baed46f4997ffe79f25c07c4b51a4165a5938cc27fe165c7e1ca485d11 -F src/whereInt.h 1e36ec50392f7cc3d93d1152d4338064cd522b87156a0739388b7e273735f0ca +F src/where.c 066374c086ded30e6829a909df532c22f6fb03b1a29ef1bc0f34f45bd7895687 +F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f F src/window.c 2bf01f9941a64fbcead61a0e3cb5db3fca5094b30d2ff0d23274c2a81d2e2385 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a9475e7614f8e44252abf273d0e0522c247df12624e40108ce98ad4aaf320f2d -R 1edfbe182664cb23963ce1c643c56290 -U stephan -Z 7b3481ce418acfe304612eaa50fc5d07 +P 7cfc75a625095e41c3e952d4a209fdbb344df0d3dd9b0103e9e6a986dfe53c89 +R d91733ae99ec500ae8110e1fa74b02f9 +U drh +Z 7b31834eebc351dc793c0a6c7bc753c6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2e33fd143c..14ca545255 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7cfc75a625095e41c3e952d4a209fdbb344df0d3dd9b0103e9e6a986dfe53c89 +dbc2d6a244fdafd208239894dbdd8f139db6ca20dd8f1ed00d87028e0cb60570 diff --git a/src/where.c b/src/where.c index 20b1c38c0c..25b64bcaad 100644 --- a/src/where.c +++ b/src/where.c @@ -5511,7 +5511,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ int mxI = 0; /* Index of next entry to replace */ int nOrderBy; /* Number of ORDER BY clause terms */ LogEst mxCost = 0; /* Maximum cost of a set of paths */ - LogEst mxUnsorted = 0; /* Maximum unsorted cost of a set of path */ + LogEst mxUnsort = 0; /* Maximum unsorted cost of a set of path */ int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ WherePath *aFrom; /* All nFrom paths at the previous level */ WherePath *aTo; /* The nTo best paths at the current level */ @@ -5608,7 +5608,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ LogEst nOut; /* Rows visited by (pFrom+pWLoop) */ LogEst rCost; /* Cost of path (pFrom+pWLoop) */ - LogEst rUnsorted; /* Unsorted cost of (pFrom+pWLoop) */ + LogEst rUnsort; /* Unsorted cost of (pFrom+pWLoop) */ i8 isOrdered; /* isOrdered for (pFrom+pWLoop) */ Bitmask maskNew; /* Mask of src visited by (..) */ Bitmask revMask; /* Mask of rev-order loops for (..) */ @@ -5626,11 +5626,11 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ /* At this point, pWLoop is a candidate to be the next loop. ** Compute its cost */ - rUnsorted = pWLoop->rRun + pFrom->nRow; + rUnsort = pWLoop->rRun + pFrom->nRow; if( pWLoop->rSetup ){ - rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup, rUnsorted); + rUnsort = sqlite3LogEstAdd(pWLoop->rSetup, rUnsort); } - rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted); + rUnsort = sqlite3LogEstAdd(rUnsort, pFrom->rUnsort); nOut = pFrom->nRow + pWLoop->nOut; maskNew = pFrom->maskLoop | pWLoop->maskSelf; isOrdered = pFrom->isOrdered; @@ -5652,15 +5652,15 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** extra encouragement to the query planner to select a plan ** where the rows emerge in the correct order without any sorting ** required. */ - rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]) + 3; + rCost = sqlite3LogEstAdd(rUnsort, aSortCost[isOrdered]) + 3; WHERETRACE(0x002, ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n", aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy, - rUnsorted, rCost)); + rUnsort, rCost)); }else{ - rCost = rUnsorted; - rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ + rCost = rUnsort; + rUnsort -= 2; /* TUNING: Slight bias in favor of no-sort plans */ } /* Check to see if pWLoop should be added to the set of @@ -5686,7 +5686,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ if( jj>=nTo ){ /* None of the existing best-so-far paths match the candidate. */ if( nTo>=mxChoice - && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted)) + && (rCost>mxCost || (rCost==mxCost && rUnsort>=mxUnsort)) ){ /* The current candidate is no better than any of the mxChoice ** paths currently in the best-so-far buffer. So discard @@ -5694,7 +5694,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ sqlite3DebugPrintf("Skip %s cost=%-3d,%3d,%3d order=%c\n", - wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted, + wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort, isOrdered>=0 ? isOrdered+'0' : '?'); } #endif @@ -5713,7 +5713,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ sqlite3DebugPrintf("New %s cost=%-3d,%3d,%3d order=%c\n", - wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted, + wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort, isOrdered>=0 ? isOrdered+'0' : '?'); } #endif @@ -5724,24 +5724,21 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** pTo or if the candidate should be skipped. ** ** The conditional is an expanded vector comparison equivalent to: - ** (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted) + ** (pTo->rCost,pTo->nRow,pTo->rUnsort) <= (rCost,nOut,rUnsort) */ - if( pTo->rCostrCost==rCost - && (pTo->nRownRow==nOut && pTo->rUnsorted<=rUnsorted) - ) - ) + if( (pTo->rCostrCost==rCost && pTo->nRowrCost==rCost && pTo->nRow==nOut && pTo->rUnsort<=rUnsort) ){ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ sqlite3DebugPrintf( "Skip %s cost=%-3d,%3d,%3d order=%c", - wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted, + wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort, isOrdered>=0 ? isOrdered+'0' : '?'); sqlite3DebugPrintf(" vs %s cost=%-3d,%3d,%3d order=%c\n", wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow, - pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?'); + pTo->rUnsort, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?'); } #endif /* Discard the candidate path from further consideration */ @@ -5755,11 +5752,11 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ if( sqlite3WhereTrace&0x4 ){ sqlite3DebugPrintf( "Update %s cost=%-3d,%3d,%3d order=%c", - wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted, + wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort, isOrdered>=0 ? isOrdered+'0' : '?'); sqlite3DebugPrintf(" was %s cost=%-3d,%3d,%3d order=%c\n", wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow, - pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?'); + pTo->rUnsort, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?'); } #endif } @@ -5768,20 +5765,20 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pTo->revLoop = revMask; pTo->nRow = nOut; pTo->rCost = rCost; - pTo->rUnsorted = rUnsorted; + pTo->rUnsort = rUnsort; pTo->isOrdered = isOrdered; memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop); pTo->aLoop[iLoop] = pWLoop; if( nTo>=mxChoice ){ mxI = 0; mxCost = aTo[0].rCost; - mxUnsorted = aTo[0].nRow; + mxUnsort = aTo[0].nRow; for(jj=1, pTo=&aTo[1]; jjrCost>mxCost - || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted) + || (pTo->rCost==mxCost && pTo->rUnsort>mxUnsort) ){ mxCost = pTo->rCost; - mxUnsorted = pTo->rUnsorted; + mxUnsort = pTo->rUnsort; mxI = jj; } } diff --git a/src/whereInt.h b/src/whereInt.h index f262b0eebc..f44c040418 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -212,7 +212,7 @@ struct WherePath { Bitmask revLoop; /* aLoop[]s that should be reversed for ORDER BY */ LogEst nRow; /* Estimated number of rows generated by this path */ LogEst rCost; /* Total cost of this path */ - LogEst rUnsorted; /* Total cost of this path ignoring sorting costs */ + LogEst rUnsort; /* Total cost of this path ignoring sorting costs */ i8 isOrdered; /* No. of ORDER BY terms satisfied. -1 for unknown */ WhereLoop **aLoop; /* Array of WhereLoop objects implementing this path */ }; From d1047faad681aca6c1ceea052f027c91fb75cabe Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 15 Jan 2025 20:23:22 +0000 Subject: [PATCH 006/115] When choosing between two indexes with the same cost, pick the one with the smaller predicted number of bytes per row. FossilOrigin-Name: d4bd0d4214551f88f248698fefc821575b722ce5c194d0b3796f572e4704f641 --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/where.c | 26 +++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c560adf18a..6da9fb0a2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Variable\snames\sand\sconditional\slogic\ssimplified\sin\swhere.c.\s\sThese\nchanges\sare\scosmetic\sonly\sand\sdo\snot\saffect\sthe\sresuling\smachine\scode. -D 2025-01-15T19:30:10.144 +C When\schoosing\sbetween\stwo\sindexes\swith\sthe\ssame\scost,\spick\sthe\sone\swith\sthe\nsmaller\spredicted\snumber\sof\sbytes\sper\srow. +D 2025-01-15T20:23:22.162 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -862,7 +862,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 066374c086ded30e6829a909df532c22f6fb03b1a29ef1bc0f34f45bd7895687 +F src/where.c f081a371086f48201948431832f5e9bb1bf6c930397b8d7bcf8aaa9e21d819da F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2205,8 +2205,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7cfc75a625095e41c3e952d4a209fdbb344df0d3dd9b0103e9e6a986dfe53c89 -R d91733ae99ec500ae8110e1fa74b02f9 +P dbc2d6a244fdafd208239894dbdd8f139db6ca20dd8f1ed00d87028e0cb60570 +R b4fed608ae80dc9fc4a5de4904cc7901 +T *branch * consider-idx-width +T *sym-consider-idx-width * +T -sym-trunk * U drh -Z 7b31834eebc351dc793c0a6c7bc753c6 +Z dfdb92c016b02704a64b8a1056c8f180 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 14ca545255..a279b0e281 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dbc2d6a244fdafd208239894dbdd8f139db6ca20dd8f1ed00d87028e0cb60570 +d4bd0d4214551f88f248698fefc821575b722ce5c194d0b3796f572e4704f641 diff --git a/src/where.c b/src/where.c index 25b64bcaad..05dab8fdd5 100644 --- a/src/where.c +++ b/src/where.c @@ -5490,6 +5490,28 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ return pWInfo->nOutStarDelta>0 ? 18 : 12; } +/* +** Two WhereLoop objects, pCandidate and pBaseline, are known to have the +** same cost. Look deep into each to see if pCandidate is even slightly +** better than pBaseline. Return false if it is, if pCandidate is is preferred. +** Return true if pBaseline is preferred or if we cannot tell the difference. +** +** Result Meaning +** -------- ---------------------------------------------------------- +** true We cannot tell the difference in pCandidate and pBaseline +** false pCandidate seems like a better choice than pBaseline +*/ +static SQLITE_NOINLINE int whereLoopIsNoBetter( + const WhereLoop *pCandidate, + const WhereLoop *pBaseline +){ + if( (pCandidate->wsFlags & WHERE_INDEXED)==0 ) return 1; + if( (pBaseline->wsFlags & WHERE_INDEXED)==0 ) return 1; + if( pCandidate->u.btree.pIndex->szIdxRow < + pBaseline->u.btree.pIndex->szIdxRow ) return 0; + return 1; +} + /* ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine ** attempts to find the lowest cost path that visits each WhereLoop @@ -5728,7 +5750,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ */ if( (pTo->rCostrCost==rCost && pTo->nRowrCost==rCost && pTo->nRow==nOut && pTo->rUnsort<=rUnsort) + || (pTo->rCost==rCost && pTo->nRow==nOut && pTo->rUnsortrCost==rCost && pTo->nRow==nOut && pTo->rUnsort==rUnsort + && whereLoopIsNoBetter(pWLoop, pTo->aLoop[iLoop]) ) ){ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ From c738052394db4847c129c5039a973972e8125152 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 15 Jan 2025 20:53:14 +0000 Subject: [PATCH 007/115] Work around [https://github.com/emscripten-core/emscripten/issues/23420|a behavior change in emsdk 4.0.0] which breaks the load/init timing of the wasm module. FossilOrigin-Name: 00a750184bcf1a94bf4e7f1d5029a42671e87e2997ae97be07bd900d3702883d --- ext/wasm/api/extern-post-js.c-pp.js | 13 ++++++++++++- ext/wasm/api/post-js-footer.js | 2 ++ ext/wasm/api/post-js-header.js | 1 + ext/wasm/api/sqlite3-api-cleanup.js | 3 +++ manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js index 63e55051c6..c54e1f0825 100644 --- a/ext/wasm/api/extern-post-js.c-pp.js +++ b/ext/wasm/api/extern-post-js.c-pp.js @@ -12,6 +12,7 @@ const toExportForESM = //#endif (function(){ + //console.warn("this is extern-post-js"); /** In order to hide the sqlite3InitModule()'s resulting Emscripten module from downstream clients (and simplify our @@ -62,6 +63,17 @@ const toExportForESM = globalThis.sqlite3InitModule = function ff(...args){ //console.warn("Using replaced sqlite3InitModule()",globalThis.location); return originalInit(...args).then((EmscriptenModule)=>{ + //console.warn("originalInit() then() arg =",EmscriptenModule); + //console.warn("initModuleState =",initModuleState); + if( EmscriptenModule.postRun && EmscriptenModule.postRun.length ){ + /* Emscripten 4.0.0 changes the order in which our Module.postRun handler + runs. In 3.x postRun would have run by now, and our code relies + heavily on that order, so we'll work around that difference here. + + https://github.com/emscripten-core/emscripten/issues/23420 */ + //console.warn("Emscripten did not run postRun: running them now!"); + EmscriptenModule.postRun.shift()(EmscriptenModule); + } //#if wasmfs if('undefined'!==typeof WorkerGlobalScope && EmscriptenModule['ENVIRONMENT_IS_PTHREAD']){ @@ -74,7 +86,6 @@ const toExportForESM = return EmscriptenModule; } //#endif - //console.warn("sqlite3InitModule() returning sqlite3 object."); const s = EmscriptenModule.sqlite3; s.scriptInfo = initModuleState; //console.warn("sqlite3.scriptInfo =",s.scriptInfo); diff --git a/ext/wasm/api/post-js-footer.js b/ext/wasm/api/post-js-footer.js index 58882cbd9c..d9bb1eab0b 100644 --- a/ext/wasm/api/post-js-footer.js +++ b/ext/wasm/api/post-js-footer.js @@ -1,4 +1,6 @@ /* The current function scope was opened via post-js-header.js, which gets prepended to this at build-time. This file closes that scope. */ +//console.warn("This is the end of the Module.postRun handler."); })/*postRun.push(...)*/; +//console.warn("This is the end of the setup of the (pending) Module.postRun"); diff --git a/ext/wasm/api/post-js-header.js b/ext/wasm/api/post-js-header.js index 7fd82a7d6c..d0778b9807 100644 --- a/ext/wasm/api/post-js-header.js +++ b/ext/wasm/api/post-js-header.js @@ -10,6 +10,7 @@ if(!Module.postRun) Module.postRun = []; Module.postRun.push(function(Module/*the Emscripten-style module object*/){ 'use strict'; + //console.warn("This is the start of the Module.postRun handler."); /* This function will contain at least the following: - post-js-header.js (this file) diff --git a/ext/wasm/api/sqlite3-api-cleanup.js b/ext/wasm/api/sqlite3-api-cleanup.js index 65dbb4eb64..7fb29e6487 100644 --- a/ext/wasm/api/sqlite3-api-cleanup.js +++ b/ext/wasm/api/sqlite3-api-cleanup.js @@ -14,6 +14,9 @@ intended to be appended after all other sqlite3-api-*.js files so that it can finalize any setup and clean up any global symbols temporarily used for setting up the API's various subsystems. + + In Emscripten builds it's run in the context of a Module.postRun + handler. */ 'use strict'; if('undefined' !== typeof Module){ // presumably an Emscripten build diff --git a/manifest b/manifest index c560adf18a..47d06a98cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Variable\snames\sand\sconditional\slogic\ssimplified\sin\swhere.c.\s\sThese\nchanges\sare\scosmetic\sonly\sand\sdo\snot\saffect\sthe\sresuling\smachine\scode. -D 2025-01-15T19:30:10.144 +C Work\saround\s[https://github.com/emscripten-core/emscripten/issues/23420|a\sbehavior\schange\sin\semsdk\s4.0.0]\swhich\sbreaks\sthe\sload/init\stiming\sof\sthe\swasm\smodule. +D 2025-01-15T20:53:14.915 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -631,12 +631,12 @@ F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras fe40d6d758646e38f8b15f709044951 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 -F ext/wasm/api/extern-post-js.c-pp.js c4154a7f90c2d7e51fd6738273908152036c3457fdc0b6523f1be3ef51105aac +F ext/wasm/api/extern-post-js.c-pp.js 13b1202f2815165a063ea41cc8450e0dc1505bbbe0be2fdac439b30b8cbdaacd 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 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122 +F ext/wasm/api/post-js-footer.js 6137d9d3dea0f3868d03bca058dc662f01848f81ab6bf940ffaa10a75069d709 +F ext/wasm/api/post-js-header.js bd91458bd0763c1bdb382dc4e8ac7b52e2d7337adc3a2f07f454631b64f12e82 F ext/wasm/api/pre-js.c-pp.js a614a2c82b12c4d96d8e3ba77330329efc53c4d56a8a7e60ade900f341866cfb -F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e +F ext/wasm/api/sqlite3-api-cleanup.js 3ac1786e461ada63033143be8c3b00b26b939540661f3e839515bb92f2e35359 F ext/wasm/api/sqlite3-api-glue.c-pp.js fb6dbfe692cc23000a65a4cd95a1a47ed5eb592dc9d8b55363b3c2952a787244 F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7cfc75a625095e41c3e952d4a209fdbb344df0d3dd9b0103e9e6a986dfe53c89 -R d91733ae99ec500ae8110e1fa74b02f9 -U drh -Z 7b31834eebc351dc793c0a6c7bc753c6 +P dbc2d6a244fdafd208239894dbdd8f139db6ca20dd8f1ed00d87028e0cb60570 +R 723821a02135b50496a5bd528b97b64e +U stephan +Z ebeb04455686fb17ca7f0190e9405462 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 14ca545255..4b58858647 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dbc2d6a244fdafd208239894dbdd8f139db6ca20dd8f1ed00d87028e0cb60570 +00a750184bcf1a94bf4e7f1d5029a42671e87e2997ae97be07bd900d3702883d From 3ba9adc5c165055268cb0a75020e8a1296c619b8 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 15 Jan 2025 21:09:19 +0000 Subject: [PATCH 008/115] Teach tool/stripccomments.c that a backslash immediately preceeding a forward slash means that that forward slash cannot be the start of a comment. This is intended to allow JavaScript regular expressions containing \/* (like [https://github.com/emscripten-core/emscripten/issues/23412|the one introduced in emsdk 4.0.0]) to pass through properly. Re-enable comment-stripping in the JS dist builds. FossilOrigin-Name: db21d6cc9d1c425deffc0e4e92173caf586e6ac66110c71a4930b21e3e7f84b9 --- ext/wasm/dist.make | 3 ++- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/stripccomments.c | 19 ++++++++++++++++++- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ext/wasm/dist.make b/ext/wasm/dist.make index 10c64e16d6..60699ff5c0 100644 --- a/ext/wasm/dist.make +++ b/ext/wasm/dist.make @@ -104,7 +104,8 @@ STRIP_K2.js := $(sqlite3.js) $(sqlite3.mjs) \ # to know that it's in a regex or string literal. Because of that, # comment-stripping is currently disabled, which means the builds will # be significantly larger than before. -apply_comment_stripper := false +#apply_comment_stripper := false +apply_comment_stripper := true # ^^^ shell command true or false dist: \ $(bin.stripccomments) $(bin.version-info) \ diff --git a/manifest b/manifest index 47d06a98cd..611f9cccda 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Work\saround\s[https://github.com/emscripten-core/emscripten/issues/23420|a\sbehavior\schange\sin\semsdk\s4.0.0]\swhich\sbreaks\sthe\sload/init\stiming\sof\sthe\swasm\smodule. -D 2025-01-15T20:53:14.915 +C Teach\stool/stripccomments.c\sthat\sa\sbackslash\simmediately\spreceeding\sa\sforward\sslash\smeans\sthat\sthat\sforward\sslash\scannot\sbe\sthe\sstart\sof\sa\scomment.\sThis\sis\sintended\sto\sallow\sJavaScript\sregular\sexpressions\scontaining\s\\/*\s(like\s[https://github.com/emscripten-core/emscripten/issues/23412|the\sone\sintroduced\sin\semsdk\s4.0.0])\sto\spass\sthrough\sproperly.\sRe-enable\scomment-stripping\sin\sthe\sJS\sdist\sbuilds. +D 2025-01-15T21:09:19.736 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -668,7 +668,7 @@ F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a F ext/wasm/demo-worker1-promiser.c-pp.js fcc628cb42fcfaf07d250477801de1e6deb1e319d003976612a0db8d76b9fccc F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 836bece8615b17b1b572584f7b15912236a5947fe8c68b98d2737d7e287447ef -F ext/wasm/dist.make a5bed3b6e6d6a644e1cd416f18b799b956765333130f948d1065872a7f1ce199 +F ext/wasm/dist.make 92ef4ffe33022a50f92d602acabad10bd8dd91759f3eb7df27fc6d7d37072b96 F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle.make d4969f0322a582c57a22ce3541f10a5b09a609d14eab32891f613f43b3c14d8b F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce @@ -2193,7 +2193,7 @@ F tool/src-verify.c d00f93263aa2fa6ba0cba0106d95458e6effb94fdb5fc634f56834f90c05 F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/srctree-check.tcl 1f1f505835a4beca64c1751a7ebec5c41a1ddf22b1e80481345b95059eef6583 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 -F tool/stripccomments.c 20b8aabc4694d0d4af5566e42da1f1a03aff057689370326e9269a9ddcffdc37 +F tool/stripccomments.c dfe9cc03cf87728ac9836be30763f8aa52b82caca0780b3d3f3572e4643b01d3 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh 1612bd947750e21e7b47befad5f6b3825b06cce0705441f903bf35ced65ae9b9 F tool/tclConfigShToAutoDef.sh 44ec55046d86a3febb2cb3e099399b41794e80e9cd138eee7b9b016f819e882b x @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P dbc2d6a244fdafd208239894dbdd8f139db6ca20dd8f1ed00d87028e0cb60570 -R 723821a02135b50496a5bd528b97b64e +P 00a750184bcf1a94bf4e7f1d5029a42671e87e2997ae97be07bd900d3702883d +R 1dd6d511f4cfda5dc1ec4a63bbc6ac95 U stephan -Z ebeb04455686fb17ca7f0190e9405462 +Z 602290f471545d4fbdf4261f6ac0243b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4b58858647..0a601b281b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00a750184bcf1a94bf4e7f1d5029a42671e87e2997ae97be07bd900d3702883d +db21d6cc9d1c425deffc0e4e92173caf586e6ac66110c71a4930b21e3e7f84b9 diff --git a/tool/stripccomments.c b/tool/stripccomments.c index 53933c0138..1bdb5c6b82 100644 --- a/tool/stripccomments.c +++ b/tool/stripccomments.c @@ -111,7 +111,24 @@ void do_it_all(void){ } else if(slash == ch){ /* MARKER(("state 0 ==> 1 @ %d:%d\n", line, col)); */ - state = S_SLASH1; + if( '\\'==prev ){ + /** + JS regexes may contain slash-asterisks, as happened at: + + https://github.com/emscripten-core/emscripten/issues/23412 + + Such regexes will always necessarily be preceeded by a + backslash, though. + + It is hypothetically possible for a legitimate comment + slash-asterisk to appear immediately before a + backslash, but that seems like an even rarer corner + case than the JS regex case. + */ + fputc(ch, out); + }else{ + state = S_SLASH1; + } break; } fputc(ch, out); From 65d0312c96cd23958372fac8940314c782a6b03c Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 15 Jan 2025 21:13:38 +0000 Subject: [PATCH 009/115] Check-in [da9124fee28c155c] broken the new SQLITE_IOCAP_SUBPAGE_READ mechanism for inhibiting direct-overflow-read. This check-in fixes the problem. FossilOrigin-Name: 113078d555eaf740666680562ebbb04f7d823b72e8b2d553627e54ab3d7bf653 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 611f9cccda..1ccac6a46a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Teach\stool/stripccomments.c\sthat\sa\sbackslash\simmediately\spreceeding\sa\sforward\sslash\smeans\sthat\sthat\sforward\sslash\scannot\sbe\sthe\sstart\sof\sa\scomment.\sThis\sis\sintended\sto\sallow\sJavaScript\sregular\sexpressions\scontaining\s\\/*\s(like\s[https://github.com/emscripten-core/emscripten/issues/23412|the\sone\sintroduced\sin\semsdk\s4.0.0])\sto\spass\sthrough\sproperly.\sRe-enable\scomment-stripping\sin\sthe\sJS\sdist\sbuilds. -D 2025-01-15T21:09:19.736 +C Check-in\s[da9124fee28c155c]\sbroken\sthe\snew\sSQLITE_IOCAP_SUBPAGE_READ\smechanism\nfor\sinhibiting\sdirect-overflow-read.\s\sThis\scheck-in\sfixes\sthe\sproblem. +D 2025-01-15T21:13:38.465 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -765,7 +765,7 @@ F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d87210 F src/os_unix.c d2edbd92b07a3f778c2defa8a2e9d75acceb6267bda56948c41e8cdda65224d6 F src/os_win.c 49c7725b500f5867e8360e75eeb30f9d70b62fa1f05c8a101da627210578df32 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 2fdd489447aa6bb0f672973bacb801ced92225ca9a1c874ed9b856d2741dc54e +F src/pager.c 3a1c4e7f69af482e33c8cba8a75afe0dda0ea6391240adac22b040ce1bdeef44 F src/pager.h 6137149346e6c8a3ddc1eeb40aee46381e9bc8b0fcc6dda8a1efde993c2275b8 F src/parse.y dcf45a81b61223ac93e61fdfe9b22d635dd371c446e8222634d90aa37e25e5f6 F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 00a750184bcf1a94bf4e7f1d5029a42671e87e2997ae97be07bd900d3702883d -R 1dd6d511f4cfda5dc1ec4a63bbc6ac95 -U stephan -Z 602290f471545d4fbdf4261f6ac0243b +P db21d6cc9d1c425deffc0e4e92173caf586e6ac66110c71a4930b21e3e7f84b9 +R c4c1c248146b8316d21d4d01771a3b12 +U drh +Z 22739ec3697956e07bb55a68cf1c833f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0a601b281b..468e020a54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -db21d6cc9d1c425deffc0e4e92173caf586e6ac66110c71a4930b21e3e7f84b9 +113078d555eaf740666680562ebbb04f7d823b72e8b2d553627e54ab3d7bf653 diff --git a/src/pager.c b/src/pager.c index e2dbbeae3f..ecec892b45 100644 --- a/src/pager.c +++ b/src/pager.c @@ -808,7 +808,7 @@ int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){ if( pPager->pWal ){ u32 iRead = 0; (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead); - return iRead==0; /* Condition (4) */ + if( iRead ) return 0; /* Case (4) */ } #endif assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 ); From 3202b11f66aaeac6dd86f64f3d38dff9e3464b86 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 16 Jan 2025 09:27:40 +0000 Subject: [PATCH 010/115] Replace use of Emscripten's Module.postRun() with a custom callback so that we get consistent library init timing with both Emscripten 3.1.x and 4.0.x. Details and discussion are in [https://github.com/emscripten-core/emscripten/issues/23420|Emscripten ticket #23420]. FossilOrigin-Name: 4863a70ac61ff6f868429f16f0141484ea98f973fde1a9aff879252d0f1dbb6b --- ext/wasm/api/extern-post-js.c-pp.js | 25 +++++++++---------------- ext/wasm/api/post-js-footer.js | 6 +++--- ext/wasm/api/post-js-header.js | 12 ++++++++---- ext/wasm/api/sqlite3-api-prologue.js | 12 ++++++------ manifest | 21 ++++++++++----------- manifest.uuid | 2 +- 6 files changed, 37 insertions(+), 41 deletions(-) diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js index c54e1f0825..3598c0d6fe 100644 --- a/ext/wasm/api/extern-post-js.c-pp.js +++ b/ext/wasm/api/extern-post-js.c-pp.js @@ -65,15 +65,14 @@ const toExportForESM = return originalInit(...args).then((EmscriptenModule)=>{ //console.warn("originalInit() then() arg =",EmscriptenModule); //console.warn("initModuleState =",initModuleState); - if( EmscriptenModule.postRun && EmscriptenModule.postRun.length ){ - /* Emscripten 4.0.0 changes the order in which our Module.postRun handler - runs. In 3.x postRun would have run by now, and our code relies - heavily on that order, so we'll work around that difference here. - - https://github.com/emscripten-core/emscripten/issues/23420 */ - //console.warn("Emscripten did not run postRun: running them now!"); - EmscriptenModule.postRun.shift()(EmscriptenModule); - } + EmscriptenModule.runSQLite3PostLoadInit(EmscriptenModule); + const s = EmscriptenModule.sqlite3; + s.scriptInfo = initModuleState; + //console.warn("sqlite3.scriptInfo =",s.scriptInfo); + if(ff.__isUnderTest) s.__isUnderTest = true; + const f = s.asyncPostInit; + delete s.asyncPostInit; + const rv = f(); //#if wasmfs if('undefined'!==typeof WorkerGlobalScope && EmscriptenModule['ENVIRONMENT_IS_PTHREAD']){ @@ -86,13 +85,7 @@ const toExportForESM = return EmscriptenModule; } //#endif - const s = EmscriptenModule.sqlite3; - s.scriptInfo = initModuleState; - //console.warn("sqlite3.scriptInfo =",s.scriptInfo); - if(ff.__isUnderTest) s.__isUnderTest = true; - const f = s.asyncPostInit; - delete s.asyncPostInit; - return f(); + return rv; }).catch((e)=>{ console.error("Exception loading sqlite3 module:",e); throw e; diff --git a/ext/wasm/api/post-js-footer.js b/ext/wasm/api/post-js-footer.js index d9bb1eab0b..7af12cbe34 100644 --- a/ext/wasm/api/post-js-footer.js +++ b/ext/wasm/api/post-js-footer.js @@ -1,6 +1,6 @@ /* The current function scope was opened via post-js-header.js, which gets prepended to this at build-time. This file closes that scope. */ -//console.warn("This is the end of the Module.postRun handler."); -})/*postRun.push(...)*/; -//console.warn("This is the end of the setup of the (pending) Module.postRun"); +//console.warn("This is the end of the Module.runSQLite3PostLoadInit handler."); +}/*Module.runSQLite3PostLoadInit()*/; +//console.warn("This is the end of the setup of the (pending) Module.runSQLite3PostLoadInit"); diff --git a/ext/wasm/api/post-js-header.js b/ext/wasm/api/post-js-header.js index d0778b9807..a543c14f3a 100644 --- a/ext/wasm/api/post-js-header.js +++ b/ext/wasm/api/post-js-header.js @@ -7,8 +7,12 @@ installs will be run after the WASM module is loaded, at which point the sqlite3 JS API bits will get set up. */ -if(!Module.postRun) Module.postRun = []; -Module.postRun.push(function(Module/*the Emscripten-style module object*/){ +Module.runSQLite3PostLoadInit = function(EmscriptenModule/*the Emscripten-style module object*/){ + /** ^^^ As don't use Module.postRun, as that runs a different time + depending on whether this file is built with emcc 3.1.x or + 4.0.x. This function name is intentionally obnoxiously verbose to + ensure that we don't collide with current and future Emscripten + symbol names. */ 'use strict'; //console.warn("This is the start of the Module.postRun handler."); /* This function will contain at least the following: @@ -16,9 +20,9 @@ Module.postRun.push(function(Module/*the Emscripten-style module object*/){ - post-js-header.js (this file) - sqlite3-api-prologue.js => Bootstrapping bits to attach the rest to - common/whwasmutil.js => Replacements for much of Emscripten's glue - - jaccwaby/jaccwabyt.js => Jaccwabyt (C/JS struct binding) + - jaccwabyt/jaccwabyt.js => Jaccwabyt (C/JS struct binding) - sqlite3-api-glue.js => glues previous parts together - - sqlite3-api-oo.js => SQLite3 OO API #1 + - sqlite3-api-oo1.js => SQLite3 OO API #1 - sqlite3-api-worker1.js => Worker-based API - sqlite3-vfs-helper.c-pp.js => Utilities for VFS impls - sqlite3-vtab-helper.c-pp.js => Utilities for virtual table impls diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index c8db3698c1..ee973990a3 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -12,12 +12,12 @@ This file is intended to be combined at build-time with other related code, most notably a header and footer which wraps this - whole file into an Emscripten Module.postRun() handler. The sqlite3 - JS API has no hard requirements on Emscripten and does not expose - any Emscripten APIs to clients. It is structured such that its build - can be tweaked to include it in arbitrary WASM environments which - can supply the necessary underlying features (e.g. a POSIX file I/O - layer). + whole file into an Emscripten Module.postRun()-style handler. The + sqlite3 JS API has no hard requirements on Emscripten and does not + expose any Emscripten APIs to clients. It is structured such that + its build can be tweaked to include it in arbitrary WASM + environments which can supply the necessary underlying features + (e.g. a POSIX file I/O layer). Main project home page: https://sqlite.org diff --git a/manifest b/manifest index f9dbf25f7f..9701b9f5c6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\stwo\sindexes\shave\sthe\ssame\scost,\suse\sthe\snarrower\sone\s(the\sone\swith\sthe\nsmaller\saverage\son-disk\srow\swidth). -D 2025-01-16T01:47:03.189 +C Replace\suse\sof\sEmscripten's\sModule.postRun()\swith\sa\scustom\scallback\sso\sthat\swe\sget\sconsistent\slibrary\sinit\stiming\swith\sboth\sEmscripten\s3.1.x\sand\s4.0.x.\sDetails\sand\sdiscussion\sare\sin\s[https://github.com/emscripten-core/emscripten/issues/23420|Emscripten\sticket\s#23420]. +D 2025-01-16T09:27:40.151 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -631,15 +631,15 @@ F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras fe40d6d758646e38f8b15f709044951 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 -F ext/wasm/api/extern-post-js.c-pp.js 13b1202f2815165a063ea41cc8450e0dc1505bbbe0be2fdac439b30b8cbdaacd +F ext/wasm/api/extern-post-js.c-pp.js 3fcd904f1204685dea84e5ae90d8b7e65a1dcebab1e838386d8328b74cce46c9 F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41 -F ext/wasm/api/post-js-footer.js 6137d9d3dea0f3868d03bca058dc662f01848f81ab6bf940ffaa10a75069d709 -F ext/wasm/api/post-js-header.js bd91458bd0763c1bdb382dc4e8ac7b52e2d7337adc3a2f07f454631b64f12e82 +F ext/wasm/api/post-js-footer.js 365405929f41ca0e6d389ed8a8da3f3c93e11d3ef43a90ae151e37fa9f75bf41 +F ext/wasm/api/post-js-header.js 54b2b4294501b3866245cc94315a16f5424c0e87729d0fb610fba151593c6d26 F ext/wasm/api/pre-js.c-pp.js a614a2c82b12c4d96d8e3ba77330329efc53c4d56a8a7e60ade900f341866cfb F ext/wasm/api/sqlite3-api-cleanup.js 3ac1786e461ada63033143be8c3b00b26b939540661f3e839515bb92f2e35359 F ext/wasm/api/sqlite3-api-glue.c-pp.js fb6dbfe692cc23000a65a4cd95a1a47ed5eb592dc9d8b55363b3c2952a787244 F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f -F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 +F ext/wasm/api/sqlite3-api-prologue.js 3caa0d1f46fe1bfbd1cce31b57b4446ca073ddb15f67476a9ff6c93456467712 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 3774befd97cd1a5e2895c8225a894aad946848c6d9b4028acc988b5d123475af @@ -2205,9 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 113078d555eaf740666680562ebbb04f7d823b72e8b2d553627e54ab3d7bf653 d4bd0d4214551f88f248698fefc821575b722ce5c194d0b3796f572e4704f641 -R 67bf1f1ea7b98f52d11babfcef31079b -T +closed d4bd0d4214551f88f248698fefc821575b722ce5c194d0b3796f572e4704f641 -U drh -Z e2e745138fe18758760902106f28615a +P 398559678f2b9a65b245ed73b4d512c4fccc69d42b5a6a1c1b7755a80b69d073 +R 2801f6e9d42f0c28c93c86330f3de131 +U stephan +Z d1762f6c1968a826e67235d5776c3a77 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1fb039b289..bc45adc644 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -398559678f2b9a65b245ed73b4d512c4fccc69d42b5a6a1c1b7755a80b69d073 +4863a70ac61ff6f868429f16f0141484ea98f973fde1a9aff879252d0f1dbb6b From b6953280e7563d2e7e900391d36f618b39b64b02 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 16 Jan 2025 12:15:51 +0000 Subject: [PATCH 011/115] When generating the autoconf snapshot, replaces the Libs.private line from sqlite3.pc.in with one compatible with the legacy build, as reported in [forum:e40b9b424a|forum post e40b9b424a]. FossilOrigin-Name: fe47154799bfefb12eb1209d9ada64ecac38bee1b7c3558d175215a2beba991d --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/mkautoconfamal.sh | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 9701b9f5c6..29cdb16be1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Replace\suse\sof\sEmscripten's\sModule.postRun()\swith\sa\scustom\scallback\sso\sthat\swe\sget\sconsistent\slibrary\sinit\stiming\swith\sboth\sEmscripten\s3.1.x\sand\s4.0.x.\sDetails\sand\sdiscussion\sare\sin\s[https://github.com/emscripten-core/emscripten/issues/23420|Emscripten\sticket\s#23420]. -D 2025-01-16T09:27:40.151 +C When\sgenerating\sthe\sautoconf\ssnapshot,\sreplaces\sthe\sLibs.private\sline\sfrom\ssqlite3.pc.in\swith\sone\scompatible\swith\sthe\slegacy\sbuild,\sas\sreported\sin\s[forum:e40b9b424a|forum\spost\se40b9b424a]. +D 2025-01-16T12:15:51.633 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -2140,7 +2140,7 @@ F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669 F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176 F tool/mkamalzip.tcl 8aa5ebe7973c8b8774062d34e15fea9815c4cc2ceea3a9b184695f005910876a -F tool/mkautoconfamal.sh cbdcf993fa83dccbef7fb77b39cdeb31ef9f77d9d88c9e343b58d35ca3898a6a +F tool/mkautoconfamal.sh 4fbfd523330c8cf12ead8f0e0acdb3c5c9c08a1bcb293119267aeaa3e0bbe3e1 F tool/mkccode.tcl 210159febe0ef0ecbc53c79833500663ceaba0115b2b374405818dc835b5f84b x F tool/mkctimec.tcl ef6a67ec82e5b6fc19152a4c79f237227b18bf67ff16d155bac7adb94355d9cf x F tool/mkkeywordhash.c 6b0be901c47f9ad42215fc995eb2f4384ac49213b1fba395102ec3e999acf559 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 398559678f2b9a65b245ed73b4d512c4fccc69d42b5a6a1c1b7755a80b69d073 -R 2801f6e9d42f0c28c93c86330f3de131 +P 4863a70ac61ff6f868429f16f0141484ea98f973fde1a9aff879252d0f1dbb6b +R e6fb17d788fe1bd29fcc394e2d7718b5 U stephan -Z d1762f6c1968a826e67235d5776c3a77 +Z e136bf1726024a0aa66f18035e95cfb5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bc45adc644..5c39a70ad1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4863a70ac61ff6f868429f16f0141484ea98f973fde1a9aff879252d0f1dbb6b +fe47154799bfefb12eb1209d9ada64ecac38bee1b7c3558d175215a2beba991d diff --git a/tool/mkautoconfamal.sh b/tool/mkautoconfamal.sh index 35dbfb41e0..f3ce9dd5ba 100644 --- a/tool/mkautoconfamal.sh +++ b/tool/mkautoconfamal.sh @@ -68,6 +68,10 @@ cat $TMPSPACE/configure.ac | sed "s/--SQLITE-VERSION--/$VERSION/" > $TMPSPACE/tmp mv $TMPSPACE/tmp $TMPSPACE/configure.ac +cat $TMPSPACE/sqlite3.pc.in | +sed "s/^Libs.private:.*/Libs.private: @LIBS@/" > $TMPSPACE/tmp +mv $TMPSPACE/tmp $TMPSPACE/sqlite3.pc.in + cd $TMPSPACE autoreconf -i #libtoolize From ec50c5a2a430b77c45a1118ab68c93d53c9299bb Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 16 Jan 2025 13:10:06 +0000 Subject: [PATCH 012/115] wasm: after generating the .js/.mjs file, strip out all of the generated pieces which create Emscripten call() bindings for the sqlite3 APIs, as we don't use those binding, so both the setup time and the memory they use installing WASM proxy bindings is wasted. This eliminates some 200 superfluous/unused bindings from the init process. FossilOrigin-Name: 020d2c7528be6f11a5b2b849d7b2f04e47abe2b0842520ff60eb7defb3768e1c --- ext/wasm/GNUmakefile | 1 + ext/wasm/mkwasmbuilds.c | 11 +++++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 6f226fbb4f..ad6fafacc7 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -1052,6 +1052,7 @@ $(speedtest1.js): $(MAKEFILE) $(speedtest1.cfiles) \ $(speedtest1.exit-runtime0) \ -o $@ $(speedtest1.cfiles) -lm $(maybe-wasm-strip) $(speedtest1.wasm) + sed -i -e '/^var _sqlite3.*createExportWrapper/d' $@ chmod -x $(speedtest1.wasm) ls -la $@ $(speedtest1.wasm) diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index 29b6cafae9..d7a9a3e71c 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -75,7 +75,7 @@ static void mk_pre_post(const char *zName /* build name */, const char *zMode /* build mode */, const char *zCmppD /* optional -D flags for c-pp for the ** --pre/--post-js files. */){ - pf("%s# Begin --pre/--post flags for %s-%s\n", zBanner, zName, zMode); + pf("%s# Begin --pre/--post flags for %s-%s\n", zBanner, zNM); pf("c-pp.D.%s-%s := %s\n", zNM, zCmppD ? zCmppD : ""); pf("pre-post-%s-%s.flags ?=\n", zNM); @@ -130,7 +130,7 @@ static void mk_pre_post(const char *zName /* build name */, zNM, zNM, zNM); pf("pre-post-%s-%s.deps := $(pre-post-jses.%s-%s.deps) $(dir.tmp)/pre-js.%s-%s.js\n", zNM, zNM, zNM); - pf("# End --pre/--post flags for %s-%s%s", zName, zMode, zBanner); + pf("# End --pre/--post flags for %s-%s%s", zNM, zBanner); } /* @@ -233,6 +233,13 @@ static void mk_lib_mode(const char *zName /* build name */, pf("\t@dotwasm=$(basename $@).wasm; \\\n" "\tchmod -x $$dotwasm; \\\n" "\t$(maybe-wasm-strip) $$dotwasm; \\\n"); + pf("\tsed -i -e '/^var _sqlite3.*createExportWrapper/d' %s; \\\n" + "\techo 'Stripped out createExportWrapper() parts.'; \\\n", + zJsOut) /* Our JS code installs bindings of each WASM export. The + generated Emscripten JS file does the same using its + own framework, but we don't use those results and can + speed up lib init, and reduce memory cost + considerably, by stripping them out. */; /* ** The above $(emcc.bin) call will write zJsOut and will create a ** like-named .wasm file. That .wasm file name gets hard-coded into diff --git a/manifest b/manifest index 29cdb16be1..211eaabd00 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sgenerating\sthe\sautoconf\ssnapshot,\sreplaces\sthe\sLibs.private\sline\sfrom\ssqlite3.pc.in\swith\sone\scompatible\swith\sthe\slegacy\sbuild,\sas\sreported\sin\s[forum:e40b9b424a|forum\spost\se40b9b424a]. -D 2025-01-16T12:15:51.633 +C wasm:\safter\sgenerating\sthe\s.js/.mjs\sfile,\sstrip\sout\sall\sof\sthe\sgenerated\spieces\swhich\screate\sEmscripten\scall()\sbindings\sfor\sthe\ssqlite3\sAPIs,\sas\swe\sdon't\suse\sthose\sbinding,\sso\sboth\sthe\ssetup\stime\sand\sthe\smemory\sthey\suse\sinstalling\sWASM\sproxy\sbindings\sis\swasted.\sThis\seliminates\ssome\s200\ssuperfluous/unused\sbindings\sfrom\sthe\sinit\sprocess. +D 2025-01-16T13:10:06.949 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -618,7 +618,7 @@ F ext/session/sqlite3session.c d6f5e3e83b9b0bbc4a8db4837284f0ecc6af5321d4c8e7136 F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 6b42d6de2316ae01a96d1b850932fcab0f2938affc27b48495776903f544a488 +F ext/wasm/GNUmakefile 78f49e47146d58fa44f9ac624627a718fba4b2b2baeaea641bcf6fed300c0f0d F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -678,7 +678,7 @@ F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29a F ext/wasm/index.html e4bbffdb3d40eff12b3f9c7abedef91787e2935620b7f8d40f2c774b80ad8fa9 F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 -F ext/wasm/mkwasmbuilds.c e3580b26bc393e4e4beb25f6349b999878782f3319b740469f64c2e772632e03 +F ext/wasm/mkwasmbuilds.c af06fd14fcb7803c0adacab276047bb696c07f5b683a6f70adc5b3f146cf61f3 F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4863a70ac61ff6f868429f16f0141484ea98f973fde1a9aff879252d0f1dbb6b -R e6fb17d788fe1bd29fcc394e2d7718b5 +P fe47154799bfefb12eb1209d9ada64ecac38bee1b7c3558d175215a2beba991d +R 0d99f3ed7952e5d1d1a513615776937d U stephan -Z e136bf1726024a0aa66f18035e95cfb5 +Z 6b1b963846ad84056f214255285f2dea # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5c39a70ad1..57bfab2704 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe47154799bfefb12eb1209d9ada64ecac38bee1b7c3558d175215a2beba991d +020d2c7528be6f11a5b2b849d7b2f04e47abe2b0842520ff60eb7defb3768e1c From 4a25b740f26ee60386cdbf962dc30acf563cb432 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 16 Jan 2025 14:06:29 +0000 Subject: [PATCH 013/115] Speedtest1 enhancements: (1) Add the ability to scale performance of tests sets using "/NNN" after the testset name, even for testsets in a comma-separated list. (2) Add the "mix1" macro testset. FossilOrigin-Name: 85667b3a572bc9afd8c862a0b2c5f47f76ca80d6e61302ca7d7c1b326d3dd578 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/speedtest1.c | 23 +++++++++++++++++++++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 211eaabd00..46cf956575 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C wasm:\safter\sgenerating\sthe\s.js/.mjs\sfile,\sstrip\sout\sall\sof\sthe\sgenerated\spieces\swhich\screate\sEmscripten\scall()\sbindings\sfor\sthe\ssqlite3\sAPIs,\sas\swe\sdon't\suse\sthose\sbinding,\sso\sboth\sthe\ssetup\stime\sand\sthe\smemory\sthey\suse\sinstalling\sWASM\sproxy\sbindings\sis\swasted.\sThis\seliminates\ssome\s200\ssuperfluous/unused\sbindings\sfrom\sthe\sinit\sprocess. -D 2025-01-16T13:10:06.949 +C Speedtest1\senhancements:\s\s(1)\sAdd\sthe\sability\sto\sscale\sperformance\sof\ntests\ssets\susing\s"/NNN"\safter\sthe\stestset\sname,\seven\sfor\stestsets\sin\sa\ncomma-separated\slist.\s\s(2)\sAdd\sthe\s"mix1"\smacro\stestset. +D 2025-01-16T14:06:30.000 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1677,7 +1677,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 cc503febbb8559d541a67d7a33d3d7bb8a2c8cbbfc89eb336e2e2bd6ad6a63ee +F test/speedtest1.c ef3a1b9c0938b5202a6ad7a16bf53422f13f4c3901e9b973aaac168a30d75feb F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fe47154799bfefb12eb1209d9ada64ecac38bee1b7c3558d175215a2beba991d -R 0d99f3ed7952e5d1d1a513615776937d -U stephan -Z 6b1b963846ad84056f214255285f2dea +P 020d2c7528be6f11a5b2b849d7b2f04e47abe2b0842520ff60eb7defb3768e1c +R 6782bdbb35165160181ae38f9abe3d27 +U drh +Z 6a345f2c4878196402ebe51d9f9059ab # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 57bfab2704..b51b9a35e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -020d2c7528be6f11a5b2b849d7b2f04e47abe2b0842520ff60eb7defb3768e1c +85667b3a572bc9afd8c862a0b2c5f47f76ca80d6e61302ca7d7c1b326d3dd578 diff --git a/test/speedtest1.c b/test/speedtest1.c index b0817858ae..37f215172e 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -43,6 +43,8 @@ static const char zHelp[] = " --stmtscanstatus Activate SQLITE_DBCONFIG_STMT_SCANSTATUS\n" " --temp N N from 0 to 9. 0: no temp table. 9: all temp tables\n" " --testset T Run test-set T (main, cte, rtree, orm, fp, debug)\n" + " Can be a comma-separated list of values, with /SCALE suffixes\n" + " or macro \"mix1\"\n" " --trace Turn on SQL tracing\n" " --threads N Use up to N threads for sorting\n" " --utf16be Set text encoding to UTF-16BE\n" @@ -99,6 +101,7 @@ static struct Global { int bMemShrink; /* Call sqlite3_db_release_memory() often */ int eTemp; /* 0: no TEMP. 9: always TEMP. */ int szTest; /* Scale factor for test iterations */ + int szBase; /* Base size prior to testset scaling */ int nRepeat; /* Repeat selects this many times */ int doCheckpoint; /* Run PRAGMA wal_checkpoint after each trans */ int nReserve; /* Reserve bytes */ @@ -2299,6 +2302,7 @@ int main(int argc, char **argv){ g.zNN = ""; g.zPK = "UNIQUE"; g.szTest = 100; + g.szBase = 100; g.nRepeat = 1; for(i=1; i0 || zComma!=0 ){ + zSep = strchr(zThisTest, '/'); + if( zSep ){ + int kk; + for(kk=1; zSep[kk] && ISDIGIT(zSep[kk]); kk++){} + if( kk==1 || zSep[kk]!=0 ){ + fatal_error("bad modifier on testset name: \"%s\"", zThisTest); + } + g.szTest = g.szBase*integerValue(zSep+1)/100; + zSep[0] = 0; + }else{ + g.szTest = g.szBase; + } + if( g.iTotal>0 || zComma==0 ){ printf(" Begin testset \"%s\"\n", zThisTest); } if( strcmp(zThisTest,"main")==0 ){ From bfa721898255f8529bb58e8cbb1d1b3d867896fe Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 16 Jan 2025 14:37:48 +0000 Subject: [PATCH 014/115] Add the "json" test case to speedtest1 and include it in "mix1". FossilOrigin-Name: 2db3a3ee37a9d2fe9b94d16d35c24846c37abe73b89cde4dd763e01a2bfaa8b7 --- manifest | 12 +++---- manifest.uuid | 2 +- test/speedtest1.c | 85 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 90 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 46cf956575..73e42b6f79 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Speedtest1\senhancements:\s\s(1)\sAdd\sthe\sability\sto\sscale\sperformance\sof\ntests\ssets\susing\s"/NNN"\safter\sthe\stestset\sname,\seven\sfor\stestsets\sin\sa\ncomma-separated\slist.\s\s(2)\sAdd\sthe\s"mix1"\smacro\stestset. -D 2025-01-16T14:06:30.000 +C Add\sthe\s"json"\stest\scase\sto\sspeedtest1\sand\sinclude\sit\sin\s"mix1". +D 2025-01-16T14:37:48.974 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1677,7 +1677,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 ef3a1b9c0938b5202a6ad7a16bf53422f13f4c3901e9b973aaac168a30d75feb +F test/speedtest1.c 572cc10da33f9ce696346fefddf8afc583745e448192fda8d81ae4be897da27f F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 020d2c7528be6f11a5b2b849d7b2f04e47abe2b0842520ff60eb7defb3768e1c -R 6782bdbb35165160181ae38f9abe3d27 +P 85667b3a572bc9afd8c862a0b2c5f47f76ca80d6e61302ca7d7c1b326d3dd578 +R 207656080a990b075c009fc5a42018e0 U drh -Z 6a345f2c4878196402ebe51d9f9059ab +Z 5e27a73ae0785d981160c5186c684481 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b51b9a35e4..d4dd07d115 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -85667b3a572bc9afd8c862a0b2c5f47f76ca80d6e61302ca7d7c1b326d3dd578 +2db3a3ee37a9d2fe9b94d16d35c24846c37abe73b89cde4dd763e01a2bfaa8b7 diff --git a/test/speedtest1.c b/test/speedtest1.c index 37f215172e..581e0af373 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -42,7 +42,7 @@ static const char zHelp[] = " --stats Show statistics at the end\n" " --stmtscanstatus Activate SQLITE_DBCONFIG_STMT_SCANSTATUS\n" " --temp N N from 0 to 9. 0: no temp table. 9: all temp tables\n" - " --testset T Run test-set T (main, cte, rtree, orm, fp, debug)\n" + " --testset T Run test-set T (main, cte, rtree, orm, fp, json, debug)\n" " Can be a comma-separated list of values, with /SCALE suffixes\n" " or macro \"mix1\"\n" " --trace Turn on SQL tracing\n" @@ -2152,6 +2152,85 @@ void testset_debug1(void){ } } +/* +** Performance tests for JSON. +*/ +void testset_json(void){ + speedtest1_begin_test(100, "construct table J1 with %d rows of text JSON", + g.szTest*250); + speedtest1_exec( + "CREATE TABLE j1(x JSON TEXT);\n" + "WITH RECURSIVE\n" + " c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<%d),\n" + " array1(y) AS (\n" + " SELECT json_group_array(\n" + " json_object('x',x,'y',random(),'z',hex(randomblob(50)))\n" + " )\n" + " FROM c\n" + " ),\n" + " c2(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c2 WHERE n<5)\n" + "INSERT INTO j1(x)\n" + " SELECT json_object('a',n,'b',n*2,'c',y,'d',3,'e',5,'f',6) FROM array1, c2;\n", + g.szTest*250 + ); + speedtest1_end_test(); + + speedtest1_begin_test(110, "construct table J2 with %d rows of JSONB", + g.szTest*250); + speedtest1_exec( + "CREATE TABLE j2(x JSON TEXT);\n" + "WITH RECURSIVE\n" + " c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<%d),\n" + " array1(y) AS (\n" + " SELECT json_group_array(\n" + " json_object('x',x,'y',random(),'z',hex(randomblob(50)))\n" + " )\n" + " FROM c\n" + " ),\n" + " c2(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c2 WHERE n<5)\n" + "INSERT INTO j2(x)\n" + " SELECT jsonb_object('a',n,'b',n*2,'c',y,'d',3,'e',5,'f',6) FROM array1, c2;\n", + g.szTest*250 + ); + speedtest1_end_test(); + + speedtest1_begin_test(120, "create indexes on JSON expressions"); + speedtest1_exec( + "BEGIN;\n" + "CREATE INDEX j1x1 ON j1(x->>'a');\n" + "CREATE INDEX j1x2 ON j1(x->>'b');\n" + "CREATE INDEX j1x3 ON j1(x->>'e');\n" + "CREATE INDEX j1x4 ON j1(x->>'f');\n" + "CREATE INDEX j2x1 ON j2(x->>'a');\n" + "CREATE INDEX j2x2 ON j2(x->>'b');\n" + "CREATE INDEX j2x3 ON j2(x->>'e');\n" + "CREATE INDEX j2x4 ON j2(x->>'f');\n" + "COMMIT;\n" + ); + speedtest1_end_test(); + + speedtest1_begin_test(130, "json_replace()/set()/remove() on every row of J1"); + speedtest1_exec( + "BEGIN;\n" + "UPDATE j1 SET x=json_replace(x,'$.f',(x->>'f')+1);\n" + "UPDATE j1 SET x=json_set(x,'$.e',(x->>'f')-1);\n" + "UPDATE j1 SET x=json_remove(x,'$.d');\n" + "COMMIT;\n" + ); + speedtest1_end_test(); + + speedtest1_begin_test(140, "json_replace()/set()/remove() on every row of J2"); + speedtest1_exec( + "BEGIN;\n" + "UPDATE j2 SET x=jsonb_replace(x,'$.f',(x->>'f')+1);\n" + "UPDATE j2 SET x=jsonb_set(x,'$.e',(x->>'f')-1);\n" + "UPDATE j2 SET x=jsonb_remove(x,'$.d');\n" + "COMMIT;\n" + ); + speedtest1_end_test(); + +} + /* ** This testset focuses on the speed of parsing numeric literals (integers ** and real numbers). This was added to test the impact of allowing "_" @@ -2423,7 +2502,7 @@ int main(int argc, char **argv){ } g.eTemp = argv[i][0] - '0'; }else if( strcmp(z,"testset")==0 ){ - static char zMix1Tests[] = "main,orm/25,cte/20,fp/25,parsenumber,rtree/20"; + static char zMix1Tests[] = "main,orm/25,cte/20,json,fp/25,parsenumber,rtree/20"; ARGC_VALUE_CHECK(1); zTSet = argv[++i]; if( strcmp(zTSet,"mix1")==0 ) zTSet = zMix1Tests; @@ -2613,6 +2692,8 @@ int main(int argc, char **argv){ testset_cte(); }else if( strcmp(zThisTest,"fp")==0 ){ testset_fp(); + }else if( strcmp(zThisTest,"json")==0 ){ + testset_json(); }else if( strcmp(zThisTest,"trigger")==0 ){ testset_trigger(); }else if( strcmp(zThisTest,"parsenumber")==0 ){ From c957673bf7f8e79f29ce217bc89c0f686ff4c590 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 16 Jan 2025 17:19:06 +0000 Subject: [PATCH 015/115] Revamp the "json" testset in speedtest1. FossilOrigin-Name: d33508836bc88314a205bfa9d80f3ebe695163cf0c46d500ad674535975408fb --- manifest | 12 +++---- manifest.uuid | 2 +- test/speedtest1.c | 83 ++++++++++++++++++++++++++--------------------- 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/manifest b/manifest index 73e42b6f79..82d8bd5ec6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"json"\stest\scase\sto\sspeedtest1\sand\sinclude\sit\sin\s"mix1". -D 2025-01-16T14:37:48.974 +C Revamp\sthe\s"json"\stestset\sin\sspeedtest1. +D 2025-01-16T17:19:06.045 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1677,7 +1677,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 572cc10da33f9ce696346fefddf8afc583745e448192fda8d81ae4be897da27f +F test/speedtest1.c 6c9f30a9035aeafc767b770f0c576d45701ed928f7e354f6c18b6bbccbf81417 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 85667b3a572bc9afd8c862a0b2c5f47f76ca80d6e61302ca7d7c1b326d3dd578 -R 207656080a990b075c009fc5a42018e0 +P 2db3a3ee37a9d2fe9b94d16d35c24846c37abe73b89cde4dd763e01a2bfaa8b7 +R c60371158767e3daeea4a8672be014f0 U drh -Z 5e27a73ae0785d981160c5186c684481 +Z 3720db8250a91ea5623fb5048e644ae1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d4dd07d115..e1c1950809 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2db3a3ee37a9d2fe9b94d16d35c24846c37abe73b89cde4dd763e01a2bfaa8b7 +d33508836bc88314a205bfa9d80f3ebe695163cf0c46d500ad674535975408fb diff --git a/test/speedtest1.c b/test/speedtest1.c index 581e0af373..95a451e7b7 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -2156,55 +2156,64 @@ void testset_debug1(void){ ** Performance tests for JSON. */ void testset_json(void){ - speedtest1_begin_test(100, "construct table J1 with %d rows of text JSON", - g.szTest*250); + unsigned int r = 0x12345678; + sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SEED, r, g.db); + speedtest1_begin_test(100, "table J1 is %d rows of JSONB", + g.szTest*5); speedtest1_exec( - "CREATE TABLE j1(x JSON TEXT);\n" + "CREATE TABLE j1(x JSONB);\n" "WITH RECURSIVE\n" - " c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<%d),\n" - " array1(y) AS (\n" - " SELECT json_group_array(\n" - " json_object('x',x,'y',random(),'z',hex(randomblob(50)))\n" - " )\n" - " FROM c\n" + " jval(n,j) AS (\n" + " VALUES(0,'{}'),(1,'[]'),(2,'true'),(3,'false'),(4,'null'),\n" + " (5,'{x:1,y:2}'),(6,'0.0'),(7,'3.14159'),(8,'-99.9'),\n" + " (9,'[1,2,3,4]')\n" " ),\n" - " c2(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c2 WHERE n<5)\n" + " c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<26*26-1),\n" + " array1(y) AS MATERIALIZED (\n" + " SELECT jsonb_group_array(\n" + " jsonb_object('x',x,\n" + " 'y',jsonb(coalesce(j,random()%%10000)),\n" + " 'z',hex(randomblob(50)))\n" + " )\n" + " FROM c LEFT JOIN jval ON (x%%20)=n\n" + " ),\n" + " object1(z) AS MATERIALIZED (\n" + " SELECT jsonb_group_object(char(0x61+x%%26,0x61+(x/26)%%26),\n" + " jsonb( coalesce(j,random()%%10000)))\n" + " FROM c LEFT JOIN jval ON (x%%20)=n\n" + " ),\n" + " c2(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c2 WHERE n<%d)\n" "INSERT INTO j1(x)\n" - " SELECT json_object('a',n,'b',n*2,'c',y,'d',3,'e',5,'f',6) FROM array1, c2;\n", - g.szTest*250 + " SELECT jsonb_object('a',n,'b',n+10000,'c',jsonb(y),'d',jsonb(z),\n" + " 'e',n+20000,'f',n+30000)\n" + " FROM array1, object1, c2;", + g.szTest*5 ); speedtest1_end_test(); - speedtest1_begin_test(110, "construct table J2 with %d rows of JSONB", - g.szTest*250); + speedtest1_begin_test(110, "table J2 is %d rows from J1 converted to text", g.szTest); speedtest1_exec( "CREATE TABLE j2(x JSON TEXT);\n" - "WITH RECURSIVE\n" - " c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<%d),\n" - " array1(y) AS (\n" - " SELECT json_group_array(\n" - " json_object('x',x,'y',random(),'z',hex(randomblob(50)))\n" - " )\n" - " FROM c\n" - " ),\n" - " c2(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c2 WHERE n<5)\n" - "INSERT INTO j2(x)\n" - " SELECT jsonb_object('a',n,'b',n*2,'c',y,'d',3,'e',5,'f',6) FROM array1, c2;\n", - g.szTest*250 + "INSERT INTO j2(x) SELECT json(x) FROM j1 LIMIT %d", g.szTest ); speedtest1_end_test(); - speedtest1_begin_test(120, "create indexes on JSON expressions"); + speedtest1_begin_test(120, "create indexes on JSON expressions on J1"); speedtest1_exec( "BEGIN;\n" "CREATE INDEX j1x1 ON j1(x->>'a');\n" "CREATE INDEX j1x2 ON j1(x->>'b');\n" - "CREATE INDEX j1x3 ON j1(x->>'e');\n" - "CREATE INDEX j1x4 ON j1(x->>'f');\n" + "CREATE INDEX j1x3 ON j1(x->>'f');\n" + "COMMIT;\n" + ); + speedtest1_end_test(); + + speedtest1_begin_test(130, "create indexes on JSON expressions on J2"); + speedtest1_exec( + "BEGIN;\n" "CREATE INDEX j2x1 ON j2(x->>'a');\n" "CREATE INDEX j2x2 ON j2(x->>'b');\n" - "CREATE INDEX j2x3 ON j2(x->>'e');\n" - "CREATE INDEX j2x4 ON j2(x->>'f');\n" + "CREATE INDEX j2x3 ON j2(x->>'f');\n" "COMMIT;\n" ); speedtest1_end_test(); @@ -2212,9 +2221,9 @@ void testset_json(void){ speedtest1_begin_test(130, "json_replace()/set()/remove() on every row of J1"); speedtest1_exec( "BEGIN;\n" - "UPDATE j1 SET x=json_replace(x,'$.f',(x->>'f')+1);\n" - "UPDATE j1 SET x=json_set(x,'$.e',(x->>'f')-1);\n" - "UPDATE j1 SET x=json_remove(x,'$.d');\n" + "UPDATE j1 SET x=jsonb_replace(x,'$.f',(x->>'f')+1);\n" + "UPDATE j1 SET x=jsonb_set(x,'$.e',(x->>'f')-1);\n" + "UPDATE j1 SET x=jsonb_remove(x,'$.d');\n" "COMMIT;\n" ); speedtest1_end_test(); @@ -2222,9 +2231,9 @@ void testset_json(void){ speedtest1_begin_test(140, "json_replace()/set()/remove() on every row of J2"); speedtest1_exec( "BEGIN;\n" - "UPDATE j2 SET x=jsonb_replace(x,'$.f',(x->>'f')+1);\n" - "UPDATE j2 SET x=jsonb_set(x,'$.e',(x->>'f')-1);\n" - "UPDATE j2 SET x=jsonb_remove(x,'$.d');\n" + "UPDATE j2 SET x=json_replace(x,'$.f',(x->>'f')+1);\n" + "UPDATE j2 SET x=json_set(x,'$.e',(x->>'f')-1);\n" + "UPDATE j2 SET x=json_remove(x,'$.d');\n" "COMMIT;\n" ); speedtest1_end_test(); From 7edb0c392078837d268cea54c2a6252e195a6210 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 16 Jan 2025 20:08:59 +0000 Subject: [PATCH 016/115] speedtest1: Improvements to the "json" testset. Better balance in "mix1". FossilOrigin-Name: 2cc73c5e08f1a16fe8accf0af6af061e42d27635883d09234516fd470e99bc0a --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 33 +++++++++++++++++++++++---------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 82d8bd5ec6..08f99e6eef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revamp\sthe\s"json"\stestset\sin\sspeedtest1. -D 2025-01-16T17:19:06.045 +C speedtest1:\s\sImprovements\sto\sthe\s"json"\stestset.\s\sBetter\sbalance\sin\s"mix1". +D 2025-01-16T20:08:59.559 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1677,7 +1677,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 6c9f30a9035aeafc767b770f0c576d45701ed928f7e354f6c18b6bbccbf81417 +F test/speedtest1.c 26f1b44de121c114d1487baa5b040c0f2d5fe6bb57febb7ae51ece6ab919783d F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2db3a3ee37a9d2fe9b94d16d35c24846c37abe73b89cde4dd763e01a2bfaa8b7 -R c60371158767e3daeea4a8672be014f0 +P d33508836bc88314a205bfa9d80f3ebe695163cf0c46d500ad674535975408fb +R dd0ac0f4915c519ed5a12a3b5d1c6f66 U drh -Z 3720db8250a91ea5623fb5048e644ae1 +Z 81cac1efd10a78c1a3b6a5cb8d65a46e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e1c1950809..d6dcda86ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d33508836bc88314a205bfa9d80f3ebe695163cf0c46d500ad674535975408fb +2cc73c5e08f1a16fe8accf0af6af061e42d27635883d09234516fd470e99bc0a diff --git a/test/speedtest1.c b/test/speedtest1.c index 95a451e7b7..c84d2c5919 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -2166,7 +2166,7 @@ void testset_json(void){ " jval(n,j) AS (\n" " VALUES(0,'{}'),(1,'[]'),(2,'true'),(3,'false'),(4,'null'),\n" " (5,'{x:1,y:2}'),(6,'0.0'),(7,'3.14159'),(8,'-99.9'),\n" - " (9,'[1,2,3,4]')\n" + " (9,'[1,2,\"\\n\\u2192\\\"\\u2190\",4]')\n" " ),\n" " c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<26*26-1),\n" " array1(y) AS MATERIALIZED (\n" @@ -2218,20 +2218,32 @@ void testset_json(void){ ); speedtest1_end_test(); - speedtest1_begin_test(130, "json_replace()/set()/remove() on every row of J1"); + speedtest1_begin_test(140, "queries against J1"); + speedtest1_exec( + "WITH c(n) AS (VALUES(0) UNION ALL SELECT n+1 FROM c WHERE n<7)\n" + " SELECT sum(x->>format('$.c[%%d].x',n)) FROM c, j1;\n" + "WITH c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<5)\n" + " SELECT sum(x->>format('$.\"c\"[#-%%d].y',n)) FROM c, j1;\n" + "SELECT sum(x->>'$.d.ez' + x->>'$.d.\"xz\"' + x->>'a' + x->>'$.c[10].y') FROM j1;\n" + "SELECT x->>'$.d.tz[2]', x->'$.d.tz' FROM j1;\n" + ); + speedtest1_end_test(); + + + speedtest1_begin_test(150, "json_insert()/set()/remove() on every row of J1"); speedtest1_exec( "BEGIN;\n" - "UPDATE j1 SET x=jsonb_replace(x,'$.f',(x->>'f')+1);\n" + "UPDATE j1 SET x=jsonb_insert(x,'$.g',(x->>'f')+1);\n" "UPDATE j1 SET x=jsonb_set(x,'$.e',(x->>'f')-1);\n" "UPDATE j1 SET x=jsonb_remove(x,'$.d');\n" "COMMIT;\n" ); speedtest1_end_test(); - speedtest1_begin_test(140, "json_replace()/set()/remove() on every row of J2"); + speedtest1_begin_test(160, "json_insert()/set()/remove() on every row of J2"); speedtest1_exec( "BEGIN;\n" - "UPDATE j2 SET x=json_replace(x,'$.f',(x->>'f')+1);\n" + "UPDATE j2 SET x=json_insert(x,'$.g',(x->>'f')+1);\n" "UPDATE j2 SET x=json_set(x,'$.e',(x->>'f')-1);\n" "UPDATE j2 SET x=json_remove(x,'$.d');\n" "COMMIT;\n" @@ -2259,25 +2271,25 @@ void testset_parsenumber(void){ const int NROW = 100*g.szTest; int ii; - speedtest1_begin_test(100, "parsing small integers"); + speedtest1_begin_test(100, "parsing %d small integers", NROW); for(ii=0; ii Date: Thu, 16 Jan 2025 20:46:08 +0000 Subject: [PATCH 017/115] speedtest1: further improvements to the "json" testset. FossilOrigin-Name: c4750f7cf7e2188623de8b12e01acf3e3d7dc7b5ea87ac449571eb36f97d842a --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 16 +++++++++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 08f99e6eef..a5505b6964 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C speedtest1:\s\sImprovements\sto\sthe\s"json"\stestset.\s\sBetter\sbalance\sin\s"mix1". -D 2025-01-16T20:08:59.559 +C speedtest1:\sfurther\simprovements\sto\sthe\s"json"\stestset. +D 2025-01-16T20:46:08.022 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1677,7 +1677,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 26f1b44de121c114d1487baa5b040c0f2d5fe6bb57febb7ae51ece6ab919783d +F test/speedtest1.c 323ce0956430a5aae56ea20f502da7bea3fb62b8ed02e9b0f12ab078b2b258f5 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d33508836bc88314a205bfa9d80f3ebe695163cf0c46d500ad674535975408fb -R dd0ac0f4915c519ed5a12a3b5d1c6f66 +P 2cc73c5e08f1a16fe8accf0af6af061e42d27635883d09234516fd470e99bc0a +R f4bb93608db14b0baa099caf842aef42 U drh -Z 81cac1efd10a78c1a3b6a5cb8d65a46e +Z 1a1ead4cbc7ce98f73040d73112e92fb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d6dcda86ad..43e7b2476a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2cc73c5e08f1a16fe8accf0af6af061e42d27635883d09234516fd470e99bc0a +c4750f7cf7e2188623de8b12e01acf3e3d7dc7b5ea87ac449571eb36f97d842a diff --git a/test/speedtest1.c b/test/speedtest1.c index c84d2c5919..8847ed04bf 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -2222,18 +2222,32 @@ void testset_json(void){ speedtest1_exec( "WITH c(n) AS (VALUES(0) UNION ALL SELECT n+1 FROM c WHERE n<7)\n" " SELECT sum(x->>format('$.c[%%d].x',n)) FROM c, j1;\n" + "WITH c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<5)\n" " SELECT sum(x->>format('$.\"c\"[#-%%d].y',n)) FROM c, j1;\n" + "SELECT sum(x->>'$.d.ez' + x->>'$.d.\"xz\"' + x->>'a' + x->>'$.c[10].y') FROM j1;\n" + "SELECT x->>'$.d.tz[2]', x->'$.d.tz' FROM j1;\n" ); speedtest1_end_test(); + speedtest1_begin_test(141, "queries involving json_type()"); + speedtest1_exec( + "WITH c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<20)\n" + " SELECT json_type(x,format('$.c[#-%%d].y',n)), count(*)\n" + " FROM c, j1\n" + " WHERE j1.rowid=1\n" + " GROUP BY 1 ORDER BY 2;" + ); + speedtest1_end_test(); + speedtest1_begin_test(150, "json_insert()/set()/remove() on every row of J1"); speedtest1_exec( "BEGIN;\n" - "UPDATE j1 SET x=jsonb_insert(x,'$.g',(x->>'f')+1);\n" + "UPDATE j1 SET x=jsonb_insert(x,'$.g',(x->>'f')+1,'$.h',3.14159,'$.i','hello',\n" + " '$.j',json('{x:99}'),'$.k','{y:98}');\n" "UPDATE j1 SET x=jsonb_set(x,'$.e',(x->>'f')-1);\n" "UPDATE j1 SET x=jsonb_remove(x,'$.d');\n" "COMMIT;\n" From d0c6c6586e03ddef4713388ce95e212b1c26f5ed Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 Jan 2025 10:39:04 +0000 Subject: [PATCH 018/115] Fix a potential one-byte buffer overrun when reading from the Windows console in the CLI. [forum:/forumpost/95e17b8f5c|Forum post 95e17b8f5c]. FossilOrigin-Name: 4d96759694c91301410f53a3f737a049c33e8b259b0954ff659714aff8b21ae8 --- ext/misc/sqlite3_stdio.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/misc/sqlite3_stdio.c b/ext/misc/sqlite3_stdio.c index 97c3551da2..be3acc665e 100644 --- a/ext/misc/sqlite3_stdio.c +++ b/ext/misc/sqlite3_stdio.c @@ -151,7 +151,7 @@ char *sqlite3_fgets(char *buf, int sz, FILE *in){ #ifndef SQLITE_USE_STDIO_FOR_CONSOLE DWORD nRead = 0; if( IsConsole(in) - && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz, &nRead, 0) + && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0) ){ b1[nRead] = 0; }else diff --git a/manifest b/manifest index a5505b6964..4ddace420a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C speedtest1:\sfurther\simprovements\sto\sthe\s"json"\stestset. -D 2025-01-16T20:46:08.022 +C Fix\sa\spotential\sone-byte\sbuffer\soverrun\swhen\sreading\sfrom\sthe\sWindows\nconsole\sin\sthe\sCLI.\s[forum:/forumpost/95e17b8f5c|Forum\spost\s95e17b8f5c]. +D 2025-01-17T10:39:04.650 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -442,7 +442,7 @@ F ext/misc/shathree.c f3a778f27bf3e71b666a77f28e463a3b931c4dbe4219447e61bb678b4b F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bcc42ef3fd29429bc01a83e751332b8d4690e65d45008449bdffe7656371487f F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 -F ext/misc/sqlite3_stdio.c 5657afb6ec81bef31790973528980af778e0e1388a93db780d33007336efe6e6 +F ext/misc/sqlite3_stdio.c 18160504b9348d0ebb9f5620fd61e64cd2d55fffde05ab3f7db03396add4840a F ext/misc/sqlite3_stdio.h f05eaf5e0258f0573910324a789a9586fc360a57678c57a6d63cfaa2245b6176 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc @@ -2205,8 +2205,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2cc73c5e08f1a16fe8accf0af6af061e42d27635883d09234516fd470e99bc0a -R f4bb93608db14b0baa099caf842aef42 +P c4750f7cf7e2188623de8b12e01acf3e3d7dc7b5ea87ac449571eb36f97d842a +R 45a83a05156d426ada8c2c9a4e3fc01c U drh -Z 1a1ead4cbc7ce98f73040d73112e92fb +Z 4047e2705a87b112269cd6828f65ee7b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 43e7b2476a..ce8658f845 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c4750f7cf7e2188623de8b12e01acf3e3d7dc7b5ea87ac449571eb36f97d842a +4d96759694c91301410f53a3f737a049c33e8b259b0954ff659714aff8b21ae8 From e0244216242601f768a211f99cef2c8f2e191473 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 Jan 2025 12:32:01 +0000 Subject: [PATCH 019/115] Add the test/speedtest.tcl script to simplify performance and size testing. FossilOrigin-Name: ad7b38672656d0336a73bb789ec83f6939fbdae81e21be68e0313006826dc294 --- manifest | 11 +- manifest.uuid | 2 +- test/speedtest.tcl | 271 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 278 insertions(+), 6 deletions(-) create mode 100755 test/speedtest.tcl diff --git a/manifest b/manifest index 4ddace420a..33319f9174 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\sone-byte\sbuffer\soverrun\swhen\sreading\sfrom\sthe\sWindows\nconsole\sin\sthe\sCLI.\s[forum:/forumpost/95e17b8f5c|Forum\spost\s95e17b8f5c]. -D 2025-01-17T10:39:04.650 +C Add\sthe\stest/speedtest.tcl\sscript\sto\ssimplify\sperformance\sand\ssize\stesting. +D 2025-01-17T12:32:01.367 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1677,6 +1677,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c +F test/speedtest.tcl 76a0959d7d16cbebae49756bbb858a3d2f1d9081e757c87cb7fea7c816d1c575 x F test/speedtest1.c 323ce0956430a5aae56ea20f502da7bea3fb62b8ed02e9b0f12ab078b2b258f5 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 @@ -2205,8 +2206,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c4750f7cf7e2188623de8b12e01acf3e3d7dc7b5ea87ac449571eb36f97d842a -R 45a83a05156d426ada8c2c9a4e3fc01c +P 4d96759694c91301410f53a3f737a049c33e8b259b0954ff659714aff8b21ae8 +R 7f163047a093ae4e315e910ea1611ab4 U drh -Z 4047e2705a87b112269cd6828f65ee7b +Z 4d5c65aabce50a5f7c599ac5c2690d5d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ce8658f845..36403859dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4d96759694c91301410f53a3f737a049c33e8b259b0954ff659714aff8b21ae8 +ad7b38672656d0336a73bb789ec83f6939fbdae81e21be68e0313006826dc294 diff --git a/test/speedtest.tcl b/test/speedtest.tcl new file mode 100755 index 0000000000..1d6cf4e9d8 --- /dev/null +++ b/test/speedtest.tcl @@ -0,0 +1,271 @@ +#!/bin/sh +# the next line restarts using tclsh \ +exec tclsh "$0" ${1+"$@"} +# +# This program runs performance testing on sqlite3.c. Usage: +set usage {USAGE: + + speedtest.tcl sqlite3.c x1.txt trunk.txt -Os -DSQLITE_ENABLE_STAT4 + | | | `-----------------------' + File to test ----' | | | + | | `- options + Output filename --------' | + `--- optional prior output to diff + +Do a cache-grind performance analysis of the sqlite3.c file named and +write the results into the output file. The ".txt" is appended to the +output file (and diff-file) name if it is not already present. If the +diff-file is specified then show a diff from the diff-file to the new +output. + +Other options include: + --dryrun Show what would happen but don't do anything + --help Show this help screen + --lean "Lean" mode. + --lookaside N SZ Lookahead uses N slots of SZ bytes each + --pagesize N Use N as the page size +} +set srcfile {} +set outfile {} +set difffile {} +set cflags {} +set cc gcc +set testset mix1 +set dryrun 0 +set speedtestflags {--shrink-memory --reprepare --stats --heap 40000000 64} +lappend speedtestflags --journal wal --size 5 + +for {set i 0} {$i<[llength $argv]} {incr i} { + set arg [lindex $argv $i] + if {[string index $arg 0]=="-"} { + switch -- $arg { + -pagesize - + --pagesize { + lappend speedtestflags --pagesize + incr i + lappend speedtestflags [lindex $argv $i] + } + -lookaside - + --lookaside { + lappend speedtestflags --lookaside + incr i + lappend speedtestflags [lindex $argv $i] + incr i + lappend speedtestflags [lindex $argv $i] + } + -lean - + --lean { + lappend cflags \ + -DSQLITE_DEFAULT_MEMSTATUS=0 \ + -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \ + -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \ + -DSQLITE_MAX_EXPR_DEPTH=1 \ + -DSQLITE_OMIT_DECLTYPE \ + -DSQLITE_OMIT_DEPRECATED \ + -DSQLITE_OMIT_PROGRESS_CALLBACK \ + -DSQLITE_OMIT_SHARED_CACHE \ + -DSQLITE_USE_ALLOCA + } + -n - + -dryrun - + --dryrun { + set dryrun 1 + } + -? - + -help - + --help { + puts $usage + exit 0 + } + default { + lappend cflags $arg + } + } + continue + } + if {[string match CC=* $arg]} { + set cc [lrange $arg 3 end] + continue + } + if {[string match *.c $arg]} { + if {$srcfile!=""} { + puts stderr "multiple source files: $srcfile $arg" + exit 1 + } + set srcfile $arg + continue + } + if {[lsearch {main cte rtree orm fp json parsenumber mix1} $arg]>=0} { + set testset $arg + continue + } + if {$outfile==""} { + set outfile $arg + continue + } + if {$difffile==""} { + set difffile $arg + continue + } + puts stderr "unknown option: \"$arg\". Use --help for more info." + exit 1 +} +if {[lsearch -glob $cflags -O*]<0} { + lappend cflags -Os +} +if {[lsearch -glob $cflags -DSQLITE_ENABLE_MEMSYS*]<0} { + lappend cflags -DSQLITE_ENABLE_MEMSYS5 +} +if {[lsearch -glob $cflags -DSQLITE_ENABLE_RTREE*]<0} { + lappend cflags -DSQLITE_ENABLE_RTREE +} +if {$srcfile==""} { + puts stderr "no sqlite3.c source file specified" + exit 1 +} +if {![file readable $srcfile]} { + puts stderr "source file \"$srcfile\" does not exist" + exit 1 +} +if {$outfile==""} { + puts stderr "no output file specified" + exit 1 +} +if {![string match *.* [file tail $outfile]]} { + append outfile .txt +} +if {$difffile!=""} { + if {![file exists $difffile]} { + if {[file exists $difffile.txt]} { + append difffile .txt + } else { + puts stderr "No such file: \"$difffile\"" + exit 1 + } + } +} + +set cccmd [list $cc -g] +lappend cccmd -I[file dir $srcfile] +lappend cccmd {*}[lsort $cflags] +lappend cccmd [file dir $argv0]/speedtest1.c +lappend cccmd $srcfile +lappend cccmd -o speedtest1 +puts $cccmd +if {!$dryrun} { + exec {*}$cccmd +} +lappend speedtestflags --testset $testset +set stcmd [list valgrind --tool=cachegrind ./speedtest1 {*}$speedtestflags] +lappend stcmd >valgrind-out.txt 2>valgrind-err.txt +puts $stcmd +if {!$dryrun} { + exec {*}$stcmd +} + +set maxmtime 0 +set cgfile {} +foreach cgout [glob -nocomplain cachegrind.out.*] { + if {[file mtime $cgout]>$maxmtime} { + set cgfile $cgout + set maxmtime [file mtime $cgfile] + } +} +if {$cgfile==""} { + puts "no cachegrind output" + exit 1 +} + +############# Process the cachegrind.out.# file ########################## +set fd [open $outfile wb] +set in [open "|cg_annotate --show=Ir --auto=yes --context=40 $cgfile" r] +set dest ! +set out(!) {} +set linenum 0 +set cntlines 0 ;# true to remember cycle counts on each line +set seenSqlite3 0 ;# true if we have seen the sqlite3.c file +while {![eof $in]} { + set line [string map {\t { }} [gets $in]] + if {[regexp {^-- Auto-annotated source: (.*)} $line all name]} { + set dest $name + if {[string match */sqlite3.c $dest]} { + set cntlines 1 + set seenSqlite3 1 + } else { + set cntlines 0 + } + } elseif {[regexp {^-- line (\d+) ------} $line all ln]} { + set line [lreplace $line 2 2 {#}] + set linenum [expr {$ln-1}] + } elseif {[regexp {^The following files chosen for } $line]} { + set dest ! + } + append out($dest) $line\n + if {$cntlines} { + incr linenum + if {[regexp {^ *([0-9,]+) } $line all x]} { + set x [string map {, {}} $x] + set cycles($linenum) $x + } + } +} +foreach x [lsort [array names out]] { + puts $fd $out($x) +} +# If the sqlite3.c file has been seen, then output a summary of the +# cycle counts for each file that went into making up sqlite3.c +# +if {$seenSqlite3} { + close $in + set in [open sqlite3.c] + set linenum 0 + set fn sqlite3.c + set pattern1 {^/\*+ Begin file ([^ ]+) \*} + set pattern2 {^/\*+ Continuing where we left off in ([^ ]+) \*} + while {![eof $in]} { + set line [gets $in] + incr linenum + if {[regexp $pattern1 $line all newfn]} { + set fn $newfn + } elseif {[regexp $pattern2 $line all newfn]} { + set fn $newfn + } elseif {[info exists cycles($linenum)]} { + incr fcycles($fn) $cycles($linenum) + } + } + close $in + puts $fd \ + {**********************************************************************} + set lx {} + set sum 0 + foreach {fn cnt} [array get fcycles] { + lappend lx [list $cnt $fn] + incr sum $cnt + } + puts $fd [format {%20s %14d %8.3f%%} TOTAL $sum 100] + foreach entry [lsort -index 0 -integer -decreasing $lx] { + foreach {cnt fn} $entry break + puts $fd [format {%20s %14d %8.3f%%} $fn $cnt [expr {$cnt*100.0/$sum}]] + } +} +puts $fd "Executable size:" +close $fd +exec size speedtest1 >>$outfile +# +# Processed cachegrind output should now be in the $outfile +############################################################################# + +if {$difffile!=""} { + set fossilcmd {fossil xdiff --tk -c 20} + lappend fossilcmd $difffile + lappend fossilcmd $outfile + lappend fossilcmd & + puts $fossilcmd + if {!$dryrun} { + exec {*}$fossilcmd + } +} else { + if {!$dryrun} { + exec open $outfile + } +} From ada34700755801e93ec8b5704caf4b9203a25151 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 Jan 2025 15:39:48 +0000 Subject: [PATCH 020/115] Improvements to the speedtest.tcl script. Add documentation on how to use the script. FossilOrigin-Name: eb3853d08141bf941193e8ecaf991191bb7fb46287818708a84018520eb1835e --- manifest | 13 ++++++------ manifest.uuid | 2 +- test/speedtest.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++ test/speedtest.tcl | 18 ++++++++++++---- 4 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 test/speedtest.md diff --git a/manifest b/manifest index 33319f9174..c97b983558 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\stest/speedtest.tcl\sscript\sto\ssimplify\sperformance\sand\ssize\stesting. -D 2025-01-17T12:32:01.367 +C Improvements\sto\sthe\sspeedtest.tcl\sscript.\s\sAdd\sdocumentation\son\show\sto\suse\sthe\nscript. +D 2025-01-17T15:39:48.918 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1677,7 +1677,8 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c -F test/speedtest.tcl 76a0959d7d16cbebae49756bbb858a3d2f1d9081e757c87cb7fea7c816d1c575 x +F test/speedtest.md 3ce32f2d60cf701381f95e1d8c916b6c57c31ae015f096224e83823f9b3a3d87 +F test/speedtest.tcl 96052cb8c5d44f69e0600e690794557f176ef99bd87cb4360080982d1f479a70 x F test/speedtest1.c 323ce0956430a5aae56ea20f502da7bea3fb62b8ed02e9b0f12ab078b2b258f5 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 @@ -2206,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4d96759694c91301410f53a3f737a049c33e8b259b0954ff659714aff8b21ae8 -R 7f163047a093ae4e315e910ea1611ab4 +P ad7b38672656d0336a73bb789ec83f6939fbdae81e21be68e0313006826dc294 +R f4c44da8ff797a58ac8642b4946994e1 U drh -Z 4d5c65aabce50a5f7c599ac5c2690d5d +Z f6ee9eb4c1425ae484e244ffbda51720 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 36403859dc..d830cfeb92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad7b38672656d0336a73bb789ec83f6939fbdae81e21be68e0313006826dc294 +eb3853d08141bf941193e8ecaf991191bb7fb46287818708a84018520eb1835e diff --git a/test/speedtest.md b/test/speedtest.md new file mode 100644 index 0000000000..0a575b6a5c --- /dev/null +++ b/test/speedtest.md @@ -0,0 +1,53 @@ +# Performance And Size Measurements + +This document shows a procedure for making performance and size +comparisons between two versions of the SQLite Amalgamation "sqlite3.c". +You will need: + + * fossil + * valgrind + * tclsh + * A script or program named "open" that brings up *.txt files in an + editor for viewing. (Macs provide this by default. You'll need to + come up with your own on Linxu and Windows.) + * An SQLite source tree + +The procedure described in this document is not the only way to make +performance and size measurements. Use this as a guide and make +adjustments as needed. + +## Establish the baseline measurement + + * Begin at the root the SQLite source tree + * mkdir -p ../speed
+ ↑ Speed measurement output files will go into this directory. + You can actually put those files wherever you want. This is just a + suggestion. It might be good to keep these files outside of the + source tree so that "fossil clean" does not delete them. + * Obtain the baseline SQLite amalgamation. For the purpose of this + technical not, assume the baseline SQLite sources are in files + "../baseline/sqlite3.c" and "../baseline/sqlite3.h". + * test/speedtest.tcl ../baseline/sqlite3.c ../speed/baseline.txt
+ ↑ The performance measure will be written into ../speed/baseline.txt + and that file will be brought up in an editor for easy viewing.
+ ↑ The "sqlite3.h" will be taken from the directory that contains + the "sqlite3.c" amalgamation file. + +## Comparing the current checkout against the baseline + + * make sqlite3.c + * test/speedtest.tcl sqlite3.c ../speed/test.txt ../speed/baseline.txt
+ ↑ Test results written into ../speed/test.txt and then + "fossil xdiff" is run to compare ../speed/baseline.txt against + the new test results. + +## When to do this + +Performance and size checks should be done prior to trunk check-ins. +Sometimes a seemingly innocuous change can have large performance +impacts. A large impact does not mean that the change cannot continue, +but it is important to be aware of the impact. + +## Additional hints + +Use the --help option to test/speedtest.tcl to see other available options. diff --git a/test/speedtest.tcl b/test/speedtest.tcl index 1d6cf4e9d8..b353077e7c 100755 --- a/test/speedtest.tcl +++ b/test/speedtest.tcl @@ -19,11 +19,16 @@ diff-file is specified then show a diff from the diff-file to the new output. Other options include: - --dryrun Show what would happen but don't do anything - --help Show this help screen + CC=... Specify an alternative C compiler. Default is "gcc". + -D... -D and -O options are passed through to the C compiler. + --dryrun Show what would happen but don't do anything. + --help Show this help screen. --lean "Lean" mode. - --lookaside N SZ Lookahead uses N slots of SZ bytes each - --pagesize N Use N as the page size + --lookaside N SZ Lookahead uses N slots of SZ bytes each. + --pagesize N Use N as the page size. + --testset TEST Specify the specific testset to use. The default + is "mix1". Other options include: "main", "json", + "cte", "orm", "fp", "rtree". } set srcfile {} set outfile {} @@ -66,6 +71,11 @@ for {set i 0} {$i<[llength $argv]} {incr i} { -DSQLITE_OMIT_SHARED_CACHE \ -DSQLITE_USE_ALLOCA } + -testset - + --testset { + incr i + set testset [lindex $argv $i] + } -n - -dryrun - --dryrun { From 0887b702863ab085dff6396bbc57039083cd117b Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 17 Jan 2025 15:56:16 +0000 Subject: [PATCH 021/115] Typo fix in speedtest.md. FossilOrigin-Name: 36027cf340fe2e351c63129d069f9bced090c4a028ffd78d5b8c0f418ad9f230 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/speedtest.md | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c97b983558..393700dac9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sspeedtest.tcl\sscript.\s\sAdd\sdocumentation\son\show\sto\suse\sthe\nscript. -D 2025-01-17T15:39:48.918 +C Typo\sfix\sin\sspeedtest.md. +D 2025-01-17T15:56:16.503 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1677,7 +1677,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c -F test/speedtest.md 3ce32f2d60cf701381f95e1d8c916b6c57c31ae015f096224e83823f9b3a3d87 +F test/speedtest.md e4f467683acfdb2834ca1d6ce209c3d883dfecf73c41f77234b2368be9579de2 F test/speedtest.tcl 96052cb8c5d44f69e0600e690794557f176ef99bd87cb4360080982d1f479a70 x F test/speedtest1.c 323ce0956430a5aae56ea20f502da7bea3fb62b8ed02e9b0f12ab078b2b258f5 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ad7b38672656d0336a73bb789ec83f6939fbdae81e21be68e0313006826dc294 -R f4c44da8ff797a58ac8642b4946994e1 -U drh -Z f6ee9eb4c1425ae484e244ffbda51720 +P eb3853d08141bf941193e8ecaf991191bb7fb46287818708a84018520eb1835e +R ffaa647250f944a4e334209019949953 +U stephan +Z 0892513d03b81f8f5fa790c99efdef39 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d830cfeb92..c4119bbbab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb3853d08141bf941193e8ecaf991191bb7fb46287818708a84018520eb1835e +36027cf340fe2e351c63129d069f9bced090c4a028ffd78d5b8c0f418ad9f230 diff --git a/test/speedtest.md b/test/speedtest.md index 0a575b6a5c..645742d756 100644 --- a/test/speedtest.md +++ b/test/speedtest.md @@ -25,7 +25,7 @@ adjustments as needed. suggestion. It might be good to keep these files outside of the source tree so that "fossil clean" does not delete them. * Obtain the baseline SQLite amalgamation. For the purpose of this - technical not, assume the baseline SQLite sources are in files + technical note, assume the baseline SQLite sources are in files "../baseline/sqlite3.c" and "../baseline/sqlite3.h". * test/speedtest.tcl ../baseline/sqlite3.c ../speed/baseline.txt
↑ The performance measure will be written into ../speed/baseline.txt From f462046cd14511ccfd8d819050fb2b18e5a11f61 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 Jan 2025 17:09:42 +0000 Subject: [PATCH 022/115] Enhance a comment on a test case to add recent context. FossilOrigin-Name: c2647d1bd16fd46dd03953afee6cad44ce14fa2c36713c487b678d63660bc072 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/with6.test | 6 ++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 393700dac9..48e8749eee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Typo\sfix\sin\sspeedtest.md. -D 2025-01-17T15:56:16.503 +C Enhance\sa\scomment\son\sa\stest\scase\sto\sadd\srecent\scontext. +D 2025-01-17T17:09:42.305 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -2090,7 +2090,7 @@ F test/with2.test 181674a6cc86a601ca2ac052741cdfad5b529e07e870435d2f6cdb92d589ff F test/with3.test e30369ea27aa27eb1bda4c5e510c8a9f782c8afd2ab99d1a02b8a7f25a5d3e65 F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205 F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8 -F test/with6.test 9ff3503c3ff7cd459dc4852a02aaefa998dccace53f4142a0eb726174ad5984a +F test/with6.test 281e4861b5e517f6c3c2f08517a520c1e2ee7c11966545d3901f258a4fe8ef76 F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64 F test/without_rowid1.test a5210b8770dc4736bca4e74bc96588f43025ad03ad6a80f885afd36d9890e217 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99 @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P eb3853d08141bf941193e8ecaf991191bb7fb46287818708a84018520eb1835e -R ffaa647250f944a4e334209019949953 -U stephan -Z 0892513d03b81f8f5fa790c99efdef39 +P 36027cf340fe2e351c63129d069f9bced090c4a028ffd78d5b8c0f418ad9f230 +R ef3d991b9c054b173fa221e38e326aa0 +U drh +Z 0b63cd7bd279966e11ae3eece17abfb9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c4119bbbab..e9d77082b4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -36027cf340fe2e351c63129d069f9bced090c4a028ffd78d5b8c0f418ad9f230 +c2647d1bd16fd46dd03953afee6cad44ce14fa2c36713c487b678d63660bc072 diff --git a/test/with6.test b/test/with6.test index 95e6305474..b95ec0b763 100644 --- a/test/with6.test +++ b/test/with6.test @@ -325,6 +325,12 @@ do_eqp_test 331 { # marked with M10d_Yes and hence prohibited from participating in the # query flattening optimization. # +# Updated 2025-01-02. +# https://sqlite.org/forum/forumpost/8f38fc9878a92aa9 +# +# The same optimization that made Grunthos's query fast made +# Jean-Noël Mayor's query slow. Bummer. +# reset_db db eval { CREATE TABLE raw(country,date,total,delta, UNIQUE(country,date)); From e432f2a316d281f6f4de268483fd113606ed14a7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 Jan 2025 23:49:40 +0000 Subject: [PATCH 023/115] For the purpose of the query planner heuristic added by [38db9b5c83], a query should only count as a star query if the fact tables are connected to the dimension table by an INNER JOIN. If a LEFT JOIN is used, then the fact tables are constrained to be in inner loops anyhow and so the heuristic does not make any sense. But it does interfere with AUTOMATIC index creation, which causes the performance regression reported by [forum:/forumpost/d87570a145599033|forum post d87570a1455]. FossilOrigin-Name: 0852c57ee2768224af79910e6f26e70a4962651dae0f8b45cbfc847e6707d7bb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 13 +++++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 48e8749eee..ddf6529f37 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sa\scomment\son\sa\stest\scase\sto\sadd\srecent\scontext. -D 2025-01-17T17:09:42.305 +C For\sthe\spurpose\sof\sthe\squery\splanner\sheuristic\sadded\sby\s[38db9b5c83],\sa\squery\nshould\sonly\scount\sas\sa\sstar\squery\sif\sthe\sfact\stables\sare\sconnected\sto\sthe\ndimension\stable\sby\san\sINNER\sJOIN.\s\sIf\sa\sLEFT\sJOIN\sis\sused,\sthen\sthe\sfact\ntables\sare\sconstrained\sto\sbe\sin\sinner\sloops\sanyhow\sand\sso\sthe\sheuristic\sdoes\nnot\smake\sany\ssense.\s\sBut\sit\sdoes\sinterfere\swith\sAUTOMATIC\sindex\screation,\swhich\ncauses\sthe\sperformance\sregression\sreported\sby\n[forum:/forumpost/d87570a145599033|forum\spost\sd87570a1455]. +D 2025-01-17T23:49:40.018 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -862,7 +862,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c f081a371086f48201948431832f5e9bb1bf6c930397b8d7bcf8aaa9e21d819da +F src/where.c 7aa91f806d19d254d47763564e355cca50d1787d93fc0a62c7d5361d8dfbce70 F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 36027cf340fe2e351c63129d069f9bced090c4a028ffd78d5b8c0f418ad9f230 -R ef3d991b9c054b173fa221e38e326aa0 +P c2647d1bd16fd46dd03953afee6cad44ce14fa2c36713c487b678d63660bc072 +R 93d684fb6b94ab6c95c7721a922c90f7 U drh -Z 0b63cd7bd279966e11ae3eece17abfb9 +Z 89119702900b9ccbb1fc6836bf36a009 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e9d77082b4..f763ea63a8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c2647d1bd16fd46dd03953afee6cad44ce14fa2c36713c487b678d63660bc072 +0852c57ee2768224af79910e6f26e70a4962651dae0f8b45cbfc847e6707d7bb diff --git a/src/where.c b/src/where.c index 05dab8fdd5..b3f177fb40 100644 --- a/src/where.c +++ b/src/where.c @@ -5427,9 +5427,10 @@ static LogEst whereSortingCost( ** 12 otherwise ** ** For the purposes of SQLite, a star-query is defined as a query -** with a large central table that is joined against four or more -** smaller tables. The central table is called the "fact" table. -** The smaller tables that get joined are "dimension tables". +** with a large central table that is joined (using an INNER JOIN, +** not a LEFT JOIN) against four or more smaller tables. The central +** table is called the "fact" table. The smaller tables that get +** joined are "dimension tables". ** ** SIDE EFFECT: (and really the whole point of this subroutine) ** @@ -5457,7 +5458,11 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ LogEst rDelta; /* Heuristic cost adjustment */ Bitmask mSeen = 0; /* Mask of dimension tables */ for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ - if( (pWLoop->prereq & m)!=0 && (pWLoop->maskSelf & mSeen)==0 ){ + if( (pWLoop->prereq & m)!=0 /* pWInfo depends on iLoop */ + && (pWLoop->maskSelf & mSeen)==0 /* pWInfo not already a dependency */ + && (pWInfo->pTabList->a[pWLoop->iTab].fg.jointype & JT_LEFT)==0 + /* ^- pWInfo isn't a LEFT JOIN */ + ){ nDep++; mSeen |= pWLoop->maskSelf; } From e52cdadea7b9978d75bc9d8733409f8cdea2ce0b Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 18 Jan 2025 13:51:01 +0000 Subject: [PATCH 024/115] When running make install, avoid the -s (strip) flag when cross-compiling, as it only works for the build platform. Reported in [forum:9a67df63eda9925c|forum post 9a67df63eda9925c]. FossilOrigin-Name: 230e49c10e3aa6fe9c487a1e026016a8bf97f7e736e7477d5976d987da5e83cf --- Makefile.in | 1 + auto.def | 6 +++++- main.mk | 11 +++++++++-- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Makefile.in b/Makefile.in index 5b17c0e426..5fff3d2fc5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -335,4 +335,5 @@ distclean: distclean-autosetup version-info$(T.exe): $(TOP)/tool/version-info.c Makefile sqlite3.h $(T.link) $(ST_OPT) -o $@ $(TOP)/tool/version-info.c +IS_CROSS_COMPILING = @IS_CROSS_COMPILING@ include $(TOP)/main.mk diff --git a/auto.def b/auto.def index c9aa0cb9d1..8c7599c032 100644 --- a/auto.def +++ b/auto.def @@ -475,7 +475,6 @@ apply {{} { } switch -exact -- $soname { none - "" { return 0 } - auto { set soname libsqlite3.so.3 } legacy { set soname libsqlite3.so.0 } default { if {[string match libsqlite3.* $soname]} { @@ -1356,6 +1355,11 @@ apply {{} { unset oFF }} +######################################################################## +# When cross-compiling, we have to avoid using the -s flag to +# /usr/bin/install: https://sqlite.org/forum/forumpost/9a67df63eda9925c +define IS_CROSS_COMPILING $isCrossCompiling + ######################################################################## # "Re-export" the autoconf-conventional --XYZdir flags into something # which is more easily overridable from a make invocation. See the docs diff --git a/main.mk b/main.mk index a0b08e5773..d83c39b3a9 100644 --- a/main.mk +++ b/main.mk @@ -351,6 +351,13 @@ T.cc += $(OPTS) INSTALL.noexec = $(INSTALL) -m 0644 # ^^^ do not use GNU-specific flags to $(INSTALL), e.g. --mode=... +# When cross-compiling, we need to avoid the -s flag because it only +# works on the build host's platform. +INSTALL.strip.1 = $(INSTALL) +INSTALL.strip.0 = $(INSTALL) -s +INSTALL.strip. = $(INSTALL.strip.0) +INSTALL.strip = $(INSTALL.strip.$(IS_CROSS_COMPILING)) + # # $(T.compile) = generic target platform compiler invocation, # differing only from $(T.cc) in that it appends $(T.compile.extras), @@ -2017,7 +2024,7 @@ sqlite3d$(T.exe): shell.c $(LIBOBJS0) $(LDFLAGS.libsqlite3) $(LDFLAGS.readline) install-shell-0: sqlite3$(T.exe) $(install-dir.bin) - $(INSTALL) -s sqlite3$(T.exe) "$(install-dir.bin)" + $(INSTALL.strip) sqlite3$(T.exe) "$(install-dir.bin)" install-shell-1: install: install-shell-$(HAVE_WASI_SDK) @@ -2031,7 +2038,7 @@ sqldiff$(T.exe): $(sqldiff.$(LINK_TOOLS_DYNAMICALLY).deps) $(sqldiff.$(LINK_TOOLS_DYNAMICALLY).rules) install-diff: sqldiff$(T.exe) $(install-dir.bin) - $(INSTALL) -s sqldiff$(T.exe) "$(install-dir.bin)" + $(INSTALL.strip) sqldiff$(T.exe) "$(install-dir.bin)" #install: install-diff dbhash$(T.exe): $(TOP)/tool/dbhash.c sqlite3.o sqlite3.h diff --git a/manifest b/manifest index ddf6529f37..e7d438afbf 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C For\sthe\spurpose\sof\sthe\squery\splanner\sheuristic\sadded\sby\s[38db9b5c83],\sa\squery\nshould\sonly\scount\sas\sa\sstar\squery\sif\sthe\sfact\stables\sare\sconnected\sto\sthe\ndimension\stable\sby\san\sINNER\sJOIN.\s\sIf\sa\sLEFT\sJOIN\sis\sused,\sthen\sthe\sfact\ntables\sare\sconstrained\sto\sbe\sin\sinner\sloops\sanyhow\sand\sso\sthe\sheuristic\sdoes\nnot\smake\sany\ssense.\s\sBut\sit\sdoes\sinterfere\swith\sAUTOMATIC\sindex\screation,\swhich\ncauses\sthe\sperformance\sregression\sreported\sby\n[forum:/forumpost/d87570a145599033|forum\spost\sd87570a1455]. -D 2025-01-17T23:49:40.018 +C When\srunning\smake\sinstall,\savoid\sthe\s-s\s(strip)\sflag\swhen\scross-compiling,\sas\sit\sonly\sworks\sfor\sthe\sbuild\splatform.\sReported\sin\s[forum:9a67df63eda9925c|forum\spost\s9a67df63eda9925c]. +D 2025-01-18T13:51:01.877 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d -F Makefile.in ad349acf91b3569033439fe498fa197aa530cafaa01362eb7daad2f84e43d265 +F Makefile.in 572271a39d7ac1ae228ed911c63fdf374300a6a880ceb851b1f3d357e9a9534e F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0 F Makefile.msc 39785ec45f9ae0311e49094eff2ee079562246fed6be3b9f632a99d4df20056a F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -14,7 +14,7 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 -F auto.def 63dfbbc58b041d1c5c516f31a02679cce8d79123c89ad87fd2783f4ef26dedbb +F auto.def b8135ba11ec23857bc76469f8b447c43fcfeecc9c775179107392e18ebe8c740 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac @@ -700,7 +700,7 @@ F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65a F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 F ext/wasm/wasmfs.make bc8bb227f35d5bd3863a7bd2233437c37472a0d81585979f058f9b9b503bef35 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 0b62344246f8a3e920edb8a52b0c3296dde829d7eb450f67b89c63d79536de85 +F main.mk a187ada134ccb55b5d59ea3eb8f71cc6b19bfc244689e24a729f7a64aa500dc3 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c2647d1bd16fd46dd03953afee6cad44ce14fa2c36713c487b678d63660bc072 -R 93d684fb6b94ab6c95c7721a922c90f7 -U drh -Z 89119702900b9ccbb1fc6836bf36a009 +P 0852c57ee2768224af79910e6f26e70a4962651dae0f8b45cbfc847e6707d7bb +R ed0f0a3d6dea2dbb296ffb05bcf1dd67 +U stephan +Z b7991c6ad22e45c5f184f51dda631f10 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f763ea63a8..dbbf089777 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0852c57ee2768224af79910e6f26e70a4962651dae0f8b45cbfc847e6707d7bb +230e49c10e3aa6fe9c487a1e026016a8bf97f7e736e7477d5976d987da5e83cf From 1a1fe1d1da294f2b4f48c3212852151bb10688c6 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 18 Jan 2025 16:05:38 +0000 Subject: [PATCH 025/115] When cross-compiling, change the CFLAGS default to exclude -g, per /chat discussion prompted by [forum:9a67df63eda9925c|forum post 9a67df63eda9925c]. FossilOrigin-Name: 4309da2ca5cb99ea81f3034ae3c5809187c0131d21f9f9469ea0d69c941f393e --- auto.def | 14 +++++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/auto.def b/auto.def index 8c7599c032..b4a54111b9 100644 --- a/auto.def +++ b/auto.def @@ -325,8 +325,18 @@ if {"" eq [proj-bin-define install]} { # compiling binaries for the target system (CC a.k.a. $(T.cc)). # Normally they're the same, but they will differ when # cross-compiling. -define CFLAGS [proj-get-env CFLAGS {-g -O2}] +# +# When cross-compiling we default to not using the -g flag, based on a +# /chat discussion prompted by +# https://sqlite.org/forum/forumpost/9a67df63eda9925c +set defaultCFlags {-O2} +if {!$isCrossCompiling} { + lappend defaultCFlags -g +} +define CFLAGS [proj-get-env CFLAGS $defaultCFlags] +# BUILD_CFLAGS is the CFLAGS for CC_FOR_BUILD. define BUILD_CFLAGS [proj-get-env BUILD_CFLAGS {-g}] +unset defaultCFlags proj-if-opt-truthy dev { # --enable-dev needs to come early so that the downstream tests @@ -335,6 +345,8 @@ proj-if-opt-truthy dev { proj-opt-set debug 1 proj-opt-set amalgamation 0 define CFLAGS [get-env CFLAGS {-O0 -g}] + # -------------^^^^^^^ intentionally using [get-env] instead of + # [proj-get-env] here. } ######################################################################## diff --git a/manifest b/manifest index e7d438afbf..141c4d0b23 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\srunning\smake\sinstall,\savoid\sthe\s-s\s(strip)\sflag\swhen\scross-compiling,\sas\sit\sonly\sworks\sfor\sthe\sbuild\splatform.\sReported\sin\s[forum:9a67df63eda9925c|forum\spost\s9a67df63eda9925c]. -D 2025-01-18T13:51:01.877 +C When\scross-compiling,\schange\sthe\sCFLAGS\sdefault\sto\sexclude\s-g,\sper\s/chat\sdiscussion\sprompted\sby\s[forum:9a67df63eda9925c|forum\spost\s9a67df63eda9925c]. +D 2025-01-18T16:05:38.256 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -14,7 +14,7 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 -F auto.def b8135ba11ec23857bc76469f8b447c43fcfeecc9c775179107392e18ebe8c740 +F auto.def 20ddd61060516e29cb984d716c451ad6e7e3ebe1d3786ec8f70813fada06eb2f F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0852c57ee2768224af79910e6f26e70a4962651dae0f8b45cbfc847e6707d7bb -R ed0f0a3d6dea2dbb296ffb05bcf1dd67 +P 230e49c10e3aa6fe9c487a1e026016a8bf97f7e736e7477d5976d987da5e83cf +R 862143f3cdd830dae6969328bc86fd10 U stephan -Z b7991c6ad22e45c5f184f51dda631f10 +Z 5e9420f0d3ea15cbb564de8d4adc7b33 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dbbf089777..94ceeec9f2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -230e49c10e3aa6fe9c487a1e026016a8bf97f7e736e7477d5976d987da5e83cf +4309da2ca5cb99ea81f3034ae3c5809187c0131d21f9f9469ea0d69c941f393e From 50c44200300f77e5415e8fe8c3475d53830a9ff2 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 18 Jan 2025 21:00:19 +0000 Subject: [PATCH 026/115] Add support for automatic query-time indexes on WITHOUT ROWID tables. FossilOrigin-Name: 89c4cbd9529081941d7283a401c4a8d71b241f4577ebf6d3eb2ebe5a1cf92f2e --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/where.c | 23 +++++++++++++++++++---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index e7d438afbf..dbd4e38927 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\srunning\smake\sinstall,\savoid\sthe\s-s\s(strip)\sflag\swhen\scross-compiling,\sas\sit\sonly\sworks\sfor\sthe\sbuild\splatform.\sReported\sin\s[forum:9a67df63eda9925c|forum\spost\s9a67df63eda9925c]. -D 2025-01-18T13:51:01.877 +C Add\ssupport\sfor\sautomatic\squery-time\sindexes\son\sWITHOUT\sROWID\stables. +D 2025-01-18T21:00:19.369 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -862,7 +862,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 7aa91f806d19d254d47763564e355cca50d1787d93fc0a62c7d5361d8dfbce70 +F src/where.c b09334881ab87dfdb1d2dbc71a8cf97f345834d36509344207a133f0e6b86161 F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2207,8 +2207,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0852c57ee2768224af79910e6f26e70a4962651dae0f8b45cbfc847e6707d7bb -R ed0f0a3d6dea2dbb296ffb05bcf1dd67 -U stephan -Z b7991c6ad22e45c5f184f51dda631f10 +P 230e49c10e3aa6fe9c487a1e026016a8bf97f7e736e7477d5976d987da5e83cf +R 1eb7d22a051c22dd4afc1e0246916027 +T *branch * without-rowid-autoidx +T *sym-without-rowid-autoidx * +T -sym-trunk * +U drh +Z eca129c2aba163fe6547f234a58ed149 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dbbf089777..d320276785 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -230e49c10e3aa6fe9c487a1e026016a8bf97f7e736e7477d5976d987da5e83cf +89c4cbd9529081941d7283a401c4a8d71b241f4577ebf6d3eb2ebe5a1cf92f2e diff --git a/src/where.c b/src/where.c index b3f177fb40..8af00b96a3 100644 --- a/src/where.c +++ b/src/where.c @@ -1080,6 +1080,19 @@ static SQLITE_NOINLINE void constructAutomaticIndex( }else{ extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1)); } + if( !HasRowid(pTable) ){ + /* For WITHOUT ROWID tables, ensure that all PRIMARY KEY columns are + ** either in the idxCols mask or in the extraCols mask */ + for(i=0; inCol; i++){ + if( (pTable->aCol[i].colFlags & COLFLAG_PRIMKEY)==0 ) continue; + if( i>=BMS-1 ){ + extraCols |= MASKBIT(BMS-1); + break; + } + if( idxCols & MASKBIT(i) ) continue; + extraCols |= MASKBIT(i); + } + } mxBitCol = MIN(BMS-1,pTable->nCol); testcase( pTable->nCol==BMS-1 ); testcase( pTable->nCol==BMS-2 ); @@ -1091,7 +1104,8 @@ static SQLITE_NOINLINE void constructAutomaticIndex( } /* Construct the Index object to describe this index */ - pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed); + pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+HasRowid(pTable), + 0, &zNotUsed); if( pIdx==0 ) goto end_auto_index_create; pLoop->u.btree.pIndex = pIdx; pIdx->zName = "auto-index"; @@ -1147,8 +1161,10 @@ static SQLITE_NOINLINE void constructAutomaticIndex( } } assert( n==nKeyCol ); - pIdx->aiColumn[n] = XN_ROWID; - pIdx->azColl[n] = sqlite3StrBINARY; + if( HasRowid(pTable) ){ + pIdx->aiColumn[n] = XN_ROWID; + pIdx->azColl[n] = sqlite3StrBINARY; + } /* Create the automatic index */ explainAutomaticIndex(pParse, pIdx, pPartial!=0, &addrExp); @@ -3923,7 +3939,6 @@ static int whereLoopAddBtree( && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 && !pSrc->fg.isIndexedBy /* Has no INDEXED BY clause */ && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */ - && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */ && !pSrc->fg.isCorrelated /* Not a correlated subquery */ && !pSrc->fg.isRecursive /* Not a recursive common table expression. */ && (pSrc->fg.jointype & JT_RIGHT)==0 /* Not the right tab of a RIGHT JOIN */ From 0f4de9bf9deabc2246fc9f076c22e83322a339b0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 18 Jan 2025 21:19:02 +0000 Subject: [PATCH 027/115] Add a simple test case (many more are coming soon to TH3). Fix an obsolete assert(). FossilOrigin-Name: aa829a131a3431791083cf60d9cf00e7b3c0fafdd39a23e761b629a2287ab875 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/where.c | 2 +- test/autoindex1.test | 28 ++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index dbd4e38927..acd3f5611e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sautomatic\squery-time\sindexes\son\sWITHOUT\sROWID\stables. -D 2025-01-18T21:00:19.369 +C Add\sa\ssimple\stest\scase\s(many\smore\sare\scoming\ssoon\sto\sTH3).\s\sFix\san\sobsolete\nassert(). +D 2025-01-18T21:19:02.129 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -862,7 +862,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c b09334881ab87dfdb1d2dbc71a8cf97f345834d36509344207a133f0e6b86161 +F src/where.c 521472bb0c7cfdd65a9b5b92d44f921e3e0a26a1996cc0416cf53e25301820d2 F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -925,7 +925,7 @@ F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1 F test/auth3.test 76d20a7fa136d63bcfcf8bcb65c0b1455ed71078d81f22bcd0550d3eb18594ab F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec F test/autoinc.test 997d6f185f138229dc4251583a1d04816423dddc2fc034871a01aeb1d728cb39 -F test/autoindex1.test 714cac6e60beeb5a26ed346dd46505ba60b5a5597e9122c9ed3a55f89a922aa4 +F test/autoindex1.test 65931519206bbec71948b11e125af0656435a0937973fe5fed70d776a712911f F test/autoindex2.test 12ef578928102baaa0dc23ad397601a2f4ecb0df F test/autoindex3.test ca502c8050166ac6107a7b4fe4e951f4d3270a23a958af02b14f1b962b83c4b6 F test/autoindex4.test 3c2105e9172920e26f950ba3c5823e4972190e022c1e6f260ba476b0af24c593 @@ -2207,11 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 230e49c10e3aa6fe9c487a1e026016a8bf97f7e736e7477d5976d987da5e83cf -R 1eb7d22a051c22dd4afc1e0246916027 -T *branch * without-rowid-autoidx -T *sym-without-rowid-autoidx * -T -sym-trunk * +P 89c4cbd9529081941d7283a401c4a8d71b241f4577ebf6d3eb2ebe5a1cf92f2e +R 060bc82586424a9cc221e972d5251271 U drh -Z eca129c2aba163fe6547f234a58ed149 +Z 18819fcf6e705c7a88ab29e3c059c242 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d320276785..1691c3d936 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -89c4cbd9529081941d7283a401c4a8d71b241f4577ebf6d3eb2ebe5a1cf92f2e +aa829a131a3431791083cf60d9cf00e7b3c0fafdd39a23e761b629a2287ab875 diff --git a/src/where.c b/src/where.c index 8af00b96a3..b867e615f7 100644 --- a/src/where.c +++ b/src/where.c @@ -949,7 +949,7 @@ static void explainAutomaticIndex( sqlite3_str *pStr = sqlite3_str_new(pParse->db); sqlite3_str_appendf(pStr,"CREATE AUTOMATIC INDEX ON %s(", pTab->zName); assert( pIdx->nColumn>1 ); - assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID ); + assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID || !HasRowid(pTab) ); for(ii=0; ii<(pIdx->nColumn-1); ii++){ const char *zName = 0; int iCol = pIdx->aiColumn[ii]; diff --git a/test/autoindex1.test b/test/autoindex1.test index b294a2721f..1c8ce007f0 100644 --- a/test/autoindex1.test +++ b/test/autoindex1.test @@ -563,4 +563,32 @@ do_execsql_test autoindex-1120 { SELECT * FROM t1 LEFT JOIN t2 ON (t2.c=+t1.a) LEFT JOIN t3 ON (t2.d IS NULL); } {1 1 1 2 {} {}} +# 2025-01-18 +# Added support for automatic indexes on WITHOUT ROWID tables. +# +reset_db +do_execsql_test autoindex-1200 { + CREATE TABLE t1(a INT, b INT, x INT, PRIMARY KEY(a,b)) WITHOUT ROWID; + INSERT INTO t1 VALUES(1,2,90),(1,3,91),(1,4,92); + CREATE TABLE t2a(c INTEGER PRIMARY KEY, i1 INT); + CREATE TABLE t2b(i1 INTEGER PRIMARY KEY, d INT); + CREATE VIEW t2(c,d) AS SELECT c, d FROM t2a NATURAL JOIN t2b; + INSERT INTO t2a VALUES(3,93),(4,94),(5,95),(6,96),(7,97); + INSERT INTO t2b VALUES(91,11),(92,22),(93,33),(94,44),(95,55); + CREATE TABLE dual(dummy TEXT); + INSERT INTO dual(dummy) VALUES('x'); +} +db null NULL +do_execsql_test autoindex-1210 { + SELECT t1.*, t2.* FROM t2 LEFT OUTER JOIN t1 ON b=c ORDER BY +b; +} { + NULL NULL NULL 5 55 + 1 3 91 3 33 + 1 4 92 4 44 +} +do_execsql_test autoindex-1211 { + EXPLAIN QUERY PLAN + SELECT t1.*, t2.* FROM t2 LEFT OUTER JOIN t1 ON b=c ORDER BY +b; +} {/SEARCH t1 USING AUTOMATIC COVERING INDEX/} + finish_test From 6cd83aecb944636fe5bcf1f4335aec016524e3a8 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 19 Jan 2025 14:53:45 +0000 Subject: [PATCH 028/115] Move some of the auto.def functions into autosetup/sqlite-config.tcl for re-use in the pending migration of the autoconf bundle to autosetup. This is just reorg, no functional changes. FossilOrigin-Name: 2f1e94994f3595baad4045ab05ffee0668059c23ab37a39c25b83c62bfbaea28 --- auto.def | 492 ++--------------------------------- autosetup/sqlite-config.tcl | 505 ++++++++++++++++++++++++++++++++++++ manifest | 16 +- manifest.uuid | 2 +- 4 files changed, 529 insertions(+), 486 deletions(-) create mode 100644 autosetup/sqlite-config.tcl diff --git a/auto.def b/auto.def index b4a54111b9..8ee102dc8a 100644 --- a/auto.def +++ b/auto.def @@ -12,7 +12,7 @@ # # JimTCL: https://jim.tcl.tk # -use cc cc-db cc-shared cc-lib proj pkg-config +use sqlite-config # $DUMP_DEFINES_TXT is the file emitted by --dump-defines, intended # only for build debugging and not part of the public build interface. @@ -220,16 +220,7 @@ if {"" ne $DUMP_DEFINES_JSON} { options [subst -nobackslashes -nocommands $flags] unset flags - -# -# Carry values from hidden --flag aliases over to their canonical flag -# forms. -# -proj-xfer-options-aliases { - with-readline-inc => with-readline-cflags - with-readline-lib => with-readline-ldflags - with-debug => debug -} +sqlite-post-options-init set srcdir $::autosetup(srcdir) set PACKAGE_VERSION [proj-file-content -trim $srcdir/VERSION] @@ -242,56 +233,6 @@ msg-result "Source dir = $srcdir" msg-result "Build dir = $::autosetup(builddir)" msg-result "Configuring SQLite version $PACKAGE_VERSION" -apply {{} { - # - # SQLITE_AUTORECONFIG contains make target rules for re-running the - # configure script with the same arguments it was initially invoked - # with. This can be used to automatically reconfigure - # - proc squote {arg} { - # Wrap $arg in single-quotes if it looks like it might need that - # to avoid mis-handling as a shell argument. We assume that $arg - # will never contain any single-quote characters. - if {[string match {*[ &;$*"]*} $arg]} { return '$arg' } - return $arg - } - define-append SQLITE_AUTORECONFIG cd [squote $::autosetup(builddir)] && [squote $::srcdir/configure] - #{*}$::autosetup(argv) breaks with --flag='val with spaces', so... - foreach arg $::autosetup(argv) { - define-append SQLITE_AUTORECONFIG [squote $arg] - } - rename squote "" -}} - -# Are we cross-compiling? -set isCrossCompiling [proj-is-cross-compiling] - -define OPT_FEATURE_FLAGS {} ; # -DSQLITE_OMIT/ENABLE flags. -define OPT_SHELL {} ; # Feature-related CFLAGS for the sqlite3 CLI app -######################################################################## -# Adds $args, if not empty, to OPT_FEATURE_FLAGS. If the first arg is -# -shell then it strips that arg and passes the remaining args the -# sqlite-add-shell-opt in addition to adding them to -# OPT_FEATURE_FLAGS. -proc sqlite-add-feature-flag {args} { - set shell "" - if {"-shell" eq [lindex $args 0]} { - set args [lassign $args shell] - } - if {"" ne $args} { - if {"" ne $shell} { - sqlite-add-shell-opt {*}$args - } - define-append OPT_FEATURE_FLAGS {*}$args - } -} -# Appends $args, if not empty, to OPT_SHELL. -proc sqlite-add-shell-opt {args} { - if {"" ne $args} { - define-append OPT_SHELL {*}$args - } -} - # Pass msg-debug=1 to configure to enable obnoxiously loud output from # msg-debug. set msgDebugEnabled [proj-val-truthy [get-env msg-debug 0]] @@ -330,7 +271,7 @@ if {"" eq [proj-bin-define install]} { # /chat discussion prompted by # https://sqlite.org/forum/forumpost/9a67df63eda9925c set defaultCFlags {-O2} -if {!$isCrossCompiling} { +if {!$sqliteIsCrossCompiling} { lappend defaultCFlags -g } define CFLAGS [proj-get-env CFLAGS $defaultCFlags] @@ -359,7 +300,7 @@ proc sqlite-check-wasi-sdk {} { define HAVE_WASI_SDK 0 if {$wasiSdkDir eq ""} { return 0 - } elseif {$::isCrossCompiling} { + } elseif {$::sqliteIsCrossCompiling} { proj-fatal "Cannot combine --with-wasi-sdk with cross-compilation" } msg-result "Checking WASI SDK directory \[$wasiSdkDir]... " @@ -402,8 +343,8 @@ proc sqlite-check-wasi-sdk {} { } } # Remember that we now have a discrepancy beteween - # $::isCrossCompiling and [proj-is-cross-compiling]. - set ::isCrossCompiling 1 + # $::sqliteIsCrossCompiling and [proj-is-cross-compiling]. + set ::sqliteIsCrossCompiling 1 # # Changing --host and --target have no effect here except to @@ -471,45 +412,6 @@ if {[cc-check-includes zlib.h] && [proj-check-function-in-lib deflate z]} { proj-check-rpath ; # Determine proper rpath-handling flag -######################################################################## -# "soname" for libsqlite3.so. See discussion at: -# https://sqlite.org/src/forumpost/5a3b44f510df8ded -apply {{} { - define LDFLAGS_LIBSQLITE3_SONAME "" - if {[proj-opt-was-provided soname]} { - set soname [join [opt-val soname] ""] - } else { - # Enabling soname breaks linking for the --dynlink-tools feature, - # and this project has no direct use for soname, so default to - # none. Package maintainers, on the other hand, like to have an - # soname. - set soname none - } - switch -exact -- $soname { - none - "" { return 0 } - legacy { set soname libsqlite3.so.0 } - default { - if {[string match libsqlite3.* $soname]} { - # use it as-is - } else { - # Assume it's a suffix - set soname "libsqlite3.so.${soname}" - } - } - } - msg-debug "soname=$soname" - if {[proj-check-soname $soname]} { - define LDFLAGS_LIBSQLITE3_SONAME [get-define LDFLAGS_SONAME_PREFIX]$soname - msg-result "Setting SONAME using: [get-define LDFLAGS_LIBSQLITE3_SONAME]" - } elseif {[proj-opt-was-provided soname]} { - # --soname was explicitly requested but not available, so fail fatally - proj-fatal "This environment does not support SONAME." - } else { - # --soname was not explicitly requested but not available, so just warn - msg-result "This environment does not support SONAME." - } -}} - proj-define-for-opt shared ENABLE_SHARED "Build shared library?" if {![proj-define-for-opt static ENABLE_STATIC \ @@ -527,16 +429,8 @@ proj-define-for-opt test-status TSTRNNR_OPTS \ proj-define-for-opt linemacros AMALGAMATION_LINE_MACROS \ "Use #line macros in the amalgamation:" -msg-checking "SQLITE_DEBUG build? " -proj-if-opt-truthy debug { - define SQLITE_DEBUG 1 - define TARGET_DEBUG {-g -DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0 -Wall} - proj-opt-set memsys5 - msg-result yes -} { - define TARGET_DEBUG {-DNDEBUG} - msg-result no -} +sqlite-check-soname +sqlite-check-debug ######################################################################## # TCL... @@ -774,8 +668,8 @@ sqlite-check-tcl # - CFLAGS_JIMSH = any flags needed for buildng a BTCLSH-compatible # jimsh. The defaults may be passed on to configure as # CFLAGS_JIMSH=... -set useJimForCodeGen 0 ; # Set to 1 when using jimsh for code generation. - # May affect later decisions. +set sqliteUseJimForCodeGen 0 ; # Set to 1 when using jimsh for code + # generation. May affect later decisions. proc sqlite-determine-codegen-tcl {} { rename sqlite-determine-codegen-tcl "" msg-result "Checking for TCL to use for code generation... " @@ -812,7 +706,7 @@ proc sqlite-determine-codegen-tcl {} { if {$sysh && [cc-check-functions realpath]} { define-append CFLAGS_JIMSH -DHAVE_REALPATH define BTCLSH "\$(JIMSH)" - set ::useJimForCodeGen 1 + set ::sqliteUseJimForCodeGen 1 } elseif {$sysh && [cc-check-functions _fullpath]} { # _fullpath() is a Windows API. It's not entirely clear # whether we need to add {-DHAVE_SYS_TIME_H -DHAVE_DIRENT_H} @@ -821,7 +715,7 @@ proc sqlite-determine-codegen-tcl {} { # builds it does not. define-append CFLAGS_JIMSH -DHAVE__FULLPATH define BTCLSH "\$(JIMSH)" - set ::useJimForCodeGen 1 + set ::sqliteUseJimForCodeGen 1 } elseif {[file-isexec [get-define TCLSH_CMD]]} { set cgtcl [get-define TCLSH_CMD] define BTCLSH "\$(TCLSH_CMD)" @@ -854,23 +748,7 @@ msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]" ######################################################################## # Thread safety? -msg-checking "Support threadsafe operation? " -proj-if-opt-truthy threadsafe { - msg-result yes - sqlite-add-feature-flag -DSQLITE_THREADSAFE=1 - if {![proj-check-function-in-lib pthread_create pthread] - || ![proj-check-function-in-lib pthread_mutexattr_init pthread]} { - user-error "Missing required pthread bits" - } - define LDFLAGS_PTHREAD [get-define lib_pthread_create] - undefine lib_pthread_create - # Recall that LDFLAGS_PTHREAD might be empty even if pthreads if - # found because it's in -lc on some platforms. -} { - msg-result no - sqlite-add-feature-flag -DSQLITE_THREADSAFE=0 - define LDFLAGS_PTHREAD "" -} +sqlite-check-threadsafe ######################################################################## # Do we want temporary databases in memory? @@ -897,245 +775,6 @@ if {[proj-opt-was-provided with-tempstore]} { }} } -######################################################################## -# sqlite-check-line-editing jumps through proverbial hoops to try to -# find a working line-editing library, setting: -# -# - HAVE_READLINE to 0 or 1 -# - HAVE_LINENOISE to 0, 1, or 2 -# - HAVE_EDITLINE to 0 or 1 -# -# Only one of ^^^ those will be set to non-0. -# -# - LDFLAGS_READLINE = linker flags or empty string -# -# - CFLAGS_READLINE = compilation flags for clients or empty string. -# -# Note that LDFLAGS_READLINE and CFLAGS_READLINE may refer to -# linenoise or editline, not necessarily libreadline. In some cases -# it will set HAVE_READLINE=1 when it's really using editline, for -# reasons described in this function's comments. -# -# Returns a string describing which line-editing approach to use, or -# "none" if no option is available. -# -# Order of checks: -# -# 1) --with-linenoise trumps all others and skips all of the -# complexities involved with the remaining options. -# -# 2) --editline trumps --readline -# -# 3) --disable-readline trumps --readline -# -# 4) Default to automatic search for optional readline -# -# 5) Try to find readline or editline. If it's not found AND the -# corresponding --FEATURE flag was explicitly given, fail fatally, -# else fail silently. -proc sqlite-check-line-editing {} { - rename sqlite-check-line-editing "" - msg-result "Checking for line-editing capability..." - define HAVE_READLINE 0 - define HAVE_LINENOISE 0 - define HAVE_EDITLINE 0 - define LDFLAGS_READLINE "" - define CFLAGS_READLINE "" - set failIfNotFound 0 ; # Gets set to 1 for explicit --FEATURE requests - # so that we know whether to fail fatally or not - # if the library is not found. - set libsForReadline {readline edit} ; # -l names to check for readline(). - # The libedit check changes this. - set editLibName "readline" ; # "readline" or "editline" - set editLibDef "HAVE_READLINE" ; # "HAVE_READLINE" or "HAVE_EDITLINE" - set dirLn [opt-val with-linenoise] - if {"" ne $dirLn} { - # Use linenoise from a copy of its sources (not a library)... - if {![file isdir $dirLn]} { - proj-fatal "--with-linenoise value is not a directory" - } - set lnH $dirLn/linenoise.h - if {![file exists $lnH] } { - proj-fatal "Cannot find linenoise.h in $dirLn" - } - set lnC "" - set lnCOpts {linenoise-ship.c linenoise.c} - foreach f $lnCOpts { - if {[file exists $dirLn/$f]} { - set lnC $dirLn/$f - break; - } - } - if {"" eq $lnC} { - proj-fatal "Cannot find any of $lnCOpts in $dirLn" - } - set flavor "" - set lnVal [proj-which-linenoise $lnH] - switch -- $lnVal { - 1 { set flavor "antirez" } - 2 { set flavor "msteveb" } - default { - proj-fatal "Cannot determine the flavor of linenoise from $lnH" - } - } - define CFLAGS_READLINE "-I$dirLn $lnC" - define HAVE_LINENOISE $lnVal - sqlite-add-shell-opt -DHAVE_LINENOISE=$lnVal - if {$::useJimForCodeGen && 2 == $lnVal} { - define-append CFLAGS_JIMSH -DUSE_LINENOISE [get-define CFLAGS_READLINE] - user-notice "Adding linenoise support to jimsh." - } - return "linenoise ($flavor)" - } elseif {[opt-bool editline]} { - # libedit mimics libreadline and on some systems does not have its - # own header installed (instead, that of libreadline is used). - # - # shell.c historically expects HAVE_EDITLINE to be set for - # libedit, but it then expects to see , which - # some system's don't actually have despite having libedit. If we - # end up finding below, we will use - # -DHAVE_EDITLINE=1, else we will use -DHAVE_READLINE=1. In either - # case, we will link against libedit. - set failIfNotFound 1 - set libsForReadline {edit} - set editLibName editline - } elseif {![opt-bool readline]} { - msg-result "Readline support explicitly disabled with --disable-readline" - return "none" - } elseif {[proj-opt-was-provided readline]} { - # If an explicit --[enable-]readline was used, fail if it's not - # found, else treat the feature as optional. - set failIfNotFound 1 - } - - # Transform with-readline-header=X to with-readline-cflags=-I... - set v [opt-val with-readline-header] - proj-opt-set with-readline-header "" - if {"" ne $v} { - if {"auto" eq $v} { - proj-opt-set with-readline-cflags auto - } else { - set v [file dirname $v] - if {[string match */readline $v]} { - # Special case: if the path includes .../readline/readline.h, - # set the -I to one dir up from that because our sources - # #include or . - set v [file dirname $v] - } - proj-opt-set with-readline-cflags "-I$v" - } - } - - # Look for readline.h - set rlInc [opt-val with-readline-cflags auto] - if {"auto" eq $rlInc} { - set rlInc "" - if {$::isCrossCompiling} { - # ^^^ this check is derived from the legacy configure script. - proj-warn "Skipping check for readline.h because we're cross-compiling." - } else { - set dirs "[get-define prefix] /usr /usr/local /usr/local/readline /usr/contrib /mingw" - set subdirs "include/$editLibName" - if {"editline" eq $editLibName} { - lappend subdirs include/readline - # ^^^ editline, on some systems, does not have its own header, - # and uses libreadline's header. - } - lappend subdirs include - # ^^^ The dirs and subdirs lists are, except for the inclusion - # of $prefix and editline, from the legacy configure script - set rlInc [proj-search-for-header-dir readline.h \ - -dirs $dirs -subdirs $subdirs] - if {"" ne $rlInc} { - if {[string match */readline $rlInc]} { - set rlInc [file dirname $rlInc]; # shell #include's - } elseif {[string match */editline $rlInc]} { - set editLibDef HAVE_EDITLINE - set rlInc [file dirname $rlInc]; # shell #include's - } - set rlInc "-I${rlInc}" - } - } - } elseif {"" ne $rlInc && ![string match *-I* $rlInc]} { - proj-fatal "Argument to --with-readline-cflags is intended to be CFLAGS and contain -I..." - } - - # If readline.h was found/specified, look for lib(readline|edit)... - # - # This is not quite straightforward because both libreadline and - # libedit typically require some other library which (according to - # legacy autotools-generated tests) provides tgetent(3). On some - # systems that's built into libreadline/edit, on some (most?) its in - # lib[n]curses, and on some it's in libtermcap. - set rlLib "" - if {"" ne $rlInc} { - set rlLib [opt-val with-readline-ldflags] - if {"" eq $rlLib || "auto" eq $rlLib} { - set rlLib "" - set libTerm "" - if {[proj-check-function-in-lib tgetent "$editLibName ncurses curses termcap"]} { - # ^^^ that libs list comes from the legacy configure script ^^^ - set libTerm [get-define lib_tgetent] - undefine lib_tgetent - } - if {$editLibName eq $libTerm} { - set rlLib $libTerm - } elseif {[proj-check-function-in-lib readline $libsForReadline $libTerm]} { - set rlLib [get-define lib_readline] - lappend rlLib $libTerm - undefine lib_readline - } - } - } - - # If we found a library, configure the build to use it... - if {"" ne $rlLib} { - if {"editline" eq $editLibName && "HAVE_READLINE" eq $editLibDef} { - # Alert the user that, despite outward appearances, we won't be - # linking to the GPL'd libreadline. Presumably that distinction is - # significant for those using --editline. - proj-indented-notice { - NOTE: the local libedit but uses so we - will compile with -DHAVE_READLINE=1 but will link with - libedit. - } - } - set rlLib [join $rlLib] - set rlInc [join $rlInc] - define LDFLAGS_READLINE $rlLib - define CFLAGS_READLINE $rlInc - proj-assert {$editLibDef in {HAVE_READLINE HAVE_EDITLINE}} - proj-assert {$editLibName in {readline editline}} - sqlite-add-shell-opt -D${editLibDef}=1 - msg-result "Using $editLibName flags: $rlInc $rlLib" - # Check whether rl_completion_matches() has a signature we can use - # and disable that sub-feature if it doesn't. - if {![cctest \ - -cflags "$rlInc -D${editLibDef}" -libs $rlLib -nooutput 1 -source { - #include - #ifdef HAVE_EDITLINE - #include - #else - #include - #endif - static char * rcg(const char *z, int i){(void)z; (void)i; return 0;} - int main(void) { - char ** x = rl_completion_matches("one", rcg); - (void)x; - return 0; - } - }]} { - proj-warn "readline-style completion disabled due to rl_completion_matches() signature mismatch" - sqlite-add-shell-opt -DSQLITE_OMIT_READLINE_COMPLETION - } - return $editLibName - } - - if {$failIfNotFound} { - proj-fatal "Explicit --$editLibName failed to find a matching library." - } - return "none" -}; # sqlite-check-line-editing msg-result "Line-editing support for the sqlite3 shell: [sqlite-check-line-editing]" proj-if-opt-truthy load-extension { @@ -1164,93 +803,6 @@ proj-if-opt-truthy math { msg-result "Disabling math SQL functions" } -######################################################################## -# ICU - International Components for Unicode -# -# Handles these flags: -# -# --with-icu-ldflags=LDFLAGS -# --with-icu-cflags=CFLAGS -# --with-icu-config[=auto | pkg-config | /path/to/icu-config] -# --enable-icu-collations -# -# --with-icu-config values: -# -# - auto: use the first one of (pkg-config, icu-config) found on the -# system. -# - pkg-config: use only pkg-config to determine flags -# - /path/to/icu-config: use that to determine flags -# -# If --with-icu-config is used as neither pkg-config nor icu-config -# are found, fail fatally. -# -# If both --with-icu-ldflags and --with-icu-config are provided, they -# are cumulative. If neither are provided, icu-collations is not -# honored and a warning is emitted if it is provided. -# -# Design note: though we could automatically enable ICU if the -# icu-config binary or (pkg-config icu-io) are found, we specifically -# do not. ICU is always an opt-in feature. -proc sqlite-check-icu {} { - rename sqlite-check-icu "" - define LDFLAGS_ICU [join [opt-val with-icu-ldflags ""]] - define CFLAGS_ICU [join [opt-val with-icu-cflags ""]] - if {[proj-opt-was-provided with-icu-config]} { - set icuConfigBin [opt-val with-icu-config] - set tryIcuConfigBin 1; # set to 0 if we end up using pkg-config - if {"auto" eq $icuConfigBin || "pkg-config" eq $icuConfigBin} { - if {[pkg-config-init 0] && [pkg-config icu-io]} { - # Maintenance reminder: historical docs say to use both of - # (icu-io, icu-uc). icu-uc lacks a required lib and icu-io has - # all of them on tested OSes. - set tryIcuConfigBin 0 - define LDFLAGS_ICU [get-define PKG_ICU_IO_LDFLAGS] - define-append LDFLAGS_ICU [get-define PKG_ICU_IO_LIBS] - define CFLAGS_ICU [get-define PKG_ICU_IO_CFLAGS] - } elseif {"pkg-config" eq $icuConfigBin} { - proj-fatal "pkg-config cannot find package icu-io" - } else { - proj-assert {"auto" eq $icuConfigBin} - } - } - if {$tryIcuConfigBin} { - if {"auto" eq $icuConfigBin} { - set icuConfigBin [proj-first-bin-of \ - /usr/local/bin/icu-config \ - /usr/bin/icu-config] - if {"" eq $icuConfigBin} { - proj-fatal "--with-icu-config=auto cannot find (pkg-config icu-io) or icu-config binary" - } - } - if {[file-isexec $icuConfigBin]} { - set x [exec $icuConfigBin --ldflags] - if {"" eq $x} { - proj-fatal "$icuConfigBin --ldflags returned no data" - } - define-append LDFLAGS_ICU $x - set x [exec $icuConfigBin --cppflags] - define-append CFLAGS_ICU $x - } else { - proj-fatal "--with-icu-config=$bin does not refer to an executable" - } - } - } - set ldflags [define LDFLAGS_ICU [string trim [get-define LDFLAGS_ICU]]] - set cflags [define CFLAGS_ICU [string trim [get-define CFLAGS_ICU]]] - if {"" ne $ldflags} { - sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU - msg-result "Enabling ICU support with flags: $ldflags $cflags" - if {[opt-bool icu-collations]} { - msg-result "Enabling ICU collations." - sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU_COLLATIONS - # Recall that shell.c builds with sqlite3.c - } - } elseif {[opt-bool icu-collations]} { - proj-warn "ignoring --enable-icu-collations because neither --with-icu-ldflags nor --with-icu-config provided any linker flags" - } else { - msg-result "ICU support is disabled." - } -}; # sqlite-check-icu sqlite-check-icu ######################################################################## @@ -1351,26 +903,12 @@ foreach {boolFlag featureFlag} { } } -######################################################################### -# Show the final feature flag sets: -apply {{} { - set oFF [get-define OPT_FEATURE_FLAGS] - if {"" ne $oFF} { - define OPT_FEATURE_FLAGS [lsort -unique $oFF] - msg-result "Library feature flags: [get-define OPT_FEATURE_FLAGS]" - } - set oFF [get-define OPT_SHELL] - if {"" ne $oFF} { - define OPT_SHELL [lsort -unique $oFF] - msg-result "Shell options: [get-define OPT_SHELL]" - } - unset oFF -}} +sqlite-show-feature-flags ######################################################################## # When cross-compiling, we have to avoid using the -s flag to # /usr/bin/install: https://sqlite.org/forum/forumpost/9a67df63eda9925c -define IS_CROSS_COMPILING $isCrossCompiling +define IS_CROSS_COMPILING $sqliteIsCrossCompiling ######################################################################## # "Re-export" the autoconf-conventional --XYZdir flags into something diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl new file mode 100644 index 0000000000..9bd712c0a8 --- /dev/null +++ b/autosetup/sqlite-config.tcl @@ -0,0 +1,505 @@ +# This file holds functions for autosetup which are specific to the +# sqlite build tree. They are in this file, instead of auto.def, so +# that they can be reused in the TEA sub-tree. This file requires +# functions from proj.tcl. + +use cc cc-db cc-shared cc-lib pkg-config proj + +# Are we cross-compiling? This value may be changed by certain build +# options, so it's important that config code which checks for +# cross-compilation uses this var instead of +# [proj-is-cross-compiling]. +set ::sqliteIsCrossCompiling [proj-is-cross-compiling] + + +######################################################################## +# Runs some common initialization which must happen immediately after +# autosetup's [options] function is called. +proc sqlite-post-options-init {} { + # + # Carry values from hidden --flag aliases over to their canonical + # flag forms. This list must include only options which are common + # to both the top-level auto.def and autoconf/auto.def. + # + proj-xfer-options-aliases { + with-readline-inc => with-readline-cflags + with-readline-lib => with-readline-ldflags + with-debug => debug + } + sqlite-autoreconfig +} + +######################################################################## +# Sets up the SQLITE_AUTORECONFIG define. +proc sqlite-autoreconfig {} { + # + # SQLITE_AUTORECONFIG contains make target rules for re-running the + # configure script with the same arguments it was initially invoked + # with. This can be used to automatically reconfigure + # + proc squote {arg} { + # Wrap $arg in single-quotes if it looks like it might need that + # to avoid mis-handling as a shell argument. We assume that $arg + # will never contain any single-quote characters. + if {[string match {*[ &;$*"]*} $arg]} { return '$arg' } + return $arg + } + define-append SQLITE_AUTORECONFIG cd [squote $::autosetup(builddir)] && [squote $::autosetup(srcdir)/configure] + #{*}$::autosetup(argv) breaks with --flag='val with spaces', so... + foreach arg $::autosetup(argv) { + define-append SQLITE_AUTORECONFIG [squote $arg] + } + rename squote "" +} + +define OPT_FEATURE_FLAGS {} ; # -DSQLITE_OMIT/ENABLE flags. +define OPT_SHELL {} ; # Feature-related CFLAGS for the sqlite3 CLI app +######################################################################## +# Adds $args, if not empty, to OPT_FEATURE_FLAGS. If the first arg is +# -shell then it strips that arg and passes the remaining args the +# sqlite-add-shell-opt in addition to adding them to +# OPT_FEATURE_FLAGS. +proc sqlite-add-feature-flag {args} { + set shell "" + if {"-shell" eq [lindex $args 0]} { + set args [lassign $args shell] + } + if {"" ne $args} { + if {"" ne $shell} { + sqlite-add-shell-opt {*}$args + } + define-append OPT_FEATURE_FLAGS {*}$args + } +} +# Appends $args, if not empty, to OPT_SHELL. +proc sqlite-add-shell-opt {args} { + if {"" ne $args} { + define-append OPT_SHELL {*}$args + } +} + +######################################################################### +# Show the final feature flag sets. +proc sqlite-show-feature-flags {} { + set oFF [get-define OPT_FEATURE_FLAGS] + if {"" ne $oFF} { + define OPT_FEATURE_FLAGS [lsort -unique $oFF] + msg-result "Library feature flags: [get-define OPT_FEATURE_FLAGS]" + } + set oFF [get-define OPT_SHELL] + if {"" ne $oFF} { + define OPT_SHELL [lsort -unique $oFF] + msg-result "Shell options: [get-define OPT_SHELL]" + } +} + +######################################################################## +# Checks for the --debug flag, defining SQLITE_DEBUG to 1 if it is +# true. TARGET_DEBUG gets defined either way, with content depending +# on whether --debug is true or false. +proc sqlite-check-debug {} { + msg-checking "SQLITE_DEBUG build? " + proj-if-opt-truthy debug { + define SQLITE_DEBUG 1 + define TARGET_DEBUG {-g -DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0 -Wall} + proj-opt-set memsys5 + msg-result yes + } { + define TARGET_DEBUG {-DNDEBUG} + msg-result no + } +} + +######################################################################## +# "soname" for libsqlite3.so. See discussion at: +# https://sqlite.org/src/forumpost/5a3b44f510df8ded +proc sqlite-check-soname {} { + define LDFLAGS_LIBSQLITE3_SONAME "" + if {[proj-opt-was-provided soname]} { + set soname [join [opt-val soname] ""] + } else { + # Enabling soname breaks linking for the --dynlink-tools feature, + # and this project has no direct use for soname, so default to + # none. Package maintainers, on the other hand, like to have an + # soname. + set soname none + } + switch -exact -- $soname { + none - "" { return 0 } + legacy { set soname libsqlite3.so.0 } + default { + if {[string match libsqlite3.* $soname]} { + # use it as-is + } else { + # Assume it's a suffix + set soname "libsqlite3.so.${soname}" + } + } + } + # msg-debug "soname=$soname" + if {[proj-check-soname $soname]} { + define LDFLAGS_LIBSQLITE3_SONAME [get-define LDFLAGS_SONAME_PREFIX]$soname + msg-result "Setting SONAME using: [get-define LDFLAGS_LIBSQLITE3_SONAME]" + } elseif {[proj-opt-was-provided soname]} { + # --soname was explicitly requested but not available, so fail fatally + proj-fatal "This environment does not support SONAME." + } else { + # --soname was not explicitly requested but not available, so just warn + msg-result "This environment does not support SONAME." + } +} + +######################################################################## +# If --enable-thresafe is set, this adds -DSQLITE_THREADSAFE=1 to +# OPT_FEATURE_FLAGS and sets LDFLAGS_PTHREAD to the linker flags +# needed for linking pthread. If --enable-threadsafe is not set, adds +# -DSQLITE_THREADSAFE=0 to OPT_FEATURE_FLAGS and sets LDFLAGS_PTHREAD +# to an empty string. +proc sqlite-check-threadsafe {} { + msg-checking "Support threadsafe operation? " + proj-if-opt-truthy threadsafe { + msg-result yes + sqlite-add-feature-flag -DSQLITE_THREADSAFE=1 + if {![proj-check-function-in-lib pthread_create pthread] + || ![proj-check-function-in-lib pthread_mutexattr_init pthread]} { + user-error "Missing required pthread bits" + } + define LDFLAGS_PTHREAD [get-define lib_pthread_create] + undefine lib_pthread_create + # Recall that LDFLAGS_PTHREAD might be empty even if pthreads if + # found because it's in -lc on some platforms. + } { + msg-result no + sqlite-add-feature-flag -DSQLITE_THREADSAFE=0 + define LDFLAGS_PTHREAD "" + } +} + +######################################################################## +# sqlite-check-line-editing jumps through proverbial hoops to try to +# find a working line-editing library, setting: +# +# - HAVE_READLINE to 0 or 1 +# - HAVE_LINENOISE to 0, 1, or 2 +# - HAVE_EDITLINE to 0 or 1 +# +# Only one of ^^^ those will be set to non-0. +# +# - LDFLAGS_READLINE = linker flags or empty string +# +# - CFLAGS_READLINE = compilation flags for clients or empty string. +# +# Note that LDFLAGS_READLINE and CFLAGS_READLINE may refer to +# linenoise or editline, not necessarily libreadline. In some cases +# it will set HAVE_READLINE=1 when it's really using editline, for +# reasons described in this function's comments. +# +# Returns a string describing which line-editing approach to use, or +# "none" if no option is available. +# +# Order of checks: +# +# 1) --with-linenoise trumps all others and skips all of the +# complexities involved with the remaining options. +# +# 2) --editline trumps --readline +# +# 3) --disable-readline trumps --readline +# +# 4) Default to automatic search for optional readline +# +# 5) Try to find readline or editline. If it's not found AND the +# corresponding --FEATURE flag was explicitly given, fail fatally, +# else fail silently. +proc sqlite-check-line-editing {} { + rename sqlite-check-line-editing "" + msg-result "Checking for line-editing capability..." + define HAVE_READLINE 0 + define HAVE_LINENOISE 0 + define HAVE_EDITLINE 0 + define LDFLAGS_READLINE "" + define CFLAGS_READLINE "" + set failIfNotFound 0 ; # Gets set to 1 for explicit --FEATURE requests + # so that we know whether to fail fatally or not + # if the library is not found. + set libsForReadline {readline edit} ; # -l names to check for readline(). + # The libedit check changes this. + set editLibName "readline" ; # "readline" or "editline" + set editLibDef "HAVE_READLINE" ; # "HAVE_READLINE" or "HAVE_EDITLINE" + set dirLn [opt-val with-linenoise] + if {"" ne $dirLn} { + # Use linenoise from a copy of its sources (not a library)... + if {![file isdir $dirLn]} { + proj-fatal "--with-linenoise value is not a directory" + } + set lnH $dirLn/linenoise.h + if {![file exists $lnH] } { + proj-fatal "Cannot find linenoise.h in $dirLn" + } + set lnC "" + set lnCOpts {linenoise-ship.c linenoise.c} + foreach f $lnCOpts { + if {[file exists $dirLn/$f]} { + set lnC $dirLn/$f + break; + } + } + if {"" eq $lnC} { + proj-fatal "Cannot find any of $lnCOpts in $dirLn" + } + set flavor "" + set lnVal [proj-which-linenoise $lnH] + switch -- $lnVal { + 1 { set flavor "antirez" } + 2 { set flavor "msteveb" } + default { + proj-fatal "Cannot determine the flavor of linenoise from $lnH" + } + } + define CFLAGS_READLINE "-I$dirLn $lnC" + define HAVE_LINENOISE $lnVal + sqlite-add-shell-opt -DHAVE_LINENOISE=$lnVal + if {[info exists sqliteUseJimForCodeGen] + && $::sqliteUseJimForCodeGen && 2 == $lnVal} { + define-append CFLAGS_JIMSH -DUSE_LINENOISE [get-define CFLAGS_READLINE] + user-notice "Adding linenoise support to jimsh." + } + return "linenoise ($flavor)" + } elseif {[opt-bool editline]} { + # libedit mimics libreadline and on some systems does not have its + # own header installed (instead, that of libreadline is used). + # + # shell.c historically expects HAVE_EDITLINE to be set for + # libedit, but it then expects to see , which + # some system's don't actually have despite having libedit. If we + # end up finding below, we will use + # -DHAVE_EDITLINE=1, else we will use -DHAVE_READLINE=1. In either + # case, we will link against libedit. + set failIfNotFound 1 + set libsForReadline {edit} + set editLibName editline + } elseif {![opt-bool readline]} { + msg-result "Readline support explicitly disabled with --disable-readline" + return "none" + } elseif {[proj-opt-was-provided readline]} { + # If an explicit --[enable-]readline was used, fail if it's not + # found, else treat the feature as optional. + set failIfNotFound 1 + } + + # Transform with-readline-header=X to with-readline-cflags=-I... + set v [opt-val with-readline-header] + proj-opt-set with-readline-header "" + if {"" ne $v} { + if {"auto" eq $v} { + proj-opt-set with-readline-cflags auto + } else { + set v [file dirname $v] + if {[string match */readline $v]} { + # Special case: if the path includes .../readline/readline.h, + # set the -I to one dir up from that because our sources + # #include or . + set v [file dirname $v] + } + proj-opt-set with-readline-cflags "-I$v" + } + } + + # Look for readline.h + set rlInc [opt-val with-readline-cflags auto] + if {"auto" eq $rlInc} { + set rlInc "" + if {$::sqliteIsCrossCompiling} { + # ^^^ this check is derived from the legacy configure script. + proj-warn "Skipping check for readline.h because we're cross-compiling." + } else { + set dirs "[get-define prefix] /usr /usr/local /usr/local/readline /usr/contrib /mingw" + set subdirs "include/$editLibName" + if {"editline" eq $editLibName} { + lappend subdirs include/readline + # ^^^ editline, on some systems, does not have its own header, + # and uses libreadline's header. + } + lappend subdirs include + # ^^^ The dirs and subdirs lists are, except for the inclusion + # of $prefix and editline, from the legacy configure script + set rlInc [proj-search-for-header-dir readline.h \ + -dirs $dirs -subdirs $subdirs] + if {"" ne $rlInc} { + if {[string match */readline $rlInc]} { + set rlInc [file dirname $rlInc]; # shell #include's + } elseif {[string match */editline $rlInc]} { + set editLibDef HAVE_EDITLINE + set rlInc [file dirname $rlInc]; # shell #include's + } + set rlInc "-I${rlInc}" + } + } + } elseif {"" ne $rlInc && ![string match *-I* $rlInc]} { + proj-fatal "Argument to --with-readline-cflags is intended to be CFLAGS and contain -I..." + } + + # If readline.h was found/specified, look for lib(readline|edit)... + # + # This is not quite straightforward because both libreadline and + # libedit typically require some other library which (according to + # legacy autotools-generated tests) provides tgetent(3). On some + # systems that's built into libreadline/edit, on some (most?) its in + # lib[n]curses, and on some it's in libtermcap. + set rlLib "" + if {"" ne $rlInc} { + set rlLib [opt-val with-readline-ldflags] + if {"" eq $rlLib || "auto" eq $rlLib} { + set rlLib "" + set libTerm "" + if {[proj-check-function-in-lib tgetent "$editLibName ncurses curses termcap"]} { + # ^^^ that libs list comes from the legacy configure script ^^^ + set libTerm [get-define lib_tgetent] + undefine lib_tgetent + } + if {$editLibName eq $libTerm} { + set rlLib $libTerm + } elseif {[proj-check-function-in-lib readline $libsForReadline $libTerm]} { + set rlLib [get-define lib_readline] + lappend rlLib $libTerm + undefine lib_readline + } + } + } + + # If we found a library, configure the build to use it... + if {"" ne $rlLib} { + if {"editline" eq $editLibName && "HAVE_READLINE" eq $editLibDef} { + # Alert the user that, despite outward appearances, we won't be + # linking to the GPL'd libreadline. Presumably that distinction is + # significant for those using --editline. + proj-indented-notice { + NOTE: the local libedit but uses so we + will compile with -DHAVE_READLINE=1 but will link with + libedit. + } + } + set rlLib [join $rlLib] + set rlInc [join $rlInc] + define LDFLAGS_READLINE $rlLib + define CFLAGS_READLINE $rlInc + proj-assert {$editLibDef in {HAVE_READLINE HAVE_EDITLINE}} + proj-assert {$editLibName in {readline editline}} + sqlite-add-shell-opt -D${editLibDef}=1 + msg-result "Using $editLibName flags: $rlInc $rlLib" + # Check whether rl_completion_matches() has a signature we can use + # and disable that sub-feature if it doesn't. + if {![cctest \ + -cflags "$rlInc -D${editLibDef}" -libs $rlLib -nooutput 1 -source { + #include + #ifdef HAVE_EDITLINE + #include + #else + #include + #endif + static char * rcg(const char *z, int i){(void)z; (void)i; return 0;} + int main(void) { + char ** x = rl_completion_matches("one", rcg); + (void)x; + return 0; + } + }]} { + proj-warn "readline-style completion disabled due to rl_completion_matches() signature mismatch" + sqlite-add-shell-opt -DSQLITE_OMIT_READLINE_COMPLETION + } + return $editLibName + } + + if {$failIfNotFound} { + proj-fatal "Explicit --$editLibName failed to find a matching library." + } + return "none" +}; # sqlite-check-line-editing + +######################################################################## +# ICU - International Components for Unicode +# +# Handles these flags: +# +# --with-icu-ldflags=LDFLAGS +# --with-icu-cflags=CFLAGS +# --with-icu-config[=auto | pkg-config | /path/to/icu-config] +# --enable-icu-collations +# +# --with-icu-config values: +# +# - auto: use the first one of (pkg-config, icu-config) found on the +# system. +# - pkg-config: use only pkg-config to determine flags +# - /path/to/icu-config: use that to determine flags +# +# If --with-icu-config is used as neither pkg-config nor icu-config +# are found, fail fatally. +# +# If both --with-icu-ldflags and --with-icu-config are provided, they +# are cumulative. If neither are provided, icu-collations is not +# honored and a warning is emitted if it is provided. +# +# Design note: though we could automatically enable ICU if the +# icu-config binary or (pkg-config icu-io) are found, we specifically +# do not. ICU is always an opt-in feature. +proc sqlite-check-icu {} { + rename sqlite-check-icu "" + define LDFLAGS_ICU [join [opt-val with-icu-ldflags ""]] + define CFLAGS_ICU [join [opt-val with-icu-cflags ""]] + if {[proj-opt-was-provided with-icu-config]} { + set icuConfigBin [opt-val with-icu-config] + set tryIcuConfigBin 1; # set to 0 if we end up using pkg-config + if {"auto" eq $icuConfigBin || "pkg-config" eq $icuConfigBin} { + if {[pkg-config-init 0] && [pkg-config icu-io]} { + # Maintenance reminder: historical docs say to use both of + # (icu-io, icu-uc). icu-uc lacks a required lib and icu-io has + # all of them on tested OSes. + set tryIcuConfigBin 0 + define LDFLAGS_ICU [get-define PKG_ICU_IO_LDFLAGS] + define-append LDFLAGS_ICU [get-define PKG_ICU_IO_LIBS] + define CFLAGS_ICU [get-define PKG_ICU_IO_CFLAGS] + } elseif {"pkg-config" eq $icuConfigBin} { + proj-fatal "pkg-config cannot find package icu-io" + } else { + proj-assert {"auto" eq $icuConfigBin} + } + } + if {$tryIcuConfigBin} { + if {"auto" eq $icuConfigBin} { + set icuConfigBin [proj-first-bin-of \ + /usr/local/bin/icu-config \ + /usr/bin/icu-config] + if {"" eq $icuConfigBin} { + proj-fatal "--with-icu-config=auto cannot find (pkg-config icu-io) or icu-config binary" + } + } + if {[file-isexec $icuConfigBin]} { + set x [exec $icuConfigBin --ldflags] + if {"" eq $x} { + proj-fatal "$icuConfigBin --ldflags returned no data" + } + define-append LDFLAGS_ICU $x + set x [exec $icuConfigBin --cppflags] + define-append CFLAGS_ICU $x + } else { + proj-fatal "--with-icu-config=$bin does not refer to an executable" + } + } + } + set ldflags [define LDFLAGS_ICU [string trim [get-define LDFLAGS_ICU]]] + set cflags [define CFLAGS_ICU [string trim [get-define CFLAGS_ICU]]] + if {"" ne $ldflags} { + sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU + msg-result "Enabling ICU support with flags: $ldflags $cflags" + if {[opt-bool icu-collations]} { + msg-result "Enabling ICU collations." + sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU_COLLATIONS + # Recall that shell.c builds with sqlite3.c + } + } elseif {[opt-bool icu-collations]} { + proj-warn "ignoring --enable-icu-collations because neither --with-icu-ldflags nor --with-icu-config provided any linker flags" + } else { + msg-result "ICU support is disabled." + } +}; # sqlite-check-icu diff --git a/manifest b/manifest index d90ea454d8..528a20c4ab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enable\sautomatic\squery-time\sindexes\sfor\sWITHOUT\sROWID\stables. -D 2025-01-18T23:44:06.756 +C Move\ssome\sof\sthe\sauto.def\sfunctions\sinto\sautosetup/sqlite-config.tcl\sfor\sre-use\sin\sthe\spending\smigration\sof\sthe\sautoconf\sbundle\sto\sautosetup.\sThis\sis\sjust\sreorg,\sno\sfunctional\schanges. +D 2025-01-19T14:53:45.375 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -14,7 +14,7 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 -F auto.def 20ddd61060516e29cb984d716c451ad6e7e3ebe1d3786ec8f70813fada06eb2f +F auto.def 8d8467f21bd073a7d62ad9803d958d5e5f625459cd64b97776636ca740d4f743 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac @@ -51,6 +51,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 2e817159b997077cb79bd871f6255276b787558f386dfc0830b0f825f6a53767 +F autosetup/sqlite-config.tcl 0a14f4deb35c150d565f13defd0d02aa2a9fb34b7ceec4de5c817f6205d90873 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2207,9 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4309da2ca5cb99ea81f3034ae3c5809187c0131d21f9f9469ea0d69c941f393e aa829a131a3431791083cf60d9cf00e7b3c0fafdd39a23e761b629a2287ab875 -R f761383deed49e3993fc59c86662b3e0 -T +closed aa829a131a3431791083cf60d9cf00e7b3c0fafdd39a23e761b629a2287ab875 -U drh -Z 98bd687a2f93dbfd54703fb8cab1103d +P 8534af5b94be9f5b1f02453e1c3b6b3f78a698af91595bdbbfdea00676510116 +R 6870ce5e67a7ecb1dfa87ef84e5cc5df +U stephan +Z 3acb6f6b529d76da2efc2bf22b964dc8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 450b852af6..8835e88290 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8534af5b94be9f5b1f02453e1c3b6b3f78a698af91595bdbbfdea00676510116 +2f1e94994f3595baad4045ab05ffee0668059c23ab37a39c25b83c62bfbaea28 From 815709dd0019c4825b25efb7b78c44233463b532 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 19 Jan 2025 16:26:25 +0000 Subject: [PATCH 029/115] Minor internal refactoring of auto.def to support the pending autoconf subdir port to autosetup. No functional changes. FossilOrigin-Name: 01ff37584708f3f79c62c1b5ed8cceab721cf8348a69a65f0559b1ef8845e85b --- auto.def | 20 ++++++++++---------- autosetup/sqlite-config.tcl | 26 ++++++++++++++++++++------ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/auto.def b/auto.def index 8ee102dc8a..f807947c10 100644 --- a/auto.def +++ b/auto.def @@ -271,7 +271,7 @@ if {"" eq [proj-bin-define install]} { # /chat discussion prompted by # https://sqlite.org/forum/forumpost/9a67df63eda9925c set defaultCFlags {-O2} -if {!$sqliteIsCrossCompiling} { +if {!$::sqliteConfig(is-cross-compiling)} { lappend defaultCFlags -g } define CFLAGS [proj-get-env CFLAGS $defaultCFlags] @@ -300,7 +300,7 @@ proc sqlite-check-wasi-sdk {} { define HAVE_WASI_SDK 0 if {$wasiSdkDir eq ""} { return 0 - } elseif {$::sqliteIsCrossCompiling} { + } elseif {$::sqliteConfig(is-cross-compiling)} { proj-fatal "Cannot combine --with-wasi-sdk with cross-compilation" } msg-result "Checking WASI SDK directory \[$wasiSdkDir]... " @@ -310,7 +310,7 @@ proc sqlite-check-wasi-sdk {} { define WASI_SDK_DIR $wasiSdkDir # Disable numerous options which we know either can't work or are # not useful in this build... - msg-result "Using wasi-sdk clang. Disabling CLI shell modifying config flags:" + msg-result "Using wasi-sdk clang. Disabling CLI shell and modifying config flags:" # Boolean (--enable-/--disable-) flags which must be switched off: foreach opt { dynlink-tools @@ -343,8 +343,8 @@ proc sqlite-check-wasi-sdk {} { } } # Remember that we now have a discrepancy beteween - # $::sqliteIsCrossCompiling and [proj-is-cross-compiling]. - set ::sqliteIsCrossCompiling 1 + # $::sqliteConfig(is-cross-compiling) and [proj-is-cross-compiling]. + set ::sqliteConfig(is-cross-compiling) 1 # # Changing --host and --target have no effect here except to @@ -668,8 +668,6 @@ sqlite-check-tcl # - CFLAGS_JIMSH = any flags needed for buildng a BTCLSH-compatible # jimsh. The defaults may be passed on to configure as # CFLAGS_JIMSH=... -set sqliteUseJimForCodeGen 0 ; # Set to 1 when using jimsh for code - # generation. May affect later decisions. proc sqlite-determine-codegen-tcl {} { rename sqlite-determine-codegen-tcl "" msg-result "Checking for TCL to use for code generation... " @@ -706,7 +704,7 @@ proc sqlite-determine-codegen-tcl {} { if {$sysh && [cc-check-functions realpath]} { define-append CFLAGS_JIMSH -DHAVE_REALPATH define BTCLSH "\$(JIMSH)" - set ::sqliteUseJimForCodeGen 1 + set ::sqliteConfig(use-jim-for-codegen) 1 } elseif {$sysh && [cc-check-functions _fullpath]} { # _fullpath() is a Windows API. It's not entirely clear # whether we need to add {-DHAVE_SYS_TIME_H -DHAVE_DIRENT_H} @@ -715,7 +713,7 @@ proc sqlite-determine-codegen-tcl {} { # builds it does not. define-append CFLAGS_JIMSH -DHAVE__FULLPATH define BTCLSH "\$(JIMSH)" - set ::sqliteUseJimForCodeGen 1 + set ::sqliteConfig(use-jim-for-codegen) 1 } elseif {[file-isexec [get-define TCLSH_CMD]]} { set cgtcl [get-define TCLSH_CMD] define BTCLSH "\$(TCLSH_CMD)" @@ -775,6 +773,7 @@ if {[proj-opt-was-provided with-tempstore]} { }} } +# Must come after sqlite-determine-codegen-tcl msg-result "Line-editing support for the sqlite3 shell: [sqlite-check-line-editing]" proj-if-opt-truthy load-extension { @@ -908,7 +907,7 @@ sqlite-show-feature-flags ######################################################################## # When cross-compiling, we have to avoid using the -s flag to # /usr/bin/install: https://sqlite.org/forum/forumpost/9a67df63eda9925c -define IS_CROSS_COMPILING $sqliteIsCrossCompiling +define IS_CROSS_COMPILING $sqliteConfig(is-cross-compiling) ######################################################################## # "Re-export" the autoconf-conventional --XYZdir flags into something @@ -991,3 +990,4 @@ apply {{} { } } }} + diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 9bd712c0a8..6b036b529c 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -5,11 +5,25 @@ use cc cc-db cc-shared cc-lib pkg-config proj -# Are we cross-compiling? This value may be changed by certain build -# options, so it's important that config code which checks for +# +# Object for communicating config-time state across various +# auto.def-related pieces. +# +array set sqliteConfig {} + +# +# Set to 1 when cross-compiling This value may be changed by certain +# build options, so it's important that config code which checks for # cross-compilation uses this var instead of # [proj-is-cross-compiling]. -set ::sqliteIsCrossCompiling [proj-is-cross-compiling] +# +set sqliteConfig(is-cross-compiling) [proj-is-cross-compiling] + +# +# Gets set to 1 when using jimsh for code generation. May affect later +# decisions. +# +set sqliteConfig(use-jim-for-codegen) 0 ######################################################################## @@ -91,6 +105,7 @@ proc sqlite-show-feature-flags {} { define OPT_SHELL [lsort -unique $oFF] msg-result "Shell options: [get-define OPT_SHELL]" } + #parray ::sqliteConfig } ######################################################################## @@ -259,8 +274,7 @@ proc sqlite-check-line-editing {} { define CFLAGS_READLINE "-I$dirLn $lnC" define HAVE_LINENOISE $lnVal sqlite-add-shell-opt -DHAVE_LINENOISE=$lnVal - if {[info exists sqliteUseJimForCodeGen] - && $::sqliteUseJimForCodeGen && 2 == $lnVal} { + if {$::sqliteConfig(use-jim-for-codegen) && 2 == $lnVal} { define-append CFLAGS_JIMSH -DUSE_LINENOISE [get-define CFLAGS_READLINE] user-notice "Adding linenoise support to jimsh." } @@ -309,7 +323,7 @@ proc sqlite-check-line-editing {} { set rlInc [opt-val with-readline-cflags auto] if {"auto" eq $rlInc} { set rlInc "" - if {$::sqliteIsCrossCompiling} { + if {$::sqliteConfig(is-cross-compiling)} { # ^^^ this check is derived from the legacy configure script. proj-warn "Skipping check for readline.h because we're cross-compiling." } else { diff --git a/manifest b/manifest index 528a20c4ab..02e383c8f0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\ssome\sof\sthe\sauto.def\sfunctions\sinto\sautosetup/sqlite-config.tcl\sfor\sre-use\sin\sthe\spending\smigration\sof\sthe\sautoconf\sbundle\sto\sautosetup.\sThis\sis\sjust\sreorg,\sno\sfunctional\schanges. -D 2025-01-19T14:53:45.375 +C Minor\sinternal\srefactoring\sof\sauto.def\sto\ssupport\sthe\spending\sautoconf\ssubdir\sport\sto\sautosetup.\sNo\sfunctional\schanges. +D 2025-01-19T16:26:25.254 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -14,7 +14,7 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 -F auto.def 8d8467f21bd073a7d62ad9803d958d5e5f625459cd64b97776636ca740d4f743 +F auto.def 8b7e3bdf0a9f3caccddb13175f6a2c3fdb1740220bbfe0bb8dae460a4f84d85a F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac @@ -51,7 +51,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 2e817159b997077cb79bd871f6255276b787558f386dfc0830b0f825f6a53767 -F autosetup/sqlite-config.tcl 0a14f4deb35c150d565f13defd0d02aa2a9fb34b7ceec4de5c817f6205d90873 +F autosetup/sqlite-config.tcl e52fa291ef148712a9392203b05e86743b474065ea88bdc65cdb664dbb188783 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8534af5b94be9f5b1f02453e1c3b6b3f78a698af91595bdbbfdea00676510116 -R 6870ce5e67a7ecb1dfa87ef84e5cc5df +P 2f1e94994f3595baad4045ab05ffee0668059c23ab37a39c25b83c62bfbaea28 +R 9c60fa033887f9029838d451908d0067 U stephan -Z 3acb6f6b529d76da2efc2bf22b964dc8 +Z ec3ab526fc22a680c0602f434f403d4d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8835e88290..684943058c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f1e94994f3595baad4045ab05ffee0668059c23ab37a39c25b83c62bfbaea28 +01ff37584708f3f79c62c1b5ed8cceab721cf8348a69a65f0559b1ef8845e85b From c6a39debf9f15c4163b8228f4bf7dd14e76efd97 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 19 Jan 2025 18:32:45 +0000 Subject: [PATCH 030/115] Further refactoring of auto.def to simplify creation of variant builds like the autoconf bundle. FossilOrigin-Name: f806c563a29240c709508316846fbe0cb3ed61b68a6c1d9544eb699e30141d8d --- auto.def | 793 ++---------------------------------- autosetup/proj.tcl | 4 +- autosetup/sqlite-config.tcl | 778 ++++++++++++++++++++++++++++++++++- manifest | 16 +- manifest.uuid | 2 +- 5 files changed, 817 insertions(+), 776 deletions(-) diff --git a/auto.def b/auto.def index f807947c10..4e646e6f2b 100644 --- a/auto.def +++ b/auto.def @@ -14,17 +14,6 @@ # use sqlite-config -# $DUMP_DEFINES_TXT is the file emitted by --dump-defines, intended -# only for build debugging and not part of the public build interface. -set DUMP_DEFINES_TXT ./config.defines.txt -# $DUMP_DEFINES_JSON is the autosetup counterpart of the historical -# "DEFS" var which was generated by the autotools in the pre-processed -# autotools builds (but not in the canonical tree). Generation of this -# file is disabled (via an empty file name) until/unless someone -# voices a specific interest in it. The original motivating use case -# is handled fine by sqlite_cfg.h. -set DUMP_DEFINES_JSON ""; #./config.defines.json - ######################################################################## # Regarding flag compatibility with the historical autotool configure # script: @@ -34,10 +23,9 @@ set DUMP_DEFINES_JSON ""; #./config.defines.json # flags compared to the historical autotools build. The differences # are documented here: # -# 1) --debug is used by autosetup itself, so we have to rename it to -# --with-debug. We cannot use --enable-debug because that is, for -# autosetup, an alias for --debug=1. Alternately, we can patch -# autosetup to use --autosetup-debug for its own purposes instead. +# 1) --debug is used by autosetup itself, but we patch it because +# decades of muscle memory expect --debug to apply to this code, +# not the configure script (details are in autosetup/README.md). # # 2) In autosetup, all flags starting with (--enable, --disable) are # forced to be booleans and receive special handling in how they're @@ -199,9 +187,9 @@ set flags { test-status => {Enable status of tests} gcov=0 => {Enable coverage testing using gcov} linemacros => {Enable #line macros in the amalgamation} - dump-defines=0 => {Dump autosetup defines to $DUMP_DEFINES_TXT (for build debugging)} dynlink-tools => {Dynamically link libsqlite3 to certain tools which normally statically embed it.} soname:=legacy => + # --soname has a long story behind it: https://sqlite.org/src/forumpost/5a3b44f510df8ded {SONAME for libsqlite3.so. "none", or not using this flag, sets no soname. "legacy" sets it to its historical value of libsqlite3.so.0. A value matching the glob "libsqlite3.*" sets @@ -209,76 +197,36 @@ set flags { suffix which gets applied to "libsqlite3.so.", e.g. --soname=9.10 equates to "libsqlite3.so.9.10". } - # --soname has a long story behind it: https://sqlite.org/src/forumpost/5a3b44f510df8ded + dump-defines=0 => {Dump autosetup defines to $::sqliteConfig(dump-defines-txt) (for build debugging)} # } -if {"" ne $DUMP_DEFINES_JSON} { +if {"" ne $::sqliteConfig(dump-defines-json)} { lappend flags \ defines-json-include-lowercase=0 \ - => {Include lower-case defines (primarily system paths) in $DUMP_DEFINES_JSON} + => {Include lower-case defines (primarily system paths) in $::sqliteConfig(dump-defines-json)} } options [subst -nobackslashes -nocommands $flags] unset flags sqlite-post-options-init -set srcdir $::autosetup(srcdir) -set PACKAGE_VERSION [proj-file-content -trim $srcdir/VERSION] -define PACKAGE_NAME "sqlite" -define PACKAGE_URL {https://sqlite.org} -define PACKAGE_VERSION $PACKAGE_VERSION -define PACKAGE_STRING "[get-define PACKAGE_NAME] $PACKAGE_VERSION" -define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/forum -msg-result "Source dir = $srcdir" -msg-result "Build dir = $::autosetup(builddir)" -msg-result "Configuring SQLite version $PACKAGE_VERSION" - -# Pass msg-debug=1 to configure to enable obnoxiously loud output from -# msg-debug. -set msgDebugEnabled [proj-val-truthy [get-env msg-debug 0]] -proc msg-debug {msg} { - if {$::msgDebugEnabled} { - puts stderr [proj-bold "** DEBUG: $msg"] - } +if {1} { + # TODO: move this into autosetup/sqlite-config.tcl once we get the + # version info into autoconf/auto.def. + set srcdir $::autosetup(srcdir) + set PACKAGE_VERSION [proj-file-content -trim $srcdir/VERSION] + define PACKAGE_NAME "sqlite" + define PACKAGE_URL {https://sqlite.org} + define PACKAGE_VERSION $PACKAGE_VERSION + define PACKAGE_STRING "[get-define PACKAGE_NAME] $PACKAGE_VERSION" + define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/forum + msg-result "Source dir = $srcdir" + msg-result "Build dir = $::autosetup(builddir)" + msg-result "Configuring SQLite version $PACKAGE_VERSION" + unset srcdir } -proj-file-extensions -if {".exe" eq [get-define TARGET_EXEEXT]} { - define SQLITE_OS_UNIX 0 - define SQLITE_OS_WIN 1 -} else { - define SQLITE_OS_UNIX 1 - define SQLITE_OS_WIN 0 -} - -######### -# Programs needed -cc-check-tools ld ar ; # must come before [sqlite-check-wasi-sdk] -if {"" eq [proj-bin-define install]} { - proj-warn "Cannot find install binary, so 'make install' will not work." - define BIN_INSTALL false -} - -######################################################################## -# We differentiate between two C compilers: the one used for binaries -# which are to run on the build system (in autosetup it's called -# CC_FOR_BUILD and in Makefile.in it's $(B.cc)) and the one used for -# compiling binaries for the target system (CC a.k.a. $(T.cc)). -# Normally they're the same, but they will differ when -# cross-compiling. -# -# When cross-compiling we default to not using the -g flag, based on a -# /chat discussion prompted by -# https://sqlite.org/forum/forumpost/9a67df63eda9925c -set defaultCFlags {-O2} -if {!$::sqliteConfig(is-cross-compiling)} { - lappend defaultCFlags -g -} -define CFLAGS [proj-get-env CFLAGS $defaultCFlags] -# BUILD_CFLAGS is the CFLAGS for CC_FOR_BUILD. -define BUILD_CFLAGS [proj-get-env BUILD_CFLAGS {-g}] -unset defaultCFlags - +sqlite-setup-default-cflags proj-if-opt-truthy dev { # --enable-dev needs to come early so that the downstream tests # which check for the following flags use their updated state. @@ -287,131 +235,22 @@ proj-if-opt-truthy dev { proj-opt-set amalgamation 0 define CFLAGS [get-env CFLAGS {-O0 -g}] # -------------^^^^^^^ intentionally using [get-env] instead of - # [proj-get-env] here. + # [proj-get-env] here because [sqlite-setup-default-cflags] uses + # [proj-get-env]. } -######################################################################## -# Handle --with-wasi-sdk=DIR -# -# This must be run relatively early on because it may change the -# toolchain and disable a number of config options. -proc sqlite-check-wasi-sdk {} { - set wasiSdkDir [opt-val with-wasi-sdk] ; # ??? [lindex [opt-val with-wasi-sdk] end] - define HAVE_WASI_SDK 0 - if {$wasiSdkDir eq ""} { - return 0 - } elseif {$::sqliteConfig(is-cross-compiling)} { - proj-fatal "Cannot combine --with-wasi-sdk with cross-compilation" - } - msg-result "Checking WASI SDK directory \[$wasiSdkDir]... " - #puts "prefix = [prefix $wasiSdkDir/bin {clang ld}]" - proj-affirm-files-exist -v {*}[prefix "$wasiSdkDir/bin/" {clang wasm-ld ar}] - define HAVE_WASI_SDK 1 - define WASI_SDK_DIR $wasiSdkDir - # Disable numerous options which we know either can't work or are - # not useful in this build... - msg-result "Using wasi-sdk clang. Disabling CLI shell and modifying config flags:" - # Boolean (--enable-/--disable-) flags which must be switched off: - foreach opt { - dynlink-tools - editline - gcov - icu-collations - load-extension - readline - shared - tcl - threadsafe - } { - if {[opt-bool $opt]} { - msg-result " --disable-$opt" - proj-opt-set $opt 0 - } - } - # Non-boolean flags which need to be cleared: - foreach opt { - with-emsdk - with-icu-config - with-icu-ldflags - with-icu-cflags - with-linenoise - with-tcl - } { - if {[proj-opt-was-provided $opt]} { - msg-result " removing --$opt" - proj-opt-set $opt "" - } - } - # Remember that we now have a discrepancy beteween - # $::sqliteConfig(is-cross-compiling) and [proj-is-cross-compiling]. - set ::sqliteConfig(is-cross-compiling) 1 - - # - # Changing --host and --target have no effect here except to - # possibly cause confusion. Autosetup has finished processing them - # by this point. - # - # host_alias=wasm32-wasi - # target=wasm32-wasi - # - # Merely changing CC, LD, and AR to the wasi-sdk's is enough to get - # sqlite3.o building in WASM format. - # - define CC "${wasiSdkDir}/bin/clang" - define LD "${wasiSdkDir}/bin/wasm-ld" - define AR "${wasiSdkDir}/bin/ar" - #define STRIP "${wasiSdkDir}/bin/strip" - return 1 -}; # sqlite-check-wasi-sdk -sqlite-check-wasi-sdk - -######################################################################## -# --dynlink-tools tells the build to dynamically link certain binaries -# to libsqlite3.so instead of embedding a copy of the amalgamation. -define LINK_TOOLS_DYNAMICALLY [proj-opt-was-provided dynlink-tools] +sqlite-check-common-bins ;# must come before [sqlite-handle-wasi-sdk] +sqlite-handle-wasi-sdk ;# must run relatively early, as it changes the environment +sqlite-check-common-system-deps # # Enable large file support (if special flags are necessary) +# define HAVE_LFS 0 if {[opt-bool largefile]} { cc-check-lfs } -# -# Check for needed/wanted data types -cc-with {-includes stdint.h} \ - {cc-check-types int8_t int16_t int32_t int64_t intptr_t \ - uint8_t uint16_t uint32_t uint64_t uintptr_t} - -# -# Check for needed/wanted functions -cc-check-functions gmtime_r isnan localtime_r localtime_s \ - malloc_usable_size strchrnul usleep utime pread pread64 pwrite pwrite64 - -proj-check-function-in-lib fdatasync rt -define LDFLAGS_FDATASYNC [get-define lib_fdatasync] -undefine lib_fdatasync - -# -# Check for needed/wanted headers -cc-check-includes \ - sys/types.h sys/stat.h dlfcn.h unistd.h \ - stdlib.h malloc.h memory.h \ - string.h strings.h \ - inttypes.h - -if {[cc-check-includes zlib.h] && [proj-check-function-in-lib deflate z]} { - # TODO? port over the more sophisticated zlib search from the fossil auto.def - define HAVE_ZLIB 1 - define LDFLAGS_ZLIB -lz - sqlite-add-shell-opt -DSQLITE_HAVE_ZLIB=1 -} else { - define HAVE_ZLIB 0 - define LDFLAGS_ZLIB "" -} - -proj-check-rpath ; # Determine proper rpath-handling flag - proj-define-for-opt shared ENABLE_SHARED "Build shared library?" if {![proj-define-for-opt static ENABLE_STATIC \ @@ -429,565 +268,21 @@ proj-define-for-opt test-status TSTRNNR_OPTS \ proj-define-for-opt linemacros AMALGAMATION_LINE_MACROS \ "Use #line macros in the amalgamation:" -sqlite-check-soname -sqlite-check-debug - -######################################################################## -# TCL... -# -# sqlite-check-tcl performs most of the --with-tcl and --with-tclsh -# handling. Some related bits and pieces are performed before and -# after that function is called. -# -# Important [define]'d vars: -# -# - HAVE_TCL indicates whether we have a tclsh suitable for building -# the TCL SQLite extension and, by extension, the testing -# infrastructure. This must only be 1 for environments where -# tclConfig.sh can be found. -# -# - TCLSH_CMD is the path to the canonical tclsh or "". It never -# refers to jimtcl. -# -# - TCL_CONFIG_SH is the path to tclConfig.sh or "". -# -# - TCLLIBDIR is the dir to which libtclsqlite3 gets installed. -# -# - BTCLSH = the path to the tcl interpreter used for in-tree code -# generation. It may be jimtcl or the canonical tclsh but may not -# be empty - this tree requires TCL to generated numerous -# components. -# -# If --tcl or --with-tcl are provided but no TCL is found, this -# function fails fatally. If they are not explicitly provided then -# failure to find TCL is not fatal but a loud warning will be emitted. -# -proc sqlite-check-tcl {} { - rename sqlite-check-tcl "" - define TCLSH_CMD false ; # Significant is that it exits with non-0 - define HAVE_TCL 0 ; # Will be enabled via --tcl or a successful search - define TCLLIBDIR "" ; # Installation dir for TCL extension lib - define TCL_CONFIG_SH ""; # full path to tclConfig.sh - - # Clear out all vars which would be set by tclConfigToAutoDef.sh, so - # that the late-config validation of @VARS@ works even if - # --disable-tcl is used. - foreach k {TCL_INCLUDE_SPEC TCL_LIB_SPEC TCL_STUB_LIB_SPEC TCL_EXEC_PREFIX TCL_VERSION} { - define $k "" - } - - file delete -force ".tclenv.sh"; # ensure no stale state from previous configures. - if {![opt-bool tcl]} { - proj-indented-notice { - NOTE: TCL is disabled via --disable-tcl. This means that none - of the TCL-based components will be built, including tests - and sqlite3_analyzer. - } - return - } - # TODO: document the steps this is taking. - global srcdir - msg-result "Checking for a suitable tcl... " - proj-assert [proj-opt-truthy tcl] - set use_tcl 1 - set with_tclsh [opt-val with-tclsh] - set with_tcl [opt-val with-tcl] - if {"prefix" eq $with_tcl} { - set with_tcl [get-define prefix] - } - msg-debug "sqlite-check-tcl: use_tcl ${use_tcl}" - msg-debug "sqlite-check-tcl: with_tclsh=${with_tclsh}" - msg-debug "sqlite-check-tcl: with_tcl=$with_tcl" - if {"" eq $with_tclsh && "" eq $with_tcl} { - # If neither --with-tclsh nor --with-tcl are provided, try to find - # a workable tclsh. - set with_tclsh [proj-first-bin-of tclsh9.0 tclsh8.6 tclsh] - msg-debug "sqlite-check-tcl: with_tclsh=${with_tclsh}" - } - - set doConfigLookup 1 ; # set to 0 to test the tclConfig.sh-not-found cases - if {"" ne $with_tclsh} { - # --with-tclsh was provided or found above. Validate it and use it - # to trump any value passed via --with-tcl=DIR. - if {![file isfile $with_tclsh]} { - proj-fatal "TCL shell $with_tclsh is not a file" - } elseif {![file-isexec $with_tclsh]} { - proj-fatal "TCL shell $with_tclsh is not executable" - } else { - define TCLSH_CMD $with_tclsh - #msg-result "Using tclsh: $with_tclsh" - } - if {$doConfigLookup && - [catch {exec $with_tclsh $srcdir/tool/find_tclconfig.tcl} result] == 0} { - set with_tcl $result - } - if {"" ne $with_tcl && [file isdir $with_tcl]} { - msg-result "$with_tclsh recommends the tclConfig.sh from $with_tcl" - } else { - proj-warn "$with_tclsh is unable to recommend a tclConfig.sh" - set use_tcl 0 - } - } - set cfg "" - set tclSubdirs {tcl9.0 tcl8.6 lib} - while {$use_tcl} { - if {"" ne $with_tcl} { - # Ensure that we can find tclConfig.sh under ${with_tcl}/... - if {$doConfigLookup} { - if {[file readable "${with_tcl}/tclConfig.sh"]} { - set cfg "${with_tcl}/tclConfig.sh" - } else { - foreach i $tclSubdirs { - if {[file readable "${with_tcl}/$i/tclConfig.sh"]} { - set cfg "${with_tcl}/$i/tclConfig.sh" - break - } - } - } - } - if {"" eq $cfg} { - proj-fatal "No tclConfig.sh found under ${with_tcl}" - } - } else { - # If we have not yet found a tclConfig.sh file, look in - # $libdir which is set automatically by autosetup or by the - # --prefix command-line option. See - # https://sqlite.org/forum/forumpost/e04e693439a22457 - set libdir [get-define libdir] - if {[file readable "${libdir}/tclConfig.sh"]} { - set cfg "${libdir}/tclConfig.sh" - } else { - foreach i $tclSubdirs { - if {[file readable "${libdir}/$i/tclConfig.sh"]} { - set cfg "${libdir}/$i/tclConfig.sh" - break - } - } - } - if {![file readable $cfg]} { - break - } - } - msg-result "Using tclConfig.sh: $cfg" - break - } - define TCL_CONFIG_SH $cfg - # Export a subset of tclConfig.sh to the current TCL-space. If $cfg - # is an empty string, this emits empty-string entries for the - # various options we're interested in. - eval [exec "${srcdir}/tool/tclConfigShToAutoDef.sh" "$cfg"] - - if {"" eq $with_tclsh && $cfg ne ""} { - # We have tclConfig.sh but no tclsh. Attempt to locate a tclsh - # based on info from tclConfig.sh. - proj-assert {"" ne [get-define TCL_EXEC_PREFIX]} - set with_tclsh [get-define TCL_EXEC_PREFIX]/bin/tclsh[get-define TCL_VERSION] - if {![file-isexec $with_tclsh]} { - set with_tclsh2 [get-define TCL_EXEC_PREFIX]/bin/tclsh - if {![file-isexec $with_tclsh2]} { - proj-warn "Cannot find a usable tclsh (tried: $with_tclsh $with_tclsh2)" - } else { - set with_tclsh $with_tclsh2 - } - } - } - define TCLSH_CMD $with_tclsh - if {$use_tcl} { - # Set up the TCLLIBDIR - # - # 2024-10-28: calculation of TCLLIBDIR is now done via the shell - # in main.mk (search it for T.tcl.env.sh) so that - # static/hand-written makefiles which import main.mk do not have - # to define that before importing main.mk. Even so, we export - # TCLLIBDIR from here, which will cause the canonical makefile to - # use this one rather than to re-calculate it at make-time. - set tcllibdir [get-env TCLLIBDIR ""] - if {"" eq $tcllibdir} { - # Attempt to extract TCLLIBDIR from TCL's $auto_path - if {"" ne $with_tclsh && - [catch {exec echo "puts stdout \$auto_path" | "$with_tclsh"} result] == 0} { - foreach i $result { - if {[file isdir $i]} { - set tcllibdir $i/sqlite3 - break - } - } - } else { - proj-warn "Cannot determine TCLLIBDIR." - # The makefile will fail fatally in this case if a target is - # invoked which requires TCLLIBDIR. - } - } - #if {"" ne $tcllibdir} { msg-result "TCLLIBDIR = ${tcllibdir}"; } - define TCLLIBDIR $tcllibdir - }; # find TCLLIBDIR - - if {[file-isexec $with_tclsh]} { - msg-result "Using tclsh: $with_tclsh" - if {$cfg ne ""} { - define HAVE_TCL 1 - } else { - proj-warn "Found tclsh but no tclConfig.sh." - } - } - show-notices - # If TCL is not found: if it was explicitly requested then fail - # fatally, else just emit a warning. If we can find the APIs needed - # to generate a working JimTCL then that will suffice for build-time - # TCL purposes (see: proc sqlite-determine-codegen-tcl). - if {![get-define HAVE_TCL] && - ([proj-opt-was-provided tcl] || [proj-opt-was-provided with-tcl])} { - proj-fatal "TCL support was requested but no tclConfig.sh could be found." - } - if {"" eq $cfg} { - proj-assert {0 == [get-define HAVE_TCL]} - proj-indented-notice { - WARNING: Cannot find a usable tclConfig.sh file. Use - --with-tcl=DIR to specify a directory where tclConfig.sh can be - found. SQLite does not use TCL internally, but some optional - components require TCL, including tests and sqlite3_analyzer. - } - } -}; # sqlite-check-tcl -sqlite-check-tcl - -######################################################################## -# sqlite-determine-codegen-tcl checks which TCL to use as a code -# generator. By default, prefer jimsh simply because we have it -# in-tree (it's part of autosetup) unless --with-tclsh=X is used, in -# which case prefer X. -# -# Returns the human-readable name of the TCL it selects. Fails fatally -# if it cannot detect a TCL appropriate for code generation. -# -# Defines: -# -# - BTCLSH = the TCL shell used for code generation. It may set this -# to an unexpanded makefile var name. -# -# - CFLAGS_JIMSH = any flags needed for buildng a BTCLSH-compatible -# jimsh. The defaults may be passed on to configure as -# CFLAGS_JIMSH=... -proc sqlite-determine-codegen-tcl {} { - rename sqlite-determine-codegen-tcl "" - msg-result "Checking for TCL to use for code generation... " - define CFLAGS_JIMSH [proj-get-env CFLAGS_JIMSH {-O1}] - set cgtcl [opt-val with-tclsh jimsh] - if {"jimsh" ne $cgtcl} { - # When --with-tclsh=X is used, use that for all TCL purposes, - # including in-tree code generation, per developer request. - define BTCLSH "\$(TCLSH_CMD)" - return $cgtcl - } - set flagsToRestore {CC CFLAGS AS_CFLAGS CPPFLAGS AS_CPPFLAGS LDFLAGS LINKFLAGS LIBS CROSS} - define-push $flagsToRestore { - # We have to swap CC to CC_FOR_BUILD for purposes of the various - # [cc-...] tests below. Recall that --with-wasi-sdk may have - # swapped out CC with one which is not appropriate for this block. - # Per consulation with autosetup's creator, doing this properly - # requires us to [define-push] the whole $flagsToRestore list - # (plus a few others which are not relevant in this tree). - # - # These will get set to their previous values at the end of this - # block. - foreach flag $flagsToRestore {define $flag ""} - define CC [get-define CC_FOR_BUILD] - # These headers are technically optional for JimTCL but necessary if - # we want to use it for code generation: - set sysh [cc-check-includes dirent.h sys/time.h] - # jimsh0.c hard-codes #define's for HAVE_DIRENT_H and - # HAVE_SYS_TIME_H on the platforms it supports, so we do not - # need to add -D... flags for those. We check for them here only - # so that we can avoid the situation that we later, at - # make-time, try to compile jimsh but it then fails due to - # missing headers (i.e. fail earlier rather than later). - if {$sysh && [cc-check-functions realpath]} { - define-append CFLAGS_JIMSH -DHAVE_REALPATH - define BTCLSH "\$(JIMSH)" - set ::sqliteConfig(use-jim-for-codegen) 1 - } elseif {$sysh && [cc-check-functions _fullpath]} { - # _fullpath() is a Windows API. It's not entirely clear - # whether we need to add {-DHAVE_SYS_TIME_H -DHAVE_DIRENT_H} - # to CFLAGS_JIMSH in this case. On MinGW32 we definitely do - # not want to because it already hard-codes them. On _MSC_VER - # builds it does not. - define-append CFLAGS_JIMSH -DHAVE__FULLPATH - define BTCLSH "\$(JIMSH)" - set ::sqliteConfig(use-jim-for-codegen) 1 - } elseif {[file-isexec [get-define TCLSH_CMD]]} { - set cgtcl [get-define TCLSH_CMD] - define BTCLSH "\$(TCLSH_CMD)" - } else { - # One last-ditch effort to find TCLSH_CMD: use info from - # tclConfig.sh to try to find a tclsh - if {"" eq [get-define TCLSH_CMD]} { - set tpre [get-define TCL_EXEC_PREFIX] - if {"" ne $tpre} { - set tv [get-define TCL_VERSION] - if {[file-isexec "${tpre}/bin/tclsh${tv}"]} { - define TCLSH_CMD "${tpre}/bin/tclsh${tv}" - } elseif {[file-isexec "${tpre}/bin/tclsh"]} { - define TCLSH_CMD "${tpre}/bin/tclsh" - } - } - } - set cgtcl [get-define TCLSH_CMD] - if {![file-isexec $cgtcl]} { - proj-fatal "Cannot find a tclsh to use for code generation." - } - define BTCLSH "\$(TCLSH_CMD)" - } - }; # CC swap-out - return $cgtcl -}; # sqlite-determine-codegen-tcl -msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]" -# /TCL -######################################################################## - -######################################################################## -# Thread safety? -sqlite-check-threadsafe - -######################################################################## -# Do we want temporary databases in memory? -# -# The test fixture likes to set SQLITE_TEMP_STORE on its own, so do -# not set that feature flag unless it was explicitly provided to the -# configure script. -if {[proj-opt-was-provided with-tempstore]} { - apply {{} { - set ts [opt-val with-tempstore no] - set tsn 1 - msg-checking "Use an in-RAM database for temporary tables? " - switch -exact -- $ts { - never { set tsn 0 } - no { set tsn 1 } - yes { set tsn 2 } - always { set tsn 3 } - default { - user-error "Invalid --with-tempstore value '$ts'. Use one of: never, no, yes, always" - } - } - msg-result $ts - sqlite-add-feature-flag -DSQLITE_TEMP_STORE=$tsn - }} -} - -# Must come after sqlite-determine-codegen-tcl -msg-result "Line-editing support for the sqlite3 shell: [sqlite-check-line-editing]" - -proj-if-opt-truthy load-extension { - if {[proj-check-function-in-lib dlopen dl]} { - define LDFLAGS_DLOPEN [get-define lib_dlopen] - undefine lib_dlopen - } else { - user-error "dlopen() not found. Use --disable-load-extension to bypass this check." - } -} { - define LDFLAGS_DLOPEN "" - sqlite-add-feature-flag {-DSQLITE_OMIT_LOAD_EXTENSION=1} - msg-result "Disabling loadable extensions." -} - -proj-if-opt-truthy math { - if {![proj-check-function-in-lib ceil m]} { - user-error "Cannot find libm functions. Use --disable-math to bypass this." - } - define LDFLAGS_MATH [get-define lib_ceil] - undefine lib_ceil - sqlite-add-feature-flag {-DSQLITE_ENABLE_MATH_FUNCTIONS} - msg-result "Enabling math SQL functions [get-define LDFLAGS_MATH]" -} { - define LDFLAGS_MATH "" - msg-result "Disabling math SQL functions" -} - -sqlite-check-icu - -######################################################################## -# Check for the Emscripten SDK for building the web-based wasm -# components. The core lib and tools do not require this but ext/wasm -# does. -apply {{} { - if {$::autosetup(srcdir) ne $::autosetup(builddir)} { - # The EMSDK pieces require writing to the original source tree - # even when doing an out-of-tree build. The ext/wasm pieces do not - # support an out-of-tree build so we catch that case and treat it - # as if EMSDK were not found. - msg-result "Out-of tree build: not checking for EMSDK." - define EMCC_WRAPPER "" - return - } - set emccsh $::srcdir/tool/emcc.sh - if {![get-define HAVE_WASI_SDK] && [proj-check-emsdk]} { - define EMCC_WRAPPER $emccsh - proj-make-from-dot-in $emccsh - catch {exec chmod u+x $emccsh} - } else { - define EMCC_WRAPPER "" - file delete -force $emccsh - } -}} - -######################################################################## -# Check for log(3) in libm and die with an error if it is not -# found. $featureName should be the feature name which requires that -# function (it's used only in error messages). defines LDFLAGS_MATH to -# the required linker flags (which may be empty even if the math APIs -# are found, depending on the OS). -proc affirm-have-math {featureName} { - if {"" eq [get-define LDFLAGS_MATH ""]} { - if {![msg-quiet proj-check-function-in-lib log m]} { - user-error "Missing math APIs for $featureName" - } - define LDFLAGS_MATH [get-define lib_log ""] - undefine lib_log - } -} - -######################################################################## -# Handle various SQLITE_ENABLE_... feature flags. -msg-result "Feature flags..." -foreach {boolFlag featureFlag ifSetEvalThis} { - all {} { - # The 'all' option must be first in this list. - proj-opt-set fts4 - proj-opt-set fts5 - proj-opt-set geopoly - proj-opt-set rtree - proj-opt-set session - } - fts4 -DSQLITE_ENABLE_FTS4 {affirm-have-math fts4} - fts5 -DSQLITE_ENABLE_FTS5 {affirm-have-math fts5} - geopoly -DSQLITE_ENABLE_GEOPOLY {proj-opt-set rtree} - rtree -DSQLITE_ENABLE_RTREE {} - session {-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK} {} - update-limit -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT {} - memsys5 -DSQLITE_ENABLE_MEMSYS5 {} - memsys3 {} { - if {[opt-bool memsys5]} { - proj-warn "not enabling memsys3 because memsys5 is enabled." - expr 0 - } else { - sqlite-add-feature-flag -DSQLITE_ENABLE_MEMSYS3 - } - } - scanstatus -DSQLITE_ENABLE_STMT_SCANSTATUS {} -} { - proj-if-opt-truthy $boolFlag { - sqlite-add-feature-flag $featureFlag - if {0 != [eval $ifSetEvalThis] && "all" ne $boolFlag} { - msg-result " + $boolFlag" - } - } { - if {"all" ne $boolFlag} { - msg-result " - $boolFlag" - } - } -} - -######################################################################## -# Invert the above loop's logic for some SQLITE_OMIT_... cases. If -# config option $boolFlag is false, [sqlite-add-feature-flag -# $featureFlag], where $featureFlag is intended to be -# -DSQLITE_OMIT_... -foreach {boolFlag featureFlag} { - json -DSQLITE_OMIT_JSON -} { - if {[proj-opt-truthy $boolFlag]} { - msg-result " + $boolFlag" - } else { - sqlite-add-feature-flag $featureFlag - msg-result " - $boolFlag" - } -} +define LINK_TOOLS_DYNAMICALLY [proj-opt-was-provided dynlink-tools] +proj-check-rpath +sqlite-handle-soname +sqlite-handle-debug +sqlite-handle-tcl +sqlite-handle-threadsafe +sqlite-handle-tempstore +sqlite-handle-line-editing +sqlite-handle-load-extension +sqlite-handle-math +sqlite-handle-icu +sqlite-handle-emsdk +sqlite-handle-common-feature-flags sqlite-show-feature-flags - -######################################################################## -# When cross-compiling, we have to avoid using the -s flag to -# /usr/bin/install: https://sqlite.org/forum/forumpost/9a67df63eda9925c -define IS_CROSS_COMPILING $sqliteConfig(is-cross-compiling) - -######################################################################## -# "Re-export" the autoconf-conventional --XYZdir flags into something -# which is more easily overridable from a make invocation. See the docs -# for [proj-remap-autoconf-dir-vars] for the explanation of why. -# -# We do this late in the config process, immediately before we export -# the Makefile and other generated files, so that configure tests -# which make make use of the autotools-conventional flags -# (e.g. [proj-check-rpath]) may do so before we "mangle" them here. -proj-remap-autoconf-dir-vars - -######################################################################## -# Generate the output files. -# -# Potential TODO (unclear): in sqlite3.pc.in, do we need to include -# any CFLAGS_READLINE, CFLAGS_ZLIB, etc in its "Cflags:" section? -proj-make-from-dot-in -touch Makefile sqlite3.pc -make-config-header sqlite_cfg.h \ - -bare {SIZEOF_* HAVE_DECL_*} \ - -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG - TARGET_* USE_GCOV TCL_*} \ - -auto {HAVE_* PACKAGE_*} \ - -none * -proj-touch sqlite_cfg.h ; # help avoid frequent unnecessary @SQLITE_AUTORECONFIG@ - -######################################################################## -# Some build-dev/debug-only output -proj-if-opt-truthy dump-defines { - make-config-header $::DUMP_DEFINES_TXT \ - -bare {SQLITE_OS* SQLITE_DEBUG USE_*} \ - -str {BIN_* CC LD AR LDFLAG* OPT_*} \ - -auto {*} - # achtung: ^^^^ whichever SQLITE_OS_foo flag which is set to 0 will - # get _undefined_ here unless it's part of the -bare set. - if {"" ne $DUMP_DEFINES_JSON} { - msg-result "--dump-defines is creating $::DUMP_DEFINES_JSON" - ######################################################################## - # Dump config-defines.json... - # Demonstrate (mis?)handling of spaces in JSON-export array values: - # define-append OPT_FOO.list {"-DFOO=bar baz" -DBAR="baz barre"} - define OPT_FEATURE_FLAGS.list [get-define OPT_FEATURE_FLAGS] - define OPT_SHELL.list [get-define OPT_SHELL] - set dumpDefsOpt { - -bare {SIZEOF_* HAVE_DECL_*} - -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG TARGET_* USE_GCOV TCL_*} - -array {*.list} - -auto {OPT_* PACKAGE_* HAVE_*} - } - if {[opt-bool defines-json-include-lowercase]} { - lappend dumpDefsOpt -none {lib_*} ; # remnants from proj-check-function-in-lib and friends - lappend dumpDefsOpt -auto {[a-z]*} - } - lappend dumpDefsOpt -none * - proj-dump-defs-json $DUMP_DEFINES_JSON {*}$dumpDefsOpt - undefine OPT_FEATURE_FLAGS.list - undefine OPT_SHELL.list - } -} - -######################################################################## -# Perform some high-level validation on the generated files... -# -# 1) Ensure that no unresolved @VAR@ placeholders are in files which -# use those. -# -# 2) TBD -apply {{} { - # Check #1: ensure that files which get filtered for @VAR@ do not - # contain any unresolved @VAR@ refs. That may indicate an - # unexported/unused var or a typo. - foreach f "Makefile sqlite3.pc $::srcdir/tool/emcc.sh" { - if {![file exists $f]} continue - set lnno 1 - foreach line [proj-file-content-list $f] { - if {[regexp {(@[A-Za-z_]+@)} $line match]} { - error "Unresolved reference to $match at line $lnno of $f" - } - incr lnno - } - } -}} - +sqlite-process-dot-in-files +sqlite-post-config-validation +sqlite-dump-defines diff --git a/autosetup/proj.tcl b/autosetup/proj.tcl index a469c898de..915a6b1349 100644 --- a/autosetup/proj.tcl +++ b/autosetup/proj.tcl @@ -184,7 +184,7 @@ proc proj-lshift_ {listVar {count 1}} { # out any lines which begin with an number of whitespace followed by a # '#', and returns a value containing the [append]ed results of each # remaining line with a \n between each. -proc proj-strip-hash-comments_ {val} { +proc proj-strip-hash-comments {val} { set x {} foreach line [split $val \n] { if {![string match "#*" [string trimleft $line]]} { @@ -1119,7 +1119,7 @@ proc proj-dump-defs-json {file args} { # that [opt-value canonical] will return X if --alias=X is passed to # configure. proc proj-xfer-options-aliases {mapping} { - foreach {hidden - canonical} [proj-strip-hash-comments_ $mapping] { + foreach {hidden - canonical} [proj-strip-hash-comments $mapping] { if {[proj-opt-was-provided $hidden]} { if {[proj-opt-was-provided $canonical]} { proj-fatal "both --$canonical and its alias --$hidden were used. Use only one or the other." diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 6b036b529c..08bd0467e5 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -9,7 +9,29 @@ use cc cc-db cc-shared cc-lib pkg-config proj # Object for communicating config-time state across various # auto.def-related pieces. # -array set sqliteConfig {} +array set sqliteConfig [proj-strip-hash-comments { + # + # Gets set to 1 when using jimsh for code generation. May affect + # later decisions. + use-jim-for-codegen 0 + # + # Pass msg-debug=1 to configure to enable obnoxiously loud output + # from [msg-debug]. + msg-debug-enabled 0 + # + # Output file for --dump-defines. Intended only for build debugging + # and not part of the public build interface. + dump-defines-txt ./config.defines.txt + # + # Output file for --dump-defines-json. This is the autosetup + # counterpart of the historical "DEFS" var which was generated by + # the autotools in the pre-processed autotools builds (but not in + # the canonical tree). Generation of this file is disabled (via an + # empty file name) until/unless someone voices a specific interest + # in it. The original motivating use case is handled fine by + # sqlite_cfg.h. + dump-defines-json "" +}] # # Set to 1 when cross-compiling This value may be changed by certain @@ -19,13 +41,6 @@ array set sqliteConfig {} # set sqliteConfig(is-cross-compiling) [proj-is-cross-compiling] -# -# Gets set to 1 when using jimsh for code generation. May affect later -# decisions. -# -set sqliteConfig(use-jim-for-codegen) 0 - - ######################################################################## # Runs some common initialization which must happen immediately after # autosetup's [options] function is called. @@ -41,6 +56,23 @@ proc sqlite-post-options-init {} { with-debug => debug } sqlite-autoreconfig + proj-file-extensions + if {".exe" eq [get-define TARGET_EXEEXT]} { + define SQLITE_OS_UNIX 0 + define SQLITE_OS_WIN 1 + } else { + define SQLITE_OS_UNIX 1 + define SQLITE_OS_WIN 0 + } + + set ::sqliteConfig(msg-debug-enabled) [proj-val-truthy [get-env msg-debug 0]] + +} + +proc msg-debug {msg} { + if {$::sqliteConfig(msg-debug-enabled)} { + puts stderr [proj-bold "** DEBUG: $msg"] + } } ######################################################################## @@ -92,6 +124,151 @@ proc sqlite-add-shell-opt {args} { } } +######################################################################## +# Check for log(3) in libm and die with an error if it is not +# found. $featureName should be the feature name which requires that +# function (it's used only in error messages). defines LDFLAGS_MATH to +# the required linker flags (which may be empty even if the math APIs +# are found, depending on the OS). +proc sqlite-affirm-have-math {featureName} { + if {"" eq [get-define LDFLAGS_MATH ""]} { + if {![msg-quiet proj-check-function-in-lib log m]} { + user-error "Missing math APIs for $featureName" + } + define LDFLAGS_MATH [get-define lib_log ""] + undefine lib_log + } +} + +######################################################################## +# Run checks for required binaries, like ld and ar. In the canonical +# build this must come before [sqlite-handle-wasi-sdk]. +proc sqlite-check-common-bins {} { + cc-check-tools ld ar ; # must come before [sqlite-handle-wasi-sdk] + if {"" eq [proj-bin-define install]} { + proj-warn "Cannot find install binary, so 'make install' will not work." + define BIN_INSTALL false + } +} + +######################################################################## +# Run checks for system-level includes and libs which are common to +# both the canonical build and the "autoconf" bundle. +proc sqlite-check-common-system-deps {} { + # + # Check for needed/wanted data types + cc-with {-includes stdint.h} \ + {cc-check-types int8_t int16_t int32_t int64_t intptr_t \ + uint8_t uint16_t uint32_t uint64_t uintptr_t} + + # + # Check for needed/wanted functions + cc-check-functions gmtime_r isnan localtime_r localtime_s \ + malloc_usable_size strchrnul usleep utime pread pread64 pwrite pwrite64 + + proj-check-function-in-lib fdatasync rt + define LDFLAGS_FDATASYNC [get-define lib_fdatasync] + undefine lib_fdatasync + + # + # Check for needed/wanted headers + cc-check-includes \ + sys/types.h sys/stat.h dlfcn.h unistd.h \ + stdlib.h malloc.h memory.h \ + string.h strings.h \ + inttypes.h + + if {[cc-check-includes zlib.h] && [proj-check-function-in-lib deflate z]} { + # TODO? port over the more sophisticated zlib search from the fossil auto.def + define HAVE_ZLIB 1 + define LDFLAGS_ZLIB -lz + sqlite-add-shell-opt -DSQLITE_HAVE_ZLIB=1 + } else { + define HAVE_ZLIB 0 + define LDFLAGS_ZLIB "" + } +} + +proc sqlite-setup-default-cflags {} { + ######################################################################## + # We differentiate between two C compilers: the one used for binaries + # which are to run on the build system (in autosetup it's called + # CC_FOR_BUILD and in Makefile.in it's $(B.cc)) and the one used for + # compiling binaries for the target system (CC a.k.a. $(T.cc)). + # Normally they're the same, but they will differ when + # cross-compiling. + # + # When cross-compiling we default to not using the -g flag, based on a + # /chat discussion prompted by + # https://sqlite.org/forum/forumpost/9a67df63eda9925c + set defaultCFlags {-O2} + if {!$::sqliteConfig(is-cross-compiling)} { + lappend defaultCFlags -g + } + define CFLAGS [proj-get-env CFLAGS $defaultCFlags] + # BUILD_CFLAGS is the CFLAGS for CC_FOR_BUILD. + define BUILD_CFLAGS [proj-get-env BUILD_CFLAGS {-g}] +} + +######################################################################## +# Handle various SQLITE_ENABLE_... feature flags. +proc sqlite-handle-common-feature-flags {} { + msg-result "Feature flags..." + foreach {boolFlag featureFlag ifSetEvalThis} { + all {} { + # The 'all' option must be first in this list. + proj-opt-set fts4 + proj-opt-set fts5 + proj-opt-set geopoly + proj-opt-set rtree + proj-opt-set session + } + fts4 -DSQLITE_ENABLE_FTS4 {sqlite-affirm-have-math fts4} + fts5 -DSQLITE_ENABLE_FTS5 {sqlite-affirm-have-math fts5} + geopoly -DSQLITE_ENABLE_GEOPOLY {proj-opt-set rtree} + rtree -DSQLITE_ENABLE_RTREE {} + session {-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK} {} + update-limit -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT {} + memsys5 -DSQLITE_ENABLE_MEMSYS5 {} + memsys3 {} { + if {[opt-bool memsys5]} { + proj-warn "not enabling memsys3 because memsys5 is enabled." + expr 0 + } else { + sqlite-add-feature-flag -DSQLITE_ENABLE_MEMSYS3 + } + } + scanstatus -DSQLITE_ENABLE_STMT_SCANSTATUS {} + } { + proj-if-opt-truthy $boolFlag { + sqlite-add-feature-flag $featureFlag + if {0 != [eval $ifSetEvalThis] && "all" ne $boolFlag} { + msg-result " + $boolFlag" + } + } { + if {"all" ne $boolFlag} { + msg-result " - $boolFlag" + } + } + } + ######################################################################## + # Invert the above loop's logic for some SQLITE_OMIT_... cases. If + # config option $boolFlag is false, [sqlite-add-feature-flag + # $featureFlag], where $featureFlag is intended to be + # -DSQLITE_OMIT_... + foreach {boolFlag featureFlag} { + json -DSQLITE_OMIT_JSON + } { + if {[proj-opt-truthy $boolFlag]} { + msg-result " + $boolFlag" + } else { + sqlite-add-feature-flag $featureFlag + msg-result " - $boolFlag" + } + } + +} + ######################################################################### # Show the final feature flag sets. proc sqlite-show-feature-flags {} { @@ -112,7 +289,7 @@ proc sqlite-show-feature-flags {} { # Checks for the --debug flag, defining SQLITE_DEBUG to 1 if it is # true. TARGET_DEBUG gets defined either way, with content depending # on whether --debug is true or false. -proc sqlite-check-debug {} { +proc sqlite-handle-debug {} { msg-checking "SQLITE_DEBUG build? " proj-if-opt-truthy debug { define SQLITE_DEBUG 1 @@ -128,7 +305,7 @@ proc sqlite-check-debug {} { ######################################################################## # "soname" for libsqlite3.so. See discussion at: # https://sqlite.org/src/forumpost/5a3b44f510df8ded -proc sqlite-check-soname {} { +proc sqlite-handle-soname {} { define LDFLAGS_LIBSQLITE3_SONAME "" if {[proj-opt-was-provided soname]} { set soname [join [opt-val soname] ""] @@ -151,7 +328,7 @@ proc sqlite-check-soname {} { } } } - # msg-debug "soname=$soname" + msg-debug "soname=$soname" if {[proj-check-soname $soname]} { define LDFLAGS_LIBSQLITE3_SONAME [get-define LDFLAGS_SONAME_PREFIX]$soname msg-result "Setting SONAME using: [get-define LDFLAGS_LIBSQLITE3_SONAME]" @@ -170,7 +347,7 @@ proc sqlite-check-soname {} { # needed for linking pthread. If --enable-threadsafe is not set, adds # -DSQLITE_THREADSAFE=0 to OPT_FEATURE_FLAGS and sets LDFLAGS_PTHREAD # to an empty string. -proc sqlite-check-threadsafe {} { +proc sqlite-handle-threadsafe {} { msg-checking "Support threadsafe operation? " proj-if-opt-truthy threadsafe { msg-result yes @@ -190,6 +367,57 @@ proc sqlite-check-threadsafe {} { } } +######################################################################## +# Handles the --with-tempstore flag. +# +# The test fixture likes to set SQLITE_TEMP_STORE on its own, so do +# not set that feature flag unless it was explicitly provided to the +# configure script. +proc sqlite-handle-tempstore {} { + if {[proj-opt-was-provided with-tempstore]} { + set ts [opt-val with-tempstore no] + set tsn 1 + msg-checking "Use an in-RAM database for temporary tables? " + switch -exact -- $ts { + never { set tsn 0 } + no { set tsn 1 } + yes { set tsn 2 } + always { set tsn 3 } + default { + user-error "Invalid --with-tempstore value '$ts'. Use one of: never, no, yes, always" + } + } + msg-result $ts + sqlite-add-feature-flag -DSQLITE_TEMP_STORE=$tsn + } +} + +######################################################################## +# Check for the Emscripten SDK for building the web-based wasm +# components. The core lib and tools do not require this but ext/wasm +# does. +proc sqlite-handle-emsdk {} { + set srcdir $::autosetup(srcdir) + if {$srcdir ne $::autosetup(builddir)} { + # The EMSDK pieces require writing to the original source tree + # even when doing an out-of-tree build. The ext/wasm pieces do not + # support an out-of-tree build so we catch that case and treat it + # as if EMSDK were not found. + msg-result "Out-of tree build: not checking for EMSDK." + define EMCC_WRAPPER "" + return + } + set emccsh $srcdir/tool/emcc.sh + if {![get-define HAVE_WASI_SDK] && [proj-check-emsdk]} { + define EMCC_WRAPPER $emccsh + proj-make-from-dot-in $emccsh + catch {exec chmod u+x $emccsh} + } else { + define EMCC_WRAPPER "" + file delete -force $emccsh + } +} + ######################################################################## # sqlite-check-line-editing jumps through proverbial hoops to try to # find a working line-editing library, setting: @@ -227,7 +455,6 @@ proc sqlite-check-threadsafe {} { # corresponding --FEATURE flag was explicitly given, fail fatally, # else fail silently. proc sqlite-check-line-editing {} { - rename sqlite-check-line-editing "" msg-result "Checking for line-editing capability..." define HAVE_READLINE 0 define HAVE_LINENOISE 0 @@ -430,6 +657,15 @@ proc sqlite-check-line-editing {} { return "none" }; # sqlite-check-line-editing +######################################################################## +# Runs sqlite-check-line-editing and adds a message around it In the +# canonical build this must not be called before +# sqlite-determine-codegen-tcl. +proc sqlite-handle-line-editing {} { + msg-result "Line-editing support for the sqlite3 shell: [sqlite-check-line-editing]" +} + + ######################################################################## # ICU - International Components for Unicode # @@ -457,8 +693,7 @@ proc sqlite-check-line-editing {} { # Design note: though we could automatically enable ICU if the # icu-config binary or (pkg-config icu-io) are found, we specifically # do not. ICU is always an opt-in feature. -proc sqlite-check-icu {} { - rename sqlite-check-icu "" +proc sqlite-handle-icu {} { define LDFLAGS_ICU [join [opt-val with-icu-ldflags ""]] define CFLAGS_ICU [join [opt-val with-icu-cflags ""]] if {[proj-opt-was-provided with-icu-config]} { @@ -516,4 +751,515 @@ proc sqlite-check-icu {} { } else { msg-result "ICU support is disabled." } -}; # sqlite-check-icu +}; # sqlite-handle-icu + + +######################################################################## +# Handles the --enable-load-extension flag. +proc sqlite-handle-load-extension {} { + proj-if-opt-truthy load-extension { + if {[proj-check-function-in-lib dlopen dl]} { + define LDFLAGS_DLOPEN [get-define lib_dlopen] + undefine lib_dlopen + } else { + user-error "dlopen() not found. Use --disable-load-extension to bypass this check." + } + } { + define LDFLAGS_DLOPEN "" + sqlite-add-feature-flag {-DSQLITE_OMIT_LOAD_EXTENSION=1} + msg-result "Disabling loadable extensions." + } +} + +######################################################################## +# Handles the --enable-math flag. +proc sqlite-handle-math {} { + proj-if-opt-truthy math { + if {![proj-check-function-in-lib ceil m]} { + user-error "Cannot find libm functions. Use --disable-math to bypass this." + } + define LDFLAGS_MATH [get-define lib_ceil] + undefine lib_ceil + sqlite-add-feature-flag {-DSQLITE_ENABLE_MATH_FUNCTIONS} + msg-result "Enabling math SQL functions [get-define LDFLAGS_MATH]" + } { + define LDFLAGS_MATH "" + msg-result "Disabling math SQL functions" + } +} + +######################################################################## +# Generate the configure-process output file(s). +proc sqlite-process-dot-in-files {} { + ######################################################################## + # When cross-compiling, we have to avoid using the -s flag to + # /usr/bin/install: https://sqlite.org/forum/forumpost/9a67df63eda9925c + define IS_CROSS_COMPILING $::sqliteConfig(is-cross-compiling) + + ######################################################################## + # "Re-export" the autoconf-conventional --XYZdir flags into something + # which is more easily overridable from a make invocation. See the docs + # for [proj-remap-autoconf-dir-vars] for the explanation of why. + # + # We do this late in the config process, immediately before we export + # the Makefile and other generated files, so that configure tests + # which make make use of the autotools-conventional flags + # (e.g. [proj-check-rpath]) may do so before we "mangle" them here. + proj-remap-autoconf-dir-vars + + proj-make-from-dot-in -touch Makefile sqlite3.pc + make-config-header sqlite_cfg.h \ + -bare {SIZEOF_* HAVE_DECL_*} \ + -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG + TARGET_* USE_GCOV TCL_*} \ + -auto {HAVE_* PACKAGE_*} \ + -none * + proj-touch sqlite_cfg.h ; # help avoid frequent unnecessary @SQLITE_AUTORECONFIG@ +} + +######################################################################## +# Perform some high-level validation on the generated files... +# +# 1) Ensure that no unresolved @VAR@ placeholders are in files which +# use those. +# +# 2) TBD +proc sqlite-post-config-validation {} { + # Check #1: ensure that files which get filtered for @VAR@ do not + # contain any unresolved @VAR@ refs. That may indicate an + # unexported/unused var or a typo. + foreach f "Makefile sqlite3.pc $::autosetup(srcdir)/tool/emcc.sh" { + if {![file exists $f]} continue + set lnno 1 + foreach line [proj-file-content-list $f] { + if {[regexp {(@[A-Za-z_]+@)} $line match]} { + error "Unresolved reference to $match at line $lnno of $f" + } + incr lnno + } + } +} + +######################################################################## +# Handle --with-wasi-sdk[=DIR] +# +# This must be run relatively early on because it may change the +# toolchain and disable a number of config options. However, in the +# canonical build this must come after [sqlite-check-common-bins]. +proc sqlite-handle-wasi-sdk {} { + set wasiSdkDir [opt-val with-wasi-sdk] ; # ??? [lindex [opt-val with-wasi-sdk] end] + define HAVE_WASI_SDK 0 + if {$wasiSdkDir eq ""} { + return 0 + } elseif {$::sqliteConfig(is-cross-compiling)} { + proj-fatal "Cannot combine --with-wasi-sdk with cross-compilation" + } + msg-result "Checking WASI SDK directory \[$wasiSdkDir]... " + proj-affirm-files-exist -v {*}[prefix "$wasiSdkDir/bin/" {clang wasm-ld ar}] + define HAVE_WASI_SDK 1 + define WASI_SDK_DIR $wasiSdkDir + # Disable numerous options which we know either can't work or are + # not useful in this build... + msg-result "Using wasi-sdk clang. Disabling CLI shell and modifying config flags:" + # Boolean (--enable-/--disable-) flags which must be switched off: + foreach opt { + dynlink-tools + editline + gcov + icu-collations + load-extension + readline + shared + tcl + threadsafe + } { + if {[opt-bool $opt]} { + msg-result " --disable-$opt" + proj-opt-set $opt 0 + } + } + # Non-boolean flags which need to be cleared: + foreach opt { + with-emsdk + with-icu-config + with-icu-ldflags + with-icu-cflags + with-linenoise + with-tcl + } { + if {[proj-opt-was-provided $opt]} { + msg-result " removing --$opt" + proj-opt-set $opt "" + } + } + # Remember that we now have a discrepancy beteween + # $::sqliteConfig(is-cross-compiling) and [proj-is-cross-compiling]. + set ::sqliteConfig(is-cross-compiling) 1 + + # + # Changing --host and --target have no effect here except to + # possibly cause confusion. Autosetup has finished processing them + # by this point. + # + # host_alias=wasm32-wasi + # target=wasm32-wasi + # + # Merely changing CC, LD, and AR to the wasi-sdk's is enough to get + # sqlite3.o building in WASM format. + # + define CC "${wasiSdkDir}/bin/clang" + define LD "${wasiSdkDir}/bin/wasm-ld" + define AR "${wasiSdkDir}/bin/ar" + #define STRIP "${wasiSdkDir}/bin/strip" + return 1 +}; # sqlite-handle-wasi-sdk + +######################################################################## +# TCL... +# +# sqlite-check-tcl performs most of the --with-tcl and --with-tclsh +# handling. Some related bits and pieces are performed before and +# after that function is called. +# +# Important [define]'d vars: +# +# - HAVE_TCL indicates whether we have a tclsh suitable for building +# the TCL SQLite extension and, by extension, the testing +# infrastructure. This must only be 1 for environments where +# tclConfig.sh can be found. +# +# - TCLSH_CMD is the path to the canonical tclsh or "". It never +# refers to jimtcl. +# +# - TCL_CONFIG_SH is the path to tclConfig.sh or "". +# +# - TCLLIBDIR is the dir to which libtclsqlite3 gets installed. +# +# - BTCLSH = the path to the tcl interpreter used for in-tree code +# generation. It may be jimtcl or the canonical tclsh but may not +# be empty - this tree requires TCL to generated numerous +# components. +# +# If --tcl or --with-tcl are provided but no TCL is found, this +# function fails fatally. If they are not explicitly provided then +# failure to find TCL is not fatal but a loud warning will be emitted. +# +proc sqlite-check-tcl {} { + define TCLSH_CMD false ; # Significant is that it exits with non-0 + define HAVE_TCL 0 ; # Will be enabled via --tcl or a successful search + define TCLLIBDIR "" ; # Installation dir for TCL extension lib + define TCL_CONFIG_SH ""; # full path to tclConfig.sh + + # Clear out all vars which would be set by tclConfigToAutoDef.sh, so + # that the late-config validation of @VARS@ works even if + # --disable-tcl is used. + foreach k {TCL_INCLUDE_SPEC TCL_LIB_SPEC TCL_STUB_LIB_SPEC TCL_EXEC_PREFIX TCL_VERSION} { + define $k "" + } + + file delete -force ".tclenv.sh"; # ensure no stale state from previous configures. + if {![opt-bool tcl]} { + proj-indented-notice { + NOTE: TCL is disabled via --disable-tcl. This means that none + of the TCL-based components will be built, including tests + and sqlite3_analyzer. + } + return + } + # TODO: document the steps this is taking. + set srcdir $::autosetup(srcdir) + msg-result "Checking for a suitable tcl... " + proj-assert [proj-opt-truthy tcl] + set use_tcl 1 + set with_tclsh [opt-val with-tclsh] + set with_tcl [opt-val with-tcl] + if {"prefix" eq $with_tcl} { + set with_tcl [get-define prefix] + } + msg-debug "sqlite-check-tcl: use_tcl ${use_tcl}" + msg-debug "sqlite-check-tcl: with_tclsh=${with_tclsh}" + msg-debug "sqlite-check-tcl: with_tcl=$with_tcl" + if {"" eq $with_tclsh && "" eq $with_tcl} { + # If neither --with-tclsh nor --with-tcl are provided, try to find + # a workable tclsh. + set with_tclsh [proj-first-bin-of tclsh9.0 tclsh8.6 tclsh] + msg-debug "sqlite-check-tcl: with_tclsh=${with_tclsh}" + } + + set doConfigLookup 1 ; # set to 0 to test the tclConfig.sh-not-found cases + if {"" ne $with_tclsh} { + # --with-tclsh was provided or found above. Validate it and use it + # to trump any value passed via --with-tcl=DIR. + if {![file isfile $with_tclsh]} { + proj-fatal "TCL shell $with_tclsh is not a file" + } elseif {![file-isexec $with_tclsh]} { + proj-fatal "TCL shell $with_tclsh is not executable" + } else { + define TCLSH_CMD $with_tclsh + #msg-result "Using tclsh: $with_tclsh" + } + if {$doConfigLookup && + [catch {exec $with_tclsh $srcdir/tool/find_tclconfig.tcl} result] == 0} { + set with_tcl $result + } + if {"" ne $with_tcl && [file isdir $with_tcl]} { + msg-result "$with_tclsh recommends the tclConfig.sh from $with_tcl" + } else { + proj-warn "$with_tclsh is unable to recommend a tclConfig.sh" + set use_tcl 0 + } + } + set cfg "" + set tclSubdirs {tcl9.0 tcl8.6 lib} + while {$use_tcl} { + if {"" ne $with_tcl} { + # Ensure that we can find tclConfig.sh under ${with_tcl}/... + if {$doConfigLookup} { + if {[file readable "${with_tcl}/tclConfig.sh"]} { + set cfg "${with_tcl}/tclConfig.sh" + } else { + foreach i $tclSubdirs { + if {[file readable "${with_tcl}/$i/tclConfig.sh"]} { + set cfg "${with_tcl}/$i/tclConfig.sh" + break + } + } + } + } + if {"" eq $cfg} { + proj-fatal "No tclConfig.sh found under ${with_tcl}" + } + } else { + # If we have not yet found a tclConfig.sh file, look in + # $libdir which is set automatically by autosetup or by the + # --prefix command-line option. See + # https://sqlite.org/forum/forumpost/e04e693439a22457 + set libdir [get-define libdir] + if {[file readable "${libdir}/tclConfig.sh"]} { + set cfg "${libdir}/tclConfig.sh" + } else { + foreach i $tclSubdirs { + if {[file readable "${libdir}/$i/tclConfig.sh"]} { + set cfg "${libdir}/$i/tclConfig.sh" + break + } + } + } + if {![file readable $cfg]} { + break + } + } + msg-result "Using tclConfig.sh: $cfg" + break + } + define TCL_CONFIG_SH $cfg + # Export a subset of tclConfig.sh to the current TCL-space. If $cfg + # is an empty string, this emits empty-string entries for the + # various options we're interested in. + eval [exec "$srcdir/tool/tclConfigShToAutoDef.sh" "$cfg"] + + if {"" eq $with_tclsh && $cfg ne ""} { + # We have tclConfig.sh but no tclsh. Attempt to locate a tclsh + # based on info from tclConfig.sh. + proj-assert {"" ne [get-define TCL_EXEC_PREFIX]} + set with_tclsh [get-define TCL_EXEC_PREFIX]/bin/tclsh[get-define TCL_VERSION] + if {![file-isexec $with_tclsh]} { + set with_tclsh2 [get-define TCL_EXEC_PREFIX]/bin/tclsh + if {![file-isexec $with_tclsh2]} { + proj-warn "Cannot find a usable tclsh (tried: $with_tclsh $with_tclsh2)" + } else { + set with_tclsh $with_tclsh2 + } + } + } + define TCLSH_CMD $with_tclsh + if {$use_tcl} { + # Set up the TCLLIBDIR + # + # 2024-10-28: calculation of TCLLIBDIR is now done via the shell + # in main.mk (search it for T.tcl.env.sh) so that + # static/hand-written makefiles which import main.mk do not have + # to define that before importing main.mk. Even so, we export + # TCLLIBDIR from here, which will cause the canonical makefile to + # use this one rather than to re-calculate it at make-time. + set tcllibdir [get-env TCLLIBDIR ""] + if {"" eq $tcllibdir} { + # Attempt to extract TCLLIBDIR from TCL's $auto_path + if {"" ne $with_tclsh && + [catch {exec echo "puts stdout \$auto_path" | "$with_tclsh"} result] == 0} { + foreach i $result { + if {[file isdir $i]} { + set tcllibdir $i/sqlite3 + break + } + } + } else { + proj-warn "Cannot determine TCLLIBDIR." + # The makefile will fail fatally in this case if a target is + # invoked which requires TCLLIBDIR. + } + } + #if {"" ne $tcllibdir} { msg-result "TCLLIBDIR = ${tcllibdir}"; } + define TCLLIBDIR $tcllibdir + }; # find TCLLIBDIR + + if {[file-isexec $with_tclsh]} { + msg-result "Using tclsh: $with_tclsh" + if {$cfg ne ""} { + define HAVE_TCL 1 + } else { + proj-warn "Found tclsh but no tclConfig.sh." + } + } + show-notices + # If TCL is not found: if it was explicitly requested then fail + # fatally, else just emit a warning. If we can find the APIs needed + # to generate a working JimTCL then that will suffice for build-time + # TCL purposes (see: proc sqlite-determine-codegen-tcl). + if {![get-define HAVE_TCL] && + ([proj-opt-was-provided tcl] || [proj-opt-was-provided with-tcl])} { + proj-fatal "TCL support was requested but no tclConfig.sh could be found." + } + if {"" eq $cfg} { + proj-assert {0 == [get-define HAVE_TCL]} + proj-indented-notice { + WARNING: Cannot find a usable tclConfig.sh file. Use + --with-tcl=DIR to specify a directory where tclConfig.sh can be + found. SQLite does not use TCL internally, but some optional + components require TCL, including tests and sqlite3_analyzer. + } + } +}; # sqlite-check-tcl + +######################################################################## +# sqlite-determine-codegen-tcl checks which TCL to use as a code +# generator. By default, prefer jimsh simply because we have it +# in-tree (it's part of autosetup) unless --with-tclsh=X is used, in +# which case prefer X. +# +# Returns the human-readable name of the TCL it selects. Fails fatally +# if it cannot detect a TCL appropriate for code generation. +# +# Defines: +# +# - BTCLSH = the TCL shell used for code generation. It may set this +# to an unexpanded makefile var name. +# +# - CFLAGS_JIMSH = any flags needed for buildng a BTCLSH-compatible +# jimsh. The defaults may be passed on to configure as +# CFLAGS_JIMSH=... +proc sqlite-determine-codegen-tcl {} { + msg-result "Checking for TCL to use for code generation... " + define CFLAGS_JIMSH [proj-get-env CFLAGS_JIMSH {-O1}] + set cgtcl [opt-val with-tclsh jimsh] + if {"jimsh" ne $cgtcl} { + # When --with-tclsh=X is used, use that for all TCL purposes, + # including in-tree code generation, per developer request. + define BTCLSH "\$(TCLSH_CMD)" + return $cgtcl + } + set flagsToRestore {CC CFLAGS AS_CFLAGS CPPFLAGS AS_CPPFLAGS LDFLAGS LINKFLAGS LIBS CROSS} + define-push $flagsToRestore { + # We have to swap CC to CC_FOR_BUILD for purposes of the various + # [cc-...] tests below. Recall that --with-wasi-sdk may have + # swapped out CC with one which is not appropriate for this block. + # Per consulation with autosetup's creator, doing this properly + # requires us to [define-push] the whole $flagsToRestore list + # (plus a few others which are not relevant in this tree). + # + # These will get set to their previous values at the end of this + # block. + foreach flag $flagsToRestore {define $flag ""} + define CC [get-define CC_FOR_BUILD] + # These headers are technically optional for JimTCL but necessary if + # we want to use it for code generation: + set sysh [cc-check-includes dirent.h sys/time.h] + # jimsh0.c hard-codes #define's for HAVE_DIRENT_H and + # HAVE_SYS_TIME_H on the platforms it supports, so we do not + # need to add -D... flags for those. We check for them here only + # so that we can avoid the situation that we later, at + # make-time, try to compile jimsh but it then fails due to + # missing headers (i.e. fail earlier rather than later). + if {$sysh && [cc-check-functions realpath]} { + define-append CFLAGS_JIMSH -DHAVE_REALPATH + define BTCLSH "\$(JIMSH)" + set ::sqliteConfig(use-jim-for-codegen) 1 + } elseif {$sysh && [cc-check-functions _fullpath]} { + # _fullpath() is a Windows API. It's not entirely clear + # whether we need to add {-DHAVE_SYS_TIME_H -DHAVE_DIRENT_H} + # to CFLAGS_JIMSH in this case. On MinGW32 we definitely do + # not want to because it already hard-codes them. On _MSC_VER + # builds it does not. + define-append CFLAGS_JIMSH -DHAVE__FULLPATH + define BTCLSH "\$(JIMSH)" + set ::sqliteConfig(use-jim-for-codegen) 1 + } elseif {[file-isexec [get-define TCLSH_CMD]]} { + set cgtcl [get-define TCLSH_CMD] + define BTCLSH "\$(TCLSH_CMD)" + } else { + # One last-ditch effort to find TCLSH_CMD: use info from + # tclConfig.sh to try to find a tclsh + if {"" eq [get-define TCLSH_CMD]} { + set tpre [get-define TCL_EXEC_PREFIX] + if {"" ne $tpre} { + set tv [get-define TCL_VERSION] + if {[file-isexec "${tpre}/bin/tclsh${tv}"]} { + define TCLSH_CMD "${tpre}/bin/tclsh${tv}" + } elseif {[file-isexec "${tpre}/bin/tclsh"]} { + define TCLSH_CMD "${tpre}/bin/tclsh" + } + } + } + set cgtcl [get-define TCLSH_CMD] + if {![file-isexec $cgtcl]} { + proj-fatal "Cannot find a tclsh to use for code generation." + } + define BTCLSH "\$(TCLSH_CMD)" + } + }; # CC swap-out + return $cgtcl +}; # sqlite-determine-codegen-tcl + +######################################################################## +# Runs sqlite-check-tcl and sqlite-determine-codegen-tcl. +proc sqlite-handle-tcl {} { + sqlite-check-tcl + msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]" +} + +######################################################################## +# If the --dump-defines configure flag is provided then emit a list of +# all [define] values to config.defines.txt, else do nothing. +proc sqlite-dump-defines {} { + proj-if-opt-truthy dump-defines { + make-config-header $::sqliteConfig(dump-defines-txt) \ + -bare {SQLITE_OS* SQLITE_DEBUG USE_*} \ + -str {BIN_* CC LD AR LDFLAG* OPT_*} \ + -auto {*} + # achtung: ^^^^ whichever SQLITE_OS_foo flag which is set to 0 will + # get _undefined_ here unless it's part of the -bare set. + if {"" ne $::sqliteConfig(dump-defines-json)} { + msg-result "--dump-defines is creating $::sqliteConfig(dump-defines-json)" + ######################################################################## + # Dump config-defines.json... + # Demonstrate (mis?)handling of spaces in JSON-export array values: + # define-append OPT_FOO.list {"-DFOO=bar baz" -DBAR="baz barre"} + define OPT_FEATURE_FLAGS.list [get-define OPT_FEATURE_FLAGS] + define OPT_SHELL.list [get-define OPT_SHELL] + set dumpDefsOpt { + -bare {SIZEOF_* HAVE_DECL_*} + -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG TARGET_* USE_GCOV TCL_*} + -array {*.list} + -auto {OPT_* PACKAGE_* HAVE_*} + } + if {[opt-bool defines-json-include-lowercase]} { + lappend dumpDefsOpt -none {lib_*} ; # remnants from proj-check-function-in-lib and friends + lappend dumpDefsOpt -auto {[a-z]*} + } + lappend dumpDefsOpt -none * + proj-dump-defs-json $::sqliteConfig(dump-defines-json) {*}$dumpDefsOpt + undefine OPT_FEATURE_FLAGS.list + undefine OPT_SHELL.list + } + } +} diff --git a/manifest b/manifest index 02e383c8f0..2bd5902120 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sinternal\srefactoring\sof\sauto.def\sto\ssupport\sthe\spending\sautoconf\ssubdir\sport\sto\sautosetup.\sNo\sfunctional\schanges. -D 2025-01-19T16:26:25.254 +C Further\srefactoring\sof\sauto.def\sto\ssimplify\screation\sof\svariant\sbuilds\slike\sthe\sautoconf\sbundle. +D 2025-01-19T18:32:45.973 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -14,7 +14,7 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 -F auto.def 8b7e3bdf0a9f3caccddb13175f6a2c3fdb1740220bbfe0bb8dae460a4f84d85a +F auto.def 056352c70a74a82929bdb5aaef65b38d44e4b912a8c7ebcb0a7d87fa1fd7c185 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac @@ -50,8 +50,8 @@ F autosetup/cc-shared.tcl 4f024e94a47f427ba61de1739f6381ef0080210f9fae89112d5c1d F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e45f F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba -F autosetup/proj.tcl 2e817159b997077cb79bd871f6255276b787558f386dfc0830b0f825f6a53767 -F autosetup/sqlite-config.tcl e52fa291ef148712a9392203b05e86743b474065ea88bdc65cdb664dbb188783 +F autosetup/proj.tcl 50b060ea6760b02ef5cb16650fbe9c1840e16351a0be0ccfc3727c565f74a257 +F autosetup/sqlite-config.tcl 4b1b8288415e26743a66a73a154303f67b8a1ae1aed478868843945cd5a58a29 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2f1e94994f3595baad4045ab05ffee0668059c23ab37a39c25b83c62bfbaea28 -R 9c60fa033887f9029838d451908d0067 +P 01ff37584708f3f79c62c1b5ed8cceab721cf8348a69a65f0559b1ef8845e85b +R 8c31a36a753a4b17d602415d7f01de06 U stephan -Z ec3ab526fc22a680c0602f434f403d4d +Z 2c8a02028d4af4395c0183d2b9aa5b8f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 684943058c..8ccb68a4f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -01ff37584708f3f79c62c1b5ed8cceab721cf8348a69a65f0559b1ef8845e85b +f806c563a29240c709508316846fbe0cb3ed61b68a6c1d9544eb699e30141d8d From 2534bf40117b7ad810a2f84a41910f28a842c377 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 19 Jan 2025 18:58:09 +0000 Subject: [PATCH 031/115] Initial work towards converting the autoconf bundle to autosetup. Currently non-functional. FossilOrigin-Name: d7708372ff2fef4bfa61e56dbfbb363cac7685587a61a151497991d9a08bb07f --- autoconf/auto.def | 84 +++++++++++++++++++++++++++++++++++++ autosetup/sqlite-config.tcl | 5 +++ manifest | 18 ++++---- manifest.uuid | 2 +- tool/mkautoconfamal.sh | 34 ++++++++------- 5 files changed, 120 insertions(+), 23 deletions(-) create mode 100644 autoconf/auto.def diff --git a/autoconf/auto.def b/autoconf/auto.def new file mode 100644 index 0000000000..6aba4216fb --- /dev/null +++ b/autoconf/auto.def @@ -0,0 +1,84 @@ +#/do/not/tclsh +# ^^^ help out editors which guess this file's content type. +# +# This is the main autosetup-compatible configure script for the +# TEA build of the SQLite project. +# +# This script should be kept compatible with JimTCL, a copy of which +# is included in this source tree as ./autosetup/jimsh0.c. +# +use sqlite-config + +options { + # + static=1 => {Disable build of static library (mostly)} + # + # + threadsafe=1 => {Disable mutexing} + with-tempstore:=no => {Use an in-RAM database for temporary tables: never,no,yes,always} + load-extension=1 => {Disable loading of external extensions} + math=1 => {Disable math functions} + json=1 => {Disable JSON functions} + memsys5 => {Enable MEMSYS5} + memsys3 => {Enable MEMSYS3} + fts3 => {Enable the FTS3 extension} + fts4 => {Enable the FTS4 extension} + fts5 => {Enable the FTS5 extension} + update-limit => {Enable the UPDATE/DELETE LIMIT clause} + geopoly => {Enable the GEOPOLY extension} + rtree => {Enable the RTREE extension} + session => {Enable the SESSION extension} + all => {Enable FTS4, FTS5, Geopoly, RTree, Sessions} + # + # + readline=1 => {Disable readline support} + # --with-readline-lib is a backwards-compatible alias for + # --with-readline-ldflags + with-readline-lib: + with-readline-ldflags:=auto + => {Readline LDFLAGS, e.g. -lreadline -lncurses} + # --with-readline-inc is a backwards-compatible alias for + # --with-readline-cflags. + with-readline-inc: + with-readline-cflags:=auto + => {Readline CFLAGS, e.g. -I/path/to/includes} + with-readline-header:PATH + => {Full path to readline.h, from which --with-readline-cflags will be derived} + with-linenoise:DIR => {Source directory for linenoise.c and linenoise.h} + editline=0 => {Enable BSD editline support} + # + # + with-icu-ldflags:LDFLAGS + => {Enable SQLITE_ENABLE_ICU and add the given linker flags for the ICU libraries} + with-icu-cflags:CFLAGS + => {Apply extra CFLAGS/CPPFLAGS necessary for building with ICU. e.g. -I/usr/local/include} + with-icu-config:=auto => {Enable SQLITE_ENABLE_ICU. Value must be one of: auto, pkg-config, /path/to/icu-config} + icu-collations=0 => {Enable SQLITE_ENABLE_ICU_COLLATIONS. Requires --with-icu-ldflags=... or --with-icu-config} + # + # + # Note that using the --debug/--enable-debug flag here requires patching + # autosetup/autosetup to rename the --debug to --autosetup-debug. + with-debug=0 + debug=0 => + {Enable debug build flags. This option will impact performance by + as much as 4x, as it includes large numbers of assert()s in + performance-critical loops. Never use --debug for production + builds.} + # +} + +sqlite-post-options-init +sqlite-check-common-bins +sqlite-check-common-system-deps +proj-check-rpath +sqlite-handle-debug +sqlite-handle-threadsafe +sqlite-handle-tempstore +sqlite-handle-line-editing +sqlite-handle-load-extension +sqlite-handle-math +sqlite-handle-icu +sqlite-handle-common-feature-flags +sqlite-show-feature-flags +sqlite-process-dot-in-files +sqlite-post-config-validation diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 08bd0467e5..c1fc7b00b0 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -240,6 +240,11 @@ proc sqlite-handle-common-feature-flags {} { } scanstatus -DSQLITE_ENABLE_STMT_SCANSTATUS {} } { + if {$boolFlag ni $::autosetup(options)} { + # Skip flags which are in the canonical build but not + # the autoconf bundle. + continue + } proj-if-opt-truthy $boolFlag { sqlite-add-feature-flag $featureFlag if {0 != [eval $ifSetEvalThis] && "all" ne $boolFlag} { diff --git a/manifest b/manifest index 2bd5902120..0cd90b08c5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\srefactoring\sof\sauto.def\sto\ssimplify\screation\sof\svariant\sbuilds\slike\sthe\sautoconf\sbundle. -D 2025-01-19T18:32:45.973 +C Initial\swork\stowards\sconverting\sthe\sautoconf\sbundle\sto\sautosetup.\sCurrently\snon-functional. +D 2025-01-19T18:58:09.462 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -21,6 +21,7 @@ F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 5e946ffb6fbdbb114c81e1bdc862df27fce8beab557d7b0421820b0fe8fc048f +F autoconf/auto.def 28003a20207d21aecb879a74778ca5d6b5c15e84efffbc8f90c3791b8d1d2248 F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277 F autoconf/tea/Makefile.in ba0556fee8da09c066bad85a4457904e46ee2c2eabaa309c0e83a78f2f151a8e F autoconf/tea/README.txt 61e62e519579e4a112791354d6d440f8b51ea6db3b0bab58d59f29df42d2dfe3 @@ -51,7 +52,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 50b060ea6760b02ef5cb16650fbe9c1840e16351a0be0ccfc3727c565f74a257 -F autosetup/sqlite-config.tcl 4b1b8288415e26743a66a73a154303f67b8a1ae1aed478868843945cd5a58a29 +F autosetup/sqlite-config.tcl 10cab051ed3de04d5c842703d27881a7cdb6772448339e3d3689140026d1c442 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2143,7 +2144,7 @@ F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669 F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176 F tool/mkamalzip.tcl 8aa5ebe7973c8b8774062d34e15fea9815c4cc2ceea3a9b184695f005910876a -F tool/mkautoconfamal.sh 4fbfd523330c8cf12ead8f0e0acdb3c5c9c08a1bcb293119267aeaa3e0bbe3e1 +F tool/mkautoconfamal.sh 7a9b54df5f3fbcbef9ff7f4d7bffb1b074425db23f999e1b27bd0b544fe7f2ff F tool/mkccode.tcl 210159febe0ef0ecbc53c79833500663ceaba0115b2b374405818dc835b5f84b x F tool/mkctimec.tcl ef6a67ec82e5b6fc19152a4c79f237227b18bf67ff16d155bac7adb94355d9cf x F tool/mkkeywordhash.c 6b0be901c47f9ad42215fc995eb2f4384ac49213b1fba395102ec3e999acf559 @@ -2208,8 +2209,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 01ff37584708f3f79c62c1b5ed8cceab721cf8348a69a65f0559b1ef8845e85b -R 8c31a36a753a4b17d602415d7f01de06 +P f806c563a29240c709508316846fbe0cb3ed61b68a6c1d9544eb699e30141d8d +R 37212f5b411c8b75c25b4343cda71606 +T *branch * autoconf-to-autosetup +T *sym-autoconf-to-autosetup * +T -sym-trunk * Cancelled\sby\sbranch. U stephan -Z 2c8a02028d4af4395c0183d2b9aa5b8f +Z f100e7f94531c215a65ef7fb114eddd4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8ccb68a4f6..8245556619 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f806c563a29240c709508316846fbe0cb3ed61b68a6c1d9544eb699e30141d8d +d7708372ff2fef4bfa61e56dbfbb363cac7685587a61a151497991d9a08bb07f diff --git a/tool/mkautoconfamal.sh b/tool/mkautoconfamal.sh index f3ce9dd5ba..3b46fc4de8 100644 --- a/tool/mkautoconfamal.sh +++ b/tool/mkautoconfamal.sh @@ -13,7 +13,7 @@ # -# Bail out of the script if any command returns a non-zero exit +# Bail out of the script if any command returns a non-zero exit # status. Or if the script tries to use an unset variable. These # may fail for old /bin/sh interpreters. # @@ -34,12 +34,12 @@ else echo "TEA version number mismatch. Should be $VERSION"; exit 1 fi # If this script is given an argument of --snapshot, then generate a -# snapshot tarball named for the current checkout SHA1 hash, rather than +# snapshot tarball named for the current checkout SHA hash, rather than # the version number. # if test "$#" -ge 1 -a x$1 != x--snapshot then - # Set global variable $ARTIFACT to the "3xxyyzz" string incorporated + # Set global variable $ARTIFACT to the "3xxyyzz" string incorporated # into artifact filenames. And $VERSION2 to the "3.x.y[.z]" form. xx=`echo $VERSION|sed 's/3\.\([0-9]*\)\..*/\1/'` yy=`echo $VERSION|sed 's/3\.[^.]*\.\([0-9]*\).*/\1/'` @@ -54,6 +54,8 @@ fi rm -rf $TMPSPACE cp -R $TOP/autoconf $TMPSPACE +cp -R $TOP/autosetup $TMPSPACE +cp -p $TOP/configure $TMPSPACE cp sqlite3.c $TMPSPACE cp sqlite3.h $TMPSPACE cp sqlite3ext.h $TMPSPACE @@ -63,38 +65,39 @@ cp $TOP/sqlite3.pc.in $TMPSPACE cp shell.c $TMPSPACE cp $TOP/src/sqlite3.rc $TMPSPACE cp $TOP/tool/Replace.cs $TMPSPACE - -cat $TMPSPACE/configure.ac | -sed "s/--SQLITE-VERSION--/$VERSION/" > $TMPSPACE/tmp -mv $TMPSPACE/tmp $TMPSPACE/configure.ac - -cat $TMPSPACE/sqlite3.pc.in | -sed "s/^Libs.private:.*/Libs.private: @LIBS@/" > $TMPSPACE/tmp -mv $TMPSPACE/tmp $TMPSPACE/sqlite3.pc.in +cp $TOP/VERSION $TMPSPACE +cp $TOP/main.mk $TMPSPACE cd $TMPSPACE -autoreconf -i +#autoreconf -i #libtoolize #aclocal #autoconf #automake --add-missing +# This bit is only for use during porting of the +# autoconf bundle to autosetup. +if true; then + find . -name '*~' -exec rm \{} \; +fi + mkdir -p tea/generic -echo "#ifdef USE_SYSTEM_SQLITE" > tea/generic/tclsqlite3.c +echo "#ifdef USE_SYSTEM_SQLITE" > tea/generic/tclsqlite3.c echo "# include " >> tea/generic/tclsqlite3.c echo "#else" >> tea/generic/tclsqlite3.c echo "#include \"sqlite3.c\"" >> tea/generic/tclsqlite3.c echo "#endif" >> tea/generic/tclsqlite3.c cat $TOP/src/tclsqlite.c >> tea/generic/tclsqlite3.c -cat tea/configure.ac | - sed "s/AC_INIT(\[sqlite\], .*)/AC_INIT([sqlite], [$VERSION])/" > tmp +sed "s/AC_INIT(\[sqlite\], .*)/AC_INIT([sqlite], [$VERSION])/" tea/configure.ac > tmp mv tmp tea/configure.ac cd tea autoconf rm -rf autom4te.cache +echo "--------------- TODO: -----------------" +cat < Date: Sun, 19 Jan 2025 19:14:21 +0000 Subject: [PATCH 032/115] Add an SQLITE_TESTCTRL_OPTIMIZATION mask that can disable the query planner heuristics that are designed to help with star queries. FossilOrigin-Name: fec4ff185a2f3f1bee8f27432206276636cf27365d2d41cd7282f8c0425f2e96 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/shell.c.in | 1 + src/sqliteInt.h | 1 + src/where.c | 10 +++++++--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 2bd5902120..c926f45fe9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\srefactoring\sof\sauto.def\sto\ssimplify\screation\sof\svariant\sbuilds\slike\sthe\sautoconf\sbundle. -D 2025-01-19T18:32:45.973 +C Add\san\sSQLITE_TESTCTRL_OPTIMIZATION\smask\sthat\scan\sdisable\sthe\squery\splanner\nheuristics\sthat\sare\sdesigned\sto\shelp\swith\sstar\squeries. +D 2025-01-19T19:14:21.044 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -780,11 +780,11 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 83e88fbb36f89b6703b348777491619554f0fd6f917c9fdf51e4c2e9cda6c04e -F src/shell.c.in beb370609906092a6810fcd9ea76737be2c91694445061c2eb05c4c0a3753de4 +F src/shell.c.in 9ade75afa953c5c2ded38d076533eaa6c9b2ab1977ef6cce0bc773adac178c50 F src/sqlite.h.in 6afbcaae44140216704a6c82e4c4ea4118c46d5f6573d6c5fa4fc901ed9d369e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 3f20dfb5ae54e787b2643edc0b5bae0cecddfb89988e28afdc3c0b05892e25cc +F src/sqliteInt.h 953f2476f712b115ecb43f7a21183d07c88af8d3b4c32f18317724ce1ce04d56 F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 521472bb0c7cfdd65a9b5b92d44f921e3e0a26a1996cc0416cf53e25301820d2 +F src/where.c 5e74d76b264abcd7e6682e02853756b5d32f543c59fb47bb55a02575b73693ae F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 01ff37584708f3f79c62c1b5ed8cceab721cf8348a69a65f0559b1ef8845e85b -R 8c31a36a753a4b17d602415d7f01de06 -U stephan -Z 2c8a02028d4af4395c0183d2b9aa5b8f +P f806c563a29240c709508316846fbe0cb3ed61b68a6c1d9544eb699e30141d8d +R a016f5b06b30e7627e9627eb42538187 +U drh +Z 386d6c5415cb5b1ed55b033eb5e08a17 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8ccb68a4f6..72562901a8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f806c563a29240c709508316846fbe0cb3ed61b68a6c1d9544eb699e30141d8d +fec4ff185a2f3f1bee8f27432206276636cf27365d2d41cd7282f8c0425f2e96 diff --git a/src/shell.c.in b/src/shell.c.in index 17054a961c..d7a0bf55b3 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -11475,6 +11475,7 @@ static int do_meta_command(char *zLine, ShellState *p){ { 0x04000000, 1, "NullUnusedCols" }, { 0x08000000, 1, "OnePass" }, { 0x10000000, 1, "OrderBySubq" }, + { 0x20000000, 1, "StarQuery" }, { 0xffffffff, 0, "All" }, }; unsigned int curOpt; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b8c9136a59..3045d7c4a5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1889,6 +1889,7 @@ struct sqlite3 { #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */ #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */ #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */ +#define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */ #define SQLITE_AllOpts 0xffffffff /* All optimizations */ /* diff --git a/src/where.c b/src/where.c index b867e615f7..0b8e5aceaa 100644 --- a/src/where.c +++ b/src/where.c @@ -5459,7 +5459,10 @@ static LogEst whereSortingCost( */ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ int nLoop = pWInfo->nLevel; /* Number of terms in the join */ - if( nRowEst==0 && nLoop>=5 ){ + if( nRowEst==0 + && nLoop>=5 + && OptimizationEnabled(pWInfo->pParse->db, SQLITE_StarQuery) + ){ /* Check to see if we are dealing with a star schema and if so, reduce ** the cost of fact tables relative to dimension tables, as a heuristic ** to help keep the fact tables in outer loops. @@ -5487,8 +5490,9 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ SrcItem *pItem = pWInfo->pTabList->a + iLoop; - sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n", - pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName, + sqlite3DebugPrintf( + "Fact-table %s(%d): %d dimensions, cost reduced %d\n", + pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName, iLoop, nDep, rDelta); } #endif From 17dca772e0a87571b40178b8ab0f25d0609732bf Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 19 Jan 2025 19:51:47 +0000 Subject: [PATCH 033/115] Get the CLI shell building in the autoconf bundle. FossilOrigin-Name: 241cdbc40a2f82df53c149849a103a335b0643a65e229a1e80ab90a0e457bb6b --- Makefile.in | 3 - auto.def | 16 ---- autoconf/Makefile.am | 20 ----- autoconf/Makefile.in | 141 ++++++++++++++++++++++++++++++++++++ autosetup/sqlite-config.tcl | 22 +++++- manifest | 21 +++--- manifest.uuid | 2 +- 7 files changed, 171 insertions(+), 54 deletions(-) delete mode 100644 autoconf/Makefile.am create mode 100644 autoconf/Makefile.in diff --git a/Makefile.in b/Makefile.in index 5fff3d2fc5..15e61217f2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -323,9 +323,6 @@ distclean-autosetup: clean rm -f $(TOP)/tool/emcc.sh rm -f libsqlite3*$(T.dll) rm -f jimsh0* -# -if [ -f ext/wasm/GNUmakefile ]; then \ -# gmake --no-print-directory --ignore-errors -C ext/wasm distclean; \ -# fi >/dev/null 2>&1; true distclean: distclean-autosetup # diff --git a/auto.def b/auto.def index 4e646e6f2b..7fdf61f16c 100644 --- a/auto.def +++ b/auto.def @@ -210,22 +210,6 @@ options [subst -nobackslashes -nocommands $flags] unset flags sqlite-post-options-init -if {1} { - # TODO: move this into autosetup/sqlite-config.tcl once we get the - # version info into autoconf/auto.def. - set srcdir $::autosetup(srcdir) - set PACKAGE_VERSION [proj-file-content -trim $srcdir/VERSION] - define PACKAGE_NAME "sqlite" - define PACKAGE_URL {https://sqlite.org} - define PACKAGE_VERSION $PACKAGE_VERSION - define PACKAGE_STRING "[get-define PACKAGE_NAME] $PACKAGE_VERSION" - define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/forum - msg-result "Source dir = $srcdir" - msg-result "Build dir = $::autosetup(builddir)" - msg-result "Configuring SQLite version $PACKAGE_VERSION" - unset srcdir -} - sqlite-setup-default-cflags proj-if-opt-truthy dev { # --enable-dev needs to come early so that the downstream tests diff --git a/autoconf/Makefile.am b/autoconf/Makefile.am deleted file mode 100644 index 1eaa560ff8..0000000000 --- a/autoconf/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ - -AM_CFLAGS = @BUILD_CFLAGS@ -lib_LTLIBRARIES = libsqlite3.la -libsqlite3_la_SOURCES = sqlite3.c -libsqlite3_la_LDFLAGS = -no-undefined -version-info 8:6:8 - -bin_PROGRAMS = sqlite3 -sqlite3_SOURCES = shell.c sqlite3.h -EXTRA_sqlite3_SOURCES = sqlite3.c -sqlite3_LDADD = @EXTRA_SHELL_OBJ@ @READLINE_LIBS@ -sqlite3_DEPENDENCIES = @EXTRA_SHELL_OBJ@ -sqlite3_CFLAGS = $(AM_CFLAGS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_DQS=0 -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_DBSTAT_VTAB $(SHELL_CFLAGS) - -include_HEADERS = sqlite3.h sqlite3ext.h - -EXTRA_DIST = sqlite3.1 tea Makefile.msc sqlite3.rc sqlite3rc.h README.txt Replace.cs Makefile.fallback -pkgconfigdir = ${libdir}/pkgconfig -pkgconfig_DATA = sqlite3.pc - -man_MANS = sqlite3.1 diff --git a/autoconf/Makefile.in b/autoconf/Makefile.in new file mode 100644 index 0000000000..df97c180a6 --- /dev/null +++ b/autoconf/Makefile.in @@ -0,0 +1,141 @@ +all: + +TOP = @abs_top_srcdir@ + +# +# Filename extensions for binaries and libraries +# +B.exe = @BUILD_EXEEXT@ +T.exe = @TARGET_EXEEXT@ +B.dll = @BUILD_DLLEXT@ +T.dll = @TARGET_DLLEXT@ +B.lib = @BUILD_LIBEXT@ +T.lib = @TARGET_LIBEXT@ + +# +# Autotools-compatibility dirs +# +prefix = @prefix@ +datadir = @datadir@ +mandir = @mandir@ +includedir = @includedir@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ + +# +# Required binaries +# +INSTALL = @BIN_INSTALL@ +AR = @AR@ +AR.flags = cr +CC = @CC@ + +CFLAGS = @CFLAGS@ @CPPFLAGS@ +# +# $(LDFLAGS.configure) represents any LDFLAGS=... the client passes to +# configure. See main.mk. +# +LDFLAGS.configure = @LDFLAGS@ + +CFLAGS.core = @SH_CFLAGS@ +LDFLAGS.shlib = @SH_LDFLAGS@ +LDFLAGS.zlib = @LDFLAGS_ZLIB@ +LDFLAGS.math = @LDFLAGS_MATH@ +LDFLAGS.rpath = @LDFLAGS_RPATH@ +LDFLAGS.pthread = @LDFLAGS_PTHREAD@ +LDFLAGS.dlopen = @LDFLAGS_DLOPEN@ +LDFLAGS.readline = @LDFLAGS_READLINE@ +CFLAGS.readline = @CFLAGS_READLINE@ +LDFLAGS.icu = @LDFLAGS_ICU@ +CFLAGS.icu = @CFLAGS_ICU@ +LDFLAGS.libsqlite3.soname = @LDFLAGS_LIBSQLITE3_SONAME@ + +# When cross-compiling, we need to avoid the -s flag because it only +# works on the build host's platform. +INSTALL.strip.1 = $(INSTALL) +INSTALL.strip.0 = $(INSTALL) -s +INSTALL.strip. = $(INSTALL.strip.0) +INSTALL.strip = $(INSTALL.strip.@IS_CROSS_COMPILING@) + +install-dir.bin = $(DESTDIR)$(bindir) +install-dir.lib = $(DESTDIR)$(libdir) +install-dir.include = $(DESTDIR)$(includedir) +install-dir.pkgconfig = $(DESTDIR)$(libdir)/pkgconfig +install-dir.man1 = $(DESTDIR)$(mandir)/man1 +install-dir.all = $(install-dir.bin) $(install-dir.include) \ + $(install-dir.lib) $(install-dir.man1) \ + $(install-dir.pkgconfig) +$(install-dir.all): + $(INSTALL) -d "$@" + + +# +# Vars with the AS_ prefix are specifically related to AutoSetup. +# +# AS_AUTO_DEF is the main configure script. +# +AS_AUTO_DEF = $(TOP)/auto.def + +# +# Shell commands to re-run $(TOP)/configure with the same args it was +# invoked with to produce this makefile. +# +AS_AUTORECONFIG = @SQLITE_AUTORECONFIG@ +Makefile: $(TOP)/Makefile.in $(AS_AUTO_DEF) + $(AS_AUTORECONFIG) + @touch $@ + +sqlite3.pc: $(TOP)/sqlite3.pc.in $(AS_AUTO_DEF) + $(AS_AUTORECONFIG) + @touch $@ + +sqlite_cfg.h: $(AS_AUTO_DEF) + $(AS_AUTORECONFIG) + @touch $@ + +# +# CFLAGS for sqlite3$(T.exe) +# +SHELL_OPT ?= @OPT_SHELL@ + +# +# Library-level feature flags +# +OPT_FEATURE_FLAGS = @OPT_FEATURE_FLAGS@ + +LDFLAGS.libsqlite3 = \ + $(LDFLAGS.rpath) $(LDFLAGS.pthread) \ + $(LDFLAGS.math) $(LDFLAGS.dlopen) \ + $(LDFLAGS.zlib) $(LDFLAGS.icu) \ + $(LDFLAGS.configure) + +sqlite3$(T.exe): shell.c sqlite3.c + $(CC) -o $@ \ + shell.c sqlite3.c \ + $(OPT_FEATURE_FLAGS) $(SHELL_OPT) \ + $(CFLAGS.readline) $(CFLAGS.icu) \ + $(LDFLAGS.libsqlite3) $(LDFLAGS.readline) +all: sqlite3$(T.exe) + +install-shell: sqlite3$(T.exe) $(install-dir.bin) + $(INSTALL.strip) sqlite3$(T.exe) "$(install-dir.bin)" +install: install-shell + +clean: + rm -f *.o sqlite3$(T.exe) + +distclean: clean + rm -f sqlite3.pc + +DIST_FILES := auto.def autosetup tea \ + sqlite3.h sqlite3.c shell.c sqlite3ext.h \ + sqlite3.1 \ + Makefile.msc sqlite3.rc sqlite3rc.h Replace.cs \ + README.txt Makefile.fallback + +dist: + @echo "Not Yet Implemented: $@" + +install: + @echo "Not Yet Implemented: $@" diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index c1fc7b00b0..5e2d121565 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -64,11 +64,29 @@ proc sqlite-post-options-init {} { define SQLITE_OS_UNIX 1 define SQLITE_OS_WIN 0 } - set ::sqliteConfig(msg-debug-enabled) [proj-val-truthy [get-env msg-debug 0]] - + sqlite-setup-package-info } +######################################################################## +# Called by [sqlite-post-options-init] to set up PACKAGE_NAME and +# related defines. +proc sqlite-setup-package-info {} { + set srcdir $::autosetup(srcdir) + set PACKAGE_VERSION [proj-file-content -trim $srcdir/VERSION] + define PACKAGE_NAME "sqlite" + define PACKAGE_URL {https://sqlite.org} + define PACKAGE_VERSION $PACKAGE_VERSION + define PACKAGE_STRING "[get-define PACKAGE_NAME] $PACKAGE_VERSION" + define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/forum + msg-result "Source dir = $srcdir" + msg-result "Build dir = $::autosetup(builddir)" + msg-result "Configuring SQLite version $PACKAGE_VERSION" +} + +######################################################################## +# Internal config-time debugging output routine. It generates no +# output unless msg-debug=1 is passed to the configure script. proc msg-debug {msg} { if {$::sqliteConfig(msg-debug-enabled)} { puts stderr [proj-bold "** DEBUG: $msg"] diff --git a/manifest b/manifest index 0cd90b08c5..0058b0f5a7 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Initial\swork\stowards\sconverting\sthe\sautoconf\sbundle\sto\sautosetup.\sCurrently\snon-functional. -D 2025-01-19T18:58:09.462 +C Get\sthe\sCLI\sshell\sbuilding\sin\sthe\sautoconf\sbundle. +D 2025-01-19T19:51:47.397 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d -F Makefile.in 572271a39d7ac1ae228ed911c63fdf374300a6a880ceb851b1f3d357e9a9534e +F Makefile.in 38485d15d9190cdad0d7bee25af7b442028865964025dcc61f40fd8d6e369cfc F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0 F Makefile.msc 39785ec45f9ae0311e49094eff2ee079562246fed6be3b9f632a99d4df20056a F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -14,10 +14,10 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 -F auto.def 056352c70a74a82929bdb5aaef65b38d44e4b912a8c7ebcb0a7d87fa1fd7c185 +F auto.def 7833c0a8630dd3a3410dcc6c8b4d1b63f25d03d6497267624b8a37aba119cb3e F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 -F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac +F autoconf/Makefile.in 8ffa4fa39ae65758e72502b86286ea1472befec9eab7999cadb89d8e101d55c7 w autoconf/Makefile.am F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 5e946ffb6fbdbb114c81e1bdc862df27fce8beab557d7b0421820b0fe8fc048f @@ -52,7 +52,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 50b060ea6760b02ef5cb16650fbe9c1840e16351a0be0ccfc3727c565f74a257 -F autosetup/sqlite-config.tcl 10cab051ed3de04d5c842703d27881a7cdb6772448339e3d3689140026d1c442 +F autosetup/sqlite-config.tcl 7a5cf6b40c5763c473c2638041ba8812f32062a78545aff223e0913fc4a7c57d F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2209,11 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f806c563a29240c709508316846fbe0cb3ed61b68a6c1d9544eb699e30141d8d -R 37212f5b411c8b75c25b4343cda71606 -T *branch * autoconf-to-autosetup -T *sym-autoconf-to-autosetup * -T -sym-trunk * Cancelled\sby\sbranch. +P d7708372ff2fef4bfa61e56dbfbb363cac7685587a61a151497991d9a08bb07f +R c183fd6972c40e51c2b2f070c9205cc8 U stephan -Z f100e7f94531c215a65ef7fb114eddd4 +Z d3c8e68d7f70bcdf216494cac16a3dcf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8245556619..b06bb9fa72 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d7708372ff2fef4bfa61e56dbfbb363cac7685587a61a151497991d9a08bb07f +241cdbc40a2f82df53c149849a103a335b0643a65e229a1e80ab90a0e457bb6b From 87cdd5926de0701f18d479efa4ffc54ea08c5dca Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 19 Jan 2025 21:47:06 +0000 Subject: [PATCH 034/115] Get libsqlite3.so and .a building in the autoconf bundle. FossilOrigin-Name: 88cee3fc7c8bfd9b6955fb6b2fd6b25660563e4d043ffa5ea18d8abe91afdb7f --- autoconf/Makefile.in | 38 ++++++++++++++++++++++++++++++++------ autoconf/auto.def | 11 +++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/autoconf/Makefile.in b/autoconf/Makefile.in index df97c180a6..18e8e9a740 100644 --- a/autoconf/Makefile.in +++ b/autoconf/Makefile.in @@ -55,8 +55,8 @@ LDFLAGS.libsqlite3.soname = @LDFLAGS_LIBSQLITE3_SONAME@ # works on the build host's platform. INSTALL.strip.1 = $(INSTALL) INSTALL.strip.0 = $(INSTALL) -s -INSTALL.strip. = $(INSTALL.strip.0) INSTALL.strip = $(INSTALL.strip.@IS_CROSS_COMPILING@) +INSTALL.noexec = $(INSTALL) -m 0644 install-dir.bin = $(DESTDIR)$(bindir) install-dir.lib = $(DESTDIR)$(libdir) @@ -109,21 +109,47 @@ LDFLAGS.libsqlite3 = \ $(LDFLAGS.math) $(LDFLAGS.dlopen) \ $(LDFLAGS.zlib) $(LDFLAGS.icu) \ $(LDFLAGS.configure) +LDFLAGS.libsqlite3.soname = @LDFLAGS_LIBSQLITE3_SONAME@ +CFLAGS.libsqlite3 = -I. $(CFLAGS.core) $(CFLAGS.icu) $(OPT_FEATURE_FLAGS) + +sqlite3.o: sqlite3.h sqlite3.c + $(CC) -c sqlite3.c -o $@ $(CFLAGS) $(CFLAGS.libsqlite3) + +libsqlite3.LIB = libsqlite3$(T.lib) +libsqlite3.SO = libsqlite3$(T.dll) + +$(libsqlite3.SO): sqlite3.o + $(CC) -o $@ sqlite3.o $(LDFLAGS.shlib) \ + $(LDFLAGS) $(LDFLAGS.libsqlite3) $(LDFLAGS.libsqlite3.soname) +all: $(libsqlite3.SO) + +$(libsqlite3.LIB): sqlite3.o + $(AR) $(AR.flags) $@ sqlite3.o +all: $(libsqlite3.LIB) sqlite3$(T.exe): shell.c sqlite3.c $(CC) -o $@ \ shell.c sqlite3.c \ - $(OPT_FEATURE_FLAGS) $(SHELL_OPT) \ - $(CFLAGS.readline) $(CFLAGS.icu) \ - $(LDFLAGS.libsqlite3) $(LDFLAGS.readline) + -I. $(OPT_FEATURE_FLAGS) $(SHELL_OPT) \ + $(CFLAGS) $(CFLAGS.readline) $(CFLAGS.icu) \ + $(LDFLAGS) $(LDFLAGS.libsqlite3) $(LDFLAGS.readline) all: sqlite3$(T.exe) install-shell: sqlite3$(T.exe) $(install-dir.bin) $(INSTALL.strip) sqlite3$(T.exe) "$(install-dir.bin)" install: install-shell +install-headers: sqlite3.h $(install-dir.include) + $(INSTALL.noexec) sqlite3.h sqlite3ext.h "$(install-dir.include)" +install: install-headers + +install-pc: sqlite3.pc $(install-dir.pkgconfig) + $(INSTALL.noexec) sqlite3.pc "$(install-dir.pkgconfig)" +install: install-pc + clean: rm -f *.o sqlite3$(T.exe) + rm -f $(libsqlite3.LIB) $(libsqlite3.SO) distclean: clean rm -f sqlite3.pc @@ -135,7 +161,7 @@ DIST_FILES := auto.def autosetup tea \ README.txt Makefile.fallback dist: - @echo "Not Yet Implemented: $@" + @echo "Not Yet Implemented: $@"; exit 1 install: - @echo "Not Yet Implemented: $@" + @echo "Not Yet Implemented: $@"; exit 1 diff --git a/autoconf/auto.def b/autoconf/auto.def index 6aba4216fb..0f9424b555 100644 --- a/autoconf/auto.def +++ b/autoconf/auto.def @@ -65,12 +65,23 @@ options { performance-critical loops. Never use --debug for production builds.} # + soname:=legacy => + # --soname has a long story behind it: https://sqlite.org/src/forumpost/5a3b44f510df8ded + {SONAME for libsqlite3.so. "none", or not using this flag, sets no + soname. "legacy" sets it to its historical value of + libsqlite3.so.0. A value matching the glob "libsqlite3.*" sets + it to that literal value. Any other value is assumed to be a + suffix which gets applied to "libsqlite3.so.", + e.g. --soname=9.10 equates to "libsqlite3.so.9.10". + } } sqlite-post-options-init sqlite-check-common-bins sqlite-check-common-system-deps proj-check-rpath +sqlite-handle-soname +sqlite-setup-default-cflags sqlite-handle-debug sqlite-handle-threadsafe sqlite-handle-tempstore diff --git a/manifest b/manifest index 0058b0f5a7..46cb1f1ef6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Get\sthe\sCLI\sshell\sbuilding\sin\sthe\sautoconf\sbundle. -D 2025-01-19T19:51:47.397 +C Get\slibsqlite3.so\sand\s.a\sbuilding\sin\sthe\sautoconf\sbundle. +D 2025-01-19T21:47:06.974 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -17,11 +17,11 @@ F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821 F auto.def 7833c0a8630dd3a3410dcc6c8b4d1b63f25d03d6497267624b8a37aba119cb3e F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac -F autoconf/Makefile.in 8ffa4fa39ae65758e72502b86286ea1472befec9eab7999cadb89d8e101d55c7 w autoconf/Makefile.am +F autoconf/Makefile.in 3fa678c42221c95ac4fc13d60b145840b9b93e7885c7d040669f3e481b5a8e93 F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 5e946ffb6fbdbb114c81e1bdc862df27fce8beab557d7b0421820b0fe8fc048f -F autoconf/auto.def 28003a20207d21aecb879a74778ca5d6b5c15e84efffbc8f90c3791b8d1d2248 +F autoconf/auto.def a2c428a91f5e3fa699e733fc3c1621ad145f3ac9f785e6518ecfe73a874f0e03 F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277 F autoconf/tea/Makefile.in ba0556fee8da09c066bad85a4457904e46ee2c2eabaa309c0e83a78f2f151a8e F autoconf/tea/README.txt 61e62e519579e4a112791354d6d440f8b51ea6db3b0bab58d59f29df42d2dfe3 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d7708372ff2fef4bfa61e56dbfbb363cac7685587a61a151497991d9a08bb07f -R c183fd6972c40e51c2b2f070c9205cc8 +P 241cdbc40a2f82df53c149849a103a335b0643a65e229a1e80ab90a0e457bb6b +R b35046aa7e07fc080621217913b53d03 U stephan -Z d3c8e68d7f70bcdf216494cac16a3dcf +Z f3e60d1f16fabf25d54188672248bb86 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b06bb9fa72..a00e35956d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -241cdbc40a2f82df53c149849a103a335b0643a65e229a1e80ab90a0e457bb6b +88cee3fc7c8bfd9b6955fb6b2fd6b25660563e4d043ffa5ea18d8abe91afdb7f From e9763e4ed719cec6d7e70832f0f9af53d752fea3 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 20 Jan 2025 16:14:09 +0000 Subject: [PATCH 035/115] configure script: remove an overzealous is-a-file check in the tclsh search which fails to account for implicit .exe extensions on Windows builds. Reported in [forum:c27403ef974df9f1|forum post c27403ef974df9f1]. (Same change as [89306d1a4905] but to a different file, as that content was moved since the 3.48 release.) FossilOrigin-Name: 239a3d1573f4cb720308018280b2add54034e69e38fe7060a7238875eee4f1c9 --- autosetup/sqlite-config.tcl | 4 +--- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 08bd0467e5..7f42922867 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -990,9 +990,7 @@ proc sqlite-check-tcl {} { if {"" ne $with_tclsh} { # --with-tclsh was provided or found above. Validate it and use it # to trump any value passed via --with-tcl=DIR. - if {![file isfile $with_tclsh]} { - proj-fatal "TCL shell $with_tclsh is not a file" - } elseif {![file-isexec $with_tclsh]} { + if {![file-isexec $with_tclsh]} { proj-fatal "TCL shell $with_tclsh is not executable" } else { define TCLSH_CMD $with_tclsh diff --git a/manifest b/manifest index c926f45fe9..0440599bc1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sSQLITE_TESTCTRL_OPTIMIZATION\smask\sthat\scan\sdisable\sthe\squery\splanner\nheuristics\sthat\sare\sdesigned\sto\shelp\swith\sstar\squeries. -D 2025-01-19T19:14:21.044 +C configure\sscript:\sremove\san\soverzealous\sis-a-file\scheck\sin\sthe\stclsh\ssearch\swhich\sfails\sto\saccount\sfor\simplicit\s.exe\sextensions\son\sWindows\sbuilds.\sReported\sin\s[forum:c27403ef974df9f1|forum\spost\sc27403ef974df9f1].\s(Same\schange\sas\s[89306d1a4905]\sbut\sto\sa\sdifferent\sfile,\sas\sthat\scontent\swas\smoved\ssince\sthe\s3.48\srelease.) +D 2025-01-20T16:14:09.083 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -51,7 +51,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 50b060ea6760b02ef5cb16650fbe9c1840e16351a0be0ccfc3727c565f74a257 -F autosetup/sqlite-config.tcl 4b1b8288415e26743a66a73a154303f67b8a1ae1aed478868843945cd5a58a29 +F autosetup/sqlite-config.tcl 96d07366aaaf717a2a1ff9b0ef89c4d669d6a38f18e7e7ae48a2498d076b39ac F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f806c563a29240c709508316846fbe0cb3ed61b68a6c1d9544eb699e30141d8d -R a016f5b06b30e7627e9627eb42538187 -U drh -Z 386d6c5415cb5b1ed55b033eb5e08a17 +P fec4ff185a2f3f1bee8f27432206276636cf27365d2d41cd7282f8c0425f2e96 +R 25cfe1ba29c81abc6c4cc0abffb7da62 +U stephan +Z 0cb7636a2c620ecf85b9efcc34578b99 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 72562901a8..289c53bcfc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fec4ff185a2f3f1bee8f27432206276636cf27365d2d41cd7282f8c0425f2e96 +239a3d1573f4cb720308018280b2add54034e69e38fe7060a7238875eee4f1c9 From 467e20ad1d579cf8a405a715e250d12ff25de952 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 20 Jan 2025 18:26:58 +0000 Subject: [PATCH 036/115] Fix an assert() that could fail if a virtual table called sqlite3_step() from within the xSync() method while committing a "PRAGMA defer_foreign_keys=1" transaction. FossilOrigin-Name: 39bdbb3f6dd1d30d180526d35c11f789f5e9d45b99ead72fd4a3b136afab66b1 --- ext/fts5/test/fts5misc.test | 22 +++++++++++++++++++++- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/vdbeapi.c | 2 +- test/fkey6.test | 15 +++++++++++++++ 5 files changed, 47 insertions(+), 12 deletions(-) diff --git a/ext/fts5/test/fts5misc.test b/ext/fts5/test/fts5misc.test index c2e580c564..2aca1986a1 100644 --- a/ext/fts5/test/fts5misc.test +++ b/ext/fts5/test/fts5misc.test @@ -591,7 +591,6 @@ do_execsql_test 21.2 { PRAGMA integrity_check } {ok} -breakpoint sqlite3_db_config db DEFENSIVE 1 do_execsql_test 21.3 { CREATE TABLE xyz_notashadow(x, y); @@ -665,5 +664,26 @@ do_execsql_test 25.0 { SELECT fts5_test_poslist(t1) FROM t1('b') ORDER BY rank; } {{}} +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 26.0 { + PRAGMA foreign_keys = ON; + CREATE TABLE t1(x INTEGER PRIMARY KEY); + CREATE TABLE t2(y INTEGER PRIMARY KEY, + z INTEGER REFERENCES t1(x) DEFERRABLE INITIALLY DEFERRED + ); + CREATE VIRTUAL TABLE t3 USING fts5(a, b, content='', tokendata=1); +} + +do_execsql_test 26.1 { + BEGIN; + INSERT INTO t2 VALUES(1,111); + INSERT INTO t3 VALUES(3,3); + PRAGMA defer_foreign_keys=ON; + DELETE FROM t2 WHERE y+1; + COMMIT; +} + finish_test diff --git a/manifest b/manifest index 0440599bc1..6c62b5451d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C configure\sscript:\sremove\san\soverzealous\sis-a-file\scheck\sin\sthe\stclsh\ssearch\swhich\sfails\sto\saccount\sfor\simplicit\s.exe\sextensions\son\sWindows\sbuilds.\sReported\sin\s[forum:c27403ef974df9f1|forum\spost\sc27403ef974df9f1].\s(Same\schange\sas\s[89306d1a4905]\sbut\sto\sa\sdifferent\sfile,\sas\sthat\scontent\swas\smoved\ssince\sthe\s3.48\srelease.) -D 2025-01-20T16:14:09.083 +C Fix\san\sassert()\sthat\scould\sfail\sif\sa\svirtual\stable\scalled\ssqlite3_step()\sfrom\swithin\sthe\sxSync()\smethod\swhile\scommitting\sa\s"PRAGMA\sdefer_foreign_keys=1"\stransaction. +D 2025-01-20T18:26:58.868 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -207,7 +207,7 @@ F ext/fts5/test/fts5locale.test 83ba7ee12628b540d3098f39c39c1de0c0440eddff8f7512 F ext/fts5/test/fts5matchinfo.test 877520582feb86bbfd95ab780099bcba4526f18ac75ee34979144cf86ba3a5a3 F ext/fts5/test/fts5merge.test 2654df0bcdb2d117c2d38b6aeb0168061be01c643f9e9194b36c43a2970e8082 F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2 -F ext/fts5/test/fts5misc.test 8c3cc771f773dc4bb4973620c51e7729e324ca2cc80eb8894f1c2c605e361f0b +F ext/fts5/test/fts5misc.test f4dee7da898d605a6488c5b7afaace3158ed6bb9addff78faa1b37b402b77fb9 F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581 F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45 F ext/fts5/test/fts5near.test 33d60867581066e5db7016deb5d651628125d7ff4e0233a88175aa5b65874c74 @@ -851,7 +851,7 @@ F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 F src/vdbe.c 8a6eb02823b424b273614bae41579392a5c495424592b60423dd2c443a583df0 F src/vdbe.h 9676348d342bd04e21e384c63b57224171ce84fac77853357334ef94c4d33cf4 F src/vdbeInt.h bf294a0c8fc4cc80779e74b04b8bd82c6e1197b3137cefe0b16cdf002fc7dfd6 -F src/vdbeapi.c 38c252a202d70b56cfb734460bc888ddbd581afec1a10cd4d6c894c9e0b5baea +F src/vdbeapi.c 033decc098df353b97a5ca14302ad812e2567f1037747c2d5fcda62aac1bb74e F src/vdbeaux.c 5fcbc642a3d3d88c5ea15cadf2c8b8e4e067cb9ff374beb1875c9d209001299e F src/vdbeblob.c 255be187436da38b01f276c02e6a08103489bbe2a7c6c21537b7aecbe0e1f797 F src/vdbemem.c df568ef0187e4be2788c35174f6d9b8566ab9475f9aff2d73907ed05aa5684b2 @@ -1154,7 +1154,7 @@ F test/fkey2.test 1063d65e5923c054cfb8f0555a92a3ae0fa8c067275a33ee1715bd856cdb30 F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49 F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d F test/fkey5.test 6727452e163a427147e84e739da18713da553d79f9783559b04fdcd36d5c7421 -F test/fkey6.test bdb9c808349a149575b87cf4bfd82d4c81612f0c4d954d27b3f42f043a385396 +F test/fkey6.test ebd11efb00b9c70b57f4c6b6184445145c96e320329bd90a175036570c5b25ca F test/fkey7.test 64fb28da03da5dfe3cdef5967aa7e832c2507bf7fb8f0780cacbca1f2338d031 F test/fkey8.test 51deda7f1a1448bca95875e4a6e1a3a75b4bd7215e924e845bd60de60e4d84bf F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fec4ff185a2f3f1bee8f27432206276636cf27365d2d41cd7282f8c0425f2e96 -R 25cfe1ba29c81abc6c4cc0abffb7da62 -U stephan -Z 0cb7636a2c620ecf85b9efcc34578b99 +P 239a3d1573f4cb720308018280b2add54034e69e38fe7060a7238875eee4f1c9 +R dfc3a0a07b5a7948068bb24ed717b487 +U dan +Z 96f6b83e4a526a99706f87b354741f28 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 289c53bcfc..6465b82876 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -239a3d1573f4cb720308018280b2add54034e69e38fe7060a7238875eee4f1c9 +39bdbb3f6dd1d30d180526d35c11f789f5e9d45b99ead72fd4a3b136afab66b1 diff --git a/src/vdbeapi.c b/src/vdbeapi.c index e33cb2e4d3..5fc04b139c 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -783,7 +783,7 @@ static int sqlite3Step(Vdbe *p){ } assert( db->nVdbeWrite>0 || db->autoCommit==0 - || (db->nDeferredCons==0 && db->nDeferredImmCons==0) + || ((db->nDeferredCons + db->nDeferredImmCons)==0) ); #ifndef SQLITE_OMIT_TRACE diff --git a/test/fkey6.test b/test/fkey6.test index 8658759523..72de926b52 100644 --- a/test/fkey6.test +++ b/test/fkey6.test @@ -250,7 +250,22 @@ do_catchsql_test 4.2 { COMMIT; } {1 {FOREIGN KEY constraint failed}} +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 5.0 { + PRAGMA foreign_keys = 1; + CREATE TABLE p1(a INTEGER PRIMARY KEY, b); + CREATE TABLE c1(x REFERENCES p1 DEFERRABLE INITIALLY DEFERRED); +} +do_execsql_test 5.1 { + BEGIN; + INSERT INTO c1 VALUES(123); + PRAGMA defer_foreign_keys = 1; + INSERT INTO p1 VALUES(123, 'one two three'); + COMMIT; +} finish_test From c69d537b93c85222ca8d44287b4167a2b28d1145 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 20 Jan 2025 19:19:31 +0000 Subject: [PATCH 037/115] Remove an assert() in the unix file locking logic that is not true if alternative VFS "unix-excl" is used for a read-only connection. FossilOrigin-Name: bd5dc92368e41231a07bb59dd3db8942e238129ec7a3c8d785459d9b62bfcba3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6c62b5451d..dfd6f151c7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sassert()\sthat\scould\sfail\sif\sa\svirtual\stable\scalled\ssqlite3_step()\sfrom\swithin\sthe\sxSync()\smethod\swhile\scommitting\sa\s"PRAGMA\sdefer_foreign_keys=1"\stransaction. -D 2025-01-20T18:26:58.868 +C Remove\san\sassert()\sin\sthe\sunix\sfile\slocking\slogic\sthat\sis\snot\strue\nif\salternative\sVFS\s"unix-excl"\sis\sused\sfor\sa\sread-only\sconnection. +D 2025-01-20T19:19:31.053 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -763,7 +763,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 d2edbd92b07a3f778c2defa8a2e9d75acceb6267bda56948c41e8cdda65224d6 +F src/os_unix.c 4c73f89479d90412cb736a180e9ef89ac1495a158753a7f5de1260c197bc8e1f F src/os_win.c 49c7725b500f5867e8360e75eeb30f9d70b62fa1f05c8a101da627210578df32 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 3a1c4e7f69af482e33c8cba8a75afe0dda0ea6391240adac22b040ce1bdeef44 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 239a3d1573f4cb720308018280b2add54034e69e38fe7060a7238875eee4f1c9 -R dfc3a0a07b5a7948068bb24ed717b487 -U dan -Z 96f6b83e4a526a99706f87b354741f28 +P 39bdbb3f6dd1d30d180526d35c11f789f5e9d45b99ead72fd4a3b136afab66b1 +R 2f208773f4b90552fa108ddc899a9482 +U drh +Z e41ea2237d4e46f40152146fd24a89c1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6465b82876..3be5a85248 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39bdbb3f6dd1d30d180526d35c11f789f5e9d45b99ead72fd4a3b136afab66b1 +bd5dc92368e41231a07bb59dd3db8942e238129ec7a3c8d785459d9b62bfcba3 diff --git a/src/os_unix.c b/src/os_unix.c index b1996278c8..c897895d72 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1664,7 +1664,7 @@ static int unixFileLock(unixFile *pFile, struct flock *pLock){ if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){ if( pInode->bProcessLock==0 ){ struct flock lock; - assert( pInode->nLock==0 ); + /* assert( pInode->nLock==0 ); <-- Not true if unix-excl READONLY used */ lock.l_whence = SEEK_SET; lock.l_start = SHARED_FIRST; lock.l_len = SHARED_SIZE; From ae24e13bc7b3d8d24aa1331db56502af7819768f Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 20 Jan 2025 19:57:32 +0000 Subject: [PATCH 038/115] Add 'dist' and missing 'install' pieces to the autoconf bundle. FossilOrigin-Name: 16fa20413e3f3f0b6ea5d97022945843d1f785ac0142836f2a3651fd1917385f --- autoconf/Makefile.in | 69 ++++++++++++++++++++++++++++++++----- autoconf/auto.def | 7 +++- autosetup/sqlite-config.tcl | 6 ++-- manifest | 19 +++++----- manifest.uuid | 2 +- tool/mkautoconfamal.sh | 11 +++--- 6 files changed, 83 insertions(+), 31 deletions(-) diff --git a/autoconf/Makefile.in b/autoconf/Makefile.in index 18e8e9a740..d43300c829 100644 --- a/autoconf/Makefile.in +++ b/autoconf/Makefile.in @@ -1,7 +1,11 @@ +######################################################################## +# This is a main makefile for the "autoconf" bundle of SQLite. all: TOP = @abs_top_srcdir@ +PACKAGE_VERSION = @PACKAGE_VERSION@ + # # Filename extensions for binaries and libraries # @@ -31,6 +35,10 @@ AR = @AR@ AR.flags = cr CC = @CC@ + +ENABLE_LIB_SHARED = @ENABLE_LIB_SHARED@ +ENABLE_LIB_STATIC = @ENABLE_LIB_STATIC@ + CFLAGS = @CFLAGS@ @CPPFLAGS@ # # $(LDFLAGS.configure) represents any LDFLAGS=... the client passes to @@ -127,6 +135,37 @@ $(libsqlite3.LIB): sqlite3.o $(AR) $(AR.flags) $@ sqlite3.o all: $(libsqlite3.LIB) +install-so-1: $(install-dir.lib) $(libsqlite3.SO) + $(INSTALL) $(libsqlite3.SO) "$(install-dir.lib)" + @echo "Setting up $(libsqlite3.SO) symlinks..."; \ + cd "$(install-dir.lib)" || exit $$?; \ + rm -f $(libsqlite3.SO).0 $(libsqlite3.SO).$(PACKAGE_VERSION) || exit $$?; \ + mv $(libsqlite3.SO) $(libsqlite3.SO).$(PACKAGE_VERSION) || exit $$?; \ + ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO) || exit $$?; \ + ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO).0 || exit $$?; \ + ls -la $(libsqlite3.SO) $(libsqlite3.SO).[03]*; \ + if [ -e $(libsqlite3.SO).0.8.6 ]; then \ + echo "ACHTUNG: legacy libtool-compatible install found. Re-linking it..."; \ + rm -f libsqlite3.la $(libsqlite3.SO).0.8.6 || exit $$?; \ + ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO).0.8.6 || exit $$?; \ + ls -la $(libsqlite3.SO).0.8.6; \ + elif [ x1 = "x$(INSTALL_SO_086_LINK)" ]; then \ + echo "ACHTUNG: installing legacy libtool-style links because INSTALL_SO_086_LINK=1"; \ + rm -f libsqlite3.la $(libsqlite3.SO).0.8.6 || exit $$?; \ + ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO).0.8.6 || exit $$?; \ + ls -la $(libsqlite3.SO).0.8.6; \ + fi +install-so-0 install-so-: +install-so: install-so-$(ENABLE_LIB_SHARED) +install: install-so + +install-lib-1: $(install-dir.lib) $(libsqlite3.LIB) + $(INSTALL.noexec) $(libsqlite3.LIB) "$(install-dir.lib)" +install-lib-0 install-lib-: +install-lib: install-lib-$(ENABLE_LIB_STATIC) +install: install-lib + + sqlite3$(T.exe): shell.c sqlite3.c $(CC) -o $@ \ shell.c sqlite3.c \ @@ -147,21 +186,33 @@ install-pc: sqlite3.pc $(install-dir.pkgconfig) $(INSTALL.noexec) sqlite3.pc "$(install-dir.pkgconfig)" install: install-pc +install-man1: sqlite3.1 $(install-dir.man1) + $(INSTALL.noexec) sqlite3.1 "$(install-dir.man1)" +install: install-man1 + clean: rm -f *.o sqlite3$(T.exe) rm -f $(libsqlite3.LIB) $(libsqlite3.SO) distclean: clean - rm -f sqlite3.pc + rm -f jimsh0$(T.exe) config.* sqlite3.pc -DIST_FILES := auto.def autosetup tea \ +DIST_FILES := \ + README.txt VERSION \ + auto.def autosetup configure tea \ sqlite3.h sqlite3.c shell.c sqlite3ext.h \ - sqlite3.1 \ - Makefile.msc sqlite3.rc sqlite3rc.h Replace.cs \ - README.txt Makefile.fallback + Makefile.in Makefile.msc Makefile.fallback \ + sqlite3.rc sqlite3rc.h Replace.cs \ + sqlite3.pc.in sqlite3.1 +# Maintenance note: dist_name must be sqlite-$(PACKAGE_VERSION) so +# that tool/mkautoconfamal.sh knows how to find it. +dist_name = sqlite-$(PACKAGE_VERSION) +dist_tarball = $(dist_name).tar.gz dist: - @echo "Not Yet Implemented: $@"; exit 1 - -install: - @echo "Not Yet Implemented: $@"; exit 1 + rm -fr $(dist_name) + mkdir -p $(dist_name) + cp -rp $(DIST_FILES) $(dist_name)/. + tar czf $(dist_tarball) $(dist_name) + rm -fr $(dist_name) + ls -l $(dist_tarball) diff --git a/autoconf/auto.def b/autoconf/auto.def index 0f9424b555..28faeee391 100644 --- a/autoconf/auto.def +++ b/autoconf/auto.def @@ -11,7 +11,8 @@ use sqlite-config options { # - static=1 => {Disable build of static library (mostly)} + static=1 => {Disable build of static library} + shared=1 => {Disable build of shared library} # # threadsafe=1 => {Disable mutexing} @@ -91,5 +92,9 @@ sqlite-handle-math sqlite-handle-icu sqlite-handle-common-feature-flags sqlite-show-feature-flags + +define ENABLE_LIB_SHARED [opt-bool shared] +define ENABLE_LIB_STATIC [opt-bool static] + sqlite-process-dot-in-files sqlite-post-config-validation diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 5e2d121565..f1ebc72913 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -1013,9 +1013,7 @@ proc sqlite-check-tcl {} { if {"" ne $with_tclsh} { # --with-tclsh was provided or found above. Validate it and use it # to trump any value passed via --with-tcl=DIR. - if {![file isfile $with_tclsh]} { - proj-fatal "TCL shell $with_tclsh is not a file" - } elseif {![file-isexec $with_tclsh]} { + if {![file-isexec $with_tclsh]} { proj-fatal "TCL shell $with_tclsh is not executable" } else { define TCLSH_CMD $with_tclsh @@ -1079,7 +1077,7 @@ proc sqlite-check-tcl {} { # Export a subset of tclConfig.sh to the current TCL-space. If $cfg # is an empty string, this emits empty-string entries for the # various options we're interested in. - eval [exec "$srcdir/tool/tclConfigShToAutoDef.sh" "$cfg"] + eval [exec /bin/sh "$srcdir/tool/tclConfigShToAutoDef.sh" "$cfg"] if {"" eq $with_tclsh && $cfg ne ""} { # We have tclConfig.sh but no tclsh. Attempt to locate a tclsh diff --git a/manifest b/manifest index 46cb1f1ef6..6e1682a339 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Get\slibsqlite3.so\sand\s.a\sbuilding\sin\sthe\sautoconf\sbundle. -D 2025-01-19T21:47:06.974 +C Add\s'dist'\sand\smissing\s'install'\spieces\sto\sthe\sautoconf\sbundle. +D 2025-01-20T19:57:32.754 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -17,11 +17,11 @@ F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821 F auto.def 7833c0a8630dd3a3410dcc6c8b4d1b63f25d03d6497267624b8a37aba119cb3e F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac -F autoconf/Makefile.in 3fa678c42221c95ac4fc13d60b145840b9b93e7885c7d040669f3e481b5a8e93 +F autoconf/Makefile.in 330a4f6a43ed3076c6e2e0627b17091a1fb1c8ab136fcc46048d6f1662f8f0d8 F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 5e946ffb6fbdbb114c81e1bdc862df27fce8beab557d7b0421820b0fe8fc048f -F autoconf/auto.def a2c428a91f5e3fa699e733fc3c1621ad145f3ac9f785e6518ecfe73a874f0e03 +F autoconf/auto.def 1d740e01d05d34140f0f403201fe625eb6469efb9b5645f068dc6b38cb005c9a F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277 F autoconf/tea/Makefile.in ba0556fee8da09c066bad85a4457904e46ee2c2eabaa309c0e83a78f2f151a8e F autoconf/tea/README.txt 61e62e519579e4a112791354d6d440f8b51ea6db3b0bab58d59f29df42d2dfe3 @@ -52,7 +52,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 50b060ea6760b02ef5cb16650fbe9c1840e16351a0be0ccfc3727c565f74a257 -F autosetup/sqlite-config.tcl 7a5cf6b40c5763c473c2638041ba8812f32062a78545aff223e0913fc4a7c57d +F autosetup/sqlite-config.tcl d1d3e66be58bf10100abf925e6b6baa98e0bad0fd581a8c0b7fd953996d6b85f F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2144,7 +2144,7 @@ F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669 F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176 F tool/mkamalzip.tcl 8aa5ebe7973c8b8774062d34e15fea9815c4cc2ceea3a9b184695f005910876a -F tool/mkautoconfamal.sh 7a9b54df5f3fbcbef9ff7f4d7bffb1b074425db23f999e1b27bd0b544fe7f2ff +F tool/mkautoconfamal.sh de0dd50c6c5899330bb1f9c9fcaf71e8fbede3229034839cafc1e8485c5e827d F tool/mkccode.tcl 210159febe0ef0ecbc53c79833500663ceaba0115b2b374405818dc835b5f84b x F tool/mkctimec.tcl ef6a67ec82e5b6fc19152a4c79f237227b18bf67ff16d155bac7adb94355d9cf x F tool/mkkeywordhash.c 6b0be901c47f9ad42215fc995eb2f4384ac49213b1fba395102ec3e999acf559 @@ -2209,8 +2209,9 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 241cdbc40a2f82df53c149849a103a335b0643a65e229a1e80ab90a0e457bb6b -R b35046aa7e07fc080621217913b53d03 +P 88cee3fc7c8bfd9b6955fb6b2fd6b25660563e4d043ffa5ea18d8abe91afdb7f +Q +239a3d1573f4cb720308018280b2add54034e69e38fe7060a7238875eee4f1c9 +R e0c333605d60d87f3232edd28cb1fd40 U stephan -Z f3e60d1f16fabf25d54188672248bb86 +Z 675925c45ad830a2f82ac547ac838105 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a00e35956d..0bb20b59c6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -88cee3fc7c8bfd9b6955fb6b2fd6b25660563e4d043ffa5ea18d8abe91afdb7f +16fa20413e3f3f0b6ea5d97022945843d1f785ac0142836f2a3651fd1917385f diff --git a/tool/mkautoconfamal.sh b/tool/mkautoconfamal.sh index 3b46fc4de8..5c96b26c64 100644 --- a/tool/mkautoconfamal.sh +++ b/tool/mkautoconfamal.sh @@ -22,8 +22,8 @@ set -u TMPSPACE=./mkpkg_tmp_dir VERSION=`cat $TOP/VERSION` -HASH=`sed 's/^\(..........\).*/\1/' $TOP/manifest.uuid` -DATETIME=`grep '^D' $TOP/manifest | sed -e 's/[^0-9]//g' -e 's/\(............\).*/\1/'` +HASH=`cut -c1-10 $TOP/manifest.uuid` +DATETIME=`grep '^D' $TOP/manifest | cut -c3- | tr -c -d '[0-9]'` # Verify that the version number in the TEA autoconf file is correct. # Fail with an error if not. @@ -96,14 +96,11 @@ cd tea autoconf rm -rf autom4te.cache -echo "--------------- TODO: -----------------" -cat < Date: Mon, 20 Jan 2025 20:48:18 +0000 Subject: [PATCH 039/115] configure script: work around msys's inability to 'exec' a '.sh' file by prefixing the call with an explicit 'sh', as reported in [forum:befb352a42a7cd6d|forum post befb352a42a7cd6d]. FossilOrigin-Name: 25b01f1c9a5e606441bfd4e729fb88361436dffc76ef7a10c04a4d4ad0bcc655 --- autosetup/sqlite-config.tcl | 4 +++- manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index f1ebc72913..96b7d0c1b3 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -1077,7 +1077,9 @@ proc sqlite-check-tcl {} { # Export a subset of tclConfig.sh to the current TCL-space. If $cfg # is an empty string, this emits empty-string entries for the # various options we're interested in. - eval [exec /bin/sh "$srcdir/tool/tclConfigShToAutoDef.sh" "$cfg"] + eval [exec sh "$srcdir/tool/tclConfigShToAutoDef.sh" "$cfg"] + # ---------^^ a Windows/msys workaround, without which it cannot + # exec a .sh file: https://sqlite.org/forum/forumpost/befb352a42a7cd6d if {"" eq $with_tclsh && $cfg ne ""} { # We have tclConfig.sh but no tclsh. Attempt to locate a tclsh diff --git a/manifest b/manifest index 6e1682a339..5a5d61168a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\s'dist'\sand\smissing\s'install'\spieces\sto\sthe\sautoconf\sbundle. -D 2025-01-20T19:57:32.754 +C configure\sscript:\swork\saround\smsys's\sinability\sto\s'exec'\sa\s'.sh'\sfile\sby\sprefixing\sthe\scall\swith\san\sexplicit\s'sh',\sas\sreported\sin\s[forum:befb352a42a7cd6d|forum\spost\sbefb352a42a7cd6d]. +D 2025-01-20T20:48:18.754 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -52,7 +52,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 50b060ea6760b02ef5cb16650fbe9c1840e16351a0be0ccfc3727c565f74a257 -F autosetup/sqlite-config.tcl d1d3e66be58bf10100abf925e6b6baa98e0bad0fd581a8c0b7fd953996d6b85f +F autosetup/sqlite-config.tcl cf9790dc31d498b69ad2b348b7a3a6f2c7df9a86d770b31dff2255c2f62e5015 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2209,9 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 88cee3fc7c8bfd9b6955fb6b2fd6b25660563e4d043ffa5ea18d8abe91afdb7f -Q +239a3d1573f4cb720308018280b2add54034e69e38fe7060a7238875eee4f1c9 -R e0c333605d60d87f3232edd28cb1fd40 +P 16fa20413e3f3f0b6ea5d97022945843d1f785ac0142836f2a3651fd1917385f +R 530ea71496225522d46777a9a2bdcaa9 U stephan -Z 675925c45ad830a2f82ac547ac838105 +Z fe186d8bfdcab6314981338fcde5c9d6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0bb20b59c6..b94a093c93 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -16fa20413e3f3f0b6ea5d97022945843d1f785ac0142836f2a3651fd1917385f +25b01f1c9a5e606441bfd4e729fb88361436dffc76ef7a10c04a4d4ad0bcc655 From d0db5edf612fff09e4548e952247ffaec53e1c19 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 21 Jan 2025 11:10:16 +0000 Subject: [PATCH 040/115] Use Tcl_GetString() instead of Tcl_GetCharLength() to test for a zero-length string in the TCL interface, since that is much more efficient. FossilOrigin-Name: a8d9dcfd23fbfcd887e451382836c1e88215984cc01e00be11387dbf4ab26fd8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tclsqlite.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index dfd6f151c7..993a673926 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sassert()\sin\sthe\sunix\sfile\slocking\slogic\sthat\sis\snot\strue\nif\salternative\sVFS\s"unix-excl"\sis\sused\sfor\sa\sread-only\sconnection. -D 2025-01-20T19:19:31.053 +C Use\sTcl_GetString()\sinstead\sof\sTcl_GetCharLength()\sto\stest\sfor\sa\szero-length\nstring\sin\sthe\sTCL\sinterface,\ssince\sthat\sis\smuch\smore\sefficient. +D 2025-01-21T11:10:16.446 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -788,7 +788,7 @@ F src/sqliteInt.h 953f2476f712b115ecb43f7a21183d07c88af8d3b4c32f18317724ce1ce04d F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c c6b9d3a0b1100e1e028460c418c41ca180dac5958e96bef79f6799b552522a37 +F src/tclsqlite.c 6a7538560adc856faea295c0f09c33a57a1cfa5c59f85ab4e12aa50dba7ff2de F src/tclsqlite.h 65e2c761446e1c9fa0342b7d2612a703483643c8b6a316d12a65b745a4727395 F src/test1.c 9d2da51b4c33633e7370e4068af6d16d2c52b22a5810ec012ac32e77f8397b64 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 39bdbb3f6dd1d30d180526d35c11f789f5e9d45b99ead72fd4a3b136afab66b1 -R 2f208773f4b90552fa108ddc899a9482 +P bd5dc92368e41231a07bb59dd3db8942e238129ec7a3c8d785459d9b62bfcba3 +R e87ed836260a3ceb4ad61cd2f818556e U drh -Z e41ea2237d4e46f40152146fd24a89c1 +Z 345b10e2ab0f1f1054b6abc135136648 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3be5a85248..b56b8e91ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bd5dc92368e41231a07bb59dd3db8942e238129ec7a3c8d785459d9b62bfcba3 +a8d9dcfd23fbfcd887e451382836c1e88215984cc01e00be11387dbf4ab26fd8 diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 598c9355ff..76c9ef75c1 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -1964,7 +1964,7 @@ static void DbHookCmd( } if( pArg ){ assert( !(*ppHook) ); - if( Tcl_GetCharLength(pArg)>0 ){ + if( Tcl_GetString(pArg)[0] ){ *ppHook = pArg; Tcl_IncrRefCount(*ppHook); } From b80d01a18237eceabbe86d77b7f43acc1815c73f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Jan 2025 14:34:59 +0000 Subject: [PATCH 041/115] Have fts5 better handle OOM errors from sqlite3_blob_close(). FossilOrigin-Name: f418350f3f83147bc5817a885be6e39ff9ff5722742a88d17600729c53c65010 --- ext/fts5/fts5_index.c | 53 +++++++++++++++++++++++------------ ext/fts5/test/fts5faultI.test | 35 +++++++++++++++++++++++ manifest | 16 +++++------ manifest.uuid | 2 +- 4 files changed, 79 insertions(+), 27 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index a8ac98b699..c98844e73d 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -778,11 +778,13 @@ static int fts5LeafFirstTermOff(Fts5Data *pLeaf){ /* ** Close the read-only blob handle, if it is open. */ -void sqlite3Fts5IndexCloseReader(Fts5Index *p){ +void fts5IndexCloseReader(Fts5Index *p){ if( p->pReader ){ + int rc; sqlite3_blob *pReader = p->pReader; p->pReader = 0; - sqlite3_blob_close(pReader); + rc = sqlite3_blob_close(pReader); + if( p->rc==SQLITE_OK ) p->rc = rc; } } @@ -807,7 +809,7 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){ assert( p->pReader==0 ); p->pReader = pBlob; if( rc!=SQLITE_OK ){ - sqlite3Fts5IndexCloseReader(p); + fts5IndexCloseReader(p); } if( rc==SQLITE_ABORT ) rc = SQLITE_OK; } @@ -5009,6 +5011,14 @@ static int fts5IndexReturn(Fts5Index *p){ return rc; } +/* +** Close the read-only blob handle, if it is open. +*/ +void sqlite3Fts5IndexCloseReader(Fts5Index *p){ + fts5IndexCloseReader(p); + fts5IndexReturn(p); +} + typedef struct Fts5FlushCtx Fts5FlushCtx; struct Fts5FlushCtx { Fts5Index *pIdx; @@ -6730,7 +6740,7 @@ int sqlite3Fts5IndexBeginWrite(Fts5Index *p, int bDelete, i64 iRowid){ int sqlite3Fts5IndexSync(Fts5Index *p){ assert( p->rc==SQLITE_OK ); fts5IndexFlush(p); - sqlite3Fts5IndexCloseReader(p); + fts5IndexCloseReader(p); return fts5IndexReturn(p); } @@ -6741,11 +6751,10 @@ int sqlite3Fts5IndexSync(Fts5Index *p){ ** records must be invalidated. */ int sqlite3Fts5IndexRollback(Fts5Index *p){ - sqlite3Fts5IndexCloseReader(p); + fts5IndexCloseReader(p); fts5IndexDiscardData(p); fts5StructureInvalidate(p); - /* assert( p->rc==SQLITE_OK ); */ - return SQLITE_OK; + return fts5IndexReturn(p); } /* @@ -6946,6 +6955,16 @@ static void fts5SegIterSetEOF(Fts5SegIter *pSeg){ pSeg->pLeaf = 0; } +void fts5IterClose(Fts5IndexIter *pIndexIter){ + if( pIndexIter ){ + Fts5Iter *pIter = (Fts5Iter*)pIndexIter; + Fts5Index *pIndex = pIter->pIndex; + fts5TokendataIterDelete(pIter->pTokenDataIter); + fts5MultiIterFree(pIter); + fts5IndexCloseReader(pIndex); + } +} + /* ** This function appends iterator pAppend to Fts5TokenDataIter pIn and ** returns the result. @@ -6973,7 +6992,7 @@ static Fts5TokenDataIter *fts5AppendTokendataIter( } } if( p->rc ){ - sqlite3Fts5IterClose((Fts5IndexIter*)pAppend); + fts5IterClose((Fts5IndexIter*)pAppend); }else{ pRet->apIter[pRet->nIter++] = pAppend; } @@ -7186,7 +7205,7 @@ static Fts5Iter *fts5SetupTokendataIter( fts5BufferSet(&p->rc, &bSeek, nToken, pToken); } if( p->rc ){ - sqlite3Fts5IterClose((Fts5IndexIter*)pNew); + fts5IterClose((Fts5IndexIter*)pNew); break; } @@ -7251,7 +7270,7 @@ static Fts5Iter *fts5SetupTokendataIter( ** not point to any terms that match the query. So delete it and break ** out of the loop - all required iterators have been collected. */ if( pSmall==0 ){ - sqlite3Fts5IterClose((Fts5IndexIter*)pNew); + fts5IterClose((Fts5IndexIter*)pNew); break; } @@ -7380,9 +7399,9 @@ int sqlite3Fts5IndexQuery( } if( p->rc ){ - sqlite3Fts5IterClose((Fts5IndexIter*)pRet); + fts5IterClose((Fts5IndexIter*)pRet); pRet = 0; - sqlite3Fts5IndexCloseReader(p); + fts5IndexCloseReader(p); } *ppIter = (Fts5IndexIter*)pRet; @@ -7632,11 +7651,9 @@ int sqlite3Fts5IndexIterWriteTokendata( */ void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){ if( pIndexIter ){ - Fts5Iter *pIter = (Fts5Iter*)pIndexIter; - Fts5Index *pIndex = pIter->pIndex; - fts5TokendataIterDelete(pIter->pTokenDataIter); - fts5MultiIterFree(pIter); - sqlite3Fts5IndexCloseReader(pIndex); + Fts5Index *pIndex = ((Fts5Iter*)pIndexIter)->pIndex; + fts5IterClose(pIndexIter); + fts5IndexReturn(pIndex); } } @@ -8166,7 +8183,7 @@ static int fts5QueryCksum( rc = sqlite3Fts5IterNext(pIter); } } - sqlite3Fts5IterClose(pIter); + fts5IterClose(pIter); *pCksum = cksum; return rc; diff --git a/ext/fts5/test/fts5faultI.test b/ext/fts5/test/fts5faultI.test index 72f25caee1..ab84d37de5 100644 --- a/ext/fts5/test/fts5faultI.test +++ b/ext/fts5/test/fts5faultI.test @@ -290,5 +290,40 @@ do_faultsim_test 11 -faults oom* -prep { faultsim_test_result {0 {}} } +#------------------------------------------------------------------------- +reset_db + +ifcapable foreignkey { + do_execsql_test 12.0 { + CREATE VIRTUAL TABLE f1 USING fts5(content); + CREATE TABLE p1(a INTEGER PRIMARY KEY); + CREATE TABLE c1(b REFERENCES p1 DEFERRABLE INITIALLY DEFERRED); + } + + faultsim_save_and_close + + do_faultsim_test 11 -faults oom* -prep { + faultsim_restore_and_reopen + execsql { + PRAGMA foreign_keys = 1; + BEGIN; + INSERT INTO c1 VALUES(123); + SAVEPOINT xyz; + } + } -body { + execsql { + INSERT INTO f1 VALUES('a b c'); + ROLLBACK TO xyz; + COMMIT; + } + } -test { + execsql { SELECT 123 } + faultsim_test_result \ + {1 {FOREIGN KEY constraint failed}} \ + {1 {out of memory}} \ + {1 {constraint failed}} + } +} + finish_test diff --git a/manifest b/manifest index 993a673926..b6bbc0b68f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sTcl_GetString()\sinstead\sof\sTcl_GetCharLength()\sto\stest\sfor\sa\szero-length\nstring\sin\sthe\sTCL\sinterface,\ssince\sthat\sis\smuch\smore\sefficient. -D 2025-01-21T11:10:16.446 +C Have\sfts5\sbetter\shandle\sOOM\serrors\sfrom\ssqlite3_blob_close(). +D 2025-01-21T14:34:59.118 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -113,7 +113,7 @@ F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70 F ext/fts5/fts5_config.c e7d8dd062b44a66cd77e5a0f74f23a2354cd1f3f8575afb967b2773c3384f7f8 F ext/fts5/fts5_expr.c 69b8d976058512c07dfe86e229521b7a871768157bd1607cedf1a5038dfd72c9 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 -F ext/fts5/fts5_index.c f1f6da5938af616e0a5e54f0423a3134df95b9f17ac1c6ebf2e2e8132bbc75b9 +F ext/fts5/fts5_index.c 1ce1e2b43fdd86a2047619c2ea3aafa5c7b909d0cef75185d0fda31e82f0e9c6 F ext/fts5/fts5_main.c 9a1daef7247f9b8a50b4159323e340efa6b0e4bea4fcd83580480f94d4f2c888 F ext/fts5/fts5_storage.c 1ad05dab4830a4e2eaf2900bb143477f93bc17437093582f36f4b818809e88d8 F ext/fts5/fts5_tcl.c 7fb5a3d3404099075aaa2457307cb459bbc257c0de3dbd52b1e80a5b503e0329 @@ -192,7 +192,7 @@ F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e F ext/fts5/test/fts5faultF.test 4abef99f86e99d9f0c6460dd68c586a766b6b9f1f660ada55bf2e8266bd1bbc1 F ext/fts5/test/fts5faultG.test 0544411ffcb3e19b42866f757a8a5e0fb8fef3a62c06f61d14deebc571bb7ea9 F ext/fts5/test/fts5faultH.test 2b2b5b8cb1b3fd7679f488c06e22af44107fbc6137eaf45b3e771dc7b149312d -F ext/fts5/test/fts5faultI.test 0706b307b208638554c9e65b4091e1c0dd8c92941535089a301df454ff2c56f4 +F ext/fts5/test/fts5faultI.test 9b33d664bccee4bbde0f275a48b2df3ea2f05d41f6d1d171aa2e844382cba621 F ext/fts5/test/fts5first.test bfd685b96905bf541d99d8644e0a7219d1d833455a08ab64e344071a613b6ba9 F ext/fts5/test/fts5full.test 97d263c1072f4a560929cca31e70f65d2ae232610e17e6affcf7e979df59547b F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bd5dc92368e41231a07bb59dd3db8942e238129ec7a3c8d785459d9b62bfcba3 -R e87ed836260a3ceb4ad61cd2f818556e -U drh -Z 345b10e2ab0f1f1054b6abc135136648 +P a8d9dcfd23fbfcd887e451382836c1e88215984cc01e00be11387dbf4ab26fd8 +R 0ff09c4d1a6df4a00a8ce3e62a42f2fa +U dan +Z dbb8340d556717da4724fb10b820bbe7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b56b8e91ab..07c5f158d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a8d9dcfd23fbfcd887e451382836c1e88215984cc01e00be11387dbf4ab26fd8 +f418350f3f83147bc5817a885be6e39ff9ff5722742a88d17600729c53c65010 From 631900291d8471903a8bb24b4401cd5b14fd78e1 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 21 Jan 2025 14:40:35 +0000 Subject: [PATCH 042/115] Remove now-extraneous autoconf/INSTALL and autoconf/configure.ac and update autoconf/README.* to account for the port to autosetup. FossilOrigin-Name: 646667af8ca2140d823facf4578105c3d9815ea34b2a4cb96103c2fe7d718229 --- autoconf/INSTALL | 370 ------------------------------------------ autoconf/README.first | 13 +- autoconf/README.txt | 25 +-- autoconf/auto.def | 6 +- autoconf/configure.ac | 270 ------------------------------ manifest | 18 +- manifest.uuid | 2 +- 7 files changed, 32 insertions(+), 672 deletions(-) delete mode 100644 autoconf/INSTALL delete mode 100644 autoconf/configure.ac diff --git a/autoconf/INSTALL b/autoconf/INSTALL deleted file mode 100644 index a1e89e18ad..0000000000 --- a/autoconf/INSTALL +++ /dev/null @@ -1,370 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, -Inc. - - Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without warranty of any kind. - -Basic Installation -================== - - Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. Some packages provide this -`INSTALL' file but do not implement all of the features documented -below. The lack of an optional feature in a given package is not -necessarily a bug. More recommendations for GNU packages can be found -in *note Makefile Conventions: (standards)Makefile Conventions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. - - The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. - - Running `configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package, generally using the just-built uninstalled binaries. - - 4. Type `make install' to install the programs and any data files and - documentation. When installing into a prefix owned by root, it is - recommended that the package be configured and built as a regular - user, and only the `make install' phase executed with root - privileges. - - 5. Optionally, type `make installcheck' to repeat any self-tests, but - this time using the binaries in their final installed location. - This target does not install anything. Running this target as a - regular user, particularly if the prior `make install' required - root privileges, verifies that the installation completed - correctly. - - 6. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - - 7. Often, you can also type `make uninstall' to remove the installed - files again. In practice, not all packages have tested that - uninstallation works correctly, even though it is required by the - GNU Coding Standards. - - 8. Some packages, particularly those that use Automake, provide `make - distcheck', which can by used by developers to test that all other - targets like `make install' and `make uninstall' work correctly. - This target is generally not run by end users. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. This -is known as a "VPATH" build. - - With a non-GNU `make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before -reconfiguring for another architecture. - - On MacOS X 10.5 and later systems, you can create libraries and -executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like -this: - - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CPP="gcc -E" CXXCPP="g++ -E" - - This is not guaranteed to produce working output in all cases, you -may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. - -Installation Names -================== - - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX', where PREFIX must be an -absolute file name. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the -default for these options is expressed in terms of `${prefix}', so that -specifying just `--prefix' will affect all of the other directory -specifications that were not explicitly provided. - - The most portable way to affect installation locations is to pass the -correct locations to `configure'; however, many packages provide one or -both of the following shortcuts of passing variable assignments to the -`make install' command line to change installation locations without -having to reconfigure or recompile. - - The first method involves providing an override variable for each -affected directory. For example, `make install -prefix=/alternate/directory' will choose an alternate location for all -directory configuration variables that were expressed in terms of -`${prefix}'. Any directories that were specified during `configure', -but not in terms of `${prefix}', must each be overridden at install -time for the entire installation to be relocated. The approach of -makefile variable overrides for each directory variable is required by -the GNU Coding Standards, and ideally causes no recompilation. -However, some platforms have known limitations with the semantics of -shared libraries that end up requiring recompilation when using this -method, particularly noticeable in packages that use GNU Libtool. - - The second method involves providing the `DESTDIR' variable. For -example, `make install DESTDIR=/alternate/directory' will prepend -`/alternate/directory' before all installation names. The approach of -`DESTDIR' overrides is not required by the GNU Coding Standards, and -does not work on platforms that have drive letters. On the other hand, -it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of `${prefix}' -at `configure' time. - -Optional Features -================= - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - - Some packages offer the ability to configure how verbose the -execution of `make' will be. For these packages, running `./configure ---enable-silent-rules' sets the default to minimal output, which can be -overridden with `make V=1'; while running `./configure ---disable-silent-rules' sets the default to verbose, which can be -overridden with `make V=0'. - -Particular systems -================== - - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in -order to use an ANSI C compiler: - - ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" - -and if that doesn't work, install pre-built binaries of GCC for HP-UX. - - HP-UX `make' updates targets which have the same time stamps as -their prerequisites, which makes it generally unusable when shipped -generated files such as `configure' are involved. Use GNU `make' -instead. - - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try - - ./configure CC="cc" - -and if that doesn't work, try - - ./configure CC="cc -nodtk" - - On Solaris, don't put `/usr/ucb' early in your `PATH'. This -directory contains several dysfunctional programs; working variants of -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' -in your `PATH', put it _after_ `/usr/bin'. - - On Haiku, software installed for all users goes in `/boot/common', -not `/usr/local'. It is recommended to use the following options: - - ./configure --prefix=/boot/common - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS - KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: - - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. - -`--help=short' -`--help=recursive' - Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. - -`--no-create' -`-n' - Run the configure checks, but stop before creating any output - files. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/autoconf/README.first b/autoconf/README.first index 5c2ea0a70f..75c4a76d61 100644 --- a/autoconf/README.first +++ b/autoconf/README.first @@ -1,11 +1,12 @@ -This directory contains components use to build an autoconf-ready package -of the SQLite amalgamation: sqlite-autoconf-30XXXXXX.tar.gz +This directory contains components used to build an autoconf-like +package of the SQLite amalgamation: sqlite-autoconf-30XXXXXX.tar.gz -To build the autoconf amalgamation, run from the top-level: +To build the autoconf amalgamation, run from the top of the canonical +source tree: ./configure make amalgamation-tarball -The amalgamation-tarball target (also available in "main.mk") runs the -script tool/mkautoconfamal.sh which does the work. Refer to that script -for details. +The amalgamation-tarball target (available in "main.mk") runs the +script tool/mkautoconfamal.sh which does the work. Refer to that +script for details. diff --git a/autoconf/README.txt b/autoconf/README.txt index b3d3510746..646c0a1215 100644 --- a/autoconf/README.txt +++ b/autoconf/README.txt @@ -4,7 +4,7 @@ This package contains: * the sqlite3.h and sqlite3ext.h header files that define the C-language interface to the sqlite3.c library file * the shell.c file used to build the sqlite3 command-line shell program - * autoconf/automake installation infrastucture for building on POSIX + * autoconf-like installation infrastucture for building on POSIX compliant systems * a Makefile.msc, sqlite3.rc, and Replace.cs for building with Microsoft Visual C++ on Windows @@ -19,8 +19,10 @@ using only generic tools and without having to install TCL. The purpose of this package is to provide that capability. This package contains a pre-build SQLite amalgamation file "sqlite3.c" -(and its associated header file "sqlite3.h"). Because the amalgamation -has been pre-built, no TCL is required. +(and its associated header file "sqlite3.h"). Because the +amalgamation has been pre-built, no TCL is required for the code +generate (the configure script itself is written in TCL but it can use +the embedded copy of JimTCL). REASONS TO USE THE CANONICAL BUILD SYSTEM RATHER THAN THIS PACKAGE ================================================================== @@ -47,14 +49,12 @@ SUMMARY OF HOW TO BUILD USING THIS PACKAGE BUILDING ON POSIX ================= -The generic installation instructions for autoconf/automake are found -in the INSTALL file. +The configure script follows common conventions, making it easy +to use for anyone who has configured a software tree before. +It supports a number of build-time flags, the full list of which +can be seen by running: -The following SQLite specific boolean options are supported: - - --enable-readline use readline in shell tool [default=yes] - --enable-threadsafe build a thread-safe library [default=yes] - --enable-dynamic-extensions support loadable extensions [default=yes] + ./configure --help The default value for the CFLAGS variable (options passed to the C compiler) includes debugging symbols in the build, resulting in larger @@ -65,10 +65,11 @@ line like this: to produce a smaller installation footprint. -Other SQLite compilation parameters can also be set using CFLAGS. For +Many SQLite compilation parameters can be defined by passing flags +to the configure script. Others may be passed on in the CFLAGS. For example: - $ CFLAGS="-Os -DSQLITE_THREADSAFE=0" ./configure + $ CFLAGS="-Os -DSQLITE_OMIT_DEPRECATED" ./configure BUILDING WITH MICROSOFT VISUAL C++ diff --git a/autoconf/auto.def b/autoconf/auto.def index 28faeee391..0f36e733ca 100644 --- a/autoconf/auto.def +++ b/autoconf/auto.def @@ -2,10 +2,10 @@ # ^^^ help out editors which guess this file's content type. # # This is the main autosetup-compatible configure script for the -# TEA build of the SQLite project. +# "autoconf" bundle of the SQLite project. # -# This script should be kept compatible with JimTCL, a copy of which -# is included in this source tree as ./autosetup/jimsh0.c. +# This script must be kept compatible with JimTCL, a copy of which is +# included in this source tree as ./autosetup/jimsh0.c. # use sqlite-config diff --git a/autoconf/configure.ac b/autoconf/configure.ac deleted file mode 100644 index 0c7a32db1f..0000000000 --- a/autoconf/configure.ac +++ /dev/null @@ -1,270 +0,0 @@ - -#----------------------------------------------------------------------- -# Supports the following non-standard switches. -# -# --enable-threadsafe -# --enable-readline -# --enable-editline -# --enable-static-shell -# --enable-dynamic-extensions -# - -AC_PREREQ(2.61) -AC_INIT(sqlite, --SQLITE-VERSION--, http://www.sqlite.org) -AC_CONFIG_SRCDIR([sqlite3.c]) -AC_CONFIG_AUX_DIR([.]) - -# Use automake. -AM_INIT_AUTOMAKE([foreign]) - -AC_SYS_LARGEFILE - -# Check for required programs. -AC_PROG_CC -AC_PROG_LIBTOOL -AC_PROG_MKDIR_P - -# Check for library functions that SQLite can optionally use. -AC_CHECK_FUNCS([fdatasync usleep fullfsync localtime_r gmtime_r]) -AC_FUNC_STRERROR_R - -AC_CONFIG_FILES([Makefile sqlite3.pc]) -BUILD_CFLAGS= -AC_SUBST(BUILD_CFLAGS) - -#------------------------------------------------------------------------- -# Two options to enable readline compatible libraries: -# -# --enable-editline -# --enable-readline -# -# Both are enabled by default. If, after command line processing both are -# still enabled, the script searches for editline first and automatically -# disables readline if it is found. So, to use readline explicitly, the -# user must pass "--disable-editline". To disable command line editing -# support altogether, "--disable-editline --disable-readline". -# -# When searching for either library, check for headers before libraries -# as some distros supply packages that contain libraries but not header -# files, which come as a separate development package. -# -AC_ARG_ENABLE(editline, [AS_HELP_STRING([--enable-editline],[use BSD libedit])]) -AC_ARG_ENABLE(readline, [AS_HELP_STRING([--enable-readline],[use readline])]) - -AS_IF([ test x"$enable_editline" != xno ],[ - AC_CHECK_HEADERS([editline/readline.h],[ - sLIBS=$LIBS - LIBS="" - AC_SEARCH_LIBS([readline],[edit],[ - AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline) - READLINE_LIBS="$LIBS -ltinfo" - enable_readline=no - ],[],[-ltinfo]) - AS_UNSET(ac_cv_search_readline) - LIBS=$sLIBS - ]) -]) - -AS_IF([ test x"$enable_readline" != xno ],[ - AC_CHECK_HEADERS([readline/readline.h],[ - sLIBS=$LIBS - LIBS="" - AC_SEARCH_LIBS(tgetent, termcap curses ncurses ncursesw, [], []) - AC_SEARCH_LIBS(readline,[readline edit], [ - AC_DEFINE([HAVE_READLINE],1,Define to use readline or wrapper) - READLINE_LIBS=$LIBS - ]) - LIBS=$sLIBS - ]) -]) - -AC_SUBST(READLINE_LIBS) -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-threadsafe -# -AC_ARG_ENABLE(threadsafe, [AS_HELP_STRING( - [--enable-threadsafe], [build a thread-safe library [default=yes]])], - [], [enable_threadsafe=yes]) -if test x"$enable_threadsafe" == "xno"; then - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_THREADSAFE=0" -else - BUILD_CFLAGS="$BUILD_CFLAGS -D_REENTRANT=1 -DSQLITE_THREADSAFE=1" - AC_SEARCH_LIBS(pthread_create, pthread) - AC_SEARCH_LIBS(pthread_mutexattr_init, pthread) -fi -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-dynamic-extensions -# -AC_ARG_ENABLE(dynamic-extensions, [AS_HELP_STRING( - [--enable-dynamic-extensions], [support loadable extensions [default=yes]])], - [], [enable_dynamic_extensions=yes]) -if test x"$enable_dynamic_extensions" != "xno"; then - AC_SEARCH_LIBS(dlopen, dl) -else - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_OMIT_LOAD_EXTENSION=1" -fi -AC_MSG_CHECKING([for whether to support dynamic extensions]) -AC_MSG_RESULT($enable_dynamic_extensions) -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-math -# -AC_ARG_ENABLE(math, [AS_HELP_STRING( - [--enable-math], [SQL math functions [default=yes]])], - [], [enable_math=yes]) -AC_MSG_CHECKING([SQL math functions]) -if test x"$enable_math" = "xyes"; then - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_MATH_FUNCTIONS" - AC_MSG_RESULT([enabled]) - AC_SEARCH_LIBS(ceil, m) -else - AC_MSG_RESULT([disabled]) -fi -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-fts4 -# -AC_ARG_ENABLE(fts4, [AS_HELP_STRING( - [--enable-fts4], [include fts4 support [default=yes]])], - [], [enable_fts4=yes]) -AC_MSG_CHECKING([FTS4 extension]) -if test x"$enable_fts4" = "xyes"; then - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS4" - AC_MSG_RESULT([enabled]) -else - AC_MSG_RESULT([disabled]) -fi -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-fts3 -# -AC_ARG_ENABLE(fts3, [AS_HELP_STRING( - [--enable-fts3], [include fts3 support [default=no]])], - [], []) -AC_MSG_CHECKING([FTS3 extension]) -if test x"$enable_fts3" = "xyes" -a x"$enable_fts4" = "xno"; then - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS3" - AC_MSG_RESULT([enabled]) -else - AC_MSG_RESULT([disabled]) -fi -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-fts5 -# -AC_ARG_ENABLE(fts5, [AS_HELP_STRING( - [--enable-fts5], [include fts5 support [default=yes]])], - [], [enable_fts5=yes]) -AC_MSG_CHECKING([FTS5 extension]) -if test x"$enable_fts5" = "xyes"; then - AC_MSG_RESULT([enabled]) - AC_SEARCH_LIBS(log, m) - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS5" -else - AC_MSG_RESULT([disabled]) -fi -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-rtree -# -AC_ARG_ENABLE(rtree, [AS_HELP_STRING( - [--enable-rtree], [include rtree support [default=yes]])], - [], [enable_rtree=yes]) -AC_MSG_CHECKING([RTREE extension]) -if test x"$enable_rtree" = "xyes"; then - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY" - AC_MSG_RESULT([enabled]) -else - AC_MSG_RESULT([disabled]) -fi -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-session -# -AC_ARG_ENABLE(session, [AS_HELP_STRING( - [--enable-session], [enable the session extension [default=no]])], - [], []) -AC_MSG_CHECKING([Session extension]) -if test x"$enable_session" = "xyes"; then - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK" - AC_MSG_RESULT([enabled]) -else - AC_MSG_RESULT([disabled]) -fi -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-debug -# -AC_ARG_ENABLE(debug, [AS_HELP_STRING( - [--enable-debug], [build with debugging features enabled [default=no]])], - [], []) -AC_MSG_CHECKING([Build type]) -if test x"$enable_debug" = "xyes"; then - BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_DEBUG -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE" - CFLAGS="-g -O0" - AC_MSG_RESULT([debug]) -else - AC_MSG_RESULT([release]) -fi -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# --enable-static-shell -# -AC_ARG_ENABLE(static-shell, [AS_HELP_STRING( - [--enable-static-shell], - [statically link libsqlite3 into shell tool [default=yes]])], - [], [enable_static_shell=yes]) -if test x"$enable_static_shell" = "xyes"; then - EXTRA_SHELL_OBJ=sqlite3-sqlite3.$OBJEXT -else - EXTRA_SHELL_OBJ=libsqlite3.la -fi -AC_SUBST(EXTRA_SHELL_OBJ) -#----------------------------------------------------------------------- - -AC_CHECK_FUNCS(posix_fallocate) -AC_CHECK_HEADERS(zlib.h,[ - AC_SEARCH_LIBS(deflate,z,[BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_HAVE_ZLIB"]) -]) - -AC_SEARCH_LIBS(system,,,[SHELL_CFLAGS="-DSQLITE_NOHAVE_SYSTEM"]) -AC_SUBST(SHELL_CFLAGS) - -#----------------------------------------------------------------------- -# UPDATE: Maybe it's better if users just set CFLAGS before invoking -# configure. This option doesn't really add much... -# -# --enable-tempstore -# -# AC_ARG_ENABLE(tempstore, [AS_HELP_STRING( -# [--enable-tempstore], -# [in-memory temporary tables (never, no, yes, always) [default=no]])], -# [], [enable_tempstore=no]) -# AC_MSG_CHECKING([for whether or not to store temp tables in-memory]) -# case "$enable_tempstore" in -# never ) TEMP_STORE=0 ;; -# no ) TEMP_STORE=1 ;; -# always ) TEMP_STORE=3 ;; -# yes ) TEMP_STORE=3 ;; -# * ) -# TEMP_STORE=1 -# enable_tempstore=yes -# ;; -# esac -# AC_MSG_RESULT($enable_tempstore) -# AC_SUBST(TEMP_STORE) -#----------------------------------------------------------------------- - -AC_OUTPUT diff --git a/manifest b/manifest index 5a5d61168a..f787520fce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C configure\sscript:\swork\saround\smsys's\sinability\sto\s'exec'\sa\s'.sh'\sfile\sby\sprefixing\sthe\scall\swith\san\sexplicit\s'sh',\sas\sreported\sin\s[forum:befb352a42a7cd6d|forum\spost\sbefb352a42a7cd6d]. -D 2025-01-20T20:48:18.754 +C Remove\snow-extraneous\sautoconf/INSTALL\sand\sautoconf/configure.ac\sand\supdate\sautoconf/README.*\sto\saccount\sfor\sthe\sport\sto\sautosetup. +D 2025-01-21T14:40:35.953 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -15,14 +15,12 @@ F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 F auto.def 7833c0a8630dd3a3410dcc6c8b4d1b63f25d03d6497267624b8a37aba119cb3e -F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac F autoconf/Makefile.in 330a4f6a43ed3076c6e2e0627b17091a1fb1c8ab136fcc46048d6f1662f8f0d8 F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 -F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 -F autoconf/README.txt 5e946ffb6fbdbb114c81e1bdc862df27fce8beab557d7b0421820b0fe8fc048f -F autoconf/auto.def 1d740e01d05d34140f0f403201fe625eb6469efb9b5645f068dc6b38cb005c9a -F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277 +F autoconf/README.first f1d3876e9a7852c22f275a6f06814e64934cecbc0b5b9617d64849094c1fd136 +F autoconf/README.txt 7f01dc3915e2d68f329011073662369e62a0938a2c69398807823c57591cb288 +F autoconf/auto.def 623e0d2339cbccc86b1c5e58d65702dc91a9fec4843a4c6198139e248579858e F autoconf/tea/Makefile.in ba0556fee8da09c066bad85a4457904e46ee2c2eabaa309c0e83a78f2f151a8e F autoconf/tea/README.txt 61e62e519579e4a112791354d6d440f8b51ea6db3b0bab58d59f29df42d2dfe3 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -2209,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 16fa20413e3f3f0b6ea5d97022945843d1f785ac0142836f2a3651fd1917385f -R 530ea71496225522d46777a9a2bdcaa9 +P 25b01f1c9a5e606441bfd4e729fb88361436dffc76ef7a10c04a4d4ad0bcc655 +R 3def29cc56a0bda1ef86cab9a156aa58 U stephan -Z fe186d8bfdcab6314981338fcde5c9d6 +Z 97ba8d81293efc855c346a0339493c53 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b94a093c93..a7c2090ea7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -25b01f1c9a5e606441bfd4e729fb88361436dffc76ef7a10c04a4d4ad0bcc655 +646667af8ca2140d823facf4578105c3d9815ea34b2a4cb96103c2fe7d718229 From 2e899ccaff0baca5cd6db7e8a24be8728c97a371 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 21 Jan 2025 15:12:00 +0000 Subject: [PATCH 043/115] The FuncDev.nArg field values -3 and -4 now have special meansing of 1 or more or 2 or more arguments, respectively. This saves space in the built-in function table, resulting in slightly faster performance and a reduced binary size. FossilOrigin-Name: 753fd747f24c5e9a019eb00b8a4f66e65c6733ba10a7adbd1b55786867c32ca6 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/callback.c | 10 ++++++++-- src/func.c | 17 +++++------------ 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index b6bbc0b68f..b6f6b78089 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sfts5\sbetter\shandle\sOOM\serrors\sfrom\ssqlite3_blob_close(). -D 2025-01-21T14:34:59.118 +C The\sFuncDev.nArg\sfield\svalues\s-3\sand\s-4\snow\shave\sspecial\smeansing\sof\s1\sor\smore\nor\s2\sor\smore\sarguments,\srespectively.\s\sThis\ssaves\sspace\sin\sthe\sbuilt-in\nfunction\stable,\sresulting\sin\sslightly\sfaster\sperformance\sand\sa\sreduced\sbinary\nsize. +D 2025-01-21T15:12:00.408 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -722,7 +722,7 @@ F src/btree.c 63ca6b647342e8cef643863cd0962a542f133e1069460725ba4461dcda92b03c F src/btree.h 18e5e7b2124c23426a283523e5f31a4bff029131b795bb82391f9d2f3136fc50 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 F src/build.c c6b09342d870a509529244ed8e19b4175a261f2e3163c199241d69e1d8a57607 -F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 +F src/callback.c acae8c8dddda41ee85cfdf19b926eefe830f371069f8aadca3aa39adf5b1c859 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c d35723024b963edce9c0fad5b3303e8bb9266083784844baed10a6dedfe26f3b F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a @@ -732,7 +732,7 @@ F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 30a407765d4e4b592f9f958085fb4e8336e54fa46a70ade7f5a67111bc191563 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f -F src/func.c 89b733a5f513c4bc06b7271384363d5693d62782de8295bc87b97d79862c9714 +F src/func.c 30051410d0379059e1e3642ffc0caae6963a2b01b3b6d9dd44c5e09b1a66d066 F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a8d9dcfd23fbfcd887e451382836c1e88215984cc01e00be11387dbf4ab26fd8 -R 0ff09c4d1a6df4a00a8ce3e62a42f2fa -U dan -Z dbb8340d556717da4724fb10b820bbe7 +P f418350f3f83147bc5817a885be6e39ff9ff5722742a88d17600729c53c65010 +R 214f345108f048affd4b7abd9f2ea035 +U drh +Z b46d6184b5d599a41424bec3e41b4c80 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 07c5f158d9..bad8235170 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f418350f3f83147bc5817a885be6e39ff9ff5722742a88d17600729c53c65010 +753fd747f24c5e9a019eb00b8a4f66e65c6733ba10a7adbd1b55786867c32ca6 diff --git a/src/callback.c b/src/callback.c index c36d51a4ec..6fe21a2956 100644 --- a/src/callback.c +++ b/src/callback.c @@ -302,12 +302,18 @@ static int matchQuality( u8 enc /* Desired text encoding */ ){ int match; - assert( p->nArg>=-1 ); + assert( p->nArg>=(-4) && p->nArg!=(-2) ); + assert( nArg>=(-2) ); /* Wrong number of arguments means "no match" */ if( p->nArg!=nArg ){ - if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH; + if( nArg==(-2) ) return p->xSFunc==0 ? 0 : FUNC_PERFECT_MATCH; if( p->nArg>=0 ) return 0; + /* Special p->nArg values available to built-in functions only: + ** -3 1 or more arguments required + ** -4 2 or more arguments required + */ + if( p->nArg<(-2) && nArg<(-2-p->nArg) ) return 0; } /* Give a better score to a function with a specific number of arguments diff --git a/src/func.c b/src/func.c index 7a4774527d..2bd4be31ca 100644 --- a/src/func.c +++ b/src/func.c @@ -2695,12 +2695,10 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(rtrim, 2, 2, 0, trimFunc ), FUNCTION(trim, 1, 3, 0, trimFunc ), FUNCTION(trim, 2, 3, 0, trimFunc ), - FUNCTION(min, -1, 0, 1, minmaxFunc ), - FUNCTION(min, 0, 0, 1, 0 ), + FUNCTION(min, -3, 0, 1, minmaxFunc ), WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), - FUNCTION(max, -1, 1, 1, minmaxFunc ), - FUNCTION(max, 0, 1, 1, 0 ), + FUNCTION(max, -3, 1, 1, minmaxFunc ), WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF), @@ -2727,11 +2725,8 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(hex, 1, 0, 0, hexFunc ), FUNCTION(unhex, 1, 0, 0, unhexFunc ), FUNCTION(unhex, 2, 0, 0, unhexFunc ), - FUNCTION(concat, -1, 0, 0, concatFunc ), - FUNCTION(concat, 0, 0, 0, 0 ), - FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ), - FUNCTION(concat_ws, 0, 0, 0, 0 ), - FUNCTION(concat_ws, 1, 0, 0, 0 ), + FUNCTION(concat, -3, 0, 0, concatFunc ), + FUNCTION(concat_ws, -4, 0, 0, concatwsFunc ), INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), VFUNCTION(random, 0, 0, 0, randomFunc ), VFUNCTION(randomblob, 1, 0, 0, randomBlob ), @@ -2775,8 +2770,6 @@ void sqlite3RegisterBuiltinFunctions(void){ #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION FUNCTION(unknown, -1, 0, 0, unknownFunc ), #endif - FUNCTION(coalesce, 1, 0, 0, 0 ), - FUNCTION(coalesce, 0, 0, 0, 0 ), #ifdef SQLITE_ENABLE_MATH_FUNCTIONS MFUNCTION(ceil, 1, xCeil, ceilingFunc ), MFUNCTION(ceiling, 1, xCeil, ceilingFunc ), @@ -2814,7 +2807,7 @@ void sqlite3RegisterBuiltinFunctions(void){ MFUNCTION(pi, 0, 0, piFunc ), #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ FUNCTION(sign, 1, 0, 0, signFunc ), - INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ), + INLINE_FUNC(coalesce, -4, INLINEFUNC_coalesce, 0 ), INLINE_FUNC(iif, 2, INLINEFUNC_iif, 0 ), INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ), INLINE_FUNC(if, 2, INLINEFUNC_iif, 0 ), From a6b62a26d49d952f0d64efc8562a68dc287e4cb6 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 21 Jan 2025 15:45:03 +0000 Subject: [PATCH 044/115] Explain the lack of docs in autoconf/Makefile.in and refer interested readers to main.mk in canonical tree. Minor cleanups and fixes in tool/mkautoconfamal.sh. FossilOrigin-Name: e5bbc2428f1000a451c1b4afd287742b9896a1a6c82d9706c6b8e7d6fb3b1e44 --- autoconf/Makefile.in | 5 ++++- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/mkautoconfamal.sh | 30 ++++++++++++++---------------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/autoconf/Makefile.in b/autoconf/Makefile.in index d43300c829..0c97f16321 100644 --- a/autoconf/Makefile.in +++ b/autoconf/Makefile.in @@ -1,5 +1,8 @@ ######################################################################## -# This is a main makefile for the "autoconf" bundle of SQLite. +# This is a main makefile for the "autoconf" bundle of SQLite. This is +# a trimmed-down version of the canonical makefile, devoid of most +# documentation. For the full docs, see 'main.mk' in the canonical +# source tree. all: TOP = @abs_top_srcdir@ diff --git a/manifest b/manifest index f787520fce..6bd9ed83f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\snow-extraneous\sautoconf/INSTALL\sand\sautoconf/configure.ac\sand\supdate\sautoconf/README.*\sto\saccount\sfor\sthe\sport\sto\sautosetup. -D 2025-01-21T14:40:35.953 +C Explain\sthe\slack\sof\sdocs\sin\sautoconf/Makefile.in\sand\srefer\sinterested\sreaders\sto\smain.mk\sin\scanonical\stree.\sMinor\scleanups\sand\sfixes\sin\stool/mkautoconfamal.sh. +D 2025-01-21T15:45:03.498 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -16,7 +16,7 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 F auto.def 7833c0a8630dd3a3410dcc6c8b4d1b63f25d03d6497267624b8a37aba119cb3e F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac -F autoconf/Makefile.in 330a4f6a43ed3076c6e2e0627b17091a1fb1c8ab136fcc46048d6f1662f8f0d8 +F autoconf/Makefile.in 56697ad25ecf23afa317148b06bdc14f85960b42e5ec434ac1ba87f63a3cb789 F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 F autoconf/README.first f1d3876e9a7852c22f275a6f06814e64934cecbc0b5b9617d64849094c1fd136 F autoconf/README.txt 7f01dc3915e2d68f329011073662369e62a0938a2c69398807823c57591cb288 @@ -2142,7 +2142,7 @@ F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669 F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176 F tool/mkamalzip.tcl 8aa5ebe7973c8b8774062d34e15fea9815c4cc2ceea3a9b184695f005910876a -F tool/mkautoconfamal.sh de0dd50c6c5899330bb1f9c9fcaf71e8fbede3229034839cafc1e8485c5e827d +F tool/mkautoconfamal.sh 67e14ee5d0c6d8e83bca19807c4761ab3a22e14c8bf5f3bdc56989674770c25e F tool/mkccode.tcl 210159febe0ef0ecbc53c79833500663ceaba0115b2b374405818dc835b5f84b x F tool/mkctimec.tcl ef6a67ec82e5b6fc19152a4c79f237227b18bf67ff16d155bac7adb94355d9cf x F tool/mkkeywordhash.c 6b0be901c47f9ad42215fc995eb2f4384ac49213b1fba395102ec3e999acf559 @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 25b01f1c9a5e606441bfd4e729fb88361436dffc76ef7a10c04a4d4ad0bcc655 -R 3def29cc56a0bda1ef86cab9a156aa58 +P 646667af8ca2140d823facf4578105c3d9815ea34b2a4cb96103c2fe7d718229 +R 9bbf87fd9926eb3023e4de6818e02af4 U stephan -Z 97ba8d81293efc855c346a0339493c53 +Z c74dae274099c477daebfdd70dd618de # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a7c2090ea7..0adcfc52ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -646667af8ca2140d823facf4578105c3d9815ea34b2a4cb96103c2fe7d718229 +e5bbc2428f1000a451c1b4afd287742b9896a1a6c82d9706c6b8e7d6fb3b1e44 diff --git a/tool/mkautoconfamal.sh b/tool/mkautoconfamal.sh index 5c96b26c64..0771d5bf84 100644 --- a/tool/mkautoconfamal.sh +++ b/tool/mkautoconfamal.sh @@ -23,7 +23,7 @@ set -u TMPSPACE=./mkpkg_tmp_dir VERSION=`cat $TOP/VERSION` HASH=`cut -c1-10 $TOP/manifest.uuid` -DATETIME=`grep '^D' $TOP/manifest | cut -c3- | tr -c -d '[0-9]'` +DATETIME=`grep '^D' $TOP/manifest | tr -c -d '[0-9]' | cut -c1-12` # Verify that the version number in the TEA autoconf file is correct. # Fail with an error if not. @@ -69,24 +69,22 @@ cp $TOP/VERSION $TMPSPACE cp $TOP/main.mk $TMPSPACE cd $TMPSPACE -#autoreconf -i -#libtoolize -#aclocal -#autoconf -#automake --add-missing -# This bit is only for use during porting of the -# autoconf bundle to autosetup. -if true; then - find . -name '*~' -exec rm \{} \; -fi +#if true; then + # Clean up *~ files (emacs-generated backups). + # This bit is only for use during development of + # the autoconf bundle. +# find . -name '*~' -exec rm \{} \; +#fi mkdir -p tea/generic -echo "#ifdef USE_SYSTEM_SQLITE" > tea/generic/tclsqlite3.c -echo "# include " >> tea/generic/tclsqlite3.c -echo "#else" >> tea/generic/tclsqlite3.c -echo "#include \"sqlite3.c\"" >> tea/generic/tclsqlite3.c -echo "#endif" >> tea/generic/tclsqlite3.c +cat < tea/generic/tclsqlite3.c +#ifdef USE_SYSTEM_SQLITE +# include +#else +# include "sqlite3.c" +#endif +EOF cat $TOP/src/tclsqlite.c >> tea/generic/tclsqlite3.c sed "s/AC_INIT(\[sqlite\], .*)/AC_INIT([sqlite], [$VERSION])/" tea/configure.ac > tmp From 8e7a16895c62f8c56e8ada82cecdacaf1e97fcd3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 21 Jan 2025 16:30:55 +0000 Subject: [PATCH 045/115] Performance improvements to the (debug-use only) Mem.pScopyFrom logic, resulting in about 8x faster performance under -DSQLITE_DEBUG for the query in from [forum:/forumpost/0025389d0860af82|forum post 0025389d0860af82]. This change only affects builds that use -DSQLITE_DEBUG. FossilOrigin-Name: 7fb1ae25d1572dd7709a0f850c148a5f745a524f01ea231e29a1ebc37c173fb9 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/vdbe.c | 3 +++ src/vdbeInt.h | 1 + src/vdbeapi.c | 1 + src/vdbeaux.c | 1 + src/vdbemem.c | 41 ++++++++++++++++++++++------------------- 7 files changed, 39 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index b6f6b78089..b9e1cd0b1e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sFuncDev.nArg\sfield\svalues\s-3\sand\s-4\snow\shave\sspecial\smeansing\sof\s1\sor\smore\nor\s2\sor\smore\sarguments,\srespectively.\s\sThis\ssaves\sspace\sin\sthe\sbuilt-in\nfunction\stable,\sresulting\sin\sslightly\sfaster\sperformance\sand\sa\sreduced\sbinary\nsize. -D 2025-01-21T15:12:00.408 +C Performance\simprovements\sto\sthe\s(debug-use\sonly)\sMem.pScopyFrom\slogic,\sresulting\nin\sabout\s8x\sfaster\sperformance\sunder\s-DSQLITE_DEBUG\sfor\sthe\squery\sin\sfrom\n[forum:/forumpost/0025389d0860af82|forum\spost\s0025389d0860af82].\s\sThis\schange\nonly\saffects\sbuilds\sthat\suse\s-DSQLITE_DEBUG. +D 2025-01-21T16:30:55.694 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -848,13 +848,13 @@ F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c 8b29d9a5956569ea2700f869669b8ef67a9662ee5e724ff77ab3c387e27094ba F src/util.c e5f6a5eeaa26b69054a43bbd0048cfe3d2851f6961052b35aed8f695df922850 F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 -F src/vdbe.c 8a6eb02823b424b273614bae41579392a5c495424592b60423dd2c443a583df0 +F src/vdbe.c b428a751953c0c2ff85e3e152ec16e29d488895cd541c8c20876ff9f3bf6978a F src/vdbe.h 9676348d342bd04e21e384c63b57224171ce84fac77853357334ef94c4d33cf4 -F src/vdbeInt.h bf294a0c8fc4cc80779e74b04b8bd82c6e1197b3137cefe0b16cdf002fc7dfd6 -F src/vdbeapi.c 033decc098df353b97a5ca14302ad812e2567f1037747c2d5fcda62aac1bb74e -F src/vdbeaux.c 5fcbc642a3d3d88c5ea15cadf2c8b8e4e067cb9ff374beb1875c9d209001299e +F src/vdbeInt.h 895b1ab7536f018d3d70d690f6c0adbd1062b6dddce1c2cad912927856d4033c +F src/vdbeapi.c 76fa76b21f46afc70e71ecd69954f601e9b80b5fb0c1eb7ace06d30802255768 +F src/vdbeaux.c 885e16100597507fbbe09d82cbb963bff3fd8a9c1e358dc4f463fc95feb18e8b F src/vdbeblob.c 255be187436da38b01f276c02e6a08103489bbe2a7c6c21537b7aecbe0e1f797 -F src/vdbemem.c df568ef0187e4be2788c35174f6d9b8566ab9475f9aff2d73907ed05aa5684b2 +F src/vdbemem.c 977438546df236c6a3e7d8b4fe86c0643c13b89b00235db1f11c3a91a4796d30 F src/vdbesort.c d0a3c7056c081703c8b6d91ad60f17da5e062a5c64bf568ed0fa1b5f4cae311f F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f418350f3f83147bc5817a885be6e39ff9ff5722742a88d17600729c53c65010 -R 214f345108f048affd4b7abd9f2ea035 +P 753fd747f24c5e9a019eb00b8a4f66e65c6733ba10a7adbd1b55786867c32ca6 +R f2e8145ad0d67966271c1c923a7301c7 U drh -Z b46d6184b5d599a41424bec3e41b4c80 +Z 86ef734f24e1aa297cb586202f4cb17a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bad8235170..14622345fc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -753fd747f24c5e9a019eb00b8a4f66e65c6733ba10a7adbd1b55786867c32ca6 +7fb1ae25d1572dd7709a0f850c148a5f745a524f01ea231e29a1ebc37c173fb9 diff --git a/src/vdbe.c b/src/vdbe.c index 558970ed95..d41ac8d517 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -607,6 +607,7 @@ static void registerTrace(int iReg, Mem *p){ printf("R[%d] = ", iReg); memTracePrint(p); if( p->pScopyFrom ){ + assert( p->pScopyFrom->bScopy ); printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg])); } printf("\n"); @@ -1590,6 +1591,7 @@ case OP_Move: { { int i; for(i=1; inMem; i++){ if( aMem[i].pScopyFrom==pIn1 ){ + assert( aMem[i].bScopy ); aMem[i].pScopyFrom = pOut; } } @@ -1662,6 +1664,7 @@ case OP_SCopy: { /* out2 */ #ifdef SQLITE_DEBUG pOut->pScopyFrom = pIn1; pOut->mScopyFlags = pIn1->flags; + pIn1->bScopy = 1; #endif break; } diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 2cb4f8c2a1..24cf1ac56c 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -244,6 +244,7 @@ struct sqlite3_value { #ifdef SQLITE_DEBUG Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */ u16 mScopyFlags; /* flags value immediately after the shallow copy */ + u8 bScopy; /* The pScopyFrom of some other Mem *might* point here */ #endif }; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 5fc04b139c..113b8a9c04 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1294,6 +1294,7 @@ static const Mem *columnNullValue(void){ #ifdef SQLITE_DEBUG /* .pScopyFrom = */ (Mem*)0, /* .mScopyFlags= */ 0, + /* .bScopy = */ 0, #endif }; return &nullMem; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index b9e8b3cdf8..81dca10f02 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2152,6 +2152,7 @@ static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){ p->szMalloc = 0; #ifdef SQLITE_DEBUG p->pScopyFrom = 0; + p->bScopy = 0; #endif p++; }while( (--N)>0 ); diff --git a/src/vdbemem.c b/src/vdbemem.c index 0fc6b68f5e..38ba5abe80 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1046,27 +1046,30 @@ int sqlite3VdbeMemTooBig(Mem *p){ void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){ int i; Mem *pX; - for(i=1, pX=pVdbe->aMem+1; inMem; i++, pX++){ - if( pX->pScopyFrom==pMem ){ - u16 mFlags; - if( pVdbe->db->flags & SQLITE_VdbeTrace ){ - sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n", - (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem)); + if( pMem->bScopy ){ + for(i=1, pX=pVdbe->aMem+1; inMem; i++, pX++){ + if( pX->pScopyFrom==pMem ){ + u16 mFlags; + if( pVdbe->db->flags & SQLITE_VdbeTrace ){ + sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n", + (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem)); + } + /* If pX is marked as a shallow copy of pMem, then try to verify that + ** no significant changes have been made to pX since the OP_SCopy. + ** A significant change would indicated a missed call to this + ** function for pX. Minor changes, such as adding or removing a + ** dual type, are allowed, as long as the underlying value is the + ** same. */ + mFlags = pMem->flags & pX->flags & pX->mScopyFlags; + assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i ); + + /* pMem is the register that is changing. But also mark pX as + ** undefined so that we can quickly detect the shallow-copy error */ + pX->flags = MEM_Undefined; + pX->pScopyFrom = 0; } - /* If pX is marked as a shallow copy of pMem, then try to verify that - ** no significant changes have been made to pX since the OP_SCopy. - ** A significant change would indicated a missed call to this - ** function for pX. Minor changes, such as adding or removing a - ** dual type, are allowed, as long as the underlying value is the - ** same. */ - mFlags = pMem->flags & pX->flags & pX->mScopyFlags; - assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i ); - - /* pMem is the register that is changing. But also mark pX as - ** undefined so that we can quickly detect the shallow-copy error */ - pX->flags = MEM_Undefined; - pX->pScopyFrom = 0; } + pMem->bScopy = 0; } pMem->pScopyFrom = 0; } From 255548562b125e6c148bb27d49aaa01b2fe61dba Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 21 Jan 2025 17:37:58 +0000 Subject: [PATCH 046/115] Fix date/time computations to deal with the sub-millisecond rounding problem identified in [forum:/forumpost/766a2c9231|forum post 766a2c9231]. FossilOrigin-Name: afb0a5923a6db4045fab5226198aab970d746d4866294ebba943c6986e97ecde --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/date.c | 5 ++++- test/date.test | 8 ++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b9e1cd0b1e..2ab7b29c59 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\simprovements\sto\sthe\s(debug-use\sonly)\sMem.pScopyFrom\slogic,\sresulting\nin\sabout\s8x\sfaster\sperformance\sunder\s-DSQLITE_DEBUG\sfor\sthe\squery\sin\sfrom\n[forum:/forumpost/0025389d0860af82|forum\spost\s0025389d0860af82].\s\sThis\schange\nonly\saffects\sbuilds\sthat\suse\s-DSQLITE_DEBUG. -D 2025-01-21T16:30:55.694 +C Fix\sdate/time\scomputations\sto\sdeal\swith\sthe\ssub-millisecond\srounding\nproblem\sidentified\sin\s[forum:/forumpost/766a2c9231|forum\spost\s766a2c9231]. +D 2025-01-21T17:37:58.001 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -725,7 +725,7 @@ F src/build.c c6b09342d870a509529244ed8e19b4175a261f2e3163c199241d69e1d8a57607 F src/callback.c acae8c8dddda41ee85cfdf19b926eefe830f371069f8aadca3aa39adf5b1c859 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c d35723024b963edce9c0fad5b3303e8bb9266083784844baed10a6dedfe26f3b -F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a +F src/date.c 842c08ac143a56a627b05ac51d68624f2b7b03e3b4cba596205e735eed64ee57 F src/dbpage.c e90410e5d4c0217dfddc4184a81e38ec4903c25d4ec0f201060a0e54e7c2099f F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 @@ -1068,7 +1068,7 @@ F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c47 F test/cursorhint.test 05cf0febe5c5f8a31f199401fd1c9322249e753950d55f26f9d5aca61408a270 F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8 -F test/date.test c8ff835023f2107b57ce7a45c92265d51c98a23fc93231e998f12d850831aad6 +F test/date.test 8911c3d9fb0e496e92e0259697f431a00707222d2b3438ce1105d1790a3c0d51 F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1 F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5 F test/date4.test 75dc8401e8c0639a228cd26a6eaa4ff5ea8ccda912b9853d1c9462c476670e17 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 753fd747f24c5e9a019eb00b8a4f66e65c6733ba10a7adbd1b55786867c32ca6 -R f2e8145ad0d67966271c1c923a7301c7 +P 7fb1ae25d1572dd7709a0f850c148a5f745a524f01ea231e29a1ebc37c173fb9 +R b5ed3ff5cc6ba0a7bea1d83d8e8c82a9 U drh -Z 86ef734f24e1aa297cb586202f4cb17a +Z a3888b28f8eea48eee70a7de9cd84dd2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 14622345fc..a04023f095 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7fb1ae25d1572dd7709a0f850c148a5f745a524f01ea231e29a1ebc37c173fb9 +afb0a5923a6db4045fab5226198aab970d746d4866294ebba943c6986e97ecde diff --git a/src/date.c b/src/date.c index 8c48a81fa5..de27366370 100644 --- a/src/date.c +++ b/src/date.c @@ -222,6 +222,9 @@ static int parseHhMmSs(const char *zDate, DateTime *p){ zDate++; } ms /= rScale; + /* Truncate to avoid problems with sub-milliseconds + ** rounding. https://sqlite.org/forum/forumpost/766a2c9231 */ + if( ms>0.999 ) ms = 0.999; } }else{ s = 0; @@ -1429,7 +1432,7 @@ static void strftimeFunc( } case 'f': { /* Fractional seconds. (Non-standard) */ double s = x.s; - if( s>59.999 ) s = 59.999; + if( NEVER(s>59.999) ) s = 59.999; sqlite3_str_appendf(&sRes, "%06.3f", s); break; } diff --git a/test/date.test b/test/date.test index d22b652b47..2042880a92 100644 --- a/test/date.test +++ b/test/date.test @@ -651,5 +651,13 @@ datetest 19.51 {date('2000-08-31','+0022-06-00','floor')} {2023-02-28} datetest 19.52 {date('2000-08-31','+0023-06-00','ceiling')} {2024-03-02} datetest 19.53 {date('2000-08-31','+0022-06-00','ceiling')} {2023-03-03} +# 2025-01-21 +# https://sqlite.org/forum/forumpost/766a2c9231 +# +datetest 20.1 {datetime('2024-12-31 23:59:59.9990')} {2024-12-31 23:59:59} +datetest 20.2 {datetime('2024-12-31 23:59:59.9999999999999')} \ + {2024-12-31 23:59:59} +datetest 20.3 {datetime('2024-12-31 23:59:59.9995')} {2024-12-31 23:59:59} +datetest 20.4 {datetime('2024-12-31 23:59:58.9995')} {2024-12-31 23:59:58} finish_test From 9489aefb83fd72aa64fafe6a98617af9dfdcc538 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 22 Jan 2025 17:18:53 +0000 Subject: [PATCH 047/115] Add the -q/--quiet option to test/speedtest.tcl. Automatically enable -DSQLITE_OMIT_LOAD_EXTENSION and -DSQLITE_THREADSAFE=0 so that no extra libraries are required. FossilOrigin-Name: c20d21b473d8a45267262c5df1d7b102eccce8e4cfbe1e467ea66c474aea0af5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest.tcl | 13 +++++++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2ab7b29c59..7b86302386 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sdate/time\scomputations\sto\sdeal\swith\sthe\ssub-millisecond\srounding\nproblem\sidentified\sin\s[forum:/forumpost/766a2c9231|forum\spost\s766a2c9231]. -D 2025-01-21T17:37:58.001 +C Add\sthe\s-q/--quiet\soption\sto\stest/speedtest.tcl.\s\sAutomatically\senable\n-DSQLITE_OMIT_LOAD_EXTENSION\sand\s-DSQLITE_THREADSAFE=0\sso\sthat\sno\sextra\nlibraries\sare\srequired. +D 2025-01-22T17:18:53.134 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1679,7 +1679,7 @@ F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c F test/speedtest.md e4f467683acfdb2834ca1d6ce209c3d883dfecf73c41f77234b2368be9579de2 -F test/speedtest.tcl 96052cb8c5d44f69e0600e690794557f176ef99bd87cb4360080982d1f479a70 x +F test/speedtest.tcl 8a9362c1e429318e741b91d26888e7edcc326f98c3aea505ffd618cc5b9e7f0a x F test/speedtest1.c 323ce0956430a5aae56ea20f502da7bea3fb62b8ed02e9b0f12ab078b2b258f5 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7fb1ae25d1572dd7709a0f850c148a5f745a524f01ea231e29a1ebc37c173fb9 -R b5ed3ff5cc6ba0a7bea1d83d8e8c82a9 +P afb0a5923a6db4045fab5226198aab970d746d4866294ebba943c6986e97ecde +R 9d6f6255d4d3d13ac3e7250fb9209015 U drh -Z a3888b28f8eea48eee70a7de9cd84dd2 +Z 359fbb7e57428de2830f61ee25224064 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a04023f095..ad960cacc6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -afb0a5923a6db4045fab5226198aab970d746d4866294ebba943c6986e97ecde +c20d21b473d8a45267262c5df1d7b102eccce8e4cfbe1e467ea66c474aea0af5 diff --git a/test/speedtest.tcl b/test/speedtest.tcl index b353077e7c..93b407c94e 100755 --- a/test/speedtest.tcl +++ b/test/speedtest.tcl @@ -26,6 +26,7 @@ Other options include: --lean "Lean" mode. --lookaside N SZ Lookahead uses N slots of SZ bytes each. --pagesize N Use N as the page size. + --quiet | -q "Quite". Put results in file but don't pop up editor --testset TEST Specify the specific testset to use. The default is "mix1". Other options include: "main", "json", "cte", "orm", "fp", "rtree". @@ -33,10 +34,11 @@ Other options include: set srcfile {} set outfile {} set difffile {} -set cflags {} +set cflags {-DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_THREADSAFE=0} set cc gcc set testset mix1 set dryrun 0 +set quiet 0 set speedtestflags {--shrink-memory --reprepare --stats --heap 40000000 64} lappend speedtestflags --journal wal --size 5 @@ -87,6 +89,11 @@ for {set i 0} {$i<[llength $argv]} {incr i} { puts $usage exit 0 } + -q - + -quiet - + --quiet { + set quiet 1 + } default { lappend cflags $arg } @@ -265,7 +272,9 @@ exec size speedtest1 >>$outfile # Processed cachegrind output should now be in the $outfile ############################################################################# -if {$difffile!=""} { +if {$quiet} { + # Skip this last part of popping up a GUI viewer +} elseif {$difffile!=""} { set fossilcmd {fossil xdiff --tk -c 20} lappend fossilcmd $difffile lappend fossilcmd $outfile From c850c2be757ffbf11423b47f8ef94bd0ce20f048 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 22 Jan 2025 19:37:47 +0000 Subject: [PATCH 048/115] Add two new sqlite3_db_config() options that enable the ATTACH command to create new database files and to open databases read/write. Both default to on for backwards compatibility. FossilOrigin-Name: fe0c58d00b491d1af7c0894f5c32542954aeea2e6510853b3bcbf13ac0bf5ce0 --- manifest | 23 +++++++++++++---------- manifest.uuid | 2 +- src/attach.c | 6 ++++++ src/main.c | 6 +++++- src/shell.c.in | 2 ++ src/sqlite.h.in | 39 ++++++++++++++++++++++++++++++++++++++- src/sqliteInt.h | 2 ++ 7 files changed, 67 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 7b86302386..7527c1a3fb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s-q/--quiet\soption\sto\stest/speedtest.tcl.\s\sAutomatically\senable\n-DSQLITE_OMIT_LOAD_EXTENSION\sand\s-DSQLITE_THREADSAFE=0\sso\sthat\sno\sextra\nlibraries\sare\srequired. -D 2025-01-22T17:18:53.134 +C Add\stwo\snew\ssqlite3_db_config()\soptions\sthat\senable\sthe\sATTACH\scommand\nto\screate\snew\sdatabase\sfiles\sand\sto\sopen\sdatabases\sread/write.\s\sBoth\ndefault\sto\son\sfor\sbackwards\scompatibility. +D 2025-01-22T19:37:47.938 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -713,7 +713,7 @@ F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc F sqlite3.pc.in 0977c03a4da7c4204bd60e784a0efb8d51a190448aba78a4e973fe7192bdaf03 F src/alter.c aa93e37e4a36a0525bbb2a2aeda20d2018f0aa995542c7dc658e031375e3f532 F src/analyze.c 9a8b67239d899ac12289db5db3f5bfe7f7a0ad1277f80f87ead1d048085876eb -F src/attach.c f35bb8cc1fcdde8f6815a7ef09ae413bcac71821d530796800ba24b3c7da1e80 +F src/attach.c 3a5cb9ee4aad6c5b22268287340a4f2f7b07959b7a522201be30fee23cd802e9 F src/auth.c 54ab9c6c5803b47c0d45b76ce27eff22a03b4b1f767c5945a3a4eb13aa4c78dc F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523 F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645 @@ -742,7 +742,7 @@ F src/insert.c f8d1a0f8ee258411009c6b7f2d93170e351bd19f5ad89d57e1180644297cbe70 F src/json.c 68a98c020c22127f2d65f08855f7fc7460ff352a6ce0b543d8931dde83319c22 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c a19dc8b47760ed95f3fbb255cfa8d3f7146b33c263eb4af05ab05e0115d161b9 +F src/main.c 84239c53aaac3aa1734eaf33a41d575c1d2494313bd8af5e6d885f0dc0547cfd F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -780,11 +780,11 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 83e88fbb36f89b6703b348777491619554f0fd6f917c9fdf51e4c2e9cda6c04e -F src/shell.c.in 9ade75afa953c5c2ded38d076533eaa6c9b2ab1977ef6cce0bc773adac178c50 -F src/sqlite.h.in 6afbcaae44140216704a6c82e4c4ea4118c46d5f6573d6c5fa4fc901ed9d369e +F src/shell.c.in 9915487b27e3169d59a4018c88d14246059c392c662d98fc516264267396b65e +F src/sqlite.h.in 666fa171bf5a9fa532b637571303a596c80723e89f3e10962c0d81378b2b789d F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 953f2476f712b115ecb43f7a21183d07c88af8d3b4c32f18317724ce1ce04d56 +F src/sqliteInt.h dd2385d05fbc892d865296fa3f493ba132044a2bbbd15bfad67984bb4afba1d3 F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2208,8 +2208,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P afb0a5923a6db4045fab5226198aab970d746d4866294ebba943c6986e97ecde -R 9d6f6255d4d3d13ac3e7250fb9209015 +P c20d21b473d8a45267262c5df1d7b102eccce8e4cfbe1e467ea66c474aea0af5 +R 1e3a803f41f6c1dff31eede2c9428a7d +T *branch * enable-attach +T *sym-enable-attach * +T -sym-trunk * U drh -Z 359fbb7e57428de2830f61ee25224064 +Z 45431d003e2c2a4fccdcefe1b482f2e1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ad960cacc6..4aa4c3121f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c20d21b473d8a45267262c5df1d7b102eccce8e4cfbe1e467ea66c474aea0af5 +fe0c58d00b491d1af7c0894f5c32542954aeea2e6510853b3bcbf13ac0bf5ce0 diff --git a/src/attach.c b/src/attach.c index 9f23dce1ed..399a6cb537 100644 --- a/src/attach.c +++ b/src/attach.c @@ -175,6 +175,12 @@ static void attachFunc( sqlite3_free(zErr); return; } + if( (db->flags & SQLITE_AttachWrite)==0 ){ + flags &= ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE); + flags |= SQLITE_OPEN_READONLY; + }else if( (db->flags & SQLITE_AttachCreate)==0 ){ + flags &= ~SQLITE_OPEN_CREATE; + } assert( pVfs ); flags |= SQLITE_OPEN_MAIN_DB; rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags); diff --git a/src/main.c b/src/main.c index 1163deb6e3..943478d6da 100644 --- a/src/main.c +++ b/src/main.c @@ -959,7 +959,7 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){ default: { static const struct { int op; /* The opcode */ - u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */ + u64 mask; /* Mask of the bit in sqlite3.flags to set/clear */ } aFlagOp[] = { { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys }, { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger }, @@ -980,6 +980,8 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){ { SQLITE_DBCONFIG_TRUSTED_SCHEMA, SQLITE_TrustedSchema }, { SQLITE_DBCONFIG_STMT_SCANSTATUS, SQLITE_StmtScanStatus }, { SQLITE_DBCONFIG_REVERSE_SCANORDER, SQLITE_ReverseOrder }, + { SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE, SQLITE_AttachCreate }, + { SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, SQLITE_AttachWrite }, }; unsigned int i; rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ @@ -3321,6 +3323,8 @@ static int openDatabase( | SQLITE_EnableTrigger | SQLITE_EnableView | SQLITE_CacheSpill + | SQLITE_AttachCreate + | SQLITE_AttachWrite #if !defined(SQLITE_TRUSTED_SCHEMA) || SQLITE_TRUSTED_SCHEMA+0!=0 | SQLITE_TrustedSchema #endif diff --git a/src/shell.c.in b/src/shell.c.in index d7a0bf55b3..be6508fb1f 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8725,6 +8725,8 @@ static int do_meta_command(char *zLine, ShellState *p){ const char *zName; int op; } aDbConfig[] = { + { "attach_create", SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE }, + { "attach_write", SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE }, { "defensive", SQLITE_DBCONFIG_DEFENSIVE }, { "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL }, { "dqs_dml", SQLITE_DBCONFIG_DQS_DML }, diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9a117fa54e..46336bf3e7 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2523,6 +2523,41 @@ struct sqlite3_mem_methods { ** first argument. ** ** +** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]] +**
SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE
+**
The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables the ability +** of the [ATTACH DATABASE] SQL command to create a new database if the +** database filed named by the SQL command does not already exist. This +** ability of [ATTACH] to create a new database is enabled by default, but +** can be disabled, using the current DBCONFIG option if desired. +** This option takes two arguments which are an integer and a pointer +** to an integer. The first argument is 1, 0, or -1 to enable, disable, or +** leave unchanged the attach-create flag, respectively. If the second +** argument is not NULL, then 0 or 1 is written into the integer that the +** second argument points to depending on if the attach-create flag is set +** after processing the first argument. +**
+** +** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]] +**
SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE
+**
The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables the ability +** of the [ATTACH DATABASE] SQL command to create a new database that is +** open for writing. This capability is enabled by default, but +** can be disabled, using the current DBCONFIG option if desired. If this +** capability is disabled, the [ATTACH] command will still work, but the +** database is opened read-only. If this option is disabled, then the +** ability to create a new database using [ATTACH] is also disabled, +** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE] +** option. +** This option takes two arguments which are an integer and a pointer +** to an integer. The first argument is 1, 0, or -1 to enable, disable, or +** leave unchanged the ability to ATTACH another database for writing, +** respectively. If the second argument is not NULL, then 0 or 1 is written +** into the integer that the second argument points to depending on if the +** ability to ATTACH a read/write database is set +** after processing the first argument. +**
+** ** */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ @@ -2545,7 +2580,9 @@ struct sqlite3_mem_methods { #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */ #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */ #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */ -#define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */ +#define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */ +#define SQLITE_DBCONFIG_MAX 1021 /* Largest DBCONFIG */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 3045d7c4a5..aa7e297e77 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1830,6 +1830,8 @@ struct sqlite3 { #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */ #define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */ +#define SQLITE_AttachCreate HI(0x00010) /* ATTACH allowed to create new dbs */ +#define SQLITE_AttachWrite HI(0x00020) /* ATTACH allowed to open for write */ /* Flags used only if debugging */ #ifdef SQLITE_DEBUG From 83baa239e7000295cc17b9b9a0ea317b03dfb3c0 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 23 Jan 2025 06:10:54 +0000 Subject: [PATCH 049/115] Do not strip binaries during 'make install', for consistency with the legacy build and per request from package maintainers. FossilOrigin-Name: cd3fed5c2082c250c32c4d99eecd49a1ab840583fc343bcfd27fb536715d0ce9 --- main.mk | 11 ++--------- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/main.mk b/main.mk index d83c39b3a9..1def7d1d0d 100644 --- a/main.mk +++ b/main.mk @@ -351,13 +351,6 @@ T.cc += $(OPTS) INSTALL.noexec = $(INSTALL) -m 0644 # ^^^ do not use GNU-specific flags to $(INSTALL), e.g. --mode=... -# When cross-compiling, we need to avoid the -s flag because it only -# works on the build host's platform. -INSTALL.strip.1 = $(INSTALL) -INSTALL.strip.0 = $(INSTALL) -s -INSTALL.strip. = $(INSTALL.strip.0) -INSTALL.strip = $(INSTALL.strip.$(IS_CROSS_COMPILING)) - # # $(T.compile) = generic target platform compiler invocation, # differing only from $(T.cc) in that it appends $(T.compile.extras), @@ -2024,7 +2017,7 @@ sqlite3d$(T.exe): shell.c $(LIBOBJS0) $(LDFLAGS.libsqlite3) $(LDFLAGS.readline) install-shell-0: sqlite3$(T.exe) $(install-dir.bin) - $(INSTALL.strip) sqlite3$(T.exe) "$(install-dir.bin)" + $(INSTALL) sqlite3$(T.exe) "$(install-dir.bin)" install-shell-1: install: install-shell-$(HAVE_WASI_SDK) @@ -2038,7 +2031,7 @@ sqldiff$(T.exe): $(sqldiff.$(LINK_TOOLS_DYNAMICALLY).deps) $(sqldiff.$(LINK_TOOLS_DYNAMICALLY).rules) install-diff: sqldiff$(T.exe) $(install-dir.bin) - $(INSTALL.strip) sqldiff$(T.exe) "$(install-dir.bin)" + $(INSTALL) sqldiff$(T.exe) "$(install-dir.bin)" #install: install-diff dbhash$(T.exe): $(TOP)/tool/dbhash.c sqlite3.o sqlite3.h diff --git a/manifest b/manifest index 522504c0c9..a49d904122 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Replace\sthe\suse\sof\sthe\sAutools\sin\s./autoconf/\swith\sAutosetup\sand\sextend\sits\sconfigure\sscript\sto\sinclude\smany\sof\sthe\sflags\savailable\sin\sthe\scanonical\sbuild. -D 2025-01-22T21:34:53.714 +C Do\snot\sstrip\sbinaries\sduring\s'make\sinstall',\sfor\sconsistency\swith\sthe\slegacy\sbuild\sand\sper\srequest\sfrom\spackage\smaintainers. +D 2025-01-23T06:10:54.168 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -16,7 +16,7 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 F auto.def 7833c0a8630dd3a3410dcc6c8b4d1b63f25d03d6497267624b8a37aba119cb3e F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac -F autoconf/Makefile.in 56697ad25ecf23afa317148b06bdc14f85960b42e5ec434ac1ba87f63a3cb789 w autoconf/Makefile.am +F autoconf/Makefile.in 56697ad25ecf23afa317148b06bdc14f85960b42e5ec434ac1ba87f63a3cb789 F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 F autoconf/README.first f1d3876e9a7852c22f275a6f06814e64934cecbc0b5b9617d64849094c1fd136 F autoconf/README.txt 7f01dc3915e2d68f329011073662369e62a0938a2c69398807823c57591cb288 @@ -700,7 +700,7 @@ F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65a F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 F ext/wasm/wasmfs.make bc8bb227f35d5bd3863a7bd2233437c37472a0d81585979f058f9b9b503bef35 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk a187ada134ccb55b5d59ea3eb8f71cc6b19bfc244689e24a729f7a64aa500dc3 +F main.mk 18b859068a43818d29172b36d624a9bc8ce8204350ebd18a9f96994970081ab9 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2207,9 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c20d21b473d8a45267262c5df1d7b102eccce8e4cfbe1e467ea66c474aea0af5 e5bbc2428f1000a451c1b4afd287742b9896a1a6c82d9706c6b8e7d6fb3b1e44 -R 2375827128bc5d50768932667a2d6889 -T +closed e5bbc2428f1000a451c1b4afd287742b9896a1a6c82d9706c6b8e7d6fb3b1e44 Closed\sby\sintegrate-merge. +P 8c60d4c901af716d4d4dfd1dd4aa626c758fac2cb46112b24b0838b7888fc66f +R f8ba6d19954b4d49ab26ed596b2e234d U stephan -Z b7887b7452fd09e55e3fce7da3a1b70f +Z 3c78270c553a7173f56e21c430eac6f8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 02ec10f1aa..fa88295178 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c60d4c901af716d4d4dfd1dd4aa626c758fac2cb46112b24b0838b7888fc66f +cd3fed5c2082c250c32c4d99eecd49a1ab840583fc343bcfd27fb536715d0ce9 From c9bf7ed9ad146a64aea26fc58c1d91fb281b6693 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 23 Jan 2025 11:21:29 +0000 Subject: [PATCH 050/115] Remove unnecessary --minify 0 emcc flag from the wasm build, as -g3 implies that capability along with other anti-minification features we rely on. FossilOrigin-Name: 10c91f9cd074e8d35af1c7f8251ac18e5dd91fa14df3fe4e1fb44441c4f08c7a --- ext/wasm/GNUmakefile | 1 - manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index ad6fafacc7..d782a8122e 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -618,7 +618,6 @@ emcc.cflags += -I. -I$(dir.top) ######################################################################## # emcc flags specific to building .js/.wasm files... emcc.jsflags := -fPIC -emcc.jsflags += --minify 0 emcc.jsflags += --no-entry emcc.jsflags += -sWASM_BIGINT=$(emcc.WASM_BIGINT) emcc.jsflags += -sMODULARIZE diff --git a/manifest b/manifest index a49d904122..87b1fdc1da 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sstrip\sbinaries\sduring\s'make\sinstall',\sfor\sconsistency\swith\sthe\slegacy\sbuild\sand\sper\srequest\sfrom\spackage\smaintainers. -D 2025-01-23T06:10:54.168 +C Remove\sunnecessary\s--minify\s0\semcc\sflag\sfrom\sthe\swasm\sbuild,\sas\s-g3\simplies\sthat\scapability\salong\swith\sother\santi-minification\sfeatures\swe\srely\son. +D 2025-01-23T11:21:29.495 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -618,7 +618,7 @@ F ext/session/sqlite3session.c d6f5e3e83b9b0bbc4a8db4837284f0ecc6af5321d4c8e7136 F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 78f49e47146d58fa44f9ac624627a718fba4b2b2baeaea641bcf6fed300c0f0d +F ext/wasm/GNUmakefile ccd219b2db93f5dba54ba5ed45d71b46eb219e2b27a541d3dc21f98b16dc0f5f F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8c60d4c901af716d4d4dfd1dd4aa626c758fac2cb46112b24b0838b7888fc66f -R f8ba6d19954b4d49ab26ed596b2e234d +P cd3fed5c2082c250c32c4d99eecd49a1ab840583fc343bcfd27fb536715d0ce9 +R de609fdf581bc64ebd30372c2fbf1eb4 U stephan -Z 3c78270c553a7173f56e21c430eac6f8 +Z a93ce720e037c2af4cd69560e744cedd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fa88295178..3ce03ee524 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd3fed5c2082c250c32c4d99eecd49a1ab840583fc343bcfd27fb536715d0ce9 +10c91f9cd074e8d35af1c7f8251ac18e5dd91fa14df3fe4e1fb44441c4f08c7a From 72543206e59eb55e4040603e2fe98bde15772d44 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 23 Jan 2025 14:09:02 +0000 Subject: [PATCH 051/115] Move small parts of ext/wasm/GNUmakefile into ext/wasm/config.make.in and have the configure script populate that, rather than dynamically determining those values on each 'make' invocation. Add a configure-time check for the optional wasm-opt binary in prep for pending experimentation with using it to reduce the wasm file sizes. FossilOrigin-Name: 0a426a549577b883e2de7cd0605041cc97b57f53ee6657bc318b0bfde7b62677 --- autosetup/proj.tcl | 18 ++-- autosetup/sqlite-config.tcl | 57 ++++++++--- ext/wasm/GNUmakefile | 182 ++++++++++++++++++------------------ ext/wasm/config.make.in | 14 +++ ext/wasm/mkwasmbuilds.c | 15 ++- manifest | 19 ++-- manifest.uuid | 2 +- 7 files changed, 182 insertions(+), 125 deletions(-) create mode 100644 ext/wasm/config.make.in diff --git a/autosetup/proj.tcl b/autosetup/proj.tcl index 915a6b1349..88da2112cf 100644 --- a/autosetup/proj.tcl +++ b/autosetup/proj.tcl @@ -276,9 +276,9 @@ proc proj-find-executable-path {args} { # a binary, sets a define (see below) to the result, and returns the # result (an empty string if not found). # -# The define'd name is: if defName is empty then "BIN_X" is used, -# where X is the upper-case form of $binName with any '-' characters -# replaced with '_'. +# The define'd name is: If $defName is not empty, it is used as-is. If +# $defName is empty then "BIN_X" is used, where X is the upper-case +# form of $binName with any '-' characters replaced with '_'. proc proj-bin-define {binName {defName {}}} { set check [proj-find-executable-path -v $binName] if {"" eq $defName} { @@ -850,16 +850,16 @@ proc proj-affirm-files-exist {args} { # If the given directory is found, it expects to find emsdk_env.sh in # that directory, as well as the emcc compiler somewhere under there. # -# If the --with-emsdk flag is explicitly provided and the SDK is not -# found then a fatal error is generated, otherwise failure to find the -# SDK is not fatal. +# If the --with-emsdk[=DIR] flag is explicitly provided and the SDK is +# not found then a fatal error is generated, otherwise failure to find +# the SDK is not fatal. # # Defines the following: # -# - EMSDK_HOME = top dir of the emsdk or "". -# - EMSDK_ENV_SH = path to EMSDK_HOME/emsdk_env.sh or "" -# - BIN_EMCC = $EMSDK_HOME/upstream/emscripten/emcc or "" # - HAVE_EMSDK = 0 or 1 (this function's return value) +# - EMSDK_HOME = "" or top dir of the emsdk +# - EMSDK_ENV_SH = "" or $EMSDK_HOME/emsdk_env.sh +# - BIN_EMCC = "" or $EMSDK_HOME/upstream/emscripten/emcc # # Returns 1 if EMSDK_ENV_SH is found, else 0. If EMSDK_HOME is not empty # but BIN_EMCC is then emcc was not found in the EMSDK_HOME, in which diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 96b7d0c1b3..40941687e4 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -418,26 +418,58 @@ proc sqlite-handle-tempstore {} { ######################################################################## # Check for the Emscripten SDK for building the web-based wasm # components. The core lib and tools do not require this but ext/wasm -# does. +# does. Most of the work is done via [proj-check-emsdk], then this +# function adds the following defines: +# +# - EMCC_WRAPPER = "" or top-srcdir/tool/emcc.sh +# - BIN_WASM_OPT = "" or path to wasm-opt +# - BIN_WASM_STRIP = "" or path to wasm-strip +# +# Noting that: +# +# 1) Not finding the SDK is not fatal at this level, nor is failure to +# find one of the related binaries. +# +# 2) wasm-strip is part of the wabt package: +# +# https://github.com/WebAssembly/wabt +# +# and this project requires it for production-mode builds but not dev +# builds. +# proc sqlite-handle-emsdk {} { + define EMCC_WRAPPER "" + define BIN_WASM_STRIP "" + define BIN_WASM_OPT "" set srcdir $::autosetup(srcdir) if {$srcdir ne $::autosetup(builddir)} { # The EMSDK pieces require writing to the original source tree # even when doing an out-of-tree build. The ext/wasm pieces do not - # support an out-of-tree build so we catch that case and treat it - # as if EMSDK were not found. + # support an out-of-tree build so we treat that case as if EMSDK + # were not found. msg-result "Out-of tree build: not checking for EMSDK." - define EMCC_WRAPPER "" return } - set emccsh $srcdir/tool/emcc.sh + set emccSh $srcdir/tool/emcc.sh + set extWasmConfig $srcdir/ext/wasm/config.make if {![get-define HAVE_WASI_SDK] && [proj-check-emsdk]} { - define EMCC_WRAPPER $emccsh - proj-make-from-dot-in $emccsh - catch {exec chmod u+x $emccsh} + define EMCC_WRAPPER $emccSh + set emsdkHome [get-define EMSDK_HOME ""] + proj-assert {"" ne $emsdkHome} + #define EMCC_WRAPPER ""; # just for testing + proj-bin-define wasm-strip + proj-bin-define bash; # ext/wasm/GNUmakefile requires bash + if {[file-isexec $emsdkHome/upstream/bin/wasm-opt]} { + define BIN_WASM_OPT $emsdkHome/upstream/bin/wasm-opt + } else { + # Maybe there's a copy in the path? + proj-bin-define wasm-opt BIN_WASM_OPT + } + proj-make-from-dot-in $emccSh $extWasmConfig + catch {exec chmod u+x $emccSh} } else { define EMCC_WRAPPER "" - file delete -force $emccsh + file delete -force -- $emccSh $extWasmConfig } } @@ -851,11 +883,14 @@ proc sqlite-post-config-validation {} { # Check #1: ensure that files which get filtered for @VAR@ do not # contain any unresolved @VAR@ refs. That may indicate an # unexported/unused var or a typo. - foreach f "Makefile sqlite3.pc $::autosetup(srcdir)/tool/emcc.sh" { + set srcdir $::autosetup(srcdir) + foreach f [list Makefile sqlite3.pc \ + $srcdir/tool/emcc.sh \ + $srcdir/ext/wasm/config.make] { if {![file exists $f]} continue set lnno 1 foreach line [proj-file-content-list $f] { - if {[regexp {(@[A-Za-z_]+@)} $line match]} { + if {[regexp {(@[A-Za-z0-9_]+@)} $line match]} { error "Unresolved reference to $match at line $lnno of $f" } incr lnno diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index d782a8122e..258c4a466e 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -38,13 +38,9 @@ ######################################################################## default: all #default: quick -SHELL := $(firstword $(shell which bash) $(wildcard /usr/local/bin/bash /usr/bin/bash /bin/bash)) -ifeq (,$(SHELL)) - $(error Cannot find the bash shell) -endif MAKEFILE := $(lastword $(MAKEFILE_LIST)) CLEAN_FILES := -DISTCLEAN_FILES := +DISTCLEAN_FILES := config.make MAKING_CLEAN := $(if $(filter %clean,$(MAKECMDGOALS)),1,0) .PHONY: clean distclean clean: @@ -52,6 +48,67 @@ clean: distclean: clean -rm -f $(DISTCLEAN_FILES) + +######################################################################## +# Special-case builds for which we require certain pre-conditions +# which, if not met, may cause warnings or fatal errors in the build. +# This also affects the default optimization level flags. Note that +# the fiddle targets are in this list because they are used for +# generating sqlite.org/fiddle. +OPTIMIZED_TARGETS := dist snapshot fiddle fiddle.debug + +ifeq (1,$(MAKING_CLEAN)) + bin.wasm-strip := echo "not stripping" + bin.wasm-opt := irrelevant + bin.emcc := irrelevant + bin.bash := irrelevant + emcc.version := unknown +else + # Include config.make and perform some bootstrapping... + ifeq (,$(wildcard ./config.make)) + $(error Missing config.make (gets generated by the configure script if the EMSDK is found)) + endif + include ./config.make + ifeq (,$(bin.bash)) + $(error Configure script did not find the bash shell) + endif + ifeq (,$(bin.emcc)) + $(error Configure script did not find emcc) + endif + emcc.version := $(shell $(bin.emcc) --version | sed -n 1p | sed -e 's/^.* \([3-9][^ ]*\) .*$$/\1/;') + $(info using emcc version [$(emcc.version)]) + ifeq (,$(bin.wasm-strip)) + #################################################################### + # We need wasm-strip for release builds (see below for why) but + # not strictly for non-release builds. + $(info WARNING: *******************************************************************) + $(info WARNING: Builds using -Oz will minify WASM-exported names, breaking) + $(info WARNING: _All The Things_. The workaround for that is to build) + $(info WARNING: with -g3 (which explodes the file size) and then strip the debug) + $(info WARNING: info after compilation, using wasm-strip, to shrink the wasm file.) + $(info WARNING: wasm-strip was not found in the PATH so we cannot strip those.) + $(info WARNING: If this build uses any optimization level higher than -O1 then) + $(info WARNING: the ***resulting JS code WILL NOT BE USABLE***.) + $(info WARNING: wasm-strip is part of the wabt package:) + $(info WARNING: https://github.com/WebAssembly/wabt) + $(info WARNING: on Ubuntu-like systems it can be installed with:) + $(info WARNING: sudo apt install wabt) + $(info WARNING: *******************************************************************) + ifneq (,$(filter $(OPTIMIZED_TARGETS),$(MAKECMDGOALS))) + $(error Cannot make release-quality binary because wasm-strip is not available.) + endif + bin.wasm-strip := echo "not wasm-stripping" + endif + ifeq (,$(filter $(OPTIMIZED_TARGETS),$(MAKECMDGOALS))) + $(info ==============================================================) + $(info == Development build. Make one of (dist, snapshot) for a) + $(info == smaller release build.) + $(info ==============================================================) + endif +endif +# ^^^ end of are-we-MAKING_CLEAN +maybe-wasm-strip := $(bin.wasm-strip) + ######################################################################## # JS_BUILD_NAMES exists for documentation purposes only. It enumerates # the core build styles: @@ -133,13 +190,15 @@ sqlite3.canonical.c := $(dir.top)/sqlite3.c sqlite3.c ?= $(firstword $(wildcard $(dir.top)/sqlite3-see.c) $(sqlite3.canonical.c)) sqlite3.h := $(dir.top)/sqlite3.h -ifneq (1,$(MAKING_CLEAN)) -ifeq (,$(shell grep sqlite3_activate_see $(sqlite3.c))) +ifeq (1,$(MAKING_CLEAN)) SQLITE_C_IS_SEE := 0 else - SQLITE_C_IS_SEE := 1 - $(info This is an SEE build) -endif + ifeq (,$(shell grep sqlite3_activate_see $(sqlite3.c))) + SQLITE_C_IS_SEE := 0 + else + SQLITE_C_IS_SEE := 1 + $(info This is an SEE build) + endif endif ########################################################################@ @@ -151,65 +210,6 @@ $(sqlite3.h): $(MAKE) -C $(dir.top) sqlite3.c $(sqlite3.c): $(sqlite3.h) -######################################################################## -# Special-case builds for which we require certain pre-conditions -# which, if not met, may cause warnings or fatal errors in the build. -# This also affects the default optimization level flags. Note that -# the fiddle targets are in this list because they are used for -# generating sqlite.org/fiddle. -OPTIMIZED_TARGETS := dist snapshot fiddle fiddle.debug - -ifneq (1,$(MAKING_CLEAN)) - ifeq (,$(filter $(OPTIMIZED_TARGETS),$(MAKECMDGOALS))) - $(info ==============================================================) - $(info == Development build. Make one of (dist, snapshot) for a) - $(info == smaller release build.) - $(info ==============================================================) - endif -endif - -######################################################################## -# Find emcc (Emscripten compiler)... -ifeq (1,$(MAKING_CLEAN)) - emcc.bin := echo - emcc.version := unknown -else - emcc.bin := $(dir.tool)/emcc.sh - ifeq (,$(wildcard $(emcc.bin))) - $(error Configure script did not find emcc.) - endif - emcc.version := $(shell $(emcc.bin) --version | sed -n 1p | sed -e 's/^.* \([3-9][^ ]*\) .*$$/\1/;') - $(info using emcc version [$(emcc.version)]) -endif -######################################################################### -# Find wasm-strip, which we need for release builds (see below for -# why) but not strictly for non-release builds. -ifeq (1,$(MAKING_CLEAN)) - wasm-strip.bin := irrelevant -else - wasm-strip.bin ?= $(shell which wasm-strip 2>/dev/null) - ifeq (,$(wasm-strip.bin)) - $(info WARNING: *******************************************************************) - $(info WARNING: Builds using -O2/-O3/-Os/-Oz will minify WASM-exported names,) - $(info WARNING: breaking _All The Things_. The workaround for that is to build) - $(info WARNING: with -g3 (which explodes the file size) and then strip the debug) - $(info WARNING: info after compilation, using wasm-strip, to shrink the wasm file.) - $(info WARNING: wasm-strip was not found in the PATH so we cannot strip those.) - $(info WARNING: If this build uses any optimization level higher than -O1 then) - $(info WARNING: the ***resulting JS code WILL NOT BE USABLE***.) - $(info WARNING: wasm-strip is part of the wabt package:) - $(info WARNING: https://github.com/WebAssembly/wabt) - $(info WARNING: on Ubuntu-like systems it can be installed with:) - $(info WARNING: sudo apt install wabt) - $(info WARNING: *******************************************************************) - ifneq (,$(filter $(OPTIMIZED_TARGETS),$(MAKECMDGOALS))) - $(error Cannot make release-quality binary because wasm-strip is not available.) - endif - wasm-strip.bin := echo "not wasm-stripping" - endif -endif -maybe-wasm-strip := $(wasm-strip.bin) - ######################################################################## # barebones=1 disables all "extraneous" stuff from sqlite3-wasm.c, the # goal being to create a WASM file with only the core APIs. @@ -375,19 +375,6 @@ $(bin.stripccomments): $(bin.stripccomments).c $(MAKEFILE) $(CC) -o $@ $< DISTCLEAN_FILES += $(bin.stripccomments) -######################################################################## -# bin.mkwb is used for generating some of the makefile code for the -# various wasm builds. It used to be generated in this makefile via a -# difficult-to-read/maintain block of $(eval)'d code. Attempts were -# made to generate it from tcl and bash (shell) but having to escape -# the $ references in those languages made it just as illegible as the -# native makefile code. Somewhat surprisingly, moving that code generation -# to C makes it slightly less illegible than the previous 3 options. -bin.mkwb := ./mkwasmbuilds -$(bin.mkwb): $(bin.mkwb).c $(MAKEFILE) - $(CC) -o $@ $< -DISTCLEAN_FILES += $(bin.mkwb) - ######################################################################## # C-PP.FILTER: a $(call)able to transform $(1) to $(2) via: # @@ -872,14 +859,6 @@ sqlite3-node.mjs := $(dir.dout)/sqlite3-node.mjs sqlite3-api-wasmfs.mjs := $(dir.tmp)/sqlite3-api-wasmfs.mjs sqlite3-wasmfs.mjs := $(dir.wasmfs)/sqlite3-wasmfs.mjs EXPORTED_FUNCTIONS.fiddle := $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle -ifneq (1,$(MAKING_CLEAN)) -.wasmbuilds.make: $(bin.mkwb) - @rm -f $@ - $(bin.mkwb) > $@ - @chmod -w $@ --include .wasmbuilds.make -endif -DISTCLEAN_FILES += .wasmbuilds.make # The various -D... values used by *.c-pp.js include: # @@ -960,6 +939,27 @@ sqlite3-api.ext.jses += \ all quick: $(sqlite3-api.ext.jses) q: quick +ifneq (1,$(MAKING_CLEAN)) +######################################################################## +# bin.mkwb is used for generating some of the makefile code for the +# various wasm builds. It used to be generated in this makefile via a +# difficult-to-read/maintain block of $(eval)'d code. Attempts were +# made to generate it from tcl and bash (shell) but having to escape +# the $ references in those languages made it just as illegible as the +# native makefile code. Somewhat surprisingly, moving that code generation +# to C makes it slightly less illegible than the previous 3 options. +bin.mkwb := ./mkwasmbuilds +$(bin.mkwb): $(bin.mkwb).c $(MAKEFILE) + $(CC) -o $@ $< +DISTCLEAN_FILES += $(bin.mkwb) +.wasmbuilds.make: $(bin.mkwb) + @rm -f $@ + $(bin.mkwb) > $@ + @chmod -w $@ +-include .wasmbuilds.make +endif +DISTCLEAN_FILES += .wasmbuilds.make + ######################################################################## # batch-runner.js is part of one of the test apps which reads in SQL # dumps generated by $(speedtest1) and executes them. @@ -1041,7 +1041,7 @@ $(speedtest1.js): $(MAKEFILE) $(speedtest1.cfiles) \ $(pre-post-speedtest1-vanilla.deps) \ $(EXPORTED_FUNCTIONS.speedtest1) @echo "Building $@ ..." - $(emcc.bin) \ + $(bin.emcc) \ $(emcc.speedtest1) \ $(emcc.speedtest1.common) \ $(emcc.flags.speedtest1-vanilla) $(pre-post-speedtest1-vanilla.flags) \ diff --git a/ext/wasm/config.make.in b/ext/wasm/config.make.in new file mode 100644 index 0000000000..caaceb4bb2 --- /dev/null +++ b/ext/wasm/config.make.in @@ -0,0 +1,14 @@ +# Gets filtered by the configure script +bin.bash = @BIN_BASH@ +bin.emcc = @EMCC_WRAPPER@ +bin.wasm-strip = @BIN_WASM_STRIP@ +bin.wasm-opt = @BIN_WASM_OPT@ + +SHELL := $(bin.bash) + +# The following overrides can be activated to test +# various validation in GNUmakefile: +# +#bin.bash := +#bin.emcc := +#bin.wasm-strip := diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index d7a9a3e71c..ece1185a36 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -157,7 +157,7 @@ static void mk_fiddle(){ if( 1==i ){/*fiddle.debug*/ pf(" @test -d \"$(dir $@)\" || mkdir -p \"$(dir $@)\"\n"); } - pf(" $(emcc.bin) -o $@ $(fiddle.emcc-flags%s) " + pf(" $(bin.emcc) -o $@ $(fiddle.emcc-flags%s) " "$(pre-post-fiddle-module-vanilla.flags) $(fiddle.cses)\n", zTail); pf(" $(maybe-wasm-strip) $(fiddle-module.wasm%s)\n", zTail); @@ -213,10 +213,17 @@ static void mk_lib_mode(const char *zName /* build name */, /* target zJsOut */ pf("%s: %s $(MAKEFILE) $(sqlite3-wasm.cfiles) $(EXPORTED_FUNCTIONS.api) " - "$(pre-post-%s-%s.deps)\n", + "$(pre-post-%s-%s.deps) " + "$(sqlite3-api.ext.jses)" + /* ^^^ maintenance reminder: we set these as deps so that they + get copied into place early. That allows the developer to + reload the base-most test pages while the later-stage builds + are still compiling, which is especially helpful when running + builds with long build times (like -Oz). */ + "\n", zJsOut, zApiJsOut, zNM); pf("\t@echo \"Building $@ ...\"\n"); - pf("\t$(emcc.bin) -o $@ $(emcc_opt_full) $(emcc.flags) \\\n"); + pf("\t$(bin.emcc) -o $@ $(emcc_opt_full) $(emcc.flags) \\\n"); pf("\t\t$(emcc.jsflags) -sENVIRONMENT=$(emcc.environment.%s) \\\n", zMode); pf("\t\t$(pre-post-%s-%s.flags) \\\n", zNM); pf("\t\t$(emcc.flags.%s) $(emcc.flags.%s.%s) \\\n", zName, zNM); @@ -241,7 +248,7 @@ static void mk_lib_mode(const char *zName /* build name */, speed up lib init, and reduce memory cost considerably, by stripping them out. */; /* - ** The above $(emcc.bin) call will write zJsOut and will create a + ** The above $(bin.emcc) call will write zJsOut and will create a ** like-named .wasm file. That .wasm file name gets hard-coded into ** zJsOut so we need to, for some cases, patch zJsOut to use the ** name sqlite3.wasm instead. Note that the resulting .wasm file is diff --git a/manifest b/manifest index 87b1fdc1da..2bb299c38b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunnecessary\s--minify\s0\semcc\sflag\sfrom\sthe\swasm\sbuild,\sas\s-g3\simplies\sthat\scapability\salong\swith\sother\santi-minification\sfeatures\swe\srely\son. -D 2025-01-23T11:21:29.495 +C Move\ssmall\sparts\sof\sext/wasm/GNUmakefile\sinto\sext/wasm/config.make.in\sand\shave\sthe\sconfigure\sscript\spopulate\sthat,\srather\sthan\sdynamically\sdetermining\sthose\svalues\son\seach\s'make'\sinvocation.\sAdd\sa\sconfigure-time\scheck\sfor\sthe\soptional\swasm-opt\sbinary\sin\sprep\sfor\spending\sexperimentation\swith\susing\sit\sto\sreduce\sthe\swasm\sfile\ssizes. +D 2025-01-23T14:09:02.122 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -49,8 +49,8 @@ F autosetup/cc-shared.tcl 4f024e94a47f427ba61de1739f6381ef0080210f9fae89112d5c1d F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e45f F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba -F autosetup/proj.tcl 50b060ea6760b02ef5cb16650fbe9c1840e16351a0be0ccfc3727c565f74a257 -F autosetup/sqlite-config.tcl cf9790dc31d498b69ad2b348b7a3a6f2c7df9a86d770b31dff2255c2f62e5015 +F autosetup/proj.tcl 9adf1539673cef15bff862d9360b479e6920cc2c0d85de707b0ba31c04ce4531 +F autosetup/sqlite-config.tcl f37f6961c8fb2454960f97a28011a29994f6c591b1da392a9ae28af96e0c15a2 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -618,7 +618,7 @@ F ext/session/sqlite3session.c d6f5e3e83b9b0bbc4a8db4837284f0ecc6af5321d4c8e7136 F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile ccd219b2db93f5dba54ba5ed45d71b46eb219e2b27a541d3dc21f98b16dc0f5f +F ext/wasm/GNUmakefile 5c36cb9ad5217e74f8936861210dac0b052b9cd418cbabe915cc9d646c5743a0 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -659,6 +659,7 @@ F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b5318317 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f F ext/wasm/common/whwasmutil.js d76c69617e95d85ffc9996f7d9d7481df6976dcbd860ecd82bd8c075e3a101ae +F ext/wasm/config.make.in f830c98f0f668f7628d9521bc0b1175ab15b050f20fe3234346be346d747c587 F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf @@ -678,7 +679,7 @@ F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29a F ext/wasm/index.html e4bbffdb3d40eff12b3f9c7abedef91787e2935620b7f8d40f2c774b80ad8fa9 F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 -F ext/wasm/mkwasmbuilds.c af06fd14fcb7803c0adacab276047bb696c07f5b683a6f70adc5b3f146cf61f3 +F ext/wasm/mkwasmbuilds.c 619b99bffb9538c681f0622395a177e4ba2e2658bc1b94bb7f6605245b6e365e F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -2207,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cd3fed5c2082c250c32c4d99eecd49a1ab840583fc343bcfd27fb536715d0ce9 -R de609fdf581bc64ebd30372c2fbf1eb4 +P 10c91f9cd074e8d35af1c7f8251ac18e5dd91fa14df3fe4e1fb44441c4f08c7a +R 07e50a0cf41474faaa27c1572e1c844e U stephan -Z a93ce720e037c2af4cd69560e744cedd +Z 685755e90bacd2eb62f10206ae6eb72e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3ce03ee524..8753d034c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -10c91f9cd074e8d35af1c7f8251ac18e5dd91fa14df3fe4e1fb44441c4f08c7a +0a426a549577b883e2de7cd0605041cc97b57f53ee6657bc318b0bfde7b62677 From efafde5eb44fa2791e914445e5189b26a5c63063 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 23 Jan 2025 15:58:01 +0000 Subject: [PATCH 052/115] Initial support for post-processing wasm files with wasm-opt (if it's available). This currently shaves 12kb off of the release-mode build of sqlite3.wasm but there are many dozens of wasm-opt flags left to try. FossilOrigin-Name: 5d16e3f28364de2d6b6456a6fc56bf604b9106c3ae15719f2862192ae3020cc1 --- ext/wasm/GNUmakefile | 6 +++--- ext/wasm/config.make.in | 6 ++++++ ext/wasm/mkwasmbuilds.c | 47 +++++++++++++++++++++++++++++++---------- ext/wasm/wasmfs.make | 2 +- manifest | 18 ++++++++-------- manifest.uuid | 2 +- 6 files changed, 56 insertions(+), 25 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 258c4a466e..5623965478 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -812,7 +812,7 @@ sqlite3-wasmfs.cfiles := $(sqlite3-wasm.cfiles) ######################################################################## ######################################################################## -# SQLITE3.xJS.ESM-EXPORT-DEFAULT is used by mkwasmbuilds.c and the +# SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT is used by mkwasmbuilds.c and the # wasmfs build. $1 is 1 if the build mode needs this workaround # (modes: esm, bundler-friendly, node) and 0 if not (vanilla). $2 must # be 0 for all builds except sqlite3-wasmfs.mjs, in which case it must @@ -833,9 +833,9 @@ sqlite3-wasmfs.cfiles := $(sqlite3-wasm.cfiles) # # Maintenance reminder: Mac sed works differently than GNU sed, so we # use awk instead of sed for this. -define SQLITE3.xJS.ESM-EXPORT-DEFAULT +define SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT if [ x1 = x$(1) ]; then \ - echo "Fragile workaround for emscripten/issues/18237. See SQLITE3.xJS.ESM-EXPORT-DEFAULT."; \ + echo "Fragile workaround for emscripten/issues/18237. See SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT."; \ {\ awk '/^export default/ && !f{f=1; next} 1' $@ > $@.tmp && mv $@.tmp $@; \ } || exit $$?; \ diff --git a/ext/wasm/config.make.in b/ext/wasm/config.make.in index caaceb4bb2..3218541b37 100644 --- a/ext/wasm/config.make.in +++ b/ext/wasm/config.make.in @@ -4,6 +4,12 @@ bin.emcc = @EMCC_WRAPPER@ bin.wasm-strip = @BIN_WASM_STRIP@ bin.wasm-opt = @BIN_WASM_OPT@ +ifeq (,$(bin.wasm-opt)) + # wasm-opt is an optional optimization step. We install a dummy + # command in its place if it's not available to simplify the make + # recipes which use it. + #bin.wasm-opt = echo "[not wasm-opt]" +endif SHELL := $(bin.bash) # The following overrides can be activated to test diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index ece1185a36..27aa3b156f 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -64,6 +64,24 @@ static void mk_prologue(void){ ps("# pre-post-jses.deps.* = a list of dependencies for the"); ps("# --[extern-][pre/post]-js files."); ps("pre-post-jses.deps.common := $(extern-pre-js.js) $(sqlite3-license-version.js)"); + + /* SQLITE.CALL.WASM-OPT = shell code to run $(1) (source wasm file + ** name) through $(bin.wasm-opt) */ + ps("ifeq (,$(bin.wasm-opt))"); + ps("define SQLITE.CALL.WASM-OPT"); + ps("echo 'wasm-opt not available: $(1)'"); + ps("endef"); + ps("else"); + ps("define SQLITE.CALL.WASM-OPT"); + ps("echo -n 'Before wasm-opt:'; ls -l $(1);\\\n" + "\trm -f wasm-opt-tmp.wasm;\\\n" + "\t$(bin.wasm-opt) --enable-bulk-memory-opt --all-features --post-emscripten\\\n" + "\t$(1) -o wasm-opt-tmp.wasm || exit;\\\n" + "\tmv wasm-opt-tmp.wasm $(1); " + "echo -n 'After wasm-opt: '; ls -l $(1)" + ); + ps("endef"); + ps("endif"); } /* @@ -193,6 +211,10 @@ static void mk_lib_mode(const char *zName /* build name */, const char *zJsOut /* name of generated sqlite3.js/.mjs */, const char *zCmppD /* extra -D flags for c-pp */, const char *zEmcc /* extra flags for emcc */){ + const char * zTgtWasmName = "$(basename $@).wasm" + /* The various targets named X.js or X.mjs (zJsOut) also generate + ** X.wasm, and we need that part of the name to perform some + ** post-processing after Emscripten generates X.wasm. */; assert( zName ); assert( zMode ); assert( zApiJsOut ); @@ -234,14 +256,16 @@ static void mk_lib_mode(const char *zName /* build name */, /* TODO? Replace this CALL with the corresponding makefile code. ** OTOH, we also use this $(call) in the speedtest1-wasmfs build, ** which is not part of the rules emitted by this program. */ - pf("\t@$(call SQLITE3.xJS.ESM-EXPORT-DEFAULT,1,%d)\n", + pf("\t@$(call SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT,1,%d)\n", 0==strcmp("sqlite3-wasmfs", zName) ? 1 : 0); } - pf("\t@dotwasm=$(basename $@).wasm; \\\n" - "\tchmod -x $$dotwasm; \\\n" - "\t$(maybe-wasm-strip) $$dotwasm; \\\n"); - pf("\tsed -i -e '/^var _sqlite3.*createExportWrapper/d' %s; \\\n" - "\techo 'Stripped out createExportWrapper() parts.'; \\\n", + pf("\t@chmod -x %s; \\\n" + "\t$(maybe-wasm-strip) %s;\n", + zTgtWasmName, zTgtWasmName); + pf("\t@$(call SQLITE.CALL.WASM-OPT,%s)\n", zTgtWasmName); + pf("\t@sed -i -e '/^var _sqlite3.*createExportWrapper/d' %s || exit; \\\n" + /* ^^^^^^ reminder: Mac/BSD sed has no -i flag */ + "\techo 'Stripped out createExportWrapper() parts.'\n", zJsOut) /* Our JS code installs bindings of each WASM export. The generated Emscripten JS file does the same using its own framework, but we don't use those results and can @@ -255,13 +279,14 @@ static void mk_lib_mode(const char *zName /* build name */, ** identical for all builds for which zEmcc is empty. */ if( 0==strcmp("bundler-friendly", zMode) - || 0==strcmp("node", zMode) ) { - pf("\techo 'Patching $@ for %s.wasm...' \\\n", zName); - pf("\trm -f $$dotwasm; dotwasm=; \\\n" - "\tsed -i -e 's/%s-%s.wasm/%s.wasm/g' $@ || exit $$?; \\\n", + || 0==strcmp("node", zMode) ){ + pf("\t@echo 'Patching $@ for %s.wasm...'; \\\n", zName); + pf("\trm -f %s; \\\n", zTgtWasmName); + pf("\tsed -i -e 's/%s-%s.wasm/%s.wasm/g' $@ || exit;\n", + /* ^^^^^^ reminder: Mac/BSD sed has no -i flag */ zNM, zName); } - pf("\tls -la $$dotwasm $@\n"); + pf("\t@ls -la %s $@\n", zTgtWasmName); if( 0!=strcmp("sqlite3-wasmfs", zName) ){ /* The sqlite3-wasmfs build is optional and needs to be invoked ** conditionally using info we don't have here. */ diff --git a/ext/wasm/wasmfs.make b/ext/wasm/wasmfs.make index 9de5574f26..2c6fa35bdd 100644 --- a/ext/wasm/wasmfs.make +++ b/ext/wasm/wasmfs.make @@ -101,7 +101,7 @@ $(speedtest1-wasmfs.mjs): $(speedtest1.cfiles) $(sqlite3-wasmfs.js) \ $(emcc.flags.sqlite3-wasmfs) \ $(emcc.flags.speedtest1-wasmfs) \ -o $@ $(speedtest1.cfiles) -lm - @$(call SQLITE3.xJS.ESM-EXPORT-DEFAULT,1,1) + @$(call SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT,1,1) $(maybe-wasm-strip) $(speedtest1-wasmfs.wasm) chmod -x $(speedtest1-wasmfs.wasm) ls -la $@ $(speedtest1-wasmfs.wasm) diff --git a/manifest b/manifest index 2bb299c38b..a531e94568 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\ssmall\sparts\sof\sext/wasm/GNUmakefile\sinto\sext/wasm/config.make.in\sand\shave\sthe\sconfigure\sscript\spopulate\sthat,\srather\sthan\sdynamically\sdetermining\sthose\svalues\son\seach\s'make'\sinvocation.\sAdd\sa\sconfigure-time\scheck\sfor\sthe\soptional\swasm-opt\sbinary\sin\sprep\sfor\spending\sexperimentation\swith\susing\sit\sto\sreduce\sthe\swasm\sfile\ssizes. -D 2025-01-23T14:09:02.122 +C Initial\ssupport\sfor\spost-processing\swasm\sfiles\swith\swasm-opt\s(if\sit's\savailable).\sThis\scurrently\sshaves\s12kb\soff\sof\sthe\srelease-mode\sbuild\sof\ssqlite3.wasm\sbut\sthere\sare\smany\sdozens\sof\swasm-opt\sflags\sleft\sto\stry. +D 2025-01-23T15:58:01.776 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -618,7 +618,7 @@ F ext/session/sqlite3session.c d6f5e3e83b9b0bbc4a8db4837284f0ecc6af5321d4c8e7136 F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 5c36cb9ad5217e74f8936861210dac0b052b9cd418cbabe915cc9d646c5743a0 +F ext/wasm/GNUmakefile 999ea962c098a934daa18e724c53856493adf1e03b3237465a5ee5b6fde28880 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -659,7 +659,7 @@ F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b5318317 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f F ext/wasm/common/whwasmutil.js d76c69617e95d85ffc9996f7d9d7481df6976dcbd860ecd82bd8c075e3a101ae -F ext/wasm/config.make.in f830c98f0f668f7628d9521bc0b1175ab15b050f20fe3234346be346d747c587 +F ext/wasm/config.make.in a44a2f9657c80c9ef0f5a462937a7c2f64916c8b99fb0a28b67d37f961997c94 F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf @@ -679,7 +679,7 @@ F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29a F ext/wasm/index.html e4bbffdb3d40eff12b3f9c7abedef91787e2935620b7f8d40f2c774b80ad8fa9 F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 -F ext/wasm/mkwasmbuilds.c 619b99bffb9538c681f0622395a177e4ba2e2658bc1b94bb7f6605245b6e365e +F ext/wasm/mkwasmbuilds.c 9f4e0527043a20fab98463e455eeaf287e58b01700248b213159b86a6c3fbb5f F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -699,7 +699,7 @@ F ext/wasm/tester1.c-pp.js 228101c290003423f0bfb66a6ebbfc6904fa7b1b69466e700c135 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 -F ext/wasm/wasmfs.make bc8bb227f35d5bd3863a7bd2233437c37472a0d81585979f058f9b9b503bef35 +F ext/wasm/wasmfs.make 68999f5bd8c489239592d59a420f8c627c99169bbd6fa16a404751f757b9f702 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 F main.mk 18b859068a43818d29172b36d624a9bc8ce8204350ebd18a9f96994970081ab9 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 10c91f9cd074e8d35af1c7f8251ac18e5dd91fa14df3fe4e1fb44441c4f08c7a -R 07e50a0cf41474faaa27c1572e1c844e +P 0a426a549577b883e2de7cd0605041cc97b57f53ee6657bc318b0bfde7b62677 +R 2d32486992b9b3356e014d934b282b6a U stephan -Z 685755e90bacd2eb62f10206ae6eb72e +Z edbdf887524cd901e3308cf68c45b681 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8753d034c2..d0f50acaa8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a426a549577b883e2de7cd0605041cc97b57f53ee6657bc318b0bfde7b62677 +5d16e3f28364de2d6b6456a6fc56bf604b9106c3ae15719f2862192ae3020cc1 From 726a047a4767ebde16b64a807ca4d9132aa39a5e Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 23 Jan 2025 16:11:24 +0000 Subject: [PATCH 053/115] Remove some now-dead makefile code, rename a var for consistency, and fix a recipe bug introduced in the previous checkin in the bundler-friendly build. FossilOrigin-Name: 0acd4ef3addb311476f4a670be0c4c4a0f3f88b0420886d4c1c3c3027dd51d73 --- ext/wasm/config.make.in | 11 +++-------- ext/wasm/mkwasmbuilds.c | 29 ++++++++++++++++------------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/ext/wasm/config.make.in b/ext/wasm/config.make.in index 3218541b37..f30baac3f1 100644 --- a/ext/wasm/config.make.in +++ b/ext/wasm/config.make.in @@ -4,17 +4,12 @@ bin.emcc = @EMCC_WRAPPER@ bin.wasm-strip = @BIN_WASM_STRIP@ bin.wasm-opt = @BIN_WASM_OPT@ -ifeq (,$(bin.wasm-opt)) - # wasm-opt is an optional optimization step. We install a dummy - # command in its place if it's not available to simplify the make - # recipes which use it. - #bin.wasm-opt = echo "[not wasm-opt]" -endif SHELL := $(bin.bash) -# The following overrides can be activated to test -# various validation in GNUmakefile: +# The following overrides can be uncommented to test various +# validation and if/else branches the makefile code: # #bin.bash := #bin.emcc := #bin.wasm-strip := +#bin.wasm-opt := diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index 27aa3b156f..738885ff34 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -69,7 +69,7 @@ static void mk_prologue(void){ ** name) through $(bin.wasm-opt) */ ps("ifeq (,$(bin.wasm-opt))"); ps("define SQLITE.CALL.WASM-OPT"); - ps("echo 'wasm-opt not available: $(1)'"); + ps("echo 'wasm-opt not available for $(1)'"); ps("endef"); ps("else"); ps("define SQLITE.CALL.WASM-OPT"); @@ -211,7 +211,7 @@ static void mk_lib_mode(const char *zName /* build name */, const char *zJsOut /* name of generated sqlite3.js/.mjs */, const char *zCmppD /* extra -D flags for c-pp */, const char *zEmcc /* extra flags for emcc */){ - const char * zTgtWasmName = "$(basename $@).wasm" + const char * zWasmOut = "$(basename $@).wasm" /* The various targets named X.js or X.mjs (zJsOut) also generate ** X.wasm, and we need that part of the name to perform some ** post-processing after Emscripten generates X.wasm. */; @@ -260,12 +260,12 @@ static void mk_lib_mode(const char *zName /* build name */, 0==strcmp("sqlite3-wasmfs", zName) ? 1 : 0); } pf("\t@chmod -x %s; \\\n" - "\t$(maybe-wasm-strip) %s;\n", - zTgtWasmName, zTgtWasmName); - pf("\t@$(call SQLITE.CALL.WASM-OPT,%s)\n", zTgtWasmName); + "\t\t$(maybe-wasm-strip) %s;\n", + zWasmOut, zWasmOut); + pf("\t@$(call SQLITE.CALL.WASM-OPT,%s)\n", zWasmOut); pf("\t@sed -i -e '/^var _sqlite3.*createExportWrapper/d' %s || exit; \\\n" /* ^^^^^^ reminder: Mac/BSD sed has no -i flag */ - "\techo 'Stripped out createExportWrapper() parts.'\n", + "\t\techo 'Stripped out createExportWrapper() parts.'\n", zJsOut) /* Our JS code installs bindings of each WASM export. The generated Emscripten JS file does the same using its own framework, but we don't use those results and can @@ -273,20 +273,23 @@ static void mk_lib_mode(const char *zName /* build name */, considerably, by stripping them out. */; /* ** The above $(bin.emcc) call will write zJsOut and will create a - ** like-named .wasm file. That .wasm file name gets hard-coded into - ** zJsOut so we need to, for some cases, patch zJsOut to use the - ** name sqlite3.wasm instead. Note that the resulting .wasm file is - ** identical for all builds for which zEmcc is empty. + ** like-named .wasm file (zWasmOut). That .wasm file name gets + ** hard-coded into zJsOut so we need to, for some cases, patch + ** zJsOut to use the name sqlite3.wasm instead. Note that the + ** resulting .wasm file is identical for all builds for which zEmcc + ** is empty. */ if( 0==strcmp("bundler-friendly", zMode) || 0==strcmp("node", zMode) ){ pf("\t@echo 'Patching $@ for %s.wasm...'; \\\n", zName); - pf("\trm -f %s; \\\n", zTgtWasmName); - pf("\tsed -i -e 's/%s-%s.wasm/%s.wasm/g' $@ || exit;\n", + pf("\t\trm -f %s; \\\n", zWasmOut); + pf("\t\tsed -i -e 's/%s-%s.wasm/%s.wasm/g' $@ || exit;\n", /* ^^^^^^ reminder: Mac/BSD sed has no -i flag */ zNM, zName); + pf("\t@ls -la $@\n"); + }else{ + pf("\t@ls -la %s $@\n", zWasmOut); } - pf("\t@ls -la %s $@\n", zTgtWasmName); if( 0!=strcmp("sqlite3-wasmfs", zName) ){ /* The sqlite3-wasmfs build is optional and needs to be invoked ** conditionally using info we don't have here. */ diff --git a/manifest b/manifest index a531e94568..db22f48ef3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initial\ssupport\sfor\spost-processing\swasm\sfiles\swith\swasm-opt\s(if\sit's\savailable).\sThis\scurrently\sshaves\s12kb\soff\sof\sthe\srelease-mode\sbuild\sof\ssqlite3.wasm\sbut\sthere\sare\smany\sdozens\sof\swasm-opt\sflags\sleft\sto\stry. -D 2025-01-23T15:58:01.776 +C Remove\ssome\snow-dead\smakefile\scode,\srename\sa\svar\sfor\sconsistency,\sand\sfix\sa\srecipe\sbug\sintroduced\sin\sthe\sprevious\scheckin\sin\sthe\sbundler-friendly\sbuild. +D 2025-01-23T16:11:24.436 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -659,7 +659,7 @@ F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b5318317 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f F ext/wasm/common/whwasmutil.js d76c69617e95d85ffc9996f7d9d7481df6976dcbd860ecd82bd8c075e3a101ae -F ext/wasm/config.make.in a44a2f9657c80c9ef0f5a462937a7c2f64916c8b99fb0a28b67d37f961997c94 +F ext/wasm/config.make.in 4bc43443f768a61efd43cf995a5e618f58ac9afc0936706014193537d82c41cb F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.js c7b3cca50c55841c381a9ca4f9396e5bbdc6114273d0b10a43e378e32e7be5bf @@ -679,7 +679,7 @@ F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29a F ext/wasm/index.html e4bbffdb3d40eff12b3f9c7abedef91787e2935620b7f8d40f2c774b80ad8fa9 F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 -F ext/wasm/mkwasmbuilds.c 9f4e0527043a20fab98463e455eeaf287e58b01700248b213159b86a6c3fbb5f +F ext/wasm/mkwasmbuilds.c 0c85aef64ac94f903964c046e7d5a291a95afbbc881d2a96b7871e825e1d175c F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0a426a549577b883e2de7cd0605041cc97b57f53ee6657bc318b0bfde7b62677 -R 2d32486992b9b3356e014d934b282b6a +P 5d16e3f28364de2d6b6456a6fc56bf604b9106c3ae15719f2862192ae3020cc1 +R f70ac1b6c598112d9638929ed475c3d8 U stephan -Z edbdf887524cd901e3308cf68c45b681 +Z e841368168cc448b3b9bb4f562d2f5fb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d0f50acaa8..374beb8fa4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d16e3f28364de2d6b6456a6fc56bf604b9106c3ae15719f2862192ae3020cc1 +0acd4ef3addb311476f4a670be0c4c4a0f3f88b0420886d4c1c3c3027dd51d73 From 02e81f72a06964998971059312fe36fc64e9dda8 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 23 Jan 2025 19:44:09 +0000 Subject: [PATCH 054/115] When running wasm-opt, ignore any failure because it will fail for unknown flags and the set of legal flags will change from version to version. Document the size-reduction effect (or non-effect) of a dozen-odd wasm-opt flags and retain those which demonstrate a wasm file size reduction in -Oz builds (our production build mode). Total size savings: roughly 13kb. FossilOrigin-Name: c9dc581e0287e3462ac55f80ca76e7e98d31157022052c892517363c45287a7b --- ext/wasm/mkwasmbuilds.c | 85 ++++++++++++++++++++++++++++++++--------- manifest | 12 +++--- manifest.uuid | 2 +- 3 files changed, 75 insertions(+), 24 deletions(-) diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index 738885ff34..a3c0e4c067 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -65,23 +65,74 @@ static void mk_prologue(void){ ps("# --[extern-][pre/post]-js files."); ps("pre-post-jses.deps.common := $(extern-pre-js.js) $(sqlite3-license-version.js)"); - /* SQLITE.CALL.WASM-OPT = shell code to run $(1) (source wasm file - ** name) through $(bin.wasm-opt) */ - ps("ifeq (,$(bin.wasm-opt))"); - ps("define SQLITE.CALL.WASM-OPT"); - ps("echo 'wasm-opt not available for $(1)'"); - ps("endef"); - ps("else"); - ps("define SQLITE.CALL.WASM-OPT"); - ps("echo -n 'Before wasm-opt:'; ls -l $(1);\\\n" - "\trm -f wasm-opt-tmp.wasm;\\\n" - "\t$(bin.wasm-opt) --enable-bulk-memory-opt --all-features --post-emscripten\\\n" - "\t$(1) -o wasm-opt-tmp.wasm || exit;\\\n" - "\tmv wasm-opt-tmp.wasm $(1); " - "echo -n 'After wasm-opt: '; ls -l $(1)" - ); - ps("endef"); - ps("endif"); + { + /* SQLITE.CALL.WASM-OPT = shell code to run $(1) (source wasm file + ** name) through $(bin.wasm-opt) */ + const char * zOptFlags = + /* + ** Flags for wasm-opt. It has many, many, MANY "passes" options + ** and the ones which appear here were selected solely on the + ** basis of trial and error. + ** + ** All wasm file size savings/costs mentioned below are based on + ** the vanilla build of sqlite3.wasm with -Oz (our shipping + ** configuration). Comments like "saves nothing" may not be + ** technically correct: "nothing" means "some neglible amount." + ** + ** Note that performance gains/losses are _not_ taken into + ** account here: only wasm file size. + */ + "--enable-bulk-memory-opt " /* required */ + "--all-features " /* required */ + "--post-emscripten " /* Saves roughly 12kb */ + "--strip-debug " /* We already wasm-strip, but in + ** case this environment has no + ** wasm-strip... */ + /* + ** The rest are trial-and-error. See wasm-opt --help and search + ** for "Optimization passes" to find the full list. + ** + ** With many flags this gets unusuably slow. + */ + /*"--converge " saves nothing for the options we're using */ + /*"--dce " saves nothing */ + /*"--directize " saves nothing */ + /*"--gsi " no: requires --closed-world flag, which does not + ** sound like something we want. */ + /*"--gufa --gufa-cast-all --gufa-optimizing " costs roughly 2kb */ + /*"--heap-store-optimization " saves nothing */ + /*"--heap2local " saves nothing */ + //"--inlining --inlining-optimizing " costs roughly 3kb */ + "--local-cse " /* saves roughly 1kb */ + /*"--once-reduction " saves nothing */ + /*"--remove-memory-init " presumably a performance tweak */ + /*"--remove-unused-names " saves nothing */ + /*"--safe-heap "*/ + /*"--vacuum " saves nothing */ + ; + ps("ifeq (,$(bin.wasm-opt))"); + ps("define SQLITE.CALL.WASM-OPT"); + ps("echo 'wasm-opt not available for $(1)'"); + ps("endef"); + ps("else"); + ps("define SQLITE.CALL.WASM-OPT"); + pf("echo -n 'Before wasm-opt:'; ls -l $(1);\\\n" + "\trm -f wasm-opt-tmp.wasm;\\\n" + /* It's very likely that the set of wasm-opt flags varies from + ** version to version, so we'll ignore any errors here. */ + "\tif $(bin.wasm-opt) $(1) -o wasm-opt-tmp.wasm \\\n" + "\t\t%s; then \\\n" + "\t\tmv wasm-opt-tmp.wasm $(1); \\\n" + "\t\techo -n 'After wasm-opt: '; \\\n" + "\t\tls -l $(1); \\\n" + "\telse \\\n" + "\t\techo 'WARNING: ignoring wasm-opt failure'; \\\n" + "\tfi\n", + zOptFlags + ); + ps("endef"); + ps("endif"); + } } /* diff --git a/manifest b/manifest index db22f48ef3..7b5514b31f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\snow-dead\smakefile\scode,\srename\sa\svar\sfor\sconsistency,\sand\sfix\sa\srecipe\sbug\sintroduced\sin\sthe\sprevious\scheckin\sin\sthe\sbundler-friendly\sbuild. -D 2025-01-23T16:11:24.436 +C When\srunning\swasm-opt,\signore\sany\sfailure\sbecause\sit\swill\sfail\sfor\sunknown\sflags\sand\sthe\sset\sof\slegal\sflags\swill\schange\sfrom\sversion\sto\sversion.\s\sDocument\sthe\ssize-reduction\seffect\s(or\snon-effect)\sof\sa\sdozen-odd\swasm-opt\sflags\sand\sretain\sthose\swhich\sdemonstrate\sa\swasm\sfile\ssize\sreduction\sin\s-Oz\sbuilds\s(our\sproduction\sbuild\smode).\sTotal\ssize\ssavings:\sroughly\s13kb. +D 2025-01-23T19:44:09.613 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -679,7 +679,7 @@ F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29a F ext/wasm/index.html e4bbffdb3d40eff12b3f9c7abedef91787e2935620b7f8d40f2c774b80ad8fa9 F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 -F ext/wasm/mkwasmbuilds.c 0c85aef64ac94f903964c046e7d5a291a95afbbc881d2a96b7871e825e1d175c +F ext/wasm/mkwasmbuilds.c 1d5ba1e274d0331b2c8549b288ed108f6764674deb3fa7105b0bb0cea6f68cd5 F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5d16e3f28364de2d6b6456a6fc56bf604b9106c3ae15719f2862192ae3020cc1 -R f70ac1b6c598112d9638929ed475c3d8 +P 0acd4ef3addb311476f4a670be0c4c4a0f3f88b0420886d4c1c3c3027dd51d73 +R 1bff543c29d839d27b34bab0c548a658 U stephan -Z e841368168cc448b3b9bb4f562d2f5fb +Z 154b3ea92135b6fb56c35822cc74d582 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 374beb8fa4..780c9d3745 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0acd4ef3addb311476f4a670be0c4c4a0f3f88b0420886d4c1c3c3027dd51d73 +c9dc581e0287e3462ac55f80ca76e7e98d31157022052c892517363c45287a7b From 1519675a1acb02e18edb5014068a70698e670648 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 23 Jan 2025 21:06:59 +0000 Subject: [PATCH 055/115] Fix a possible infinity loop in debugging-printf logic in the query planner. No changes to production code. FossilOrigin-Name: 9a20b94080f5379867530772e081b737ae4cf6b416469dcabb85b8dd819f491f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 7 +++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 7b5514b31f..30ff3f1fd0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\srunning\swasm-opt,\signore\sany\sfailure\sbecause\sit\swill\sfail\sfor\sunknown\sflags\sand\sthe\sset\sof\slegal\sflags\swill\schange\sfrom\sversion\sto\sversion.\s\sDocument\sthe\ssize-reduction\seffect\s(or\snon-effect)\sof\sa\sdozen-odd\swasm-opt\sflags\sand\sretain\sthose\swhich\sdemonstrate\sa\swasm\sfile\ssize\sreduction\sin\s-Oz\sbuilds\s(our\sproduction\sbuild\smode).\sTotal\ssize\ssavings:\sroughly\s13kb. -D 2025-01-23T19:44:09.613 +C Fix\sa\spossible\sinfinity\sloop\sin\sdebugging-printf\slogic\sin\sthe\squery\splanner.\nNo\schanges\sto\sproduction\scode. +D 2025-01-23T21:06:59.817 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 5e74d76b264abcd7e6682e02853756b5d32f543c59fb47bb55a02575b73693ae +F src/where.c 6722991bece039c7094e9e31bb57b9eb155299f01d2209f1378a81c9605ded31 F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0acd4ef3addb311476f4a670be0c4c4a0f3f88b0420886d4c1c3c3027dd51d73 -R 1bff543c29d839d27b34bab0c548a658 -U stephan -Z 154b3ea92135b6fb56c35822cc74d582 +P c9dc581e0287e3462ac55f80ca76e7e98d31157022052c892517363c45287a7b +R fa61ff8d8db6242b1ed2cb7c9f3ef7ec +U drh +Z 2dbdf3625aeab02b475903def004e928 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 780c9d3745..e686eed397 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c9dc581e0287e3462ac55f80ca76e7e98d31157022052c892517363c45287a7b +9a20b94080f5379867530772e081b737ae4cf6b416469dcabb85b8dd819f491f diff --git a/src/where.c b/src/where.c index 0b8e5aceaa..cad66e70bc 100644 --- a/src/where.c +++ b/src/where.c @@ -5838,8 +5838,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ if( sqlite3WhereTrace & 0x02 ){ LogEst rMin, rFloor = 0; int nDone = 0; + int nProgress; sqlite3DebugPrintf("---- after round %d ----\n", iLoop); - while( nDonerCost>rFloor && pTo->rCostrCost; @@ -5855,10 +5857,11 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ sqlite3DebugPrintf("\n"); } nDone++; + nProgress++; } } rFloor = rMin; - } + }while( nDone0 ); } #endif From 07a2e5d1ed4fbfd283c48c7201f2743c5295005a Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 23 Jan 2025 22:23:31 +0000 Subject: [PATCH 056/115] wasm: de-list demo-worker1-promiser-esm.html from the test pages because (per Chrome 131) "Module scripts don't support importScripts()", where "don't" means "they used to but no longer do". FossilOrigin-Name: 4aa025a943a4024094b91f13abfb8945bbbb8334e3ec904dee5315852845bfe1 --- ext/wasm/index-dist.html | 4 ++-- ext/wasm/index.html | 4 ++-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/wasm/index-dist.html b/ext/wasm/index-dist.html index 7b778b0205..47bae3f7a9 100644 --- a/ext/wasm/index-dist.html +++ b/ext/wasm/index-dist.html @@ -97,8 +97,8 @@ wrapper is significantly easier to use, however.
  • demo-worker1-promiser: a demo of the Promise-based wrapper of the Worker1 API.
  • -
  • demo-worker1-promiser-esm: - same as the previous demo except loads the promiser from an ESM module.
  • + diff --git a/ext/wasm/index.html b/ext/wasm/index.html index a3d41f1a9c..5d53b62d48 100644 --- a/ext/wasm/index.html +++ b/ext/wasm/index.html @@ -84,8 +84,8 @@ wrapper is significantly easier to use, however.
  • demo-worker1-promiser: a demo of the Promise-based wrapper of the Worker1 API.
  • -
  • demo-worker1-promiser-esm: - same as the previous demo except loads the promiser from an ESM module.
  • +
  • speedtest1 ports (sqlite3's primary benchmarking tool)... diff --git a/manifest b/manifest index 30ff3f1fd0..16562bac12 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spossible\sinfinity\sloop\sin\sdebugging-printf\slogic\sin\sthe\squery\splanner.\nNo\schanges\sto\sproduction\scode. -D 2025-01-23T21:06:59.817 +C wasm:\sde-list\sdemo-worker1-promiser-esm.html\sfrom\sthe\stest\spages\sbecause\s(per\sChrome\s131)\s"Module\sscripts\sdon't\ssupport\simportScripts()",\swhere\s"don't"\smeans\s"they\sused\sto\sbut\sno\slonger\sdo". +D 2025-01-23T22:23:31.384 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -675,8 +675,8 @@ F ext/wasm/fiddle.make d4969f0322a582c57a22ce3541f10a5b09a609d14eab32891f613f43b F ext/wasm/fiddle/fiddle-worker.js 850e66fce39b89d59e161d1abac43a181a4caa89ddeea162765d660277cd84ce F ext/wasm/fiddle/fiddle.js b444a5646a9aac9f3fc06c53d78af5e1912eb235d69a8e6010723e4eb0e9d4a1 F ext/wasm/fiddle/index.html c79b1741cbeba78f88af0a84cf5ec7de87a909a6a8d10a369b1f4824c66c2088 -F ext/wasm/index-dist.html 564b5ec5669676482c5a25dea9e721d8eafed426ecb155f93d29aeff8507511f -F ext/wasm/index.html e4bbffdb3d40eff12b3f9c7abedef91787e2935620b7f8d40f2c774b80ad8fa9 +F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf188f024b3730 +F ext/wasm/index.html 10ff3ad190aadccb713109fa55a38e5c1f3c2a8cf05cd31783745bab3f184079 F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 F ext/wasm/mkwasmbuilds.c 1d5ba1e274d0331b2c8549b288ed108f6764674deb3fa7105b0bb0cea6f68cd5 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c9dc581e0287e3462ac55f80ca76e7e98d31157022052c892517363c45287a7b -R fa61ff8d8db6242b1ed2cb7c9f3ef7ec -U drh -Z 2dbdf3625aeab02b475903def004e928 +P 9a20b94080f5379867530772e081b737ae4cf6b416469dcabb85b8dd819f491f +R 1263da0640161ebdae6e992388a26d15 +U stephan +Z 4ee9ffdcb199c9538a20ad596279afe3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e686eed397..fe61a8162e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a20b94080f5379867530772e081b737ae4cf6b416469dcabb85b8dd819f491f +4aa025a943a4024094b91f13abfb8945bbbb8334e3ec904dee5315852845bfe1 From c70631623c314bb699f0fab9ba1bd884cef11289 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 24 Jan 2025 08:58:54 +0000 Subject: [PATCH 057/115] Remove extraneous are-we-making-clean guards from the generated wasm build rules, as that guard is set at a higher level. Rename a makefile call()able for consistency. FossilOrigin-Name: 7f9074e2a7ff62bdcf343895e80a51224de62a22afbbf82068ec5fea7eeda0bb --- ext/wasm/GNUmakefile | 43 +++++++++++++++++++++-------------------- ext/wasm/mkwasmbuilds.c | 12 +++++------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 5623965478..3e9621c6d2 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -32,7 +32,8 @@ # # - Emscripten SDK: https://emscripten.org/docs/getting_started/downloads.html # - The bash shell -# - GNU make, GNU sed, GNU awk, GNU grep (all in the $PATH) +# - GNU make, GNU sed, GNU awk, GNU grep (all in the $PATH and without +# a "g" prefix like they have on some non-GNU systems) # - wasm-strip for release builds: https://github.com/WebAssembly/wabt # - InfoZip for 'dist' zip file ######################################################################## @@ -376,7 +377,7 @@ $(bin.stripccomments): $(bin.stripccomments).c $(MAKEFILE) DISTCLEAN_FILES += $(bin.stripccomments) ######################################################################## -# C-PP.FILTER: a $(call)able to transform $(1) to $(2) via: +# SQLITE.CALL.C-PP.FILTER: a $(call)able to transform $(1) to $(2) via: # # ./c-pp -f $(1) -o $(2) $(3) # @@ -406,7 +407,7 @@ DISTCLEAN_FILES += $(bin.stripccomments) # JS/WASM build. They are solely for use with $(bin.c-pp) itself. # # -D... flags which should be included in all invocations should be -# appended to $(C-PP.FILTER.global). +# appended to $(SQLITE.CALL.C-PP.FILTER.global). bin.c-pp := ./c-pp $(bin.c-pp): c-pp.c $(sqlite3.c) $(MAKEFILE) $(CC) -O0 -o $@ c-pp.c $(sqlite3.c) '-DCMPP_DEFAULT_DELIM="//#"' -I$(dir.top) \ @@ -414,20 +415,20 @@ $(bin.c-pp): c-pp.c $(sqlite3.c) $(MAKEFILE) -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_WAL -DSQLITE_THREADSAFE=0 \ -DSQLITE_TEMP_STORE=3 DISTCLEAN_FILES += $(bin.c-pp) -C-PP.FILTER.global ?= +SQLITE.CALL.C-PP.FILTER.global ?= ifeq (1,$(SQLITE_C_IS_SEE)) - C-PP.FILTER.global += -Denable-see + SQLITE.CALL.C-PP.FILTER.global += -Denable-see endif -define C-PP.FILTER +define SQLITE.CALL.C-PP.FILTER # Create $2 from $1 using $(bin.c-pp) # $1 = Input file: c-pp -f $(1).js # $2 = Output file: c-pp -o $(2).js # $3 = optional c-pp -D... flags $(2): $(1) $$(MAKEFILE) $$(bin.c-pp) - $$(bin.c-pp) -f $(1) -o $$@ $(3) $(C-PP.FILTER.global) + $$(bin.c-pp) -f $(1) -o $$@ $(3) $(SQLITE.CALL.C-PP.FILTER.global) #CLEAN_FILES += $(2) endef -# /end C-PP.FILTER +# /end SQLITE.CALL.C-PP.FILTER ######################################################################## # cflags.common = C compiler flags for all builds @@ -908,22 +909,22 @@ sqlite3-worker1-promiser.js := $(dir.dout)/sqlite3-worker1-promiser.js sqlite3-worker1-promiser.mjs := $(dir.dout)/sqlite3-worker1-promiser.mjs sqlite3-worker1-bundler-friendly.mjs := $(dir.dout)/sqlite3-worker1-bundler-friendly.mjs sqlite3-worker1-promiser-bundler-friendly.js := $(dir.dout)/sqlite3-worker1-promiser-bundler-friendly.js -$(eval $(call C-PP.FILTER,$(sqlite3-worker1.js.in),$(sqlite3-worker1.js))) -$(eval $(call C-PP.FILTER,$(sqlite3-worker1.js.in),$(sqlite3-worker1-bundler-friendly.mjs),\ +$(eval $(call SQLITE.CALL.C-PP.FILTER,$(sqlite3-worker1.js.in),$(sqlite3-worker1.js))) +$(eval $(call SQLITE.CALL.C-PP.FILTER,$(sqlite3-worker1.js.in),$(sqlite3-worker1-bundler-friendly.mjs),\ $(c-pp.D.sqlite3-bundler-friendly))) -$(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-promiser.js))) -$(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),\ +$(eval $(call SQLITE.CALL.C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-promiser.js))) +$(eval $(call SQLITE.CALL.C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),\ $(sqlite3-worker1-promiser-bundler-friendly.js),\ $(c-pp.D.sqlite3-bundler-friendly))) -$(eval $(call C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-promiser.mjs),\ +$(eval $(call SQLITE.CALL.C-PP.FILTER,$(sqlite3-worker1-promiser.js.in),$(sqlite3-worker1-promiser.mjs),\ -Dtarget=es6-module -Dtarget=es6-bundler-friendly)) $(sqlite3-bundler-friendly.mjs): $(sqlite3-worker1-bundler-friendly.mjs) \ $(sqlite3-worker1-promiser-bundler-friendly.js) -$(eval $(call C-PP.FILTER,demo-worker1-promiser.c-pp.js,demo-worker1-promiser.js)) -$(eval $(call C-PP.FILTER,demo-worker1-promiser.c-pp.js,demo-worker1-promiser.mjs,\ +$(eval $(call SQLITE.CALL.C-PP.FILTER,demo-worker1-promiser.c-pp.js,demo-worker1-promiser.js)) +$(eval $(call SQLITE.CALL.C-PP.FILTER,demo-worker1-promiser.c-pp.js,demo-worker1-promiser.mjs,\ -Dtarget=es6-module)) -$(eval $(call C-PP.FILTER,demo-worker1-promiser.c-pp.html,demo-worker1-promiser.html)) -$(eval $(call C-PP.FILTER,demo-worker1-promiser.c-pp.html,demo-worker1-promiser-esm.html,\ +$(eval $(call SQLITE.CALL.C-PP.FILTER,demo-worker1-promiser.c-pp.html,demo-worker1-promiser.html)) +$(eval $(call SQLITE.CALL.C-PP.FILTER,demo-worker1-promiser.c-pp.html,demo-worker1-promiser-esm.html,\ -Dtarget=es6-module)) all: $(sqlite3-worker1.js) \ $(sqlite3-worker1-promiser.js) $(sqlite3-worker1-promiser.mjs) @@ -1077,10 +1078,10 @@ all: speedtest1 # tester1.mjs: cases 3 and 4 # # To create those, we filter tester1.c-pp.js with $(bin.c-pp)... -$(eval $(call C-PP.FILTER,tester1.c-pp.js,tester1.js)) -$(eval $(call C-PP.FILTER,tester1.c-pp.js,tester1.mjs,$(c-pp.D.sqlite3-esm))) -$(eval $(call C-PP.FILTER,tester1.c-pp.html,tester1.html)) -$(eval $(call C-PP.FILTER,tester1.c-pp.html,tester1-esm.html,$(c-pp.D.sqlite3-esm))) +$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.js,tester1.js)) +$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.js,tester1.mjs,$(c-pp.D.sqlite3-esm))) +$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.html,tester1.html)) +$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.html,tester1-esm.html,$(c-pp.D.sqlite3-esm))) tester1: tester1.js tester1.mjs tester1.html tester1-esm.html # Note that we do not include $(sqlite3-bundler-friendly.mjs) in this # because bundlers are client-specific. diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index a3c0e4c067..86c98cf9d3 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -153,14 +153,14 @@ static void mk_pre_post(const char *zName /* build name */, zNM, zNM); pf("$(pre-js.js.%s-%s): $(MAKEFILE)\n", zNM); #if 1 - pf("$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s)," + pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s)," "$(c-pp.D.%s-%s)))\n", zNM, zNM); #else /* This part is needed if/when we re-enable the custom ** Module.instantiateModule() impl in api/pre-js.c-pp.js. */ pf("pre-js.js.%s-%s.intermediary := $(dir.tmp)/pre-js.%s-%s.intermediary.js\n", zNM, zNM); - pf("$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s.intermediary)," + pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s.intermediary)," "$(c-pp.D.%s-%s) -Dcustom-Module.instantiateModule))\n", zNM, zNM); pf("$(pre-js.js.%s-%s): $(pre-js.js.%s-%s.intermediary)\n", zNM, zNM); pf("\tcp $(pre-js.js.%s-%s.intermediary) $@\n", zNM); @@ -176,12 +176,12 @@ static void mk_pre_post(const char *zName /* build name */, /* --post-js=... */ pf("post-js.js.%s-%s := $(dir.tmp)/post-js.%s-%s.js\n", zNM, zNM); - pf("$(eval $(call C-PP.FILTER,$(post-js.js.in)," + pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(post-js.js.in)," "$(post-js.js.%s-%s),$(c-pp.D.%s-%s)))\n", zNM, zNM); /* --extern-post-js=... */ pf("extern-post-js.js.%s-%s := $(dir.tmp)/extern-post-js.%s-%s.js\n", zNM, zNM); - pf("$(eval $(call C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.%s-%s)," + pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.%s-%s)," "$(c-pp.D.%s-%s)))\n", zNM, zNM); /* Combine flags for use with emcc... */ @@ -274,14 +274,13 @@ static void mk_lib_mode(const char *zName /* build name */, if( !zEmcc ) zEmcc = ""; pf("%s# Begin build [%s-%s]\n", zBanner, zNM); - pf("ifneq (1,$(MAKING_CLEAN))\n"); pf("$(info Setting up build [%s-%s]: %s)\n", zNM, zJsOut); mk_pre_post(zNM, zCmppD); pf("\nemcc.flags.%s.%s ?=\n", zNM); if( zEmcc[0] ){ pf("emcc.flags.%s.%s += %s\n", zNM, zEmcc); } - pf("$(eval $(call C-PP.FILTER, $(sqlite3-api.js.in), %s, %s))\n", + pf("$(eval $(call SQLITE.CALL.C-PP.FILTER, $(sqlite3-api.js.in), %s, %s))\n", zApiJsOut, zCmppD); /* target zJsOut */ @@ -346,7 +345,6 @@ static void mk_lib_mode(const char *zName /* build name */, ** conditionally using info we don't have here. */ pf("all: %s\n", zJsOut); } - ps("endif\n# ^^^ !$(MAKING_CLEAN)"); pf("# End build [%s-%s]%s", zNM, zBanner); } diff --git a/manifest b/manifest index 16562bac12..90e606e2e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C wasm:\sde-list\sdemo-worker1-promiser-esm.html\sfrom\sthe\stest\spages\sbecause\s(per\sChrome\s131)\s"Module\sscripts\sdon't\ssupport\simportScripts()",\swhere\s"don't"\smeans\s"they\sused\sto\sbut\sno\slonger\sdo". -D 2025-01-23T22:23:31.384 +C Remove\sextraneous\sare-we-making-clean\sguards\sfrom\sthe\sgenerated\swasm\sbuild\srules,\sas\sthat\sguard\sis\sset\sat\sa\shigher\slevel.\sRename\sa\smakefile\scall()able\sfor\sconsistency. +D 2025-01-24T08:58:54.139 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -618,7 +618,7 @@ F ext/session/sqlite3session.c d6f5e3e83b9b0bbc4a8db4837284f0ecc6af5321d4c8e7136 F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 999ea962c098a934daa18e724c53856493adf1e03b3237465a5ee5b6fde28880 +F ext/wasm/GNUmakefile 47f121d057c08ba49443c06c1c51ba2572e3d5d28a06c968cf0b2ccd5878c3d3 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -679,7 +679,7 @@ F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf1 F ext/wasm/index.html 10ff3ad190aadccb713109fa55a38e5c1f3c2a8cf05cd31783745bab3f184079 F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 -F ext/wasm/mkwasmbuilds.c 1d5ba1e274d0331b2c8549b288ed108f6764674deb3fa7105b0bb0cea6f68cd5 +F ext/wasm/mkwasmbuilds.c 7f0dabf715456274bf2df1e9405aa1f658a6134ee3e863ce87b4efde954f73fb F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9a20b94080f5379867530772e081b737ae4cf6b416469dcabb85b8dd819f491f -R 1263da0640161ebdae6e992388a26d15 +P 4aa025a943a4024094b91f13abfb8945bbbb8334e3ec904dee5315852845bfe1 +R 42d46d94722ee7e44271375fb148ccd7 U stephan -Z 4ee9ffdcb199c9538a20ad596279afe3 +Z 819bc68a21feb3b1bb7fc8b14a535d25 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fe61a8162e..effe5e06c0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4aa025a943a4024094b91f13abfb8945bbbb8334e3ec904dee5315852845bfe1 +7f9074e2a7ff62bdcf343895e80a51224de62a22afbbf82068ec5fea7eeda0bb From dfb5f32758e26299a1f5edfa004c3d068a3237cb Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 24 Jan 2025 09:18:19 +0000 Subject: [PATCH 058/115] Update ext/wasm/README.md to reflect simplifications permitted by the current configure script behavior. FossilOrigin-Name: 9abb56c6acb1c84c2df8534ca3ebb2894afd68bc7b8331d4d12611896c576749 --- ext/wasm/README.md | 37 ++++++++++++++++++++++++++++++------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/ext/wasm/README.md b/ext/wasm/README.md index 0c328310d9..3c68755690 100644 --- a/ext/wasm/README.md +++ b/ext/wasm/README.md @@ -29,8 +29,16 @@ $ ./emsdk install latest $ ./emsdk activate latest ``` -The following needs to be run for each shell instance which needs the -`emcc` compiler: +(Sidebar: Emscripten updates can and do _change things_, i.e. _break +things_, so it's considered _required practice_ to test thoroughly +after upgrading it! Our build process makes no guarantees about which +Emscripten version(s) will or won't work, but it's important that +production builds are built using a compatible version. During active +development, the EMSDK is frequently updated, the goal being to keep +sqlite3.wasm working with "the latest" EMSDK) + +The SQLite configure script will search for the EMSDK. One way +to ensure that it finds it is: ``` # Activate PATH and other environment variables in the current terminal: @@ -38,15 +46,27 @@ $ source ./emsdk_env.sh $ which emcc /path/to/emsdk/upstream/emscripten/emcc + +$ ./configure ... ``` -Optionally, add that to your login shell's resource file (`~/.bashrc` -or equivalent). +Optionally, add that `source` part to your login shell's resource file +(`~/.bashrc` or equivalent). -That `env` script needs to be sourced for building this application -from the top of the sqlite3 build tree: +Another way is to pass the EMSDK dir to configure: ``` +$ ./configure --with-emsdk=/path/to/emsdk +``` + +The build tree uses a small wrapper for invoking the `emcc` (the +Emscripten compiler): `tool/emcc.sh` is generated from +`tool/emcc.sh.in` using the EMSDK path found by the configure process. + +With that in place, the most common build approaches are: + +``` +# From the top of the tree: $ make fiddle ``` @@ -57,7 +77,7 @@ $ cd ext/wasm $ make ``` -That will generate the a number of files required for a handful of +Those will generate the a number of files required for a handful of test and demo applications which can be accessed via `index.html`. WASM content cannot, due to XMLHttpRequest security limitations, be loaded if the containing HTML file is opened directly @@ -68,8 +88,11 @@ needs to be served via an HTTP server. For example, using ``` $ cd ext/wasm $ althttpd --enable-sab --max-age 1 --page index.html +# Or, more simply: +$ make httpd ``` + That will open the system's browser and run the index page, from which all of the test and demo applications can be accessed. diff --git a/manifest b/manifest index 90e606e2e4..3ebae6c9f9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sextraneous\sare-we-making-clean\sguards\sfrom\sthe\sgenerated\swasm\sbuild\srules,\sas\sthat\sguard\sis\sset\sat\sa\shigher\slevel.\sRename\sa\smakefile\scall()able\sfor\sconsistency. -D 2025-01-24T08:58:54.139 +C Update\sext/wasm/README.md\sto\sreflect\ssimplifications\spermitted\sby\sthe\scurrent\sconfigure\sscript\sbehavior. +D 2025-01-24T09:18:19.598 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -620,7 +620,7 @@ F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c4 F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c F ext/wasm/GNUmakefile 47f121d057c08ba49443c06c1c51ba2572e3d5d28a06c968cf0b2ccd5878c3d3 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 -F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 +F ext/wasm/README.md 463b41328cf5b286ca910731263337aecb76e7f821e2a96d2bbc78e425eba064 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff F ext/wasm/SQLTester/SQLTester.mjs 66e1adc3d79467b68e3e40614fd42c1a577c7e219ec0985db966eded52a941e5 F ext/wasm/SQLTester/SQLTester.run.mjs 57f2adb33f43f2784abbf8026c1bfd049d8013af1998e7dcb8b50c89ffc332e0 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4aa025a943a4024094b91f13abfb8945bbbb8334e3ec904dee5315852845bfe1 -R 42d46d94722ee7e44271375fb148ccd7 +P 7f9074e2a7ff62bdcf343895e80a51224de62a22afbbf82068ec5fea7eeda0bb +R 9870d8aac6c5ee0536c13705fc8fd884 U stephan -Z 819bc68a21feb3b1bb7fc8b14a535d25 +Z 82e929fd8c92d791a9c756aa05ed50ac # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index effe5e06c0..90b751cd4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f9074e2a7ff62bdcf343895e80a51224de62a22afbbf82068ec5fea7eeda0bb +9abb56c6acb1c84c2df8534ca3ebb2894afd68bc7b8331d4d12611896c576749 From 4331e6bd1d04099fb9e3f3a99f40c46e910c73c6 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 24 Jan 2025 09:21:39 +0000 Subject: [PATCH 059/115] Minor additions to ext/wasm/README.md. FossilOrigin-Name: 85747ea1654c74d330614aa174ede4a989b6456eb1fc5eb0fc9f2d1418b6ef99 --- ext/wasm/README.md | 12 +++++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ext/wasm/README.md b/ext/wasm/README.md index 3c68755690..21330f0eba 100644 --- a/ext/wasm/README.md +++ b/ext/wasm/README.md @@ -35,7 +35,7 @@ after upgrading it! Our build process makes no guarantees about which Emscripten version(s) will or won't work, but it's important that production builds are built using a compatible version. During active development, the EMSDK is frequently updated, the goal being to keep -sqlite3.wasm working with "the latest" EMSDK) +sqlite3.wasm working with "the latest" EMSDK.) The SQLite configure script will search for the EMSDK. One way to ensure that it finds it is: @@ -88,13 +88,15 @@ needs to be served via an HTTP server. For example, using ``` $ cd ext/wasm $ althttpd --enable-sab --max-age 1 --page index.html -# Or, more simply: +# Or, more simply, from the ext/wasm dir: $ make httpd ``` - -That will open the system's browser and run the index page, from which -all of the test and demo applications can be accessed. +That will open the system's browser and visit the index page, from +which (almost) all of the test and demo applications can be accessed. +(`ext/wasm/SQLTester` is not listed in that page because it's only of +real utility when it's used in conjunction with the proprietary test +suite, which most users don't have access to.) Note that when serving this app via [althttpd][], it must be a version from 2022-09-26 or newer so that it recognizes the `--enable-sab` diff --git a/manifest b/manifest index 3ebae6c9f9..c3a2065573 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sext/wasm/README.md\sto\sreflect\ssimplifications\spermitted\sby\sthe\scurrent\sconfigure\sscript\sbehavior. -D 2025-01-24T09:18:19.598 +C Minor\sadditions\sto\sext/wasm/README.md. +D 2025-01-24T09:21:39.150 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -620,7 +620,7 @@ F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c4 F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c F ext/wasm/GNUmakefile 47f121d057c08ba49443c06c1c51ba2572e3d5d28a06c968cf0b2ccd5878c3d3 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 -F ext/wasm/README.md 463b41328cf5b286ca910731263337aecb76e7f821e2a96d2bbc78e425eba064 +F ext/wasm/README.md 6c1dd9e4448c672f4a072c56d3ce9164b3c7dc818ea8f18b49c6834bfd5efe24 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff F ext/wasm/SQLTester/SQLTester.mjs 66e1adc3d79467b68e3e40614fd42c1a577c7e219ec0985db966eded52a941e5 F ext/wasm/SQLTester/SQLTester.run.mjs 57f2adb33f43f2784abbf8026c1bfd049d8013af1998e7dcb8b50c89ffc332e0 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7f9074e2a7ff62bdcf343895e80a51224de62a22afbbf82068ec5fea7eeda0bb -R 9870d8aac6c5ee0536c13705fc8fd884 +P 9abb56c6acb1c84c2df8534ca3ebb2894afd68bc7b8331d4d12611896c576749 +R b60ec68df024b8f8f0b2a3ce728fcf4f U stephan -Z 82e929fd8c92d791a9c756aa05ed50ac +Z e5bd1e0cb1773df371cd520b4807bcb1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 90b751cd4a..3d6d41ac1b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9abb56c6acb1c84c2df8534ca3ebb2894afd68bc7b8331d4d12611896c576749 +85747ea1654c74d330614aa174ede4a989b6456eb1fc5eb0fc9f2d1418b6ef99 From 8bfb18672821e70893a3d2a5ac6c96faf8daf4a2 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 24 Jan 2025 12:54:59 +0000 Subject: [PATCH 060/115] Replace a handful of hard tabs in string literals with \t in mkwasmbuilds.c. FossilOrigin-Name: e8e4d497a7b6aae450cb93927c7583fcce3fe971cd3691f9d9cad605de3cfb1f --- ext/wasm/mkwasmbuilds.c | 18 +++++++++--------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index 86c98cf9d3..1e09f83c01 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -224,23 +224,23 @@ static void mk_fiddle(){ "$(SOAP.js)\n", zTail, (i ? " $(fiddle-module.js)" : "")); if( 1==i ){/*fiddle.debug*/ - pf(" @test -d \"$(dir $@)\" || mkdir -p \"$(dir $@)\"\n"); + pf("\t@test -d \"$(dir $@)\" || mkdir -p \"$(dir $@)\"\n"); } - pf(" $(bin.emcc) -o $@ $(fiddle.emcc-flags%s) " + pf("\t$(bin.emcc) -o $@ $(fiddle.emcc-flags%s) " "$(pre-post-fiddle-module-vanilla.flags) $(fiddle.cses)\n", zTail); - pf(" $(maybe-wasm-strip) $(fiddle-module.wasm%s)\n", zTail); - pf(" @cp -p $(SOAP.js) $(dir $@)\n"); + pf("\t$(maybe-wasm-strip) $(fiddle-module.wasm%s)\n", zTail); + pf("\t@cp -p $(SOAP.js) $(dir $@)\n"); if( 1==i ){/*fiddle.debug*/ - pf(" cp -p $(dir.fiddle)/index.html " + pf("\tcp -p $(dir.fiddle)/index.html " "$(dir.fiddle)/fiddle.js " "$(dir.fiddle)/fiddle-worker.js " "$(dir $@)\n"); } - pf(" @for i in %s/*.*js %s/*.html %s/*.wasm; do \\\n" - " test -f $${i} || continue; \\\n" - " gzip < $${i} > $${i}.gz; \\\n" - " done\n", zDir, zDir, zDir); + pf("\t@for i in %s/*.*js %s/*.html %s/*.wasm; do \\\n" + "\t\ttest -f $${i} || continue; \\\n" + "\t\tgzip < $${i} > $${i}.gz; \\\n" + "\tdone\n", zDir, zDir, zDir); if( 0==i ){ ps("fiddle: $(fiddle-module.js)"); }else{ diff --git a/manifest b/manifest index c3a2065573..85c94391b1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sadditions\sto\sext/wasm/README.md. -D 2025-01-24T09:21:39.150 +C Replace\sa\shandful\sof\shard\stabs\sin\sstring\sliterals\swith\s\\t\sin\smkwasmbuilds.c. +D 2025-01-24T12:54:59.643 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -679,7 +679,7 @@ F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf1 F ext/wasm/index.html 10ff3ad190aadccb713109fa55a38e5c1f3c2a8cf05cd31783745bab3f184079 F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54 F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8 -F ext/wasm/mkwasmbuilds.c 7f0dabf715456274bf2df1e9405aa1f658a6134ee3e863ce87b4efde954f73fb +F ext/wasm/mkwasmbuilds.c d5885bacf2253bed913cdc7eb16b44f9c9e782133e10600652d1a78841c337af F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9abb56c6acb1c84c2df8534ca3ebb2894afd68bc7b8331d4d12611896c576749 -R b60ec68df024b8f8f0b2a3ce728fcf4f +P 85747ea1654c74d330614aa174ede4a989b6456eb1fc5eb0fc9f2d1418b6ef99 +R f289df2f01e608fa0d2578a973e6c703 U stephan -Z e5bd1e0cb1773df371cd520b4807bcb1 +Z 87e6ba9e21ab9593bfe7380a7c7c21ab # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3d6d41ac1b..80506a8ac8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -85747ea1654c74d330614aa174ede4a989b6456eb1fc5eb0fc9f2d1418b6ef99 +e8e4d497a7b6aae450cb93927c7583fcce3fe971cd3691f9d9cad605de3cfb1f From 7a16413a849bf4f28f8aa7a29c27b704c8e64944 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 24 Jan 2025 14:13:20 +0000 Subject: [PATCH 061/115] Update autosetup/README.md to reflect recent refactoring. FossilOrigin-Name: 601636829b79888deda7d4dc5786f82b4f0b302d84663ee96b4d47fcb429abcf --- autosetup/README.md | 36 +++++++++++++++++++++++++++--------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/autosetup/README.md b/autosetup/README.md index fd426d56d9..288ac87c3b 100644 --- a/autosetup/README.md +++ b/autosetup/README.md @@ -33,12 +33,26 @@ $ ./configure --reference | less That will include any docs from any TCL files in the `./autosetup` dir which contain certain (simple) markup defined by autosetup. -This project's own autosetup-related APIs are in [proj.tcl][] or -[auto.def][]. The former contains helper APIs which are, more or -less, portable across projects (that file is re-used as-is in other -projects) and all have a `proj-` name prefix. The latter is the main -configure script driver and contains related functions which are -specific to this tree. +This project's own configuration-related TCL code is spread across the +following files: + +- [proj.tcl][]: project-agnostic utility code for autosetup-driven + projects. This file is designed to be shared between this project, + other projects managed under the SQLite/Hwaci umbrella + (e.g. Fossil), and personal projects of SQLite's developers. It is + essentially an amalgamation of a decade's worth of autosetup-related + utility code. +- [auto.def][]: the primary driver for the `./configure` process. + When we talk about "the configure script," we're referring to + this file. +- [sqlite-config.tcl][]: utility code which is too project-specific + for `proj.tcl`. We split this out of `auto.def` so that it can be + used by both `auto.def` and... +- [autoconf/auto.def][]: the main driver script for the "autoconf" + bundle's configure script. It is essentially a slightly trimmed-down + version of the main `auto.def` file. The `autoconf` dir was ported + from the Autotools to Autosetup in the 3.39 dev cycle but retains + the "autoconf" name to minimize downstream disruption. @@ -47,9 +61,11 @@ Autosetup API Tips This section briefly covers only APIs which are frequently useful in day-to-day maintenance and might not be immediately recognized as such -obvious from a casual perusal of [auto.def][]. The complete docs of -those with `proj-` prefix can be found in [proj.tcl][]. The others are -scattered around [the TCL files in ./autosetup](/dir/autosetup). +obvious from a casual perusal of the relevant TCL files. The complete +docs of those with `proj-` prefix can be found in [proj.tcl][] and +those with an `sqlite-` prefix are in [sqlite-config.tcl][]. The +others are scattered around [the TCL files in +./autosetup](/dir/autosetup). In (mostly) alphabetical order: @@ -331,8 +347,10 @@ If autosetup is upgraded and this patch is _not_ applied the invoking [Autosetup]: https://msteveb.github.io/autosetup/ [auto.def]: /file/auto.def +[autoconf/auto.def]: /file/autoconf/auto.def [autosetup-git]: https://github.com/msteveb/autosetup [proj.tcl]: /file/autosetup/proj.tcl +[sqlite-config.tcl]: /file/autosetup/sqlite-config.tcl [Makefile.in]: /file/Makefile.in [main.mk]: /file/main.mk [JimTCL]: https://jim.tcl.tk diff --git a/manifest b/manifest index 85c94391b1..fc696fccec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Replace\sa\shandful\sof\shard\stabs\sin\sstring\sliterals\swith\s\\t\sin\smkwasmbuilds.c. -D 2025-01-24T12:54:59.643 +C Update\sautosetup/README.md\sto\sreflect\srecent\srefactoring. +D 2025-01-24T14:13:20.824 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -37,7 +37,7 @@ F autoconf/tea/win/rules.vc 94a18c3e453535459b4a643983acca52fb8756e79055bd2ad4b0 F autoconf/tea/win/targets.vc 96a25a1fa6e9e9cfb348fd3760a5395b4ce8acafc8ed10f0412937ec200d5dbd F autosetup/LICENSE 41a26aebdd2cd185d1e2b210f71b7ce234496979f6b35aef2cbf6b80cbed4ce4 F autosetup/README.autosetup a78ff8c4a3d2636a4268736672a74bf14a82f42687fcf0631a70c516075c031e -F autosetup/README.md 1a02f5a94fd460eb7ffc8dea5d6f1657e38ddf8ffa2d6c5dce9a630b97021a69 +F autosetup/README.md 3bd13779b29479c3ff5cab776a2932215d96d05df510ed2035b165338566eb9f F autosetup/autosetup df8b53928b1fe3c67db5bc77c8e1eb8160c1b6a26c370e9a06c68748f803b7e4 x F autosetup/autosetup-config.guess dfa101c5e8220e864d5e9c72a85e87110df60260d36cb951ad0a85d6d9eaa463 x F autosetup/autosetup-config.sub a38fb074d0dece01cf919e9fb534a26011608aa8fa606490864295328526cd73 x @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 85747ea1654c74d330614aa174ede4a989b6456eb1fc5eb0fc9f2d1418b6ef99 -R f289df2f01e608fa0d2578a973e6c703 +P e8e4d497a7b6aae450cb93927c7583fcce3fe971cd3691f9d9cad605de3cfb1f +R cc2c59119834894a1981954ea1b6c946 U stephan -Z 87e6ba9e21ab9593bfe7380a7c7c21ab +Z cd03a612b740dea69fa91e8f1fbec1aa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 80506a8ac8..7c9511a739 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e8e4d497a7b6aae450cb93927c7583fcce3fe971cd3691f9d9cad605de3cfb1f +601636829b79888deda7d4dc5786f82b4f0b302d84663ee96b4d47fcb429abcf From 299fe02393f94ed2905c2b147acea78a066cc95d Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 24 Jan 2025 14:51:15 +0000 Subject: [PATCH 062/115] When looking for star-queries, do not count a table as a dimension table if that table is separated from the fact table by an OUTER or CROSS join or if the table is a self-join. FossilOrigin-Name: 5aebd7df0d577e98b3affd22b84b42dfe84a9f37fa29187505cc245b95460ba4 --- manifest | 15 ++++---- manifest.uuid | 2 +- src/where.c | 99 ++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 89 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 30ff3f1fd0..04cbc622ad 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spossible\sinfinity\sloop\sin\sdebugging-printf\slogic\sin\sthe\squery\splanner.\nNo\schanges\sto\sproduction\scode. -D 2025-01-23T21:06:59.817 +C When\slooking\sfor\sstar-queries,\sdo\snot\scount\sa\stable\sas\sa\sdimension\stable\nif\sthat\stable\sis\sseparated\sfrom\sthe\sfact\stable\sby\san\sOUTER\sor\sCROSS\sjoin\nor\sif\sthe\stable\sis\sa\sself-join. +D 2025-01-24T14:51:15.886 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 6722991bece039c7094e9e31bb57b9eb155299f01d2209f1378a81c9605ded31 +F src/where.c 5112b3f0a27bc9708b26b8dc0a513a38c3f03e58a3ad2a6323aa706d8459d7b7 F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c9dc581e0287e3462ac55f80ca76e7e98d31157022052c892517363c45287a7b -R fa61ff8d8db6242b1ed2cb7c9f3ef7ec +P 9a20b94080f5379867530772e081b737ae4cf6b416469dcabb85b8dd819f491f +R fc36952f8e44ca6141073778b4516171 +T *branch * star-query-heuristic +T *sym-star-query-heuristic * +T -sym-trunk * U drh -Z 2dbdf3625aeab02b475903def004e928 +Z d58ed75293e728cbf22986bd4a983f27 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e686eed397..03fb6a033f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a20b94080f5379867530772e081b737ae4cf6b416469dcabb85b8dd819f491f +5aebd7df0d577e98b3affd22b84b42dfe84a9f37fa29187505cc245b95460ba4 diff --git a/src/where.c b/src/where.c index cad66e70bc..6327f7688e 100644 --- a/src/where.c +++ b/src/where.c @@ -5441,11 +5441,13 @@ static LogEst whereSortingCost( ** 18 for star queries ** 12 otherwise ** -** For the purposes of SQLite, a star-query is defined as a query -** with a large central table that is joined (using an INNER JOIN, -** not a LEFT JOIN) against four or more smaller tables. The central -** table is called the "fact" table. The smaller tables that get -** joined are "dimension tables". +** For the purposes of this heuristic, a star-query is defined as a query +** with a large central table that is joined using an INNER JOIN, +** not CROSS or OUTER JOINs, against four or more smaller tables. +* The central table is called the "fact" table. The smaller tables +** that get joined are "dimension tables". Also, any table that is +** self-joined cannot be a dimension table; we assume that dimension +** tables may only be joined against fact tables. ** ** SIDE EFFECT: (and really the whole point of this subroutine) ** @@ -5456,44 +5458,101 @@ static LogEst whereSortingCost( ** resulting in poor query plans. The total amount of heuristic cost ** adjustment is stored in pWInfo->nOutStarDelta and the cost adjustment ** for each WhereLoop is stored in its rStarDelta field. +** +** This heuristic can be completely disabled, so that no query is +** considered a star-query, using SQLITE_TESTCTRL_OPTIMIZATION to +** disable the SQLITE_StarQuery optimization. In the CLI, the command +** to do that is: ".testctrl opt -starquery". */ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ int nLoop = pWInfo->nLevel; /* Number of terms in the join */ + WhereLoop *pWLoop; /* For looping over WhereLoops */ + +#ifdef SQLITE_DEBUG + /* The star-query detection code below makes use of the following + ** properties of the WhereLoop list, so verifying them before + ** continuing: + ** (1) .maskSelf is the bitmask corresponding to .iTab + ** (2) The WhereLoop list is in ascending .iTab order + */ + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + assert( pWLoop->maskSelf==MASKBIT(pWLoop->iTab) ); + assert( pWLoop->pNextLoop==0 || pWLoop->iTab<=pWLoop->pNextLoop->iTab ); + } +#endif /* SQLITE_DEBUG */ + if( nRowEst==0 && nLoop>=5 && OptimizationEnabled(pWInfo->pParse->db, SQLITE_StarQuery) ){ + SrcItem *aFromTabs; /* All terms of the FROM clause */ + int iFromIdx; /* Term of FROM clause is the candidate fact-table */ + Bitmask m; /* Bitmask for candidate fact-table */ + Bitmask mSelfJoin = 0; /* Tables that cannot be dimension tables */ + WhereLoop *pStart; /* Where to start searching for dimension-tables */ + /* Check to see if we are dealing with a star schema and if so, reduce ** the cost of fact tables relative to dimension tables, as a heuristic ** to help keep the fact tables in outer loops. */ - int iLoop; /* Counter over join terms */ - Bitmask m; /* Bitmask for current loop */ assert( pWInfo->nOutStarDelta==0 ); - for(iLoop=0, m=1; iLooppTabList->a; + pStart = pWInfo->pLoops; + for(iFromIdx=0, m=1; iFromIdxpLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ - if( (pWLoop->prereq & m)!=0 /* pWInfo depends on iLoop */ + SrcItem *pFactTab; /* The candidate fact table */ + + pFactTab = aFromTabs + iFromIdx; + if( (pFactTab->fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){ + /* If the candidate fact-table is the right table of an outer join + ** restrict the search for dimension-tables to be tables to the right + ** of the fact-table. */ + if( iFromIdx+4 > nLoop ) break; /* Impossible to reach nDep>=4 */ + while( ALWAYS(pStart) && pStart->iTab<=iFromIdx ){ + pStart = pStart->pNextLoop; + } + } + for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){ + if( (aFromTabs[pWLoop->iTab].fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){ + /* Fact-tables and dimension-tables cannot be separated by an + ** outer join (at least for the definition of fact- and dimension- + ** used by this heuristic). */ + break; + } + if( (pWLoop->prereq & m)!=0 /* pWInfo depends on iFromIdx */ && (pWLoop->maskSelf & mSeen)==0 /* pWInfo not already a dependency */ - && (pWInfo->pTabList->a[pWLoop->iTab].fg.jointype & JT_LEFT)==0 - /* ^- pWInfo isn't a LEFT JOIN */ + && (pWLoop->maskSelf & mSelfJoin)==0 /* Not a self-join */ ){ - nDep++; - mSeen |= pWLoop->maskSelf; + if( aFromTabs[pWLoop->iTab].pSTab==pFactTab->pSTab ){ + mSelfJoin |= m; + }else{ + nDep++; + mSeen |= pWLoop->maskSelf; + } } } if( nDep<=3 ) continue; rDelta = 15*(nDep-3); #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ - SrcItem *pItem = pWInfo->pTabList->a + iLoop; - sqlite3DebugPrintf( - "Fact-table %s(%d): %d dimensions, cost reduced %d\n", - pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName, iLoop, - nDep, rDelta); + Bitmask x; + int ii; + sqlite3DebugPrintf( + "Fact-table %s(%d): cost reduced %d due to %d dimension tables:", + pFactTab->zAlias ? pFactTab->zAlias : pFactTab->pSTab->zName, + iFromIdx, rDelta, nDep + ); + for(ii=0, x=1; iizAlias ? pDim->zAlias : pDim->pSTab->zName, ii + ); + } + } + sqlite3DebugPrintf("\n"); } #endif if( pWInfo->nOutStarDelta==0 ){ From 7ae051df2a29b834ff049a7159dea11882602858 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 24 Jan 2025 15:41:33 +0000 Subject: [PATCH 063/115] Correct a version number in autosetup/README.md. FossilOrigin-Name: c338caf0fd4adc7baacf20f6d4274b1776b9487a5a976b8d85e490791be82b11 --- autosetup/README.md | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/autosetup/README.md b/autosetup/README.md index 288ac87c3b..19a16c943a 100644 --- a/autosetup/README.md +++ b/autosetup/README.md @@ -51,7 +51,7 @@ following files: - [autoconf/auto.def][]: the main driver script for the "autoconf" bundle's configure script. It is essentially a slightly trimmed-down version of the main `auto.def` file. The `autoconf` dir was ported - from the Autotools to Autosetup in the 3.39 dev cycle but retains + from the Autotools to Autosetup in the 3.49.0 dev cycle but retains the "autoconf" name to minimize downstream disruption. diff --git a/manifest b/manifest index fc696fccec..3b7ea01db7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sautosetup/README.md\sto\sreflect\srecent\srefactoring. -D 2025-01-24T14:13:20.824 +C Correct\sa\sversion\snumber\sin\sautosetup/README.md. +D 2025-01-24T15:41:33.001 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -37,7 +37,7 @@ F autoconf/tea/win/rules.vc 94a18c3e453535459b4a643983acca52fb8756e79055bd2ad4b0 F autoconf/tea/win/targets.vc 96a25a1fa6e9e9cfb348fd3760a5395b4ce8acafc8ed10f0412937ec200d5dbd F autosetup/LICENSE 41a26aebdd2cd185d1e2b210f71b7ce234496979f6b35aef2cbf6b80cbed4ce4 F autosetup/README.autosetup a78ff8c4a3d2636a4268736672a74bf14a82f42687fcf0631a70c516075c031e -F autosetup/README.md 3bd13779b29479c3ff5cab776a2932215d96d05df510ed2035b165338566eb9f +F autosetup/README.md 2737c4eb44b022a694b1f93fb01c3b6c3a45b4f663e18490c2106643a77b39da F autosetup/autosetup df8b53928b1fe3c67db5bc77c8e1eb8160c1b6a26c370e9a06c68748f803b7e4 x F autosetup/autosetup-config.guess dfa101c5e8220e864d5e9c72a85e87110df60260d36cb951ad0a85d6d9eaa463 x F autosetup/autosetup-config.sub a38fb074d0dece01cf919e9fb534a26011608aa8fa606490864295328526cd73 x @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e8e4d497a7b6aae450cb93927c7583fcce3fe971cd3691f9d9cad605de3cfb1f -R cc2c59119834894a1981954ea1b6c946 +P 601636829b79888deda7d4dc5786f82b4f0b302d84663ee96b4d47fcb429abcf +R 7edf0e5d3b3392becf43b655692773e3 U stephan -Z cd03a612b740dea69fa91e8f1fbec1aa +Z 8a4c0606d9fc49f835c4115814c6ca15 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7c9511a739..12aa7b8716 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -601636829b79888deda7d4dc5786f82b4f0b302d84663ee96b4d47fcb429abcf +c338caf0fd4adc7baacf20f6d4274b1776b9487a5a976b8d85e490791be82b11 From f1c5830311d5d9382a89b87184fb9fb5f5db5420 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 24 Jan 2025 15:55:20 +0000 Subject: [PATCH 064/115] Minor tweaks to the star-query detection and processing. FossilOrigin-Name: 61f76a45ac7aa454419fd7539a3d8e60f0733fb5a2abd034d795328f3c1b6e9b --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/where.c | 26 +++++++++++++++----------- src/whereInt.h | 4 ++++ 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 04cbc622ad..a6cc524f90 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\slooking\sfor\sstar-queries,\sdo\snot\scount\sa\stable\sas\sa\sdimension\stable\nif\sthat\stable\sis\sseparated\sfrom\sthe\sfact\stable\sby\san\sOUTER\sor\sCROSS\sjoin\nor\sif\sthe\stable\sis\sa\sself-join. -D 2025-01-24T14:51:15.886 +C Minor\stweaks\sto\sthe\sstar-query\sdetection\sand\sprocessing. +D 2025-01-24T15:55:20.191 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,8 +863,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 5112b3f0a27bc9708b26b8dc0a513a38c3f03e58a3ad2a6323aa706d8459d7b7 -F src/whereInt.h 2b0804f300c7f65de4046a1d81c65f01b208d6c08950ccd1fa6b8c16162a8af7 +F src/where.c 3dacc2fa210fa44a55041ddaa6f89da1626a48017817f196f12ceed52723bba0 +F src/whereInt.h 3b2ef4617758174d00c6940850e4988c1b195d39bcc20f2965319a1f7bffc714 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f F src/window.c 2bf01f9941a64fbcead61a0e3cb5db3fca5094b30d2ff0d23274c2a81d2e2385 @@ -2208,11 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9a20b94080f5379867530772e081b737ae4cf6b416469dcabb85b8dd819f491f -R fc36952f8e44ca6141073778b4516171 -T *branch * star-query-heuristic -T *sym-star-query-heuristic * -T -sym-trunk * +P 5aebd7df0d577e98b3affd22b84b42dfe84a9f37fa29187505cc245b95460ba4 +R f847747d05c8cfe1b5f92bc976034b08 U drh -Z d58ed75293e728cbf22986bd4a983f27 +Z b010436488b72486e8da8913eae9dd55 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 03fb6a033f..f9eccc3e4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5aebd7df0d577e98b3affd22b84b42dfe84a9f37fa29187505cc245b95460ba4 +61f76a45ac7aa454419fd7539a3d8e60f0733fb5a2abd034d795328f3c1b6e9b diff --git a/src/where.c b/src/where.c index 6327f7688e..4fa281c158 100644 --- a/src/where.c +++ b/src/where.c @@ -5464,7 +5464,7 @@ static LogEst whereSortingCost( ** disable the SQLITE_StarQuery optimization. In the CLI, the command ** to do that is: ".testctrl opt -starquery". */ -static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ +static int computeMxChoice(WhereInfo *pWInfo){ int nLoop = pWInfo->nLevel; /* Number of terms in the join */ WhereLoop *pWLoop; /* For looping over WhereLoops */ @@ -5481,8 +5481,8 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ } #endif /* SQLITE_DEBUG */ - if( nRowEst==0 - && nLoop>=5 + if( nLoop>=5 + && !pWInfo->bStarDone && OptimizationEnabled(pWInfo->pParse->db, SQLITE_StarQuery) ){ SrcItem *aFromTabs; /* All terms of the FROM clause */ @@ -5491,6 +5491,8 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ Bitmask mSelfJoin = 0; /* Tables that cannot be dimension tables */ WhereLoop *pStart; /* Where to start searching for dimension-tables */ + pWInfo->bStarDone = 1; /* Only do this computation once */ + /* Check to see if we are dealing with a star schema and if so, reduce ** the cost of fact tables relative to dimension tables, as a heuristic ** to help keep the fact tables in outer loops. @@ -5555,12 +5557,10 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ sqlite3DebugPrintf("\n"); } #endif - if( pWInfo->nOutStarDelta==0 ){ - for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ - pWLoop->rStarDelta = 0; - } + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + pWLoop->rStarDelta = 0; } - pWInfo->nOutStarDelta += rDelta; + pWInfo->nOutStarDelta = rDelta; for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ if( pWLoop->maskSelf==m ){ pWLoop->rRun -= rDelta; @@ -5568,7 +5568,7 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ pWLoop->rStarDelta = rDelta; } } - } + } } return pWInfo->nOutStarDelta>0 ? 18 : 12; } @@ -5646,7 +5646,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ }else if( nLoop==2 ){ mxChoice = 5; }else{ - mxChoice = computeMxChoice(pWInfo, nRowEst); + mxChoice = computeMxChoice(pWInfo); } assert( nLoop<=pWInfo->pTabList->nSrc ); @@ -6015,6 +6015,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ } pWInfo->nRowOut = pFrom->nRow + pWInfo->nOutStarDelta; +#ifdef WHERETRACE_ENABLED + pWInfo->rTotalCost = pFrom->rCost + pWInfo->nOutStarDelta; +#endif /* Free temporary memory and return success */ sqlite3StackFreeNN(pParse->db, pSpace); @@ -6895,7 +6898,8 @@ WhereInfo *sqlite3WhereBegin( assert( db->mallocFailed==0 ); #ifdef WHERETRACE_ENABLED if( sqlite3WhereTrace ){ - sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut); + sqlite3DebugPrintf("---- Solution cost=%d, nRow=%d", + pWInfo->rTotalCost, pWInfo->nRowOut); if( pWInfo->nOBSat>0 ){ sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask); } diff --git a/src/whereInt.h b/src/whereInt.h index f44c040418..5bea70ba9f 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -486,8 +486,12 @@ struct WhereInfo { unsigned untestedTerms :1; /* Not all WHERE terms resolved by outer loop */ unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */ unsigned sorted :1; /* True if really sorted (not just grouped) */ + unsigned bStarDone :1; /* True if check for star-query is complete */ LogEst nOutStarDelta; /* Artifical nOut reduction for star-query */ LogEst nRowOut; /* Estimated number of output rows */ +#ifdef WHERETRACE_ENABLED + LogEst rTotalCost; /* Total cost of the solution */ +#endif int iTop; /* The very beginning of the WHERE loop */ int iEndWhere; /* End of the WHERE clause itself */ WhereLoop *pLoops; /* List of all WhereLoop objects */ From d37412b80c754e4ca1e45d373bb3b3d832662c73 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 24 Jan 2025 16:27:18 +0000 Subject: [PATCH 065/115] The debugging output for WhereLoop objects now shows cost estimate changes due to the star-query heuristic. FossilOrigin-Name: a280f5f5480e560fc2b80e8947d8062e8b3487d930e71cb60fc9ba90d87977c1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 11 +++++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index a6cc524f90..71a6bc9616 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\stweaks\sto\sthe\sstar-query\sdetection\sand\sprocessing. -D 2025-01-24T15:55:20.191 +C The\sdebugging\soutput\sfor\sWhereLoop\sobjects\snow\sshows\scost\nestimate\schanges\sdue\sto\sthe\sstar-query\sheuristic. +D 2025-01-24T16:27:18.228 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 3dacc2fa210fa44a55041ddaa6f89da1626a48017817f196f12ceed52723bba0 +F src/where.c 647dfba23202523c64ca204f3501a09d18670ea081acea680ddcb1e63beda163 F src/whereInt.h 3b2ef4617758174d00c6940850e4988c1b195d39bcc20f2965319a1f7bffc714 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5aebd7df0d577e98b3affd22b84b42dfe84a9f37fa29187505cc245b95460ba4 -R f847747d05c8cfe1b5f92bc976034b08 +P 61f76a45ac7aa454419fd7539a3d8e60f0733fb5a2abd034d795328f3c1b6e9b +R b5fb3d6f32de07f513e6a24731e9896f U drh -Z b010436488b72486e8da8913eae9dd55 +Z 6f36bcae3e1b7a772902eff5e8fa7c2d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f9eccc3e4a..dad04bb867 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -61f76a45ac7aa454419fd7539a3d8e60f0733fb5a2abd034d795328f3c1b6e9b +a280f5f5480e560fc2b80e8947d8062e8b3487d930e71cb60fc9ba90d87977c1 diff --git a/src/where.c b/src/where.c index 4fa281c158..14dc99e5c1 100644 --- a/src/where.c +++ b/src/where.c @@ -2431,8 +2431,9 @@ void sqlite3WhereClausePrint(WhereClause *pWC){ ** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31 */ void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){ + WhereInfo *pWInfo; if( pWC ){ - WhereInfo *pWInfo = pWC->pWInfo; + pWInfo = pWC->pWInfo; int nb = 1+(pWInfo->pTabList->nSrc+3)/4; SrcItem *pItem = pWInfo->pTabList->a + p->iTab; Table *pTab = pItem->pSTab; @@ -2442,6 +2443,7 @@ void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){ sqlite3DebugPrintf(" %12s", pItem->zAlias ? pItem->zAlias : pTab->zName); }else{ + pWInfo = 0; sqlite3DebugPrintf("%c%2d.%03llx.%03llx %c%d", p->cId, p->iTab, p->maskSelf, p->prereq & 0xfff, p->cId, p->iTab); } @@ -2473,7 +2475,12 @@ void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){ }else{ sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm); } - sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut); + if( pWInfo && pWInfo->nOutStarDelta>0 && p->rStarDelta!=0 ){ + sqlite3DebugPrintf(" cost %d,%d,%d delta=%d\n", + p->rSetup, p->rRun, p->nOut, -p->rStarDelta); + }else{ + sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut); + } if( p->nLTerm && (sqlite3WhereTrace & 0x4000)!=0 ){ int i; for(i=0; inLTerm; i++){ From 77731d5ec03b4fecbe615c21bb45e4bc53f64fdf Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 24 Jan 2025 18:37:55 +0000 Subject: [PATCH 066/115] Clarify handling of a NULL for the 2nd argument to sqlite3_serialize(), as pointed out in [forum:3df7168b90|forum post 3df7168b90]. FossilOrigin-Name: 340edbe5540762656b648c18a359ab7039b4a0af15db199fc86317a415e2bafa --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 5 +++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 87f0cf85ca..3bd11a690c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sthe\sstar-query\sheuristic\sso\sthat\sit\sdoes\sa\sbetter\sjob\sof\sidentifying\nactual\sstar\squeries.\s\sAlso\sincludes\simproved\sdiagnostic\soutput\sfrom\sthe\nquery\splanner. -D 2025-01-24T16:37:31.813 +C Clarify\shandling\sof\sa\sNULL\sfor\sthe\s2nd\sargument\sto\ssqlite3_serialize(),\sas\spointed\sout\sin\s[forum:3df7168b90|forum\spost\s3df7168b90]. +D 2025-01-24T18:37:55.155 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -781,7 +781,7 @@ F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 83e88fbb36f89b6703b348777491619554f0fd6f917c9fdf51e4c2e9cda6c04e F src/shell.c.in 9ade75afa953c5c2ded38d076533eaa6c9b2ab1977ef6cce0bc773adac178c50 -F src/sqlite.h.in 6afbcaae44140216704a6c82e4c4ea4118c46d5f6573d6c5fa4fc901ed9d369e +F src/sqlite.h.in 135c4479d03d5dcff7f580c1997f351d94954cf37346db560948c7add6159d9a F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 953f2476f712b115ecb43f7a21183d07c88af8d3b4c32f18317724ce1ce04d56 @@ -2208,9 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c338caf0fd4adc7baacf20f6d4274b1776b9487a5a976b8d85e490791be82b11 a280f5f5480e560fc2b80e8947d8062e8b3487d930e71cb60fc9ba90d87977c1 -R 7125d6757cc5225f643dd2f0408b79ed -T +closed a280f5f5480e560fc2b80e8947d8062e8b3487d930e71cb60fc9ba90d87977c1 -U drh -Z f818ed71ad97105ec5c66c8cb2f2a934 +P 7cfbe14d199bb631abd4d009698eeaee9b8450d5061ded612095ee4738ac6a1f +R d95198c99c03bf1086d509885c532867 +U stephan +Z 8d7df02ae4ad22d5b811a7e9945d57db # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 38a6c8e782..de6b6e3649 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7cfbe14d199bb631abd4d009698eeaee9b8450d5061ded612095ee4738ac6a1f +340edbe5540762656b648c18a359ab7039b4a0af15db199fc86317a415e2bafa diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9a117fa54e..b6863b30fa 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -10748,8 +10748,9 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb); /* ** CAPI3REF: Serialize a database ** -** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory -** that is a serialization of the S database on [database connection] D. +** The sqlite3_serialize(D,S,P,F) interface returns a pointer to +** memory that is a serialization of the S database on [database +** connection] D. If S is a NULL pointer, the main database is used. ** If P is not a NULL pointer, then the size of the database in bytes ** is written into *P. ** From bc7e41c03c9009c96cf3f1179ba0545ba3561abe Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 24 Jan 2025 20:59:12 +0000 Subject: [PATCH 067/115] Remove an incorrect ALWAYS() added in check-in [7cfbe14d199bb631]. FossilOrigin-Name: 431a1a29f93dc642779dc21c3a0edad5fcda1d175e9d1e3b216fa02c234fe774 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 3bd11a690c..0784f8fab1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clarify\shandling\sof\sa\sNULL\sfor\sthe\s2nd\sargument\sto\ssqlite3_serialize(),\sas\spointed\sout\sin\s[forum:3df7168b90|forum\spost\s3df7168b90]. -D 2025-01-24T18:37:55.155 +C Remove\san\sincorrect\sALWAYS()\sadded\sin\scheck-in\s[7cfbe14d199bb631]. +D 2025-01-24T20:59:12.630 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 647dfba23202523c64ca204f3501a09d18670ea081acea680ddcb1e63beda163 +F src/where.c e1bd86a1f86e8713e571928db044e786d6ca99033a1642f054275cd9c4192b6c F src/whereInt.h 3b2ef4617758174d00c6940850e4988c1b195d39bcc20f2965319a1f7bffc714 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7cfbe14d199bb631abd4d009698eeaee9b8450d5061ded612095ee4738ac6a1f -R d95198c99c03bf1086d509885c532867 -U stephan -Z 8d7df02ae4ad22d5b811a7e9945d57db +P 340edbe5540762656b648c18a359ab7039b4a0af15db199fc86317a415e2bafa +R 6b5e2e687d0ef7732e967617df5d4d35 +U drh +Z e079a1f3d11224b9203a1e2c133626d6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index de6b6e3649..2a7fb17f5d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -340edbe5540762656b648c18a359ab7039b4a0af15db199fc86317a415e2bafa +431a1a29f93dc642779dc21c3a0edad5fcda1d175e9d1e3b216fa02c234fe774 diff --git a/src/where.c b/src/where.c index 14dc99e5c1..eeea2e13d0 100644 --- a/src/where.c +++ b/src/where.c @@ -5519,7 +5519,7 @@ static int computeMxChoice(WhereInfo *pWInfo){ ** restrict the search for dimension-tables to be tables to the right ** of the fact-table. */ if( iFromIdx+4 > nLoop ) break; /* Impossible to reach nDep>=4 */ - while( ALWAYS(pStart) && pStart->iTab<=iFromIdx ){ + while( pStart && pStart->iTab<=iFromIdx ){ pStart = pStart->pNextLoop; } } From dea434ea6513a3f91bf15ce4106db0c54a9d6161 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 25 Jan 2025 00:07:14 +0000 Subject: [PATCH 068/115] Avoid calling computeMxChoice() after an OOM as some assert()s can fail in that routine if a prior OOM occurred while building the WhereLoop array. FossilOrigin-Name: 8b9e621dbf599d7e75e07d75d4c400247d693ea76e00eba0919f4e33e3e10bdd --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 0784f8fab1..ec0df49442 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sincorrect\sALWAYS()\sadded\sin\scheck-in\s[7cfbe14d199bb631]. -D 2025-01-24T20:59:12.630 +C Avoid\scalling\scomputeMxChoice()\safter\san\sOOM\sas\ssome\sassert()s\scan\sfail\nin\sthat\sroutine\sif\sa\sprior\sOOM\soccurred\swhile\sbuilding\sthe\sWhereLoop\sarray. +D 2025-01-25T00:07:14.255 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c e1bd86a1f86e8713e571928db044e786d6ca99033a1642f054275cd9c4192b6c +F src/where.c 75427197cc4a6251f7e643c27512a846593a8fc349381ca210b8e1c5b87c5fdb F src/whereInt.h 3b2ef4617758174d00c6940850e4988c1b195d39bcc20f2965319a1f7bffc714 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 340edbe5540762656b648c18a359ab7039b4a0af15db199fc86317a415e2bafa -R 6b5e2e687d0ef7732e967617df5d4d35 +P 431a1a29f93dc642779dc21c3a0edad5fcda1d175e9d1e3b216fa02c234fe774 +R 5b1c7e21f9360cd4e11f23b85175a095 U drh -Z e079a1f3d11224b9203a1e2c133626d6 +Z 397108c3fd80a1eae2be914e45c3c459 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2a7fb17f5d..848e01e8a7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -431a1a29f93dc642779dc21c3a0edad5fcda1d175e9d1e3b216fa02c234fe774 +8b9e621dbf599d7e75e07d75d4c400247d693ea76e00eba0919f4e33e3e10bdd diff --git a/src/where.c b/src/where.c index eeea2e13d0..24674f91df 100644 --- a/src/where.c +++ b/src/where.c @@ -5652,6 +5652,8 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ mxChoice = 1; }else if( nLoop==2 ){ mxChoice = 5; + }else if( pParse->nErr ){ + mxChoice = 1; }else{ mxChoice = computeMxChoice(pWInfo); } From 0186ee1cd742a78f8b98fd1ec7e197aaf8f1c2f8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 25 Jan 2025 14:30:36 +0000 Subject: [PATCH 069/115] Improvments to debug output on the star-query heuristic. FossilOrigin-Name: b3ebeb0682a2c837987acf4ed92f06cf91aea235830c5a0f9dd1ce64afe16e84 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 4 +++- src/where.c | 22 +++++++++++++++++----- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index ec0df49442..b407f7242e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\scalling\scomputeMxChoice()\safter\san\sOOM\sas\ssome\sassert()s\scan\sfail\nin\sthat\sroutine\sif\sa\sprior\sOOM\soccurred\swhile\sbuilding\sthe\sWhereLoop\sarray. -D 2025-01-25T00:07:14.255 +C Improvments\sto\sdebug\soutput\son\sthe\sstar-query\sheuristic. +D 2025-01-25T14:30:36.057 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -784,7 +784,7 @@ F src/shell.c.in 9ade75afa953c5c2ded38d076533eaa6c9b2ab1977ef6cce0bc773adac178c5 F src/sqlite.h.in 135c4479d03d5dcff7f580c1997f351d94954cf37346db560948c7add6159d9a F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 953f2476f712b115ecb43f7a21183d07c88af8d3b4c32f18317724ce1ce04d56 +F src/sqliteInt.h e28d3ad85c671effec0892f156e1e0f949733fb0995335406b5ec3803faba3a4 F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 75427197cc4a6251f7e643c27512a846593a8fc349381ca210b8e1c5b87c5fdb +F src/where.c 8fb5ce22e5fbc82f8e53a059e76ff492113f3de8ff26c3639d52c75e94088596 F src/whereInt.h 3b2ef4617758174d00c6940850e4988c1b195d39bcc20f2965319a1f7bffc714 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 431a1a29f93dc642779dc21c3a0edad5fcda1d175e9d1e3b216fa02c234fe774 -R 5b1c7e21f9360cd4e11f23b85175a095 +P 8b9e621dbf599d7e75e07d75d4c400247d693ea76e00eba0919f4e33e3e10bdd +R e6dd9f24405ca06acecad76b774b4e57 U drh -Z 397108c3fd80a1eae2be914e45c3c459 +Z 5c57dd71c02ea0fa33cecfe1d8ec4eed # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 848e01e8a7..a25e3e3f14 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b9e621dbf599d7e75e07d75d4c400247d693ea76e00eba0919f4e33e3e10bdd +b3ebeb0682a2c837987acf4ed92f06cf91aea235830c5a0f9dd1ce64afe16e84 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 3045d7c4a5..d29b2e3930 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1151,7 +1151,7 @@ extern u32 sqlite3WhereTrace; ** 0xFFFF---- Low-level debug messages ** ** 0x00000001 Code generation -** 0x00000002 Solver +** 0x00000002 Solver (Use 0x40000 for less detail) ** 0x00000004 Solver costs ** 0x00000008 WhereLoop inserts ** @@ -1170,6 +1170,8 @@ extern u32 sqlite3WhereTrace; ** ** 0x00010000 Show more detail when printing WHERE terms ** 0x00020000 Show WHERE terms returned from whereScanNext() +** 0x00040000 Solver overview messages +** 0x00080000 Star-query heuristic */ diff --git a/src/where.c b/src/where.c index 24674f91df..d25a1723d3 100644 --- a/src/where.c +++ b/src/where.c @@ -5544,8 +5544,8 @@ static int computeMxChoice(WhereInfo *pWInfo){ } if( nDep<=3 ) continue; rDelta = 15*(nDep-3); -#ifdef WHERETRACE_ENABLED /* 0x4 */ - if( sqlite3WhereTrace&0x4 ){ +#ifdef WHERETRACE_ENABLED /* 0x80000 */ + if( sqlite3WhereTrace & 0x80000 ){ Bitmask x; int ii; sqlite3DebugPrintf( @@ -5564,10 +5564,12 @@ static int computeMxChoice(WhereInfo *pWInfo){ sqlite3DebugPrintf("\n"); } #endif - for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ - pWLoop->rStarDelta = 0; + if( pWInfo->nOutStarDelta==0 ){ + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + pWLoop->rStarDelta = 0; + } } - pWInfo->nOutStarDelta = rDelta; + pWInfo->nOutStarDelta += rDelta; for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ if( pWLoop->maskSelf==m ){ pWLoop->rRun -= rDelta; @@ -5576,6 +5578,16 @@ static int computeMxChoice(WhereInfo *pWInfo){ } } } +#ifdef WHERETRACE_ENABLED /* 0x80000 */ + if( (sqlite3WhereTrace & 0x80000)!=0 && pWInfo->nOutStarDelta ){ + sqlite3DebugPrintf("WhereLoops changed by star-query heuristic:\n"); + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + if( pWLoop->rStarDelta ){ + sqlite3WhereLoopPrint(pWLoop, &pWInfo->sWC); + } + } + } +#endif } return pWInfo->nOutStarDelta>0 ? 18 : 12; } From fb9e8e48fd70b463fb7ba6d99e00f2be54df749e Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 25 Jan 2025 23:04:05 +0000 Subject: [PATCH 070/115] Revise the strategy used by the star-query heuristic: Instead of decreasing the cost of all fact-table WhereLoops, increase the run-cost of WhereLoops that are SCANs of dimension tables. FossilOrigin-Name: 1bc09c9e8bd77ac41ecbe510c7e003757fc11d0f586da6cdf3584315aa9d6407 --- manifest | 14 ++++---- manifest.uuid | 2 +- src/where.c | 87 ++++++++++++++++++++++++++------------------------ src/whereInt.h | 4 +-- 4 files changed, 55 insertions(+), 52 deletions(-) diff --git a/manifest b/manifest index b407f7242e..c6113e84a4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvments\sto\sdebug\soutput\son\sthe\sstar-query\sheuristic. -D 2025-01-25T14:30:36.057 +C Revise\sthe\sstrategy\sused\sby\sthe\sstar-query\sheuristic:\s\sInstead\sof\sdecreasing\nthe\scost\sof\sall\sfact-table\sWhereLoops,\sincrease\sthe\srun-cost\sof\sWhereLoops\sthat\nare\sSCANs\sof\sdimension\stables. +D 2025-01-25T23:04:05.646 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,8 +863,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 8fb5ce22e5fbc82f8e53a059e76ff492113f3de8ff26c3639d52c75e94088596 -F src/whereInt.h 3b2ef4617758174d00c6940850e4988c1b195d39bcc20f2965319a1f7bffc714 +F src/where.c 3917a56c85951be386057ee4e9af8a6746427f6f26e8ffce293a61e334b76498 +F src/whereInt.h 510b12f85a763602a1b1e70a9cc643a73082a63cda2ca204dd912daaa540115d F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f F src/window.c 2bf01f9941a64fbcead61a0e3cb5db3fca5094b30d2ff0d23274c2a81d2e2385 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8b9e621dbf599d7e75e07d75d4c400247d693ea76e00eba0919f4e33e3e10bdd -R e6dd9f24405ca06acecad76b774b4e57 +P b3ebeb0682a2c837987acf4ed92f06cf91aea235830c5a0f9dd1ce64afe16e84 +R a3d46d3d0d804ef5b7f52b211e4f3855 U drh -Z 5c57dd71c02ea0fa33cecfe1d8ec4eed +Z 01bfb692a509c7bcf6c556a6b5d760a5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a25e3e3f14..29b013c9fc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b3ebeb0682a2c837987acf4ed92f06cf91aea235830c5a0f9dd1ce64afe16e84 +1bc09c9e8bd77ac41ecbe510c7e003757fc11d0f586da6cdf3584315aa9d6407 diff --git a/src/where.c b/src/where.c index d25a1723d3..0db7cbc1e2 100644 --- a/src/where.c +++ b/src/where.c @@ -2475,9 +2475,9 @@ void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){ }else{ sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm); } - if( pWInfo && pWInfo->nOutStarDelta>0 && p->rStarDelta!=0 ){ + if( pWInfo && pWInfo->bStarUsed && p->rStarDelta!=0 ){ sqlite3DebugPrintf(" cost %d,%d,%d delta=%d\n", - p->rSetup, p->rRun, p->nOut, -p->rStarDelta); + p->rSetup, p->rRun, p->nOut, p->rStarDelta); }else{ sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut); } @@ -5458,13 +5458,13 @@ static LogEst whereSortingCost( ** ** SIDE EFFECT: (and really the whole point of this subroutine) ** -** If pWInfo describes a star-query, then the cost on WhereLoops for the -** fact table is reduced. This heuristic helps keep fact tables in +** If pWInfo describes a star-query, then the cost for SCANs of dimension +** WhereLoops is increased to be slightly larger than the cost of a SCAN +** in the fact table. This heuristic helps keep fact tables in ** outer loops. Without this heuristic, paths with fact tables in outer ** loops tend to get pruned by the mxChoice limit on the number of paths, -** resulting in poor query plans. The total amount of heuristic cost -** adjustment is stored in pWInfo->nOutStarDelta and the cost adjustment -** for each WhereLoop is stored in its rStarDelta field. +** resulting in poor query plans. The cost adjustment for each WhereLoop +** is stored in its rStarDelta field. ** ** This heuristic can be completely disabled, so that no query is ** considered a star-query, using SQLITE_TESTCTRL_OPTIMIZATION to @@ -5488,7 +5488,7 @@ static int computeMxChoice(WhereInfo *pWInfo){ } #endif /* SQLITE_DEBUG */ - if( nLoop>=5 + if( nLoop>=5 && !pWInfo->bStarDone && OptimizationEnabled(pWInfo->pParse->db, SQLITE_StarQuery) ){ @@ -5504,12 +5504,12 @@ static int computeMxChoice(WhereInfo *pWInfo){ ** the cost of fact tables relative to dimension tables, as a heuristic ** to help keep the fact tables in outer loops. */ - assert( pWInfo->nOutStarDelta==0 ); + assert( !pWInfo->bStarUsed ); aFromTabs = pWInfo->pTabList->a; pStart = pWInfo->pLoops; for(iFromIdx=0, m=1; iFromIdxzAlias ? pFactTab->zAlias : pFactTab->pSTab->zName, - iFromIdx, rDelta, nDep - ); - for(ii=0, x=1; iizAlias ? pDim->zAlias : pDim->pSTab->zName, ii - ); - } - } - sqlite3DebugPrintf("\n"); + + /* Compute the maximum cost of any WhereLoop for the iFromIdx-th term */ + mxRun = -32767; + for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){ + if( pWLoop->iTabiTab>iFromIdx ) break; + if( pWLoop->rRun>mxRun ) mxRun = pWLoop->rRun; } -#endif - if( pWInfo->nOutStarDelta==0 ){ + + /* Make sure rStarDelta values are initialized */ + if( !pWInfo->bStarUsed ){ for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ pWLoop->rStarDelta = 0; } + pWInfo->bStarUsed = 1; } - pWInfo->nOutStarDelta += rDelta; - for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ - if( pWLoop->maskSelf==m ){ - pWLoop->rRun -= rDelta; - pWLoop->nOut -= rDelta; - pWLoop->rStarDelta = rDelta; + + /* Increase the cost of table scans for dimension tables to be slightly + ** more than the maximum cost of fact table */ + for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){ + if( (pWLoop->maskSelf & mSeen)==0 ) continue; + if( pWLoop->nLTerm ) continue; + if( pWLoop->rRun<=mxRun ){ +#ifdef WHERETRACE_ENABLED /* 0x80000 */ + if( sqlite3WhereTrace & 0x80000 ){ + SrcItem *pDim = aFromTabs + pWLoop->iTab; + sqlite3DebugPrintf( + "Increase SCAN cost of dimension %s(%d) of fact %s(%d) to %d\n", + pDim->zAlias ? pDim->zAlias: pDim->pSTab->zName, pWLoop->iTab, + pFactTab->zAlias ? pFactTab->zAlias : pFactTab->pSTab->zName, + iFromIdx, mxRun+1 + ); + } +#endif /* WHERETRACE_ENABLED */ + pWLoop->rStarDelta = mxRun+1 - pWLoop->rRun; + pWLoop->rRun = mxRun+1; } } } #ifdef WHERETRACE_ENABLED /* 0x80000 */ - if( (sqlite3WhereTrace & 0x80000)!=0 && pWInfo->nOutStarDelta ){ + if( (sqlite3WhereTrace & 0x80000)!=0 && pWInfo->bStarUsed ){ sqlite3DebugPrintf("WhereLoops changed by star-query heuristic:\n"); for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ if( pWLoop->rStarDelta ){ @@ -5589,7 +5593,7 @@ static int computeMxChoice(WhereInfo *pWInfo){ } #endif } - return pWInfo->nOutStarDelta>0 ? 18 : 12; + return pWInfo->bStarUsed ? 18 : 12; } /* @@ -6035,9 +6039,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ } } - pWInfo->nRowOut = pFrom->nRow + pWInfo->nOutStarDelta; + pWInfo->nRowOut = pFrom->nRow; #ifdef WHERETRACE_ENABLED - pWInfo->rTotalCost = pFrom->rCost + pWInfo->nOutStarDelta; + pWInfo->rTotalCost = pFrom->rCost; #endif /* Free temporary memory and return success */ @@ -6436,7 +6440,6 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful( } } nSearch += pLoop->nOut; - if( pWInfo->nOutStarDelta ) nSearch += pLoop->rStarDelta; } } diff --git a/src/whereInt.h b/src/whereInt.h index 5bea70ba9f..35bfe581dd 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -163,7 +163,7 @@ struct WhereLoop { # define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot) u16 nLSlot; /* Number of slots allocated for aLTerm[] */ LogEst rStarDelta; /* Cost delta due to star-schema heuristic. Not - ** initialized unless pWInfo->nOutStarDelta>0 */ + ** initialized unless pWInfo->bStarUsed */ WhereTerm **aLTerm; /* WhereTerms used */ WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */ WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */ @@ -487,7 +487,7 @@ struct WhereInfo { unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */ unsigned sorted :1; /* True if really sorted (not just grouped) */ unsigned bStarDone :1; /* True if check for star-query is complete */ - LogEst nOutStarDelta; /* Artifical nOut reduction for star-query */ + unsigned bStarUsed :1; /* True if cost adjustments for star-query */ LogEst nRowOut; /* Estimated number of output rows */ #ifdef WHERETRACE_ENABLED LogEst rTotalCost; /* Total cost of the solution */ From fe54b7a1f442a4c5b1a23fe83821adbe04b782cf Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 26 Jan 2025 17:29:33 +0000 Subject: [PATCH 071/115] Small size and complexity reduction on the star-query heuristic. Improved comments for the star-query heuristic. FossilOrigin-Name: a7ecb2f4b7eee78b88f1b2e026dffed2007ca4ffeb152632624ab2582839b250 --- manifest | 18 +++++------ manifest.uuid | 2 +- src/sqliteInt.h | 2 ++ src/where.c | 73 +++++++++++++++++++++++++++++-------------- src/whereInt.h | 6 ++-- test/starschema1.test | 2 +- 6 files changed, 66 insertions(+), 37 deletions(-) diff --git a/manifest b/manifest index c6113e84a4..e2dc85219e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revise\sthe\sstrategy\sused\sby\sthe\sstar-query\sheuristic:\s\sInstead\sof\sdecreasing\nthe\scost\sof\sall\sfact-table\sWhereLoops,\sincrease\sthe\srun-cost\sof\sWhereLoops\sthat\nare\sSCANs\sof\sdimension\stables. -D 2025-01-25T23:04:05.646 +C Small\ssize\sand\scomplexity\sreduction\son\sthe\sstar-query\sheuristic.\s\sImproved\ncomments\sfor\sthe\sstar-query\sheuristic. +D 2025-01-26T17:29:33.018 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -784,7 +784,7 @@ F src/shell.c.in 9ade75afa953c5c2ded38d076533eaa6c9b2ab1977ef6cce0bc773adac178c5 F src/sqlite.h.in 135c4479d03d5dcff7f580c1997f351d94954cf37346db560948c7add6159d9a F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h e28d3ad85c671effec0892f156e1e0f949733fb0995335406b5ec3803faba3a4 +F src/sqliteInt.h 5c859fc5b1b9fa489bc7a39d37606472b70f808f965eab11c24f14d8d7654330 F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -863,8 +863,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 3917a56c85951be386057ee4e9af8a6746427f6f26e8ffce293a61e334b76498 -F src/whereInt.h 510b12f85a763602a1b1e70a9cc643a73082a63cda2ca204dd912daaa540115d +F src/where.c adda3afc98a4f58713973997c699be2a8515c591701092e8380695f1a0a7b220 +F src/whereInt.h d20cddddb1d61b18d5cb1fcfa9b77fbeebbc4afe44d996e603452a23b3009ee1 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f F src/window.c 2bf01f9941a64fbcead61a0e3cb5db3fca5094b30d2ff0d23274c2a81d2e2385 @@ -1688,7 +1688,7 @@ F test/spellfix4.test 51c7c26514ade169855c66bcf130bd5acfb4d7fd090cc624645ab275ae F test/sqldiff1.test 1b7ab4f312442c5cc6b3a5f299fa8ca051416d1dd173cb1126fd51bf64f2c3fb F test/sqllimits1.test 408131e4975d61868711c83f101a56d4602313cc5cae88d3eee81c1da364fd89 F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a -F test/starschema1.test a84205f97fe278a015ac39546c86b97228d22043af28f3a2ef809e8d5637ce1d +F test/starschema1.test f5388cd32527ab18d3f98f9e3402ec780f6a186e04e0d9c8531d7568ee734e11 F test/startup.c 1beb5ca66fcc0fce95c3444db9d1674f90fc605499a574ae2434dcfc10d22805 F test/stat.test 123212a20ceb496893d5254a5f6c76442ce549fdc08d1702d8288a2bbaac8408 F test/statfault.test 064f43379e4992b5221b7d9ac887c313b3191f85cce605d78e416fc4045da64e @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b3ebeb0682a2c837987acf4ed92f06cf91aea235830c5a0f9dd1ce64afe16e84 -R a3d46d3d0d804ef5b7f52b211e4f3855 +P 1bc09c9e8bd77ac41ecbe510c7e003757fc11d0f586da6cdf3584315aa9d6407 +R c0f75689e724495cafe203db572d7b59 U drh -Z 01bfb692a509c7bcf6c556a6b5d760a5 +Z 5884f43bd01d477b04985ecdd4572f42 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 29b013c9fc..22688c5390 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1bc09c9e8bd77ac41ecbe510c7e003757fc11d0f586da6cdf3584315aa9d6407 +a7ecb2f4b7eee78b88f1b2e026dffed2007ca4ffeb152632624ab2582839b250 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index d29b2e3930..205f8f3e0e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -881,6 +881,8 @@ typedef u64 tRowcnt; ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40 */ typedef INT16_TYPE LogEst; +#define LOGEST_MIN (-32768) +#define LOGEST_MAX (32767) /* ** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer diff --git a/src/where.c b/src/where.c index 0db7cbc1e2..01f8ff0d9a 100644 --- a/src/where.c +++ b/src/where.c @@ -5451,7 +5451,7 @@ static LogEst whereSortingCost( ** For the purposes of this heuristic, a star-query is defined as a query ** with a large central table that is joined using an INNER JOIN, ** not CROSS or OUTER JOINs, against four or more smaller tables. -* The central table is called the "fact" table. The smaller tables +** The central table is called the "fact" table. The smaller tables ** that get joined are "dimension tables". Also, any table that is ** self-joined cannot be a dimension table; we assume that dimension ** tables may only be joined against fact tables. @@ -5460,16 +5460,35 @@ static LogEst whereSortingCost( ** ** If pWInfo describes a star-query, then the cost for SCANs of dimension ** WhereLoops is increased to be slightly larger than the cost of a SCAN -** in the fact table. This heuristic helps keep fact tables in -** outer loops. Without this heuristic, paths with fact tables in outer -** loops tend to get pruned by the mxChoice limit on the number of paths, -** resulting in poor query plans. The cost adjustment for each WhereLoop -** is stored in its rStarDelta field. +** in the fact table. Only SCAN costs are increased. SEARCH costs are +** unchanged. This heuristic helps keep fact tables in outer loops. Without +** this heuristic, paths with fact tables in outer loops tend to get pruned +** by the mxChoice limit on the number of paths, resulting in poor query +** plans. See the starschema1.test test module for examples of queries +** that need this heuristic to find good query plans. ** ** This heuristic can be completely disabled, so that no query is ** considered a star-query, using SQLITE_TESTCTRL_OPTIMIZATION to ** disable the SQLITE_StarQuery optimization. In the CLI, the command ** to do that is: ".testctrl opt -starquery". +** +** HISTORICAL NOTES: +** +** This optimization was first added on 2024-05-09 by check-in 38db9b5c83d. +** The original optimization reduced the cost and output size estimate for +** fact tables to help them move to outer loops. But months later (as people +** started upgrading) performance regression reports started caming in, +** including: +** +** forum post b18ef983e68d06d1 (2024-12-21) +** forum post 0025389d0860af82 (2025-01-14) +** forum post d87570a145599033 (2025-01-17) +** +** To address these, the criteria for a star-query was tightened to exclude +** cases where the fact and dimensions are separated by an outer join, and +** the affect of star-schema detection was changed to increase the rRun cost +** on just full table scans of dimension tables, rather than reducing costs +** in the all access methods of the fact table. */ static int computeMxChoice(WhereInfo *pWInfo){ int nLoop = pWInfo->nLevel; /* Number of terms in the join */ @@ -5477,7 +5496,7 @@ static int computeMxChoice(WhereInfo *pWInfo){ #ifdef SQLITE_DEBUG /* The star-query detection code below makes use of the following - ** properties of the WhereLoop list, so verifying them before + ** properties of the WhereLoop list, so verify them before ** continuing: ** (1) .maskSelf is the bitmask corresponding to .iTab ** (2) The WhereLoop list is in ascending .iTab order @@ -5500,9 +5519,10 @@ static int computeMxChoice(WhereInfo *pWInfo){ pWInfo->bStarDone = 1; /* Only do this computation once */ - /* Check to see if we are dealing with a star schema and if so, reduce - ** the cost of fact tables relative to dimension tables, as a heuristic - ** to help keep the fact tables in outer loops. + /* Check to see if we are dealing with a star schema and if so, adjust + ** SCAN cost of dimensino tables so that they are as large as the SCAN + ** cost of the fact table. This is a heuristic that helps keep the + ** fact tables in outer loops. */ assert( !pWInfo->bStarUsed ); aFromTabs = pWInfo->pTabList->a; @@ -5543,29 +5563,34 @@ static int computeMxChoice(WhereInfo *pWInfo){ } } if( nDep<=3 ) continue; - - /* Compute the maximum cost of any WhereLoop for the iFromIdx-th term */ - mxRun = -32767; - for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){ - if( pWLoop->iTabiTab>iFromIdx ) break; - if( pWLoop->rRun>mxRun ) mxRun = pWLoop->rRun; - } - + /* If we reach this point, it means that pFactTab is a fact table */ + +#ifdef WHERETRACE_ENABLED /* Make sure rStarDelta values are initialized */ if( !pWInfo->bStarUsed ){ for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ pWLoop->rStarDelta = 0; } - pWInfo->bStarUsed = 1; } +#endif + pWInfo->bStarUsed = 1; + + /* Compute one more than the maximum cost of any WhereLoop for the + ** fact table */ + mxRun = LOGEST_MIN; + for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){ + if( pWLoop->iTabiTab>iFromIdx ) break; + if( pWLoop->rRun>mxRun ) mxRun = pWLoop->rRun; + } + if( ALWAYS(mxRunpNextLoop){ if( (pWLoop->maskSelf & mSeen)==0 ) continue; if( pWLoop->nLTerm ) continue; - if( pWLoop->rRun<=mxRun ){ + if( pWLoop->rRuniTab; @@ -5573,12 +5598,12 @@ static int computeMxChoice(WhereInfo *pWInfo){ "Increase SCAN cost of dimension %s(%d) of fact %s(%d) to %d\n", pDim->zAlias ? pDim->zAlias: pDim->pSTab->zName, pWLoop->iTab, pFactTab->zAlias ? pFactTab->zAlias : pFactTab->pSTab->zName, - iFromIdx, mxRun+1 + iFromIdx, mxRun ); } + pWLoop->rStarDelta = mxRun - pWLoop->rRun; #endif /* WHERETRACE_ENABLED */ - pWLoop->rStarDelta = mxRun+1 - pWLoop->rRun; - pWLoop->rRun = mxRun+1; + pWLoop->rRun = mxRun; } } } diff --git a/src/whereInt.h b/src/whereInt.h index 35bfe581dd..8ba8a7072d 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -162,8 +162,10 @@ struct WhereLoop { /**** whereLoopXfer() copies fields above ***********************/ # define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot) u16 nLSlot; /* Number of slots allocated for aLTerm[] */ +#ifdef WHERETRACE_ENABLED LogEst rStarDelta; /* Cost delta due to star-schema heuristic. Not ** initialized unless pWInfo->bStarUsed */ +#endif WhereTerm **aLTerm; /* WhereTerms used */ WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */ WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */ @@ -485,9 +487,9 @@ struct WhereInfo { unsigned bDeferredSeek :1; /* Uses OP_DeferredSeek */ unsigned untestedTerms :1; /* Not all WHERE terms resolved by outer loop */ unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */ - unsigned sorted :1; /* True if really sorted (not just grouped) */ + unsigned sorted :1; /* True if really sorted (not just grouped) */ unsigned bStarDone :1; /* True if check for star-query is complete */ - unsigned bStarUsed :1; /* True if cost adjustments for star-query */ + unsigned bStarUsed :1; /* True if star-query heuristic is used */ LogEst nRowOut; /* Estimated number of output rows */ #ifdef WHERETRACE_ENABLED LogEst rTotalCost; /* Total cost of the solution */ diff --git a/test/starschema1.test b/test/starschema1.test index af8168b510..bb7d8aa79b 100644 --- a/test/starschema1.test +++ b/test/starschema1.test @@ -10,7 +10,7 @@ #*********************************************************************** # # Test cases for the ability of the query planner to cope with -# star-schema queries on databases with goofy indexes. +# star-schema queries. # set testdir [file dirname $argv0] From 2228567ad33a41951fc79205d5555c51f7881562 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 26 Jan 2025 20:09:57 +0000 Subject: [PATCH 072/115] Further comment improvements in the star-query heuristic. Add an ALWAYS() on an unreachable branch to achieve MC/DC. FossilOrigin-Name: 5e18ce68fbc5e73e6694936f3ba71f5b5e3758cf380951805ca6ea6a3f0943aa --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 22 ++++++++++++---------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index e2dc85219e..7bdfce7763 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\ssize\sand\scomplexity\sreduction\son\sthe\sstar-query\sheuristic.\s\sImproved\ncomments\sfor\sthe\sstar-query\sheuristic. -D 2025-01-26T17:29:33.018 +C Further\scomment\simprovements\sin\sthe\sstar-query\sheuristic.\s\sAdd\san\sALWAYS()\non\san\sunreachable\sbranch\sto\sachieve\sMC/DC. +D 2025-01-26T20:09:57.061 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c adda3afc98a4f58713973997c699be2a8515c591701092e8380695f1a0a7b220 +F src/where.c 72cd936dcaa391fdce021840fbd1d9cbe51e34f821e0a09a05a2cc99ab506e92 F src/whereInt.h d20cddddb1d61b18d5cb1fcfa9b77fbeebbc4afe44d996e603452a23b3009ee1 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1bc09c9e8bd77ac41ecbe510c7e003757fc11d0f586da6cdf3584315aa9d6407 -R c0f75689e724495cafe203db572d7b59 +P a7ecb2f4b7eee78b88f1b2e026dffed2007ca4ffeb152632624ab2582839b250 +R 56a3a416133fa0f7166c060fc9c27138 U drh -Z 5884f43bd01d477b04985ecdd4572f42 +Z a3e111b0c87ac0b331649395aaa39e29 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 22688c5390..fbc82e399e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a7ecb2f4b7eee78b88f1b2e026dffed2007ca4ffeb152632624ab2582839b250 +5e18ce68fbc5e73e6694936f3ba71f5b5e3758cf380951805ca6ea6a3f0943aa diff --git a/src/where.c b/src/where.c index 01f8ff0d9a..8f467e9787 100644 --- a/src/where.c +++ b/src/where.c @@ -5519,10 +5519,9 @@ static int computeMxChoice(WhereInfo *pWInfo){ pWInfo->bStarDone = 1; /* Only do this computation once */ - /* Check to see if we are dealing with a star schema and if so, adjust - ** SCAN cost of dimensino tables so that they are as large as the SCAN - ** cost of the fact table. This is a heuristic that helps keep the - ** fact tables in outer loops. + /* Look for fact tables with four or more dimensions where the + ** dimension tables are not separately from the fact tables by an outer + ** or cross join. Adjust cost weights if found. */ assert( !pWInfo->bStarUsed ); aFromTabs = pWInfo->pTabList->a; @@ -5539,7 +5538,7 @@ static int computeMxChoice(WhereInfo *pWInfo){ ** restrict the search for dimension-tables to be tables to the right ** of the fact-table. */ if( iFromIdx+4 > nLoop ) break; /* Impossible to reach nDep>=4 */ - while( pStart && pStart->iTab<=iFromIdx ){ + while( ALWAYS(pStart) && pStart->iTab<=iFromIdx ){ pStart = pStart->pNextLoop; } } @@ -5563,7 +5562,10 @@ static int computeMxChoice(WhereInfo *pWInfo){ } } if( nDep<=3 ) continue; - /* If we reach this point, it means that pFactTab is a fact table */ + + /* If we reach this point, it means that pFactTab is a fact table + ** with four or more dimensions connected by inner joins. Proceed + ** to make cost adjustments. */ #ifdef WHERETRACE_ENABLED /* Make sure rStarDelta values are initialized */ @@ -5575,8 +5577,8 @@ static int computeMxChoice(WhereInfo *pWInfo){ #endif pWInfo->bStarUsed = 1; - /* Compute one more than the maximum cost of any WhereLoop for the - ** fact table */ + /* Compute the maximum cost of any WhereLoop for the + ** fact table plus one epsilon */ mxRun = LOGEST_MIN; for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){ if( pWLoop->iTabpNextLoop){ if( (pWLoop->maskSelf & mSeen)==0 ) continue; if( pWLoop->nLTerm ) continue; From e097db7210321c5c98a810a88e9efc87730dc202 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 26 Jan 2025 23:34:49 +0000 Subject: [PATCH 073/115] Make two private routines in FTS "static" so that they are not callable from outside of SQLite itself. FossilOrigin-Name: 9b11bed0448b95319206b413c35f23bb80f3f4c0a4394d40f2e64066400a01ed --- ext/fts5/fts5_index.c | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index c98844e73d..c53bad8248 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -778,7 +778,7 @@ static int fts5LeafFirstTermOff(Fts5Data *pLeaf){ /* ** Close the read-only blob handle, if it is open. */ -void fts5IndexCloseReader(Fts5Index *p){ +static void fts5IndexCloseReader(Fts5Index *p){ if( p->pReader ){ int rc; sqlite3_blob *pReader = p->pReader; @@ -6955,7 +6955,7 @@ static void fts5SegIterSetEOF(Fts5SegIter *pSeg){ pSeg->pLeaf = 0; } -void fts5IterClose(Fts5IndexIter *pIndexIter){ +static void fts5IterClose(Fts5IndexIter *pIndexIter){ if( pIndexIter ){ Fts5Iter *pIter = (Fts5Iter*)pIndexIter; Fts5Index *pIndex = pIter->pIndex; diff --git a/manifest b/manifest index 7bdfce7763..27b5bb653a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\scomment\simprovements\sin\sthe\sstar-query\sheuristic.\s\sAdd\san\sALWAYS()\non\san\sunreachable\sbranch\sto\sachieve\sMC/DC. -D 2025-01-26T20:09:57.061 +C Make\stwo\sprivate\sroutines\sin\sFTS\s"static"\sso\sthat\sthey\sare\snot\scallable\sfrom\noutside\sof\sSQLite\sitself. +D 2025-01-26T23:34:49.014 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -112,7 +112,7 @@ F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70 F ext/fts5/fts5_config.c e7d8dd062b44a66cd77e5a0f74f23a2354cd1f3f8575afb967b2773c3384f7f8 F ext/fts5/fts5_expr.c 69b8d976058512c07dfe86e229521b7a871768157bd1607cedf1a5038dfd72c9 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 -F ext/fts5/fts5_index.c 1ce1e2b43fdd86a2047619c2ea3aafa5c7b909d0cef75185d0fda31e82f0e9c6 +F ext/fts5/fts5_index.c a59ccd06af157da2471f356198af14bc37d86e46231e4e1858b2af2f94c2c6e4 F ext/fts5/fts5_main.c 9a1daef7247f9b8a50b4159323e340efa6b0e4bea4fcd83580480f94d4f2c888 F ext/fts5/fts5_storage.c 1ad05dab4830a4e2eaf2900bb143477f93bc17437093582f36f4b818809e88d8 F ext/fts5/fts5_tcl.c 7fb5a3d3404099075aaa2457307cb459bbc257c0de3dbd52b1e80a5b503e0329 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a7ecb2f4b7eee78b88f1b2e026dffed2007ca4ffeb152632624ab2582839b250 -R 56a3a416133fa0f7166c060fc9c27138 +P 5e18ce68fbc5e73e6694936f3ba71f5b5e3758cf380951805ca6ea6a3f0943aa +R a54b570883d195008f2678c7c81be853 U drh -Z a3e111b0c87ac0b331649395aaa39e29 +Z dcfa08d4408fce3e0f4c19a22b5dac4d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fbc82e399e..8dfffe85a9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e18ce68fbc5e73e6694936f3ba71f5b5e3758cf380951805ca6ea6a3f0943aa +9b11bed0448b95319206b413c35f23bb80f3f4c0a4394d40f2e64066400a01ed From 7c727bb61b0494913992635eb267425c25bcf298 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 Jan 2025 14:12:14 +0000 Subject: [PATCH 074/115] Avoid splitting a hyperlink across lines in the documentation comment for sqlite3_serialize(). FossilOrigin-Name: 74b770bd445d98ff883000ab2e31603d729e415e4e4f640646eef30825634f48 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 27b5bb653a..421ef339e6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\stwo\sprivate\sroutines\sin\sFTS\s"static"\sso\sthat\sthey\sare\snot\scallable\sfrom\noutside\sof\sSQLite\sitself. -D 2025-01-26T23:34:49.014 +C Avoid\ssplitting\sa\shyperlink\sacross\slines\sin\sthe\sdocumentation\scomment\sfor\nsqlite3_serialize(). +D 2025-01-27T14:12:14.624 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -781,7 +781,7 @@ F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 83e88fbb36f89b6703b348777491619554f0fd6f917c9fdf51e4c2e9cda6c04e F src/shell.c.in 9ade75afa953c5c2ded38d076533eaa6c9b2ab1977ef6cce0bc773adac178c50 -F src/sqlite.h.in 135c4479d03d5dcff7f580c1997f351d94954cf37346db560948c7add6159d9a +F src/sqlite.h.in f1362730549010733d30fff4de369f0e48b0857f71e874cca91ffcfecf587eba F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 5c859fc5b1b9fa489bc7a39d37606472b70f808f965eab11c24f14d8d7654330 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5e18ce68fbc5e73e6694936f3ba71f5b5e3758cf380951805ca6ea6a3f0943aa -R a54b570883d195008f2678c7c81be853 +P 9b11bed0448b95319206b413c35f23bb80f3f4c0a4394d40f2e64066400a01ed +R e2b813a3abd3bf21562fc924e1b6e152 U drh -Z dcfa08d4408fce3e0f4c19a22b5dac4d +Z 538ef5af19384f8d48d29325a60a77c0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8dfffe85a9..804b833798 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b11bed0448b95319206b413c35f23bb80f3f4c0a4394d40f2e64066400a01ed +74b770bd445d98ff883000ab2e31603d729e415e4e4f640646eef30825634f48 diff --git a/src/sqlite.h.in b/src/sqlite.h.in index b6863b30fa..a9a08d4ffd 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -10749,8 +10749,8 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb); ** CAPI3REF: Serialize a database ** ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to -** memory that is a serialization of the S database on [database -** connection] D. If S is a NULL pointer, the main database is used. +** memory that is a serialization of the S database on +** [database connection] D. If S is a NULL pointer, the main database is used. ** If P is not a NULL pointer, then the size of the database in bytes ** is written into *P. ** From 5dcf5890ae72c446217f679b8f805a7d3cf34f72 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 Jan 2025 17:48:51 +0000 Subject: [PATCH 075/115] Enhance ./configure to issue an unambiguious error if the pathname to either the source tree or the build directory contains any space characters. FossilOrigin-Name: 614ae5c74f3b534f50432c875681d7a1e6135be883508939c9c57822cc1e9361 --- auto.def | 10 ++++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/auto.def b/auto.def index 7fdf61f16c..dade81613f 100644 --- a/auto.def +++ b/auto.def @@ -14,6 +14,16 @@ # use sqlite-config +if {[string first " " $autosetup(srcdir)] != -1} { + user-error "The pathname of the source tree\ + may not contain space characters" +} +if {[string first " " $autosetup(builddir)] != -1} { + user-error "The pathname of the build directory\ + may not contain space characters" +} + + ######################################################################## # Regarding flag compatibility with the historical autotool configure # script: diff --git a/manifest b/manifest index 421ef339e6..9658ed78bb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\ssplitting\sa\shyperlink\sacross\slines\sin\sthe\sdocumentation\scomment\sfor\nsqlite3_serialize(). -D 2025-01-27T14:12:14.624 +C Enhance\s./configure\sto\sissue\san\sunambiguious\serror\sif\sthe\spathname\sto\seither\nthe\ssource\stree\sor\sthe\sbuild\sdirectory\scontains\sany\sspace\scharacters. +D 2025-01-27T17:48:51.296 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -14,7 +14,7 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 -F auto.def 7833c0a8630dd3a3410dcc6c8b4d1b63f25d03d6497267624b8a37aba119cb3e +F auto.def caf7cca9c235fc6a3d7639e00eb75972d9bf8527717498b9fa1d7112d50b5720 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac F autoconf/Makefile.in 56697ad25ecf23afa317148b06bdc14f85960b42e5ec434ac1ba87f63a3cb789 F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9b11bed0448b95319206b413c35f23bb80f3f4c0a4394d40f2e64066400a01ed -R e2b813a3abd3bf21562fc924e1b6e152 +P 74b770bd445d98ff883000ab2e31603d729e415e4e4f640646eef30825634f48 +R 0d48e3ec7a39c2ed6a320258adde1027 U drh -Z 538ef5af19384f8d48d29325a60a77c0 +Z 7ae24fa2aff28dbc435f2d2a94f34ec6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 804b833798..8f386fb7b5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -74b770bd445d98ff883000ab2e31603d729e415e4e4f640646eef30825634f48 +614ae5c74f3b534f50432c875681d7a1e6135be883508939c9c57822cc1e9361 From 44980e816985953ed7125b657751a1d09560df02 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 27 Jan 2025 21:18:13 +0000 Subject: [PATCH 076/115] Use hashing to accelerate column matching on INSERT statements. Code is smaller and about 1.8% faster overall according to test/speedtest.tcl. FossilOrigin-Name: 8be956383e0344fb613ec2e56fce7b518f439ae34bf9ddb424de2bd9b31c9889 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9658ed78bb..73dc628f2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\s./configure\sto\sissue\san\sunambiguious\serror\sif\sthe\spathname\sto\seither\nthe\ssource\stree\sor\sthe\sbuild\sdirectory\scontains\sany\sspace\scharacters. -D 2025-01-27T17:48:51.296 +C Use\shashing\sto\saccelerate\scolumn\smatching\son\sINSERT\sstatements.\s\sCode\sis\nsmaller\sand\sabout\s1.8%\sfaster\soverall\saccording\sto\stest/speedtest.tcl. +D 2025-01-27T21:18:13.459 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -738,7 +738,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c f8d1a0f8ee258411009c6b7f2d93170e351bd19f5ad89d57e1180644297cbe70 +F src/insert.c ed2eeba6f0584b91dfe1fc0b68257162ffc003bec429f7f86515fc45a12a9f0e F src/json.c 68a98c020c22127f2d65f08855f7fc7460ff352a6ce0b543d8931dde83319c22 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 74b770bd445d98ff883000ab2e31603d729e415e4e4f640646eef30825634f48 -R 0d48e3ec7a39c2ed6a320258adde1027 +P 614ae5c74f3b534f50432c875681d7a1e6135be883508939c9c57822cc1e9361 +R 03aea741a0703ca96f0d93fb17714919 U drh -Z 7ae24fa2aff28dbc435f2d2a94f34ec6 +Z 0ad560704a9a8a0c8ed384deaa40c4eb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8f386fb7b5..8b991c86cb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -614ae5c74f3b534f50432c875681d7a1e6135be883508939c9c57822cc1e9361 +8be956383e0344fb613ec2e56fce7b518f439ae34bf9ddb424de2bd9b31c9889 diff --git a/src/insert.c b/src/insert.c index d380281bed..a93a465570 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1077,8 +1077,11 @@ void sqlite3Insert( pColumn->a[i].u4.idx = -1; } for(i=0; inId; i++){ + const char *zCName = pColumn->a[i].zName; + u8 hName = sqlite3StrIHash(zCName); for(j=0; jnCol; j++){ - if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zCnName)==0 ){ + if( pTab->aCol[j].hName!=hName ) continue; + if( sqlite3StrICmp(zCName, pTab->aCol[j].zCnName)==0 ){ pColumn->a[i].u4.idx = j; if( i!=j ) bIdListInOrder = 0; if( j==pTab->iPKey ){ From d8c37bbc54d1c4d74a0038addcbc28df7a178074 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 Jan 2025 00:48:01 +0000 Subject: [PATCH 077/115] Remove an ALWAYS() in the star-query heuristic that is sometimes false if you have a corrupt database. dbsqlfuzz c37ba7728d79859b79c8341b59297e88fba017d3. Test case in TH3. FossilOrigin-Name: 6b9a339628eb8bfb6dfbee02000a6ac91cc8a9ae16bd990e62c4142b9f912c36 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 73dc628f2b..1d8c3e1f3e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\shashing\sto\saccelerate\scolumn\smatching\son\sINSERT\sstatements.\s\sCode\sis\nsmaller\sand\sabout\s1.8%\sfaster\soverall\saccording\sto\stest/speedtest.tcl. -D 2025-01-27T21:18:13.459 +C Remove\san\sALWAYS()\sin\sthe\sstar-query\sheuristic\sthat\sis\ssometimes\sfalse\sif\syou\nhave\sa\scorrupt\sdatabase.\s\sdbsqlfuzz\sc37ba7728d79859b79c8341b59297e88fba017d3.\nTest\scase\sin\sTH3. +D 2025-01-28T00:48:01.787 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -863,7 +863,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 72cd936dcaa391fdce021840fbd1d9cbe51e34f821e0a09a05a2cc99ab506e92 +F src/where.c 09dc313e7223ca1217c39c7026b00f16ff449a8323511a762fcba7863a00f4cd F src/whereInt.h d20cddddb1d61b18d5cb1fcfa9b77fbeebbc4afe44d996e603452a23b3009ee1 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 614ae5c74f3b534f50432c875681d7a1e6135be883508939c9c57822cc1e9361 -R 03aea741a0703ca96f0d93fb17714919 +P 8be956383e0344fb613ec2e56fce7b518f439ae34bf9ddb424de2bd9b31c9889 +R 77d3f24a906693f579bd3b508d5195e5 U drh -Z 0ad560704a9a8a0c8ed384deaa40c4eb +Z 249159a5b98132893f1e97c49e03bb71 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8b991c86cb..a380877b99 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8be956383e0344fb613ec2e56fce7b518f439ae34bf9ddb424de2bd9b31c9889 +6b9a339628eb8bfb6dfbee02000a6ac91cc8a9ae16bd990e62c4142b9f912c36 diff --git a/src/where.c b/src/where.c index 8f467e9787..5cb52b8adb 100644 --- a/src/where.c +++ b/src/where.c @@ -5538,7 +5538,7 @@ static int computeMxChoice(WhereInfo *pWInfo){ ** restrict the search for dimension-tables to be tables to the right ** of the fact-table. */ if( iFromIdx+4 > nLoop ) break; /* Impossible to reach nDep>=4 */ - while( ALWAYS(pStart) && pStart->iTab<=iFromIdx ){ + while( pStart && pStart->iTab<=iFromIdx ){ pStart = pStart->pNextLoop; } } From 50637ca5c5420f807b9a49a0645f5d0c31aa3523 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 Jan 2025 01:10:45 +0000 Subject: [PATCH 078/115] Apparently I got the logic of [abfe488ed67e2e35] confused, even backwards. Change it so that the SQLITE_USE_W32_FOR_CONSOLE_IO macro causes Win32 APIs to be used for console I/O and for stdio to be used otherwise. This is reported to be necessary for builds that use a C-language runtime other than the one provided by Microsoft. This changes if for Windows only. It is a bug fix, though we don't have a test case that will demonstrate a malfunction. FossilOrigin-Name: 925e97e6f4238f02259a0c95b1fc668ae32a95329242f8eeae236ef207aca112 --- ext/misc/sqlite3_stdio.c | 14 ++++++++++---- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ext/misc/sqlite3_stdio.c b/ext/misc/sqlite3_stdio.c index be3acc665e..c9bceb1942 100644 --- a/ext/misc/sqlite3_stdio.c +++ b/ext/misc/sqlite3_stdio.c @@ -46,6 +46,11 @@ ** use O_U8TEXT when writing to the Windows console (or anything ** else for which _isatty() returns true) and to use O_BINARY or O_TEXT ** for all other output channels. +** +** The SQLITE_USE_W32_FOR_CONSOLE_IO macro is also available. If +** defined, it forces the use of Win32 APIs for all console I/O, both +** input and output. This is necessary for some non-Microsoft run-times +** that implement stdio differently from Microsoft/Visual-Studio. */ #if defined(SQLITE_U8TEXT_ONLY) # define UseWtextForOutput(fd) 1 @@ -148,7 +153,7 @@ char *sqlite3_fgets(char *buf, int sz, FILE *in){ */ wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) ); if( b1==0 ) return 0; -#ifndef SQLITE_USE_STDIO_FOR_CONSOLE +#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO DWORD nRead = 0; if( IsConsole(in) && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0) @@ -226,7 +231,7 @@ int sqlite3_fputs(const char *z, FILE *out){ sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz); b1[sz] = 0; -#ifndef SQLITE_STDIO_FOR_CONSOLE +#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO DWORD nWr = 0; if( IsConsole(out) && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0) @@ -236,8 +241,9 @@ int sqlite3_fputs(const char *z, FILE *out){ }else #endif { - /* For non-console I/O, or if SQLITE_USE_STDIO_FOR_CONSOLE is defined - ** then write using the standard library. */ + /* As long as SQLITE_USE_W32_FOR_CONSOLE_IO is not defined, or for + ** non-console I/O even if that macro is defined, write using the + ** standard library. */ _setmode(_fileno(out), _O_U8TEXT); if( UseBinaryWText(out) ){ piecemealOutput(b1, sz, out); diff --git a/manifest b/manifest index 1d8c3e1f3e..359b597c81 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sALWAYS()\sin\sthe\sstar-query\sheuristic\sthat\sis\ssometimes\sfalse\sif\syou\nhave\sa\scorrupt\sdatabase.\s\sdbsqlfuzz\sc37ba7728d79859b79c8341b59297e88fba017d3.\nTest\scase\sin\sTH3. -D 2025-01-28T00:48:01.787 +C Apparently\sI\sgot\sthe\slogic\sof\s[abfe488ed67e2e35]\sconfused,\seven\sbackwards.\nChange\sit\sso\sthat\sthe\sSQLITE_USE_W32_FOR_CONSOLE_IO\smacro\scauses\sWin32\sAPIs\nto\sbe\sused\sfor\sconsole\sI/O\sand\sfor\sstdio\sto\sbe\sused\sotherwise.\s\sThis\sis\nreported\sto\sbe\snecessary\sfor\sbuilds\sthat\suse\sa\sC-language\sruntime\sother\sthan\nthe\sone\sprovided\sby\sMicrosoft.\s\sThis\schanges\sif\sfor\sWindows\sonly.\s\sIt\sis\sa\nbug\sfix,\sthough\swe\sdon't\shave\sa\stest\scase\sthat\swill\sdemonstrate\sa\smalfunction. +D 2025-01-28T01:10:45.744 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -442,7 +442,7 @@ F ext/misc/shathree.c f3a778f27bf3e71b666a77f28e463a3b931c4dbe4219447e61bb678b4b F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bcc42ef3fd29429bc01a83e751332b8d4690e65d45008449bdffe7656371487f F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 -F ext/misc/sqlite3_stdio.c 18160504b9348d0ebb9f5620fd61e64cd2d55fffde05ab3f7db03396add4840a +F ext/misc/sqlite3_stdio.c 0fe5a45bd332b30aef2b68c64edbe69e31e9c42365b0fa79ce95a034bca6fbb0 F ext/misc/sqlite3_stdio.h f05eaf5e0258f0573910324a789a9586fc360a57678c57a6d63cfaa2245b6176 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8be956383e0344fb613ec2e56fce7b518f439ae34bf9ddb424de2bd9b31c9889 -R 77d3f24a906693f579bd3b508d5195e5 +P 6b9a339628eb8bfb6dfbee02000a6ac91cc8a9ae16bd990e62c4142b9f912c36 +R 85cb8890cc290d809a1a9ad2ffbbbd4c U drh -Z 249159a5b98132893f1e97c49e03bb71 +Z 5b8003927aa3346b085a7fb5e605a55b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a380877b99..2cf98d2e84 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b9a339628eb8bfb6dfbee02000a6ac91cc8a9ae16bd990e62c4142b9f912c36 +925e97e6f4238f02259a0c95b1fc668ae32a95329242f8eeae236ef207aca112 From b0c8b08874b90bf3eaf05e3b87d0ad1cb05d46ee Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 Jan 2025 10:56:22 +0000 Subject: [PATCH 079/115] Fix typo in speedtest.md. FossilOrigin-Name: 984a9cc22c7c8492bf4fae482749663899b0e33a25c32e6ae5c5e98fc12bb83e --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest.md | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 359b597c81..88850f9ca3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Apparently\sI\sgot\sthe\slogic\sof\s[abfe488ed67e2e35]\sconfused,\seven\sbackwards.\nChange\sit\sso\sthat\sthe\sSQLITE_USE_W32_FOR_CONSOLE_IO\smacro\scauses\sWin32\sAPIs\nto\sbe\sused\sfor\sconsole\sI/O\sand\sfor\sstdio\sto\sbe\sused\sotherwise.\s\sThis\sis\nreported\sto\sbe\snecessary\sfor\sbuilds\sthat\suse\sa\sC-language\sruntime\sother\sthan\nthe\sone\sprovided\sby\sMicrosoft.\s\sThis\schanges\sif\sfor\sWindows\sonly.\s\sIt\sis\sa\nbug\sfix,\sthough\swe\sdon't\shave\sa\stest\scase\sthat\swill\sdemonstrate\sa\smalfunction. -D 2025-01-28T01:10:45.744 +C Fix\stypo\sin\sspeedtest.md. +D 2025-01-28T10:56:22.927 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1678,7 +1678,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c -F test/speedtest.md e4f467683acfdb2834ca1d6ce209c3d883dfecf73c41f77234b2368be9579de2 +F test/speedtest.md ee958457ae1b729d9715ae33c0320600000bf1d9ddea1a88dcf79f56729d6fad F test/speedtest.tcl 8a9362c1e429318e741b91d26888e7edcc326f98c3aea505ffd618cc5b9e7f0a x F test/speedtest1.c 323ce0956430a5aae56ea20f502da7bea3fb62b8ed02e9b0f12ab078b2b258f5 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6b9a339628eb8bfb6dfbee02000a6ac91cc8a9ae16bd990e62c4142b9f912c36 -R 85cb8890cc290d809a1a9ad2ffbbbd4c +P 925e97e6f4238f02259a0c95b1fc668ae32a95329242f8eeae236ef207aca112 +R 40cdca5fbba192c17cd4fe2aa49c2ea4 U drh -Z 5b8003927aa3346b085a7fb5e605a55b +Z 200936ddd5ad4693d292c3f04fcfac09 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2cf98d2e84..fffadee9e0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -925e97e6f4238f02259a0c95b1fc668ae32a95329242f8eeae236ef207aca112 +984a9cc22c7c8492bf4fae482749663899b0e33a25c32e6ae5c5e98fc12bb83e diff --git a/test/speedtest.md b/test/speedtest.md index 645742d756..135e562aed 100644 --- a/test/speedtest.md +++ b/test/speedtest.md @@ -9,7 +9,7 @@ You will need: * tclsh * A script or program named "open" that brings up *.txt files in an editor for viewing. (Macs provide this by default. You'll need to - come up with your own on Linxu and Windows.) + come up with your own on Linux and Windows.) * An SQLite source tree The procedure described in this document is not the only way to make From 8b62a82ae36f7d39c2a301389219e456759f9919 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 Jan 2025 12:50:17 +0000 Subject: [PATCH 080/115] Simplifh the IdList object to remove unnecessary fields. Performance increases by about 0.8%. FossilOrigin-Name: a4625bb995dd5582d1f3cf0c2e54eb3f01f1cc1405811dda86ebd38b2b858994 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/build.c | 1 - src/expr.c | 3 --- src/insert.c | 23 ++++++++++++----------- src/sqliteInt.h | 5 ----- src/treeview.c | 16 +--------------- 7 files changed, 24 insertions(+), 46 deletions(-) diff --git a/manifest b/manifest index 88850f9ca3..ca6a8b11d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\sspeedtest.md. -D 2025-01-28T10:56:22.927 +C Simplifh\sthe\sIdList\sobject\sto\sremove\sunnecessary\sfields.\s\sPerformance\nincreases\sby\sabout\s0.8%. +D 2025-01-28T12:50:17.902 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -721,7 +721,7 @@ F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522 F src/btree.c 63ca6b647342e8cef643863cd0962a542f133e1069460725ba4461dcda92b03c F src/btree.h 18e5e7b2124c23426a283523e5f31a4bff029131b795bb82391f9d2f3136fc50 F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6 -F src/build.c c6b09342d870a509529244ed8e19b4175a261f2e3163c199241d69e1d8a57607 +F src/build.c 357f98cdd9fe93f86e93ad3324fd224492480e48506c0c7db8ae3a94f3b5c5ee F src/callback.c acae8c8dddda41ee85cfdf19b926eefe830f371069f8aadca3aa39adf5b1c859 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c d35723024b963edce9c0fad5b3303e8bb9266083784844baed10a6dedfe26f3b @@ -729,7 +729,7 @@ F src/date.c 842c08ac143a56a627b05ac51d68624f2b7b03e3b4cba596205e735eed64ee57 F src/dbpage.c e90410e5d4c0217dfddc4184a81e38ec4903c25d4ec0f201060a0e54e7c2099f F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 -F src/expr.c 30a407765d4e4b592f9f958085fb4e8336e54fa46a70ade7f5a67111bc191563 +F src/expr.c ce83e7361454a195f8393fa0baad694e2fee6c49a44c0d6db44d8a2b92534aeb F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f F src/func.c 30051410d0379059e1e3642ffc0caae6963a2b01b3b6d9dd44c5e09b1a66d066 @@ -738,7 +738,7 @@ F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c ed2eeba6f0584b91dfe1fc0b68257162ffc003bec429f7f86515fc45a12a9f0e +F src/insert.c db8bfff30fd7f71812651df3ddf5d1624b9e19104b31e349cd9055bbc9d622c4 F src/json.c 68a98c020c22127f2d65f08855f7fc7460ff352a6ce0b543d8931dde83319c22 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -784,7 +784,7 @@ F src/shell.c.in 9ade75afa953c5c2ded38d076533eaa6c9b2ab1977ef6cce0bc773adac178c5 F src/sqlite.h.in f1362730549010733d30fff4de369f0e48b0857f71e874cca91ffcfecf587eba F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 5c859fc5b1b9fa489bc7a39d37606472b70f808f965eab11c24f14d8d7654330 +F src/sqliteInt.h 6f23e483be7810ea1854c8fbfbbbfae2a702529d1feb9a210a290abb4455414c F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -841,7 +841,7 @@ F src/test_window.c 6d80e11fba89a1796525e6f0048ff0c7789aa2c6b0b11c80827dc1437bd8 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c fe17e03175cae35b6694d0f879e7bc3d1ddea2fd4ab148cba9bbd025b7a7bb12 -F src/treeview.c d1f3003cb21846828f314a304cf9117f5e80ce0be259315a681d25147004d26d +F src/treeview.c d85ce76e6d1498d781957c07cb234da6d77ce0ed2d196480d516f54dabc62279 F src/trigger.c 247e2d712d5edc6021d52a169f6ac9a9c10d7144bc4ac7ea06c1ed2aa414659f F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 925e97e6f4238f02259a0c95b1fc668ae32a95329242f8eeae236ef207aca112 -R 40cdca5fbba192c17cd4fe2aa49c2ea4 +P 984a9cc22c7c8492bf4fae482749663899b0e33a25c32e6ae5c5e98fc12bb83e +R 3ffeb05f71791678583efe8c7fde2e8f U drh -Z 200936ddd5ad4693d292c3f04fcfac09 +Z 039fb781952da1d6729d929a997aaf6e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fffadee9e0..0e2fd340b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -984a9cc22c7c8492bf4fae482749663899b0e33a25c32e6ae5c5e98fc12bb83e +a4625bb995dd5582d1f3cf0c2e54eb3f01f1cc1405811dda86ebd38b2b858994 diff --git a/src/build.c b/src/build.c index a5deb54fc6..cc29610e0a 100644 --- a/src/build.c +++ b/src/build.c @@ -4691,7 +4691,6 @@ void sqlite3IdListDelete(sqlite3 *db, IdList *pList){ int i; assert( db!=0 ); if( pList==0 ) return; - assert( pList->eU4!=EU4_EXPR ); /* EU4_EXPR mode is not currently used */ for(i=0; inId; i++){ sqlite3DbFree(db, pList->a[i].zName); } diff --git a/src/expr.c b/src/expr.c index ca5b9092e7..fcd3da2138 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1932,16 +1932,13 @@ IdList *sqlite3IdListDup(sqlite3 *db, const IdList *p){ int i; assert( db!=0 ); if( p==0 ) return 0; - assert( p->eU4!=EU4_EXPR ); pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)+(p->nId-1)*sizeof(p->a[0]) ); if( pNew==0 ) return 0; pNew->nId = p->nId; - pNew->eU4 = p->eU4; for(i=0; inId; i++){ struct IdList_item *pNewItem = &pNew->a[i]; const struct IdList_item *pOldItem = &p->a[i]; pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName); - pNewItem->u4 = pOldItem->u4; } return pNew; } diff --git a/src/insert.c b/src/insert.c index a93a465570..83baeece64 100644 --- a/src/insert.c +++ b/src/insert.c @@ -927,6 +927,7 @@ void sqlite3Insert( int regRowid; /* registers holding insert rowid */ int regData; /* register holding first column to insert */ int *aRegIdx = 0; /* One register allocated to each index */ + int *aTabColMap = 0; /* Mapping from pTab columns to pCol entries */ #ifndef SQLITE_OMIT_TRIGGER int isView; /* True if attempting to insert into a view */ @@ -1071,18 +1072,15 @@ void sqlite3Insert( */ bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0; if( pColumn ){ - assert( pColumn->eU4!=EU4_EXPR ); - pColumn->eU4 = EU4_IDX; - for(i=0; inId; i++){ - pColumn->a[i].u4.idx = -1; - } + aTabColMap = sqlite3DbMallocZero(db, pTab->nCol*sizeof(int)); + if( aTabColMap==0 ) goto insert_cleanup; for(i=0; inId; i++){ const char *zCName = pColumn->a[i].zName; u8 hName = sqlite3StrIHash(zCName); for(j=0; jnCol; j++){ if( pTab->aCol[j].hName!=hName ) continue; if( sqlite3StrICmp(zCName, pTab->aCol[j].zCnName)==0 ){ - pColumn->a[i].u4.idx = j; + if( aTabColMap[j]==0 ) aTabColMap[j] = i+1; if( i!=j ) bIdListInOrder = 0; if( j==pTab->iPKey ){ ipkColumn = i; assert( !withoutRowid ); @@ -1404,9 +1402,9 @@ void sqlite3Insert( } } if( pColumn ){ - assert( pColumn->eU4==EU4_IDX ); - for(j=0; jnId && pColumn->a[j].u4.idx!=i; j++){} - if( j>=pColumn->nId ){ + j = aTabColMap[i]; + assert( j>=0 && j<=pColumn->nId ); + if( j==0 ){ /* A column not named in the insert column list gets its ** default value */ sqlite3ExprCodeFactorable(pParse, @@ -1414,7 +1412,7 @@ void sqlite3Insert( iRegStore); continue; } - k = j; + k = j - 1; }else if( nColumn==0 ){ /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */ sqlite3ExprCodeFactorable(pParse, @@ -1659,7 +1657,10 @@ insert_cleanup: sqlite3ExprListDelete(db, pList); sqlite3UpsertDelete(db, pUpsert); sqlite3SelectDelete(db, pSelect); - sqlite3IdListDelete(db, pColumn); + if( pColumn ){ + sqlite3IdListDelete(db, pColumn); + sqlite3DbFree(db, aTabColMap); + } if( aRegIdx ) sqlite3DbNNFreeNN(db, aRegIdx); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 205f8f3e0e..6025d3f142 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3223,13 +3223,8 @@ struct ExprList { */ struct IdList { int nId; /* Number of identifiers on the list */ - u8 eU4; /* Which element of a.u4 is valid */ struct IdList_item { char *zName; /* Name of the identifier */ - union { - int idx; /* Index in some Table.aCol[] of a column named zName */ - Expr *pExpr; /* Expr to implement a USING variable -- NOT USED */ - } u4; } a[1]; }; diff --git a/src/treeview.c b/src/treeview.c index 2cfcfb69b0..8329659249 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -978,21 +978,7 @@ void sqlite3TreeViewBareIdList( if( zName==0 ) zName = "(null)"; sqlite3TreeViewPush(&pView, moreToFollow); sqlite3TreeViewLine(pView, 0); - if( pList->eU4==EU4_NONE ){ - fprintf(stdout, "%s\n", zName); - }else if( pList->eU4==EU4_IDX ){ - fprintf(stdout, "%s (%d)\n", zName, pList->a[i].u4.idx); - }else{ - assert( pList->eU4==EU4_EXPR ); - if( pList->a[i].u4.pExpr==0 ){ - fprintf(stdout, "%s (pExpr=NULL)\n", zName); - }else{ - fprintf(stdout, "%s\n", zName); - sqlite3TreeViewPush(&pView, inId-1); - sqlite3TreeViewExpr(pView, pList->a[i].u4.pExpr, 0); - sqlite3TreeViewPop(&pView); - } - } + fprintf(stdout, "%s\n", zName); sqlite3TreeViewPop(&pView); } } From 0424f255efb2aaa89e29a265683fd260da2b94c7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 Jan 2025 18:03:22 +0000 Subject: [PATCH 081/115] Fix a copy/paste typo in the output of vfstrace for xDlClose(). FossilOrigin-Name: 1d57b57c85bb8cb9b8a1808b771bb91eeb8150efd14f9064a390e533e715bab7 --- ext/misc/vfstrace.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/misc/vfstrace.c b/ext/misc/vfstrace.c index fed87e88f3..c274558d17 100644 --- a/ext/misc/vfstrace.c +++ b/ext/misc/vfstrace.c @@ -1033,7 +1033,7 @@ static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData; sqlite3_vfs *pRoot = pInfo->pRootVfs; vfstraceOnOff(pInfo, VTR_DLCLOSE); - vfstrace_printf(pInfo, "%s.xDlOpen()\n", pInfo->zVfsName); + vfstrace_printf(pInfo, "%s.xDlClose()\n", pInfo->zVfsName); pRoot->xDlClose(pRoot, pHandle); } diff --git a/manifest b/manifest index ca6a8b11d7..c9dacfd70d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifh\sthe\sIdList\sobject\sto\sremove\sunnecessary\sfields.\s\sPerformance\nincreases\sby\sabout\s0.8%. -D 2025-01-28T12:50:17.902 +C Fix\sa\scopy/paste\stypo\sin\sthe\soutput\sof\svfstrace\sfor\sxDlClose(). +D 2025-01-28T18:03:22.182 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -454,7 +454,7 @@ F ext/misc/urifuncs.c f71360d14fa9e7626b563f1f781c6148109462741c5235ac63ae0f8917 F ext/misc/uuid.c 5bb2264c1b64d163efa46509544fd7500cb8769cb7c16dd52052da8d961505cf F ext/misc/vfslog.c 3932ab932eeb2601dbc4447cb14d445aaa9fbe43b863ef5f014401c3420afd20 F ext/misc/vfsstat.c a85df08654743922a19410d7b1e3111de41bb7cd07d20dd16eda4e2b808d269d -F ext/misc/vfstrace.c 9c4abd2f67ae2760e7a241eca2e8517c64480ac2c3e66a499326e688a9bbee22 +F ext/misc/vfstrace.c a73386403c350b210dc788a2d23a0f5cc89c49b176109a66af11b5078c116331 F ext/misc/vtablog.c 1100250ce8782db37c833e3a9a5c9a3ecf1af5e15b8325572b82e6e0a138ffb5 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 0fa0c082676b7868bf2fa918e911133f2b349bcdceabd1198bba5f65b4fc0668 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 984a9cc22c7c8492bf4fae482749663899b0e33a25c32e6ae5c5e98fc12bb83e -R 3ffeb05f71791678583efe8c7fde2e8f +P a4625bb995dd5582d1f3cf0c2e54eb3f01f1cc1405811dda86ebd38b2b858994 +R ebabd9c2e4304b7712ae90388c7cdfcd U drh -Z 039fb781952da1d6729d929a997aaf6e +Z 15e8c8f9f0fdde9a0f1575293da7227a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0e2fd340b0..3e6b81e608 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4625bb995dd5582d1f3cf0c2e54eb3f01f1cc1405811dda86ebd38b2b858994 +1d57b57c85bb8cb9b8a1808b771bb91eeb8150efd14f9064a390e533e715bab7 From 9dcf3d08c9edc0c30e07a6a06f9d0dd73bfad529 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 28 Jan 2025 19:03:37 +0000 Subject: [PATCH 082/115] Fix sessions module handling of tables with generated columns. FossilOrigin-Name: 437fb316389bc3c24c5cdb4d01edfc81e2c2e9f2b399fc2a95b05d279361d8ec --- ext/session/session_common.tcl | 8 +- ext/session/session_gen.test | 190 +++++++++++++++++++++++++++++++++ ext/session/sqlite3session.c | 130 +++++++++++++--------- manifest | 19 ++-- manifest.uuid | 2 +- src/vdbeapi.c | 31 +++--- 6 files changed, 308 insertions(+), 72 deletions(-) create mode 100644 ext/session/session_gen.test diff --git a/ext/session/session_common.tcl b/ext/session/session_common.tcl index 3ff84f1c5e..7c1273bb1a 100644 --- a/ext/session/session_common.tcl +++ b/ext/session/session_common.tcl @@ -201,12 +201,16 @@ proc compare_db {db1 db2} { foreach tbl $lot1 { set col1 [list] set col2 [list] + set quoted [list] $db1 eval "PRAGMA table_info = $tbl" { lappend col1 $name } - $db2 eval "PRAGMA table_info = $tbl" { lappend col2 $name } + $db2 eval "PRAGMA table_info = $tbl" { + lappend col2 $name + lappend quoted "\"[string map {\" \"\"} $name]\"" + } if {$col1 != $col2} { error "table $tbl schema mismatch" } - set sql "SELECT * FROM $tbl ORDER BY [join $col1 ,]" + set sql "SELECT * FROM $tbl ORDER BY [join $quoted ,]" set data1 [$db1 eval $sql] set data2 [$db2 eval $sql] if {$data1 != $data2} { diff --git a/ext/session/session_gen.test b/ext/session/session_gen.test new file mode 100644 index 0000000000..8d3c5887f3 --- /dev/null +++ b/ext/session/session_gen.test @@ -0,0 +1,190 @@ +# 2025 Jan 28 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. +# + +if {![info exists testdir]} { + set testdir [file join [file dirname [info script]] .. .. test] +} +source [file join [file dirname [info script]] session_common.tcl] +source $testdir/tester.tcl +ifcapable !session {finish_test; return} + +set testprefix session_gen + + +foreach {otn sct} { + 1 VIRTUAL + 2 STORED +} { +eval [string map [list %TYPE% $sct] { + reset_db + set testprefix $testprefix-$otn + +do_execsql_test 1.0 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + + CREATE TABLE t2(a INTEGER PRIMARY KEY, b AS (c+1) %TYPE%, c); + + CREATE TABLE t3( + a, + b AS (a+10) %TYPE%, + c, + d AS (c+1) %TYPE%, + e, + PRIMARY KEY(c, e) + ) WITHOUT ROWID; + + CREATE TABLE t4(a AS (c*100) %TYPE%, b INTEGER PRIMARY KEY, c); + + CREATE TABLE t5(x, y); +} + +foreach {tn sql changeset} { + + 0.1 { + INSERT INTO t5 VALUES('abc', 'def'); + } { + {INSERT t5 0 X.. {} {i 1 t abc t def}} + } + 0.2 { + UPDATE t5 SET y='xyz' WHERE rowid=1; + } { + {UPDATE t5 0 X.. {i 1 {} {} t def} {{} {} {} {} t xyz}} + } + 0.3 { + DELETE FROM t5; + } { + {DELETE t5 0 X.. {i 1 t abc t xyz} {}} + } + + 1.1 { + INSERT INTO t2 VALUES(1, 2); + INSERT INTO t2 VALUES(2, 123); + } { + {INSERT t2 0 X. {} {i 1 i 2}} + {INSERT t2 0 X. {} {i 2 i 123}} + } + 1.2 { + UPDATE t2 SET c=456 WHERE a=1 + } { + {UPDATE t2 0 X. {i 1 i 2} {{} {} i 456}} + } + + 1.3 { + DELETE FROM t2 WHERE a=2 + } { + {DELETE t2 0 X. {i 2 i 123} {}} + } + + 1.4 { + UPDATE t2 SET a=15 + } { + {INSERT t2 0 X. {} {i 15 i 456}} + {DELETE t2 0 X. {i 1 i 456} {}} + } + + 2.1 { + INSERT INTO t3 VALUES(5, 6, 7); + INSERT INTO t3 VALUES(8, 9, 10); + } { + {INSERT t3 0 .XX {} {i 8 i 9 i 10}} + {INSERT t3 0 .XX {} {i 5 i 6 i 7}} + } + + 2.2 { + UPDATE t3 SET a = 505 WHERE (c, e) = (6, 7); + } { + {UPDATE t3 0 .XX {i 5 i 6 i 7} {i 505 {} {} {} {}}} + } + + 2.3 { + DELETE FROM t3 WHERE (c, e) = (9, 10); + } { + {DELETE t3 0 .XX {i 8 i 9 i 10} {}} + } + + 2.4 { + UPDATE t3 SET c=1000 + } { + {DELETE t3 0 .XX {i 505 i 6 i 7} {}} + {INSERT t3 0 .XX {} {i 505 i 1000 i 7}} + } + + 3.1 { + INSERT INTO t4 VALUES(100, 100); + } { + {INSERT t4 0 X. {} {i 100 i 100}} + } + +} { + do_test 1.$tn.1 { + sqlite3session S db main + S object_config rowid 1 + S attach * + execsql $sql + } {} + + do_changeset_test 1.$tn.2 S $changeset + + S delete +} +#------------------------------------------------------------------------- +reset_db + +forcedelete test.db2 +sqlite3 db2 test.db2 + +do_common_sql { + CREATE TABLE t0(x INTEGER PRIMARY KEY, y); + INSERT INTO t0 VALUES(1, 'one'); + INSERT INTO t0 VALUES(2, 'two'); + + CREATE TABLE t1(a AS (c*10) %TYPE%, b INTEGER PRIMARY KEY, c); + INSERT INTO t1 VALUES(1, 5); + INSERT INTO t1 VALUES(2, 10); + INSERT INTO t1 VALUES(3, 5); + + CREATE TABLE t2( + a, b, c AS (a*b) %TYPE%, + 'k 1', 'k 2', PRIMARY KEY('k 1', 'k 2') + ) WITHOUT ROWID; + INSERT INTO t2 VALUES('a', 'b', 1, 11); + INSERT INTO t2 VALUES('A', 'B', 2, 22); + INSERT INTO t2 VALUES('Aa', 'Bb', 3, 33); +} + +foreach {tn sql} { + 1.1 { INSERT INTO t0 VALUES(4, 15) } + 1.2 { INSERT INTO t1 VALUES(4, 15) } + 1.3 { INSERT INTO t2 VALUES(1, 2, 3, 4) } + + 2.1 { UPDATE t1 SET c=100 WHERE b=2 } + 2.2 { UPDATE t2 SET a=11 } + + 3.1 { DELETE FROM t2 WHERE (t2.'k 1') = 2 } + 3.2 { DELETE FROM t1 } +} { + do_test 2.$tn.1 { + # execsql { PRAGMA vdbe_listing = 1 } db2 + do_then_apply_sql $sql + } {} + do_test 2.$tn.2 { + compare_db db db2 + } {} +} + +}]} + + + + +finish_test diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index a3f132add8..d78dd9b064 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -139,11 +139,13 @@ struct sqlite3_changeset_iter { struct SessionTable { SessionTable *pNext; char *zName; /* Local name of table */ - int nCol; /* Number of columns in table zName */ + int nCol; /* Number of non-hidden columns */ + int nTotalCol; /* Number of columns including hidden */ int bStat1; /* True if this is sqlite_stat1 */ int bRowid; /* True if this table uses rowid for PK */ const char **azCol; /* Column names */ const char **azDflt; /* Default value expressions */ + int *aiIdx; /* Index to pass to xNew/xOld */ u8 *abPK; /* Array of primary key flags */ int nEntry; /* Total number of entries in hash table */ int nChange; /* Size of apChange[] array */ @@ -546,22 +548,22 @@ static int sessionPreupdateHash( unsigned int h = 0; /* Hash value to return */ int i; /* Used to iterate through columns */ + assert( pTab->nTotalCol==pSession->hook.xCount(pSession->hook.pCtx) ); if( pTab->bRowid ){ - assert( pTab->nCol-1==pSession->hook.xCount(pSession->hook.pCtx) ); h = sessionHashAppendI64(h, iRowid); }else{ assert( *pbNullPK==0 ); - assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) ); for(i=0; inCol; i++){ if( pTab->abPK[i] ){ int rc; int eType; sqlite3_value *pVal; + int iIdx = pTab->aiIdx[i]; if( bNew ){ - rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal); + rc = pSession->hook.xNew(pSession->hook.pCtx, iIdx, &pVal); }else{ - rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal); + rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &pVal); } if( rc!=SQLITE_OK ) return rc; @@ -898,6 +900,7 @@ static int sessionPreupdateEqual( sqlite3_value *pVal; /* Value returned by preupdate_new/old */ int rc; /* Error code from preupdate_new/old */ int eType = *a++; /* Type of value from change record */ + int iIdx = pTab->aiIdx[iCol]; /* The following calls to preupdate_new() and preupdate_old() can not ** fail. This is because they cache their return values, and by the @@ -906,10 +909,10 @@ static int sessionPreupdateEqual( ** this (that the method has already been called). */ if( op==SQLITE_INSERT ){ /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */ - rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal); + rc = pSession->hook.xNew(pSession->hook.pCtx, iIdx, &pVal); }else{ /* assert( db->pPreUpdate->pUnpacked ); */ - rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal); + rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &pVal); } assert( rc==SQLITE_OK ); (void)rc; /* Suppress warning about unused variable */ @@ -1034,9 +1037,11 @@ static int sessionTableInfo( const char *zDb, /* Name of attached database (e.g. "main") */ const char *zThis, /* Table name */ int *pnCol, /* OUT: number of columns */ + int *pnTotalCol, /* OUT: number of hidden columns */ const char **pzTab, /* OUT: Copy of zThis */ const char ***pazCol, /* OUT: Array of column names for table */ const char ***pazDflt, /* OUT: Array of default value expressions */ + int **paiIdx, /* OUT: Array of xNew/xOld indexes */ u8 **pabPK, /* OUT: Array of booleans - true for PK col */ int *pbRowid /* OUT: True if only PK is a rowid */ ){ @@ -1051,6 +1056,7 @@ static int sessionTableInfo( char **azCol = 0; char **azDflt = 0; u8 *abPK = 0; + int *aiIdx = 0; int bRowid = 0; /* Set to true to use rowid as PK */ assert( pazCol && pabPK ); @@ -1058,6 +1064,8 @@ static int sessionTableInfo( *pazCol = 0; *pabPK = 0; *pnCol = 0; + if( pnTotalCol ) *pnTotalCol = 0; + if( paiIdx ) *paiIdx = 0; if( pzTab ) *pzTab = 0; if( pazDflt ) *pazDflt = 0; @@ -1067,9 +1075,9 @@ static int sessionTableInfo( if( rc==SQLITE_OK ){ /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ zPragma = sqlite3_mprintf( - "SELECT 0, 'tbl', '', 0, '', 1 UNION ALL " - "SELECT 1, 'idx', '', 0, '', 2 UNION ALL " - "SELECT 2, 'stat', '', 0, '', 0" + "SELECT 0, 'tbl', '', 0, '', 1, 0 UNION ALL " + "SELECT 1, 'idx', '', 0, '', 2, 0 UNION ALL " + "SELECT 2, 'stat', '', 0, '', 0, 0" ); }else if( rc==SQLITE_ERROR ){ zPragma = sqlite3_mprintf(""); @@ -1077,7 +1085,7 @@ static int sessionTableInfo( return rc; } }else{ - zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); + zPragma = sqlite3_mprintf("PRAGMA '%q'.table_xinfo('%q')", zDb, zThis); } if( !zPragma ){ return SQLITE_NOMEM; @@ -1094,7 +1102,9 @@ static int sessionTableInfo( while( SQLITE_ROW==sqlite3_step(pStmt) ){ nByte += sqlite3_column_bytes(pStmt, 1); /* name */ nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */ - nDbCol++; + if( sqlite3_column_int(pStmt, 6)==0 ){ /* !hidden */ + nDbCol++; + } if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */ } if( nDbCol==0 ) bRowid = 0; @@ -1103,7 +1113,7 @@ static int sessionTableInfo( rc = sqlite3_reset(pStmt); if( rc==SQLITE_OK ){ - nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1); + nByte += nDbCol * (sizeof(const char *)*2 +sizeof(int)+sizeof(u8) + 1 + 1); pAlloc = sessionMalloc64(pSession, nByte); if( pAlloc==0 ){ rc = SQLITE_NOMEM; @@ -1114,8 +1124,8 @@ static int sessionTableInfo( if( rc==SQLITE_OK ){ azCol = (char **)pAlloc; azDflt = (char**)&azCol[nDbCol]; - pAlloc = (u8 *)&azDflt[nDbCol]; - abPK = (u8 *)pAlloc; + aiIdx = (int*)&azDflt[nDbCol]; + abPK = (u8 *)&aiIdx[nDbCol]; pAlloc = &abPK[nDbCol]; if( pzTab ){ memcpy(pAlloc, zThis, nThis+1); @@ -1130,27 +1140,32 @@ static int sessionTableInfo( azCol[i] = (char*)pAlloc; pAlloc += nName+1; abPK[i] = 1; + aiIdx[i] = -1; i++; } while( SQLITE_ROW==sqlite3_step(pStmt) ){ - int nName = sqlite3_column_bytes(pStmt, 1); - int nDflt = sqlite3_column_bytes(pStmt, 4); - const unsigned char *zName = sqlite3_column_text(pStmt, 1); - const unsigned char *zDflt = sqlite3_column_text(pStmt, 4); + if( sqlite3_column_int(pStmt, 6)==0 ){ /* !hidden */ + int nName = sqlite3_column_bytes(pStmt, 1); + int nDflt = sqlite3_column_bytes(pStmt, 4); + const unsigned char *zName = sqlite3_column_text(pStmt, 1); + const unsigned char *zDflt = sqlite3_column_text(pStmt, 4); - if( zName==0 ) break; - memcpy(pAlloc, zName, nName+1); - azCol[i] = (char *)pAlloc; - pAlloc += nName+1; - if( zDflt ){ - memcpy(pAlloc, zDflt, nDflt+1); - azDflt[i] = (char *)pAlloc; - pAlloc += nDflt+1; - }else{ - azDflt[i] = 0; + if( zName==0 ) break; + memcpy(pAlloc, zName, nName+1); + azCol[i] = (char *)pAlloc; + pAlloc += nName+1; + if( zDflt ){ + memcpy(pAlloc, zDflt, nDflt+1); + azDflt[i] = (char *)pAlloc; + pAlloc += nDflt+1; + }else{ + azDflt[i] = 0; + } + abPK[i] = sqlite3_column_int(pStmt, 5); + aiIdx[i] = sqlite3_column_int(pStmt, 0); + i++; } - abPK[i] = sqlite3_column_int(pStmt, 5); - i++; + if( pnTotalCol ) (*pnTotalCol)++; } rc = sqlite3_reset(pStmt); } @@ -1163,6 +1178,7 @@ static int sessionTableInfo( if( pazDflt ) *pazDflt = (const char**)azDflt; *pabPK = abPK; *pnCol = nDbCol; + if( paiIdx ) *paiIdx = aiIdx; }else{ sessionFree(pSession, azCol); } @@ -1194,7 +1210,8 @@ static int sessionInitTable( u8 *abPK; assert( pTab->azCol==0 || pTab->abPK==0 ); rc = sessionTableInfo(pSession, db, zDb, - pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK, + pTab->zName, &pTab->nCol, &pTab->nTotalCol, 0, &pTab->azCol, + &pTab->azDflt, &pTab->aiIdx, &abPK, ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0) ); if( rc==SQLITE_OK ){ @@ -1229,15 +1246,17 @@ static int sessionInitTable( */ static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){ int nCol = 0; + int nTotalCol = 0; const char **azCol = 0; const char **azDflt = 0; + int *aiIdx = 0; u8 *abPK = 0; int bRowid = 0; assert( pSession->rc==SQLITE_OK ); pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, - pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK, + pTab->zName, &nCol, &nTotalCol, 0, &azCol, &azDflt, &aiIdx, &abPK, (pSession->bImplicitPK ? &bRowid : 0) ); if( pSession->rc==SQLITE_OK ){ @@ -1260,8 +1279,10 @@ static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){ const char **a = pTab->azCol; pTab->azCol = azCol; pTab->nCol = nCol; + pTab->nTotalCol = nTotalCol; pTab->azDflt = azDflt; pTab->abPK = abPK; + pTab->aiIdx = aiIdx; azCol = a; } if( pSession->bEnableSize ){ @@ -1579,7 +1600,7 @@ static int sessionUpdateMaxSize( int ii; for(ii=0; iinCol; ii++){ sqlite3_value *p = 0; - pSession->hook.xNew(pSession->hook.pCtx, ii, &p); + pSession->hook.xNew(pSession->hook.pCtx, pTab->aiIdx[ii], &p); sessionSerializeValue(0, p, &nNew); } } @@ -1599,8 +1620,9 @@ static int sessionUpdateMaxSize( int bChanged = 1; int nOld = 0; int eType; + int iIdx = pTab->aiIdx[ii]; sqlite3_value *p = 0; - pSession->hook.xNew(pSession->hook.pCtx, ii-pTab->bRowid, &p); + pSession->hook.xNew(pSession->hook.pCtx, iIdx, &p); if( p==0 ){ return SQLITE_NOMEM; } @@ -1697,11 +1719,11 @@ static void sessionPreupdateOneChange( /* Check the number of columns in this xPreUpdate call matches the ** number of columns in the table. */ nExpect = pSession->hook.xCount(pSession->hook.pCtx); - if( (pTab->nCol-pTab->bRowid)nTotalColnCol-pTab->bRowid)!=nExpect ){ + if( pTab->nTotalCol!=nExpect ){ pSession->rc = SQLITE_SCHEMA; return; } @@ -1758,14 +1780,15 @@ static void sessionPreupdateOneChange( /* Figure out how large an allocation is required */ nByte = sizeof(SessionChange); - for(i=0; i<(pTab->nCol-pTab->bRowid); i++){ + for(i=pTab->bRowid; inCol; i++){ + int iIdx = pTab->aiIdx[i]; sqlite3_value *p = 0; if( op!=SQLITE_INSERT ){ /* This may fail if the column has a non-NULL default and was added ** using ALTER TABLE ADD COLUMN after this record was created. */ - rc = pSession->hook.xOld(pSession->hook.pCtx, i, &p); + rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &p); }else if( pTab->abPK[i] ){ - TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx, i, &p); + TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx,iIdx,&p); assert( trc==SQLITE_OK ); } @@ -1800,12 +1823,13 @@ static void sessionPreupdateOneChange( sessionPutI64(&pC->aRecord[1], iRowid); nByte = 9; } - for(i=0; i<(pTab->nCol-pTab->bRowid); i++){ + for(i=pTab->bRowid; inCol; i++){ sqlite3_value *p = 0; + int iIdx = pTab->aiIdx[i]; if( op!=SQLITE_INSERT ){ - pSession->hook.xOld(pSession->hook.pCtx, i, &p); + pSession->hook.xOld(pSession->hook.pCtx, iIdx, &p); }else if( pTab->abPK[i] ){ - pSession->hook.xNew(pSession->hook.pCtx, i, &p); + pSession->hook.xNew(pSession->hook.pCtx, iIdx, &p); } sessionSerializeValue(&pC->aRecord[nByte], p, &nByte); } @@ -2207,7 +2231,8 @@ int sqlite3session_diff( int bRowid = 0; u8 *abPK; const char **azCol = 0; - rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK, + rc = sessionTableInfo(0, db, zFrom, zTbl, + &nCol, 0, 0, &azCol, 0, 0, &abPK, pSession->bImplicitPK ? &bRowid : 0 ); if( rc==SQLITE_OK ){ @@ -2784,10 +2809,10 @@ static int sessionSelectStmt( int rc = SQLITE_OK; char *zSql = 0; const char *zSep = ""; - const char *zCols = bRowid ? SESSIONS_ROWID ", *" : "*"; int nSql = -1; int i; + SessionBuffer cols = {0, 0, 0}; SessionBuffer nooptest = {0, 0, 0}; SessionBuffer pkfield = {0, 0, 0}; SessionBuffer pkvar = {0, 0, 0}; @@ -2800,9 +2825,16 @@ static int sessionSelectStmt( sessionAppendStr(&pkvar, "?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc ); - zCols = "tbl, ?2, stat"; + sessionAppendStr(&cols, "tbl, ?2, stat", &rc); }else{ + #if 0 + if( bRowid ){ + sessionAppendStr(&cols, SESSIONS_ROWID, &rc); + } + #endif for(i=0; ipPk ){ - iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx); + iStore = sqlite3TableColumnToIndex(p->pPk, iIdx); + }else{ + iStore = sqlite3TableColumnToStorage(p->pTab, iIdx); } - if( iIdx>=p->pCsr->nField || iIdx<0 ){ + if( iStore>=p->pCsr->nField || iStore<0 ){ rc = SQLITE_RANGE; goto preupdate_old_out; } @@ -2224,8 +2227,8 @@ int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ p->aRecord = aRec; } - pMem = *ppValue = &p->pUnpacked->aMem[iIdx]; - if( iIdx>=p->pUnpacked->nField ){ + pMem = *ppValue = &p->pUnpacked->aMem[iStore]; + if( iStore>=p->pUnpacked->nField ){ /* This occurs when the table has been extended using ALTER TABLE ** ADD COLUMN. The value to return is the default value of the column. */ Column *pCol = &p->pTab->aCol[iIdx]; @@ -2329,6 +2332,7 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ PreUpdate *p; int rc = SQLITE_OK; Mem *pMem; + int iStore = 0; #ifdef SQLITE_ENABLE_API_ARMOR if( db==0 || ppValue==0 ){ @@ -2341,9 +2345,12 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ goto preupdate_new_out; } if( p->pPk && p->op!=SQLITE_UPDATE ){ - iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx); + iStore = sqlite3TableColumnToIndex(p->pPk, iIdx); + }else{ + iStore = sqlite3TableColumnToStorage(p->pTab, iIdx); } - if( iIdx>=p->pCsr->nField || iIdx<0 ){ + + if( iStore>=p->pCsr->nField || iStore<0 ){ rc = SQLITE_RANGE; goto preupdate_new_out; } @@ -2363,14 +2370,14 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ } p->pNewUnpacked = pUnpack; } - pMem = &pUnpack->aMem[iIdx]; + pMem = &pUnpack->aMem[iStore]; if( iIdx==p->pTab->iPKey ){ sqlite3VdbeMemSetInt64(pMem, p->iKey2); - }else if( iIdx>=pUnpack->nField ){ + }else if( iStore>=pUnpack->nField ){ pMem = (sqlite3_value *)columnNullValue(); } }else{ - /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required + /* For an UPDATE, memory cell (p->iNewReg+1+iStore) contains the required ** value. Make a copy of the cell contents and return a pointer to it. ** It is not safe to return a pointer to the memory cell itself as the ** caller may modify the value text encoding. @@ -2383,13 +2390,13 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ goto preupdate_new_out; } } - assert( iIdx>=0 && iIdxpCsr->nField ); - pMem = &p->aNew[iIdx]; + assert( iStore>=0 && iStorepCsr->nField ); + pMem = &p->aNew[iStore]; if( pMem->flags==0 ){ if( iIdx==p->pTab->iPKey ){ sqlite3VdbeMemSetInt64(pMem, p->iKey2); }else{ - rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]); + rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iStore]); if( rc!=SQLITE_OK ) goto preupdate_new_out; } } From 36279c256b722ba00e7737b9f4050b264e0be0db Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 28 Jan 2025 20:32:48 +0000 Subject: [PATCH 083/115] Enhance the if() and iif() SQL functions so that they support any number of arguments greater than or equal to two. Suggested by [forum:/forumpost/40f7867f75f80|forum post 40f7867f75f80]. FossilOrigin-Name: fb76d184ee5afc41009c4023bb68b3ddd42c9235a79ec9695c26f5bbe9a1aa25 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 6 ++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 1c1778f249..39bf2bf6db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssessions\smodule\shandling\sof\stables\swith\sgenerated\scolumns. -D 2025-01-28T19:03:37.907 +C Enhance\sthe\sif()\sand\siif()\sSQL\sfunctions\sso\sthat\sthey\ssupport\sany\nnumber\sof\sarguments\sgreater\sthan\sor\sequal\sto\stwo.\nSuggested\sby\s[forum:/forumpost/40f7867f75f80|forum\spost\s40f7867f75f80]. +D 2025-01-28T20:32:48.256 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -733,7 +733,7 @@ F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c ce83e7361454a195f8393fa0baad694e2fee6c49a44c0d6db44d8a2b92534aeb F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f -F src/func.c 30051410d0379059e1e3642ffc0caae6963a2b01b3b6d9dd44c5e09b1a66d066 +F src/func.c f5b31c805679930cc5afcdfb1e657f9dd273053f52ff51133df5a448c519e5d9 F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1d57b57c85bb8cb9b8a1808b771bb91eeb8150efd14f9064a390e533e715bab7 -R 28bdb97771277a5a6a62f1ef55b562ac -U dan -Z 3453954a42c7f4fd97cc752d61f14e68 +P 437fb316389bc3c24c5cdb4d01edfc81e2c2e9f2b399fc2a95b05d279361d8ec +R 79d5061e2e3bbb1ea5ad89bea1a7b048 +U drh +Z 108486be1053ae42ce8d5fd32905dfdb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a854f9c995..ae82b8d99e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -437fb316389bc3c24c5cdb4d01edfc81e2c2e9f2b399fc2a95b05d279361d8ec +fb76d184ee5afc41009c4023bb68b3ddd42c9235a79ec9695c26f5bbe9a1aa25 diff --git a/src/func.c b/src/func.c index 2bd4be31ca..bd25a44d4a 100644 --- a/src/func.c +++ b/src/func.c @@ -2808,10 +2808,8 @@ void sqlite3RegisterBuiltinFunctions(void){ #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ FUNCTION(sign, 1, 0, 0, signFunc ), INLINE_FUNC(coalesce, -4, INLINEFUNC_coalesce, 0 ), - INLINE_FUNC(iif, 2, INLINEFUNC_iif, 0 ), - INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ), - INLINE_FUNC(if, 2, INLINEFUNC_iif, 0 ), - INLINE_FUNC(if, 3, INLINEFUNC_iif, 0 ), + INLINE_FUNC(iif, -4, INLINEFUNC_iif, 0 ), + INLINE_FUNC(if, -4, INLINEFUNC_iif, 0 ), }; #ifndef SQLITE_OMIT_ALTERTABLE sqlite3AlterFunctions(); From 4f8f1965f77dece3c5a87fb95a3e350c5c9ae901 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 29 Jan 2025 18:53:19 +0000 Subject: [PATCH 084/115] Fix bug in sessions handling of FK constraints introduced by [e09a0c02] (released in 3.48.0). Bug was preventing a changeset containing FK violations from being applied even when the xConflict(CHANGESET_FOREIGN_KEY) returned OMIT. FossilOrigin-Name: d7c07581203a0a88456588e49e51b40a8341b0e7121809f75be0ee882d91650f --- ext/session/session1.test | 2 +- ext/session/session9.test | 4 +-- ext/session/sessionnoact.test | 66 ++++++++++++++++++++++++++++++++++- ext/session/sqlite3session.c | 5 +++ manifest | 20 +++++------ manifest.uuid | 2 +- 6 files changed, 84 insertions(+), 15 deletions(-) diff --git a/ext/session/session1.test b/ext/session/session1.test index dfc1aa8957..6da9051791 100644 --- a/ext/session/session1.test +++ b/ext/session/session1.test @@ -285,7 +285,7 @@ do_conflict_test $tn.3.2.3 -tables t2 -sql { {FOREIGN_KEY 1} } do_execsql_test $tn.3.2.4 "SELECT * FROM t2" {} -do_db2_test $tn.3.2.5 "SELECT * FROM t2" {1 one 2 two 4 five} +do_db2_test $tn.3.2.5 "SELECT * FROM t2" {4 five} # Test UPDATE changesets. # diff --git a/ext/session/session9.test b/ext/session/session9.test index 6b7d1648b2..5c406c344e 100644 --- a/ext/session/session9.test +++ b/ext/session/session9.test @@ -80,7 +80,7 @@ foreach {tn delrow trans conflictargs conflictret} { 8 3 1 {FOREIGN_KEY 1} ABORT } { - set A(OMIT,0) {1 SQLITE_CONSTRAINT} + set A(OMIT,0) {0 {}} set A(OMIT,1) {0 {}} set A(ABORT,0) {1 SQLITE_CONSTRAINT} set A(ABORT,1) {1 SQLITE_CONSTRAINT} @@ -95,7 +95,7 @@ foreach {tn delrow trans conflictargs conflictret} { do_test 1.2.$tn.2 { set ::xConflict } $conflictargs - set A(OMIT,0) {0 0} + set A(OMIT,0) {1 1} set A(OMIT,1) {1 1} set A(ABORT,0) {0 0} set A(ABORT,1) {0 0} diff --git a/ext/session/sessionnoact.test b/ext/session/sessionnoact.test index e447bc8a16..54e9a62151 100644 --- a/ext/session/sessionnoact.test +++ b/ext/session/sessionnoact.test @@ -59,7 +59,7 @@ do_execsql_test 1.2 { set ::nConflict 0 proc conflict {args} { incr ::nConflict - return "OMIT" + return "ABORT" } sqlite3changeset_apply_v2 db $C conflict @@ -111,6 +111,9 @@ do_execsql_test 1.8 { # Check that a changeset that causes an FK violation may not be applied, # even if SQLITE_CHANGESETAPPLY_FKNOACTION is specified. # +# UPDATE: Unless the conflict-handler returns OMIT. In that case it can +# be committed. See test cases 3.* in this file. +# reset_db do_execsql_test 2.0 { CREATE TABLE p1(a INTEGER PRIMARY KEY, b, c UNIQUE); @@ -164,5 +167,66 @@ do_execsql_test 2.8 { SELECT * FROM c1; } {two} +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 3.0 { + CREATE TABLE p1(a INTEGER PRIMARY KEY, b, c UNIQUE); + INSERT INTO p1 VALUES(1, 1, 'one'); + INSERT INTO p1 VALUES(2, 2, 'two'); + + CREATE TABLE c1(x REFERENCES p1(c) ON DELETE CASCADE); + INSERT INTO c1 VALUES('two'); +} + +set ::nConflict 0 +proc conflict {args} { + incr ::nConflict + return "OMIT" +} + +db_save + +set C [changeset_from_sql { + DELETE FROM p1 WHERE a=2; +}] + +db_restore_and_reopen + +do_test 3.1 { + sqlite3changeset_apply_v2 -noaction db $C conflict +} {} +do_execsql_test 3.2 { + SELECT * FROM p1 +} {1 1 one} + +db_restore_and_reopen +db eval { PRAGMA foreign_keys = 1 } + +do_test 3.3 { + list [catch { sqlite3changeset_apply_v2 -noaction db $C conflict } msg] $msg +} {0 {}} +do_execsql_test 3.4 { + SELECT * FROM p1; +} {1 1 one} +do_execsql_test 3.5 { + SELECT * FROM c1; +} {two} + +db_restore_and_reopen +db eval { PRAGMA foreign_keys = 1 } + +do_test 3.6 { + list [catch { + sqlite3changeset_apply_v2 -ignorenoop -noaction db $C conflict + } msg] $msg +} {0 {}} +do_execsql_test 3.7 { + SELECT * FROM p1; +} {1 1 one} +do_execsql_test 3.8 { + SELECT * FROM c1; +} {two} + finish_test diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index d78dd9b064..66b21d63ac 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -5318,6 +5318,11 @@ static int sessionChangesetApply( } } + { + int rc2 = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0); + if( rc==SQLITE_OK ) rc = rc2; + } + if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){ if( rc==SQLITE_OK ){ rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0); diff --git a/manifest b/manifest index 39bf2bf6db..eec067567d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sif()\sand\siif()\sSQL\sfunctions\sso\sthat\sthey\ssupport\sany\nnumber\sof\sarguments\sgreater\sthan\sor\sequal\sto\stwo.\nSuggested\sby\s[forum:/forumpost/40f7867f75f80|forum\spost\s40f7867f75f80]. -D 2025-01-28T20:32:48.256 +C Fix\sbug\sin\ssessions\shandling\sof\sFK\sconstraints\sintroduced\sby\s[e09a0c02]\s(released\sin\s3.48.0).\sBug\swas\spreventing\sa\schangeset\scontaining\sFK\sviolations\sfrom\sbeing\sapplied\seven\swhen\sthe\sxConflict(CHANGESET_FOREIGN_KEY)\sreturned\sOMIT. +D 2025-01-29T18:53:19.277 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -576,14 +576,14 @@ F ext/rtree/visual01.txt e9c2564083bcd30ec51b07f881bffbf0e12b50a3f6fced0c222c5c1 F ext/session/changeset.c 7a1e6a14c7e92d36ca177e92e88b5281acd709f3b726298dc34ec0fb58869cb5 F ext/session/changesetfuzz.c 227076ab0ae4447d742c01ee88a564da6478bbf26b65108bf8fac9cd8b0b24aa F ext/session/changesetfuzz1.test 15b629004e58d5ffcc852e6842a603775bb64b1ce51254831f3d12b113b616cd -F ext/session/session1.test 8d0509cd3fcfdee6a33422d5fe5c95a9770d62a0b8588adb0177ecdf79b2c345 +F ext/session/session1.test cc7e58976c2cc6263fb7ef0c5125a98eafc2f213c75929f986768d2dbc224725 F ext/session/session2.test ee83bb973b9ce17ccce4db931cdcdae65eb40bbb22089b2fe6aa4f6be3b9303f F ext/session/session3.test 2cc1629cfb880243aec1a7251145e07b78411d851b39b2aa1390704550db8e6a F ext/session/session4.test 823f6f018fcbb8dacf61e2960f8b3b848d492b094f8b495eae1d9407d9ab7219 F ext/session/session5.test 716bc6fafd625ce60dfa62ae128971628c1a1169 F ext/session/session6.test 35279f2ec45448cd2e24a61688219dc6cf7871757716063acf4a8b5455e1e926 F ext/session/session8.test 326f3273abf9d5d2d7d559eee8f5994c4ea74a5d935562454605e6607ee29904 -F ext/session/session9.test be090b1420f3824a573da9e56ff542b1e1c2a4f772118e9ab2f75774e66d25d0 +F ext/session/session9.test 4e3aff62d6b4294498ddbe309076de06f4fddffad4fe5f5a6c033358b01df083 F ext/session/sessionA.test 1feeab0b8e03527f08f2f1defb442da25480138f F ext/session/sessionB.test c4fb7f8a688787111606e123a555f18ee04f65bb9f2a4bb2aa71d55ce4e6d02c F ext/session/sessionC.test f8a5508bc059ae646e5ec9bdbca66ad24bc92fe99fda5790ac57e1f59fce2fdf @@ -607,7 +607,7 @@ F ext/session/sessionfault2.test b0d6a7c1d7398a7e800d84657404909c7d385965ea8576d F ext/session/sessionfault3.test ce0b5d182133935c224d72507dbf1c5be1a1febf7e85d0b0fbd6d2f724b32b96 F ext/session/sessioninvert.test 04075517a9497a80d39c495ba6b44f3982c7371129b89e2c52219819bc105a25 F ext/session/sessionmem.test f2a735db84a3e9e19f571033b725b0b2daf847f3f28b1da55a0c1a4e74f1de09 -F ext/session/sessionnoact.test 0f552bd318b764bbc5b2cd6f3518435254a1c830fdaa5aab9c688f507ebc301e +F ext/session/sessionnoact.test 4c7ae5c7d351cb5323bca62b6b095592ad24bd90a6713c178b62ab0063d23e19 F ext/session/sessionnoop.test a9366a36a95ef85f8a3687856ebef46983df399541174cb1ede2ee53b8011bc7 F ext/session/sessionnoop2.test de4672dce88464396ec9f30ed08c6c01643a69c53ae540fadbbf6d30642d64e8 F ext/session/sessionrebase.test 702378bdcb5062f1106e74457beca8797d09c113a81768734a58b197b5b334e2 @@ -615,7 +615,7 @@ F ext/session/sessionrowid.test 85187c2f1b38861a5844868126f69f9ec62223a03449a98a F ext/session/sessionsize.test 8fcf4685993c3dbaa46a24183940ab9f5aa9ed0d23e5fb63bfffbdb56134b795 F ext/session/sessionstat1.test 5e718d5888c0c49bbb33a7a4f816366db85f59f6a4f97544a806421b85dc2dec F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009ecef8511f4cf3fc -F ext/session/sqlite3session.c b2047d4b6c343f92d1c5cead3a7f529d074db01ceb4724f5ec4cd361379afb38 +F ext/session/sqlite3session.c 01e321269fe21982b79336c8b7a4b83ef0779f5c1644a04c8bb7c1174c8c71ae F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd8097fa4bca569104b F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 437fb316389bc3c24c5cdb4d01edfc81e2c2e9f2b399fc2a95b05d279361d8ec -R 79d5061e2e3bbb1ea5ad89bea1a7b048 -U drh -Z 108486be1053ae42ce8d5fd32905dfdb +P fb76d184ee5afc41009c4023bb68b3ddd42c9235a79ec9695c26f5bbe9a1aa25 +R 7bb63bb81389e805cac068949f19d72e +U dan +Z ad8a1ab5c6c6b8d1277c1e707cdd7fec # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ae82b8d99e..b65314c307 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fb76d184ee5afc41009c4023bb68b3ddd42c9235a79ec9695c26f5bbe9a1aa25 +d7c07581203a0a88456588e49e51b40a8341b0e7121809f75be0ee882d91650f From 00d6b7abfccfcf33c45bbb162dcc0fcadce6e5c3 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 30 Jan 2025 11:19:16 +0000 Subject: [PATCH 085/115] Fix build regression, introduced in [d2fe6b05f38d9d] (3.48.0), in which SQLITE_OMIT and SQLITE_ENABLE flags passed to configure via CFLAGS were not propagated to the OPT_FEATURE_FLAGS list. Reported in [forum:9801e54665afd728|forum post 9801e54665afd728]. FossilOrigin-Name: ec71d9dcd582188d7fb4ab945187de1023eaaecffeeb2903a6fcc49650bd21e9 --- autosetup/sqlite-config.tcl | 14 ++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 40941687e4..90e4d7dbcc 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -226,6 +226,20 @@ proc sqlite-setup-default-cflags {} { define CFLAGS [proj-get-env CFLAGS $defaultCFlags] # BUILD_CFLAGS is the CFLAGS for CC_FOR_BUILD. define BUILD_CFLAGS [proj-get-env BUILD_CFLAGS {-g}] + + # Copy all CFLAGS entries matching -DSQLITE_OMIT* and + # -DSQLITE_ENABLE* to OPT_FEATURE_FLAGS. This behavior is derived + # from the legacy build and was missing the 3.48.0 release (the + # initial Autosetup port). + # https://sqlite.org/forum/forumpost/9801e54665afd728 + foreach cf [get-define CFLAGS ""] { + switch -glob -- $cf { + -DSQLITE_OMIT* - + -DSQLITE_ENABLE* { + sqlite-add-feature-flag $cf + } + } + } } ######################################################################## diff --git a/manifest b/manifest index eec067567d..b7e2d3655a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sbug\sin\ssessions\shandling\sof\sFK\sconstraints\sintroduced\sby\s[e09a0c02]\s(released\sin\s3.48.0).\sBug\swas\spreventing\sa\schangeset\scontaining\sFK\sviolations\sfrom\sbeing\sapplied\seven\swhen\sthe\sxConflict(CHANGESET_FOREIGN_KEY)\sreturned\sOMIT. -D 2025-01-29T18:53:19.277 +C Fix\sbuild\sregression,\sintroduced\sin\s[d2fe6b05f38d9d]\s(3.48.0),\sin\swhich\sSQLITE_OMIT\sand\sSQLITE_ENABLE\sflags\spassed\sto\sconfigure\svia\sCFLAGS\swere\snot\spropagated\sto\sthe\sOPT_FEATURE_FLAGS\slist.\sReported\sin\s[forum:9801e54665afd728|forum\spost\s9801e54665afd728]. +D 2025-01-30T11:19:16.519 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -50,7 +50,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 9adf1539673cef15bff862d9360b479e6920cc2c0d85de707b0ba31c04ce4531 -F autosetup/sqlite-config.tcl f37f6961c8fb2454960f97a28011a29994f6c591b1da392a9ae28af96e0c15a2 +F autosetup/sqlite-config.tcl e5de87d000ef5fa4ed78663c74688bbdd989b59bf5bae2aabaff65a502b0ec80 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fb76d184ee5afc41009c4023bb68b3ddd42c9235a79ec9695c26f5bbe9a1aa25 -R 7bb63bb81389e805cac068949f19d72e -U dan -Z ad8a1ab5c6c6b8d1277c1e707cdd7fec +P d7c07581203a0a88456588e49e51b40a8341b0e7121809f75be0ee882d91650f +R 1c8a0d642354e8cc82e464f25cf69897 +U stephan +Z 9d44f698cd53e225ebbddcb3eac9dddd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b65314c307..9ef3858dd5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d7c07581203a0a88456588e49e51b40a8341b0e7121809f75be0ee882d91650f +ec71d9dcd582188d7fb4ab945187de1023eaaecffeeb2903a6fcc49650bd21e9 From 1392ff5533b467beb96f3780928d80f38305891a Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 30 Jan 2025 12:01:24 +0000 Subject: [PATCH 086/115] Disable a test case that (intentionally) does use-after-free, as it does occasionally cause problems even for non-sanitizer builds. FossilOrigin-Name: 23c7d5bea351c04785153ddb30e19c1236db9d11054ab8229893531026b53655 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/capi3.test | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b7e2d3655a..736757ee45 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sbuild\sregression,\sintroduced\sin\s[d2fe6b05f38d9d]\s(3.48.0),\sin\swhich\sSQLITE_OMIT\sand\sSQLITE_ENABLE\sflags\spassed\sto\sconfigure\svia\sCFLAGS\swere\snot\spropagated\sto\sthe\sOPT_FEATURE_FLAGS\slist.\sReported\sin\s[forum:9801e54665afd728|forum\spost\s9801e54665afd728]. -D 2025-01-30T11:19:16.519 +C Disable\sa\stest\scase\sthat\s(intentionally)\sdoes\suse-after-free,\sas\sit\sdoes\noccasionally\scause\sproblems\seven\sfor\snon-sanitizer\sbuilds. +D 2025-01-30T12:01:24.848 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -990,7 +990,7 @@ F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de F test/cacheflush.test af25bb1509df04c1da10e38d8f322d66eceedf61 F test/cachespill.test 895997f84a25b323b166aecb69baab2d6380ea98f9e0bcc688c4493c535cfab9 F test/capi2.test 4ee545824adc3eb33bf57ef89f77440b28188ec3da72e5425ff0fcdba32e8d5a -F test/capi3.test 4892b5e53d2a6941edc9d204a0ab174dd66e8689282d9a15e4384561c3965945 +F test/capi3.test ab90c548969613315605c555a8623f6b56e00e28d451c46a17ef73683c422c70 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test 31d3a6778f2d06f2d9222bd7660c41a516d1518a059b069e96ebbeadb5a490f7 F test/capi3d.test 8b778794af891b0dca3d900bd345fbc8ebd2aa2aae425a9dccdd10d5233dfbde @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d7c07581203a0a88456588e49e51b40a8341b0e7121809f75be0ee882d91650f -R 1c8a0d642354e8cc82e464f25cf69897 -U stephan -Z 9d44f698cd53e225ebbddcb3eac9dddd +P ec71d9dcd582188d7fb4ab945187de1023eaaecffeeb2903a6fcc49650bd21e9 +R 7b8d1f95b47e47a5d559070e34819714 +U drh +Z 470d847ca31236034508764b46198386 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9ef3858dd5..793cb84d2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec71d9dcd582188d7fb4ab945187de1023eaaecffeeb2903a6fcc49650bd21e9 +23c7d5bea351c04785153ddb30e19c1236db9d11054ab8229893531026b53655 diff --git a/test/capi3.test b/test/capi3.test index e65f90e3aa..6319d8284d 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -689,7 +689,9 @@ do_test capi3-6.3 { sqlite3_finalize $STMT } {SQLITE_OK} -if {[clang_sanitize_address]==0} { +if {0 && [clang_sanitize_address]==0} { + # This use-after-free occasionally causes segfaults during ordinary + # builds. Let's just disable it completely. do_test capi3-6.4-misuse { db cache flush sqlite3_close $DB From 73dcf45a3d9bcd7da13dffa59b090de3dcfd10bb Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 30 Jan 2025 12:19:30 +0000 Subject: [PATCH 087/115] Minor code de-duplication across the top-level auto.def and autoconf/auto.def. FossilOrigin-Name: 3c990d77cb83ab371d92c97e0528f790ab6126c60f48ff77e48bd166d7834cf0 --- auto.def | 2 -- autoconf/auto.def | 2 -- autosetup/sqlite-config.tcl | 22 +++++++++++++++++----- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/auto.def b/auto.def index dade81613f..52c758850c 100644 --- a/auto.def +++ b/auto.def @@ -275,8 +275,6 @@ sqlite-handle-load-extension sqlite-handle-math sqlite-handle-icu sqlite-handle-emsdk -sqlite-handle-common-feature-flags -sqlite-show-feature-flags sqlite-process-dot-in-files sqlite-post-config-validation sqlite-dump-defines diff --git a/autoconf/auto.def b/autoconf/auto.def index 0f36e733ca..12eb3d75c3 100644 --- a/autoconf/auto.def +++ b/autoconf/auto.def @@ -90,8 +90,6 @@ sqlite-handle-line-editing sqlite-handle-load-extension sqlite-handle-math sqlite-handle-icu -sqlite-handle-common-feature-flags -sqlite-show-feature-flags define ENABLE_LIB_SHARED [opt-bool shared] define ENABLE_LIB_STATIC [opt-bool static] diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 90e4d7dbcc..9f300e317d 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -232,6 +232,10 @@ proc sqlite-setup-default-cflags {} { # from the legacy build and was missing the 3.48.0 release (the # initial Autosetup port). # https://sqlite.org/forum/forumpost/9801e54665afd728 + # + # If any configure flags for features are in conflict with + # CFLAGS-specified feature flags, all bets are off. There are no + # guarantees about which one will take precedence. foreach cf [get-define CFLAGS ""] { switch -glob -- $cf { -DSQLITE_OMIT* - @@ -307,8 +311,9 @@ proc sqlite-handle-common-feature-flags {} { } ######################################################################### -# Show the final feature flag sets. -proc sqlite-show-feature-flags {} { +# Remove duplicates from the final feature flag sets and show them to +# the user. +proc sqlite-finalize-feature-flags {} { set oFF [get-define OPT_FEATURE_FLAGS] if {"" ne $oFF} { define OPT_FEATURE_FLAGS [lsort -unique $oFF] @@ -319,7 +324,6 @@ proc sqlite-show-feature-flags {} { define OPT_SHELL [lsort -unique $oFF] msg-result "Shell options: [get-define OPT_SHELL]" } - #parray ::sqliteConfig } ######################################################################## @@ -858,13 +862,21 @@ proc sqlite-handle-math {} { } ######################################################################## -# Generate the configure-process output file(s). +# Perform some late-stage work and generate the configure-process +# output file(s). proc sqlite-process-dot-in-files {} { ######################################################################## # When cross-compiling, we have to avoid using the -s flag to - # /usr/bin/install: https://sqlite.org/forum/forumpost/9a67df63eda9925c + # /usr/bin/install: + # https://sqlite.org/forum/forumpost/9a67df63eda9925c define IS_CROSS_COMPILING $::sqliteConfig(is-cross-compiling) + # Finish up handling of the various feature flags here because it's + # convenient for both the canonical build and autoconf bundles that + # it be done here. + sqlite-handle-common-feature-flags + sqlite-finalize-feature-flags + ######################################################################## # "Re-export" the autoconf-conventional --XYZdir flags into something # which is more easily overridable from a make invocation. See the docs diff --git a/manifest b/manifest index 736757ee45..ce04412697 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sa\stest\scase\sthat\s(intentionally)\sdoes\suse-after-free,\sas\sit\sdoes\noccasionally\scause\sproblems\seven\sfor\snon-sanitizer\sbuilds. -D 2025-01-30T12:01:24.848 +C Minor\scode\sde-duplication\sacross\sthe\stop-level\sauto.def\sand\sautoconf/auto.def. +D 2025-01-30T12:19:30.898 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -14,13 +14,13 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 -F auto.def caf7cca9c235fc6a3d7639e00eb75972d9bf8527717498b9fa1d7112d50b5720 +F auto.def e7e92090c98aeb0174d29988c259834eb1b71ae1ea927015c3ef300f6f9b68ae F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac F autoconf/Makefile.in 56697ad25ecf23afa317148b06bdc14f85960b42e5ec434ac1ba87f63a3cb789 F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 F autoconf/README.first f1d3876e9a7852c22f275a6f06814e64934cecbc0b5b9617d64849094c1fd136 F autoconf/README.txt 7f01dc3915e2d68f329011073662369e62a0938a2c69398807823c57591cb288 -F autoconf/auto.def 623e0d2339cbccc86b1c5e58d65702dc91a9fec4843a4c6198139e248579858e +F autoconf/auto.def 23bc095a3890c0ca334abf7ef67d1c8af4c22c12832bcc738015e868d54fe9d7 F autoconf/tea/Makefile.in ba0556fee8da09c066bad85a4457904e46ee2c2eabaa309c0e83a78f2f151a8e F autoconf/tea/README.txt 61e62e519579e4a112791354d6d440f8b51ea6db3b0bab58d59f29df42d2dfe3 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -50,7 +50,7 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/proj.tcl 9adf1539673cef15bff862d9360b479e6920cc2c0d85de707b0ba31c04ce4531 -F autosetup/sqlite-config.tcl e5de87d000ef5fa4ed78663c74688bbdd989b59bf5bae2aabaff65a502b0ec80 +F autosetup/sqlite-config.tcl 00af5b9d94d580367bf01984b86397e8d35b74090427def9591a54ded0e1a287 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ec71d9dcd582188d7fb4ab945187de1023eaaecffeeb2903a6fcc49650bd21e9 -R 7b8d1f95b47e47a5d559070e34819714 -U drh -Z 470d847ca31236034508764b46198386 +P 23c7d5bea351c04785153ddb30e19c1236db9d11054ab8229893531026b53655 +R ba9c9d617d2000ba71d01bbdea8f462f +U stephan +Z 94fb984dd769f6092f86cd16435effad # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 793cb84d2a..dcfee8e9d0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -23c7d5bea351c04785153ddb30e19c1236db9d11054ab8229893531026b53655 +3c990d77cb83ab371d92c97e0528f790ab6126c60f48ff77e48bd166d7834cf0 From 8dacf71043d9ed61f32a5a643b89cea8460254a3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 30 Jan 2025 13:54:32 +0000 Subject: [PATCH 088/115] Updates to the compile-for-windows.md document. FossilOrigin-Name: bcd22ed686954657ba820d53dec255d33797924f76e57b931016813581e04e06 --- doc/compile-for-windows.md | 9 +++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/doc/compile-for-windows.md b/doc/compile-for-windows.md index 717569dd78..2e62286339 100644 --- a/doc/compile-for-windows.md +++ b/doc/compile-for-windows.md @@ -43,8 +43,13 @@ systems, including MacOS. or .
  • Untar or unzip the source archive. CD into the "win/" subfolder of the source tree. -
  • Run: `nmake /f makefile.vc release` -
  • Run: `nmake /f makefile.vc INSTALLDIR=c:\Tcl install` +
  • Run: `nmake /f makefile.vc INSTALLDIR=c:\Tcl release` +
  • Run: `nmake /f makefile.vc INSTALLDIR=c:\Tcl install`
    + Notes: +
      +
    1. The previous two `nmake` commands must be run separately. +
    2. Also, the INSTALLDIR=... argument is required on both. +
  • Optional: CD to `c:\Tcl\bin` and make a copy of `tclsh90.exe` over into just `tclsh.exe`.
  • Optional: diff --git a/manifest b/manifest index ce04412697..12685bd00c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\scode\sde-duplication\sacross\sthe\stop-level\sauto.def\sand\sautoconf/auto.def. -D 2025-01-30T12:19:30.898 +C Updates\sto\sthe\scompile-for-windows.md\sdocument. +D 2025-01-30T13:54:32.680 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -56,7 +56,7 @@ F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-unix.md c9dce1ddd4bf0d25efccc5c63eb047e78c01ce06a6ff29c73e0a8af4a0f4adbc -F doc/compile-for-windows.md 31cddda1d5f34027f1f2b7484d580e7558f22a9875884805b6fdc84d56cab848 +F doc/compile-for-windows.md 5141661e783c9ca9e3fd30e813345898712f5c311d71316f183db87038fa28a6 F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 23c7d5bea351c04785153ddb30e19c1236db9d11054ab8229893531026b53655 -R ba9c9d617d2000ba71d01bbdea8f462f -U stephan -Z 94fb984dd769f6092f86cd16435effad +P 3c990d77cb83ab371d92c97e0528f790ab6126c60f48ff77e48bd166d7834cf0 +R ee4011e86e18eda74626e7b7a4c214d1 +U drh +Z c0301aa5783297a36ea33255b63dc517 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dcfee8e9d0..f3cfcb9994 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3c990d77cb83ab371d92c97e0528f790ab6126c60f48ff77e48bd166d7834cf0 +bcd22ed686954657ba820d53dec255d33797924f76e57b931016813581e04e06 From 000e39e9a891e2559c8194c2d2f0a30d99782f70 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 30 Jan 2025 16:00:28 +0000 Subject: [PATCH 089/115] Improvements to the TCL interface for Tcl9 as suggested by Jan Nijtmans. FossilOrigin-Name: d76c5db866de2732b68401a4c3e39acddc7a99bed965160c1796477c062b478a --- main.mk | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/tclsqlite.c | 4 +++- tool/buildtclext.tcl | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/main.mk b/main.mk index 1def7d1d0d..f2212c4f11 100644 --- a/main.mk +++ b/main.mk @@ -1507,7 +1507,7 @@ install: install-headers # libtclsqlite3... # pkgIndex.tcl: - echo 'package ifneeded sqlite3 $(PACKAGE_VERSION) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] sqlite3]' > $@ + echo 'package ifneeded sqlite3 $(PACKAGE_VERSION) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] Sqlite3]' > $@ pkgIndex.tcl-1: pkgIndex.tcl pkgIndex.tcl-0 pkgIndex.tcl-: tcl: pkgIndex.tcl-$(HAVE_TCL) diff --git a/manifest b/manifest index 12685bd00c..3a78112986 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sto\sthe\scompile-for-windows.md\sdocument. -D 2025-01-30T13:54:32.680 +C Improvements\sto\sthe\sTCL\sinterface\sfor\sTcl9\sas\ssuggested\sby\sJan\sNijtmans. +D 2025-01-30T16:00:28.158 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -702,7 +702,7 @@ F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65a F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 F ext/wasm/wasmfs.make 68999f5bd8c489239592d59a420f8c627c99169bbd6fa16a404751f757b9f702 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 18b859068a43818d29172b36d624a9bc8ce8204350ebd18a9f96994970081ab9 +F main.mk 043987843e8365dbaf74dce60c11683b62e2bcfcb3122574c14a0324d37a72f3 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -789,7 +789,7 @@ F src/sqliteInt.h 6f23e483be7810ea1854c8fbfbbbfae2a702529d1feb9a210a290abb445541 F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c 6a7538560adc856faea295c0f09c33a57a1cfa5c59f85ab4e12aa50dba7ff2de +F src/tclsqlite.c 0eb2b419b89a59085ea175423c24bb771fc83784313cf164e8d61e6bbddd58f6 F src/tclsqlite.h 65e2c761446e1c9fa0342b7d2612a703483643c8b6a316d12a65b745a4727395 F src/test1.c 9d2da51b4c33633e7370e4068af6d16d2c52b22a5810ec012ac32e77f8397b64 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2114,7 +2114,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x F tool/build-shell.sh 369c4b171cc877ad974fef691e4da782b4c1e99fe8f4361316c735f64d49280f -F tool/buildtclext.tcl e82120d672b34b507e1d9cb220ce18c5c36c3ee0ff0328e35f1806ce74ed2266 +F tool/buildtclext.tcl 20726b6b73c7911baa8519a9467b4062104339a5ce57947819884525c56d79e3 F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3c990d77cb83ab371d92c97e0528f790ab6126c60f48ff77e48bd166d7834cf0 -R ee4011e86e18eda74626e7b7a4c214d1 +P bcd22ed686954657ba820d53dec255d33797924f76e57b931016813581e04e06 +R d309c684cafbcb8b827c550f3c1fa4b1 U drh -Z c0301aa5783297a36ea33255b63dc517 +Z a306e9e3591ef614e7789f7fb42dc8cb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f3cfcb9994..1e32c2b55f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bcd22ed686954657ba820d53dec255d33797924f76e57b931016813581e04e06 +d76c5db866de2732b68401a4c3e39acddc7a99bed965160c1796477c062b478a diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 76c9ef75c1..2f12f7f671 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -4021,7 +4021,9 @@ EXTERN int Tclsqlite_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } EXTERN int Sqlite_SafeInit(Tcl_Interp *interp){ return TCL_ERROR; } EXTERN int Sqlite_SafeUnload(Tcl_Interp *interp, int flags){return TCL_ERROR;} -/* Also variants with a lowercase "s" */ +/* Also variants with a lowercase "s". I'm told that these are +** deprecated in Tcl9, but they continue to be included for backwards +** compatibility. */ EXTERN int sqlite3_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp);} EXTERN int sqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp);} diff --git a/tool/buildtclext.tcl b/tool/buildtclext.tcl index 26f9b6dcc9..905087d1da 100644 --- a/tool/buildtclext.tcl +++ b/tool/buildtclext.tcl @@ -289,7 +289,7 @@ if {$build} { # Tcl package index file, version ??? # package ifneeded sqlite3 $VERSION \\ - [list load [file join \$dir $OUT] sqlite3] + [list load [file join \$dir $OUT] Sqlite3] }] close $fd From 8bffd498eaac9f208f925d771fdfadd3be1e41d1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 30 Jan 2025 16:07:51 +0000 Subject: [PATCH 090/115] Remove an unused parameter from an internal-use subroutine in the TCL interface. FossilOrigin-Name: a700692b39e24f5ca9ea6f879d413e20c2ad2b85f62c867407dafe111f13d931 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tclsqlite.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 3a78112986..40bab9c95f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sTCL\sinterface\sfor\sTcl9\sas\ssuggested\sby\sJan\sNijtmans. -D 2025-01-30T16:00:28.158 +C Remove\san\sunused\sparameter\sfrom\san\sinternal-use\ssubroutine\sin\sthe\sTCL\sinterface. +D 2025-01-30T16:07:51.559 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -789,7 +789,7 @@ F src/sqliteInt.h 6f23e483be7810ea1854c8fbfbbbfae2a702529d1feb9a210a290abb445541 F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c 0eb2b419b89a59085ea175423c24bb771fc83784313cf164e8d61e6bbddd58f6 +F src/tclsqlite.c 5c1e367e26711044730c93d4b81312170918a8d1fe811f45be740ab48f7de8c1 F src/tclsqlite.h 65e2c761446e1c9fa0342b7d2612a703483643c8b6a316d12a65b745a4727395 F src/test1.c 9d2da51b4c33633e7370e4068af6d16d2c52b22a5810ec012ac32e77f8397b64 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bcd22ed686954657ba820d53dec255d33797924f76e57b931016813581e04e06 -R d309c684cafbcb8b827c550f3c1fa4b1 +P d76c5db866de2732b68401a4c3e39acddc7a99bed965160c1796477c062b478a +R e81adcf32270498fe2fdd74c590e8f70 U drh -Z a306e9e3591ef614e7789f7fb42dc8cb +Z baccdbeebeaa149b6573e44db1cfe14f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1e32c2b55f..6d745253d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d76c5db866de2732b68401a4c3e39acddc7a99bed965160c1796477c062b478a +a700692b39e24f5ca9ea6f879d413e20c2ad2b85f62c867407dafe111f13d931 diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 2f12f7f671..824e8c4d3c 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -510,7 +510,7 @@ static int createIncrblobChannel( ** or {...} or ; to be seen anywhere. Most callback scripts consist ** of just a single procedure name and they meet this requirement. */ -static int safeToUseEvalObjv(Tcl_Interp *interp, Tcl_Obj *pCmd){ +static int safeToUseEvalObjv(Tcl_Obj *pCmd){ /* We could try to do something with Tcl_Parse(). But we will instead ** just do a search for forbidden characters. If any of the forbidden ** characters appear in pCmd, we will report the string as unsafe. @@ -2993,7 +2993,7 @@ deserialize_error: } pFunc->pScript = pScript; Tcl_IncrRefCount(pScript); - pFunc->useEvalObjv = safeToUseEvalObjv(interp, pScript); + pFunc->useEvalObjv = safeToUseEvalObjv(pScript); pFunc->eType = eType; rc = sqlite3_create_function(pDb->db, zName, nArg, flags, pFunc, tclSqlFunc, 0, 0); From 49906e8e4bfbac201532e111b5f972129ce7bafe Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 30 Jan 2025 21:12:58 +0000 Subject: [PATCH 091/115] The reuse-subroutine optimization [c9a3498113074bbc] might have generated byte-code that loops forever. This check-in fixes the problem. FossilOrigin-Name: 0cc4ed8c6e53aca1f5e94c132bedbc7f561c04a77f1a30b965ffe7560634bfeb --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 5 ++++- src/vdbe.h | 1 + test/in7.test | 29 +++++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 40bab9c95f..99247a99ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunused\sparameter\sfrom\san\sinternal-use\ssubroutine\sin\sthe\sTCL\sinterface. -D 2025-01-30T16:07:51.559 +C The\sreuse-subroutine\soptimization\s[c9a3498113074bbc]\smight\shave\sgenerated\nbyte-code\sthat\sloops\sforever.\s\sThis\scheck-in\sfixes\sthe\sproblem. +D 2025-01-30T21:12:58.438 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -730,7 +730,7 @@ F src/date.c 842c08ac143a56a627b05ac51d68624f2b7b03e3b4cba596205e735eed64ee57 F src/dbpage.c e90410e5d4c0217dfddc4184a81e38ec4903c25d4ec0f201060a0e54e7c2099f F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 -F src/expr.c ce83e7361454a195f8393fa0baad694e2fee6c49a44c0d6db44d8a2b92534aeb +F src/expr.c 8705be31ee713aaa43c97d91399db09f16ee41b88250406eb99de6b47f550a98 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f F src/func.c f5b31c805679930cc5afcdfb1e657f9dd273053f52ff51133df5a448c519e5d9 @@ -850,7 +850,7 @@ F src/utf.c 8b29d9a5956569ea2700f869669b8ef67a9662ee5e724ff77ab3c387e27094ba F src/util.c e5f6a5eeaa26b69054a43bbd0048cfe3d2851f6961052b35aed8f695df922850 F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 F src/vdbe.c b428a751953c0c2ff85e3e152ec16e29d488895cd541c8c20876ff9f3bf6978a -F src/vdbe.h 9676348d342bd04e21e384c63b57224171ce84fac77853357334ef94c4d33cf4 +F src/vdbe.h 3d26d5c7660c5c7bd33ffb0d8784615072d8b23c81f8110870efe2631136bc89 F src/vdbeInt.h 895b1ab7536f018d3d70d690f6c0adbd1062b6dddce1c2cad912927856d4033c F src/vdbeapi.c 08d0445b6066b04e5014d5d322b75736a61fe847ed88eb6e1a186c79dd9ed117 F src/vdbeaux.c 885e16100597507fbbe09d82cbb963bff3fd8a9c1e358dc4f463fc95feb18e8b @@ -1307,7 +1307,7 @@ F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test bb767ec1cfd1730256f0a83219f0acda36bc251b63f8b8bb7d8c7cff17875a4f F test/in5.test 4fd79c70dfa0681313e8cdca07f5ff0400bdc0e20f808a5c59eaef1e4b48082a F test/in6.test f5f40d6816a8bb7c784424b58a10ac38efb76ab29127a2c17399e0cbeeda0e4b -F test/in7.test 5050b648510d88bd27ff6b40991a45e1cc277c20e258162e81650e01069a56bb +F test/in7.test d9efdee00b074a60c6343993b2eda78bc369ab080dad864513c73f8aca89d566 F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822 F test/incrblob2.test a494c9e848560039a23974b9119cfc2cf3ad3bd15cc2694ee6367ae537ef8f1f F test/incrblob3.test 67621a04b3084113bf38ce03797d70eca012d9d8f948193b8f655df577b0da6f @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d76c5db866de2732b68401a4c3e39acddc7a99bed965160c1796477c062b478a -R e81adcf32270498fe2fdd74c590e8f70 +P a700692b39e24f5ca9ea6f879d413e20c2ad2b85f62c867407dafe111f13d931 +R ceeb6c1a37b1d6d8b66aa63af2b79d4d U drh -Z baccdbeebeaa149b6573e44db1cfe14f +Z d3c9eaae04d6f46273321f256c2b9c5c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6d745253d1..9a908b795b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a700692b39e24f5ca9ea6f879d413e20c2ad2b85f62c867407dafe111f13d931 +0cc4ed8c6e53aca1f5e94c132bedbc7f561c04a77f1a30b965ffe7560634bfeb diff --git a/src/expr.c b/src/expr.c index fcd3da2138..8f898a1e3b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3462,6 +3462,7 @@ static int findCompatibleInRhsSubrtn( assert( pOp->opcode==OP_BeginSubrtn ); pSig = pOp->p4.pSubrtnSig; assert( pSig!=0 ); + if( !pSig->bComplete ) continue; if( pNewSig->selId!=pSig->selId ) continue; if( strcmp(pNewSig->zAff,pSig->zAff)!=0 ) continue; pExpr->y.sub.iAddr = pSig->iAddr; @@ -3508,6 +3509,7 @@ void sqlite3CodeRhsOfIN( KeyInfo *pKeyInfo = 0; /* Key information */ int nVal; /* Size of vector pLeft */ Vdbe *v; /* The prepared statement under construction */ + SubrtnSig *pSig = 0; /* Signature for this subroutine */ v = pParse->pVdbe; assert( v!=0 ); @@ -3528,7 +3530,6 @@ void sqlite3CodeRhsOfIN( ** Compute a signature for the RHS of the IN operator to facility ** finding and reusing prior instances of the same IN operator. */ - SubrtnSig *pSig = 0; assert( !ExprUseXSelect(pExpr) || pExpr->x.pSelect!=0 ); if( ExprUseXSelect(pExpr) && (pExpr->x.pSelect->selFlags & SF_All)==0 ){ pSig = sqlite3DbMallocRawNN(pParse->db, sizeof(pSig[0])); @@ -3571,6 +3572,7 @@ void sqlite3CodeRhsOfIN( pExpr->y.sub.iAddr = sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1; if( pSig ){ + pSig->bComplete = 0; pSig->iAddr = pExpr->y.sub.iAddr; pSig->regReturn = pExpr->y.sub.regReturn; pSig->iTable = iTab; @@ -3706,6 +3708,7 @@ void sqlite3CodeRhsOfIN( sqlite3ReleaseTempReg(pParse, r1); sqlite3ReleaseTempReg(pParse, r2); } + if( pSig ) pSig->bComplete = 1; if( pKeyInfo ){ sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO); } diff --git a/src/vdbe.h b/src/vdbe.h index 71aae29a08..476f1b4ea2 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -40,6 +40,7 @@ typedef struct SubrtnSig SubrtnSig; */ struct SubrtnSig { int selId; /* SELECT-id for the SELECT statement on the RHS */ + u8 bComplete; /* True if fully coded and available for reusable */ char *zAff; /* Affinity of the overall IN expression */ int iTable; /* Ephemeral table generated by the subroutine */ int iAddr; /* Subroutine entry address */ diff --git a/test/in7.test b/test/in7.test index 4dc0821d18..763396140a 100644 --- a/test/in7.test +++ b/test/in7.test @@ -219,4 +219,33 @@ do_execsql_test 3.8 { SELECT t1.a, t2.b FROM t1, t2 WHERE (t1.a, t2.b) IN ((1, 2)); } {1 2} +# 2025-01-30 Inifinite loop in byte-code discovered by dbsqlfuzz +# having to do with SubrtnSig logic. The code was using a Subroutine +# from within itself resulting in infinite recursion. +# +# This test will spin forever if the bug has not been fixed, or if +# it reappears. +# +reset_db +do_execsql_test 4.0 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + INSERT INTO t1 VALUES(1,x'1111'); + CREATE TABLE t2(c); + CREATE TABLE t3(d); + CREATE TRIGGER t1tr UPDATE ON t1 BEGIN + UPDATE t1 SET b=x'2222' FROM t2; + UPDATE t1 + SET b = (SELECT a IN (SELECT a + FROM t1 + WHERE (b,a) IN (SELECT rowid, d + FROM t3 + ) + ) + FROM t1 NATURAL RIGHT JOIN t1 + ); + END; + UPDATE t1 SET b=x'3333'; + SELECT quote(b) FROM t1; +} {X'3333'} + finish_test From e16b3452435dd03dbae8f355feeb33385780af3d Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 31 Jan 2025 01:34:19 +0000 Subject: [PATCH 092/115] Add the SQLITE_DBCONFIG_ENABLE_COMMENTS setting (default on) to enable or disable the ability to include comments in SQL input text. FossilOrigin-Name: 393749a2e22d5c8eba36e2106a35909420aa6316652d1ab4f18ef699247b6fba --- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/main.c | 2 ++ src/parse.y | 13 +++++++------ src/shell.c.in | 1 + src/sqlite.h.in | 16 +++++++++++++++- src/sqliteInt.h | 1 + src/tokenize.c | 11 +++++++---- src/vtab.c | 4 +++- 9 files changed, 50 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index b2f30124f4..a93ad027de 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sall\sthe\slatest\strunk\schanges\sinto\sthe\sextra-security\sbranch. -D 2025-01-31T00:54:59.552 +C Add\sthe\sSQLITE_DBCONFIG_ENABLE_COMMENTS\ssetting\s(default\son)\sto\senable\sor\ndisable\sthe\sability\sto\sinclude\scomments\sin\sSQL\sinput\stext. +D 2025-01-31T01:34:19.160 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -16,7 +16,7 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531 F auto.def e7e92090c98aeb0174d29988c259834eb1b71ae1ea927015c3ef300f6f9b68ae F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac -F autoconf/Makefile.in 56697ad25ecf23afa317148b06bdc14f85960b42e5ec434ac1ba87f63a3cb789 w autoconf/Makefile.am +F autoconf/Makefile.in 56697ad25ecf23afa317148b06bdc14f85960b42e5ec434ac1ba87f63a3cb789 F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 F autoconf/README.first f1d3876e9a7852c22f275a6f06814e64934cecbc0b5b9617d64849094c1fd136 F autoconf/README.txt 7f01dc3915e2d68f329011073662369e62a0938a2c69398807823c57591cb288 @@ -743,7 +743,7 @@ F src/insert.c db8bfff30fd7f71812651df3ddf5d1624b9e19104b31e349cd9055bbc9d622c4 F src/json.c 68a98c020c22127f2d65f08855f7fc7460ff352a6ce0b543d8931dde83319c22 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c 84239c53aaac3aa1734eaf33a41d575c1d2494313bd8af5e6d885f0dc0547cfd +F src/main.c 59bdd8d9bbdb3a746eaef14d611ddd5638aa18acef7c5e3271e815dbd215a1af F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -769,7 +769,7 @@ F src/os_win.c 49c7725b500f5867e8360e75eeb30f9d70b62fa1f05c8a101da627210578df32 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 3a1c4e7f69af482e33c8cba8a75afe0dda0ea6391240adac22b040ce1bdeef44 F src/pager.h 6137149346e6c8a3ddc1eeb40aee46381e9bc8b0fcc6dda8a1efde993c2275b8 -F src/parse.y dcf45a81b61223ac93e61fdfe9b22d635dd371c446e8222634d90aa37e25e5f6 +F src/parse.y 5dce477d23c6cd41da97ff9bc4ef93fba0e0a0aaa72a15ddb8a3f71618d76cac F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 @@ -781,11 +781,11 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 83e88fbb36f89b6703b348777491619554f0fd6f917c9fdf51e4c2e9cda6c04e -F src/shell.c.in 9915487b27e3169d59a4018c88d14246059c392c662d98fc516264267396b65e -F src/sqlite.h.in 584579ac930f5e0c55f40cf5f2c7e4caa93e0a3aa14c4dc078a18cec66f6fde3 +F src/shell.c.in b377a59822f207106424f08aead37e78b609222e98f86f04cc8a03563ccf3237 +F src/sqlite.h.in 30a16e4f6c337803ab0917bb98d94015783a993c970ba56f5deed1dd8684e38f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 64b3af946f779e1c7b58a1cdd2ec747797fe9f76f6e23d5f7c7c5896b5ea3ada +F src/sqliteInt.h 7f1b070ea3b4ab3c192be553810684f686fdb03f62f90afa2da64d4d61d91ec3 F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -841,7 +841,7 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c 6d80e11fba89a1796525e6f0048ff0c7789aa2c6b0b11c80827dc1437bd8ea72 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c fe17e03175cae35b6694d0f879e7bc3d1ddea2fd4ab148cba9bbd025b7a7bb12 +F src/tokenize.c cedfe799fc73106302078388547040698c5c5a3950f4ea1e4344e1b736c7d568 F src/treeview.c d85ce76e6d1498d781957c07cb234da6d77ce0ed2d196480d516f54dabc62279 F src/trigger.c 247e2d712d5edc6021d52a169f6ac9a9c10d7144bc4ac7ea06c1ed2aa414659f F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 @@ -859,7 +859,7 @@ F src/vdbemem.c 977438546df236c6a3e7d8b4fe86c0643c13b89b00235db1f11c3a91a4796d30 F src/vdbesort.c d0a3c7056c081703c8b6d91ad60f17da5e062a5c64bf568ed0fa1b5f4cae311f F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 -F src/vtab.c 316cd48e9320660db3047cd306cd056e4361180cebb4d0f10a39244e10c11422 +F src/vtab.c bd4ab699ac4d1ee6da7339d3fbbb5edf23d9737c1fd322ccd75984329d070472 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4e6181d8780ab0af2e1388d0754cbe6f2f04593d2b1ab6c41699a89942fd8997 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fe0c58d00b491d1af7c0894f5c32542954aeea2e6510853b3bcbf13ac0bf5ce0 0cc4ed8c6e53aca1f5e94c132bedbc7f561c04a77f1a30b965ffe7560634bfeb -R 21110132d98b76250ca6d2606f60e660 +P 86ba57561a8d8c14e401c06b2345a9417053aa3a5f0c84e52460f23f5e6aa8d0 +R a8e75b45389fdcc75e19207c37dcdc78 U drh -Z a99c7811057635504d507854afc123c4 +Z 58903bc3f8cbb45b4d2beab95c7e825d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6b29b07123..604c9124fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -86ba57561a8d8c14e401c06b2345a9417053aa3a5f0c84e52460f23f5e6aa8d0 +393749a2e22d5c8eba36e2106a35909420aa6316652d1ab4f18ef699247b6fba diff --git a/src/main.c b/src/main.c index 943478d6da..6a9d03d87c 100644 --- a/src/main.c +++ b/src/main.c @@ -982,6 +982,7 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){ { SQLITE_DBCONFIG_REVERSE_SCANORDER, SQLITE_ReverseOrder }, { SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE, SQLITE_AttachCreate }, { SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, SQLITE_AttachWrite }, + { SQLITE_DBCONFIG_ENABLE_COMMENTS, SQLITE_Comments }, }; unsigned int i; rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ @@ -3325,6 +3326,7 @@ static int openDatabase( | SQLITE_CacheSpill | SQLITE_AttachCreate | SQLITE_AttachWrite + | SQLITE_Comments #if !defined(SQLITE_TRUSTED_SCHEMA) || SQLITE_TRUSTED_SCHEMA+0!=0 | SQLITE_TrustedSchema #endif diff --git a/src/parse.y b/src/parse.y index b8d904d12c..e9e2c62e61 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1882,7 +1882,8 @@ wqlist(A) ::= wqlist(A) COMMA wqitem(X). { // These must be at the end of this file. Specifically, the rules that // introduce tokens WINDOW, OVER and FILTER must appear last. This causes // the integer values assigned to these tokens to be larger than all other -// tokens that may be output by the tokenizer except TK_SPACE and TK_ILLEGAL. +// tokens that may be output by the tokenizer except TK_SPACE, TK_COMMENT, +// and TK_ILLEGAL. // %ifndef SQLITE_OMIT_WINDOWFUNC %type windowdefn_list {Window*} @@ -2059,9 +2060,9 @@ term(A) ::= QNUMBER(X). { } /* -** The TK_SPACE and TK_ILLEGAL tokens must be the last two tokens. The -** parser depends on this. Those tokens are not used in any grammar rule. -** They are only used by the tokenizer. Declare them last so that they -** are guaranteed to be the last two tokens +** The TK_SPACE, TK_COMMENT, and TK_ILLEGAL tokens must be the last three +** tokens. The parser depends on this. Those tokens are not used in any +** grammar rule. They are only used by the tokenizer. Declare them last +** so that they are guaranteed to be the last three. */ -%token SPACE ILLEGAL. +%token SPACE COMMENT ILLEGAL. diff --git a/src/shell.c.in b/src/shell.c.in index be6508fb1f..fcc9316b00 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8727,6 +8727,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } aDbConfig[] = { { "attach_create", SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE }, { "attach_write", SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE }, + { "comments", SQLITE_DBCONFIG_ENABLE_COMMENTS }, { "defensive", SQLITE_DBCONFIG_DEFENSIVE }, { "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL }, { "dqs_dml", SQLITE_DBCONFIG_DQS_DML }, diff --git a/src/sqlite.h.in b/src/sqlite.h.in index b8f4ba3cbf..a17c2c5b5f 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2558,6 +2558,19 @@ struct sqlite3_mem_methods { ** after processing the first argument. ** ** +** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]] +**
    SQLITE_DBCONFIG_ENABLE_COMMENTS
    +**
    The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the +** ability to include comments in SQL text. Comments are enabled by default, +** but can be disabled, using the current DBCONFIG option if desired. +** This option takes two arguments which are an integer and a pointer +** to an integer. The first argument is 1, 0, or -1 to enable, disable, or +** leave unchanged the ability to use comments in SQL text, +** respectively. If the second argument is not NULL, then 0 or 1 is written +** into the integer that the second argument points to depending on if +** comments are allowed in SQL text after processing the first argument. +**
    +** ** */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ @@ -2582,7 +2595,8 @@ struct sqlite3_mem_methods { #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */ -#define SQLITE_DBCONFIG_MAX 1021 /* Largest DBCONFIG */ +#define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */ +#define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8c1be72c11..a37e0523ad 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1836,6 +1836,7 @@ struct sqlite3 { #define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */ #define SQLITE_AttachCreate HI(0x00010) /* ATTACH allowed to create new dbs */ #define SQLITE_AttachWrite HI(0x00020) /* ATTACH allowed to open for write */ +#define SQLITE_Comments HI(0x00040) /* Enable SQL comments */ /* Flags used only if debugging */ #ifdef SQLITE_DEBUG diff --git a/src/tokenize.c b/src/tokenize.c index b49b2aa16e..901a4f0384 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -288,7 +288,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ case CC_MINUS: { if( z[1]=='-' ){ for(i=2; (c=z[i])!=0 && c!='\n'; i++){} - *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ + *tokenType = TK_COMMENT; return i; }else if( z[1]=='>' ){ *tokenType = TK_PTR; @@ -324,7 +324,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ } for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} if( c ) i++; - *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ + *tokenType = TK_COMMENT; return i; } case CC_PERCENT: { @@ -653,12 +653,12 @@ 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 + || tokenType==TK_QNUMBER || tokenType==TK_COMMENT ); #else if( tokenType>=TK_SPACE ){ assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL - || tokenType==TK_QNUMBER + || tokenType==TK_QNUMBER || tokenType==TK_COMMENT ); #endif /* SQLITE_OMIT_WINDOWFUNC */ if( AtomicLoad(&db->u1.isInterrupted) ){ @@ -692,6 +692,9 @@ int sqlite3RunParser(Parse *pParse, const char *zSql){ assert( n==6 ); tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed); #endif /* SQLITE_OMIT_WINDOWFUNC */ + }else if( tokenType==TK_COMMENT && (db->flags & SQLITE_Comments)!=0 ){ + zSql += n; + continue; }else if( tokenType!=TK_QNUMBER ){ Token x; x.z = zSql; diff --git a/src/vtab.c b/src/vtab.c index 76ad3613e8..09f0c2d7f1 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -830,7 +830,9 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ z = (const unsigned char*)zCreateTable; for(i=0; aKeyword[i]; i++){ int tokenType = 0; - do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE ); + do{ + z += sqlite3GetToken(z, &tokenType); + }while( tokenType==TK_SPACE || tokenType==TK_COMMENT ); if( tokenType!=aKeyword[i] ){ sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error"); return SQLITE_ERROR; From 80cf9fa00b48dc02167dc58e22cac0f864aa2a05 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 31 Jan 2025 11:45:55 +0000 Subject: [PATCH 093/115] Correct a typo in tool/emcc.sh.in which could cause all of the configure-time work to locate the emcc binary to go unused. Reported in [forum:feb325cdde5b6f37|forum post feb325cdde5b6f37]. FossilOrigin-Name: f66efd5b531210407ee8f30cdf6684a7610479fd8810a609c54469f7424a0644 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/emcc.sh.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 99247a99ee..8b4cea2463 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sreuse-subroutine\soptimization\s[c9a3498113074bbc]\smight\shave\sgenerated\nbyte-code\sthat\sloops\sforever.\s\sThis\scheck-in\sfixes\sthe\sproblem. -D 2025-01-30T21:12:58.438 +C Correct\sa\stypo\sin\stool/emcc.sh.in\swhich\scould\scause\sall\sof\sthe\sconfigure-time\swork\sto\slocate\sthe\semcc\sbinary\sto\sgo\sunused.\sReported\sin\s[forum:feb325cdde5b6f37|forum\spost\sfeb325cdde5b6f37]. +D 2025-01-31T11:45:55.505 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -2123,7 +2123,7 @@ F tool/custom.txt 24ed55e71c5edae0067ba159bbf09240d58b160331f7716e95816cd3aa0ba5 F tool/dbhash.c 5da0c61032d23d74f2ab84ffc5740f0e8abec94f2c45c0b4306be7eb3ae96df0 F tool/dbtotxt.c ca48d34eaca6d6b6e4bd6a7be2b72caf34475869054240244c60fa7e69a518d6 F tool/dbtotxt.md c9a57af8739957ef36d2cfad5c4b1443ff3688ed33e4901ee200c8b651f43f3c -F tool/emcc.sh.in 1f3226166bad1765c0bf42fac3d29037704c2078eb22562f9ddfbe73bff023b0 +F tool/emcc.sh.in 41a049468c8155433e37e656ba5bae063a000768b1d627025f277732c4e7c4a4 F tool/enlargedb.c 3e8b2612b985cfa7e3e8800031ee191b43ae80de96abb5abbd5eada62651ee21 F tool/extract-sqlite3h.tcl 069ceab0cee26cba99952bfa08c0b23e35941c837acabe143f0c355d96c9e2eb x F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a700692b39e24f5ca9ea6f879d413e20c2ad2b85f62c867407dafe111f13d931 -R ceeb6c1a37b1d6d8b66aa63af2b79d4d -U drh -Z d3c9eaae04d6f46273321f256c2b9c5c +P 0cc4ed8c6e53aca1f5e94c132bedbc7f561c04a77f1a30b965ffe7560634bfeb +R 33175d85adee97e4106b94e4e3599ceb +U stephan +Z 85e214e0c7f56349a858ab72083d0810 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9a908b795b..102a5265df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0cc4ed8c6e53aca1f5e94c132bedbc7f561c04a77f1a30b965ffe7560634bfeb +f66efd5b531210407ee8f30cdf6684a7610479fd8810a609c54469f7424a0644 diff --git a/tool/emcc.sh.in b/tool/emcc.sh.in index 1263e1b0ea..1264df5376 100644 --- a/tool/emcc.sh.in +++ b/tool/emcc.sh.in @@ -63,4 +63,4 @@ if [ x = "x${emcc}" ]; then fi fi -exec emcc "$@" +exec $emcc "$@" From 824a5bfcf059cb35de6226484667a5677a8c9558 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 31 Jan 2025 12:09:36 +0000 Subject: [PATCH 094/115] Improvements to the SQLITE_DBCONFIG option documentation. FossilOrigin-Name: 59f0ba10062a6ccfd56061a16af3436b9e1b9d23378bff3302bcf33bb3137cb9 --- manifest | 12 +++--- manifest.uuid | 2 +- src/sqlite.h.in | 105 ++++++++++++++++++++++++++++++------------------ 3 files changed, 74 insertions(+), 45 deletions(-) diff --git a/manifest b/manifest index a93ad027de..2ee13706dc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_DBCONFIG_ENABLE_COMMENTS\ssetting\s(default\son)\sto\senable\sor\ndisable\sthe\sability\sto\sinclude\scomments\sin\sSQL\sinput\stext. -D 2025-01-31T01:34:19.160 +C Improvements\sto\sthe\sSQLITE_DBCONFIG\soption\sdocumentation. +D 2025-01-31T12:09:36.393 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -782,7 +782,7 @@ F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 83e88fbb36f89b6703b348777491619554f0fd6f917c9fdf51e4c2e9cda6c04e F src/shell.c.in b377a59822f207106424f08aead37e78b609222e98f86f04cc8a03563ccf3237 -F src/sqlite.h.in 30a16e4f6c337803ab0917bb98d94015783a993c970ba56f5deed1dd8684e38f +F src/sqlite.h.in 6bdaf7c577fba45afef371ba69852de9965e23e8b13b9aa099d90281bf0c1e54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 7f1b070ea3b4ab3c192be553810684f686fdb03f62f90afa2da64d4d61d91ec3 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 86ba57561a8d8c14e401c06b2345a9417053aa3a5f0c84e52460f23f5e6aa8d0 -R a8e75b45389fdcc75e19207c37dcdc78 +P 393749a2e22d5c8eba36e2106a35909420aa6316652d1ab4f18ef699247b6fba +R 13662bcaa4e43096d085a0dc17072d0e U drh -Z 58903bc3f8cbb45b4d2beab95c7e825d +Z e7786de21407765a3ba181d8f27262b9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 604c9124fe..6c5aac8ed5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -393749a2e22d5c8eba36e2106a35909420aa6316652d1ab4f18ef699247b6fba +59f0ba10062a6ccfd56061a16af3436b9e1b9d23378bff3302bcf33bb3137cb9 diff --git a/src/sqlite.h.in b/src/sqlite.h.in index a17c2c5b5f..58482f81cb 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2223,8 +2223,12 @@ struct sqlite3_mem_methods { **
    ** [[SQLITE_DBCONFIG_LOOKASIDE]] **
    SQLITE_DBCONFIG_LOOKASIDE
    -**
    ^This option takes three additional arguments that determine the -** [lookaside memory allocator] configuration for the [database connection]. +**
    The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the +** configuration of the lookaside memory allocator within a database +** connection. +** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are not +** in the [DBCONFIG arguments|usual format]. +** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two. ** ^The first argument (the third parameter to [sqlite3_db_config()] is a ** pointer to a memory buffer to use for lookaside memory. ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb @@ -2247,7 +2251,8 @@ struct sqlite3_mem_methods { ** [[SQLITE_DBCONFIG_ENABLE_FKEY]] **
    SQLITE_DBCONFIG_ENABLE_FKEY
    **
    ^This option is used to enable or disable the enforcement of -** [foreign key constraints]. There should be two additional arguments. +** [foreign key constraints]. This is the same setting that is +** enabled or disabled by the [PRAGMA foreign_keys] statement. ** The first argument is an integer which is 0 to disable FK enforcement, ** positive to enable FK enforcement or negative to leave FK enforcement ** unchanged. The second parameter is a pointer to an integer into which @@ -2269,13 +2274,13 @@ struct sqlite3_mem_methods { **

    Originally this option disabled all triggers. ^(However, since ** SQLite version 3.35.0, TEMP triggers are still allowed even if ** this option is off. So, in other words, this option now only disables -** triggers in the main database schema or in the schemas of ATTACH-ed +** triggers in the main database schema or in the schemas of [ATTACH]-ed ** databases.)^

    ** ** [[SQLITE_DBCONFIG_ENABLE_VIEW]] **
    SQLITE_DBCONFIG_ENABLE_VIEW
    **
    ^This option is used to enable or disable [CREATE VIEW | views]. -** There should be two additional arguments. +** There must be two additional arguments. ** The first argument is an integer which is 0 to disable views, ** positive to enable views or negative to leave the setting unchanged. ** The second parameter is a pointer to an integer into which @@ -2294,7 +2299,7 @@ struct sqlite3_mem_methods { **
    ^This option is used to enable or disable the ** [fts3_tokenizer()] function which is part of the ** [FTS3] full-text search engine extension. -** There should be two additional arguments. +** There must be two additional arguments. ** The first argument is an integer which is 0 to disable fts3_tokenizer() or ** positive to enable fts3_tokenizer() or negative to leave the setting ** unchanged. @@ -2309,7 +2314,7 @@ struct sqlite3_mem_methods { ** interface independently of the [load_extension()] SQL function. ** The [sqlite3_enable_load_extension()] API enables or disables both the ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()]. -** There should be two additional arguments. +** There must be two additional arguments. ** When the first argument to this interface is 1, then only the C-API is ** enabled and the SQL function remains disabled. If the first argument to ** this interface is 0, then both the C-API and the SQL function are disabled. @@ -2323,22 +2328,27 @@ struct sqlite3_mem_methods { ** ** [[SQLITE_DBCONFIG_MAINDBNAME]]
    SQLITE_DBCONFIG_MAINDBNAME
    **
    ^This option is used to change the name of the "main" database -** schema. ^The sole argument is a pointer to a constant UTF8 string -** which will become the new schema name in place of "main". ^SQLite -** does not make a copy of the new main schema name string, so the application -** must ensure that the argument passed into this DBCONFIG option is unchanged +** schema. This option does not follow the +** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format]. +** This option takes exactly one argument, which ust be a pointer +** to a constant UTF8 string which will become the new schema name +** in place of "main". ^SQLite does not make a copy of the new main +** schema name string, so the application must ensure that the argument +** passed into SQLITE_DBCONFIG MAINDBNAME is unchanged ** until after the database connection closes. **
    ** ** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]] **
    SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE
    -**
    Usually, when a database in wal mode is closed or detached from a -** database handle, SQLite checks if this will mean that there are now no -** connections at all to the database. If so, it performs a checkpoint -** operation before closing the connection. This option may be used to -** override this behavior. The first parameter passed to this operation -** is an integer - positive to disable checkpoints-on-close, or zero (the -** default) to enable them, and negative to leave the setting unchanged. +**
    Usually, when a database in [WAL mode] is closed or detached from a +** database handle, SQLite checks if if there are other connections to the +** same database, and if there are no other database connection (if the +** connection being closed is the last open connection to the database), +** then SQLite performs a [checkpoint] before closing the connection and +** deletes the WAL file. The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can +** be used to override that behavior. The first parameter passed to this +** operation is an integer - positive to disable checkpoints-on-close, or +** zero (the default) to enable them, and negative to leave the setting unchanged. ** The second parameter is a pointer to an integer ** into which is written 0 or 1 to indicate whether checkpoints-on-close ** have been disabled - 0 if they are not disabled, 1 if they are. @@ -2500,7 +2510,7 @@ struct sqlite3_mem_methods { ** statistics. For statistics to be collected, the flag must be set on ** the database handle both when the SQL statement is prepared and when it ** is stepped. The flag is set (collection of statistics is enabled) -** by default. This option takes two arguments: an integer and a pointer to +** by default.

    This option takes two arguments: an integer and a pointer to ** an integer.. The first argument is 1, 0, or -1 to enable, disable, or ** leave unchanged the statement scanstatus option. If the second argument ** is not NULL, then the value of the statement scanstatus setting after @@ -2514,7 +2524,7 @@ struct sqlite3_mem_methods { ** in which tables and indexes are scanned so that the scans start at the end ** and work toward the beginning rather than starting at the beginning and ** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the -** same as setting [PRAGMA reverse_unordered_selects]. This option takes +** same as setting [PRAGMA reverse_unordered_selects].

    This option takes ** two arguments which are an integer and a pointer to an integer. The first ** argument is 1, 0, or -1 to enable, disable, or leave unchanged the ** reverse scan order flag, respectively. If the second argument is not NULL, @@ -2525,11 +2535,12 @@ struct sqlite3_mem_methods { ** ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]] **

    SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE
    -**
    The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables the ability -** of the [ATTACH DATABASE] SQL command to create a new database if the -** database filed named by the SQL command does not already exist. This -** ability of [ATTACH] to create a new database is enabled by default, but -** can be disabled, using the current DBCONFIG option if desired. +**
    The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables +** the ability of the [ATTACH DATABASE] SQL command to create a new database +** file if the database filed named in the ATTACH command does not already +** exist. This ability of ATTACH to create a new database is enabled by +** default. Applications can disable or reenable the ability for ATTACH to +** create new database files using this DBCONFIG option.

    ** This option takes two arguments which are an integer and a pointer ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or ** leave unchanged the attach-create flag, respectively. If the second @@ -2540,29 +2551,30 @@ struct sqlite3_mem_methods { ** ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]] **

    SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE
    -**
    The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables the ability -** of the [ATTACH DATABASE] SQL command to create a new database that is -** open for writing. This capability is enabled by default, but -** can be disabled, using the current DBCONFIG option if desired. If this -** capability is disabled, the [ATTACH] command will still work, but the -** database is opened read-only. If this option is disabled, then the -** ability to create a new database using [ATTACH] is also disabled, +**
    The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the +** ability of the [ATTACH DATABASE] SQL command to open a database for writing. +** This capability is enabled by default. Applications can disable or +** reenable this capability using the current DBCONFIG option. If the +** the this capability is disabled, the [ATTACH] command will still work, +** but the database will be opened read-only. If this option is disabled, +** then the ability to create a new database using [ATTACH] is also disabled, ** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE] -** option. +** option.

    ** This option takes two arguments which are an integer and a pointer ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or ** leave unchanged the ability to ATTACH another database for writing, ** respectively. If the second argument is not NULL, then 0 or 1 is written -** into the integer that the second argument points to depending on if the -** ability to ATTACH a read/write database is set +** into the integer to which the second argument points, depending on whether +** the ability to ATTACH a read/write database is enabled or disabled ** after processing the first argument. **

    ** -** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]] +** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]] **
    SQLITE_DBCONFIG_ENABLE_COMMENTS
    **
    The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the -** ability to include comments in SQL text. Comments are enabled by default, -** but can be disabled, using the current DBCONFIG option if desired. +** ability to include comments in SQL text. Comments are enabled by default. +** An application can disable or reenable comments in SQL text using this +** DBCONFIG option.

    ** This option takes two arguments which are an integer and a pointer ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or ** leave unchanged the ability to use comments in SQL text, @@ -2572,6 +2584,23 @@ struct sqlite3_mem_methods { **

    ** **
    +** +** [[DBCONFIG arguments]]

    Arguments To SQLITE_DBCONFIG Options

    +** +**

    Most of the SQLITE_DBCONFIG options take two argument, an integer +** and a pointer to an integer. If the first integer argument is 1, then +** the option becomes enabled. If the first integer argument is 0, then the +** option is disabled. If the first argument is -1, then the option setting +** is unchanged. The second argument, the pointer to an integer, may be NULL. +** If the second argument is not NULL, then a value of 0 or 1 is written into +** the integer to which the second argument points, depending on whether the +** setting is disabled or enabled after applying any changes specified by +** the first argument. +** +**

    While most SQLITE_DBCONFIG options use the argument format +** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME] +** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the +** documentation of those exceptional options for details. */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ From efbf4815411adc7c63f7caf49c5f60cb6cccaaca Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 31 Jan 2025 12:30:37 +0000 Subject: [PATCH 095/115] Minor wasm-specific doc touchups. FossilOrigin-Name: 56b618da9073db8b8d5dafa177a3c9e4c4d927bf512e14b0e6d23937f91ce4cf --- ext/wasm/README-dist.txt | 12 ++++++++---- ext/wasm/README.md | 9 +++++---- ext/wasm/api/README.md | 24 ++++++++++++++---------- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/ext/wasm/README-dist.txt b/ext/wasm/README-dist.txt index 6656a2072a..4a527fc5ef 100644 --- a/ext/wasm/README-dist.txt +++ b/ext/wasm/README-dist.txt @@ -31,16 +31,20 @@ build: use of and is not demonstrated here. Browsers will not serve WASM files from file:// URLs, so the test and -demonstration apps require a web server and that server must include -the following headers in its response when serving the files: +demonstration apps require a web server and that server must, for the +OPFS[^1]-related features, include the following headers in its response +when serving the files: Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp -The core library will function without those headers but certain -features, most notably OPFS storage, will not be available. +Most functionality will work without those headers but the OPFS[^1] +storage capability will not be available without them. One simple way to get the demo apps up and running on Unix-style systems is to install althttpd (https://sqlite.org/althttpd) and run: althttpd --enable-sab --page index.html + + +[^1]: https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system diff --git a/ext/wasm/README.md b/ext/wasm/README.md index 21330f0eba..c41e54bd2a 100644 --- a/ext/wasm/README.md +++ b/ext/wasm/README.md @@ -35,7 +35,7 @@ after upgrading it! Our build process makes no guarantees about which Emscripten version(s) will or won't work, but it's important that production builds are built using a compatible version. During active development, the EMSDK is frequently updated, the goal being to keep -sqlite3.wasm working with "the latest" EMSDK.) +`sqlite3.wasm` working with "the latest" EMSDK.) The SQLite configure script will search for the EMSDK. One way to ensure that it finds it is: @@ -95,14 +95,14 @@ $ make httpd That will open the system's browser and visit the index page, from which (almost) all of the test and demo applications can be accessed. (`ext/wasm/SQLTester` is not listed in that page because it's only of -real utility when it's used in conjunction with the proprietary test -suite, which most users don't have access to.) +real utility when it's used in conjunction with the project's +proprietary test suite, which most users don't have access to.) Note that when serving this app via [althttpd][], it must be a version from 2022-09-26 or newer so that it recognizes the `--enable-sab` flag, which causes althttpd to emit two HTTP response headers which are required to enable JavaScript's `SharedArrayBuffer` and `Atomics` -APIs. Those APIs are required in order to enable the OPFS-related +APIs. Those APIs are required in order to enable the [OPFS][]-related features in the apps which use them. # Testing on a remote machine that is accessed via SSH @@ -129,3 +129,4 @@ be tunneled using SSH. [emscripten]: https://emscripten.org [althttpd]: https://sqlite.org/althttpd [SharedArrayBuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer +[OPFS]: https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system diff --git a/ext/wasm/api/README.md b/ext/wasm/api/README.md index ebd4aaacb1..ce7e58ebed 100644 --- a/ext/wasm/api/README.md +++ b/ext/wasm/api/README.md @@ -85,17 +85,18 @@ browser client: 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 - for database files in a browser. It requires... + is an sqlite3 VFS implementation which supports the [Origin-Private + FileSystem (OPFS)][OPFS] as a storage layer to provide persistent + storage for database files in a browser. It requires... - **`sqlite3-opfs-async-proxy.js`**\ - is the asynchronous backend part of the OPFS proxy. It speaks - directly to the (async) OPFS API and channels those results back - to its synchronous counterpart. This file, because it must be - started in its own Worker, is not part of the amalgamation. + is the asynchronous backend part of the [OPFS][] proxy. It + speaks directly to the (async) OPFS API and channels those + results back to its synchronous counterpart. This file, because + it must be started in its own Worker, is not part of the + amalgamation. - **`sqlite3-vfs-opfs-sahpool.c-pp.js`**\ - is another sqlite3 VFS supporting the OPFS, but uses a completely - different approach that the above-listed one. + is another sqlite3 VFS supporting the [OPFS][], but uses a + completely different approach that the above-listed one. - **`sqlite3-api-cleanup.js`**\ The previous files do not immediately extend the library. Instead they add callback functions to be called during its @@ -152,7 +153,7 @@ into the build-generated `sqlite3.js` along with `sqlite3-api.js`. flag. This file overwrites the Emscripten-installed `sqlite3InitModule()` function with one which, after the module is loaded, also initializes the asynchronous parts of the sqlite3 - module. For example, the OPFS VFS support. + module. For example, the [OPFS][] VFS support. Preprocessing of Source Files @@ -164,3 +165,6 @@ builds. The preprocessor application itself is in [`c-pp.c`](/file/ext/wasm/c-pp.c) and the complete technical details of such preprocessing are maintained in [`GNUMakefile`](/file/ext/wasm/GNUmakefile). + + +[OPFS]: https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system diff --git a/manifest b/manifest index 8b4cea2463..6fe6f41613 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correct\sa\stypo\sin\stool/emcc.sh.in\swhich\scould\scause\sall\sof\sthe\sconfigure-time\swork\sto\slocate\sthe\semcc\sbinary\sto\sgo\sunused.\sReported\sin\s[forum:feb325cdde5b6f37|forum\spost\sfeb325cdde5b6f37]. -D 2025-01-31T11:45:55.505 +C Minor\swasm-specific\sdoc\stouchups. +D 2025-01-31T12:30:37.066 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -620,8 +620,8 @@ F ext/session/sqlite3session.h 683ccbf16e2c2521661fc4c1cf918ce57002039efbcabcd80 F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c F ext/wasm/GNUmakefile 47f121d057c08ba49443c06c1c51ba2572e3d5d28a06c968cf0b2ccd5878c3d3 -F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 -F ext/wasm/README.md 6c1dd9e4448c672f4a072c56d3ce9164b3c7dc818ea8f18b49c6834bfd5efe24 +F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a +F ext/wasm/README.md b89605f65661cf35bf034ff6d43e448cc169b8017fc105d498e33b81218b482c F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff F ext/wasm/SQLTester/SQLTester.mjs 66e1adc3d79467b68e3e40614fd42c1a577c7e219ec0985db966eded52a941e5 F ext/wasm/SQLTester/SQLTester.run.mjs 57f2adb33f43f2784abbf8026c1bfd049d8013af1998e7dcb8b50c89ffc332e0 @@ -631,7 +631,7 @@ F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core 2bcbbfe3b95c043ed6037e2708a2ee078 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras fe40d6d758646e38f8b15f709044951e10884214f5453d35502100179c388c13 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 -F ext/wasm/api/README.md 34fe11466f9c1d81b10a0469e1114e5f1c5a6365c73d80a1a6ca639a1a358b73 +F ext/wasm/api/README.md c64ec8e84449c069e0217706d9d7d31b3bd53627228b2ba0c3cddbdc2350ca66 F ext/wasm/api/extern-post-js.c-pp.js 3fcd904f1204685dea84e5ae90d8b7e65a1dcebab1e838386d8328b74cce46c9 F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41 F ext/wasm/api/post-js-footer.js 365405929f41ca0e6d389ed8a8da3f3c93e11d3ef43a90ae151e37fa9f75bf41 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0cc4ed8c6e53aca1f5e94c132bedbc7f561c04a77f1a30b965ffe7560634bfeb -R 33175d85adee97e4106b94e4e3599ceb +P f66efd5b531210407ee8f30cdf6684a7610479fd8810a609c54469f7424a0644 +R ee4ef9a21aa00ca447e26df7a5840479 U stephan -Z 85e214e0c7f56349a858ab72083d0810 +Z effbdee03a11b5ac430008ff904c3705 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 102a5265df..b55f345c59 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f66efd5b531210407ee8f30cdf6684a7610479fd8810a609c54469f7424a0644 +56b618da9073db8b8d5dafa177a3c9e4c4d927bf512e14b0e6d23937f91ce4cf From a0337903030a123f09eae41a5146993ff81d83e4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 31 Jan 2025 14:52:05 +0000 Subject: [PATCH 096/115] If any errors occur while processing sqlite_dbpage changes, cancel pending truncate operations. FossilOrigin-Name: 6138e0dc4e0e4e19cb048fe0cd969156151fdc427eee21188d2a822642aad043 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/dbpage.c | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1e668b1a88..d8bb70d2ca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Three\snew\soptions\sto\ssqlite3_db_config():\s\sATTACH_CREATE,\sATTACH_WRITE,\nand\sCOMMENTS. -D 2025-01-31T13:32:03.815 +C If\sany\serrors\soccur\swhile\sprocessing\ssqlite_dbpage\schanges,\scancel\npending\struncate\soperations. +D 2025-01-31T14:52:05.955 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -727,7 +727,7 @@ F src/callback.c acae8c8dddda41ee85cfdf19b926eefe830f371069f8aadca3aa39adf5b1c85 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c d35723024b963edce9c0fad5b3303e8bb9266083784844baed10a6dedfe26f3b F src/date.c 842c08ac143a56a627b05ac51d68624f2b7b03e3b4cba596205e735eed64ee57 -F src/dbpage.c e90410e5d4c0217dfddc4184a81e38ec4903c25d4ec0f201060a0e54e7c2099f +F src/dbpage.c 2e677acb658a29965e55398bbc61161cb7819da538057c8032adac7ab8e4a8c0 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 8705be31ee713aaa43c97d91399db09f16ee41b88250406eb99de6b47f550a98 @@ -2209,9 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 56b618da9073db8b8d5dafa177a3c9e4c4d927bf512e14b0e6d23937f91ce4cf 59f0ba10062a6ccfd56061a16af3436b9e1b9d23378bff3302bcf33bb3137cb9 -R 9c4677ef318fd9ecf4b5844727767716 -T +closed 59f0ba10062a6ccfd56061a16af3436b9e1b9d23378bff3302bcf33bb3137cb9 +P 325e547a2195571ece4bb22ca65d67d8c2cb42030618916d37930666cf221917 +R 3bd4da0aa5d426accdfc728b0601224c U drh -Z 0620756e82ee0b6bee5e8e012928d482 +Z d6c5c6307ddd02cca8c78f06a45a0bc2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9ec94fb69f..464282d7dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -325e547a2195571ece4bb22ca65d67d8c2cb42030618916d37930666cf221917 +6138e0dc4e0e4e19cb048fe0cd969156151fdc427eee21188d2a822642aad043 diff --git a/src/dbpage.c b/src/dbpage.c index 40ebe4f14a..eb5ab33fe1 100644 --- a/src/dbpage.c +++ b/src/dbpage.c @@ -424,6 +424,7 @@ static int dbpageUpdate( return rc; update_fail: + pTab->pgnoTrunc = 0; sqlite3_free(pVtab->zErrMsg); pVtab->zErrMsg = sqlite3_mprintf("%s", zErr); return SQLITE_ERROR; From f6ca35d88cad6521ad06c6c9e1bfe0e3066d8cbb Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 31 Jan 2025 14:52:36 +0000 Subject: [PATCH 097/115] Fix a problem with LIKE and GLOB processing in utf-16be databases in cases where the utf-8 encoding of a character ends with the byte 0xBF. FossilOrigin-Name: 4b4f33d791fe4318c4597bee7d2f9e486ed223e731982af470f5cc0dbdc600fc --- manifest | 16 +++++----- manifest.uuid | 2 +- src/whereexpr.c | 32 ++++++++++++-------- test/like3.test | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index d8bb70d2ca..1632def2a1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sany\serrors\soccur\swhile\sprocessing\ssqlite_dbpage\schanges,\scancel\npending\struncate\soperations. -D 2025-01-31T14:52:05.955 +C Fix\sa\sproblem\swith\sLIKE\sand\sGLOB\sprocessing\sin\sutf-16be\sdatabases\sin\scases\swhere\sthe\sutf-8\sencoding\sof\sa\scharacter\sends\swith\sthe\sbyte\s0xBF. +D 2025-01-31T14:52:36.806 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -867,7 +867,7 @@ F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 F src/where.c 09dc313e7223ca1217c39c7026b00f16ff449a8323511a762fcba7863a00f4cd F src/whereInt.h d20cddddb1d61b18d5cb1fcfa9b77fbeebbc4afe44d996e603452a23b3009ee1 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab -F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f +F src/whereexpr.c fd80811331cebf37a96a1bbbe93a20425eb04a925baa7c2306d72e0797a47a4c F src/window.c 2bf01f9941a64fbcead61a0e3cb5db3fca5094b30d2ff0d23274c2a81d2e2385 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -1401,7 +1401,7 @@ F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 F test/lemon-test01.y 70110eff607ab137ccc851edb2bc7e14a6d4f246b5d2d25f82a60b69d87a9ff2 F test/like.test b3ea2ba3558199aa8f25a42ddeb54772e234fab50868c9f066047acdbda8fc58 F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3d3 -F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c +F test/like3.test a9d78297426279c3db1206490444f3193f579890b3c4118a52960afe2b4863cd F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e F test/literal.test a65dca9fef86e51b8e45544268e37abbd4bb94ba35fd65f6fdcab2f288cd8f79 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 325e547a2195571ece4bb22ca65d67d8c2cb42030618916d37930666cf221917 -R 3bd4da0aa5d426accdfc728b0601224c -U drh -Z d6c5c6307ddd02cca8c78f06a45a0bc2 +P 6138e0dc4e0e4e19cb048fe0cd969156151fdc427eee21188d2a822642aad043 +R 6c74985ff3e26b84d99b79b3d7d419a0 +U dan +Z f41b656617240d39be19007efc0ec242 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 464282d7dd..afbb673c85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6138e0dc4e0e4e19cb048fe0cd969156151fdc427eee21188d2a822642aad043 +4b4f33d791fe4318c4597bee7d2f9e486ed223e731982af470f5cc0dbdc600fc diff --git a/src/whereexpr.c b/src/whereexpr.c index 2b6eb6a78d..0a963f4f92 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -219,12 +219,12 @@ static int isLikeOrGlob( z = (u8*)pRight->u.zToken; } if( z ){ - /* Count the number of prefix bytes prior to the first wildcard. - ** or U+fffd character. If the underlying database has a UTF16LE - ** encoding, then only consider ASCII characters. Note that the - ** encoding of z[] is UTF8 - we are dealing with only UTF8 here in - ** this code, but the database engine itself might be processing - ** content using a different encoding. */ + /* Count the number of prefix bytes prior to the first wildcard, + ** U+fffd character, or malformed utf-8. If the underlying database + ** has a UTF16LE encoding, then only consider ASCII characters. Note that + ** the encoding of z[] is UTF8 - we are dealing with only UTF8 here in this + ** code, but the database engine itself might be processing content using a + ** different encoding. */ cnt = 0; while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ cnt++; @@ -232,7 +232,9 @@ static int isLikeOrGlob( cnt++; }else if( c>=0x80 ){ const u8 *z2 = z+cnt-1; - if( sqlite3Utf8Read(&z2)==0xfffd || ENC(db)==SQLITE_UTF16LE ){ + if( sqlite3Utf8Read(&z2)==0xfffd || c==0xFF /* bad utf-8 */ + || ENC(db)==SQLITE_UTF16LE + ){ cnt--; break; }else{ @@ -1384,9 +1386,8 @@ static void exprAnalyze( } if( !db->mallocFailed ){ - u8 c, *pC; /* Last character before the first wildcard */ + u8 *pC; /* Last character before the first wildcard */ pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1]; - c = *pC; if( noCase ){ /* The point is to increment the last character before the first ** wildcard. But if we increment '@', that will push it into the @@ -1394,10 +1395,17 @@ static void exprAnalyze( ** inequality. To avoid this, make sure to also run the full ** LIKE on all candidate expressions by clearing the isComplete flag */ - if( c=='A'-1 ) isComplete = 0; - c = sqlite3UpperToLower[c]; + if( *pC=='A'-1 ) isComplete = 0; + *pC = sqlite3UpperToLower[*pC]; } - *pC = c + 1; + + /* Increment the value of the last utf8 character in the prefix. */ + while( *pC==0xBF && pC>(u8*)pStr2->u.zToken ){ + *pC = 0x80; + pC--; + } + assert( *pC!=0xFF ); /* isLikeOrGlob() guarantees this */ + (*pC)++; } zCollSeqName = noCase ? "NOCASE" : sqlite3StrBINARY; pNewExpr1 = sqlite3ExprDup(db, pLeft, 0); diff --git a/test/like3.test b/test/like3.test index a93e113d62..2987e0e0e2 100644 --- a/test/like3.test +++ b/test/like3.test @@ -275,4 +275,84 @@ do_eqp_test like3-6.240 { } } +#------------------------------------------------------------------------- + +ifcapable utf16 { + reset_db + do_execsql_test like3-7.0 { + PRAGMA encoding = 'UTF-16be'; + + CREATE TABLE Example(word TEXT NOT NULL); + CREATE INDEX Example_word on Example(word); + + INSERT INTO Example VALUES(char(0x307F)); + } + + do_execsql_test like3-7.1 { + SELECT char(0x307F)=='み'; + } {1} + + do_execsql_test like3-7.1 { + SELECT * FROM Example WHERE word GLOB 'み*' + } {み} + + do_execsql_test like3-7.2 { + SELECT * FROM Example WHERE word >= char(0x307F) AND word < char(0x3080); + } {み} +} + +#------------------------------------------------------------------------- +reset_db + +foreach enc { + UTF-8 + UTF-16le + UTF-16be +} { + foreach {tn expr} { + 1 "CAST (X'FF' AS TEXT)" + 2 "CAST (X'FFBF' AS TEXT)" + 3 "CAST (X'FFBFBF' AS TEXT)" + 4 "CAST (X'FFBFBFBF' AS TEXT)" + + 5 "'abc' || CAST (X'FF' AS TEXT)" + 6 "'def' || CAST (X'FFBF' AS TEXT)" + 7 "'ghi' || CAST (X'FFBFBF' AS TEXT)" + 8 "'jkl' || CAST (X'FFBFBFBF' AS TEXT)" + } { + reset_db + execsql "PRAGMA encoding = '$enc'" + do_execsql_test like3-8.$tn.0 { + CREATE TABLE t1(x); + } + + do_execsql_test like3-8.$tn.1 { + PRAGMA encoding + } $enc + + do_execsql_test like3-8.$tn.1 " + INSERT INTO t1 VALUES( $expr ) + " + + do_execsql_test like3-8.$tn.2 { + SELECT typeof(x) FROM t1 + } {text} + + set x [db one {SELECT x || '%' FROM t1}] + + do_execsql_test like3-8.$tn.3 { + SELECT rowid FROM t1 WHERE x LIKE $x + } 1 + + do_execsql_test like3-8.$tn.4 { + CREATE INDEX i1 ON t1(x); + } + + do_execsql_test like3-8.$tn.5 { + SELECT rowid FROM t1 WHERE x LIKE $x + } 1 + } +} + finish_test + From 8fbf400bb0b6d094eaf8b7e17c02a6ad624f5708 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 31 Jan 2025 18:33:37 +0000 Subject: [PATCH 098/115] Remove an assert() that is not true if a trace-callback is deregistered while there are active statements. FossilOrigin-Name: 0ecfc4d0ebdb272a69f8f98ddb069c7e0735fb899804027eb16f241d83b3d046 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeapi.c | 1 - test/trace3.test | 16 ++++++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 1632def2a1..c6be9deac2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sLIKE\sand\sGLOB\sprocessing\sin\sutf-16be\sdatabases\sin\scases\swhere\sthe\sutf-8\sencoding\sof\sa\scharacter\sends\swith\sthe\sbyte\s0xBF. -D 2025-01-31T14:52:36.806 +C Remove\san\sassert()\sthat\sis\snot\strue\sif\sa\strace-callback\sis\sderegistered\swhile\sthere\sare\sactive\sstatements. +D 2025-01-31T18:33:37.705 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -852,7 +852,7 @@ F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 F src/vdbe.c b428a751953c0c2ff85e3e152ec16e29d488895cd541c8c20876ff9f3bf6978a F src/vdbe.h 3d26d5c7660c5c7bd33ffb0d8784615072d8b23c81f8110870efe2631136bc89 F src/vdbeInt.h 895b1ab7536f018d3d70d690f6c0adbd1062b6dddce1c2cad912927856d4033c -F src/vdbeapi.c 08d0445b6066b04e5014d5d322b75736a61fe847ed88eb6e1a186c79dd9ed117 +F src/vdbeapi.c 82fe278a7c71b653235c6f9fb5de0b5de589908dfcb011ba2a782e8becf06f86 F src/vdbeaux.c 885e16100597507fbbe09d82cbb963bff3fd8a9c1e358dc4f463fc95feb18e8b F src/vdbeblob.c 255be187436da38b01f276c02e6a08103489bbe2a7c6c21537b7aecbe0e1f797 F src/vdbemem.c 977438546df236c6a3e7d8b4fe86c0643c13b89b00235db1f11c3a91a4796d30 @@ -1893,7 +1893,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 4479008f85f6f8f25f7ab2cb305d665752b4727fa28a8df3d8e0ad46520c62ff F test/trace.test a659a9862957f4789e37a92b3bf6d2caf5c86b02cdeefc41e850ae53acf6992a F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test 4f418ed30d15d9d17dcf13a17f0bd99a92e3038e038798e35db7525f82f4c281 +F test/trace3.test 2deeac66359c9f007f0fc9fb6336994a5d68fc1a65129f322a9e9546fd537d0a F test/trans.test 45f6f9ab6f66a7b5744f1caac06b558f95da62501916906cf55586a896f9f439 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6138e0dc4e0e4e19cb048fe0cd969156151fdc427eee21188d2a822642aad043 -R 6c74985ff3e26b84d99b79b3d7d419a0 +P 4b4f33d791fe4318c4597bee7d2f9e486ed223e731982af470f5cc0dbdc600fc +R eb94bfac632b4e0afd83fa9877b4b4ff U dan -Z f41b656617240d39be19007efc0ec242 +Z 76e080bb074040fe3e81e0d36c896c38 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index afbb673c85..9707f1eb83 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4b4f33d791fe4318c4597bee7d2f9e486ed223e731982af470f5cc0dbdc600fc +0ecfc4d0ebdb272a69f8f98ddb069c7e0735fb899804027eb16f241d83b3d046 diff --git a/src/vdbeapi.c b/src/vdbeapi.c index aab7ac8a3c..0dc09d501e 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -63,7 +63,6 @@ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ sqlite3_int64 iNow; sqlite3_int64 iElapse; assert( p->startTime>0 ); - assert( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0 ); assert( db->init.busy==0 ); assert( p->zSql!=0 ); sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); diff --git a/test/trace3.test b/test/trace3.test index 496cc2360a..639aefafa6 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -342,5 +342,21 @@ do_test 12.1.2 { sqlite3_finalize $STMT } {SQLITE_OK} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 13.0 { + CREATE TABLE T1(a, b); + INSERT INTO t1 VALUES(1, 2), (3, 4); +} + +proc trace_callback {args} {} +db trace_v2 trace_callback profile + +do_test 13.1 { + db eval { SELECT * FROM t1 } { + db trace_v2 "" "" + } + set {} {} +} {} finish_test From 82f3052e618f95b87717c4d926f2e9bd2965a233 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 31 Jan 2025 18:45:03 +0000 Subject: [PATCH 099/115] Expose the new SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE/WRITE and SQLITE_DBCONFIG_ENABLE_COMMENTS (from [325e547a21955]) to JS/WASM. FossilOrigin-Name: 8da1a9af66f905c683e9c3445d609b5c0e11ac912be192c468ddd79f237837f4 --- ext/wasm/api/sqlite3-api-prologue.js | 75 +++++++++++++++------------- ext/wasm/api/sqlite3-wasm.c | 7 ++- ext/wasm/tester1.c-pp.js | 39 ++++++++++++++- manifest | 18 +++---- manifest.uuid | 2 +- 5 files changed, 94 insertions(+), 47 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index ee973990a3..277efa14ab 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -1712,41 +1712,48 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( missing or falsy pointer argument as 0. */ capi.sqlite3_db_config = function(pDb, op, ...args){ - if(!this.s){ - 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', - ['sqlite3*', 'int', '*','int', 'int']); - this.ip = wasm.xWrap('sqlite3__wasm_db_config_ip','int', - ['sqlite3*', 'int', 'int','*']); - } switch(op){ - case capi.SQLITE_DBCONFIG_ENABLE_FKEY: - case capi.SQLITE_DBCONFIG_ENABLE_TRIGGER: - case capi.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: - case capi.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: - case capi.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: - case capi.SQLITE_DBCONFIG_ENABLE_QPSG: - case capi.SQLITE_DBCONFIG_TRIGGER_EQP: - case capi.SQLITE_DBCONFIG_RESET_DATABASE: - case capi.SQLITE_DBCONFIG_DEFENSIVE: - case capi.SQLITE_DBCONFIG_WRITABLE_SCHEMA: - case capi.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: - case capi.SQLITE_DBCONFIG_DQS_DML: - case capi.SQLITE_DBCONFIG_DQS_DDL: - case capi.SQLITE_DBCONFIG_ENABLE_VIEW: - case capi.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: - case capi.SQLITE_DBCONFIG_TRUSTED_SCHEMA: - case capi.SQLITE_DBCONFIG_STMT_SCANSTATUS: - case capi.SQLITE_DBCONFIG_REVERSE_SCANORDER: - return this.ip(pDb, op, args[0], args[1] || 0); - case capi.SQLITE_DBCONFIG_LOOKASIDE: - return this.pii(pDb, op, args[0], args[1], args[2]); - case capi.SQLITE_DBCONFIG_MAINDBNAME: - return this.s(pDb, op, args[0]); - default: - return capi.SQLITE_MISUSE; + case capi.SQLITE_DBCONFIG_ENABLE_FKEY: + case capi.SQLITE_DBCONFIG_ENABLE_TRIGGER: + case capi.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: + case capi.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: + case capi.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: + case capi.SQLITE_DBCONFIG_ENABLE_QPSG: + case capi.SQLITE_DBCONFIG_TRIGGER_EQP: + case capi.SQLITE_DBCONFIG_RESET_DATABASE: + case capi.SQLITE_DBCONFIG_DEFENSIVE: + case capi.SQLITE_DBCONFIG_WRITABLE_SCHEMA: + case capi.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: + case capi.SQLITE_DBCONFIG_DQS_DML: + case capi.SQLITE_DBCONFIG_DQS_DDL: + case capi.SQLITE_DBCONFIG_ENABLE_VIEW: + case capi.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: + case capi.SQLITE_DBCONFIG_TRUSTED_SCHEMA: + case capi.SQLITE_DBCONFIG_STMT_SCANSTATUS: + case capi.SQLITE_DBCONFIG_REVERSE_SCANORDER: + case capi.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE: + case capi.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE: + case capi.SQLITE_DBCONFIG_ENABLE_COMMENTS: + if( !this.ip ){ + this.ip = wasm.xWrap('sqlite3__wasm_db_config_ip','int', + ['sqlite3*', 'int', 'int', '*']); + } + return this.ip(pDb, op, args[0], args[1] || 0); + case capi.SQLITE_DBCONFIG_LOOKASIDE: + if( !this.pii ){ + this.pii = wasm.xWrap('sqlite3__wasm_db_config_pii', 'int', + ['sqlite3*', 'int', '*', 'int', 'int']); + } + return this.pii(pDb, op, args[0], args[1], args[2]); + case capi.SQLITE_DBCONFIG_MAINDBNAME: + if(!this.s){ + this.s = wasm.xWrap('sqlite3__wasm_db_config_s','int', + ['sqlite3*', 'int', 'string:static'] + /* MAINDBNAME requires a static string */); + } + return this.s(pDb, op, args[0]); + default: + return capi.SQLITE_MISUSE; } }.bind(Object.create(null)); diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index c5dd495e54..461afe0663 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -331,7 +331,6 @@ SQLITE_WASM_EXPORT void sqlite3__wasm_pstack_restore(unsigned char * p){ */ 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 */; if( PStack.pBegin + n > PStack.pPos /*not enough space left*/ || PStack.pBegin + n <= PStack.pBegin /*overflow*/ ) return 0; @@ -597,6 +596,9 @@ const char * sqlite3__wasm_enum_json(void){ DefInt(SQLITE_DBCONFIG_TRUSTED_SCHEMA); DefInt(SQLITE_DBCONFIG_STMT_SCANSTATUS); DefInt(SQLITE_DBCONFIG_REVERSE_SCANORDER); + DefInt(SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE); + DefInt(SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE); + DefInt(SQLITE_DBCONFIG_ENABLE_COMMENTS); DefInt(SQLITE_DBCONFIG_MAX); } _DefGroup; @@ -1630,6 +1632,9 @@ int sqlite3__wasm_db_config_ip(sqlite3 *pDb, int op, int arg1, int* pArg2){ case SQLITE_DBCONFIG_TRUSTED_SCHEMA: case SQLITE_DBCONFIG_STMT_SCANSTATUS: case SQLITE_DBCONFIG_REVERSE_SCANORDER: + case SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE: + case SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE: + case SQLITE_DBCONFIG_ENABLE_COMMENTS: return sqlite3_db_config(pDb, op, arg1, pArg2); default: return SQLITE_MISUSE; } diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index a21a1c330e..f83ecbd873 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -1241,6 +1241,12 @@ globalThis.sqlite3InitModule = sqlite3InitModule; }finally{ wasm.pstack.restore(stack); } + + capi.sqlite3_db_config(this.db, capi.SQLITE_DBCONFIG_ENABLE_COMMENTS, 0, null); + T.mustThrow(()=>this.db.exec("select 1 /* with comments */"), "SQL comments are disallowed"); + capi.sqlite3_db_config(this.db, capi.SQLITE_DBCONFIG_ENABLE_COMMENTS, 1, null); + this.db.exec("select 1 /* with comments */"); + /* SQLITE_DBCONFIG_ENABLE_ATTACH_... are in the ATTACH-specific tests */ }) //////////////////////////////////////////////////////////////////// @@ -1999,7 +2005,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; }/*window UDFs*/) //////////////////////////////////////////////////////////////////// - .t("ATTACH", function(){ + .t("ATTACH", function(sqlite3){ const db = this.db; const resultRows = []; db.exec({ @@ -2078,7 +2084,36 @@ globalThis.sqlite3InitModule = sqlite3InitModule; db.exec("detach foo"); T.mustThrow(()=>db.exec("select * from foo.bar"), "Because foo is no longer attached."); - }) + + /* SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE/WRITE... */ + const db2 = new sqlite3.oo1.DB(); + try{ + capi.sqlite3_db_config(db2, capi.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE, 0, null); + T.mustThrow(()=>db2.exec("attach 'attached.db' as foo"), + "Cannot create a new db via ATTACH"); + capi.sqlite3_db_config(db2, capi.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE, 1, null); + db2.exec([ + "attach 'attached.db' as foo;", + "create table foo.t(a);", + "insert into foo.t(a) values(1);", + "detach foo;" + ]); + capi.sqlite3_db_config(db2, capi.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, 0, null); + db2.exec("attach 'attached.db' as foo"); + T.mustThrow(()=>db2.exec("insert into foo.t(a) values(2)"), + "ATTACH_WRITE is false"); + capi.sqlite3_db_config(db2, capi.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, 1, null); + db2.exec([ + "detach foo;", + "attach 'attached.db' as foo;", + "insert into foo.t(a) values(2);", + "drop table foo.t;", + "detach foo" + ]); + }finally{ + db2.close(); + } + })/*ATTACH tests*/ //////////////////////////////////////////////////////////////////// .t("Read-only", function(sqlite3){ diff --git a/manifest b/manifest index c6be9deac2..fde31f9ad0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sassert()\sthat\sis\snot\strue\sif\sa\strace-callback\sis\sderegistered\swhile\sthere\sare\sactive\sstatements. -D 2025-01-31T18:33:37.705 +C Expose\sthe\snew\sSQLITE_DBCONFIG_ENABLE_ATTACH_CREATE/WRITE\sand\sSQLITE_DBCONFIG_ENABLE_COMMENTS\s(from\s[325e547a21955])\sto\sJS/WASM. +D 2025-01-31T18:45:03.025 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -640,7 +640,7 @@ F ext/wasm/api/pre-js.c-pp.js a614a2c82b12c4d96d8e3ba77330329efc53c4d56a8a7e60ad F ext/wasm/api/sqlite3-api-cleanup.js 3ac1786e461ada63033143be8c3b00b26b939540661f3e839515bb92f2e35359 F ext/wasm/api/sqlite3-api-glue.c-pp.js fb6dbfe692cc23000a65a4cd95a1a47ed5eb592dc9d8b55363b3c2952a787244 F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f -F ext/wasm/api/sqlite3-api-prologue.js 3caa0d1f46fe1bfbd1cce31b57b4446ca073ddb15f67476a9ff6c93456467712 +F ext/wasm/api/sqlite3-api-prologue.js 5ff913355b3144f1c9719d0406667fa6e13eb813c71ed7ce29440e2e65363e82 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 3774befd97cd1a5e2895c8225a894aad946848c6d9b4028acc988b5d123475af @@ -648,7 +648,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js bb5e96cd0fd6e1e54538256433f1c60a4e3095063c4d1a79a8a022fc59be9571 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 9b86ca2d8276cf919fbc9ba2a10e9786033b64f92c2db844d951804dee6c4b4e F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 -F ext/wasm/api/sqlite3-wasm.c 83f5e9f998e9fa4261eb84e9f092210e3ffe03895119f5ded0429eb34ab9d2be +F ext/wasm/api/sqlite3-wasm.c 6f9d8529072d072359cd22dc5dfb0572c524684686569cfbd0f9640d7619fc10 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -696,7 +696,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 228101c290003423f0bfb66a6ebbfc6904fa7b1b69466e700c135f74ee83d62a +F ext/wasm/tester1.c-pp.js 05df7cfd2cb8aa8728afb68c90a8af51fdf724c0e892f0f986a695584edae195 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4b4f33d791fe4318c4597bee7d2f9e486ed223e731982af470f5cc0dbdc600fc -R eb94bfac632b4e0afd83fa9877b4b4ff -U dan -Z 76e080bb074040fe3e81e0d36c896c38 +P 0ecfc4d0ebdb272a69f8f98ddb069c7e0735fb899804027eb16f241d83b3d046 +R 17139128f5a15a8bba68ad5baf1b2013 +U stephan +Z 3fb4b52cbb9f7ac493f2fee0f2c8e021 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9707f1eb83..9d3fb7ec88 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0ecfc4d0ebdb272a69f8f98ddb069c7e0735fb899804027eb16f241d83b3d046 +8da1a9af66f905c683e9c3445d609b5c0e11ac912be192c468ddd79f237837f4 From 45b2669ad363ad3eb0e3e75de1b18d9e5593f837 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 31 Jan 2025 18:56:58 +0000 Subject: [PATCH 100/115] Fix test case numbering in tests recently added to like3.test. FossilOrigin-Name: 6df2098c548b58c2910837726b666a628d5c712c560c0221a771e8181f71fae7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/like3.test | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index fde31f9ad0..f8e251197c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Expose\sthe\snew\sSQLITE_DBCONFIG_ENABLE_ATTACH_CREATE/WRITE\sand\sSQLITE_DBCONFIG_ENABLE_COMMENTS\s(from\s[325e547a21955])\sto\sJS/WASM. -D 2025-01-31T18:45:03.025 +C Fix\stest\scase\snumbering\sin\stests\srecently\sadded\sto\slike3.test. +D 2025-01-31T18:56:58.478 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1401,7 +1401,7 @@ F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 F test/lemon-test01.y 70110eff607ab137ccc851edb2bc7e14a6d4f246b5d2d25f82a60b69d87a9ff2 F test/like.test b3ea2ba3558199aa8f25a42ddeb54772e234fab50868c9f066047acdbda8fc58 F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3d3 -F test/like3.test a9d78297426279c3db1206490444f3193f579890b3c4118a52960afe2b4863cd +F test/like3.test b21284df226d6028feeb4dcc56ad9d32673d82c14a63f15f25471292c36491e7 F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e F test/literal.test a65dca9fef86e51b8e45544268e37abbd4bb94ba35fd65f6fdcab2f288cd8f79 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0ecfc4d0ebdb272a69f8f98ddb069c7e0735fb899804027eb16f241d83b3d046 -R 17139128f5a15a8bba68ad5baf1b2013 -U stephan -Z 3fb4b52cbb9f7ac493f2fee0f2c8e021 +P 8da1a9af66f905c683e9c3445d609b5c0e11ac912be192c468ddd79f237837f4 +R 7c3dd7099324ee3f6570f3eda4b7c65a +U drh +Z f8d1c9b3f391a5065e5e11e0179528b8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9d3fb7ec88..dc09f5f03d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8da1a9af66f905c683e9c3445d609b5c0e11ac912be192c468ddd79f237837f4 +6df2098c548b58c2910837726b666a628d5c712c560c0221a771e8181f71fae7 diff --git a/test/like3.test b/test/like3.test index 2987e0e0e2..0b28574376 100644 --- a/test/like3.test +++ b/test/like3.test @@ -322,37 +322,37 @@ foreach enc { } { reset_db execsql "PRAGMA encoding = '$enc'" - do_execsql_test like3-8.$tn.0 { + set tn utf[string range $enc 4 end].$tn + do_execsql_test like3-8.$tn.1 { CREATE TABLE t1(x); } - do_execsql_test like3-8.$tn.1 { + do_execsql_test like3-8.$tn.2 { PRAGMA encoding } $enc - do_execsql_test like3-8.$tn.1 " + do_execsql_test like3-8.$tn.3 " INSERT INTO t1 VALUES( $expr ) " - do_execsql_test like3-8.$tn.2 { + do_execsql_test like3-8.$tn.4 { SELECT typeof(x) FROM t1 } {text} set x [db one {SELECT x || '%' FROM t1}] - do_execsql_test like3-8.$tn.3 { + do_execsql_test like3-8.$tn.5 { SELECT rowid FROM t1 WHERE x LIKE $x } 1 - do_execsql_test like3-8.$tn.4 { + do_execsql_test like3-8.$tn.6 { CREATE INDEX i1 ON t1(x); } - do_execsql_test like3-8.$tn.5 { + do_execsql_test like3-8.$tn.7 { SELECT rowid FROM t1 WHERE x LIKE $x } 1 } } finish_test - From 276d213b2aff1132a3fec04ae96b2273b70235de Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 31 Jan 2025 20:18:34 +0000 Subject: [PATCH 101/115] Tweaks to [4b4f33d791fe4318] to make it easier to test. FossilOrigin-Name: 2567298f4b0fdfeb42aa6bba7e0bec3bc8d0b89bf644a79b41893dd6a6c5774c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f8e251197c..c8b50bd721 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stest\scase\snumbering\sin\stests\srecently\sadded\sto\slike3.test. -D 2025-01-31T18:56:58.478 +C Tweaks\sto\s[4b4f33d791fe4318]\sto\smake\sit\seasier\sto\stest. +D 2025-01-31T20:18:34.963 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -867,7 +867,7 @@ F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 F src/where.c 09dc313e7223ca1217c39c7026b00f16ff449a8323511a762fcba7863a00f4cd F src/whereInt.h d20cddddb1d61b18d5cb1fcfa9b77fbeebbc4afe44d996e603452a23b3009ee1 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab -F src/whereexpr.c fd80811331cebf37a96a1bbbe93a20425eb04a925baa7c2306d72e0797a47a4c +F src/whereexpr.c d304e3fec8309cddffd194a2d06c49de3aac1c32a7ef9f6bd78546abc7d77352 F src/window.c 2bf01f9941a64fbcead61a0e3cb5db3fca5094b30d2ff0d23274c2a81d2e2385 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8da1a9af66f905c683e9c3445d609b5c0e11ac912be192c468ddd79f237837f4 -R 7c3dd7099324ee3f6570f3eda4b7c65a +P 6df2098c548b58c2910837726b666a628d5c712c560c0221a771e8181f71fae7 +R 135ac307112d80006ac833a8ae148e6e U drh -Z f8d1c9b3f391a5065e5e11e0179528b8 +Z 1e05e96ac0e79f8e8ee82c826159e60e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dc09f5f03d..79096bfae9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6df2098c548b58c2910837726b666a628d5c712c560c0221a771e8181f71fae7 +2567298f4b0fdfeb42aa6bba7e0bec3bc8d0b89bf644a79b41893dd6a6c5774c diff --git a/src/whereexpr.c b/src/whereexpr.c index 0a963f4f92..2c4d0fef0d 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -232,7 +232,7 @@ static int isLikeOrGlob( cnt++; }else if( c>=0x80 ){ const u8 *z2 = z+cnt-1; - if( sqlite3Utf8Read(&z2)==0xfffd || c==0xFF /* bad utf-8 */ + if( c==0xff || sqlite3Utf8Read(&z2)==0xfffd /* bad utf-8 */ || ENC(db)==SQLITE_UTF16LE ){ cnt--; @@ -1400,7 +1400,7 @@ static void exprAnalyze( } /* Increment the value of the last utf8 character in the prefix. */ - while( *pC==0xBF && pC>(u8*)pStr2->u.zToken ){ + while( *pC==0xBF && ALWAYS(pC>(u8*)pStr2->u.zToken) ){ *pC = 0x80; pC--; } From fdc17e0bc8f99ebece39a7668af0f40fa4fe6323 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 1 Feb 2025 09:44:48 +0000 Subject: [PATCH 102/115] JS doc typo fixes. No functional changes. FossilOrigin-Name: e0d9c74c1cdddb2321131255b94f9cda6530be3f2a06aed4abb54dcda092481e --- ext/wasm/common/whwasmutil.js | 9 +++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index 8fe4a990b6..de0f667876 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -51,7 +51,7 @@ Its global-scope symbol is intended only to provide an easy way to make it available to 3rd-party scripts and "should" be deleted - after calling it. That symbols is _not_ used within the library. + after calling it. That symbol is _not_ used within the library. Forewarning: this API explicitly targets only browser environments. If a given non-browser environment has the @@ -69,7 +69,8 @@ - WASM-exported "indirect function table" access and manipulation. e.g. creating new WASM-side functions using JS functions, analog to Emscripten's addFunction() and - uninstallFunction() but slightly different. + uninstallFunction() but slightly different and with more useful + lifetime semantics. - Get/set specific heap memory values, analog to Emscripten's getValue() and setValue(). @@ -165,7 +166,7 @@ This code is developed and maintained in conjunction with the Jaccwabyt project: - https://fossil.wanderinghorse.net/r/jaccwabbyt + https://fossil.wanderinghorse.net/r/jaccwabyt More specifically: @@ -1627,7 +1628,7 @@ globalThis.WhWasmUtilInstaller = function(target){ need a level of hand-written wrappers around them, depending on how they're used, in order to provide the client with JS strings. Alternately, clients will need to perform such conversions - on their own, e.g. using cstrtojs(). Or maybe we can find a way + on their own, e.g. using cstrToJs(). Or maybe we can find a way to perform such conversions here, via addition of an xWrap()-style function signature to the options argument. */ diff --git a/manifest b/manifest index c8b50bd721..30514be215 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tweaks\sto\s[4b4f33d791fe4318]\sto\smake\sit\seasier\sto\stest. -D 2025-01-31T20:18:34.963 +C JS\sdoc\stypo\sfixes.\sNo\sfunctional\schanges. +D 2025-02-01T09:44:48.567 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -659,7 +659,7 @@ F ext/wasm/c-pp.c 6d131069644964223305582a80973477fa8b06b57306781690d7874ebd3a4f F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f -F ext/wasm/common/whwasmutil.js d76c69617e95d85ffc9996f7d9d7481df6976dcbd860ecd82bd8c075e3a101ae +F ext/wasm/common/whwasmutil.js 8528ac79418ee7eafe7c8f634a08704e47d694d3fd8ea6368be27a5229733338 F ext/wasm/config.make.in 4bc43443f768a61efd43cf995a5e618f58ac9afc0936706014193537d82c41cb F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6df2098c548b58c2910837726b666a628d5c712c560c0221a771e8181f71fae7 -R 135ac307112d80006ac833a8ae148e6e -U drh -Z 1e05e96ac0e79f8e8ee82c826159e60e +P 2567298f4b0fdfeb42aa6bba7e0bec3bc8d0b89bf644a79b41893dd6a6c5774c +R eac70bc609a1618826ffd2d47e1f8359 +U stephan +Z d7bceb2ba8b79e070ba4dc11d65193f3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 79096bfae9..0484fa7054 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2567298f4b0fdfeb42aa6bba7e0bec3bc8d0b89bf644a79b41893dd6a6c5774c +e0d9c74c1cdddb2321131255b94f9cda6530be3f2a06aed4abb54dcda092481e From de50617bcb1d3f5de83ef0a9b31d2b9e1d4d3c52 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 1 Feb 2025 20:53:17 +0000 Subject: [PATCH 103/115] Fix an issue with sqlite3_normalized_sql() caused by changes needed to support SQLITE_DBCONFIG_ENABLE_COMMENT. FossilOrigin-Name: 79d287a39443f2d098fcc24199627555a656b34aa5bf5d484f91cb513d83e143 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tokenize.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 30514be215..d242405d2d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C JS\sdoc\stypo\sfixes.\sNo\sfunctional\schanges. -D 2025-02-01T09:44:48.567 +C Fix\san\sissue\swith\ssqlite3_normalized_sql()\scaused\sby\schanges\sneeded\sto\nsupport\sSQLITE_DBCONFIG_ENABLE_COMMENT. +D 2025-02-01T20:53:17.603 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -841,7 +841,7 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c 6d80e11fba89a1796525e6f0048ff0c7789aa2c6b0b11c80827dc1437bd8ea72 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c cedfe799fc73106302078388547040698c5c5a3950f4ea1e4344e1b736c7d568 +F src/tokenize.c 375a772e2342274f4bf73605a70633237da09deed00a9bf4c4816a56777ea7c9 F src/treeview.c d85ce76e6d1498d781957c07cb234da6d77ce0ed2d196480d516f54dabc62279 F src/trigger.c 247e2d712d5edc6021d52a169f6ac9a9c10d7144bc4ac7ea06c1ed2aa414659f F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2567298f4b0fdfeb42aa6bba7e0bec3bc8d0b89bf644a79b41893dd6a6c5774c -R eac70bc609a1618826ffd2d47e1f8359 -U stephan -Z d7bceb2ba8b79e070ba4dc11d65193f3 +P e0d9c74c1cdddb2321131255b94f9cda6530be3f2a06aed4abb54dcda092481e +R 645350b0e058e36134a55fdb6b3f2eb5 +U drh +Z 9d4896add67bdd3bb69392ede8dfd087 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0484fa7054..f1811e8ef6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e0d9c74c1cdddb2321131255b94f9cda6530be3f2a06aed4abb54dcda092481e +79d287a39443f2d098fcc24199627555a656b34aa5bf5d484f91cb513d83e143 diff --git a/src/tokenize.c b/src/tokenize.c index 901a4f0384..fe300ca529 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -801,6 +801,7 @@ char *sqlite3Normalize( n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType); if( NEVER(n<=0) ) break; switch( tokenType ){ + case TK_COMMENT: case TK_SPACE: { break; } From 5c72a39cfbf461e66ce7482a17d9448f65108883 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 1 Feb 2025 21:06:49 +0000 Subject: [PATCH 104/115] Enable SQLITE_ENABLE_NORMALIZE for several test configurations. FossilOrigin-Name: b07c64077a3912ef7cdf23e9411df6387f38baa32f5a11fffec5ba4f93935e27 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/testrunner_data.tcl | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index d242405d2d..b39253660b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sissue\swith\ssqlite3_normalized_sql()\scaused\sby\schanges\sneeded\sto\nsupport\sSQLITE_DBCONFIG_ENABLE_COMMENT. -D 2025-02-01T20:53:17.603 +C Enable\sSQLITE_ENABLE_NORMALIZE\sfor\sseveral\stest\sconfigurations. +D 2025-02-01T21:06:49.292 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1729,7 +1729,7 @@ F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 7b44f1a9b9a2de8112695b908afc21dd9a68cd2d44e84b73f1b27b53492c0d59 F test/testrunner.tcl 90ed8b6c2b26dc1f6af08aeb04670a5df86172f3d9828d8af000f972afa50061 x -F test/testrunner_data.tcl ba4aeea28aa03cfa6fe7e57782ddecb7a7b91c3a0b3251583cb4f0ee002de6a6 +F test/testrunner_data.tcl 63ff9eba1d11a3b0a6fc8446d5fa32da21aabda55b994e8fcbd4a8ce81f48378 F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e0d9c74c1cdddb2321131255b94f9cda6530be3f2a06aed4abb54dcda092481e -R 645350b0e058e36134a55fdb6b3f2eb5 +P 79d287a39443f2d098fcc24199627555a656b34aa5bf5d484f91cb513d83e143 +R 888619b059aabb68efc45862c1d541fe U drh -Z 9d4896add67bdd3bb69392ede8dfd087 +Z 9448395bcbe74c7bef7eba8e89fa76da # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f1811e8ef6..30dffb89e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -79d287a39443f2d098fcc24199627555a656b34aa5bf5d484f91cb513d83e143 +b07c64077a3912ef7cdf23e9411df6387f38baa32f5a11fffec5ba4f93935e27 diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index 9abfb242da..2cfa7f3b31 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -97,6 +97,7 @@ namespace eval trd { set build(All-Debug) { --with-debug --enable-all -DSQLITE_ENABLE_ORDERED_SET_AGGREGATES + -DSQLITE_ENABLE_NORMALIZE } set build(All-O0) { -O0 --enable-all @@ -110,6 +111,7 @@ namespace eval trd { CC=clang -fsanitize=address,undefined -fno-sanitize-recover=undefined -DSQLITE_ENABLE_STAT4 -DSQLITE_OMIT_LOOKASIDE=1 + -DSQLITE_ENABLE_NORMALIZE -DCONFIG_SLOWDOWN_FACTOR=5.0 -DSQLITE_ENABLE_RBU --with-debug @@ -168,6 +170,7 @@ namespace eval trd { -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_ATOMIC_WRITE=1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 + -DSQLITE_ENABLE_NORMALIZE -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1 -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_STMT_SCANSTATUS @@ -183,6 +186,7 @@ namespace eval trd { -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_MEMSYS5=1 + -DSQLITE_ENABLE_NORMALIZE -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_HIDDEN_COLUMNS @@ -299,6 +303,7 @@ namespace eval trd { -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS3_TOKENIZER=1 + -DSQLITE_ENABLE_NORMALIZE=1 -DSQLITE_ENABLE_PERSIST_WAL=1 -DSQLITE_ENABLE_PURGEABLE_PCACHE=1 -DSQLITE_ENABLE_RTREE=1 From 454a426e31f75e8f09973c7704b47e5df6c88dc7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 1 Feb 2025 23:28:49 +0000 Subject: [PATCH 105/115] Remove an ALWAYS() added by [2567298f4b0fdfeb] because dbsqlfuzz found a way to reach it. The test case was added to TH3. FossilOrigin-Name: d08a7aa8987458a91fcb861d58289e622ba8722936c7874a284f9f2fd782e269 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b39253660b..a1b8b7be69 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enable\sSQLITE_ENABLE_NORMALIZE\sfor\sseveral\stest\sconfigurations. -D 2025-02-01T21:06:49.292 +C Remove\san\sALWAYS()\sadded\sby\s[2567298f4b0fdfeb]\sbecause\sdbsqlfuzz\sfound\sa\sway\nto\sreach\sit.\s\sThe\stest\scase\swas\sadded\sto\sTH3. +D 2025-02-01T23:28:49.538 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -867,7 +867,7 @@ F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 F src/where.c 09dc313e7223ca1217c39c7026b00f16ff449a8323511a762fcba7863a00f4cd F src/whereInt.h d20cddddb1d61b18d5cb1fcfa9b77fbeebbc4afe44d996e603452a23b3009ee1 F src/wherecode.c 0c3d3199a2b769a5e2bb70feb5003dc85b3d86842ecaf903a47f2b4205ca5dab -F src/whereexpr.c d304e3fec8309cddffd194a2d06c49de3aac1c32a7ef9f6bd78546abc7d77352 +F src/whereexpr.c 2415c8eee5ff89a8b709d7d83d71c1ff986cd720d0520057e1d8a5371339012a F src/window.c 2bf01f9941a64fbcead61a0e3cb5db3fca5094b30d2ff0d23274c2a81d2e2385 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 79d287a39443f2d098fcc24199627555a656b34aa5bf5d484f91cb513d83e143 -R 888619b059aabb68efc45862c1d541fe +P b07c64077a3912ef7cdf23e9411df6387f38baa32f5a11fffec5ba4f93935e27 +R 1587f5175225e9073d51285cc57826f6 U drh -Z 9448395bcbe74c7bef7eba8e89fa76da +Z 785e2e3ea6ab6da1a366fb937ef1ab28 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 30dffb89e1..262be1b4aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b07c64077a3912ef7cdf23e9411df6387f38baa32f5a11fffec5ba4f93935e27 +d08a7aa8987458a91fcb861d58289e622ba8722936c7874a284f9f2fd782e269 diff --git a/src/whereexpr.c b/src/whereexpr.c index 2c4d0fef0d..4a24dadd23 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1400,7 +1400,7 @@ static void exprAnalyze( } /* Increment the value of the last utf8 character in the prefix. */ - while( *pC==0xBF && ALWAYS(pC>(u8*)pStr2->u.zToken) ){ + while( *pC==0xBF && pC>(u8*)pStr2->u.zToken ){ *pC = 0x80; pC--; } From 4b99ec0b8c0dafa7d0949e2559bd0b231dcf2d13 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 1 Feb 2025 23:34:33 +0000 Subject: [PATCH 106/115] Fix a comment typo - in a comment used to generate documentation. FossilOrigin-Name: b8de75eeded79a8312218d7a543e7c7d11181c9f4004e875495608d11a81ff38 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a1b8b7be69..7159e8849a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sALWAYS()\sadded\sby\s[2567298f4b0fdfeb]\sbecause\sdbsqlfuzz\sfound\sa\sway\nto\sreach\sit.\s\sThe\stest\scase\swas\sadded\sto\sTH3. -D 2025-02-01T23:28:49.538 +C Fix\sa\scomment\stypo\s-\sin\sa\scomment\sused\sto\sgenerate\sdocumentation. +D 2025-02-01T23:34:33.636 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -782,7 +782,7 @@ F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 83e88fbb36f89b6703b348777491619554f0fd6f917c9fdf51e4c2e9cda6c04e F src/shell.c.in b377a59822f207106424f08aead37e78b609222e98f86f04cc8a03563ccf3237 -F src/sqlite.h.in 6bdaf7c577fba45afef371ba69852de9965e23e8b13b9aa099d90281bf0c1e54 +F src/sqlite.h.in cc9a2d5a719b7434e2699ff7c28a56209b8aa459b7f80ff1d4d7d8ac6ebfd96e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 7f1b070ea3b4ab3c192be553810684f686fdb03f62f90afa2da64d4d61d91ec3 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b07c64077a3912ef7cdf23e9411df6387f38baa32f5a11fffec5ba4f93935e27 -R 1587f5175225e9073d51285cc57826f6 +P d08a7aa8987458a91fcb861d58289e622ba8722936c7874a284f9f2fd782e269 +R e49065fa7e2398b7b6e928bf8f7bfc59 U drh -Z 785e2e3ea6ab6da1a366fb937ef1ab28 +Z 8691b65bebb646fe5d4e88f85d5d14cb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 262be1b4aa..4cc6cbc2ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d08a7aa8987458a91fcb861d58289e622ba8722936c7874a284f9f2fd782e269 +b8de75eeded79a8312218d7a543e7c7d11181c9f4004e875495608d11a81ff38 diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 58482f81cb..885f187a43 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2587,7 +2587,7 @@ struct sqlite3_mem_methods { ** ** [[DBCONFIG arguments]]

    Arguments To SQLITE_DBCONFIG Options

    ** -**

    Most of the SQLITE_DBCONFIG options take two argument, an integer +**

    Most of the SQLITE_DBCONFIG options take two arguments: an integer ** and a pointer to an integer. If the first integer argument is 1, then ** the option becomes enabled. If the first integer argument is 0, then the ** option is disabled. If the first argument is -1, then the option setting From c49bfdbbee49c6a877d585ec08da131e2814730f Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 1 Feb 2025 23:49:01 +0000 Subject: [PATCH 107/115] Add a missing "db2 close" to the ext/session/session_gen.test test module. FossilOrigin-Name: 4068f586ddadd3a818645574f7584fcee6d373dbf45805c545100883b495598a --- ext/session/session_gen.test | 1 + manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ext/session/session_gen.test b/ext/session/session_gen.test index 8d3c5887f3..e9de4beaba 100644 --- a/ext/session/session_gen.test +++ b/ext/session/session_gen.test @@ -181,6 +181,7 @@ foreach {tn sql} { compare_db db db2 } {} } +db2 close }]} diff --git a/manifest b/manifest index 7159e8849a..7bc3347512 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scomment\stypo\s-\sin\sa\scomment\sused\sto\sgenerate\sdocumentation. -D 2025-02-01T23:34:33.636 +C Add\sa\smissing\s"db2\sclose"\sto\sthe\sext/session/session_gen.test\stest\smodule. +D 2025-02-01T23:49:01.341 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -593,7 +593,7 @@ F ext/session/sessionF.test d37ed800881e742c208df443537bf29aa49fd56eac520d0f0c6d F ext/session/sessionG.test 3efe388282d641b65485b5462e67851002cd91a282dc95b685d085eb8efdad0a F ext/session/sessionH.test 71bbff6b1abb2c4ac62b84dee53273c37e0b21e5fde3aed80929403e091ef859 F ext/session/session_common.tcl a31f537a929a695a852d241c9434f2847cadf329856401921139fbb03a5a7697 -F ext/session/session_gen.test 3f2ff2bd71694b82bd17c5ab2002635c54affb909fca2ee749b2daf95ff86648 +F ext/session/session_gen.test 942a0002df10da53c45b40b581cc3ed25e7ff42bda1e7ba497273dc2887aa8e6 F ext/session/session_speed_test.c dcf0ef58d76b70c8fbd9eab3be77cf9deb8bc1638fed8be518b62d6cbdef88b3 F ext/session/sessionalter.test e852acb3d2357aac7d0b920a2109da758c4331bfdf85b41d39aa3a8c18914f65 F ext/session/sessionat.test 00c8badb35e43a2f12a716d2734a44d614ff62361979b6b85419035bc04b45ee @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d08a7aa8987458a91fcb861d58289e622ba8722936c7874a284f9f2fd782e269 -R e49065fa7e2398b7b6e928bf8f7bfc59 +P b8de75eeded79a8312218d7a543e7c7d11181c9f4004e875495608d11a81ff38 +R 70de67d2731c96d5565daabba5a9f711 U drh -Z 8691b65bebb646fe5d4e88f85d5d14cb +Z 0c60cdc79cd4db383ea08f9fcd4c5692 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4cc6cbc2ef..f6733e5fe5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8de75eeded79a8312218d7a543e7c7d11181c9f4004e875495608d11a81ff38 +4068f586ddadd3a818645574f7584fcee6d373dbf45805c545100883b495598a From 14613b1b1d9ef977229a9b8279e54c569469d2a9 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 2 Feb 2025 12:15:25 +0000 Subject: [PATCH 108/115] URL typo fix in code comments. No code changes. FossilOrigin-Name: 002a123094e4ef14eb5ec28033adca6083ba2717e1eaa23e80595e37a947e6c2 --- ext/wasm/common/whwasmutil.js | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index de0f667876..509d33b371 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -170,7 +170,7 @@ More specifically: - https://fossil.wanderinghorse.net/r/jaccwabbyt/file/common/whwasmutil.js + https://fossil.wanderinghorse.net/r/jaccwabyt/file/common/whwasmutil.js */ globalThis.WhWasmUtilInstaller = function(target){ 'use strict'; diff --git a/manifest b/manifest index 7bc3347512..6b499b9e73 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smissing\s"db2\sclose"\sto\sthe\sext/session/session_gen.test\stest\smodule. -D 2025-02-01T23:49:01.341 +C URL\stypo\sfix\sin\scode\scomments.\sNo\scode\schanges. +D 2025-02-02T12:15:25.699 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -659,7 +659,7 @@ F ext/wasm/c-pp.c 6d131069644964223305582a80973477fa8b06b57306781690d7874ebd3a4f F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f -F ext/wasm/common/whwasmutil.js 8528ac79418ee7eafe7c8f634a08704e47d694d3fd8ea6368be27a5229733338 +F ext/wasm/common/whwasmutil.js c2e459286c1ada789cda6b17761bb1eea6034be572468eed78c049354f1051ba F ext/wasm/config.make.in 4bc43443f768a61efd43cf995a5e618f58ac9afc0936706014193537d82c41cb F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b8de75eeded79a8312218d7a543e7c7d11181c9f4004e875495608d11a81ff38 -R 70de67d2731c96d5565daabba5a9f711 -U drh -Z 0c60cdc79cd4db383ea08f9fcd4c5692 +P 4068f586ddadd3a818645574f7584fcee6d373dbf45805c545100883b495598a +R bd36ece0544440b71f6e303d972a7e2f +U stephan +Z 78f6520da2cf6d27938a2b853e051a64 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f6733e5fe5..3c1ca149ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4068f586ddadd3a818645574f7584fcee6d373dbf45805c545100883b495598a +002a123094e4ef14eb5ec28033adca6083ba2717e1eaa23e80595e37a947e6c2 From c229f1181790894dd60262b46357def1e2f3d932 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 2 Feb 2025 16:52:21 +0000 Subject: [PATCH 109/115] Update to the "--help" output from speedtest1. FossilOrigin-Name: 5216452047eecdd6c0f6ab85b304f975ed05a394a4ad9ae793fb65d645502b12 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/speedtest1.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6b499b9e73..c251f9984c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C URL\stypo\sfix\sin\scode\scomments.\sNo\scode\schanges. -D 2025-02-02T12:15:25.699 +C Update\sto\sthe\s"--help"\soutput\sfrom\sspeedtest1. +D 2025-02-02T16:52:21.308 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1681,7 +1681,7 @@ F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c F test/speedtest.md ee958457ae1b729d9715ae33c0320600000bf1d9ddea1a88dcf79f56729d6fad F test/speedtest.tcl 8a9362c1e429318e741b91d26888e7edcc326f98c3aea505ffd618cc5b9e7f0a x -F test/speedtest1.c 323ce0956430a5aae56ea20f502da7bea3fb62b8ed02e9b0f12ab078b2b258f5 +F test/speedtest1.c f17c04829e6e9ccd60f23c38f1a6cc640e3ae807ce54192f062eb22dece40e61 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4068f586ddadd3a818645574f7584fcee6d373dbf45805c545100883b495598a -R bd36ece0544440b71f6e303d972a7e2f -U stephan -Z 78f6520da2cf6d27938a2b853e051a64 +P 002a123094e4ef14eb5ec28033adca6083ba2717e1eaa23e80595e37a947e6c2 +R 0dfb19693dad143344d481eff7a8c7a1 +U drh +Z eab3264d2412f89567991828cb35b655 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3c1ca149ca..4f45593820 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -002a123094e4ef14eb5ec28033adca6083ba2717e1eaa23e80595e37a947e6c2 +5216452047eecdd6c0f6ab85b304f975ed05a394a4ad9ae793fb65d645502b12 diff --git a/test/speedtest1.c b/test/speedtest1.c index 8847ed04bf..7bceae8512 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -43,8 +43,8 @@ static const char zHelp[] = " --stmtscanstatus Activate SQLITE_DBCONFIG_STMT_SCANSTATUS\n" " --temp N N from 0 to 9. 0: no temp table. 9: all temp tables\n" " --testset T Run test-set T (main, cte, rtree, orm, fp, json, debug)\n" - " Can be a comma-separated list of values, with /SCALE suffixes\n" - " or macro \"mix1\"\n" + " Can be a comma-separated list of values, with /SCALE\n" + " suffixes or macro \"mix1\"\n" " --trace Turn on SQL tracing\n" " --threads N Use up to N threads for sorting\n" " --utf16be Set text encoding to UTF-16BE\n" From f306ca52861de23de08b2247e8f30ce426fa8fcb Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 2 Feb 2025 18:01:32 +0000 Subject: [PATCH 110/115] Add a header comment to test/speedtest1.c that outlines how to compile the program using historical amalgamation sources, for comparison testing. FossilOrigin-Name: 602d4dd69ec9a724c69cb41ab15376ec731bfd4894fac0a2b25076b857786c6d --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 25 ++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c251f9984c..4c732ac4a4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sto\sthe\s"--help"\soutput\sfrom\sspeedtest1. -D 2025-02-02T16:52:21.308 +C Add\sa\sheader\scomment\sto\stest/speedtest1.c\sthat\soutlines\show\sto\scompile\sthe\nprogram\susing\shistorical\samalgamation\ssources,\sfor\scomparison\stesting. +D 2025-02-02T18:01:32.649 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -1681,7 +1681,7 @@ F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c F test/speedtest.md ee958457ae1b729d9715ae33c0320600000bf1d9ddea1a88dcf79f56729d6fad F test/speedtest.tcl 8a9362c1e429318e741b91d26888e7edcc326f98c3aea505ffd618cc5b9e7f0a x -F test/speedtest1.c f17c04829e6e9ccd60f23c38f1a6cc640e3ae807ce54192f062eb22dece40e61 +F test/speedtest1.c 204acd8af326bbca2c28f68166635d4574381f4cabbac1bc243663f5dcc5051d F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 002a123094e4ef14eb5ec28033adca6083ba2717e1eaa23e80595e37a947e6c2 -R 0dfb19693dad143344d481eff7a8c7a1 +P 5216452047eecdd6c0f6ab85b304f975ed05a394a4ad9ae793fb65d645502b12 +R e5e73e420449b95dfe1df31fa75f6670 U drh -Z eab3264d2412f89567991828cb35b655 +Z c88ad2ace3864df1c4b3b50fb44cd819 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4f45593820..e6c8d08022 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5216452047eecdd6c0f6ab85b304f975ed05a394a4ad9ae793fb65d645502b12 +602d4dd69ec9a724c69cb41ab15376ec731bfd4894fac0a2b25076b857786c6d diff --git a/test/speedtest1.c b/test/speedtest1.c index 7bceae8512..9d8ddc4545 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -1,6 +1,28 @@ /* ** A program for performance testing. ** +** To build this program against an historical version of SQLite for comparison +** testing: +** +** Unix: +** +** ./configure --all +** make clean speedtest1 +** mv speedtest1 speedtest1-current +** cp $HISTORICAL_SQLITE3_C_H . +** touch sqlite3.c sqlite3.h .target_source +** make speedtest1 +** mv speedtest1 speedtest1-baseline +** +** Windows: +** +** nmake /f Makefile.msc clean speedtest1.exe +** mv speedtest1.exe speedtest1-current.exe +** cp $HISTORICAL_SQLITE_C_H . +** touch sqlite3.c sqlite3.h .target_source +** nmake /f Makefile.msc speedtest1.exe +** mv speedtest1.exe speedtest1-baseline.exe +** ** The available command-line options are described below: */ static const char zHelp[] = @@ -42,7 +64,8 @@ static const char zHelp[] = " --stats Show statistics at the end\n" " --stmtscanstatus Activate SQLITE_DBCONFIG_STMT_SCANSTATUS\n" " --temp N N from 0 to 9. 0: no temp table. 9: all temp tables\n" - " --testset T Run test-set T (main, cte, rtree, orm, fp, json, debug)\n" + " --testset T Run test-set T (main, cte, rtree, orm, fp, json," + " debug)\n" " Can be a comma-separated list of values, with /SCALE\n" " suffixes or macro \"mix1\"\n" " --trace Turn on SQL tracing\n" From 4170780a82421bf723a95838d8e3e04d157de823 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 3 Feb 2025 12:42:03 +0000 Subject: [PATCH 111/115] The "clean" target on Makefile.msc should not delete the auto.def file. FossilOrigin-Name: 72fbcedfb09febb72fa325cb21d160cd33dca7fe5579817143f47d90a20ec2ef --- Makefile.msc | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 33c5ef107e..f5a1a9164d 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2811,7 +2811,8 @@ moreclean: clean clean: del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL - del /Q *.bsc *.def *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL + del /Q *.bsc *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL + del /Q sqlite3.def tclsqlite3.def 2>NUL del /Q $(SQLITE3EXE) $(SQLITE3DLL) Replace.exe 2>NUL # <> del /Q $(SQLITE3TCLDLL) pkgIndex.tcl 2>NUL diff --git a/manifest b/manifest index 4c732ac4a4..604113d5d4 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Add\sa\sheader\scomment\sto\stest/speedtest1.c\sthat\soutlines\show\sto\scompile\sthe\nprogram\susing\shistorical\samalgamation\ssources,\sfor\scomparison\stesting. -D 2025-02-02T18:01:32.649 +C The\s"clean"\starget\son\sMakefile.msc\sshould\snot\sdelete\sthe\sauto.def\sfile. +D 2025-02-03T12:42:03.773 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d F Makefile.in 38485d15d9190cdad0d7bee25af7b442028865964025dcc61f40fd8d6e369cfc F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0 -F Makefile.msc 39785ec45f9ae0311e49094eff2ee079562246fed6be3b9f632a99d4df20056a +F Makefile.msc b335ae09e0396f6fb1ff3cc477b5d42f7b19f5b657b9deb8761c02fb9ec93df9 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 01f7606130e48fd58a74d1e45e565f2674819d6eadbc219d328d94bb3362b818 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5216452047eecdd6c0f6ab85b304f975ed05a394a4ad9ae793fb65d645502b12 -R e5e73e420449b95dfe1df31fa75f6670 +P 602d4dd69ec9a724c69cb41ab15376ec731bfd4894fac0a2b25076b857786c6d +R 24aae7cdfe868af0a232714dd29906e1 U drh -Z c88ad2ace3864df1c4b3b50fb44cd819 +Z 6573e99f3b8fb91d202a158e322a8831 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e6c8d08022..e76b7795a9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -602d4dd69ec9a724c69cb41ab15376ec731bfd4894fac0a2b25076b857786c6d +72fbcedfb09febb72fa325cb21d160cd33dca7fe5579817143f47d90a20ec2ef From 3cf467a3ec3f5311cb70e229f9f675d567fabeea Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 3 Feb 2025 13:20:11 +0000 Subject: [PATCH 112/115] Adjust the build process to avoid extra CR characters inserted by jimsh on Windows. FossilOrigin-Name: 1f54853932cec9ba20e9be48a59f1817b8b45e4c4d6ef8a06d34f86dd688e28e --- Makefile.msc | 4 ++-- main.mk | 6 +++--- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- tool/mkshellc.tcl | 3 +++ tool/mksqlite3c.tcl | 2 +- tool/mksqlite3h.tcl | 31 +++++++++++++++++++++++++------ 7 files changed, 45 insertions(+), 23 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index f5a1a9164d..c1a8f88b6e 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2334,7 +2334,7 @@ parse.c: $(TOP)\src\parse.y lemon.exe .\lemon.exe $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) -S parse.y $(SQLITE3H): $(TOP)\src\sqlite.h.in $(TOP)\manifest mksourceid.exe $(TOP)\VERSION $(JIM_TCLSH) - $(JIM_TCLSH) $(TOP)\tool\mksqlite3h.tcl "$(TOP:\=/)" > $(SQLITE3H) $(MKSQLITE3H_ARGS) + $(JIM_TCLSH) $(TOP)\tool\mksqlite3h.tcl "$(TOP:\=/)" -o $(SQLITE3H) $(MKSQLITE3H_ARGS) sqlite3ext.h: .target_source !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0 @@ -2398,7 +2398,7 @@ SHELL_DEP = $(SHELL_DEP) $(TOP)\ext\misc\zipfile.c !ENDIF shell.c: $(SHELL_DEP) $(TOP)\tool\mkshellc.tcl $(JIM_TCLSH) - $(JIM_TCLSH) $(TOP)\tool\mkshellc.tcl > shell.c + $(JIM_TCLSH) $(TOP)\tool\mkshellc.tcl shell.c zlib: pushd $(ZLIBDIR) && $(MAKE) /f win32\Makefile.msc clean $(ZLIBLIB) && popd diff --git a/main.mk b/main.mk index f2212c4f11..00632a5d5c 100644 --- a/main.mk +++ b/main.mk @@ -1066,7 +1066,7 @@ mksourceid$(B.exe): $(MAKE_SANITY_CHECK) $(TOP)/tool/mksourceid.c sqlite3.h: $(MAKE_SANITY_CHECK) $(TOP)/src/sqlite.h.in \ $(TOP)/manifest mksourceid$(B.exe) \ $(TOP)/VERSION $(B.tclsh) - $(B.tclsh) $(TOP)/tool/mksqlite3h.tcl $(TOP) >sqlite3.h + $(B.tclsh) $(TOP)/tool/mksqlite3h.tcl $(TOP) -o sqlite3.h sqlite3.c: .target_source sqlite3.h $(TOP)/tool/mksqlite3c.tcl src-verify$(B.exe) \ $(B.tclsh) @@ -1075,7 +1075,7 @@ sqlite3.c: .target_source sqlite3.h $(TOP)/tool/mksqlite3c.tcl src-verify$(B.exe cp $(TOP)/ext/session/sqlite3session.h . sqlite3r.h: sqlite3.h $(B.tclsh) - $(B.tclsh) $(TOP)/tool/mksqlite3h.tcl $(TOP) --enable-recover >sqlite3r.h + $(B.tclsh) $(TOP)/tool/mksqlite3h.tcl $(TOP) --enable-recover -o sqlite3r.h sqlite3r.c: sqlite3.c sqlite3r.h $(B.tclsh) cp $(TOP)/ext/recover/sqlite3recover.c tsrc/ @@ -2210,7 +2210,7 @@ SHELL_DEP = \ $(TOP)/src/test_windirent.h shell.c: $(SHELL_DEP) $(TOP)/tool/mkshellc.tcl $(B.tclsh) - $(B.tclsh) $(TOP)/tool/mkshellc.tcl >shell.c + $(B.tclsh) $(TOP)/tool/mkshellc.tcl shell.c # # Rules to build the extension objects. diff --git a/manifest b/manifest index 604113d5d4..ae3fd789be 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C The\s"clean"\starget\son\sMakefile.msc\sshould\snot\sdelete\sthe\sauto.def\sfile. -D 2025-02-03T12:42:03.773 +C Adjust\sthe\sbuild\sprocess\sto\savoid\sextra\sCR\scharacters\sinserted\sby\sjimsh\non\sWindows. +D 2025-02-03T13:20:11.678 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d F Makefile.in 38485d15d9190cdad0d7bee25af7b442028865964025dcc61f40fd8d6e369cfc F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0 -F Makefile.msc b335ae09e0396f6fb1ff3cc477b5d42f7b19f5b657b9deb8761c02fb9ec93df9 +F Makefile.msc a9b95ae9807e17f9b0734ebe97d68032141c3f95286bb64593cb73b206f043cf F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 01f7606130e48fd58a74d1e45e565f2674819d6eadbc219d328d94bb3362b818 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 @@ -702,7 +702,7 @@ F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65a F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 F ext/wasm/wasmfs.make 68999f5bd8c489239592d59a420f8c627c99169bbd6fa16a404751f757b9f702 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 043987843e8365dbaf74dce60c11683b62e2bcfcb3122574c14a0324d37a72f3 +F main.mk 8cfe182232ac7bbc87530792db6f31c09f2a2f35e9887d0412978746efe42ea9 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2153,12 +2153,12 @@ F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61 F tool/mkopcodeh.tcl 2b4e6967a670ef21bf53a164964c35c6163277d002a4c6f56fa231d68c88d023 F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa F tool/mkpragmatab.tcl 32e359ccb21011958a821955254bd7a5fa7915d01a8c16fed91ffc8b40cb4adf -F tool/mkshellc.tcl 2bc29c201933ae72a16a79070fe80aded80c24ea487ecd2f8df20c2973c87bfc +F tool/mkshellc.tcl 9ce74de0fa904a2c56a96f8d8b5261246bacb0eaa8d7e184f9e18ff94145ebbc F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f -F tool/mksqlite3c.tcl 9e88a30981280e33489fe4782f4ab1e5349ba1866603fba7f1a948d5599b9124 -F tool/mksqlite3h.tcl 5a8d23f35462bfcf74324a19465abd0ad6717b92a404d177160963c292df5d04 +F tool/mksqlite3c.tcl 1b24a4388f544a7f42fc2d03f34422182d3b2263453f65f642890259566369c1 +F tool/mksqlite3h.tcl 3cc8f3fbb3eca38c899549385622637667254067d865a70ad16e0996c2fd3214 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mksrczip.tcl 81efd9974dbb36005383f2cd655520057a2ae5aa85ac2441a80c7c28f803ac52 F tool/mktoolzip.tcl 34b4e92be544f820e2cc26f143f7d5aec511e826ec394cc82969a5dcf7c7a27c @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 602d4dd69ec9a724c69cb41ab15376ec731bfd4894fac0a2b25076b857786c6d -R 24aae7cdfe868af0a232714dd29906e1 +P 72fbcedfb09febb72fa325cb21d160cd33dca7fe5579817143f47d90a20ec2ef +R 4d732beb3e0a16061f12827a776553c4 U drh -Z 6573e99f3b8fb91d202a158e322a8831 +Z 6e6db52bccac51a05d3eab6549c06d4c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e76b7795a9..5ca1ca5a2b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -72fbcedfb09febb72fa325cb21d160cd33dca7fe5579817143f47d90a20ec2ef +1f54853932cec9ba20e9be48a59f1817b8b45e4c4d6ef8a06d34f86dd688e28e diff --git a/tool/mkshellc.tcl b/tool/mkshellc.tcl index af9804e4fa..85e14f8498 100644 --- a/tool/mkshellc.tcl +++ b/tool/mkshellc.tcl @@ -12,6 +12,9 @@ set topdir [file dir [file dir [file normal $argv0]]] set out stdout fconfigure stdout -translation binary +if {[lindex $argv 0]!=""} { + set out [open [lindex $argv 0] wb] +} puts $out {/* DO NOT EDIT! ** This file is automatically generated by the script in the canonical ** SQLite source tree at tool/mkshellc.tcl. That script combines source diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index 1b3958f460..ddc1e58776 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -130,7 +130,7 @@ if {[file executable $vsrcprog] && [file readable $srcroot/manifest]} { } else { puts $out " with changes in files:\n**" foreach f [lrange $res 1 end] { - puts $out "** $f" + puts $out "** [string trim $f]" } } } else { diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl index b409d306b2..8ef123bc72 100644 --- a/tool/mksqlite3h.tcl +++ b/tool/mksqlite3h.tcl @@ -24,18 +24,36 @@ # 6) Adds the SQLITE_CALLBACK calling convention macro in front of all # callback declarations. # -# This script outputs to stdout. +# This script outputs to stdout unless the -o FILENAME option is used. # # Example usage: # -# tclsh mksqlite3h.tcl ../sqlite >sqlite3.h +# tclsh mksqlite3h.tcl ../sqlite [OPTIONS] +# ^^^^^^^^^ +# Root of source tree +# +# Where options are: +# +# --enable-recover Include the sqlite3recover extension +# -o FILENAME Write results to FILENAME instead of stdout +# --useapicall SQLITE_APICALL instead of SQLITE_CDECL # +# Default output stream +set out stdout # Get the source tree root directory from the command-line # set TOP [lindex $argv 0] +# If the -o FILENAME option is present, use FILENAME for output. +# +set x [lsearch $argv -o] +if {$x>0} { + incr x + set out [open [lindex $argv $x] wb] +} + # Enable use of SQLITE_APICALL macros at the right points? # set useapicall 0 @@ -44,6 +62,7 @@ set useapicall 0 # set enable_recover 0 +# Process command-line arguments if {[lsearch -regexp [lrange $argv 1 end] {^-+useapicall}] != -1} { set useapicall 1 } @@ -118,7 +137,7 @@ set cdecllist { foreach file $filelist { set in [open $file rb] if {![regexp {sqlite\.h\.in} $file]} { - puts "/******** Begin file [file tail $file] *********/" + puts $out "/******** Begin file [file tail $file] *********/" } while {![eof $in]} { @@ -161,11 +180,11 @@ foreach file $filelist { "(SQLITE_SYSAPI *sqlite3_syscall_ptr)"] $line] regsub {\(\*} $line {(SQLITE_CALLBACK *} line } - puts $line + puts $out $line } close $in if {![regexp {sqlite\.h\.in} $file]} { - puts "/******** End of [file tail $file] *********/" + puts $out "/******** End of [file tail $file] *********/" } } -puts "#endif /* SQLITE3_H */" +puts $out "#endif /* SQLITE3_H */" From d256b568806e32efd063f280a55830dbbf21ddff Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 3 Feb 2025 14:04:27 +0000 Subject: [PATCH 113/115] Correct the FuncPtrAdapter signature for the JS binding of sqlite3_set_auxdata(). Reported in [https://github.com/sqlite/sqlite-wasm/issues/92|the npm subproject, ticket #92]. FossilOrigin-Name: 76c8435a5f390001038b8ee94322ff478c9d5f29501ed1c5891c952a41e377aa --- ext/wasm/api/sqlite3-api-glue.c-pp.js | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index 680218370a..ddcf2535fd 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -232,7 +232,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ "sqlite3_context*", "int", "*", new wasm.xWrap.FuncPtrAdapter({ name: 'xDestroyAuxData', - signature: 'v(*)', + signature: 'v(p)', contextKey: (argv, argIndex)=>argv[0/* sqlite3_context* */] }) ]], diff --git a/manifest b/manifest index ae3fd789be..7030dfa0ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sthe\sbuild\sprocess\sto\savoid\sextra\sCR\scharacters\sinserted\sby\sjimsh\non\sWindows. -D 2025-02-03T13:20:11.678 +C Correct\sthe\sFuncPtrAdapter\ssignature\sfor\sthe\sJS\sbinding\sof\ssqlite3_set_auxdata().\sReported\sin\s[https://github.com/sqlite/sqlite-wasm/issues/92|the\snpm\ssubproject,\sticket\s#92]. +D 2025-02-03T14:04:27.614 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -638,7 +638,7 @@ F ext/wasm/api/post-js-footer.js 365405929f41ca0e6d389ed8a8da3f3c93e11d3ef43a90a F ext/wasm/api/post-js-header.js 54b2b4294501b3866245cc94315a16f5424c0e87729d0fb610fba151593c6d26 F ext/wasm/api/pre-js.c-pp.js a614a2c82b12c4d96d8e3ba77330329efc53c4d56a8a7e60ade900f341866cfb F ext/wasm/api/sqlite3-api-cleanup.js 3ac1786e461ada63033143be8c3b00b26b939540661f3e839515bb92f2e35359 -F ext/wasm/api/sqlite3-api-glue.c-pp.js fb6dbfe692cc23000a65a4cd95a1a47ed5eb592dc9d8b55363b3c2952a787244 +F ext/wasm/api/sqlite3-api-glue.c-pp.js 0fc6a377907a5101ee426fda7e91def6a310785b23b7a39dd8b2c5e47ee36b4b F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 5ff913355b3144f1c9719d0406667fa6e13eb813c71ed7ce29440e2e65363e82 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 72fbcedfb09febb72fa325cb21d160cd33dca7fe5579817143f47d90a20ec2ef -R 4d732beb3e0a16061f12827a776553c4 -U drh -Z 6e6db52bccac51a05d3eab6549c06d4c +P 1f54853932cec9ba20e9be48a59f1817b8b45e4c4d6ef8a06d34f86dd688e28e +R d1320d9ef5942af95a84d7f496345d0f +U stephan +Z 691559c7ab028b93ffa7b33fa4caf5f0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5ca1ca5a2b..e59ab15d96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f54853932cec9ba20e9be48a59f1817b8b45e4c4d6ef8a06d34f86dd688e28e +76c8435a5f390001038b8ee94322ff478c9d5f29501ed1c5891c952a41e377aa From 77586831edf2f93cd8a74c1845aa6ed609cdfc1f Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 3 Feb 2025 14:40:05 +0000 Subject: [PATCH 114/115] Bring the autoconf-tarball Makefile.msc into alignment with the main Makefile.msc. FossilOrigin-Name: 52a7a162d131532de8f4403b099fa122fc72c80f71494fb561afc4e0ff8e6bf4 --- autoconf/Makefile.msc | 3 ++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index 1f0e42db4b..47e0a83af8 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -1087,5 +1087,6 @@ $(LIBRESOBJS): $(TOP)\sqlite3.rc rcver.vc $(SQLITE3H) clean: del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL - del /Q *.bsc *.def *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL + del /Q *.bsc *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL + del /Q sqlite3.def tclsqlite3.def 2>NUL del /Q $(SQLITE3EXE) $(SQLITE3DLL) Replace.exe 2>NUL diff --git a/manifest b/manifest index 7030dfa0ff..1335b4ed07 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correct\sthe\sFuncPtrAdapter\ssignature\sfor\sthe\sJS\sbinding\sof\ssqlite3_set_auxdata().\sReported\sin\s[https://github.com/sqlite/sqlite-wasm/issues/92|the\snpm\ssubproject,\sticket\s#92]. -D 2025-02-03T14:04:27.614 +C Bring\sthe\sautoconf-tarball\sMakefile.msc\sinto\salignment\swith\sthe\smain\nMakefile.msc. +D 2025-02-03T14:40:05.237 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -17,7 +17,7 @@ F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821 F auto.def e7e92090c98aeb0174d29988c259834eb1b71ae1ea927015c3ef300f6f9b68ae F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac F autoconf/Makefile.in 56697ad25ecf23afa317148b06bdc14f85960b42e5ec434ac1ba87f63a3cb789 -F autoconf/Makefile.msc ffff61fe851443015ddb6600ab69a9df503cfec25459b336be7ba8c9a9e473f8 +F autoconf/Makefile.msc 0a071367537dc395285a5d624ac4f99f3a387b27cc5e89752423c0499e15aec4 F autoconf/README.first f1d3876e9a7852c22f275a6f06814e64934cecbc0b5b9617d64849094c1fd136 F autoconf/README.txt 7f01dc3915e2d68f329011073662369e62a0938a2c69398807823c57591cb288 F autoconf/auto.def 23bc095a3890c0ca334abf7ef67d1c8af4c22c12832bcc738015e868d54fe9d7 @@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1f54853932cec9ba20e9be48a59f1817b8b45e4c4d6ef8a06d34f86dd688e28e -R d1320d9ef5942af95a84d7f496345d0f -U stephan -Z 691559c7ab028b93ffa7b33fa4caf5f0 +P 76c8435a5f390001038b8ee94322ff478c9d5f29501ed1c5891c952a41e377aa +R ffc4ba900908f24af2ec6f8d798eed37 +U drh +Z bc5ceaf13617b69dbeab721c1380d466 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e59ab15d96..a166adab6f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76c8435a5f390001038b8ee94322ff478c9d5f29501ed1c5891c952a41e377aa +52a7a162d131532de8f4403b099fa122fc72c80f71494fb561afc4e0ff8e6bf4 From d98689f4d39c4729ef95a93317eaa7892a6aaed6 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 3 Feb 2025 14:55:56 +0000 Subject: [PATCH 115/115] Add a more complete test for [76c8435a] and add some commentary about (A) the inability to automatically clean up automatically-generated WASM proxy functions for sqlite3_set_auxdata() destructors and (B) how to deal with (A) to avoid leaking WASM proxy functions. FossilOrigin-Name: d693c2dddbd10a2e0b77893b04b11502e30b768f1b06814105f7f35172845fb9 --- ext/wasm/api/sqlite3-api-glue.c-pp.js | 29 ++++++++++++ ext/wasm/tester1.c-pp.js | 67 +++++++++++++++++++++++++++ manifest | 17 ++++--- manifest.uuid | 2 +- 4 files changed, 105 insertions(+), 10 deletions(-) diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index ddcf2535fd..bcaff7243d 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -228,6 +228,31 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }), '*' ]], + /** + 2025-02-03: We do not have a way to automatically clean up + destructors which are automatically converted from JS functions + via the final argument to sqlite3_set_auxdata(). Because of + that, it is strongly recommended that clients use + wasm.installFunction() to create such callbacks, then pass that + pointer to sqlite3_set_auxdata(). Relying on automated + conversions here will lead to leaks of JS/WASM proxy functions + because sqlite3_set_auxdata() is frequently called in UDFs. + + The sqlite3.oo1.DB class's onclose handlers can be used for this + purpose. For example: + + const pAuxDtor = wasm.installFunction('v(p)', function(ptr){ + //free ptr + }); + myDb.onclose = { + after: ()=>{ + wasm.uninstallFunction(pAuxDtor); + } + }; + + Then pass pAuxDtor as the final argument to appropriate + sqlite3_set_auxdata() calls. + */ ["sqlite3_set_auxdata", undefined, [ "sqlite3_context*", "int", "*", new wasm.xWrap.FuncPtrAdapter({ @@ -1047,6 +1072,10 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ 'sqlite3_set_authorizer', 'sqlite3_trace_v2', 'sqlite3_update_hook' + /* + We do not yet have a way to clean up automatically-converted + sqlite3_set_auxdata() finalizers. + */ ]) { const x = wasm.exports[name]; if( !x ){ diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index f83ecbd873..880edcec1d 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3437,6 +3437,73 @@ globalThis.sqlite3InitModule = sqlite3InitModule; } } }) + .t({ + /* https://github.com/sqlite/sqlite-wasm/issues/92 */ + name: 'sqlite3_set_auxdata() binding signature', + test: function(sqlite3){ + const db = new sqlite3.oo1.DB(); + const stack = wasm.pstack.pointer; + const pAux = wasm.pstack.alloc(4); + let pAuxDestructed = 0; + const args = []; + const pAuxDtor = wasm.installFunction('v(p)', function(ptr){ + //log("freeing auxdata"); + ++pAuxDestructed; + }); + let pAuxDtorDestructed = false; + db.onclose = { + after: ()=>{ + pAuxDtorDestructed = true; + wasm.uninstallFunction(pAuxDtor); + } + }; + try{ + db.createFunction("auxtest",{ + xFunc: function(pCx, x, y){ + args.push(x); + T.assert(wasm.isPtr(pCx)); + const localAux = capi.sqlite3_get_auxdata(pCx, 0); + if( !localAux ){ + //log("setting auxdata"); + /** + We do not currently an automated way to clean up + auxdata finalizer functions (the 4th argument to + sqlite3_set_auxdata()) which get automatically + converted from JS to WASM. Because of that, relying + on automated conversions for those is not + recommended. Instead, follow the pattern show in + this function: use wasm.installFunction() to create + the function, then pass the resulting function + pointer this function, and cleanup (at some point) + using wasm.uninstallFunction(). + */ + capi.sqlite3_set_auxdata(pCx, 0, pAux, pAuxDtor); + }else{ + /* This is never actually hit in this example and it's + not entirely clear how to cause it to. The point of + this test, however, is to demonstrate that the + finalizer impl gets triggered, so we're not going to + fret over this at the moment. */ + //log("seen auxdata",localAux); + T.assert(pAux===localAux); + } + return x; + } + }); + db.exec([ + "create table t(a);", + "insert into t(a) values(1),(2),(3);", + "select auxtest(a,a), auxtest(a,a) from t order by a" + ]); + }finally{ + db.close(); + wasm.pstack.restore(stack); + } + T.assert(6===args.length); + T.assert(pAuxDestructed>0); + T.assert(pAuxDtorDestructed); + } + }) ;/*end of Bug Reports group*/; //////////////////////////////////////////////////////////////////////// diff --git a/manifest b/manifest index c36f2724d2..54fc8aa8ae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sbuild\sprocess\son\sWindows\sso\sthat\sit\sgenerates\sidentical\ssqlite3.c,\nsqlite3.h,\sand\sshell.c\sfiles\son\sWindows\sand\sUnix.\s\sThis\spatch\salso\sincludes\na\schange\sto\sJS\sbindings\sthat\sgot\scaught\sup\sin\sthe\sbranch. -D 2025-02-03T14:44:16.557 +C Add\sa\smore\scomplete\stest\sfor\s[76c8435a]\sand\sadd\ssome\scommentary\sabout\s(A)\sthe\sinability\sto\sautomatically\sclean\sup\sautomatically-generated\sWASM\sproxy\sfunctions\sfor\ssqlite3_set_auxdata()\sdestructors\sand\s(B)\show\sto\sdeal\swith\s(A)\sto\savoid\sleaking\sWASM\sproxy\sfunctions. +D 2025-02-03T14:55:56.185 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -638,7 +638,7 @@ F ext/wasm/api/post-js-footer.js 365405929f41ca0e6d389ed8a8da3f3c93e11d3ef43a90a F ext/wasm/api/post-js-header.js 54b2b4294501b3866245cc94315a16f5424c0e87729d0fb610fba151593c6d26 F ext/wasm/api/pre-js.c-pp.js a614a2c82b12c4d96d8e3ba77330329efc53c4d56a8a7e60ade900f341866cfb F ext/wasm/api/sqlite3-api-cleanup.js 3ac1786e461ada63033143be8c3b00b26b939540661f3e839515bb92f2e35359 -F ext/wasm/api/sqlite3-api-glue.c-pp.js 0fc6a377907a5101ee426fda7e91def6a310785b23b7a39dd8b2c5e47ee36b4b +F ext/wasm/api/sqlite3-api-glue.c-pp.js 6e2f2eaf681e342fcb047fcdd01d6e3c1b466fb9b45c1acc38676164a8b60f45 F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc5207bf746fc77d59848813225f F ext/wasm/api/sqlite3-api-prologue.js 5ff913355b3144f1c9719d0406667fa6e13eb813c71ed7ce29440e2e65363e82 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d @@ -696,7 +696,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 05df7cfd2cb8aa8728afb68c90a8af51fdf724c0e892f0f986a695584edae195 +F ext/wasm/tester1.c-pp.js fb8d0761daaa69bd40c8253cc2d6c8c37ada97e1751b7f07af7369842ba2aeae F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2209,9 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 602d4dd69ec9a724c69cb41ab15376ec731bfd4894fac0a2b25076b857786c6d 52a7a162d131532de8f4403b099fa122fc72c80f71494fb561afc4e0ff8e6bf4 -R ffc4ba900908f24af2ec6f8d798eed37 -T +closed 52a7a162d131532de8f4403b099fa122fc72c80f71494fb561afc4e0ff8e6bf4 -U drh -Z 167889892c0bdca97b0a614e610568d1 +P 91ef45fc2902e46813366ec6b8317209f39f10e4a23c3808e33aceedab9da6c7 +R f2c90877762eddda2efda339cfb2ee34 +U stephan +Z 6cfffa02c18a4e52a298c977368cc8d7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 367348a3ff..c7225ebda1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -91ef45fc2902e46813366ec6b8317209f39f10e4a23c3808e33aceedab9da6c7 +d693c2dddbd10a2e0b77893b04b11502e30b768f1b06814105f7f35172845fb9