1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Merge all the latest trunk enhancements into the wal2 branch.

FossilOrigin-Name: bd4651659548bfa523dd99f0c771b7d3c9f5dc41d0412f4f939710c4f4c6e17d
This commit is contained in:
drh
2025-02-18 14:38:00 +00:00
77 changed files with 1947 additions and 2467 deletions

View File

@@ -165,7 +165,7 @@ dir.wasmfs := $(dir.dout)
MKDIR.bld := $(dir.tmp)
$(MKDIR.bld):
-mkdir -p $@ $(dir.dout)
@mkdir -p $@ $(dir.dout)
CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ \
$(dir.fiddle-debug)/* $(dir.dout)/* $(dir.tmp)/*
@@ -424,7 +424,8 @@ define SQLITE.CALL.C-PP.FILTER
# $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)
$(2): $(1) $$(MAKEFILE_LIST) $$(bin.c-pp)
@mkdir -p $$(dir $$@)
$$(bin.c-pp) -f $(1) -o $$@ $(3) $(SQLITE.CALL.C-PP.FILTER.global)
#CLEAN_FILES += $(2)
endef
@@ -618,6 +619,12 @@ emcc.exportedRuntimeMethods := \
emcc.jsflags += $(emcc.exportedRuntimeMethods)
emcc.jsflags += -sUSE_CLOSURE_COMPILER=0
emcc.jsflags += -sIMPORTED_MEMORY
ifeq (,$(filter -O0,$(emcc_opt)))
emcc.assert ?= 0
else
emcc.assert ?= 2
endif
emcc.jsflags += -sASSERTIONS=$(emcc.assert)
emcc.jsflags += -sSTRICT_JS=0
# STRICT_JS disabled due to:
# https://github.com/emscripten-core/emscripten/issues/18610
@@ -909,6 +916,31 @@ 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
ifneq (1,$(MAKING_CLEAN))
# This block MUST come between the above definitions of
# sqlite3-...js/mjs and the $(eval) calls below this block which use
# SQLITE.CALL.C-PP.FILTER.
########################################################################
# 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
$(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)))
@@ -940,27 +972,6 @@ 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.

View File

@@ -8,16 +8,16 @@
point the sqlite3 JS API bits will get set up.
*/
Module.runSQLite3PostLoadInit = function(EmscriptenModule/*the Emscripten-style module object*/){
/** ^^^ As don't use Module.postRun, as that runs a different time
/** ^^^ 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.");
//console.warn("This is the start of Module.runSQLite3PostLoadInit()");
/* This function will contain at least the following:
- post-js-header.js (this file)
- 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
- jaccwabyt/jaccwabyt.js => Jaccwabyt (C/JS struct binding)
@@ -26,8 +26,8 @@ Module.runSQLite3PostLoadInit = function(EmscriptenModule/*the Emscripten-style
- 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
- sqlite3-vfs-opfs.c-pp.js => OPFS VFS
- sqlite3-vfs-opfs.c-pp.js => OPFS VFS
- sqlite3-vfs-opfs-sahpool.c-pp.js => OPFS SAHPool VFS
- sqlite3-api-cleanup.js => final API cleanup
- post-js-footer.js => closes this postRun() function
- post-js-footer.js => closes this function
*/

View File

@@ -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()-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).
whole file into a single callback which can be run after Emscripten
loads the corresponding WASM module. 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

View File

