git: d461550fc2c0 - stable/14 - sqlite3: Vendor import of sqlite3 3.53.1

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Mon, 31 Aug 2026 16:35:51 UTC
The branch stable/14 has been updated by cy:

URL: https://cgit.FreeBSD.org/src/commit/?id=d461550fc2c08ee7706e0ca022ded84731e2ea8e

commit d461550fc2c08ee7706e0ca022ded84731e2ea8e
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2026-05-25 17:19:28 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2026-08-31 16:35:31 +0000

    sqlite3: Vendor import of sqlite3 3.53.1
    
    Release notes at https://www.sqlite.org/releaselog/3_53_1.html.
    
    Obtained from:  https://www.sqlite.org/2026/sqlite-autoconf-3530100.tar.g
    
    Merge commit 'b00eb376e3fb28e738f9370552dae9d92c1fdd76' into sqlite3
    
    (cherry picked from commit 5b8f59e648431715e8f5f60ef09c0be4508b3ae6)
---
 contrib/sqlite3/Makefile.in                 |    11 +-
 contrib/sqlite3/Makefile.msc                |   107 +-
 contrib/sqlite3/VERSION                     |     2 +-
 contrib/sqlite3/autosetup/README.md         |    19 +-
 contrib/sqlite3/autosetup/autosetup         |    18 +-
 contrib/sqlite3/autosetup/cc-shared.tcl     |    10 +-
 contrib/sqlite3/autosetup/jimsh0.c          |    47 +-
 contrib/sqlite3/autosetup/proj.tcl          |   579 +-
 contrib/sqlite3/autosetup/sqlite-config.tcl |   259 +-
 contrib/sqlite3/autosetup/teaish/core.tcl   |   141 +-
 contrib/sqlite3/autosetup/teaish/tester.tcl |    71 +-
 contrib/sqlite3/make.bat                    |     2 +
 contrib/sqlite3/shell.c                     | 21437 +++++++++++++++-----------
 contrib/sqlite3/sqlite3.1                   |    28 +-
 contrib/sqlite3/sqlite3.c                   | 16223 +++++++++++++------
 contrib/sqlite3/sqlite3.h                   |   946 +-
 contrib/sqlite3/sqlite3ext.h                |    16 +
 contrib/sqlite3/sqlite3rc.h                 |     2 +-
 contrib/sqlite3/tea/Makefile.in             |    84 +-
 contrib/sqlite3/tea/README.txt              |    18 +-
 contrib/sqlite3/tea/_teaish.tester.tcl.in   |     3 +-
 contrib/sqlite3/tea/configure               |    17 +-
 contrib/sqlite3/tea/doc/sqlite3.n           |    15 -
 contrib/sqlite3/tea/generic/tclsqlite3.c    |   562 +-
 contrib/sqlite3/tea/teaish.tcl              |    10 +-
 25 files changed, 25692 insertions(+), 14935 deletions(-)

diff --git a/contrib/sqlite3/Makefile.in b/contrib/sqlite3/Makefile.in
index a77386faed7c..8e6b358befbb 100644
--- a/contrib/sqlite3/Makefile.in
+++ b/contrib/sqlite3/Makefile.in
@@ -222,9 +222,12 @@ install: install-lib
 # Flags to link the shell app either directly against sqlite3.c
 # (ENABLE_STATIC_SHELL==1) or libsqlite3.so (ENABLE_STATIC_SHELL==0).
 #
+# Maintenance reminder: placement of $(LDFLAGS) is more relevant for
+# some platforms than others:
+# https://sqlite.org/forum/forumpost/d80ecdaddd
 ENABLE_STATIC_SHELL = @ENABLE_STATIC_SHELL@
-sqlite3-shell-link-flags.1 = $(TOP)/sqlite3.c $(LDFLAGS.libsqlite3)
-sqlite3-shell-link-flags.0 = -L. -lsqlite3 $(LDFLAGS.zlib) $(LDFLAGS.math)
+sqlite3-shell-link-flags.1 = $(TOP)/sqlite3.c $(LDFLAGS) $(LDFLAGS.libsqlite3)
+sqlite3-shell-link-flags.0 = $(LDFLAGS) -L. -lsqlite3 $(LDFLAGS.zlib) $(LDFLAGS.math)
 sqlite3-shell-deps.1 = $(TOP)/sqlite3.c
 sqlite3-shell-deps.0 = $(libsqlite3.DLL)
 #
@@ -245,7 +248,7 @@ sqlite3$(T.exe): $(TOP)/shell.c $(sqlite3-shell-deps.$(ENABLE_STATIC_SHELL))
 		$(sqlite3-shell-static.flags.$(STATIC_CLI_SHELL)) \
 		-I. $(OPT_FEATURE_FLAGS) $(SHELL_OPT) \
 		$(CFLAGS) $(CFLAGS.readline) $(CFLAGS.icu) \
-		$(LDFLAGS) $(LDFLAGS.readline)
+		$(LDFLAGS.readline)
 
 sqlite3$(T.exe)-1:
 sqlite3$(T.exe)-0: sqlite3$(T.exe)
@@ -279,7 +282,7 @@ DIST_FILES := \
   README.txt VERSION \
   auto.def autosetup configure tea \
   sqlite3.h sqlite3.c shell.c sqlite3ext.h \
