Commit Graph

1388 Commits

Author SHA1 Message Date
Pere Diaz Bou
dbe6b8d899 Merge 'Add statement interruption support' from Pekka Enberg
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.

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #512
2024-12-19 12:59:19 +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
Pekka Enberg
10ab841d56 Merge 'Fix limbo_sqlite3 static library build' from mag1c1an1
Static lib was built successfully  on MacOS 15.0.1 (24A348) and Linux
fedora 6.12.4-orbstack-00286-g339578031cbf

Closes #511
2024-12-19 11:44:53 +02:00
mag1c1an1
ab306e9550 Fix issue #499 (add crate-type in libmo_sqlite3)
Signed-off-by: mag1c1an1 <mag1cian@icloud.com>
2024-12-19 17:33:06 +08:00
Pekka Enberg
69e3dd28f7 Limbo 0.0.10 2024-12-18 20:45:55 +02:00
Pere Diaz Bou
94d69c5a4e Merge 'pragma: inital approach to handle pragma statements' from Raul Ferrando
This change refactors how PRAGMA statements are handled, introducing a
more organized and extensible structure to simplify adding new PRAGMA
properties in the future.
Previously, only the `cache_size` PRAGMA was supported. With this
update, support for the `journal_mode` PRAGMA has been added.

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #501
2024-12-18 17:34:35 +01:00
Raul Ferrando
d74012bb59 fix pragma parsing potential errors 2024-12-18 17:26:16 +01:00
Raul Ferrando
a6d1a7cb56 pragma: inital approach to handle pragma statements
This change refactors how PRAGMA statements are handled, introducing a
more organized and extensible structure to simplify adding new PRAGMA
properties in the future.

Previously, only the `cache_size` PRAGMA was supported. With this
update, support for the `journal_mode` PRAGMA has been added.
2024-12-18 17:26:16 +01:00
Pere Diaz Bou
26b4608088 Merge 'Fix CI build' from Kacper Madej
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #505
2024-12-18 17:25:03 +01:00
Kacper Madej
89f5167315 Fix CI build 2024-12-18 16:43:35 +01:00
Pekka Enberg
c16c660aa6 Merge 'cli: added .tables command' from Konstantinos Artopoulos
This PR adds the `.tables` command. I use it a lot in sqlite and I
noticed it was missing from here so I decided to contribute.
Let me know if any changes or improvements are required.

Reviewed-by: Preston Thorpe <alpkeles99@gmail.com>

Closes #503
2024-12-18 12:31:00 +02:00
Konstantinos Artopoulos
fb2908b3e9 refactor(testing): move .table tests to shelltests.py 2024-12-18 09:10:37 +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
jussisaurio
23747ef389 Merge 'Support math functions' from Lauri Virtanen
Add support for math scalar functions of SQLite:
https://sqlite.org/lang_mathfunc.html
Since SQLite CLI and Limbo CLI present floating point numbers with
different precision, I added `do_execsql_test_tolerance` which tests
that floating point results close enough of the expected value. However,
we probably could make Limbo's floating point presentation match to
SQLite.

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

