Commit graph

201 commits

Author SHA1 Message Date
Pekka Enberg
e406a030e6 Merge 'Rework io_uring feature' from Jorge López Tello
This makes io_uring the default in CLI, but makes it non-default in
core. Before, if one built CLI without io_uring, core still built with
it as it was a default feature. To accommodate for the change, all
bindings have been updated to select the feature, except for WASM which
has a separate fs implementation.
This also adds some #[cfg] and #[allow] to silence unused-* warnings,
which I discovered when testing with different features disabled.

Closes #942
2025-02-09 08:46:29 +02:00
Jorge López
62dea0b12b
cli: select io_uring feature by default 2025-02-09 01:11:00 +01:00
wyhaya
e9046fef78 cli: Improve pretty mode table 2025-02-09 00:01:07 +08:00
Pekka Enberg
3deac98d40 cli: Make pretty mode pretty like DuckDB
DuckDB is pretty, I want to be pretty!

```
limbo> CREATE TABLE t(x); INSERT INTO t VALUES (1), (2), (3);
limbo> .mode pretty
limbo> SELECT * FROM t;
┌───┐
│ x │
├───┤
│ 1 │
├───┤
│ 2 │
├───┤
│ 3 │
└───┘
```
2025-02-08 11:39:21 +02:00
wyhaya
13062a1479 cli: Add column names in Pretty mode 2025-02-08 15:11:09 +08:00
Pekka Enberg
c210821100 core: Move result row to ProgramState
Move result row to `ProgramState` to mimic what SQLite does where `Vdbe`
struct has a `pResultRow` member. This makes it easier to deal with result
lifetime, but more importantly, eventually lazily parse values at the edges of
the API.
2025-02-06 11:52:26 +02:00
Pekka Enberg
7967cc5efc core: Kill Rows wrapper struct
It's just an useless wrapper, kill it.
2025-01-26 16:27:19 +02:00
sonhmai
a090fb927a centralize Rust integration and regression tests 2025-01-21 15:41:09 +07:00
sonhmai
e45a807f0e core: allocate 2 registers for checkpoint opcode execution 2025-01-20 08:34:13 +07:00
sonhmai
cb631dafdc feat: wire checkpoint to bytecode execution 2025-01-20 08:34:13 +07:00
sonhmai
6243ffbab4 add dev dependencies for testing wal_checkpoint 2025-01-20 08:34:13 +07:00
sonhmai
66d6291f32 add scaffolding for supporting wal checkpoint 2025-01-20 08:34:13 +07:00
Jorge López
07970468bd
syntactic changes: remove unneeded parentheses 2025-01-18 18:45:05 +01:00
Jorge López
86a4714711
syntactic changes: remove unneeded paths when the type is already imported 2025-01-18 18:29:12 +01:00
CK-7vn
57274fa40b
Correct CLI comment handling to mimic sqlite behavior 2025-01-17 13:59:34 -05:00
Diego Reis
285eeccb84 Fix cli comments parsing 2025-01-16 20:20:36 -03:00
Pekka Enberg
f711d2b7ed cli: Improve .schema command output on errors
Improve `.schema` output on errors by marking them as comments. This
allows you to pipe any `.schema` output to another shell.
2025-01-16 14:25:48 +02:00
psvri
9cc9577c91 Run all statements from sql argument in cli 2025-01-15 18:19:39 +05:30
PThorpe92
23d9d09b70
Add load_extension function, resolve shared lib extensions 2025-01-14 12:01:07 -05:00
PThorpe92
9c208dc866
Add tests for first extension 2025-01-14 07:27:35 -05:00
PThorpe92
3412a3d4c2
Rough design for extension api/draft extension 2025-01-14 07:20:48 -05:00
PThorpe92
0a10d893d9
Sketch out runtime extension loading 2025-01-14 07:18:07 -05:00
Jorge López
aca38031a4
cli: pass Io without option to get_io(), since even when running in-memory we get a default Io from Clap. Also remove last pesky Io::clone() 2025-01-11 22:44:56 +01:00
Jorge López
486389d6ff
cli: remove calls to Io::clone() as it is now Copy 2025-01-11 21:54:41 +01:00
Jorge López
b630414722
cli: implement Copy for DbLocation and Io, as suggested by [Preston](https://github.com/PThorpe92) 2025-01-11 21:50:09 +01:00
Jorge López
2596e0800e
core: expose UnixIO apart from PlatformIO on any Unix, and expose UringIO on Linux with feature io_uring.
cli: add a new argument to select I/O backend (more than one option only for Linux with io_uring feature).

cli: make both Limbo::new() and Limbo::open_db() use get_io(), unifying parsing of database path and eliminating duplicated code.
2025-01-11 15:21:26 +01:00
Jorge López
a17464ca5c
cli: Add io_uring feature to match core 2025-01-11 15:03:26 +01:00
psvri
ce8600a695 Fix import csv failing when single quote is in string 2025-01-11 13:48:21 +05:30
Samyak S Sarnayak
c09a0bcbf3
Nicer parse errors using miette
I noticed that the parse errors were a bit hard to read - only the nearest token and the line/col offsets were printed.

I made a first attempt at improving the errors using [miette](https://github.com/zkat/miette).
- Added derive for `miette::Diagnostic` to both the parser's error type and LimboError.
- Added miette dependency to both sqlite3_parser and core. The `fancy` feature is only enabled for CLI.

Some future improvements that can be made further:
- Add spans to AST nodes so that errors can better point to the correct token. See upstream issue: https://github.com/gwenn/lemon-rs/issues/33
- Construct more errors with offset information. I noticed that most parser errors are constructed with `None` as the offset.

Comparisons.
Before:
```
❯ cargo run --package limbo --bin limbo database.db --output-mode pretty
...
limbo> selet * from a;
[2025-01-05T11:22:55Z ERROR sqlite3Parser] near "Token([115, 101, 108, 101, 116])": syntax error
Parse error: near "selet": syntax error at (1, 6)
```

After:
```
❯ cargo run --package limbo --bin limbo database.db --output-mode pretty
...
limbo> selet * from a;
[2025-01-05T12:25:52Z ERROR sqlite3Parser] near "Token([115, 101, 108, 101, 116])": syntax error

  × near "selet": syntax error at (1, 6)
   ╭────
 1 │ selet * from a
   ·     ▲
   ·     ╰── syntax error
   ╰────

```
2025-01-05 17:56:59 +05:30
psvri
18a1055088 Edit help message 2025-01-03 19:40:35 +05:30
psvri
1f21cf6a71 Feat: Import csv support 2025-01-03 15:20:22 +05:30
PThorpe92
f6cd707544
Add clippy CI, fix or ignore warnings where appropriate 2024-12-29 10:25:41 -05:00
Pekka Enberg
75992a84d8 cli: Fix unused result warnings 2024-12-27 10:55:29 +02:00
Pekka Enberg
f2ecebc357 Rename RowResult to StepResult
The name "row result" is confusing because it really *is* a result from
a step() call. The only difference is how a row is represented as we
return from VDBE or from a statement.

Therefore, rename RowResult to StepResult.
2024-12-27 10:20:41 +02:00
Pere Diaz Bou
aed14117c9 core: transaction support 2024-12-24 18:04:30 +01:00
Pekka Enberg
e93ac38e55 Add statement interruption support
This adds an interrupt() method to Statement that allows apps to
interrupt a running statement. Please note that this is different from
`sqlite3_interrupt()` which interrupts all ongoing operations in a
database. Although we want to support that too, per statement interrupt
is much more useful to apps.
2024-12-19 12:30:32 +02:00
Konstantinos Artopoulos
ba676b6ead
fix: remove old help menu item that sneaked in on rebase 2024-12-18 00:13:42 +02:00
Konstantinos Artopoulos
969ab244c2
feat(cli): added .tables command 2024-12-18 00:00:29 +02:00
jussisaurio
783ec65c77 Merge 'Expression equality checking, some optimizations' from Preston Thorpe
This PR mainly adds custom logic to check equality in ast expressions.
Not sure if this belongs in the `vendored` parser or not, let me know
and I'll bring it out. Also replaces `Vec` arguments with slice refs
where possible, as well as some clippy warnings in the same `emitter`
file.
I'll write some more tests tomorrow to make sure this is as thorough as
possible.
EDIT: failed test same issue referenced in #484. Marking as draft until
more tests + cases added

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

Closes #488
2024-12-17 22:09:20 +02:00
yinheli
8271a323a1
Fix typos in CLI application 2024-12-17 13:26:50 +08:00
PThorpe92
1833dcb618
Shrink shell help msg and replace hardcoded path for shell tests 2024-12-16 20:14:04 -05:00
PThorpe92
66c44a021f
Move ast expr equality check out of vendored, remove allocs and add cases 2024-12-16 19:39:06 -05:00
PThorpe92
7ca0abc61d
Replace tcl with python tests and add to makefile 2024-12-15 21:40:42 -05:00
PThorpe92
d6c6b84d8f
Add echo and quiet modes for shell 2024-12-15 18:21:16 -05:00
JeanArhancet
6bf8988fa0 Add display message for in-memory database 2024-12-15 11:30:27 +01:00
Pekka Enberg
9deea33afa cli: Add Limbo version back to shell 2024-12-15 09:26:07 +02:00
PThorpe92
ce2851ac8d
Fix properly opening new connection in shell 2024-12-14 21:20:10 -05:00
PThorpe92
49f8429cc0
Enable :memory: as default option for cli when no DB provided 2024-12-14 20:52:45 -05:00
PThorpe92
7a9fe8ac88
Add cli command to set null value 2024-12-14 08:15:48 -05:00
PThorpe92
33c2d528f2
Refactor shell API for command extensibility 2024-12-13 11:48:18 -05:00