WebAssembly Text Format (WAT) is the human-readable representation of WebAssembly modules. It makes Wasm instructions easier to inspect, edit, debug, and define directly in libSQL. section 5.3.3 section 5.5
A WAT module can express:
- Functions with typed parameters and results, such as a function accepting two i64 values and returning an i64. section 5.3.3
- Instructions such as local.get and i64.add, which retrieve parameters and add their values. section 5.3.3
- Exports that expose functions and memory to the embedding environment; memory may be required even when unused by a simple function. section 5.3.3
Define and test a libSQL function
Create a Wasm function named my_add with two i64 parameters, return their sum, and export both the function and memory. Register it with CREATE FUNCTION my_add LANGUAGE wasm, then run SELECT my_add(1, 41); to obtain 42. section 5.3.3
docker run --rm -v ./data:/data -it ghcr.io/danbugs/
➥serverside-wasm-book-code/libsql-wasmudf:latest
Use the libSQL environment to load SQL definitions and test Wasm-backed functions interactively. section 5.3.3
