Skip to content

Commit aa4357a

Browse files
committed
Ordered-set aggregate syntax.
1 parent aef7f05 commit aa4357a

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

embed/bcw2/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# Embeddable Wasm build of SQLite
22

3-
This folder includes an embeddable Wasm build of SQLite, including the experimental
3+
This folder includes an alternative embeddable Wasm build of SQLite,
4+
which includes the experimental
45
[`BEGIN CONCURRENT`](https://sqlite.org/src/doc/begin-concurrent/doc/begin_concurrent.md) and
56
[Wal2](https://sqlite.org/cgi/src/doc/wal2/doc/wal2.md) patches.
67

8+
It also enables the optional
9+
[`UPDATE … ORDER BY … LIMIT`](https://sqlite.org/lang_update.html#optional_limit_and_order_by_clauses) and
10+
[`DELETE … ORDER BY … LIMIT`](https://sqlite.org/lang_delete.html#optional_limit_and_order_by_clauses) clauses,
11+
and the [`WITHIN GROUP ORDER BY`](https://sqlite.org/compile.html#enable_ordered_set_aggregates) aggregate syntax.
12+
713
> [!IMPORTANT]
814
> This package is experimental.
915
> It is built from the `bedrock` branch of SQLite,
10-
> since that is _currently_ the most stable, maintained branch to include both features.
16+
> since that is _currently_ the most stable, maintained branch to include these features.
1117
1218
> [!CAUTION]
1319
> The Wal2 journaling mode creates databases that other versions of SQLite cannot access.

embed/bcw2/bcw2.wasm

910 Bytes
Binary file not shown.

embed/bcw2/bcw2_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/ncruces/go-sqlite3/driver"
8+
"github.com/ncruces/go-sqlite3/ext/stats"
89
"github.com/ncruces/go-sqlite3/vfs"
910
)
1011

@@ -15,7 +16,7 @@ func Test_bcw2(t *testing.T) {
1516

1617
tmp := filepath.ToSlash(filepath.Join(t.TempDir(), "test.db"))
1718

18-
db, err := driver.Open("file:" + tmp + "?_pragma=journal_mode(wal2)&_txlock=concurrent")
19+
db, err := driver.Open("file:"+tmp+"?_pragma=journal_mode(wal2)&_txlock=concurrent", stats.Register)
1920
if err != nil {
2021
t.Fatal(err)
2122
}
@@ -37,6 +38,11 @@ func Test_bcw2(t *testing.T) {
3738
t.Fatal(err)
3839
}
3940

41+
_, err = tx.Exec(`SELECT median() WITHIN GROUP (ORDER BY col) FROM test`)
42+
if err != nil {
43+
t.Fatal(err)
44+
}
45+
4046
err = tx.Commit()
4147
if err != nil {
4248
t.Fatal(err)

embed/bcw2/build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ curl -# https://sqlite.org/src/tarball/sqlite.tar.gz?r=ec5d7025 | tar xz
1818

1919
cd sqlite
2020
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
21-
MSYS_NO_PATHCONV=1 nmake /f makefile.msc sqlite3.c OPTS=-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT
21+
MSYS_NO_PATHCONV=1 nmake /f makefile.msc sqlite3.c "OPTS=-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_ENABLE_ORDERED_SET_AGGREGATES"
2222
else
23-
sh configure --enable-update-limit && make sqlite3.c
23+
sh configure --enable-update-limit
24+
OPTS=-DSQLITE_ENABLE_ORDERED_SET_AGGREGATES make sqlite3.c
2425
fi
2526
cd ~-
2627

embed/bcw2/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require github.com/ncruces/go-sqlite3 v0.21.3
88

99
require (
1010
github.com/ncruces/julianday v1.0.0 // indirect
11+
github.com/ncruces/sort v0.1.2 // indirect
1112
github.com/tetratelabs/wazero v1.8.2 // indirect
1213
golang.org/x/sys v0.29.0 // indirect
1314
)

embed/bcw2/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/ncruces/go-sqlite3 v0.21.3 h1:hHkfNQLcbnxPJZhC/RGw9SwP3bfkv/Y0xUHWsr1
22
github.com/ncruces/go-sqlite3 v0.21.3/go.mod h1:zxMOaSG5kFYVFK4xQa0pdwIszqxqJ0W0BxBgwdrNjuA=
33
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
44
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
5+
github.com/ncruces/sort v0.1.2 h1:zKQ9CA4fpHPF6xsUhRTfi5EEryspuBpe/QA4VWQOV1U=
6+
github.com/ncruces/sort v0.1.2/go.mod h1:vEJUTBJtebIuCMmXD18GKo5GJGhsay+xZFOoBEIXFmE=
57
github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4=
68
github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
79
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=

0 commit comments

Comments
 (0)