Commit Graph

1407 Commits

Author SHA1 Message Date
jussisaurio
5b4ef4412b Merge 'Implement json_array' from Kacper Madej
Implements [json_array](https://sqlite.org/json1.html#jarray).
As a side quest, this PR also fixes an issue with the `CHAR` function
which didn't work properly if the parameters were  non-leaf AST nodes.
The PR is quite big, because as I mentioned in https://github.com/tursod
atabase/limbo/issues/127#issuecomment-2541307979 we had to modify
`OwnedValue::Text` to support a `subtype` parameter, which is what
SQLite does.

Closes #504
2024-12-20 16:35:40 +02:00
Kacper Madej
e2fc03e822 Update COMPAT.md 2024-12-20 11:32:57 +01:00
Kacper Madej
cdb24d3de1 Handle issues with nested arguments 2024-12-20 11:32:57 +01:00
Kacper Madej
19ae42dfa3 Implement json_array 2024-12-20 11:15:48 +01:00
Pekka Enberg
8387e7903c sqlite: Fix source formatting 2024-12-20 09:30:03 +02:00
Pekka Enberg
07ae003db7 Update PERF.md 2024-12-20 09:22:44 +02:00
Pekka Enberg
56710b0187 sqlite3: Implement sqlite3_free_table() 2024-12-20 09:18:31 +02:00
Pekka Enberg
03ae123060 Add PERF.md with Mobibench instructions 2024-12-20 09:15:21 +02:00
Pekka Enberg
d0fa9e07f7 Merge 'sqlite3: Add sqlite3_wal_checkpoint_*() API' from Pekka Enberg
This wires up checkpointing to the SQLite C API. We don't respect the
checkpointing mode because core does not have that nor do we report back
some stats.

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

Closes #480
2024-12-20 09:06:04 +02:00
Pekka Enberg
875619791b Merge 'Implement basic sqlite3_get_table() API' from Diego Reis
#479
This is my first draft for implementing `sqlite3_get_table()`, it is
highly inspired on the actual implementation found [here](https://raw.gi
thubusercontent.com/rusqlite/rusqlite/92fdc11fea0ecea6400dfcb74c1c3ca362
14a7d4/libsqlite3-sys/sqlite3/sqlite3.c), I made some basic manual
testing in `example.c` and it works fine but an extensive test suite is
recommended.

Closes #519
2024-12-20 09:05:50 +02:00
Diego Reis
3a0e56bca5 Implement basic sqlite3_get_table() API 2024-12-19 23:13:51 -03:00
jussisaurio
acdfe2be0c Merge 'cleanup: replace &(*x) with x.as_ref() for smart pointer derefs' from Ziyak Jehangir
The only instances of the &(*x) dereferencing pattern in the codebase,
is used with Completion smart pointers. Changed it to use as_ref(). No
functional changes.

Closes #516
2024-12-19 17:43:59 +02:00
Pekka Enberg
91a5994eac Merge 'Fix Python binding packaging' from Gökmen Görgen
Somehow the `make` command does not work because of the name
mismatching. This PR will fix only this issue.
For reproducing the issue:
```
$ make

Checking requirements files...
mkdir -p .tmp
pip-compile pyproject.toml --quiet             --output-file=.tmp/requirements.txt
pip-compile pyproject.toml --quiet --extra=dev --output-file=.tmp/requirements-dev.txt
diff -u requirements.txt     .tmp/requirements.txt     || (echo "requirements.txt doesn't match pyproject.toml"     && exit 1)
--- requirements.txt    2024-12-17 02:19:29.887227723 +0000
+++ .tmp/requirements.txt       2024-12-17 02:19:38.046065295 +0000
@@ -1,2 +1,2 @@
 typing-extensions==4.12.2
-    # via limbo (pyproject.toml)
+    # via pylimbo (pyproject.toml)
requirements.txt doesn't match pyproject.toml
make: *** [Makefile:28: check-requirements] Error 1
```
## Another issue...
`maturin` is still not in requirements dev list. Shall we continue to
install it manually or add it to dev list?

Closes #495
2024-12-19 17:13:52 +02:00
jussisaurio
80d438ba58 Merge 'Handle all SQLite quoting syntax' from Kacper Madej
This PR adds missing SQLite quoting syntax:
https://sqlite.org/lang_keywords.html
Closes #483
Closes #497
```bash
➜  limbo git:(missing-quoting) ✗ cargo run --package limbo --bin limbo home.db
Limbo v0.0.9
Enter ".help" for usage hints.
limbo> select * from home limit 1;
Documents|dir|280|2024-10-13 06:26:05.605048960+02:00
limbo> select * from [home] limit 1;
Documents|dir|280|2024-10-13 06:26:05.605048960+02:00
limbo> select * from `home` limit 1;
Documents|dir|280|2024-10-13 06:26:05.605048960+02:00
limbo> select * from "home" limit 1;
Documents|dir|280|2024-10-13 06:26:05.605048960+02:00
```

Closes #492
2024-12-19 17:00:23 +02:00
Ziyak Jehangir
99d1b0e5a3 cleanup: replace &(*x) with x.as_ref() for smart pointer derefs 2024-12-19 19:36:04 +05:30
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
Gökmen Görgen
682f014817 add maturin as dev dependency. 2024-12-18 21:14:58 +00:00
Pekka Enberg
69e3dd28f7 Limbo 0.0.10 2024-12-18 20:45:55 +02:00
Kacper Madej
9e01c22a5e Handle quoting identifiers properly 2024-12-18 19:45:06 +01: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
Gökmen Görgen
3252ab542b fix project name in txt files. 2024-12-17 01:33:54 +00: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