Commit Graph

5087 Commits

Author SHA1 Message Date
Jussi Saurio
a5aeff9a3d Fix index insert accidentally double-inserting after balance 2025-06-10 14:16:26 +03:00
Jussi Saurio
04e89c0c4a actually fix drop table 2025-06-10 14:16:26 +03:00
Jussi Saurio
3265e0a789 adjust timeouts in ci 2025-06-10 14:16:26 +03:00
Jussi Saurio
843eb18daf simplify cursor.exists() by using seek() 2025-06-10 14:16:26 +03:00
Jussi Saurio
844461d20b update and delete fixes 2025-06-10 14:16:26 +03:00
Jussi Saurio
d81f5f67bd insert spaghetti fixes 2025-06-10 14:16:26 +03:00
Jussi Saurio
499296d396 fix drop table again: only stack.advance() in a single place 2025-06-10 14:16:26 +03:00
Jussi Saurio
1b4bef9c7c Fix op_idx_delete infinite seeking loop 2025-06-10 14:16:26 +03:00
Jussi Saurio
5c08d259bf Fix drop table: initialize loaded pages to cell idx 0 2025-06-10 14:16:26 +03:00
Jussi Saurio
e897052650 flatten process_overflow_read() to get rid of borrowmuterror possibility 2025-06-10 14:16:26 +03:00
Jussi Saurio
da2437408e get_new_rowid(): fix off by one - rowids start at 1 2025-06-10 14:16:26 +03:00
Jussi Saurio
5f60cce3c7 fix seek_to_last() 2025-06-10 14:16:26 +03:00
Jussi Saurio
0ce18a9146 Fix comment 2025-06-10 14:16:26 +03:00
Jussi Saurio
0b7f5a2a13 Merge MoveTo&Seek states, remove unnecessary seekstate methods, add eq_seen flag to prevent unnecessary next()/prev() 2025-06-10 14:16:26 +03:00
Jussi Saurio
2bac140d73 Remove SeekOp::EQ and encode eq_only in LE&GE - needed for iteration direction aware equality seeks 2025-06-10 14:16:26 +03:00
Jussi Saurio
ae6a943e43 Leave parent pointing at rightmost pointer at the end of balance_root() 2025-06-10 14:16:26 +03:00
Jussi Saurio
cba84b7ce9 Remove premature cast to usize (cell_idx can be negative) 2025-06-10 14:16:26 +03:00
Jussi Saurio
8ad6aadbbd remove unnecessary SeekingIndexMoveUp state 2025-06-10 14:16:26 +03:00
Jussi Saurio
a3ffc6f4e2 Align prev() implementation with next() 2025-06-10 14:16:26 +03:00
Jussi Saurio
58e1a2f5bc Remove unnecessary self.prev() from last() 2025-06-10 14:16:26 +03:00
Jussi Saurio
8941c4a537 fmt 2025-06-10 14:16:26 +03:00
Jussi Saurio
6e5f05a257 Remove unnecessary cell_idx move from tablebtree_move_to() 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
0f79b0dd50 fix prev? 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
f83d837131 fix next to not advance if not necessary 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
f261d5b6af compare on next/prev after seek 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
681df9b1eb fix get record 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
b46852a366 move setting target key in delete if balance is needed 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
c52d9a52d9 fix count 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
96324834a5 invalidate records on movement 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
77b6896eae implement lazy record and rowid in cursor
This also comments save_context for now
2025-06-10 14:16:26 +03:00
Pere Diaz Bou
b0c64cb4d2 parse record lazily 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
105de7e1d8 seek, next and prev return bool 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
0698249c5e test_delete_with_index 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
4a25578723 Merge 'Namespace functions that operate on Value' from Pedro Muniz
This PR is extracted from #1674. This PR creates the optional feature
flag `simulator` that exposes the numeric module and enables an optional
Serde derive on limbo's `Value` type. Additionally, it also namespaces
all of the exec_* functions that operate on a `Value` or indirectly
operate on a `Value` (e.g `exec_like` operates on a pattern string that
is derived from the `Value`). This is necessary so that instead of
reimplementing all of the expected behaviours of different operations
inside the simulator, we can just tap into the existing code we already
have. The next step for this will be wrap be to use `Value` inside the
simulator, which is something that I did in #1674.

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

