Commit Graph

1326 Commits

Author SHA1 Message Date
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
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
jussisaurio
5e9e2dffe9 support TRUE and FALSE in predicates 2024-12-13 22:58:29 +02:00
Pekka Enberg
138b3a00e8 Merge 'use correct min/max frames' from Pere Diaz Bou
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #465
2024-12-13 18:48:26 +02:00
PThorpe92
33c2d528f2 Refactor shell API for command extensibility 2024-12-13 11:48:18 -05:00
PThorpe92
f6473ea40d Add several cli commands, re-structure shell 2024-12-13 11:48:18 -05:00
Pekka Enberg
f5212b0672 Merge 'loop writing header while initializing' from Pere Diaz Bou
if somehow this doesn't finish in a single loop, do more just in case

Closes #463
2024-12-13 18:48:04 +02:00
Pere Diaz Bou
1e5239a164 use correct min/max frames 2024-12-13 14:06:29 +01:00
Pere Diaz Bou
352b3540ee loop writing header while initializing
if somehow this doesn't finish in a single loop, do more just in case
2024-12-13 13:25:56 +01:00
Pere Diaz Bou
47d25292b2 Merge 'Start multithread support' from Pere Diaz Bou
Since we expect to ensure thread safety between multiple threads in the
future, we extract what is important to be shared between multiple
connections with regards to WAL/Pager.
This is WIP so I just put whatever feels like important behind a RwLock
but expect this to change to Atomics in the future as needed. Maybe even
these locks might disappear because they will be better served with
transaction locks.
This also includes addition of unsafe Sync/Send + UnsafeCell in Pages.

Closes #415
2024-12-13 13:22:17 +01:00
Pere Diaz Bou
3e59da439c fmt 2024-12-13 13:10:33 +01:00
Pere Diaz Bou
1a663a6ed7 cargo stuff rm 2024-12-13 13:09:13 +01:00
Pere Diaz Bou
b43e8e46f6 impl sync/send for cache 2024-12-13 13:09:13 +01:00
Pere Diaz Bou
97dd95abea core: change Rc<RefCell<Page>> to Arc<Page>
This includes an inner struct in Page wrapped with Unsafe cell to access
it. This is done intentionally because concurrency control of pages is
handled by pages and not by the page itself.
2024-12-13 13:09:13 +01:00
Pere Diaz Bou
c816186326 fmt 2024-12-13 13:09:13 +01:00
Pere Diaz Bou
3fda2d09b9 Extract multi threaded part from WalFile to WalFileShared
Since we expect to ensure thread safety between multiple threads in the
future, we extract what is important to be shared between multiple
connections with regards to WAL.

This is WIP so I just put whatever feels like important behind a RwLock
but expect this to change to Atomics in the future as needed. Maybe even
these locks might disappear because they will be better served with
transaction locks.
2024-12-13 13:09:13 +01:00
Pere Diaz Bou
a4297702bd extract page cache to be multi threaded 2024-12-13 13:09:13 +01:00
Pekka Enberg
da3765d061 Merge 'Document typical code flow with charts' from Kacper Madej
I'd love to contribute to Limbo, but wrapping my head around the whole
project is hard.
I decided to start by creating a diagram of a typical flow so that other
potential contributors might have an easier time :)
LMK if this is useful, I can create more of those when I dig deeper.

Closes #456
2024-12-13 11:49:02 +02:00
Pekka Enberg
2b85d2a600 Merge 'Add implementation and tests for replace scalar function' from Alperen Keleş
Adds `replace` scalar function.

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

Closes #446
2024-12-13 11:02:08 +02:00
Pekka Enberg
fefcf1261a Merge 'Add support for unary positive' from Jean Arhancet
Add support for the unary positive operator

Closes #461
2024-12-13 11:01:40 +02:00
JeanArhancet
8bf6572e9e feat: support unary positive 2024-12-13 02:07:34 +01:00
alpaylan
4f395623ab fix the comment on replace panic in case of text cast failure 2024-12-12 15:03:35 -05:00
alpaylan
5742c51c5c improve error messages on replace function call 2024-12-12 14:14:04 -05:00
Alperen Keleş
841a4fe2f8 Merge branch 'tursodatabase:main' into main 2024-12-12 13:13:41 -05:00
Pekka Enberg
3023d228c7 Limbo 0.0.9 2024-12-12 18:49:05 +02:00
Pekka Enberg
afbf9eb9da Update CHANGELOG 2024-12-12 18:47:42 +02:00
Pekka Enberg
96547e924c Merge 'Add buffered cli input and match sqlite cli repl' from Preston Thorpe
This PR prevents input from being evaluated in the case of an incomplete
statement entered, allowing the user to continue the query on following
lines.
This matches the behavior of the sqlite CLI by alerting the user how
many parenthesis are currently open (up to 9) `(x1...`, or too many
closed `(!...` and only processes `.`commands when they are the only
input.
![image](https://github.com/user-
attachments/assets/c062814c-5499-41c1-8ccb-3c5b1dfa682c)
>sqlite
![image](https://github.com/user-
attachments/assets/754fa52b-f006-40ed-89e9-7b69f513bbec)
fixes #450

Closes #457
2024-12-12 18:47:08 +02:00
Kacper Madej
52b94f7181 Update diagram 2024-12-12 17:22:03 +01:00
Kacper Madej
ffede00531 Add link to sqlite docs 2024-12-12 17:11:51 +01:00
Pekka Enberg
5796b418b9 Merge 'Add support for soundex() function' from flaneur
add [soundex](https://www.sqlite.org/lang_corefunc.html#soundex) scalar
function.
it seems that sqlite did not enable `soundex()` function by default
unless build it with `SQLITE_SOUNDEX`, while the sqlite in the ci
workflow did not enable it. this pr skipped the test over `soundex()`
temporarily in the `scalar-function.test` file.

Closes #453
2024-12-12 18:10:46 +02:00