Add JS bindings and tests for sqlite3_interrupted(), is_interrupted(), and db_readonly().

FossilOrigin-Name: 5589ba5651d80479ae555429340fc74390ff07d3e05ba770bb7d82490211e00d
This commit is contained in:
stephan 2024-07-13 12:50:42 +00:00
parent c636e124df
commit 6f9b37b35b
5 changed files with 34 additions and 14 deletions

View File

@ -46,6 +46,7 @@ _sqlite3_data_count
_sqlite3_db_filename
_sqlite3_db_handle
_sqlite3_db_name
_sqlite3_db_readonly
_sqlite3_db_status
_sqlite3_declare_vtab
_sqlite3_deserialize
@ -64,6 +65,8 @@ _sqlite3_free
_sqlite3_get_auxdata
_sqlite3_get_autocommit
_sqlite3_initialize
_sqlite3_interrupt
_sqlite3_is_interrupted
_sqlite3_keyword_count
_sqlite3_keyword_name
_sqlite3_keyword_check

View File

@ -152,6 +152,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
["sqlite3_db_filename", "string", "sqlite3*", "string"],
["sqlite3_db_handle", "sqlite3*", "sqlite3_stmt*"],
["sqlite3_db_name", "string", "sqlite3*", "int"],
["sqlite3_db_readonly", "int", "sqlite3*", "string"],
["sqlite3_db_status", "int", "sqlite3*", "int", "*", "*", "int"],
["sqlite3_errcode", "int", "sqlite3*"],
["sqlite3_errmsg", "string", "sqlite3*"],
@ -192,10 +193,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
["sqlite3_get_autocommit", "int", "sqlite3*"],
["sqlite3_get_auxdata", "*", "sqlite3_context*", "int"],
["sqlite3_initialize", undefined],
/*["sqlite3_interrupt", undefined, "sqlite3*"
^^^ we cannot actually currently support this because JS is
single-threaded and we don't have a portable way to access a DB
from 2 SharedWorkers concurrently. ],*/
["sqlite3_interrupt", undefined, "sqlite3*"],
["sqlite3_is_interrupted", "int", "sqlite3*"],
["sqlite3_keyword_count", "int"],
["sqlite3_keyword_name", "int", ["int", "**", "*"]],
["sqlite3_keyword_check", "int", ["string", "int"]],

View File

@ -461,7 +461,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
try{ sqlite3.SQLite3Error.toss("resultCode check") }
catch(e){
T.assert(capi.SQLITE_ERROR === e.resultCode)
.assert('resultCode check' === e.message);
.assert('resultCode check' === e.message);
}
})
////////////////////////////////////////////////////////////////////
@ -2063,6 +2063,24 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
"Because foo is no longer attached.");
})
////////////////////////////////////////////////////////////////////
.t("Interrupt", function(sqlite3){
const db = new sqlite3.oo1.DB();
T.assert( 0===capi.sqlite3_is_interrupted(db) );
capi.sqlite3_interrupt(db);
T.assert( 0!==capi.sqlite3_is_interrupted(db) );
db.close();
})
////////////////////////////////////////////////////////////////////
.t("Read-only", function(sqlite3){
T.assert( 0===capi.sqlite3_db_readonly(this.db, "main") );
const db = new sqlite3.oo1.DB('file://'+this.db.filename+'?mode=ro');
T.assert( 1===capi.sqlite3_db_readonly(db, "main") );
T.assert( -1===capi.sqlite3_db_readonly(db, "nope") );
db.close();
})
////////////////////////////////////////////////////////////////////
.t({
name: 'C-side WASM tests',

View File

@ -1,5 +1,5 @@
C Remove\sa\sstray/harmless\sduplicate\swasm\sfunction\sexport\sentry.
D 2024-07-13T11:47:44.216
C Add\sJS\sbindings\sand\stests\sfor\ssqlite3_interrupted(),\sis_interrupted(),\sand\sdb_readonly().
D 2024-07-13T12:50:42.416
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -601,7 +601,7 @@ F ext/wasm/SQLTester/SQLTester.mjs ce765c0ad7d57f93553d12ef4dca574deb00300134a26
F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638
F ext/wasm/SQLTester/index.html 3f8a016df0776be76605abf20e815ecaafbe055abac0e1fe5ea080e7846b760d
F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 00a1ce656f31b0d168ace7e50faa9d9366793848318077b379c74e91f06b9041
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 79c97e7d1eae1c5c4ac785a41a59f212299ec1465235e62351bed85f14f7de40
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
@ -611,7 +611,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08
F ext/wasm/api/post-js-header.js 04dc12c3edd666b64a1b4ef3b6690c88dcc653f26451fd4734472d8e29c1c122
F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219
F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e
F ext/wasm/api/sqlite3-api-glue.c-pp.js 114085f4dceb28e06d20d3fb597b2501a4aa69f4b6cd29234f7cc1cf81d5b92d
F ext/wasm/api/sqlite3-api-glue.c-pp.js 76797cabedaed1b18ef8f613b7bd33a67d42ca10584a7173beff1fec311c808d
F ext/wasm/api/sqlite3-api-oo1.c-pp.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818c925570df5a945565e
F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63
F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d
@ -667,7 +667,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 74ade5f0d61db790b4e403f6bf7c0d346e19ec876cdee109c22ae4214aa89f4e
F ext/wasm/tester1.c-pp.js 8c5f84262c6a1b5444cbd572557502042c771ec8ccefc265382f488866896872
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
@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 397d6a18f173a46b60a867fc45611045c76316d6602a3df8b4dc4ba45e1348ce
R 8d1b4d875aa4428b36547df3364516ee
P 5402e4fb1cbd7a2c3dee6ebfb492a076d05daa66f747d18602338874405829df
R 755e2e812676ba0fd928fedbc3fc5e9e
U stephan
Z 977e101f8c18c7f8d4990fad09aea47e
Z 8d9b29289853fb56a82fa2045fc5a771
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
5402e4fb1cbd7a2c3dee6ebfb492a076d05daa66f747d18602338874405829df
5589ba5651d80479ae555429340fc74390ff07d3e05ba770bb7d82490211e00d