Commit Graph

1375 Commits

Author SHA1 Message Date
Kacper Madej
89f5167315 Fix CI build 2024-12-18 16:43:35 +01: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
Pere Diaz Bou
de3449be5a add todo for cache invalidation 2024-12-15 10:03:10 +01:00
Pere Diaz Bou
c6481c4250 add missing propagation error 2024-12-15 10:02:08 +01:00
Pere Diaz Bou
e75b90e35b add contents to checkpoint page 2024-12-15 10:01:22 +01:00
Pekka Enberg
1616ee02d2 Pin toolchain to Rust version 1.83
It's annoying for the CI to trip over formatting because you happen to
have a different version of Rust locally.
2024-12-15 10:54:52 +02:00
Pekka Enberg
636b78d4ff Merge 'Minimal cargo-c support' from Luca Barbato
Fixes #437

Closes #458
2024-12-15 09:30:12 +02:00
Pekka Enberg
9deea33afa cli: Add Limbo version back to shell 2024-12-15 09:26:07 +02:00
Pekka Enberg
15e55fbf74 Update CHANGELOG.md 2024-12-15 09:23:36 +02:00
Pekka Enberg
131ee6707e Merge 'In-memory mode' from Preston Thorpe
https://github.com/tursodatabase/limbo/issues/53
This PR implements a (naive) in-memory option and makes it the default
connection when no DB file argument is passed to the CLI. If a
`:memory:` parameter is passed in place of a path to a database file, to
replicate sqlite's behavior.
It's slightly more difficult to test for obvious reasons, so I added
some dumb and probably temporary ones until I can craft a better
solution. Let it be noted that I had never touched `tcl` previously if
that wasn't obvious ;)
also cleaned up a bit of previous pr, replacing`format!` calls to
writeln with `write_fmt` to prevent double allocations.
EDIT: I originally had these additional tests running with the `test-
compat`, but they would hang whenever running on github actions for
whatever reason.

Closes #476
2024-12-15 09:20:06 +02:00
Pekka Enberg
7907944f10 Update COMPAT.md 2024-12-15 09:14:50 +02:00
Pekka Enberg
fab82d800c Merge 'update compat.md' from Jussi Saurio
From "Partial" to "Yes":
```
SELECT
SELECT ... WHERE
SELECT ... ORDER BY
SELECT ... GROUP BY
SELECT ... HAVING
SELECT ... JOIN
SELECT ... CROSS JOIN
SELECT ... INNER JOIN
```
Opcodes from "No" to "Yes":
```
Compare
Gosub
IdxGE
IsNull
Jump
Return
SeekGe
SeekGt
Transaction
```
Added "Yes" for
```
PrevAsync
PrevAwait
```
Added `+` to the list of supported unary operations
Also added some comments to the syntax support table

Closes #474
2024-12-15 09:14:09 +02:00
PThorpe92
7fc9835899 Optimize replace byte vec with boxed array in memory page 2024-12-14 23:39:51 -05:00
PThorpe92
ce2851ac8d Fix properly opening new connection in shell 2024-12-14 21:20:10 -05:00
PThorpe92
a4ed8d07a5 Temporary tests for POC on in-memory IO impl 2024-12-14 20:52:45 -05:00