-  Makefile.in Makefile.msc Makefile.fallback \
+  Makefile.in Makefile.msc Makefile.fallback make.bat \
   sqlite3.rc sqlite3rc.h Replace.cs \
   sqlite3.pc.in sqlite3.1
 
diff --git a/contrib/sqlite3/Makefile.msc b/contrib/sqlite3/Makefile.msc
index dfa2dcfd5bdc..34e41d8aa0f3 100644
--- a/contrib/sqlite3/Makefile.msc
+++ b/contrib/sqlite3/Makefile.msc
@@ -101,13 +101,6 @@ NO_WARN = $(NO_WARN) -wd4210 -wd4232 -wd4244 -wd4305 -wd4306 -wd4702 -wd4706
 !ENDIF
 !ENDIF
 
-# Set this non-0 to use the library paths and other options necessary for
-# Windows Phone 8.1.
-#
-!IFNDEF USE_WP81_OPTS
-USE_WP81_OPTS = 0
-!ENDIF
-
 # Set this non-0 to split the SQLite amalgamation file into chunks to
 # be used for debugging with Visual Studio.
 #
@@ -156,14 +149,6 @@ USE_NATIVE_LIBPATHS = 0
 USE_RC = 1
 !ENDIF
 
-# Set this non-0 to compile binaries suitable for the WinRT environment.
-# This setting does not apply to any binaries that require Tcl to operate
-# properly (i.e. the text fixture, etc).
-#
-!IFNDEF FOR_WINRT
-FOR_WINRT = 0
-!ENDIF
-
 # Set this non-0 to compile binaries suitable for the UWP environment.
 # This setting does not apply to any binaries that require Tcl to operate
 # properly (i.e. the text fixture, etc).
@@ -327,6 +312,7 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBSTAT_VTAB=1
 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_BYTECODE_VTAB=1
+OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_CARRAY=1
 !ENDIF
 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
 !ENDIF
@@ -349,6 +335,7 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
 
 # Always enable math functions on Windows
 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MATH_FUNCTIONS
+OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PERCENTILE
 
 # Should the rbu extension be enabled?  If so, add compilation options
 # to enable it.
@@ -561,10 +548,14 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS)
 !IF "$(PLATFORM)"=="x86"
 CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
 SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+
+
 !ELSE
 !IFNDEF PLATFORM
 CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
 SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+
+
 !ELSE
 CORE_CCONV_OPTS =
 SHELL_CCONV_OPTS =
@@ -665,18 +656,6 @@ SHELL_LINK_OPTS = $(SHELL_CORE_LIB)
 TCC = $(TCC) -FAcs
 !ENDIF
 
-# When compiling the library for use in the WinRT environment,
-# the following compile-time options must be used as well to
-# disable use of Win32 APIs that are not available and to enable
-# use of Win32 APIs that are specific to Windows 8 and/or WinRT.
-#
-!IF $(FOR_WINRT)!=0
-TCC = $(TCC) -DSQLITE_OS_WINRT=1
-RCC = $(RCC) -DSQLITE_OS_WINRT=1
-TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
-RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
-!ENDIF
-
 # C compiler options for the Windows 10 platform (needs MSVC 2015).
 #
 !IF $(FOR_WIN10)!=0
