Commit Graph

2716 Commits

Author SHA1 Message Date
Pekka Enberg
ebbb84bb70 Merge 'github.com/penberg/limbo was moved to github.com/tursodatabase/limbo' from Gustavo Sverzut Barbieri
Adjust all the references since they were broken

Reviewed-by: Preston Thorpe (@PThorpe92)
Reviewed-by: Ricardo Dalarme (@ricardodalarme)

Closes #933
2025-02-09 08:44:39 +02:00
Gustavo Sverzut Barbieri
cd2d817c10 github.com/penberg/limbo was moved to github.com/tursodatabase/limbo
Adjust all the references since they were broken
2025-02-08 10:21:49 -03:00
Pekka Enberg
a1a9218131 Merge 'cli: Make pretty mode pretty like DuckDB' from Pekka Enberg
DuckDB is pretty, I want to be pretty!
```
limbo> CREATE TABLE t(x); INSERT INTO t VALUES (1), (2), (3);
limbo> .mode pretty
limbo> SELECT * FROM t;
┌───┐
│ x │
├───┤
│ 1 │
├───┤
│ 2 │
├───┤
│ 3 │
└───┘
```

Closes #931
2025-02-08 12:04:01 +02:00
Pekka Enberg
3deac98d40 cli: Make pretty mode pretty like DuckDB
DuckDB is pretty, I want to be pretty!

