1 Commits

Author SHA1 Message Date
126aae1ace fix: xDel special semmantics patch
Sqlite has a number of special custom memory deallocators, namely SQLITE_STATIC and SQLITE_TRANSIENT. Sqlite calls noop freeing memory with the special deallocators.
    Sqlite virtual tables, e.g. FTS5 implicitly creates aux tables. There are number of SQLITE_STATIC allocated empty lines or 0 size blobs that were previously freed with free. This free op spoils sqlite virtual table state  and renders VT unusable [fixes VM-239]
2023-02-17 11:30:30 +00:00
20 changed files with 411 additions and 809 deletions

View File

@ -1,3 +0,0 @@
self-hosted-runner:
labels:
- builder

View File

@ -1,5 +0,0 @@
version: 0
type: compiled
name: sqlite3
volumes:
sites: ./tmp

View File

@ -1,12 +0,0 @@
{
"bootstrap-sha": "c1fa069dcbadb1bf4bb076408ad4ddbd77c7ede0",
"release-type": "simple",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"packages": {
".": {
"package-name": "sqlite-wasm",
"component": "sqlite-wasm"
}
}
}

View File

@ -1,3 +0,0 @@
{
".": "0.18.2"
}

View File

@ -1,45 +0,0 @@
name: Build sqlite artifact
on:
workflow_call:
inputs:
ref:
description: "git ref"
type: string
default: master
jobs:
build:
name: "Build sqlite.wasm"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: fluencelabs/sqlite
ref: ${{ inputs.ref }}
- name: Setup wasi-sdk
run: |
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sdk-15.0-linux.tar.gz | tar xz -C ./
mv wasi-sdk-* wasi-sdk
- name: Setup Rust toolchain
uses: dsherret/rust-toolchain-file@v1
- name: Setup marine
uses: fluencelabs/setup-marine@v1
with:
artifact-name: "marine"
- name: Build sqlite-wasm
run: make
- name: Upload sqlite-wasm
uses: actions/upload-artifact@v3
with:
name: sqlite-wasm
path: sqlite3.wasm
if-no-files-found: error

View File

@ -1,131 +0,0 @@
name: "e2e"
on:
pull_request:
paths-ignore:
- "**.md"
- ".github/**"
- "!.github/workflows/e2e.yml"
- "!.github/workflows/snapshot.yml"
- "!.github/workflows/build.yml"
types:
- "labeled"
- "synchronize"
- "opened"
- "reopened"
push:
branches:
- "master"
paths-ignore:
- "**.md"
- ".github/**"
- "!.github/workflows/e2e.yml"
- "!.github/workflows/snapshot.yml"
- "!.github/workflows/build.yml"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
build:
name: "sqlite"
if: >
github.event_name == 'push' ||
contains(github.event.pull_request.labels.*.name, 'e2e')
uses: ./.github/workflows/build.yml
with:
ref: ${{ github.ref }}
snapshot:
needs: build
name: "sqlite-wasm"
uses: fluencelabs/sqlite-wasm-connector/.github/workflows/snapshot.yml@master
spell:
needs:
- snapshot
uses: fluencelabs/spell/.github/workflows/snapshot.yml@main
with:
cargo-dependencies: |
[
{
"package": "marine-sqlite-connector",
"version": "=${{ needs.snapshot.outputs.version }}",
"registry": "fluence"
}
]
decider:
needs:
- spell
uses: fluencelabs/decider/.github/workflows/snapshot.yml@main
with:
cargo-dependencies: |
[
{
"package": "fluence-spell-dtos",
"version": "=${{ needs.spell.outputs.cargo-version }}",
"registry": "fluence"
}
]
nox:
needs:
- spell
- decider
uses: fluencelabs/nox/.github/workflows/build.yml@master
with:
cargo-dependencies: |
[
{
"package": "fluence-spell-dtos",
"version": "=${{ needs.spell.outputs.cargo-version }}",
"registry": "fluence"
},
{
"package": "fluence-spell-distro",
"version": "=${{ needs.spell.outputs.cargo-version }}",
"registry": "fluence"
},
{
"package": "decider-distro",
"version": "=${{ needs.decider.outputs.cargo-version }}",
"manifest": "crates/system-services/Cargo.toml",
"registry": "fluence"
}
]
nox-snapshot:
name: "nox"
needs:
- nox
uses: fluencelabs/nox/.github/workflows/container.yml@master
with:
image-name: "docker.fluence.dev/sqlite"
spell-aqua-tests:
name: "spell"
needs:
- nox-snapshot
uses: fluencelabs/spell/.github/workflows/tests.yml@main
with:
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
registry:
needs:
- snapshot
- nox-snapshot
uses: fluencelabs/registry/.github/workflows/tests.yml@main
with:
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
cargo-dependencies: |
[
{
"package": "marine-sqlite-connector",
"version": "=${{ needs.snapshot.outputs.version }}",
"registry": "fluence"
}
]

View File

@ -1,35 +0,0 @@
name: lint
on:
pull_request:
types:
- opened
- edited
- synchronize
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
pr:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
reviewdog:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Lint actions
uses: reviewdog/action-actionlint@v1
env:
SHELLCHECK_OPTS: "-e SC2086 -e SC2207 -e SC2128 -e SC2035"
with:
reporter: github-pr-check
fail_on_error: true

