Commit Graph

1355 Commits

Author SHA1 Message Date
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
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
PThorpe92
89819eebf6 Expose memoryIO from limbo_core 2024-12-14 20:52:45 -05:00
PThorpe92
49f8429cc0 Enable :memory: as default option for cli when no DB provided 2024-12-14 20:52:45 -05:00
PThorpe92
a323db6f46 Add in-memory IO implementation 2024-12-14 20:52:44 -05:00
jussisaurio
30920d9ddc update compat.md 2024-12-14 21:30:49 +02:00
jussisaurio
cf085bdb98 Merge 'core: update btree.rs' from Ikko Eltociear Ashimine
postion -> position

Closes #473
2024-12-14 21:24:36 +02:00
Ikko Eltociear Ashimine
043fba2632 core: update btree.rs
postion -> position
2024-12-15 03:31:46 +09:00
jussisaurio
987a8bfb5d Run all tcl tests on 2 separate dbs (1. with rowid aliases 2. without rowid aliases) 2024-12-14 17:13:45 +02:00
jussisaurio
949d6fecbd ignore wal files 2024-12-14 17:13:02 +02:00
jussisaurio
351cb7b3f3 fix bug with incorrect ordering of scan loop body labels stack elements 2024-12-14 17:12:24 +02:00
jussisaurio
a04cf611e0 fix bug with making an index search node in a self join where expr refers to other instance of same table 2024-12-14 17:11:32 +02:00
Luca Barbato
eacbba2c07 Minimal cargo-c support 2024-12-14 15:19:50 +01:00
jussisaurio
961e57df94 Fix returning rowid instead of PK when PK is not a rowid alias 2024-12-14 15:51:08 +02:00
jussisaurio
9aaf0869ae Merge 'Add several cli shell commands, re-structure shell api' from Preston Thorpe
After fixing the shell issue earlier I just had to revisit this. Let me
know if this is too opinionated of changes or out of scope.
This PR adds several of the sqlite CLI commands to the limbo shell user
interface, with their behavior matched as much as possible.
- `.show`:  displays a list of currently enabled settings
- `.open <file>` : opens a database file
- `.output <file>`: allows the user to direct shell output to a file, or
stdout if left blank
- `.cd <dir>`: changes the current working directory of the shell
environment
- `.mode <output_mode>`: allows the user to select between the (two)
current output modes "pretty | raw"
- `.nullvalue <string>`: allows user to set the value of NULL to be
displayed in the output
It also prevents a database file argument from needing to being passed
as an argv[1], but alerts the user that no database was selected, while
allowing them to `.open` a database file with a dot command.
![image](https://github.com/user-
attachments/assets/8249e28d-e545-4c49-ab30-909cf1e42563)
![image](https://github.com/user-
attachments/assets/cfda121b-c789-48cc-a35e-259d8b5a3a04)
This PR also restructures the CLI crate a bit, to make future commands a
bit easier to add.

Reviewed-by: Pekka Enberg <pere-altea@hotmail.com>

Closes #462
2024-12-14 15:45:48 +02:00
PThorpe92
7a9fe8ac88 Add cli command to set null value 2024-12-14 08:15:48 -05:00
Pekka Enberg
3eb1e1c2f7 Update README.md 2024-12-14 11:36:22 +02:00
Pekka Enberg
e3d8de8919 Merge 'Add two arguments version of unhex(x, y) function' from Kacper Kołodziej
Part of solution for #144

Closes #470
2024-12-14 09:02:30 +02:00
Pekka Enberg
982b423709 Merge 'support TRUE and FALSE in predicates' from Jussi Saurio
closes #466

Closes #469
2024-12-14 09:01:30 +02:00
Kacper Kołodziej
dda5e1e871 update scalar function list in COMPAT.md
add `unhex(x, y)`
2024-12-14 00:55:44 +01:00
Kacper Kołodziej
64bfa2eb79 test: unhex(x, y) suite
Tests for `unhex(x, y)` (two arguments version).

Part of solution for #144
2024-12-14 00:55:44 +01:00
Kacper Kołodziej
c04839d9e0 functions: add unhex(x, y) version
For `unhex(x, y)` handle trimming `y` characters from the beginning and
end of `x` value before decoding.

Part of solutions of #144.
2024-12-14 00:55:44 +01:00