Closes #1692
2025-06-10 10:54:38 +02:00
PThorpe92
09b345dda1 Merge 'Add sleep between write tests to avoid database locking issues' from Pedro Muniz
My guess as to why the sleep solves the problem is that when you ask
Limbo to quit it needs to checkpoint and with large blobs this probably
takes a while. What I think happens is:
- Now after the python code asks for the program to quit, it already
tries to sleep to allow the checkpointing to succeed
- It terminates the pipe
- Then kills it so that the locking of file is dropped sooner
Then later, we open another shell with SQLite in `test.test_compat()`
and try to run some queries in the database, but the file locking is
still in place. This is my guess on what is going on. I remember
@PThorpe92 had a similar problem a while back on something similar to
this.
```python
    def quit(self) -> None:
        self._write_to_pipe(".quit")
        sleep(0.3)
        self.pipe.terminate()
        self.pipe.kill()
```
This PR also adds a `PRAGMA integrity_check` for the write tests

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1694
2025-06-09 18:10:23 -04:00
pedrocarlo
3e05496078 add integrity check to write tests 2025-06-09 17:44:00 -03:00
pedrocarlo
c7799c8ec5 add sleep to allow file lock to be removed 2025-06-09 16:29:58 -03:00
pedrocarlo
a9ed8dd288 namespace exec_min and exec_max to Value for reuse in simulator 2025-06-09 11:59:44 -03:00
pedrocarlo
39f85ffd03 namespace exec_like to Value 2025-06-09 11:39:55 -03:00
pedrocarlo
6c95a88533 namespace many functions to Value 2025-06-09 11:38:15 -03:00
pedrocarlo
4bbe780a34 add optional serde serialization and deserialization to limbo Value 2025-06-09 11:38:15 -03:00
pedrocarlo
0f2849f7e1 serde and serde_json as workspace dependencies 2025-06-09 11:38:15 -03:00
Pere Diaz Bou
cb4efdbc19 Merge 'LimboRwLock write and read lock fixes' from Pere Diaz Bou
* `write` was returning `true` even though it shouldn't because it
should return `false` in case it was already acquired.
* `read` theoritically can increase `nread` after another thread calls
`unlock` between first lock load and increase of `nread`. So it looks
something like this:
                  1. THREAD  1: read()
                  2. THREAD 2: get lock = `SHARED_LOCK`
                  3. THREAD 1: unlock -> lock is now `NO_LOCK`
                  4. THREAD 2: increase nread, return true.
    This is obviously wrong because `nreads` will be ` > 0 ` but `lock`
is `NO_LOCK`

Closes #1676
2025-06-09 16:15:46 +02:00
Pere Diaz Bou
8cd7c7e82e Merge 'fix: make keyword_token safe by validating UTF-8 input' from ankit
This PR fixes an unsound usage of unsafe {
str::from_utf8_unchecked(word) } in the public function keyword_token in
mod.rs.
The function now uses std::str::from_utf8(word).ok()? to safely handle
invalid UTF-8, eliminating the unsoundness.
No logic or API changes.
Code compiles and tests pass (where possible).
Closes: https://github.com/tursodatabase/libsql/issues/1859

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

Closes #1677
2025-06-09 16:07:37 +02:00
Pekka Enberg
444f963fec Drop debug log... 2025-06-09 10:46:30 +03:00
Pekka Enberg
ae2e0bd71c Merge 'bindings/java: Implement JDBC4DatabaseMetadata getTables ' from Kim Seon Woo
## Purpose
Implement `getTables` which is used to extract metadata about the
database
## Changes
- Implement `JDBC4DatabaseMetaData's` `getTables` method
- Extract `JDBC4ResultSet` as field in `JDBC4PreparedStatement`
## Related Issue
https://github.com/tursodatabase/limbo/issues/615

Closes #1687
2025-06-09 10:46:18 +03:00
Jussi Saurio
db5709dea5 Merge 'Remove plan.to_sql_string() from optimize_plan() as it panics on TODOs' from Jussi Saurio
Closes #1690
2025-06-09 09:50:03 +03:00
Jussi Saurio
18e6987904 Remove plan.to_sql_string() from optimize_plan() as it panics on TODOs 2025-06-09 09:45:06 +03:00
Jussi Saurio
a3611e9f6c Merge 'Fix UPDATE straight up not working on non-unique indexes' from Jussi Saurio
we were skipping `MakeRecord` for the new values from the `SET` clause
if the index wasn't unique, effectively emitting NULLs. Although this
would actually already fail in the `IdxInsert` instruction because the
record register didn't actually contain a record.
this has been (I think) caught in at least 1. limbo stress 2.
antithesis, but I incorrectly assumed it was something more edge-casey
instead of broken like this in a fairly basic way

Closes #1689
2025-06-09 09:11:24 +03:00
Jussi Saurio
2075e5f3eb Fix UPDATE always inserting only nulls into non-unique indexes 2025-06-09 08:51:23 +03:00