View File

@ -1,77 +0,0 @@
name: "release"
on:
push:
branches:
- "master"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release-created: ${{ steps.release.outputs['release_created'] }}
tag-name: ${{ steps.release.outputs['tag_name'] }}
version: ${{ steps.release.outputs['version'] }}
pr: ${{ steps.release.outputs['pr'] }}
steps:
- name: Run release-please
id: release
uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }}
command: manifest
config-file: .github/release-please/config.json
manifest-file: .github/release-please/manifest.json
- name: Show output from release-please
if: steps.release.outputs.releases_created
env:
RELEASE_PLEASE_OUTPUT: ${{ toJSON(steps.release.outputs) }}
run: echo "${RELEASE_PLEASE_OUTPUT}" | jq
build:
if: needs.release-please.outputs.release-created
needs: release-please
uses: ./.github/workflows/build.yml
with:
ref: ${{ github.ref }}
publish:
runs-on: ubuntu-latest
needs:
- release-please
- build
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download sqlite-wasm
uses: actions/download-artifact@v3
with:
name: sqlite-wasm
path: artifacts/
- name: Create archive
run: tar caf artifacts/sqlite3.tar.gz -C ./artifacts/ sqlite3.wasm -C ../.github/misc/ module.yaml
- name: Generate checksums
id: sum
run: |
sha256sum * | tee > sqlite3_SHA256_SUMS
working-directory: artifacts
- name: Upload binaries
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/*
tag_name: ${{ needs.release-please.outputs.tag-name }}

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
wasi-sdk*
# IntelliJ
.idea

View File

@ -1,15 +0,0 @@
# Changelog
## [0.18.2](https://github.com/fluencelabs/sqlite/compare/sqlite-wasm-v0.18.1...sqlite-wasm-v0.18.2) (2023-12-25)
### Bug Fixes
* fix use-after-free when using sqlite_bind_text/sqlite_bind_blob with sqlite_step ([#24](https://github.com/fluencelabs/sqlite/issues/24)) ([13a62f2](https://github.com/fluencelabs/sqlite/commit/13a62f2b1017e2e5e860951bf01516c0aea739a0))
## [0.18.1](https://github.com/fluencelabs/sqlite/compare/sqlite-wasm-v0.18.0...sqlite-wasm-v0.18.1) (2023-04-06)
### Bug Fixes
* bind_text and bind_blob string arguments clean up ([#18](https://github.com/fluencelabs/sqlite/issues/18)) ([258b8d1](https://github.com/fluencelabs/sqlite/commit/258b8d11b6beadf625dbeb69bd98da1b2b40176c))

View File

@ -7,10 +7,12 @@ RUN apt update \
git \
make \
pkg-config \
libtinfo6
libtinfo6 \
cargo
RUN mkdir -p ~/.local/bin && curl -L https://github.com/fluencelabs/marine/releases/download/marine-v0.14.1/marine-linux-x86_64 -o ~/.local/bin/marine && chmod +x ~/.local/bin/marine
RUN cargo install marine --version 0.12.7
RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sdk-15.0-linux.tar.gz | tar xz -C /
VOLUME /code
WORKDIR /code
ENTRYPOINT /code/entrypoint.sh
CMD make

View File

@ -1,6 +1,6 @@
TARGET = sqlite3
CC = ./wasi-sdk/bin/clang
SYSROOT = ./wasi-sdk/share/wasi-sysroot
CC = /wasi-sdk-15.0/bin/clang
SYSROOT = /wasi-sdk-15.0/share/wasi-sysroot
TARGET_TRIPLE = wasm32-wasi
CFLAGS = -fvisibility=hidden
SDK = sdk/logger.h
@ -26,18 +26,16 @@ EXPORT_FUNCS = \
--export=sqlite3_column_name_,$\
--export=sqlite3_step,$\
--export=sqlite3_reset,$\
--export=sqlite3_bind_blob_,$\
--export=sqlite3_bind_blob,$\
--export=sqlite3_bind_double,$\
--export=sqlite3_bind_int64,$\
--export=sqlite3_bind_text_,$\
--export=sqlite3_bind_text,$\
--export=sqlite3_bind_null,$\
--export=sqlite3_column_count,$\
--export=sqlite3_column_double,$\
--export=sqlite3_column_int64,$\
--export=sqlite3_column_blob_,$\
--export=sqlite3_column_bytes,$\
--export=sqlite3_soft_heap_limit64,$\
--export=sqlite3_hard_heap_limit64,$\
--export=sqlite3_finalize
SQLITE_SRC = \
src/alter.c\
@ -164,8 +162,8 @@ all: default
$(TARGET): $(SQLITE_SRC) $(WRAPPER_SRC)
$(CC) -O3 --sysroot=$(SYSROOT) --target=$(TARGET_TRIPLE) $(SQLITE_FLAGS) $(CFLAGS) $(LDFLAGS) -Wl,$(EXPORT_FUNCS) $^ -o $@.wasm
marine set version -i ./sqlite3.wasm -v $(shell cat version.txt)
marine set it -i ./sqlite3.wasm -w sqlite3.wit
/root/.cargo/bin/marine set version -i ./sqlite3.wasm -v 0.7.0
/root/.cargo/bin/marine set it -i ./sqlite3.wasm -w sqlite3.wit
.PRECIOUS: $(TARGET)

133
Readme.md
View File

@ -1,106 +1,87 @@
# SQLite
Sqlite fork ported to WebAssembly and adapted for the Fluence network. Could be launched and played on the Fluence [dashboard](http://dash.fluence.network/deploy/sqlite).
## Overview
SQLite fork adapted to work with Fluence the protocol. The current version is based on SQLite version 3.40.1. The artifact is SQLite WASM module:
- that is compiled following [Marine runtime ABI conventions](https://fluence.dev/docs/marine-book/marine-rust-sdk/module-abi)
- to be used with [Marine runtime](https://github.com/fluencelabs/marine)
## How to build
Wasm module can be built with either docker-compose
Based on SQlite version 3.40.1.
# How to build
This app could be built either with docker
```bash
docker-compose up
```
or using this [Makefile](./Makefile) with GNU make. There are prerequisites to be installed following this path, namely [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) and marine crate. Take a look at the Dockerfile for the details.
or by Makefile with [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) installed
```bash
make
```
# How to use
At now, this fork exports five API functions:
```cpp
## How to use
/**
* Executes given SQL request and returns result in as a pointer to the following structure: | result size (4 bytes, le)| result (size bytes) |.
*
* @param sql a pointer to the supplied sql request
* @param length a size of the supplied sql request
* @return a pointer to the struct contains result_size and result
*/
char *invoke(const char *sql, size_t length);
/**
* Allocates a memory region of a given size. Could be used by Wasm execution environments for byte array passing.
*
* @param size a size of allocated memory region
* @return a pointer to the allocated memory region
*/
void *allocate(size_t size);
/**
* Frees a memory region. Could be used by Wasm execution environments for freeing previous memory allocated by `allocate` function.
*
* @param ptr a pointer to the previously allocated memory region
* @param size a size of the previously allocated memory region
*/
void deallocate(void *ptr, size_t size);
The SQLite Wasm module exports a set of SQLite C API functions. The easiest way to try this module is to run it with Marine REPL.
You can find MREPL output for a simple "CREATE-INSERT-SELECT" scenario below. Mind the second argument to sqlite3_open_v2() that is an OR-ed SQLite flag values. The value "6" in this context means `SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE`.
```bash
$cargo install mrepl
...
$mrepl -q Config.toml
1> call sqlite3 sqlite3_open_v2 [":memory:",6,""]
result: {
"db_handle": 198600,
"ret_code": 0
}
elapsed time: 357.556µs
2> call sqlite3 sqlite3_exec [198600, "CREATE TABLE tab1(i bigint);", 0, 0]
result: {
"err_msg": "",
"ret_code": 0
}
elapsed time: 1.736661ms
3> call sqlite3 sqlite3_exec [198600, "INSERT INTO tab1 VALUES (42);", 0, 0]
result: {
"err_msg": "",
"ret_code": 0
}
elapsed time: 330.098µs
4> call sqlite3 sqlite3_prepare_v2 [198600, "SELECT * FROM tab1;"]
result: {
"ret_code": 0,
"stmt_handle": 244584,
"tail": 268147
}
elapsed time: 280.668µs
5> call sqlite3 sqlite3_step [244584]
result: 100
elapsed time: 124.122µs
6> call sqlite3 sqlite3_column_int64 [244584,0]
result: 42
elapsed time: 72.483µs
/**
* Stores one byte by a given address in the module memory.
*
* @param ptr a address where byte should be stored
* @param value a byte to be stored
*/
void store(void *ptr, char value);
/**
* Returns one byte by a given address in the module memory.
*
* @param ptr a address at which the needed byte is located
* @return the byte at the given address
*/
char load(void *ptr);
```
Given char string `sql` as the request, the general scheme to use it is following:
1. `void *ptr = allocate(strlen(sql))` that returns a pointer to the memory region enough for the string
2. `void *res = invoke(ptr, strlen(sql))` to execute the request
3. read a result from the `res` by reading 4 bytes as little-endian `result_size` and the read `result_size` bytes as the final result.
4. `deallocate(res, strlen(sql))` to clean memory.
You can also try the SQLite Wasm module using Rust together with [this Sqlite connector](https://github.com/fluencelabs/sqlite-wasm-connector). [Here](https://github.com/fluencelabs/examples/tree/main/marine-examples/sqlite) you can find a simple SQL REPL utility example built into a Wasm module.
Depends on your Wasm execution environment, `load`/`store` could be used for reading and writing a module memory.
## Support
## More insights
Please, [file an issue](https://github.com/fluencelabs/sqlite/issues) if you find a bug. You can also contact us at [Discord](https://discord.com/invite/5qSnPZKh7u) or [Telegram](https://t.me/fluence_project). We will do our best to resolve the issue ASAP.
At Fluence, we use WebAssembly (Wasm) to run applications in a trustless network of independent nodes. This trustless environment mandates that every piece of the code executed by any network node must be verified by another node to check whether the execution was performed correctly. In order to be verifiable, every computation must be made deterministic, which means that to run WebAssembly code in a trustless network, we need to make its execution deterministic.
There are three primary sources of nondeterminism in WebAssembly: external functions invocation, NaN payloads, and VM resource exhaustion. The first one is the most problematic; currently, we deal with it by simply prohibiting any interactions with the host environment from Wasm programs. This means that submitted WebAssembly code should not contain any external imports.
## Contributing
The main purpose of this fork is to compile to Wasm without any imports. SQlite is famous for it embeddability and allows to configure itself by variety of macros. E.g. multithreading that produces a lot of imports of host functions could be completely disabled by setting SQLITE_THREADSAFE to 0. Also this fork has been patched to use only memory database without any interaction with a hard disk. So, now it is Wasm in-memory database.
Any interested person is welcome to contribute to the project. Please, make sure you read and follow some basic [rules](https://github.com/fluencelabs/rust-peer/blob/master/CONTRIBUTING.md).
More information about ways of porting C/C++ code to Wasm could be found in our [article](https://medium.com/fluence-network/porting-redis-to-webassembly-with-clang-wasi-af99b264ca8) about porting of Redis.
## Future plans
## License
All software code is copyright (c) Fluence Labs, Inc. under the [Apache-2.0](https://github.com/fluencelabs/rust-peer/blob/master/LICENSE) license.
We are working on supporting of subset of WASI syscalls and interface types support for more convinient parameter passing scheme.

View File

@ -5,4 +5,4 @@ services:
context: .
container_name: sqlite3_builder
volumes:
- ./:/code
- .:/code

View File

@ -1,5 +0,0 @@
export PATH="${PATH}:/root/.cargo/bin:/root/.local/bin"
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sdk-15.0-linux.tar.gz | tar xz -C .
rm -rf wasi-sdk
mv -f wasi-sdk-* wasi-sdk
make

View File

@ -1,9 +0,0 @@
[toolchain]
channel = "nightly-2023-08-27"
components = [
"rustfmt",
"clippy",
]
targets = [
"x86_64-unknown-linux-gnu",
]

View File

@ -1,30 +1,30 @@
(@interface it_version "0.24.1")
(@interface it_version "0.20.0")
;; Types
(@interface type (func
(param $size: i32)
(@interface type (func
(param $size: i32)
(result i32))) ;; 0
(@interface type (func )) ;; 1
(@interface type (func
(@interface type (func
(result i32))) ;; 2
(@interface type (func
(@interface type (func
(result i32))) ;; 3
(@interface type (func
(@interface type (func
(param $result_size: i32) )) ;; 4
(@interface type (func
(@interface type (func
(param $result_ptr: i32) )) ;; 5
(@interface type (record $DBOpenDescriptor (
(@interface type (record $DBExecDescriptor (
field $ret_code: s32
field $db_handle: u32
field $err_msg: string
))) ;; 6
(@interface type (record $DBPrepareDescriptor (
field $ret_code: s32
field $stmt_handle: u32
field $tail: u32
))) ;; 7
(@interface type (record $DBExecDescriptor (
(@interface type (record $DBOpenDescriptor (
field $ret_code: s32
field $err_msg: string
field $db_handle: u32
))) ;; 8
(@interface type (record $SecurityTetraplet (
field $peer_pk: string
@ -32,266 +32,279 @@
field $function_name: string
field $json_path: string
))) ;; 9
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $value: s64)
(result s32))) ;; 10
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $value: s64)
(result s32))) ;; 11
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(@interface type (record $CallParameters (
field $init_peer_id: string
field $service_id: string
field $service_creator_peer_id: string
field $host_id: string
field $particle_id: string
field $tetraplets: array (array (record 9))
))) ;; 10
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result string))) ;; 11
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result string))) ;; 12
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result string))) ;; 13
(@interface type (func
(param $db_handle: u32 $sql: string)
(result record 7))) ;; 14
(@interface type (func
(param $db_handle: u32 $sql: string)
(result record 7))) ;; 15
(@interface type (func
(param $db_handle: u32)
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s32))) ;; 13
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s32))) ;; 14
(@interface type (func
(param $db_handle: u32)
(result s32))) ;; 15
(@interface type (func
(param $db_handle: u32)
(result s32))) ;; 16
(@interface type (func
(param $db_handle: u32)
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $value: f64)
(result s32))) ;; 17
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $value: f64)
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $value: f64)
(result s32))) ;; 18
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $value: f64)
(result s32))) ;; 19
(@interface type (func
(param $filename: string $flags: s32 $vfs: string)
(result record 6))) ;; 20
(@interface type (func
(param $filename: string $flags: s32 $vfs: string)
(result record 6))) ;; 21
(@interface type (func
(param $db_handle: u32)
(@interface type (func
(param $filename: string $flags: s32 $vfs: string)
(result record 8))) ;; 19
(@interface type (func
(param $filename: string $flags: s32 $vfs: string)
(result record 8))) ;; 20
(@interface type (func
(param $db_handle: u32)
(result s32))) ;; 21
(@interface type (func
(param $db_handle: u32)
(result s32))) ;; 22
(@interface type (func
(param $db_handle: u32)
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 23
(@interface type (func
(param $stmt_handle: u32)
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 24
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 25
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 26
(@interface type (func
(param $stmt_handle: u32)
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s64))) ;; 25
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s64))) ;; 26
(@interface type (func
(param $db: u32)
(result s32))) ;; 27
(@interface type (func
(param $size: s64)
(result s64))) ;; 28
(@interface type (func
(param $size: s64)
(result s64))) ;; 29
(@interface type (func
(param $db: u32)
(result s32))) ;; 30
(@interface type (func
(param $db: u32)
(@interface type (func
(param $db: u32)
(result s32))) ;; 28
(@interface type (func
(param $stmt_handle: u32 $icol: s32)
(result f64))) ;; 29
(@interface type (func
(param $stmt_handle: u32 $icol: s32)
(result f64))) ;; 30
(@interface type (func
(param $db_handle: u32 $ms: u32)
(result s32))) ;; 31
(@interface type (func
(param $db_handle: u32 $sql: string $callback_id: s32 $callback_arg: s32)
(result record 8))) ;; 32
(@interface type (func
(param $db_handle: u32 $sql: string $callback_id: s32 $callback_arg: s32)
(result record 8))) ;; 33
(@interface type (func
(param $stmt_handle: u32 $icol: s32)
(result f64))) ;; 34
(@interface type (func
(param $stmt_handle: u32 $icol: s32)
(result f64))) ;; 35
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(@interface type (func
(param $db_handle: u32 $ms: u32)
(result s32))) ;; 32
(@interface type (func
(param $db_handle: u32)
(result string))) ;; 33
(@interface type (func
(param $db_handle: u32)
(result string))) ;; 34
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $value: s64)
(result s32))) ;; 35
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $value: s64)
(result s32))) ;; 36
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 37
(@interface type (func
(param $stmt_handle: u32 $pos: s32)
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 38
(@interface type (func
(param $stmt_handle: u32 $pos: s32)
(result s32))) ;; 39
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $blob: array (u8) $xDel: s32)
(result s32))) ;; 40
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $blob: array (u8) $xDel: s32)
(@interface type (func
(param $db_handle: u32 $sql: string)
(result record 7))) ;; 39
(@interface type (func
(param $db_handle: u32 $sql: string)
(result record 7))) ;; 40
(@interface type (func
(param $stmt_handle: u32 $pos: s32)
(result s32))) ;; 41
(@interface type (func
(param $db_handle: u32)
(@interface type (func
(param $stmt_handle: u32 $pos: s32)
(result s32))) ;; 42
(@interface type (func
(param $db_handle: u32)
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 43
(@interface type (func
(param $stmt_handle: u32)
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 44
(@interface type (func
(param $stmt_handle: u32)
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $blob: array (u8) $xDel: s32)
(result s32))) ;; 45
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $text: string $xDel: s32)
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $blob: array (u8) $xDel: s32)
(result s32))) ;; 46
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $text: string $xDel: s32)
(@interface type (func
(param $db_handle: u32)
(result s32))) ;; 47
(@interface type (func
(param $stmt_handle: u32)
(@interface type (func
(param $db_handle: u32)
(result s32))) ;; 48
(@interface type (func
(param $stmt_handle: u32)
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $text: string $xDel: s32)
(result s32))) ;; 49
(@interface type (func
(param $size: s64)
(result s64))) ;; 50
(@interface type (func
(param $size: s64)
(result s64))) ;; 51
(@interface type (func
(@interface type (func
(param $stmt_handle: u32 $pos: s32 $text: string $xDel: s32)
(result s32))) ;; 50
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 51
(@interface type (func
(param $stmt_handle: u32)
(result s32))) ;; 52
(@interface type (func
(result s32))) ;; 53
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s64))) ;; 54
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s64))) ;; 55
(@interface type (func
(param $db_handle: u32 $ms: u32)
(@interface type (func
(param $db_handle: u32 $sql: string $callback_id: s32 $callback_arg: s32)
(result record 6))) ;; 53
(@interface type (func
(param $db_handle: u32 $sql: string $callback_id: s32 $callback_arg: s32)
(result record 6))) ;; 54
(@interface type (func
(result s32))) ;; 55
(@interface type (func
(result s32))) ;; 56
(@interface type (func
(param $db_handle: u32 $ms: u32)
(result s32))) ;; 57
(@interface type (func
(param $stmt_handle: u32 $icol: s32)
(@interface type (func
(param $stmt_handle: u32 $icol: s32)
(result array (u8)))) ;; 57
(@interface type (func
(param $stmt_handle: u32 $icol: s32)
(result array (u8)))) ;; 58
(@interface type (func
(param $stmt_handle: u32 $icol: s32)
(result array (u8)))) ;; 59
(@interface type (func
(param $stmt_handle: u32 $N: u32)
(@interface type (func
(param $stmt_handle: u32 $N: u32)
(result string))) ;; 59
(@interface type (func
(param $stmt_handle: u32 $N: u32)
(result string))) ;; 60
(@interface type (func
(param $stmt_handle: u32 $N: u32)
(result string))) ;; 61
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s32))) ;; 61
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s32))) ;; 62
(@interface type (func
(param $stmt_handle: u32 $icol: u32)
(result s32))) ;; 63
(@interface type (func
(param $db_handle: u32)
(result string))) ;; 64
(@interface type (func
(param $db_handle: u32)
(result string))) ;; 65
;; Adapters
(@interface func (type 10)
(@interface func (type 11)
arg.get 0
i32.from_u32
arg.get 1
i32.from_s32
arg.get 2
i64.from_s64
i32.from_u32
call-core 6
s32.from_i32)
(@interface func (type 12)
call-core 3
call-core 2
string.lift_memory
call-core 1)
(@interface func (type 13)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 7
call-core 3
call-core 2
string.lift_memory
call-core 1)
(@interface func (type 14)
s32.from_i32)
(@interface func (type 15)
arg.get 0
i32.from_u32
arg.get 1
string.size
i32.push 1
call-core 0
arg.get 1
string.lower_memory
call-core 8
call-core 3
record.lift_memory 7
call-core 1)
(@interface func (type 16)
s32.from_i32)
(@interface func (type 17)
arg.get 0
i32.from_u32
arg.get 1
i32.from_s32
arg.get 2
call-core 9
s32.from_i32)
(@interface func (type 18)
(@interface func (type 19)
arg.get 0
string.size
i32.push 1
call-core 0
arg.get 0
string.lower_memory
arg.get 1
i32.from_s32
arg.get 2
string.size
i32.push 1
call-core 0
arg.get 2
string.lower_memory
call-core 10
call-core 3
record.lift_memory 8
call-core 1)
(@interface func (type 21)
arg.get 0
i32.from_u32
arg.get 1
i32.from_s32
arg.get 2
call-core 10
s32.from_i32)
(@interface func (type 20)
arg.get 0
string.size
i32.push 1
call-core 0
arg.get 0
string.lower_memory
arg.get 1
i32.from_s32
arg.get 2
string.size
i32.push 1
call-core 0
arg.get 2
string.lower_memory
call-core 11
call-core 3
record.lift_memory 6
call-core 1)
(@interface func (type 22)
s32.from_i32)
(@interface func (type 23)
arg.get 0
i32.from_u32
call-core 12
s32.from_i32)
(@interface func (type 24)
(@interface func (type 25)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 13
s32.from_i32)
(@interface func (type 26)
s64.from_i64)
(@interface func (type 27)
arg.get 0
i32.from_u32
call-core 14
s32.from_i32)
(@interface func (type 28)
(@interface func (type 29)
arg.get 0
i64.from_s64
call-core 15
s64.from_i64)
(@interface func (type 30)
i32.from_u32
arg.get 1
i32.from_s32
call-core 15)
(@interface func (type 31)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 16
s32.from_i32)
(@interface func (type 32)
(@interface func (type 33)
arg.get 0
i32.from_u32
call-core 17
call-core 3
call-core 2
string.lift_memory
call-core 1)
(@interface func (type 35)
arg.get 0
i32.from_u32
arg.get 1
i32.from_s32
arg.get 2
i64.from_s64
call-core 18
s32.from_i32)
(@interface func (type 37)
arg.get 0
i32.from_u32
call-core 19
s32.from_i32)
(@interface func (type 39)
arg.get 0
i32.from_u32
arg.get 1
@ -300,35 +313,23 @@
call-core 0
arg.get 1
string.lower_memory
arg.get 2
i32.from_s32
arg.get 3
i32.from_s32
call-core 17
call-core 3
record.lift_memory 8
call-core 1)
(@interface func (type 34)
arg.get 0
i32.from_u32
arg.get 1
i32.from_s32
call-core 18)
(@interface func (type 36)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 19
s32.from_i32)
(@interface func (type 38)
arg.get 0
i32.from_u32
arg.get 1
i32.from_s32
call-core 20
call-core 3
record.lift_memory 7
call-core 1)
(@interface func (type 41)
arg.get 0
i32.from_u32
arg.get 1
i32.from_s32
call-core 21
s32.from_i32)
(@interface func (type 40)
(@interface func (type 43)
arg.get 0
i32.from_u32
call-core 22
s32.from_i32)
(@interface func (type 45)
arg.get 0
i32.from_u32
arg.get 1
@ -337,19 +338,14 @@
array.lower_memory u8
arg.get 3
i32.from_s32
call-core 21
s32.from_i32)
(@interface func (type 42)
arg.get 0
i32.from_u32
call-core 22
s32.from_i32)
(@interface func (type 44)
arg.get 0
i32.from_u32
call-core 23
s32.from_i32)
(@interface func (type 46)
(@interface func (type 47)
arg.get 0
i32.from_u32
call-core 24
s32.from_i32)
(@interface func (type 49)
arg.get 0
i32.from_u32
arg.get 1
@ -362,70 +358,60 @@
string.lower_memory
arg.get 3
i32.from_s32
call-core 24
s32.from_i32)
(@interface func (type 48)
arg.get 0
i32.from_u32
call-core 25
s32.from_i32)
(@interface func (type 50)
(@interface func (type 51)
arg.get 0
i64.from_s64
i32.from_u32
call-core 26
s64.from_i64)
(@interface func (type 52)
s32.from_i32)
(@interface func (type 53)
arg.get 0
i32.from_u32
arg.get 1
string.size
i32.push 1
call-core 0
arg.get 1
string.lower_memory
arg.get 2
i32.from_s32
arg.get 3
i32.from_s32
call-core 27
s32.from_i32)
(@interface func (type 54)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 3
record.lift_memory 6
call-core 1)
(@interface func (type 55)
call-core 28
s64.from_i64)
(@interface func (type 56)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 29
s32.from_i32)
(@interface func (type 58)
(@interface func (type 57)
arg.get 0
i32.from_u32
arg.get 1
i32.from_s32
call-core 30
call-core 29
call-core 3
call-core 2
byte_array.lift_memory
call-core 1)
(@interface func (type 60)
(@interface func (type 59)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 30
call-core 3
call-core 2
string.lift_memory
call-core 1)
(@interface func (type 61)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 31
call-core 3
call-core 2
string.lift_memory
call-core 1)
(@interface func (type 62)
arg.get 0
i32.from_u32
arg.get 1
i32.from_u32
call-core 32
s32.from_i32)
(@interface func (type 64)
arg.get 0
i32.from_u32
call-core 33
call-core 3
call-core 2
string.lift_memory
call-core 1)
;; Exports
(@interface export "allocate" (func 0))
@ -434,61 +420,57 @@
(@interface export "get_result_ptr" (func 3))
(@interface export "set_result_size" (func 4))
(@interface export "set_result_ptr" (func 5))
(@interface export "sqlite3_bind_int64" (func 11))
(@interface export "sqlite3_column_text" (func 13))
(@interface export "sqlite3_prepare_v2" (func 15))
(@interface export "sqlite3_close" (func 17))
(@interface export "sqlite3_bind_double" (func 19))
(@interface export "sqlite3_open_v2" (func 21))
(@interface export "sqlite3_changes" (func 23))
(@interface export "sqlite3_column_count" (func 25))
(@interface export "sqlite3_finalize" (func 27))
(@interface export "sqlite3_soft_heap_limit64" (func 29))
(@interface export "sqlite3_errcode" (func 31))
(@interface export "sqlite3_exec" (func 33))
(@interface export "sqlite3_column_double" (func 35))
(@interface export "sqlite3_column_bytes" (func 37))
(@interface export "sqlite3_bind_null" (func 39))
(@interface export "sqlite3_bind_blob" (func 41))
(@interface export "sqlite3_total_changes" (func 43))
(@interface export "sqlite3_step" (func 45))
(@interface export "sqlite3_bind_text" (func 47))
(@interface export "sqlite3_reset" (func 49))
(@interface export "sqlite3_hard_heap_limit64" (func 51))
(@interface export "sqlite3_libversion_number" (func 53))
(@interface export "sqlite3_column_int64" (func 55))
(@interface export "sqlite3_busy_timeout" (func 57))
(@interface export "sqlite3_column_blob" (func 59))
(@interface export "sqlite3_column_name" (func 61))
(@interface export "sqlite3_column_type" (func 63))
(@interface export "sqlite3_errmsg" (func 65))
(@interface export "sqlite3_column_text" (func 12))
(@interface export "sqlite3_column_bytes" (func 14))
(@interface export "sqlite3_close" (func 16))
(@interface export "sqlite3_bind_double" (func 18))
(@interface export "sqlite3_open_v2" (func 20))
(@interface export "sqlite3_changes" (func 22))
(@interface export "sqlite3_step" (func 24))
(@interface export "sqlite3_column_int64" (func 26))
(@interface export "sqlite3_errcode" (func 28))
(@interface export "sqlite3_column_double" (func 30))
(@interface export "sqlite3_busy_timeout" (func 32))
(@interface export "sqlite3_errmsg" (func 34))
(@interface export "sqlite3_bind_int64" (func 36))
(@interface export "sqlite3_finalize" (func 38))
(@interface export "sqlite3_prepare_v2" (func 40))
(@interface export "sqlite3_bind_null" (func 42))
(@interface export "sqlite3_column_count" (func 44))
(@interface export "sqlite3_bind_blob" (func 46))
(@interface export "sqlite3_total_changes" (func 48))
(@interface export "sqlite3_bind_text" (func 50))
(@interface export "sqlite3_reset" (func 52))
(@interface export "sqlite3_exec" (func 54))
(@interface export "sqlite3_libversion_number" (func 56))
(@interface export "sqlite3_column_blob" (func 58))
(@interface export "sqlite3_column_name" (func 60))
(@interface export "sqlite3_column_type" (func 62))
;; Implementations
(@interface implement (func 11) (func 10))
(@interface implement (func 13) (func 12))
(@interface implement (func 15) (func 14))
(@interface implement (func 17) (func 16))
(@interface implement (func 19) (func 18))
(@interface implement (func 21) (func 20))
(@interface implement (func 23) (func 22))
(@interface implement (func 25) (func 24))
(@interface implement (func 27) (func 26))
(@interface implement (func 29) (func 28))
(@interface implement (func 31) (func 30))
(@interface implement (func 33) (func 32))
(@interface implement (func 35) (func 34))
(@interface implement (func 37) (func 36))
(@interface implement (func 39) (func 38))
(@interface implement (func 41) (func 40))
(@interface implement (func 43) (func 42))
(@interface implement (func 45) (func 44))
(@interface implement (func 47) (func 46))
(@interface implement (func 49) (func 48))
(@interface implement (func 51) (func 50))
(@interface implement (func 53) (func 52))
(@interface implement (func 55) (func 54))
(@interface implement (func 57) (func 56))
(@interface implement (func 59) (func 58))
(@interface implement (func 61) (func 60))
(@interface implement (func 63) (func 62))
(@interface implement (func 65) (func 64))
(@interface implement (func 12) (func 11))
(@interface implement (func 14) (func 13))
(@interface implement (func 16) (func 15))
(@interface implement (func 18) (func 17))
(@interface implement (func 20) (func 19))
(@interface implement (func 22) (func 21))
(@interface implement (func 24) (func 23))
(@interface implement (func 26) (func 25))
(@interface implement (func 28) (func 27))
(@interface implement (func 30) (func 29))
(@interface implement (func 32) (func 31))
(@interface implement (func 34) (func 33))
(@interface implement (func 36) (func 35))
(@interface implement (func 38) (func 37))
(@interface implement (func 40) (func 39))
(@interface implement (func 42) (func 41))
(@interface implement (func 44) (func 43))
(@interface implement (func 46) (func 45))
(@interface implement (func 48) (func 47))
(@interface implement (func 50) (func 49))
(@interface implement (func 52) (func 51))
(@interface implement (func 54) (func 53))
(@interface implement (func 56) (func 55))
(@interface implement (func 58) (func 57))
(@interface implement (func 60) (func 59))
(@interface implement (func 62) (func 61))

View File

@ -1528,30 +1528,21 @@ static int bindText(sqlite3_stmt *pStmt, /* The statement to bind against */
/*
** Bind a blob value to an SQL statement variable.
*/
#ifndef __sqlite_unmodified_upstream
int sqlite3_bind_blob_(sqlite3_stmt *pStmt, int i, const void *zData, int nData,
void (*xDel)(void *))
__attribute__((export_name("sqlite3_bind_blob"))) {
int sqlite3_bind_blob(sqlite3_stmt *pStmt, int i, const void *zData, int nData,
void (*xDel)(void *)) {
#ifdef SQLITE_ENABLE_API_ARMOR
if (nData < 0)
return SQLITE_MISUSE_BKPT;
#endif
// xDel is a custom deallocator and due to our IT architecture it can't be provided from other modules.
// However the memory zData uses has to be cleaned up eventually.
// So, it is cleared as intended in IT, and xDel is set to SQLITE_TRANSIENT to make sqlite copy the data.
add_object_to_release((void*)zData);
return bindText(pStmt, i, zData, nData, SQLITE_TRANSIENT, 0);
}
#endif
int sqlite3_bind_blob(sqlite3_stmt *pStmt, int i, const void *zData, int nData,
void (*xDel)(void *)) {
#ifdef SQLITE_ENABLE_API_ARMOR
if (nData < 0) return SQLITE_MISUSE_BKPT;
#endif
#ifdef __sqlite_unmodified_upstream
return bindText(pStmt, i, zData, nData, xDel, 0);
#else
// xDel is a custom deallocator and if it is not SQLITE_STATIC
// due to our IT architecture it can't be provided from other modules.
return bindText(pStmt, i, zData, nData,
(xDel==SQLITE_STATIC || xDel==SQLITE_TRANSIENT)?xDel:free, 0);
#endif
}
int sqlite3_bind_blob64(sqlite3_stmt *pStmt, int i, const void *zData,
sqlite3_uint64 nData, void (*xDel)(void *)) {
@ -1603,24 +1594,17 @@ int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr,
}
return rc;
}
int sqlite3_bind_text(sqlite3_stmt *pStmt, int i, const char *zData, int nData,
void (*xDel)(void *)) {
#ifdef __sqlite_unmodified_upstream
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
}
#ifndef __sqlite_unmodified_upstream
int sqlite3_bind_text_(sqlite3_stmt *pStmt, int i, const char *zData, int nData,
void (*xDel)(void *))
__attribute__((export_name("sqlite3_bind_text"))) {
// xDel is a custom deallocator and due to our IT architecture it can't be provided from other modules.
// However the memory zData uses has to be cleaned up eventually.
// So, it is cleared as intended in IT, and xDel is set to SQLITE_TRANSIENT to make sqlite copy the data.
add_object_to_release((void*)zData);
return bindText(pStmt, i, zData, nData, SQLITE_TRANSIENT, SQLITE_UTF8);
}
#else
// xDel is a custom deallocator and if it is not SQLITE_STATIC
// due to our IT architecture it can't be provided from other modules.
return bindText(pStmt, i, zData, nData,
(xDel==SQLITE_STATIC || xDel==SQLITE_TRANSIENT)?xDel:free, SQLITE_UTF8);
#endif
}
int sqlite3_bind_text64(sqlite3_stmt *pStmt, int i, const char *zData,
sqlite3_uint64 nData, void (*xDel)(void *),
unsigned char enc) {

View File

@ -65,10 +65,7 @@ void write_le_int(unsigned char *array, unsigned int offset, unsigned int value)
array[offset + 3] = (value >> 24) & 0xff;
}
extern void __wasm_call_ctors();
int main() {
__wasm_call_ctors(); // for more details see https://github.com/WebAssembly/WASI/issues/471
// the main purpose of this empty main is to initialize WASI subsystem
return 0;
}

View File

@ -1 +0,0 @@
0.18.2