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
#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
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
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
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
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.
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
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.
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
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
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
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