Commit Graph

43 Commits

Author SHA1 Message Date
Pekka Enberg
92291ed736 Merge 'Fix offset variable handling' from Nikita Sivukhin
Before, db generated incorrect plan in case when offset parameter were
introduced as variable:
```
turso> EXPLAIN SELECT * FROM users LIMIT ? OFFSET ?;
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     16    0                    0   Start at 16
1     Variable           1     1     0                    0   r[1]=parameter(1); OFFSET expr
2     MustBeInt          1     0     0                    0
3     Variable           2     2     0                    0   r[2]=parameter(2); OFFSET expr
4     MustBeInt          2     0     0                    0
5     OffsetLimit        1     3     2                    0   if r[1]>0 then r[3]=r[1]+max(0,r[2]) else r[3]=(-1)
6     OpenRead           0     2     0                    0   table=users, root=2, iDb=0
7     Rewind             0     15    0                    0   Rewind table users
8       Variable         2     2     0                    0   r[2]=parameter(2); OFFSET expr
9       MustBeInt        2     0     0                    0
10      IfPos            2     14    1                    0   r[2]>0 -> r[2]-=1, goto 14
11      Column           0     0     4                    0   r[4]=users.x
12      ResultRow        4     1     0                    0   output=r[4]
13      DecrJumpZero     1     15    0                    0   if (--r[1]==0) goto 15
14    Next               0     8     0                    0
15    Halt               0     0     0                    0
16    Transaction        0     1     1                    0   iDb=0 tx_mode=Read
17    Goto               0     1     0                    0
```

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3360
2025-09-27 08:20:54 +03:00
Pekka Enberg
222ab125c1 Turso 0.2.0-pre.9 2025-09-26 19:00:14 +03:00
Nikita Sivukhin
5bf69350b3 add simple tests for offset/limit binding 2025-09-26 18:06:20 +04:00
Nikita Sivukhin
a0c47b98b8 fix test 2025-09-26 17:42:11 +04:00
Nikita Sivukhin
52f3216211 fix avg aggregation
- ignore NULL rows as SQLite do
- emit NULL instead of NaN when no rows were aggregated
- adjust agg column alias name
2025-09-26 17:11:06 +04:00
Pekka Enberg
f8130d051f Merge 'Fix JavaScript bindings' from Nikita Sivukhin
This PR makes all JS db packages to have uniform interface: `new
Database(...)` constructor with explicit `connect()` and `close()`
methods.
Also, this PR adds docstrings in the code and properly support few
better-sqlite options (readonly, fileMustExist, timeout)

Closes #3334
2025-09-25 17:24:03 +03:00
Nikita Sivukhin
a938bdcf09 fix exec to run over multiple statements in the string 2025-09-25 12:03:52 +04:00
Nikita Sivukhin
6fe5a0b61e add comments and small test adjustments 2025-09-25 10:52:18 +04:00
Nikita Sivukhin
28c9850b57 properly guard access to the private fields 2025-09-24 17:24:27 +04:00
Nikita Sivukhin
2ccd50ad69 add explicit async connect method to the database instance 2025-09-24 17:06:23 +04:00
Nikita Sivukhin
a5c2d5beb7 get rid of global module variable - otherwise there will be a race when both database-browser and sync-browser are used 2025-09-24 12:01:27 +04:00
Pekka Enberg
f72600431b Turso 0.2.0-pre.8 2025-09-24 09:08:34 +03:00
Nikita Sivukhin
1faafdb57e use wasm-runtime from NPM instead of patched sources 2025-09-23 12:28:16 +04:00
Pekka Enberg
f6e3beda45 Turso 0.2.0-pre.7 2025-09-22 20:44:08 +03:00
Pekka Enberg
26f90257a6 Turso 0.2.0-pre.6 2025-09-22 11:44:21 +03:00
Pekka Enberg
f4b0fb17f7 Turso 0.2.0-pre.5 2025-09-22 11:34:22 +03:00
Pekka Enberg
fbad158213 Turso 0.2.0-pre.4 2025-09-22 09:15:55 +03:00
Nikita Sivukhin
bc2dbe9025 fix bug 2025-09-19 13:21:00 +04:00
Nikita Sivukhin
1d3c823c7b wip 2025-09-19 13:19:30 +04:00
Nikita Sivukhin
66de28d84b wip 2025-09-19 13:19:30 +04:00
Nikita Sivukhin
974feac27b move compute to the main thread for browser and node
- now, most of the work is happening on the main thread
- for database in browser, we still have dedicated WebWorker - but it is used only for OPFS access and only for that
- for syn in browser we still offload sync operations to the WebWorker
2025-09-19 13:19:30 +04:00
Nikita Sivukhin
23e8204bfc yarn build 2025-09-15 10:57:03 +04:00
Pekka Enberg
5df05e05f8 Turso 0.2.0-pre.3 2025-09-12 18:40:06 +03:00
Nikita Sivukhin
99759b9efd fix wasm-runtime package.json 2025-09-12 19:28:30 +04:00
Pekka Enberg
2651b597c6 Turso 0.2.0-pre.2 2025-09-12 17:38:30 +03:00
Jussi Saurio
b5f3da100b Merge 'fix CI for apple builds' from Nikita Sivukhin
Intel MAC builds were removed in https://github.com/tursodatabase/turso/
commit/3547bd10931e030a372bedb4968404301c2936c6 but arm builds were
broken after that.
This PR returns back proper ARM builds for Apple

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3054
2025-09-12 16:19:05 +03:00
Nikita Sivukhin
ab6c1bd8c7 use arm target for apply builds 2025-09-12 16:50:02 +04:00
Nikita Sivukhin
4e54f9042c newlines 2025-09-12 16:25:39 +04:00
Nikita Sivukhin
a5fbcb11e5 fix CI 2025-09-12 15:39:38 +04:00
Nikita Sivukhin
8c48a1dc47 bundle browser packages too in order to easily consume them without bundlers 2025-09-12 15:27:40 +04:00
Nikita Sivukhin
1c38344f4f build bundles for browser libs 2025-09-12 14:15:28 +04:00
Nikita Sivukhin
b086cba669 hack imports of wasm due to the issues in Vite and Next.js build systems 2025-09-12 14:03:31 +04:00
Pekka Enberg
ae3c1fc2a6 Turso 0.2.0-pre.1 2025-09-11 11:44:42 +03:00
Nikita Sivukhin
1eec8f85f4 fix CI 2025-09-10 23:40:49 +04:00
Nikita Sivukhin
0aa9d59438 rebuild 2025-09-10 22:48:37 +04:00
Nikita Sivukhin
d55026f84f opfs for sync in one commit! 2025-09-10 22:35:57 +04:00
Pekka Enberg
e04938eaf5 Turso 0.1.5 2025-09-10 13:30:18 +03:00
Pekka Enberg
1d34122414 Turso 0.1.5-pre.5 2025-09-10 11:40:21 +03:00
Nikita Sivukhin
f3f69598c5 add missing module type for browser package 2025-09-10 03:06:34 +04:00
Nikita Sivukhin
f827731727 rename database-core -> database-common 2025-09-09 14:26:21 +04:00
Nikita Sivukhin
7618dfb519 final adjustments 2025-09-09 14:06:10 +04:00
Nikita Sivukhin
816aa8b2bc small fixes 2025-09-09 12:05:41 +04:00
Nikita Sivukhin
8160f4dc04 restructure js bindings 2025-09-09 11:32:38 +04:00