mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Expose sqlite3_value_frombind/nochange/numeric_type() to WASM. Add a flag to sqlite3_value_to_js() to cause it to return undefined, instead of throwing, if no conversion can be found.
FossilOrigin-Name: de8fc4bf34f80f320012a0e506ed8e3e24806daf67845d5dabb00b916108f6ef
This commit is contained in:
@ -107,8 +107,11 @@ _sqlite3_user_data
|
|||||||
_sqlite3_value_blob
|
_sqlite3_value_blob
|
||||||
_sqlite3_value_bytes
|
_sqlite3_value_bytes
|
||||||
_sqlite3_value_double
|
_sqlite3_value_double
|
||||||
|
_sqlite3_value_frombind
|
||||||
_sqlite3_value_int
|
_sqlite3_value_int
|
||||||
_sqlite3_value_int64
|
_sqlite3_value_int64
|
||||||
|
_sqlite3_value_nochange
|
||||||
|
_sqlite3_value_numeric_type
|
||||||
_sqlite3_value_pointer
|
_sqlite3_value_pointer
|
||||||
_sqlite3_value_text
|
_sqlite3_value_text
|
||||||
_sqlite3_value_type
|
_sqlite3_value_type
|
||||||
|
@ -1025,7 +1025,10 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
|||||||
["sqlite3_value_blob", "*", "sqlite3_value*"],
|
["sqlite3_value_blob", "*", "sqlite3_value*"],
|
||||||
["sqlite3_value_bytes","int", "sqlite3_value*"],
|
["sqlite3_value_bytes","int", "sqlite3_value*"],
|
||||||
["sqlite3_value_double","f64", "sqlite3_value*"],
|
["sqlite3_value_double","f64", "sqlite3_value*"],
|
||||||
|
["sqlite3_value_frombind", "int", "sqlite3_value*"],
|
||||||
["sqlite3_value_int","int", "sqlite3_value*"],
|
["sqlite3_value_int","int", "sqlite3_value*"],
|
||||||
|
["sqlite3_value_nochange", "int", "sqlite3_value*"],
|
||||||
|
["sqlite3_value_numeric_type", "int", "sqlite3_value*"],
|
||||||
["sqlite3_value_pointer", "*", "sqlite3_value*", "string:static"],
|
["sqlite3_value_pointer", "*", "sqlite3_value*", "string:static"],
|
||||||
["sqlite3_value_text", "string", "sqlite3_value*"],
|
["sqlite3_value_text", "string", "sqlite3_value*"],
|
||||||
["sqlite3_value_type", "int", "sqlite3_value*"],
|
["sqlite3_value_type", "int", "sqlite3_value*"],
|
||||||
@ -1661,10 +1664,24 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
|||||||
/**
|
/**
|
||||||
Given a (sqlite3_value*), this function attempts to convert it
|
Given a (sqlite3_value*), this function attempts to convert it
|
||||||
to an equivalent JS value with as much fidelity as feasible and
|
to an equivalent JS value with as much fidelity as feasible and
|
||||||
return it. Throws if it cannot determine any sensible
|
return it.
|
||||||
conversion, but that would be indicative of a serious error.
|
|
||||||
|
By default it throws if it cannot determine any sensible
|
||||||
|
conversion. If passed a falsy second argument, it instead returns
|
||||||
|
`undefined` if no suitable conversion is found. Note that there
|
||||||
|
is no conversion from SQL to JS which results in the `undefined`
|
||||||
|
value, so `undefined` has an unambiguous meaning here.
|
||||||
|
|
||||||
|
Caveats:
|
||||||
|
|
||||||
|
- It does not support sqlite3_value_to_pointer() conversions
|
||||||
|
because those require a type name string which this function
|
||||||
|
does not have and cannot sensibly be given at the level of the
|
||||||
|
API where this is used (e.g. automatically converting UDF
|
||||||
|
arguments). Clients using sqlite3_value_to_pointer(), and its
|
||||||
|
related APIs, will need to manage those themselves.
|
||||||
*/
|
*/
|
||||||
capi.sqlite3_value_to_js = function(pVal){
|
capi.sqlite3_value_to_js = function(pVal,throwIfCannotConvert=true){
|
||||||
let arg;
|
let arg;
|
||||||
const valType = capi.sqlite3_value_type(pVal);
|
const valType = capi.sqlite3_value_type(pVal);
|
||||||
switch(valType){
|
switch(valType){
|
||||||
@ -1693,9 +1710,11 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
|||||||
case capi.SQLITE_NULL:
|
case capi.SQLITE_NULL:
|
||||||
arg = null; break;
|
arg = null; break;
|
||||||
default:
|
default:
|
||||||
toss3("Unhandled sqlite3_value_type()",valType,
|
if(throwIfCannotConvert){
|
||||||
"is possibly indicative of incorrect",
|
toss3(capi.SQLITE_MISMATCH,
|
||||||
"pointer size assumption.");
|
"Unhandled sqlite3_value_type():",valType);
|
||||||
|
}
|
||||||
|
arg = undefined;
|
||||||
}
|
}
|
||||||
return arg;
|
return arg;
|
||||||
};
|
};
|
||||||
|
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
|||||||
C Refactor\sthe\ssqlite3_value-to-JS\sconversion\sfrom\san\sinternal\sdetail\sto\ssqlite3.capi.sqlite3_value_to_js()\sfor\suse\swith\sroutines\slike\ssqlite3_module::xFilter().
|
C Expose\ssqlite3_value_frombind/nochange/numeric_type()\sto\sWASM.\sAdd\sa\sflag\sto\ssqlite3_value_to_js()\sto\scause\sit\sto\sreturn\sundefined,\sinstead\sof\sthrowing,\sif\sno\sconversion\scan\sbe\sfound.
|
||||||
D 2022-12-09T14:46:24.289
|
D 2022-12-09T15:12:07.680
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@ -494,7 +494,7 @@ F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34ce
|
|||||||
F ext/wasm/GNUmakefile 54c0db93a5493f625c0a993c12aee5d83951440eee03b2aecfc8aeb998182998
|
F ext/wasm/GNUmakefile 54c0db93a5493f625c0a993c12aee5d83951440eee03b2aecfc8aeb998182998
|
||||||
F ext/wasm/README-dist.txt 2d670b426fc7c613b90a7d2f2b05b433088fe65181abead970980f0a4a75ea20
|
F ext/wasm/README-dist.txt 2d670b426fc7c613b90a7d2f2b05b433088fe65181abead970980f0a4a75ea20
|
||||||
F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9
|
F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9
|
||||||
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api c1a7e0054762cc88a02ab27b0a64b5682bf9c35bfe67ac0a9c6a4c641acb6a09
|
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api b9c8ddcfd899c627c136a125403977d6f33478075c5d843cfb56bc4cdd860890
|
||||||
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
|
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
|
||||||
F ext/wasm/api/README.md 17fb1e10335cc87e366dec496c5b17b061f3f75cdf216e825258de34d97a3e53
|
F ext/wasm/api/README.md 17fb1e10335cc87e366dec496c5b17b061f3f75cdf216e825258de34d97a3e53
|
||||||
F ext/wasm/api/extern-post-js.c-pp.js 8923f76c3d2213159e12d641dc750523ead5c848185dc4996fae5cc12397f88d
|
F ext/wasm/api/extern-post-js.c-pp.js 8923f76c3d2213159e12d641dc750523ead5c848185dc4996fae5cc12397f88d
|
||||||
@ -505,7 +505,7 @@ F ext/wasm/api/pre-js.c-pp.js b88499dc303c21fc3f55f2c364a0f814f587b60a9578430388
|
|||||||
F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
|
F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
|
||||||
F ext/wasm/api/sqlite3-api-glue.js ca68c522c31ff0e4fd6e97920f5426f6f8d9dce4bbeb847fe307d73a3b3bd0ae
|
F ext/wasm/api/sqlite3-api-glue.js ca68c522c31ff0e4fd6e97920f5426f6f8d9dce4bbeb847fe307d73a3b3bd0ae
|
||||||
F ext/wasm/api/sqlite3-api-oo1.js 6d10849609231ccd46fa11b1d3fbbe0f45d9fe84c66a0b054601036540844300
|
F ext/wasm/api/sqlite3-api-oo1.js 6d10849609231ccd46fa11b1d3fbbe0f45d9fe84c66a0b054601036540844300
|
||||||
F ext/wasm/api/sqlite3-api-prologue.js 652c9282b8a8cb4b7a72fcb1c149d83228eb31385c5e6cc138b5e88bce345490
|
F ext/wasm/api/sqlite3-api-prologue.js e2ad8c67edd2e0c53b97ab0cab0a926b0fdfb6c62f35a4e210754668010c5afa
|
||||||
F ext/wasm/api/sqlite3-api-worker1.js e94ba98e44afccfa482874cd9acb325883ade50ed1f9f9526beb9de1711f182f
|
F ext/wasm/api/sqlite3-api-worker1.js e94ba98e44afccfa482874cd9acb325883ade50ed1f9f9526beb9de1711f182f
|
||||||
F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
|
F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
|
||||||
F ext/wasm/api/sqlite3-opfs-async-proxy.js 7795b84b66a7a8dedc791340709b310bb497c3c72a80bef364fa2a58e2ddae3f
|
F ext/wasm/api/sqlite3-opfs-async-proxy.js 7795b84b66a7a8dedc791340709b310bb497c3c72a80bef364fa2a58e2ddae3f
|
||||||
@ -2067,8 +2067,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P c6e7582aea4ebcc4563afb4367fded1e8a74f6ef522a569460023c340ca24b30
|
P f6dbf280f99809a80c99337e4c22a86dea7a35ae41ae9a69144c4502385a0a1f
|
||||||
R 16765b1fd408728eaf5cae322d97e3fc
|
R 7bcaeae1c4ed355a7ee863306eabe9f0
|
||||||
U stephan
|
U stephan
|
||||||
Z 6fd28515eec5c302b8cea52b2f42f90b
|
Z b0f1b2204d1844f35010db0bac1847d3
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
f6dbf280f99809a80c99337e4c22a86dea7a35ae41ae9a69144c4502385a0a1f
|
de8fc4bf34f80f320012a0e506ed8e3e24806daf67845d5dabb00b916108f6ef
|
Reference in New Issue
Block a user