Closes #460
2024-12-17 22:02:43 +02:00
Pere Diaz Bou
d6ba34dd9e Merge 'Fix typos in CLI application' from yinheli
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #496
2024-12-17 13:35:41 +01: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
2f647001bc Add cases to expr equality check, normalize numeric strings 2024-12-16 19:39:06 -05:00
PThorpe92
25772ee1f3 Implement custom expression equality checking 2024-12-16 19:39:05 -05:00
PThorpe92
8d18263fd6 Replace vec args with slices where possible, clippy warnings 2024-12-16 19:39:05 -05:00
Lauri Virtanen
a1c77af8a8 Limit sin and mod tests rows 2024-12-17 00:14:26 +02:00
Lauri Virtanen
fe42930239 Take log function argument count from function context 2024-12-17 00:14:26 +02:00
Lauri Virtanen
ca418c2674 Run do_execsql_test_tolerance for each database 2024-12-17 00:14:26 +02:00
Lauri Virtanen
aa82164717 Add FIXME comments about floating point comparison tolerance 2024-12-17 00:14:25 +02:00
Lauri Virtanen
f5c82503f9 Be more explicit with pi() being the only nullary math function 2024-12-17 00:14:25 +02:00
Lauri Virtanen
e69ee80fac Support log(X) and log(B,X) math functions 2024-12-17 00:14:25 +02:00
Lauri Virtanen
89d0289444 Support pi() function 2024-12-17 00:14:25 +02:00
Lauri Virtanen
5e426a7624 Support binary math functions 2024-12-16 22:29:05 +02:00
Lauri Virtanen
f69fdc1645 Support unary math functions 2024-12-16 19:31:20 +02:00
Lauri Virtanen
793a85a14c Tolerate floating point minor differences in compatibility tests 2024-12-16 19:31:20 +02:00
Lauri Virtanen
9720f63a55 Add types for mathematical functions 2024-12-16 19:31:20 +02:00
Lauri Virtanen
9e0a9b5490 Add mathematical functions table to COMPAT.md 2024-12-16 19:31:10 +02:00
Pekka Enberg
a5cb75ac61 Update CHANGELOG 2024-12-16 18:49:45 +02:00
Pekka Enberg
61269e9c03 Merge 'Fix primary key handling' from Jussi Saurio
Closes #438
**Fixes:**
- Return the actual primary key instead of the rowid when the primary
key is not a rowid alias
sqlite:
```
limbo> create table foo (pk TEXT PRIMARY KEY, value);
sqlite> insert into foo values ('one', 'payload');
sqlite> insert into foo values ('two', 'payload');
sqlite> select * from foo;
one|payload
two|payload
```
limbo now:
```
limbo> create table foo (pk TEXT PRIMARY KEY, value);
limbo> insert into foo values ('one', 'payload');
limbo> insert into foo values ('two', 'payload');
limbo> select * from foo;
one|payload
two|payload
```
limbo before:
```
limbo> select * from foo;
1|payload
2|payload
```
Then, discovered two issues when running the whole TCL test suite
against a copy of `testing.db` that does not have rowid aliases in the
tables:
- Fix trying to convert a Scan into an IndexSearch when the associated
Expr refers to a different instance of the same table in a self-join
- Fix `scan_loop_body_labels` being pushed to in different parts of the
codegen for Scan/Search nodes resulting in incorrect label resolutions
**Additions:**
- Add a new db `testing/testing_norowidalias.db` that is a carbon copy
of `testing/testing.db` except the `id` columns of `users` and
`products` are not rowid aliases (i.e. they are `INT PRIMARY KEY`
instead of `INTEGER PRIMARY KEY`
- Run all TCL tests against both test databases with `do_execsql_test`
```
(testing/testing.db)                        Running test: coalesce-from-table
(testing/testing_norowidalias.db)           Running test: coalesce-from-table
(testing/testing.db)                        Running test: coalesce-from-table-column
(testing/testing_norowidalias.db)           Running test: coalesce-from-table-column
(testing/testing.db)                        Running test: coalesce-from-table-multiple-columns
(testing/testing_norowidalias.db)           Running test: coalesce-from-table-multiple-columns
(testing/testing.db)                        Running test: glob-fn
(testing/testing_norowidalias.db)           Running test: glob-fn
(testing/testing.db)                        Running test: where-glob
(testing/testing_norowidalias.db)           Running test: where-glob
(testing/testing.db)                        Running test: where-glob-question-mark
(testing/testing_norowidalias.db)           Running test: where-glob-question-mark
```
- Allow running tests against specific db file with
`do_execsql_test_on_specific_db $path`
- Wondering if I should add a new table with e.g. text primary key and
add some db-specific tests on that table...?

Closes #449
2024-12-16 18:49:19 +02:00
Pekka Enberg
7943fa1e35 bindings/wasm: Add API reference document
The aim is towards libSQL/better-sqlite3 compatibility. Lift the API
reference document from libsql-js.git and update it accordingly to what
`limbo-wasm` supports.
2024-12-16 18:45:18 +02:00
Pere Diaz Bou
a03749be21 Merge 'Page cache by page_number and frame_number' from Pere Diaz Bou
Since page cache is now shared by default, we need to cache pages by
page number and something else. I chose to go with max_frame of
connection, because this connection will have a max_frame set until from
the start of a transaction until the end of it.
With key pairs of (pgno, max_frame) we make sure each connection is
caching based on the snapshot it is at as two different connections
might have the same pageno being using but a different frame. If both
have same max_frame then they will share same page.

Closes #468
2024-12-16 10:08:34 +01:00
Pekka Enberg
e04de2c924 Merge 'Add tests explciitly for shell behavior, more cli options' from Preston Thorpe
This adds the initial collection of tests specifically for `limbo`
shell/cli behavior, to separate the concern from testing the underlying
dbms.
Also adds `Echo` mode, and `quiet` mode cli argument for better
experience piping output of limbo on the command line.
After writing a ton of tests in `tcl`, I realized that there is no
reason at all to write these particular tests in tcl anymore, so I
rewrote them in python :)
Shell tests were added to `make test` to run in CI

Closes #487
2024-12-16 10:24:11 +02:00
Pekka Enberg
21dbc011a4 Merge 'fix: core/translate: Dont assume GROUP BY has aggregates' from Jussi Saurio
Closes #485

Closes #486
2024-12-16 10:18:32 +02:00
PThorpe92
7ca0abc61d Replace tcl with python tests and add to makefile 2024-12-15 21:40:42 -05:00
PThorpe92
fb70be752e Add first tests for shell specific options and behavior 2024-12-15 18:23:40 -05:00
PThorpe92
d6c6b84d8f Add echo and quiet modes for shell 2024-12-15 18:21:16 -05:00
jussisaurio
419ccc327e Dont assume GROUP BY has aggregates 2024-12-16 00:30:38 +02:00
Pere Diaz Bou
a4d7fee090 typos 2024-12-15 22:54:32 +01:00
Pere Diaz Bou
78d8bb1fa6 comments for everyone 2024-12-15 22:52:49 +01:00
Pere Diaz Bou
37005a23d2 fix checkpoint 2024-12-15 18:55:23 +00:00
Pekka Enberg
66b251f4ab Merge 'Add display message for in-memory database' from Jean Arhancet
#477

Closes #482
2024-12-15 14:59:06 +02:00
JeanArhancet
6bf8988fa0 Add display message for in-memory database 2024-12-15 11:30:27 +01:00