@@ -689,35 +668,29 @@ BCC = $(BCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
 # USE_CRT_DLL option is set to force dynamically linking to the
 # MSVC runtime library.
 #
-!IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0
+!IF $(USE_CRT_DLL)!=0
 !IF $(DEBUG)>1
 TCC = $(TCC) -MDd
 BCC = $(BCC) -MDd
+ZLIBCFLAGS = -nologo -MDd -W3 -O2 -Oy- -Zi
 !ELSE
 TCC = $(TCC) -MD
 BCC = $(BCC) -MD
+ZLIBCFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi
 !ENDIF
 !ELSE
 !IF $(DEBUG)>1
 TCC = $(TCC) -MTd
 BCC = $(BCC) -MTd
+ZLIBCFLAGS = -nologo -MTd -W3 -O2 -Oy- -Zi
 !ELSE
 TCC = $(TCC) -MT
 BCC = $(BCC) -MT
+ZLIBCFLAGS = -nologo -MT -W3 -O2 -Oy- -Zi
 !ENDIF
 !ENDIF
 
 
-# Define -DNDEBUG to compile without debugging (i.e., for production usage)
-# Omitting the define will cause extra debugging code to be inserted and
-# includes extra comments when "EXPLAIN stmt" is used.
-#
-!IF $(DEBUG)==0
-TCC = $(TCC) -DNDEBUG
-BCC = $(BCC) -DNDEBUG
-RCC = $(RCC) -DNDEBUG
-!ENDIF
-
 !IF $(DEBUG)>0 || $(API_ARMOR)!=0 || $(FOR_WIN10)!=0
 TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR=1
 RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1
@@ -907,56 +880,6 @@ LTLINKOPTS = /NOLOGO
 LTLIBOPTS = /NOLOGO
 !ENDIF
 
-# When compiling for use in the WinRT environment, the following
-# linker option must be used to mark the executable as runnable
-# only in the context of an application container.
-#
-!IF $(FOR_WINRT)!=0
-LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER
-!IF "$(VISUALSTUDIOVERSION)"=="12.0" || "$(VISUALSTUDIOVERSION)"=="14.0"
-!IFNDEF STORELIBPATH
-!IF "$(PLATFORM)"=="x86"
-STORELIBPATH = $(CRTLIBPATH)\store
-!ELSEIF "$(PLATFORM)"=="x64"
-STORELIBPATH = $(CRTLIBPATH)\store\amd64
-!ELSEIF "$(PLATFORM)"=="ARM"
-STORELIBPATH = $(CRTLIBPATH)\store\arm
-!ELSE
-STORELIBPATH = $(CRTLIBPATH)\store
-!ENDIF
-!ENDIF
-STORELIBPATH = $(STORELIBPATH:\\=\)
-LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(STORELIBPATH)"
-!ENDIF
-!ENDIF
-
-# When compiling for Windows Phone 8.1, an extra library path is
-# required.
-#
-!IF $(USE_WP81_OPTS)!=0
-!IFNDEF WP81LIBPATH
-!IF "$(PLATFORM)"=="x86"
-WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
-!ELSEIF "$(PLATFORM)"=="ARM"
-WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\ARM
-!ELSE
-WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
-!ENDIF
-!ENDIF
-!ENDIF
-
-# When compiling for Windows Phone 8.1, some extra linker options
-# are also required.
-#
-!IF $(USE_WP81_OPTS)!=0
-!IFDEF WP81LIBPATH
-LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(WP81LIBPATH)"
-!ENDIF
-LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE
-LTLINKOPTS = $(LTLINKOPTS) WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib
-LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib
-!ENDIF
-
 # When compiling for UWP or the Windows 10 platform, some extra linker
 # options are also required.
 #
@@ -980,9 +903,9 @@ LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib
 # If either debugging or symbols are enabled, enable PDBs.
 #
 !IF $(DEBUG)>1 || $(SYMBOLS)!=0
-LDFLAGS = /DEBUG $(LDOPTS)
+LDFLAGS = /NODEFAULTLIB:msvcrt /DEBUG $(LDOPTS)
 !ELSE
-LDFLAGS = $(LDOPTS)
+LDFLAGS = /NODEFAULTLIB:msvcrt $(LDOPTS)
 !ENDIF
 
 
@@ -1015,8 +938,10 @@ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_DQS=0
 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS4=1
 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS=1
 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC=1
+SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_PERCENTILE=1
 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION=1
 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_STMT_SCANSTATUS=1
+SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_BYTECODE_VTAB=1
 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_STRICT_SUBTYPE=1
 !ENDIF
 
@@ -1065,6 +990,8 @@ $(SQLITE3EXE):	shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLIT
 		/link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
 
 
+tclsqlite-ex.c:
+
 # Rule to build the amalgamation
 #
 sqlite3.lo:	$(SQLITE3C)
diff --git a/contrib/sqlite3/VERSION b/contrib/sqlite3/VERSION
index acecb4fcb7aa..0d767a08f23c 100644
--- a/contrib/sqlite3/VERSION
+++ b/contrib/sqlite3/VERSION
@@ -1 +1 @@
-3.50.4
+3.53.1
diff --git a/contrib/sqlite3/autosetup/README.md b/contrib/sqlite3/autosetup/README.md
index 3301f5739599..ac013080ad02 100644
--- a/contrib/sqlite3/autosetup/README.md
+++ b/contrib/sqlite3/autosetup/README.md
@@ -375,18 +375,29 @@ configure process, and check it in.
 Patching Autosetup for Project-local Changes
 ------------------------------------------------------------------------
 
+The autosetup files require the following patches after updating
+from their upstream sources:
+
+### `--debug` flag
+
 Autosetup reserves the flag name **`--debug`** for its own purposes,
 and its own special handling of `--enable-...` flags makes `--debug`
 an alias for `--enable-debug`. As this project has a long history of
 using `--enable-debug`, we patch autosetup to use the name
 `--autosetup-debug` in place of `--debug`. That requires (as of this
-writing) four small edits in [](/file/autosetup/autosetup), as
-demonstrated in [check-in 3296c8d3](/info/3296c8d3).
+writing) four small edits in
+[/autosetup/autosetup](/file/autosetup/autosetup), as demonstrated in
+[check-in 3296c8d3](/info/3296c8d3).
 
 If autosetup is upgraded and this patch is _not_ applied the invoking
 `./configure` will fail loudly because of the declaration of the
 `debug` flag in `auto.def` - duplicated flags are not permitted.
 
+### Fail on `malloc()` error
+
+See [check-in 72c8a5b94cdf5d](/info/72c8a5b94cdf5d).
+
+
 <a name="branch-customization"></a>
 Branch-specific Customization
 ========================================================================
