Commit Graph

48 Commits

Author SHA1 Message Date
stephan
e9f740e484 Expose a JS-friendly subset of sqlite3_config() to JS, with the notable caveats that (1) setting up the JS bindings requires starting the library, making sqlite3_config() illegal to call and (2) calling sqlite3_shutdown() in order to make it legal to call sqlite3_config() may undo certain JS-side library initialization. Move sqlite3_(de)serialize() into the int64-mode-only bindings because of their int64 args.
FossilOrigin-Name: 62e0c931ac952219f68e22d64e20836781bf330b4581e4662266172a97c9289b
2022-12-16 13:04:21 +00:00
stephan
7c1c5b6232 Add a test confirming that exceptions are not passed through C-space if a JS-side sqlite3_set_authorizer() callback throws.
FossilOrigin-Name: 5a77c2c7aaa556007274e1b85790934665c2c12661ca11d896eb7d09cd49ce72
2022-12-16 11:33:42 +00:00
stephan
d83ab0cf85 Add sqlite3_set_authorizer() support and related tests to JS.
FossilOrigin-Name: 551b848894c249cb3c9d237643d2ed53ffcb3b003d0cf3f797a535df1731ce39
2022-12-16 11:13:32 +00:00
stephan
1a1d8bbdc3 Rename the new peek/pokeF32() and peek/pokeF64() to peek/poke32f() and peek/poke64f() for consistency with related APIs and because they're easier on both the eyes and the fingers.
FossilOrigin-Name: cc86f03ed698a071cd02ef3dfaba69092226bff20c917d662f808061627ad285
2022-12-14 18:06:01 +00:00
stephan
e5e61d40e9 Slight reformulation of some test code to test multi-arg wasm.peek() call form.
FossilOrigin-Name: 349bb28f614bc210b3283ed1c1144c45fbc7d9e2ffc3dc6193ccb9932d347efb
2022-12-14 16:40:17 +00:00
stephan
8a5c032b07 Use the new peek/poke() variants throughout tester1.js.
FossilOrigin-Name: ef7b783552f7783a728837fcfc81e493b135a7aac59747397e7e3d28f4309f95
2022-12-14 14:40:36 +00:00
stephan
feb9123a8c Add convenience variants of sqlite3.wasm.peek/poke() for each numeric type to help reduce errors related to typos in the final argument (type-name strings). If wasm.xWrap.FuncPtrAdapter is called as a function, instead of a constructor, it now behaves as if it were called as a constructor (previously it threw an exception).
FossilOrigin-Name: 14e3fc01b929fa3f9a2fdbd93deb4a8aad58c111d46369c772def0437152fa75
2022-12-14 14:28:54 +00:00
stephan
bca56f384f Add a test to demonstrate/verify which object acts as "this" in a oo1.DB.exec() callback.
FossilOrigin-Name: 8fc4b3f10f61e965853a22bf7a64ad2511ef656d66658a7910bac35b0f9805ec
2022-12-14 08:12:01 +00:00
stephan
30f50a2d34 Extend the sqlite3.wasm function pointer argument converter to be able to handle the "two-layered context" of sqlite3_create_collation() and friends and make use of FuncPtrAdapter to perform JS-to-WASM function conversion for them.
FossilOrigin-Name: 0a60b7215e433f8c50027c70731b11e58d74c90ec5903e66ae42f9c98e40b044
2022-12-13 08:25:28 +00:00
stephan
33ce0b3ff3 Revert part of [9386d6f63468] because the new automatic function pointer binding cannot properly track per-context function mappings when the context is more complex than a single context-type pointer. e.g. it is fine for sqlite3_trace_v2() but it breaks down with sqlite3_create_collation() because that one needs to use the collation name as part of the context key and we cannot sensibly do so with the current code.
FossilOrigin-Name: 6cd21b79075367227b57bccf829cc7d4ccc7d7fbcfaed226b4c8e942ddae4eb6
2022-12-12 18:42:39 +00:00
stephan
124fc52d96 Move JS-to-C binding signatures from sqlite3-api-prologue.js to sqlite3-api-glue.js to allow for use of the new/experimental sqlite3.wasm.xWrap() feature which automatically binds JS functions to WASM/C as needed, which simplifies creation of bindings which take C function pointers. Reimplement sqlite3_exec(), sqlite3_create_collation(), sqlite3_progress_handler() to use this new feature.
FossilOrigin-Name: 9386d6f634680b4e0fa5487c34c63acb29f0b7a6ae738b8f6164ad084a229b62
2022-12-12 14:31:38 +00:00
stephan
130cd85026 Correct wasm heap corruption introduced in test code added in [e144fd5c88fa4] which led to unpredictable failures.
FossilOrigin-Name: 6c1e07e3857b38e394853891a9028e88319bad4bc7b7b15078e25f430c3b1222
2022-12-10 17:20:29 +00:00
stephan
8c0041f5bf Remove two incorrect calls to structType.dipose() which prematurely freed objects in use by the virtual table test/demo code.
FossilOrigin-Name: 060eb2848975a24ff6683a8a9c4d7546ae36147323b0edae01fb42f52d9bb2d6
2022-12-10 15:41:47 +00:00
stephan
3ec44736b5 Remove some unused sqlite3_status() codes from the JS API. Add custom JS wrappers for sqlite3_create_collation/_v2() which accept JS functions (plus tests). Expand the argument options for sqlite3_wasm_db_error() to enable it to translate exception objects to C-level errors.
FossilOrigin-Name: 073a2f1eb006230ae0995a5ea6c789407bcaa819ec15b5064c66d8973ed4671a
2022-12-09 12:12:49 +00:00
stephan
81a3683174 Rename the oft-used, verbose sqlite3.wasm.get/setMemValue() and get/setPtrValue() to peek/poke() and peek/pokePtr(). The old names are retained as aliases just in case any client code actually uses them, but they are now deprecated.
FossilOrigin-Name: ad0a8139b0b025f8e9d2eca0c303557ef10fdfab8c8b65afb08c510a804073d5
2022-12-09 09:23:27 +00:00
stephan
a3451dd990 Correct a test bug which broke the previous checkin's wasm tests in higher optimization levels. Test bug - it should not have worked in -O0 mode.
FossilOrigin-Name: f07141b7500c36169c2c96e045acf37ec97a0d75c0a5f4d0ebed4dc1d2094ccf
2022-12-09 07:17:54 +00:00
stephan
464c80d4c2 Export sqlite3_status() and sqlite3_stmt_status() to wasm. Expand the arg/return semantics of wasm.get/setPtrValue() and get/setMemValue() to simplify handling of multiple pointers.
FossilOrigin-Name: e144fd5c88fa4151429a2fef3daf389588402e158267f0afa0dfd142527d76b9
2022-12-09 05:47:42 +00:00
stephan
735dd03377 Expose sqlite3_table_column_metadata() to wasm.
FossilOrigin-Name: c31eb509e5cb1025de058132ee9a45d70c84ee47a6abe18811a65ce339f062a0
2022-12-09 02:12:43 +00:00
stephan
6ca03e14e9 Expose sqlite3_db_status() and sqlite3_db_config() to wasm, noting that the latter requires several internal wrappers to account for the various varidic forms (C varargs cannot be bound to wasm).
FossilOrigin-Name: d5753668915c1db204fa80153614653243081ffaddea22f26ad59bb1836948b9
2022-12-09 01:49:17 +00:00
stephan
d27c3e4e7e Reorganization and renaming in the new VFS/vtab JS pieces.
FossilOrigin-Name: 1c2dda177a11fcc5b66e5554507c23ba4b9948a710b3bccfb26963b9851d40a4
2022-12-09 00:50:39 +00:00
stephan
500fa7d518 Ease-of-use/legibility improvements in the virtual table JS helpers.
FossilOrigin-Name: 54c7ad7e08bdb87579398ade366605bfa2e2538a94aabcc6e4cda8e173649760
2022-12-08 17:07:27 +00:00
stephan
16bf97b507 More work on the JS vtable tests.
FossilOrigin-Name: 51e3c3b569dce2097063d39dc484f44b2f98cad0a902ef66765ca4cdc3e06f47
2022-12-08 10:06:07 +00:00
stephan
d061f14466 Got JS non-eponymous vtable working thanks to a hint from Dan.
FossilOrigin-Name: 750719b4981df62fa2ff3665e6f559ec760609ad2493495628295ad9ae6024fc
2022-12-08 09:06:20 +00:00
stephan
ab8b22a03d Remove some dead JS code and tweak some docs.
FossilOrigin-Name: 0ee495452c014680697aa9035c245024df127a52d1820ab0e02580a015d96ecb
2022-12-08 04:19:38 +00:00
stephan
1eb1b59b89 Work on an alternate (slightly simpler) approach to binding JS vtabs. Non-eponymous vtabs are not working, for reasons as yet unknown.
FossilOrigin-Name: 6a0fefb93bcccd950df211cf5c2f49660c7b92115dd01b2b508a4ab9e3ab3d23
2022-12-07 07:22:34 +00:00
stephan
30da58c5d6 Add addOnDispose() method to Jaccwabyt and code-adjacent minor internal cleanups.
FossilOrigin-Name: 6a2723fe3f28dd94328d901e64e1e9ee9a1b2e9eeaed6c54038a5b83c914db78
2022-12-07 03:42:39 +00:00
stephan
241cde98b8 JS vtables: add infrastructure related to accessing and modifying sqlite3_index_info.
FossilOrigin-Name: 0d77c348039926c24e0fb50a7dc7e4b62895cd201c021f8e29832917e4b8b09f
2022-12-06 11:21:46 +00:00
stephan
75435f8b2d Rename wasm.cstringToJs() to wasm.cstrToJs() for consistency with other wasm.cstr... APIs.
FossilOrigin-Name: cbf483ea0ba3e6dc08ad7ed654380f818544b4c3cedfdb8aa848a83298268ceb
2022-12-06 08:46:39 +00:00
stephan
671386c637 Add wasm.cArgvToJs() to support sqlite3_module::xConnect().
FossilOrigin-Name: c3ebdccf94d5e63c229bf91056c08052d78732e663334070ef3b0ef6fb4bfb8f
2022-12-06 08:39:17 +00:00
stephan
2a665edbd4 Minor test tweaks.
FossilOrigin-Name: f902f3b2c79d6c699ead1efeb1426e1e0f4ac709afdff88be1de62f34f3d5ccc
2022-12-06 06:16:11 +00:00
stephan
6b271abc98 Add a demonstration sqlite3_vtab/module implemented in JS, based on ext/misc/templatevtab.c. Add oo1.selectArrays() and selectObjects().
FossilOrigin-Name: 60482c97e02bc4cafefef281be0cf0bc8c5c53232162829c137f3f7a80cdc534
2022-12-06 06:09:03 +00:00
stephan
2582d418d3 Remove two features of jaccwabyt which were fundamentally flawed, along with approx. 250 lines of unit tests which heavily relied on them. Thankfully, none of the sqlite3.js-level code used those bits.
FossilOrigin-Name: a190abc307847174f36421eaa3f47ef349c6f84a2bb35857fa64f64bbe722708
2022-12-05 15:05:46 +00:00
stephan
9a49a97487 Export sqlite3_vtab_collation() to wasm. Rename 'flexible-string' JS argument adapter to 'string:flexible' for consistency.
FossilOrigin-Name: 15f8042fddaeabab43dd187c463d3ccc56758cbf19bf2ca4837d9087a4850c1a
2022-12-05 13:12:48 +00:00
stephan
cf8f0d2046 Rename 'static-string' argument adapter to 'string:static'. Replace JS unit tests which were lost via editing a generated copy of tester1.js instead of the original tester1.c-pp.js input file.
FossilOrigin-Name: 9d81d51d5a255b42f8416da850c992a9e4c8eebc940e0702a9262cfcaa6d7b2f
2022-12-05 11:54:13 +00:00
stephan
9baafdabf7 Correct a memory leak in tester1.js.
FossilOrigin-Name: e42b052dd754e577b8429e2430821c5f88096170ffa58b4e5e3cb7ee19b6c37d
2022-12-03 15:41:29 +00:00
stephan
cbcc08ddc4 sqlite3.wasm.allocFromTypedArray() now optionally accepts an ArrayBuffer as its argument.
FossilOrigin-Name: 75a1a796f86d289c7275666fab19013934775dcccaed44a1a61d1749a6cb99c9
2022-12-03 14:58:45 +00:00
stephan
09c27a59db Rename wasm.xWrap.resultAdapter() X:free entries to X:dealloc for consistency with wasm.dealloc(). Add an undocumented feature to replace wasm.alloc/dealloc/realloc() with the C-standard allocators (after an allocator misuse led down a several-hour rabbit hole trying to discover a mis-free() violation). Related test updates.
FossilOrigin-Name: d9807656f8a7c2a893d3f68ee5592f44826b8e999ae66f7d9000674b5c1b0207
2022-12-03 13:10:58 +00:00
stephan
85ef4e4344 JavaScript: add sqlite3.wasm.realloc(), sqlite3.capi.SQLITE_MAX_ALLOCATION_SIZE, and related tests.
FossilOrigin-Name: eeb84ba5de1152ef0f42105b8b285fdee9f5ad58281e60a4e0c8b1d6de1dead8
2022-12-03 11:16:55 +00:00
stephan
cc70dfe679 Expand JS tests for db export/import and document reason it cannot currently work with kvvfs. Fix a minor JS build dependencies bug. Update page title with PASS/FAIL prefix for tester1.js to improve overview when launching multiple test tabs. Add ability of tester1 should-run-test predicates to report why a given test is disabled.
FossilOrigin-Name: 75f610d3a4cf3d972220f9abc27cdf5990451e3835ceb9cf66973934004dfc5c
2022-12-02 07:14:56 +00:00
stephan
919dbc846a sqlite3_js_create_file() now accepts an ArrayBuffer data source. Add test for OPFS-based export/re-import. The (sqlite3*) argument converter now optionally accepts sqlite3.oo1.DB instances.
FossilOrigin-Name: 14a84b67fb17e16a5691ea4bf7f374123ac73a361a5d3d0efca53788d2001e3a
2022-12-01 15:22:03 +00:00
stephan
9ec1a7a7a0 Reformulate and simplify some JS tests related to the previous checkin.
FossilOrigin-Name: 9ea2d3dcf798393a7fd231e199c0e2c6302949fe2a7f2573178fb0e50c78a2f4
2022-12-01 04:45:51 +00:00
stephan
2b2199570d Expand "sqlite3_vfs*" JS-to-WASM function argument conversions to accept VFS names (JS strings) and capi.sqlite3_vfs instances. Implement sqlite3_js_vfs_create_file() to facilitate creation of file-upload features which store the file in VFS-specific storage (where possible, e.g. "unix" and "opfs" VFSes). Correct an argument type check in the SQLite3Error and WasmAllocError constructors.
FossilOrigin-Name: e1009b16d351b23676ad7bffab0c91b373a92132eb855c9af61991b50cd237ed
2022-12-01 03:55:28 +00:00
stephan
8ae9545577 Install sqlite3_malloc/sqlite3_free() as the JS-side WASM allocator (as opposed to replacing C-level's malloc()/free() with them). All tests work and this eliminates the potential for allocator discrepancies when using the (de)serialize APIs.
FossilOrigin-Name: 95c78f6b46e0d8efa4313061f47677479f48610b7a7261dc8d0fb1859aca2ad9
2022-11-30 11:50:16 +00:00
stephan
ad4f782815 Refactor a significant chunk of the OPFS sqlite3_vfs init code into sqlite3.VfsHelper, and internal-use-only API encapsulating code relevant to creating new VFSes in JS. Intended to assist in pending experimentation with an alternative OPFS VFS.
FossilOrigin-Name: e25d7b080a807e35b32cb885ea75b384130e5c6e936dfef783c5b45d9bfe77d8
2022-11-30 05:27:36 +00:00
stephan
04184761de Internal restructuring of the OPFS sqlite3_vfs in order to facilitate certain experimentation and improve error reporting/hints if it cannot be activated. Deprecate the name sqlite3.opfs.OpfsDb, preferring sqlite3.oo1.OpfsDb for consistency with JsStorageDb and any future DB subclasses.
FossilOrigin-Name: 0c5c51f4fb04a4b90c50ec9704cfea9a3fb7d7d0ee55c1b0d4476129188217a6
2022-11-29 05:25:08 +00:00
stephan
f46091d73f Add sqlite3.oo1.DB.prototype.checkRc() and tests for both that method and its class-level counterpart.
FossilOrigin-Name: f7eaa6ba2147bfd6dbdc2444d0f919d846aa7f9b68cccab17ef585ffdacf3d60
2022-11-24 02:35:03 +00:00
stephan
0a94ef8b52 Minor cleanups in the ESM-related preprocessor filtering.
FossilOrigin-Name: 205884a273128bb666b496b659b4fa9f031ebdbbc1aa704fdeb4b7e015740098
2022-11-20 01:15:22 +00:00
stephan
8d0d409876 Get tester1.js working via an ES6 worker module and add that variant to the dist zipfile.
FossilOrigin-Name: 90480586f1b2ad82118e19536b095431b8457f294c0afaa9b4f883f184cc804c
2022-11-19 16:16:40 +00:00