@@ -279,11 +279,11 @@
The arguments are in the same form accepted by oo1.DB.exec(), with
the exceptions noted below.
If the `countChanges` arguments property (added in version 3.43) is
truthy then the `result` property contained by the returned object
will have a `changeCount` property which holds the number of changes
made by the provided SQL. Because the SQL may contain an arbitrary
number of statements, the `changeCount` is calculated by calling
If `args.countChanges` (added in version 3.43) is truthy then the
`result` property contained by the returned object will have a
`changeCount` property which holds the number of changes made by the
provided SQL. Because the SQL may contain an arbitrary number of
statements, the `changeCount` is calculated by calling
`sqlite3_total_changes()` before and after the SQL is evaluated. If
the value of `countChanges` is 64 then the `changeCount` property
will be returned as a 64-bit integer in the form of a BigInt (noting
@@ -292,6 +292,15 @@
calling `sqlite3_total_changes64()` before and after the SQL is
evaluated.
If the `args.lastInsertRowId` (added in version 3.50.0) is truthy
then the `result` property contained by the returned object will
have a `lastInsertRowId` will hold a BigInt-type value corresponding
to the result of sqlite3_last_insert_rowid(). This value is only
fetched once, after the SQL is run, regardless of how many
statements the SQL contains. This API has no idea whether the SQL
contains any INSERTs, so it is up to the client to apply/rely on
this property only when it makes sense to do so.
A function-type args.callback property cannot cross
the window/Worker boundary, so is not useful here. If
args.callback is a string then it is assumed to be a
@@ -542,6 +551,12 @@ sqlite3.initWorker1API = function(){
if(undefined !== changeCount){
rc.changeCount = db.changes(true,64===rc.countChanges) - changeCount;
}
const lastInsertRowId = !!rc.lastInsertRowId
? sqlite3.capi.sqlite3_last_insert_rowid(db)
: undefined;
if( undefined!==lastInsertRowId ){
rc.lastInsertRowId = lastInsertRowId;
}
if(rc.callback instanceof Function){
rc.callback = theCallback;
/* Post a sentinel message to tell the client that the end

View File

@@ -156,11 +156,14 @@
sql: ["create table t(a,b);",
"insert into t(a,b) values(1,2),(3,4),(5,6)"
],
lastInsertRowId: true,
resultRows: [], columnNames: []
}, function(ev){
ev = ev.result;
T.assert(0===ev.resultRows.length)
.assert(0===ev.columnNames.length);
.assert(0===ev.columnNames.length)
.assert('bigint'===typeof ev.lastInsertRowId)
.assert(ev.lastInsertRowId>=3);
});
runOneTest('exec',{
sql: 'select a a, b b from t order by a',

View File

@@ -91,7 +91,7 @@ all: fiddle
fiddle_remote ?=
ifeq (,$(fiddle_remote))
ifneq (,$(wildcard /home/stephan))
fiddle_remote = wh:www/wh/sqlite3/.
fiddle_remote = wh:www/wasm-testing/fiddle/.
else ifneq (,$(wildcard /home/drh))
#fiddle_remote = if appropriate, add that user@host:/path here
endif

View File

@@ -84,8 +84,8 @@
wrapper is significantly easier to use, however.</li>
<li><a href='demo-worker1-promiser.html'>demo-worker1-promiser</a>:
a demo of the Promise-based wrapper of the Worker1 API.</li>
<!--li><a href='demo-worker1-promiser-esm.html'>demo-worker1-promiser-esm</a>:
same as the previous demo except loads the promiser from an ESM module.</li-->
<li><a href='demo-worker1-promiser-esm.html'>demo-worker1-promiser-esm</a>:
same as the previous demo except loads the promiser from an ESM module.</li>
</ul>
</li>
<li>speedtest1 ports (sqlite3's primary benchmarking tool)...

View File

@@ -151,7 +151,7 @@ static void mk_pre_post(const char *zName /* build name */,
/* --pre-js=... */
pf("pre-js.js.%s-%s := $(dir.tmp)/pre-js.%s-%s.js\n",
zNM, zNM);
pf("$(pre-js.js.%s-%s): $(MAKEFILE)\n", zNM);
pf("$(pre-js.js.%s-%s): $(MAKEFILE_LIST)\n", zNM);
#if 1
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);
@@ -218,7 +218,7 @@ static void mk_fiddle(){
pf("fiddle-module.js%s := %s/fiddle-module.js\n", zTail, zDir);
pf("fiddle-module.wasm%s := "
"$(subst .js,.wasm,$(fiddle-module.js%s))\n", zTail, zTail);
pf("$(fiddle-module.js%s):%s $(MAKEFILE) $(MAKEFILE.fiddle) "
pf("$(fiddle-module.js%s):%s $(MAKEFILE_LIST) $(MAKEFILE.fiddle) "
"$(EXPORTED_FUNCTIONS.fiddle) "
"$(fiddle.cses) $(pre-post-fiddle-module-vanilla.deps) "
"$(SOAP.js)\n",
@@ -274,6 +274,7 @@ static void mk_lib_mode(const char *zName /* build name */,
if( !zEmcc ) zEmcc = "";
pf("%s# Begin build [%s-%s]\n", zBanner, zNM);
pf("# zApiJsOut=%s\n# zJsOut=%s\n# zCmppD=%s\n", zApiJsOut, zJsOut, zCmppD);
pf("$(info Setting up build [%s-%s]: %s)\n", zNM, zJsOut);
mk_pre_post(zNM, zCmppD);
pf("\nemcc.flags.%s.%s ?=\n", zNM);
@@ -284,7 +285,7 @@ static void mk_lib_mode(const char *zName /* build name */,
zApiJsOut, zCmppD);
/* target zJsOut */
pf("%s: %s $(MAKEFILE) $(sqlite3-wasm.cfiles) $(EXPORTED_FUNCTIONS.api) "
pf("%s: %s $(MAKEFILE_LIST) $(sqlite3-wasm.cfiles) $(EXPORTED_FUNCTIONS.api) "
"$(pre-post-%s-%s.deps) "
"$(sqlite3-api.ext.jses)"
/* ^^^ maintenance reminder: we set these as deps so that they
@@ -303,9 +304,10 @@ static void mk_lib_mode(const char *zName /* build name */,
"\t\t$(cflags.%s) $(cflags.%s.%s) \\\n"
"\t\t$(cflags.wasm_extra_init) $(sqlite3-wasm.cfiles)\n", zName, zNM);
if( bIsEsm ){
/* 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. */
/* 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 SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT,1,%d)\n",
0==strcmp("sqlite3-wasmfs", zName) ? 1 : 0);
}
@@ -337,6 +339,16 @@ static void mk_lib_mode(const char *zName /* build name */,
/* ^^^^^^ reminder: Mac/BSD sed has no -i flag */
zNM, zName);
pf("\t@ls -la $@\n");
if( 0==strcmp("bundler-friendly", zMode) ){
/* Avoid a 3rd occurance of the bug fixed by 65798c09a00662a3,
** which was (in two cases) caused by makefile refactoring and
** not recognized until after a release was made with the broken
** sqlite3-bundler-friendly.mjs: */
pf("\t@if grep -e '^ *importScripts(' $@; "
"then echo 'ERROR: bug fixed in 65798c09a00662a3 has re-appeared'; "
"exit 1; fi;\n");
}
}else{
pf("\t@ls -la %s $@\n", zWasmOut);
}