```
limbo> CREATE TABLE t(x); INSERT INTO t VALUES (1), (2), (3);
limbo> .mode pretty
limbo> SELECT * FROM t;
┌───┐
│ x │
├───┤
│ 1 │
├───┤
│ 2 │
├───┤
│ 3 │
└───┘
```
2025-02-08 11:39:21 +02:00
Pekka Enberg
24d65f9de2 Merge 'Fix Parser continuing to parse after encountering an error' from Krishna Vishal
Added  `had_true: bool` to `Parser` to track the state of error
encounter, this will be set to `true` once we encounter an error.
If `had_error` is set to true we early return `Ok(None)`.
`FallibleIterator` works in the following way [when `next()`
returns](https://docs.rs/fallible-iterator/latest/fallible_iterator/trai
t.FallibleIterator.html#tymethod.next):
- `Ok(Some(item))` if there's a valid next item.
- `Ok(None)` if the iteration is complete.
- `Err(e)` if there's an error.
I have also added a unit test to check the above contract holds when
parsing `SELECT FROM foo`.
After the fix:
```
limbo> SELECT FROM foo;

  × near "FROM": syntax error at (1, 12)
   ╭────
 1 │ SELECT FROM foo;
   ·           ▲
   ·           ╰── syntax error
   ╰────
```
Closes #865

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

Closes #879
2025-02-08 11:17:27 +02:00
Pekka Enberg
71d2a9b6ab Merge 'Replace hashmap for io_uring pending ops with static array' from Preston Thorpe
Since we are already round robin'ing our `iovecs` in the same way, and
the map will never be larger than MAX_IOVECS, we can remove the cost of
hashing and keep o(1) lookups.

Closes #922
2025-02-08 11:15:54 +02:00
Pekka Enberg
b17610ab77 core/mvcc: Minor code cleanups
Make the source file readable from top to bottom by moving private
functions at the end of the struct implementation.
2025-02-08 10:55:13 +02:00
Pekka Enberg
f9e0650e5e Merge 'MVCC: fix write conflict handling' from Jussi Saurio
Fixes three bugs:
- When a transaction commits, it should:
  1. set the end timestamp of the old version to its own **end
timestamp**,
  2. set the begin timestamp of the new version to its own **end
timestamp**
    * we were erroneously setting it to the transaction's begin
timestamp. see https://www.cs.cmu.edu/~15721-f24/papers/Hekaton.pdf page
299 diagram.
- When checking for write conflicts, the system should ignore versions
that the transaction cannot see. We were checking for write conflicts
before visibility, allowing a tx to always see the latest committed
version and to always overwrite it, since latest committed versions dont
have an end timestamp.
- When checking for write conflicts, the _presence_ of an end timestamp
should always indicate that it is not the latest version and thus a
newer committed version exists, forcing the transaction to abort.
see https://www.cs.cmu.edu/~15721-f24/papers/Hekaton.pdf page 301
section 2.6. Updating a version

Reviewed-by: Pekka Enberg <penberg@iki.fi>

Closes #927
2025-02-08 10:54:00 +02:00
Pekka Enberg
90e7f021fd Merge 'cli: Add column names in Pretty mode' from wyhaya
This is especially useful if you frequently run SQL query like `SELECT *
...`.
## Before
```
limbo> .mode pretty
limbo> select 123 as column1, 'Hello world' as column_2;
+-----+-------------+
| 123 | Hello world |
+-----+-------------+
```
## After
```
limbo> .mode pretty
limbo> select 123 as column1, 'Hello world' as column_2;
+---------+-------------+
| column1 | column_2    |
+---------+-------------+
| 123     | Hello world |
+---------+-------------+
```
---
In the future, if limbo adds a method like `.decl_type()`, we can also
display the data type.
###### DuckDB
```
D select 123 as column1, 'Hello world' as column_2;
┌─────────┬─────────────┐
│ column1 │  column_2   │
│  int32  │   varchar   │
├─────────┼─────────────┤
│   123   │ Hello world │
└─────────┴─────────────┘
```

Closes #925
2025-02-08 10:42:03 +02:00
Jussi Saurio
791255fd8c MVCC: Add a few comments 2025-02-08 10:20:48 +02:00
Jussi Saurio
fab105c10c MVCC: fix write conflict handling 2025-02-08 10:10:09 +02:00
Pekka Enberg
9657920dd7 Merge 'Add java section in README.md' from Kim Seon Woo
Added a section for java in README.md

Closes #923
2025-02-08 09:15:04 +02:00
wyhaya
13062a1479 cli: Add column names in Pretty mode 2025-02-08 15:11:09 +08:00
김선우
cc72439032 Add java section in README.md 2025-02-08 12:09:17 +09:00
Pekka Enberg
a9c76dd2c5 Merge 'simulator: add delete support' from Alperen Keleş
This PR enables the generation of delete statements in the simulator.
There is still some work to do(I would like to add delete a specific
property).
This version currently hits a corruption error with seed
`3270937128460682661`, if anyone could debug it and let me know if it's
the generation that's wrong or the delete code has a bug, I would be
very grateful.

Closes #921
2025-02-07 17:02:22 +02:00
PThorpe92
575a524d04 Replace hashmap for io_uring pending ops with static array 2025-02-07 09:05:08 -05:00
alpaylan
966c807a64 add delete select property 2025-02-07 08:58:02 -05:00
alpaylan
9c339cb8e1 wip: add delete support to the simulator 2025-02-07 08:19:00 -05:00
Pekka Enberg
8787ed11e2 Merge 'bindings/java: Remove @Disabled from working test ' from Kim Seon Woo
Closes #919
2025-02-07 14:04:13 +02:00
Kim Seon Woo
9f7d23df6e Remove @Disabled from working test 2025-02-07 20:41:49 +09:00
Pekka Enberg
808ae4e7bf Merge 'simulator: add more properties and make the generated queries more complex' from Alperen Keleş
We have been working with a very small subset of SQL so far. As a rather
lightweight next phase, I propose that we make the generated queries
more realistic, slowly converging into the type definitions in
`limbo/core`. This PR will gradually implement such advances, the first
commit demonstrates how `LIMIT` is added to `SELECT`.

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

Closes #793
2025-02-07 13:40:23 +02:00
Pekka Enberg
8c0c967ea2 Merge 'Implement json_quote' from Pedro Muniz
Hi! This is my first PR on the project, so I apologize if I did not
follow a convention from the project.
#127
This PR implements json_quote as specified in their source:
https://www.sqlite.org/json1.html#jquote. It follows the internal doc
guidelines for implementing functions. Most tests were added from sqlite
test suite for json_quote, while some others were added by me. Sqlite
test suite for json_quote depends on json_valid to test for correct
escape control characters, so that specific test at the moment cannot be
done the same way.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Reviewed-by: Sonny (@sonhmai)

Closes #763
2025-02-07 13:33:05 +02:00
Pekka Enberg
400dd6dd42 Merge 'bindings/java: Implement custom logger ' from Kim Seon Woo
## Purpose of the PR
- As bindings/java is just a library, we shouldn't have to add specific
library dependency(such as slf4j) to itself
- In order to load bindings/java to 3rd party software(such as
Datagrip), we shouldn't provide a library with slf4j included
## Changes
- Remove slf4j, logback dependency and files
- Add custom logger implementation
## ETC
We can now connect to Datagrip(but there are some errors though)
![image](https://github.com/user-
attachments/assets/ec8becf1-b9a8-415a-8943-74edee9b29c3)
## Reference
[Issue](https://github.com/tursodatabase/limbo/issues/615)

Closes #915
2025-02-07 12:37:56 +02:00
Pekka Enberg
0841ed2bdb Merge 'bindings/java: Implement basic functionality of PreparedStatement ' from Kim Seon Woo
## Purpose of this PR
- Implement basic functionality of `PreparedStatement`
  - `connection.prepareStatement(...)`
  - `setNull`, `setBoolean`, `setInt`, `setDouble` ...
## Changes
- Add binding functions in rust side
- Implement `JDBC4Connection`'s `prepareStatement(sql)`
- Implement basic methods of `JDBC4PreparedStatement`
## TODO
- We can improve the performance of batching the binding operations(and
not execute immediately). For example, we can defer calling limbo's
`bind_at` when query is actually executed.
## Reference
[Issue](https://github.com/tursodatabase/limbo/issues/615)

Closes #913
2025-02-07 12:37:25 +02:00
Pekka Enberg
7169706809 Merge 'Add support for delete row' from Krishna Vishal
**Core delete tasks**:
- [x] Implement free page functionality
- [x] Clear overflow pages if any before deleting their cells using free
page.
- [x] Implement delete for leaf page
- [ ] Balance after delete properly
**Auxiliary tasks to make delete work properly**:
- [x] Implement block coalescing in `free_cell_range` to reduce
fragmentation.
- [x] Track page fragmentation in `free_cell_range`.
- [x] Update page offsets in `drop_cell` and update cell pointer array
after dropping a cell.
- [x] Add TCL tasks
Closes #455
--------
I will add support for balancing after delete once `balance_nonroot` is
extended. In the current state of `balance_nonroot` balancing won't work
after delete and corrupts page.
But delete itself is functional now.

Closes #785
2025-02-07 12:36:23 +02:00
Pekka Enberg
da3981d99c Update README.md 2025-02-07 10:55:46 +02:00
Jussi Saurio
b37745ec14 Merge 'Add quickcheck tests for generate_series() and refine implementation' from Jussi Saurio
Adds `quickcheck` property based tests to the recently merged
`generate_series` implementation and fixes various issues in it:
- `0` for `step` should be treated as `1`
- missing `step` should be treated as `1`
- a string like `a` for `step` should be treated as `1`
- saturating overflow
- return an empty series for a variety of invalid inputs, instead of
erroring
For the future:
We should have e2e/fuzz tests comparing sqlite implementation to limbo
implementation

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #910
2025-02-07 10:40:25 +02:00
Jussi Saurio
49e08c43b7 remove invalid comments 2025-02-07 10:11:31 +02:00
Jussi Saurio
cb9d929eab call cursor methods instead of duplicating logic 2025-02-07 10:09:42 +02:00
Pekka Enberg
7809df913a core/mvcc: Rename Database to MvStore 2025-02-07 07:40:33 +02:00
김선우
cd8f580f54 Nit 2025-02-07 13:50:00 +09:00
김선우
edc964a2cb Implement logger 2025-02-07 13:49:07 +09:00
김선우
f88daf2803 Fix lint 2025-02-07 12:44:24 +09:00
김선우
eeb457f7a1 Implement basic functionality of JDBC4PreparedStatement 2025-02-07 12:33:13 +09:00
pedrocarlo
c3cad5dfdd corrected to use newly created as_str function to convert to string slice 2025-02-07 00:07:51 -03:00
pedrocarlo
8fe71309c0 cargo fmt 2025-02-06 23:46:00 -03:00
pedrocarlo
c8bb1fd353 unreachable to agg and record types, as it should not be possible to pass them to json_quote 2025-02-06 23:43:30 -03:00
김선우
f5c4f4e8a1 Implement JDBC4Connection#prepareStatement 2025-02-07 11:42:36 +09:00
pedrocarlo
b678375c69 increasing string capacity to reduce allocations 2025-02-06 23:37:30 -03:00
pedrocarlo
90ecaf40b5 removed unnecessary string allocations for escaped json value 2025-02-06 23:37:30 -03:00
pedrocarlo
eb40505c31 some tests in sqlite rely on commands not implemented in limbo yet 2025-02-06 23:36:02 -03:00
pedrocarlo
26388cc802 fix: cargo fmt 2025-02-06 23:36:02 -03:00
pedrocarlo
782a18d4bd modify COMPAT.md 2025-02-06 23:36:02 -03:00
pedrocarlo
303a687e65 rebase to main 2025-02-06 23:35:58 -03:00
김선우
cc09cb7d51 Add bindInt 2025-02-07 11:35:54 +09:00
김선우
21d6f33c6b Implement bindXXX functions on rust and java side 2025-02-07 11:25:23 +09:00
김선우
d574e2c277 Add comments on errors.rs 2025-02-07 11:24:43 +09:00
김선우
88c2a15b6f Add requireNotNull method in CommonUtils 2025-02-07 09:51:37 +09:00
김선우
f6919f028e Add columnNames to LimboResultSet 2025-02-07 09:25:22 +09:00
Jussi Saurio
93c3689070 make tests better and fix more edge cases 2025-02-06 23:41:31 +02:00