@@ -426,7 +437,7 @@ proc sqlite-custom-flags {} {
 ```
 
 That function must return either an empty string or a list in the form
-used internally by `sqlite-config.tcl:sqlite-configure`.
+used internally by [sqlite-config.tcl][]'s `sqlite-configure`.
 
 Next, define:
 
@@ -450,4 +461,4 @@ all other significant processing.
 [sqlite-config.tcl]: /file/autosetup/sqlite-config.tcl
 [Makefile.in]: /file/Makefile.in
 [main.mk]: /file/main.mk
-[JimTCL]: https://jim.tcl.tk
+[JimTCL]: https://msteveb.github.io/jimtcl/
diff --git a/contrib/sqlite3/autosetup/autosetup b/contrib/sqlite3/autosetup/autosetup
index 239987554ff3..c3a31bec585e 100755
--- a/contrib/sqlite3/autosetup/autosetup
+++ b/contrib/sqlite3/autosetup/autosetup
@@ -406,8 +406,8 @@ proc options-add {opts} {
 		# Find the corresponding value in the user options
 		# and set the default if necessary
 		if {[string match "-*" $opt]} {
-			# This is a documentation-only option, like "-C <dir>"
-			set opthelp $opt
+			# We no longer support documentation-only options, like "-C <dir>"
+			autosetup-error "Option $opt is not supported"
 		} elseif {$colon eq ""} {
 			# Boolean option
 			lappend autosetup(options) $name
@@ -1611,7 +1611,7 @@ proc autosetup_output_block {type lines} {
 # Generate a command reference from inline documentation
 proc automf_command_reference {} {
     lappend files $::autosetup(prog)
-    lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
+    lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/{*/*.tcl,*.tcl}]]
 
     # We want to process all non-module files before module files
     # and then modules in alphabetical order.
@@ -2124,7 +2124,7 @@ if {$autosetup(istcl)} {
 			set frame [info frame -$i]
 			if {[dict exists $frame file]} {
 				# We don't need proc, so use ""
-				lappend stacktrace "" [dict get $frame file] [dict get $frame line]
+				lappend stacktrace "" [dict get $frame file] [dict get $frame line] ""
 			}
 		}
 		return $stacktrace
@@ -2181,8 +2181,12 @@ proc error-location {msg} {
 	if {$::autosetup(debug)} {
 		return -code error $msg
 	}
-	# Search back through the stack trace for the first error in a .def file
-	foreach {p f l} [stacktrace] {
+	set vars {p f l cmd}
+	if {!$::autosetup(istcl) && ![dict exists $::tcl_platform stackFormat]} {
+		# Older versions of Jim had a 3 element stacktrace
+		set vars {p f l}
+	}
+	foreach $vars [stacktrace] {
 		if {[string match *.def $f]} {
 			return "[relative-path $f]:$l: Error: $msg"
 		}
@@ -2534,7 +2538,7 @@ if {[catch {main $argv} msg opts] == 1} {
 	show-notices
 	autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
 	if {!$autosetup(debug)} {
-		puts stderr "Try: '[file tail $autosetup(exe)] --autosetup-debug' for a full stack trace"
+		puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
 	}
 	exit 1
 }
diff --git a/contrib/sqlite3/autosetup/cc-shared.tcl b/contrib/sqlite3/autosetup/cc-shared.tcl
index cbe568018e96..1fa200eec184 100644
--- a/contrib/sqlite3/autosetup/cc-shared.tcl
+++ b/contrib/sqlite3/autosetup/cc-shared.tcl
@@ -89,13 +89,15 @@ switch -glob -- [get-define host] {
 			define SH_SOPREFIX -Wl,-h,
 		}
 	}
-	*-*-hpux {
-		# XXX: These haven't been tested
-		define SHOBJ_CFLAGS "+O3 +z"
+	*-*-hpux* {
+		define SHOBJ_CFLAGS +z
 		define SHOBJ_LDFLAGS -b
 		define SH_CFLAGS +z
+		define SH_LDFLAGS -b
 		define SH_LINKFLAGS -Wl,+s
-		define LD_LIBRARY_PATH SHLIB_PATH
+		define SH_LINKRPATH "-Wl,+b -Wl,%s"
+		define SH_SOPREFIX -Wl,+h,
+		define STRIPLIBFLAGS -Wl,-s
 	}
 	*-*-haiku {
 		define SHOBJ_CFLAGS ""
diff --git a/contrib/sqlite3/autosetup/jimsh0.c b/contrib/sqlite3/autosetup/jimsh0.c
index b035524c9681..0f0a890888b4 100644
--- a/contrib/sqlite3/autosetup/jimsh0.c
+++ b/contrib/sqlite3/autosetup/jimsh0.c
@@ -7409,11 +7409,13 @@ void *JimDefaultAllocator(void *ptr, size_t size)
         free(ptr);
         return NULL;
     }
-    else if (ptr) {
-        return realloc(ptr, size);
-    }
     else {
-        return malloc(size);
+        void *p = realloc(ptr, size);
+        if( p==0 ){
+            fprintf(stderr,"Out of memory\n");
+            exit(1);
+        }
+        return p;
     }
 }
 
@@ -9132,7 +9134,7 @@ int Jim_StringEqObj(Jim_Obj *aObjPtr, Jim_Obj *bObjPtr)
         const char *sA = Jim_GetString(aObjPtr, &Alen);
         const char *sB = Jim_GetString(bObjPtr, &Blen);
 
-        return Alen == Blen && *sA == *sB && memcmp(sA, sB, Alen) == 0;
+        return Alen == Blen && memcmp(sA, sB, Alen) == 0;
     }
 }
 
@@ -10242,7 +10244,7 @@ static int JimCommandsHT_KeyCompare(void *privdata, const void *key1, const void
     int len1, len2;
     const char *str1 = Jim_GetStringNoQualifier((Jim_Obj *)key1, &len1);
     const char *str2 = Jim_GetStringNoQualifier((Jim_Obj *)key2, &len2);
-    return len1 == len2 && *str1 == *str2 && memcmp(str1, str2, len1) == 0;
+    return len1 == len2 && memcmp(str1, str2, len1) == 0;
 }
 
 static void JimCommandsHT_ValDestructor(void *interp, void *val)
@@ -13864,13 +13866,6 @@ static int JimExprOpNumUnary(Jim_Interp *interp, struct JimExprNode *node)
             case JIM_EXPROP_NOT:
                 wC = !bA;
                 break;
-            case JIM_EXPROP_UNARYPLUS:
-            case JIM_EXPROP_UNARYMINUS:
-                rc = JIM_ERR;
-                Jim_SetResultFormatted(interp,
-                    "can't use non-numeric string as operand of \"%s\"",
-                        node->type == JIM_EXPROP_UNARYPLUS ? "+" : "-");
-                break;
             default:
                 abort();
         }
@@ -19875,22 +19870,16 @@ wrongargs:
                     }
                     else if (errorCodeObj) {
                         int len = Jim_ListLength(interp, argv[idx + 1]);
+                        int i;
 
-                        if (len > Jim_ListLength(interp, errorCodeObj)) {
+                        ret = JIM_OK;
 
-                            ret = -1;
-                        }
-                        else {
-                            int i;
-                            ret = JIM_OK;
-
-                            for (i = 0; i < len; i++) {
-                                Jim_Obj *matchObj = Jim_ListGetIndex(interp, argv[idx + 1], i);
-                                Jim_Obj *objPtr = Jim_ListGetIndex(interp, errorCodeObj, i);
-                                if (Jim_StringCompareObj(interp, matchObj, objPtr, 0) != 0) {
-                                    ret = -1;
-                                    break;
-                                }
+                        for (i = 0; i < len; i++) {
+                            Jim_Obj *matchObj = Jim_ListGetIndex(interp, argv[idx + 1], i);
+                            Jim_Obj *objPtr = Jim_ListGetIndex(interp, errorCodeObj, i);
+                            if (Jim_StringCompareObj(interp, matchObj, objPtr, 0) != 0) {
+                                ret = -1;
+                                break;
                             }
                         }
                     }
@@ -20266,7 +20255,7 @@ static int Jim_DictCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *arg
         }
 
         case OPT_SET:
-            return Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc - 4, argv[argc - 1], JIM_ERRMSG | JIM_UNSHARED);
+            return Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc - 4, argv[argc - 1], JIM_ERRMSG);
 
         case OPT_EXISTS:{
                 int rc = Jim_DictKeysVector(interp, argv[2], argv + 3, argc - 3, &objPtr, JIM_NONE);
@@ -20278,7 +20267,7 @@ static int Jim_DictCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *arg
             }
 
         case OPT_UNSET:
-            if (Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc - 3, NULL, JIM_UNSHARED) != JIM_OK) {
+            if (Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc - 3, NULL, JIM_NONE) != JIM_OK) {
                 return JIM_ERR;
             }
             return JIM_OK;
diff --git a/contrib/sqlite3/autosetup/proj.tcl b/contrib/sqlite3/autosetup/proj.tcl
index 1335567064ee..caa679ad65ba 100644
--- a/contrib/sqlite3/autosetup/proj.tcl
+++ b/contrib/sqlite3/autosetup/proj.tcl
@@ -60,10 +60,11 @@
 # $proj__Config is an internal-use-only array for storing whatever generic
 # internal stuff we need stored.
 #
-array set ::proj__Config {
-  self-tests 1
-}
-
+array set ::proj__Config [subst {
+  self-tests [get-env proj.self-tests 0]
+  verbose-assert [get-env proj.assert-verbose 0]
+  isatty [isatty? stdout]
+}]
 
 #
 # List of dot-in files to filter in the final stages of
@@ -75,7 +76,6 @@ array set ::proj__Config {
 # See: proj-dot-ins-append and proj-dot-ins-process
 #
 set ::proj__Config(dot-in-files) [list]
-set ::proj__Config(isatty) [isatty? stdout]
 
 #
 # @proj-warn msg
@@ -85,28 +85,29 @@ set ::proj__Config(isatty) [isatty? stdout]
 #
 proc proj-warn {args} {
   show-notices
-  puts stderr [join [list "WARNING: \[[proj-scope 1]\]: " {*}$args] " "]
+  puts stderr [join [list "WARNING:" \[ [proj-scope 1] \]: {*}$args] " "]
 }
 
 
+#
 # Internal impl of [proj-fatal] and [proj-error]. It must be called
 # using tailcall.
-proc proj__faterr {failMode argv} {
+#
+proc proj__faterr {failMode args} {
   show-notices
   set lvl 1
-  while {"-up" eq [lindex $argv 0]} {
-    set argv [lassign $argv -]
+  while {"-up" eq [lindex $args 0]} {
+    set args [lassign $args -]
     incr lvl
   }
   if {$failMode} {
-    puts stderr [join [list "FATAL: \[[proj-scope $lvl]]: " {*}$argv]]
+    puts stderr [join [list "FATAL:" \[ [proj-scope $lvl] \]: {*}$args]]
     exit 1
   } else {
-    error [join [list "\[[proj-scope $lvl]]:" {*}$argv]]
+    error [join [list in \[ [proj-scope $lvl] \]: {*}$args]]
   }
 }
 
-
 #
 # @proj-fatal ?-up...? msg...
 #
@@ -118,7 +119,7 @@ proc proj__faterr {failMode argv} {
 # additional level.
 #
 proc proj-fatal {args} {
-  tailcall proj__faterr 1 $args
+  tailcall proj__faterr 1 {*}$args
 }
 
 #
@@ -127,10 +128,9 @@ proc proj-fatal {args} {
 # Works like proj-fatal but uses [error] intead of [exit].
 #
 proc proj-error {args} {
-  tailcall proj__faterr 0 $args
+  tailcall proj__faterr 0 {*}$args
 }
 
-set ::proj__Config(verbose-assert) [get-env proj-assert-verbose 0]
 #
 # @proj-assert script ?message?
 #
@@ -147,7 +147,7 @@ proc proj-assert {script {msg ""}} {
     if {"" eq $msg} {
       set msg $script
     }
-    proj-fatal "Assertion failed in \[[proj-scope 1]\]: $msg"
+    tailcall proj__faterr 1 "Assertion failed:" $msg
   }
 }
 
@@ -378,8 +378,8 @@ proc proj-bin-define {binName {defName {}}} {
 #
 # Despite using cc-path-progs to do the search, this function clears
 # any define'd name that function stores for the result (because the
-# caller has no sensible way of knowing which result it was unless
-# they pass only a single argument).
+# caller has no sensible way of knowing which [define] name it has
+# unless they pass only a single argument).
 #
 proc proj-first-bin-of {args} {
   set rc ""
@@ -451,7 +451,9 @@ proc proj-opt-set {flag {val 1}} {
 # @proj-opt-exists flag
 #
 # Returns 1 if the given flag has been defined as a legal configure
-# option, else returns 0.
+# option, else returns 0. Options set via proj-opt-set "exist" for
+# this purpose even if they were not defined via autosetup's
+# [options] function.
 #
 proc proj-opt-exists {flag} {
   expr {$flag in $::autosetup(options)};
@@ -555,7 +557,7 @@ proc proj-opt-define-bool {args} {
   if {$invert} {
     set rc [expr {!$rc}]
   }
-  msg-result $rc
+  msg-result [string map {0 no 1 yes} $rc]
   define $defName $rc
   return $rc
 }
@@ -704,11 +706,20 @@ proc proj-file-write {args} {
 }
 
 #
-# @proj-check-compile-commands ?configFlag?
+# @proj-check-compile-commands ?-assume-for-clang? ?configFlag?
+#
+# Checks the compiler for compile_commands.json support. If
+# $configFlag is not empty then it is assumed to be the name of an
+# autosetup boolean config which controls whether to run/skip this
+# check.
 #
-# Checks the compiler for compile_commands.json support. If passed an
-# argument it is assumed to be the name of an autosetup boolean config
-# which controls whether to run/skip this check.
+# If -assume-for-clang is provided and $configFlag is not empty and CC
+# matches *clang* and no --$configFlag was explicitly provided to the
+# configure script then behave as if --$configFlag had been provided.
+# To disable that assumption, either don't pass -assume-for-clang or
+# pass --$configFlag=0 to the configure script. (The reason for this
+# behavior is that clang supports compile-commands but some other
+# compilers report false positives with these tests.)
 #
 # Returns 1 if supported, else 0, and defines HAVE_COMPILE_COMMANDS to
 # that value. Defines MAKE_COMPILATION_DB to "yes" if supported, "no"
@@ -716,12 +727,38 @@ proc proj-file-write {args} {
 # HAVE_COMPILE_COMMANDS is preferred.
 #
 # ACHTUNG: this test has a long history of false positive results
-# because of compilers reacting differently to the -MJ flag.
-#
-proc proj-check-compile-commands {{configFlag {}}} {
+# because of compilers reacting differently to the -MJ flag.  Because
+# of this, it is recommended that this support be an opt-in feature,
+# rather than an on-by-default default one. That is: in the
+# configure script define the option as
+# {--the-flag-name=0 => {Enable ....}}
+#
+proc proj-check-compile-commands {args} {
+  set i 0
+  set configFlag {}
+  set fAssumeForClang 0
+  set doAssume 0
   msg-checking "compile_commands.json support... "
-  if {"" ne $configFlag && ![proj-opt-truthy $configFlag]} {
-    msg-result "explicitly disabled"
+  if {"-assume-for-clang" eq [lindex $args 0]} {
+    lassign $args - configFlag
+    incr fAssumeForClang
+  } elseif {1 == [llength $args]} {
+    lassign $args configFlag
+  } else {
+    proj-error "Invalid arguments"
+  }
+  if {1 == $fAssumeForClang && "" ne $configFlag} {
+    if {[string match *clang* [get-define CC]]
+        && ![proj-opt-was-provided $configFlag]
+        && ![proj-opt-truthy $configFlag]} {
+      proj-indented-notice [subst -nocommands -nobackslashes {
+        CC appears to be clang, so assuming that --$configFlag is likely
+        to work. To disable this assumption use --$configFlag=0.}]
+      incr doAssume
+    }
+  }
+  if {!$doAssume && "" ne $configFlag && ![proj-opt-truthy $configFlag]} {
+    msg-result "check disabled. Use --${configFlag} to enable it."
     define HAVE_COMPILE_COMMANDS 0
     define MAKE_COMPILATION_DB no
     return 0
@@ -730,7 +767,7 @@ proc proj-check-compile-commands {{configFlag {}}} {
       # This test reportedly incorrectly succeeds on one of
       # Martin G.'s older systems. drh also reports a false
       # positive on an unspecified older Mac system.
-      msg-result "compiler supports compile_commands.json"
+      msg-result "compiler supports -MJ. Assuming it's useful for compile_commands.json"
       define MAKE_COMPILATION_DB yes; # deprecated
       define HAVE_COMPILE_COMMANDS 1
       return 1
@@ -885,7 +922,9 @@ proc proj-looks-like-windows {{key host}} {
 #
 proc proj-looks-like-mac {{key host}} {
   switch -glob -- [get-define $key] {
-    *apple* {
+    *-*-darwin* {
+      # https://sqlite.org/forum/forumpost/7b218c3c9f207646
+      # There's at least one Linux out there which matches *apple*.
       return 1
     }
     default {
@@ -927,17 +966,13 @@ proc proj-exe-extension {} {
 #
 proc proj-dll-extension {} {
   set inner {{key} {
-    switch -glob -- [get-define $key] {
-      *apple* {
-        return ".dylib"
-      }
-      *-*-ming* - *-*-cygwin - *-*-msys {
-        return ".dll"
-      }
-      default {
-        return ".so"
-      }
+    if {[proj-looks-like-mac $key]} {
+      return ".dylib"
     }
+    if {[proj-looks-like-windows $key]} {
+      return ".dll"
+    }
+    return ".so"
   }}
   define BUILD_DLLEXT [apply $inner build]
   define TARGET_DLLEXT [apply $inner host]
@@ -1135,6 +1170,10 @@ proc proj-check-rpath {} {
       if {"" eq $wl} {
         set wl [proj-cc-check-Wl-flag -R$lp]
       }
+      if {"" eq $wl} {
+        # HP-UX: https://sqlite.org/forum/forumpost/d80ecdaddd
+        set wl [proj-cc-check-Wl-flag +b $lp]
+      }
       define LDFLAGS_RPATH $wl
     }
   }
@@ -1144,7 +1183,7 @@ proc proj-check-rpath {} {
 #
 # @proj-check-soname ?libname?
 #
-# Checks whether CC supports the -Wl,soname,lib... flag. If so, it
+# Checks whether CC supports the -Wl,-soname,lib... flag. If so, it
 # returns 1 and defines LDFLAGS_SONAME_PREFIX to the flag's prefix, to
 # which the client would need to append "libwhatever.N".  If not, it
 # returns 0 and defines LDFLAGS_SONAME_PREFIX to an empty string.
@@ -1160,6 +1199,10 @@ proc proj-check-soname {{libname "libfoo.so.0"}} {
     if {[cc-check-flags "-Wl,-soname,${libname}"]} {
       define LDFLAGS_SONAME_PREFIX "-Wl,-soname,"
       return 1
+    } elseif {[cc-check-flags "-Wl,+h,${libname}"]} {
+      # HP-UX: https://sqlite.org/forum/forumpost/d80ecdaddd
+      define LDFLAGS_SONAME_PREFIX "-Wl,+h,"
+      return 1
     } else {
       define LDFLAGS_SONAME_PREFIX ""
       return 0
@@ -1606,7 +1649,7 @@ proc proj-tclConfig-sh-to-autosetup {tclConfigSh} {
 #
 # Similar modifications may be made for --mandir.
 #
-# Returns 1 if it modifies the environment, else 0.
+# Returns >0 if it modifies the environment, else 0.
 #
 proc proj-tweak-default-env-dirs {} {
   set rc 0
@@ -1645,7 +1688,11 @@ proc proj-tweak-default-env-dirs {} {
 # processing the file. In the context of that script, the vars
 # $dotInsIn and $dotInsOut will be set to the input and output file
 # names.  This can be used, for example, to make the output file
-# executable or perform validation on its contents.
+# executable or perform validation on its contents:
+#
+##  proj-dot-ins-append my.sh.in my.sh {
+##    catch {exec chmod u+x $dotInsOut}
+##  }
 #
 # See [proj-dot-ins-process], [proj-dot-ins-list]
 #
@@ -1665,7 +1712,7 @@ proc proj-dot-ins-append {fileIn args} {
       proj-fatal "Too many arguments: $fileIn $args"
     }
   }
-  #puts "******* [proj-scope]: adding $fileIn"
+  #puts "******* [proj-scope]: adding [llength $fileIn]-length item: $fileIn"
   lappend ::proj__Config(dot-in-files) $fileIn
 }
 
@@ -1703,17 +1750,18 @@ proc proj-dot-ins-list {} {
 #  makes proj-dot-ins-append available for re-use.
 #
 proc proj-dot-ins-process {args} {
-  proj-parse-simple-flags args flags {
+  proj-parse-flags args flags {
     -touch   "" {return "-touch"}
     -clear    0 {expr 1}
     -validate 0 {expr 1}
   }
+  #puts "args=$args"; parray flags
   if {[llength $args] > 0} {
     error "Invalid argument to [proj-scope]: $args"
   }
   foreach f $::proj__Config(dot-in-files) {
     proj-assert {3==[llength $f]} \
-      "Expecting proj-dot-ins-list to be stored in 3-entry lists"
+      "Expecting proj-dot-ins-list to be stored in 3-entry lists. Got: $f"
     lassign $f fIn fOut fScript
     #puts "DOING $fIn  ==> $fOut"
     proj-make-from-dot-in {*}$flags(-touch) $fIn $fOut
@@ -1753,7 +1801,7 @@ proc proj-validate-no-unresolved-ats {args} {
     set isMake [string match {*[Mm]ake*} $f]
     foreach line [proj-file-content-list $f] {
       if {!$isMake || ![string match "#*" [string trimleft $line]]} {
-        if {[regexp {(@[A-Za-z0-9_]+@)} $line match]} {
+        if {[regexp {(@[A-Za-z0-9_\.]+@)} $line match]} {
           error "Unresolved reference to $match at line $lnno of $f"
         }
       }
@@ -1794,7 +1842,7 @@ proc proj-setup-autoreconfig {defName} {
 }
 
 #
-# @prop-append-to defineName args...
+# @prop-define-append defineName args...
 #
 # A proxy for Autosetup's [define-append]. Appends all non-empty $args
 # to [define-append $defineName].
@@ -1825,7 +1873,7 @@ proc proj-define-append {defineName args} {
 # but it is technically correct and still relevant on some
 # environments.
 #
-# See: proj-append-to
+# See: proj-define-append
 #
 proc proj-define-amend {args} {
   set defName ""
@@ -1893,7 +1941,7 @@ proc proj-define-amend {args} {
 #
 proc proj-define-to-cflag {args} {
   set rv {}
-  proj-parse-simple-flags args flags {
+  proj-parse-flags args flags {
     -list       0 {expr 1}
     -quote      0 {expr 1}
     -zero-undef 0 {expr 1}
@@ -2001,7 +2049,7 @@ proc proj-cache-key {arg {addLevel 0}} {
 # See proj-cache-key for -key's and -level's semantics, noting that
 # this function adds one to -level for purposes of that call.
 proc proj-cache-set {args} {
-  proj-parse-simple-flags args flags {
+  proj-parse-flags args flags {
     -key => 0
     -level => 0
   }
@@ -2037,7 +2085,7 @@ proc proj-cache-remove {{key 0} {addLevel 0}} {
 # See proj-cache-key for $key's and $addLevel's semantics, noting that
 # this function adds one to $addLevel for purposes of that call.
 proc proj-cache-check {args} {
-  proj-parse-simple-flags args flags {
+  proj-parse-flags args flags {
     -key => 0
     -level => 0
   }
@@ -2070,147 +2118,316 @@ proc proj-coalesce {args} {
 }
 
 #
-# @proj-parse-simple-flags ...
+# @proj-parse-flags argvListName targetArrayName {prototype}
 #
 # A helper to parse flags from proc argument lists.
 #
-# Expects a list of arguments to parse, an array name to store any
-# -flag values to, and a prototype object which declares the flags.
+# The first argument is the name of a var holding the args to
+# parse. It will be overwritten, possibly with a smaller list.
 #
-# The prototype must be a list in one of the following forms:
+# The second argument is the name of an array variable to create in
+# the caller's scope.
 #
-#   -flag defaultValue {script}
+# The third argument, $prototype, is a description of how to handle
+# the flags. Each entry in that list must be in one of the
+# following forms:
 #
-#   -flag => defaultValue
-#   -----^--^ (with spaces there!)
+#   -flag  defaultValue ?-literal|-call|-apply?
+#                       script|number|incr|proc-name|{apply $aLambda}
 #
-# Repeated for each flag.
+#   -flag* ...as above...
 #
-# The first form represents a basic flag with no associated
-# following argument. The second form extracts its value
-# from the following argument in $argvName.
+#   -flag  => defaultValue ?-call proc-name-and-args|-apply lambdaExpr?
 #
-# The first argument to this function is the name of a var holding the
-# args to parse. It will be overwritten, possibly with a smaller list.
+#   -flag* => ...as above...
 #
-# The second argument the name of an array variable to create in the
-# caller's scope. (Pneumonic: => points to the next argument.)
+#   :PRAGMA
 #
-# For the first form of flag, $script is run in the caller's scope if
-# $argv contains -flag, and the result of that script is the new value
-# for $tgtArrayName(-flag). This function intercepts [return $val]
-# from $script. Any empty script will result in the flag having ""
-# assigned to it.
+# The first two forms represents a basic flag with no associated
+# following argument. The third and fourth forms, called arg-consuming
+# flags, extract the value from the following argument in $argvName
+# (pneumonic: => points to the next argument.). The :PRAGMA form
+# offers a way to configure certain aspects of this call.
 #
-# The args list is only inspected until the first argument which is
-# not described by $prototype. i.e. the first "non-flag" (not counting
-# values consumed for flags defined like --flag=>default).
+# If $argv contains any given flag from $prototype, its default value
+# is overridden depending on several factors:
 #
-# If a "--" flag is encountered, no more arguments are inspected as
-# flags. If "--" is the first non-flag argument, the "--" flag is
-# removed from the results but all remaining arguments are passed
-# through. If "--" appears after the first non-flag, it is retained.
+#  - If the -literal flag is used, or the flag's script is a number,
+#    value is used verbatim.
+#
+#  - Else if the -call flag is used, the argument must be a proc name
+#    and any leading arguments, e.g. {apply $myLambda}.  The proc is passed
+#    the (flag, value) as arguments (non-consuming flags will get
+#    passed the flag's current/starting value and consuming flags will
*** 57229 LINES SKIPPED ***