Commit Graph

5049 Commits

Author SHA1 Message Date
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
Jussi Saurio
51abeca896 Add regression test for updating indexes 2025-06-09 08:51:23 +03:00
Jussi Saurio
8ffe6208a3 Merge 'Minor: use use_eq_ignore_ascii_case in some places' from Anton Harniakou
Use `eq_ignore_ascii_case` because it's cooler 😎 than `x.to_lowercase()
== y.to_lowercase()`.

Closes #1678
2025-06-09 08:29:56 +03:00
Jussi Saurio
f289897450 Merge 'Remove the FromValue trait' from Anton Harniakou
This PR removes the FromValue trait and implements TryFrom trait instead
for RefValue.

Closes #1682
2025-06-09 08:26:04 +03:00
Jussi Saurio
94e334a44a Merge 'bindings/javascript: Add source property to Statement' from Anton Harniakou
Let's you get the source string that was used to create the prepared
statement.

Reviewed-by: Diego Reis (@el-yawd)

Closes #1670
2025-06-09 08:24:47 +03:00
Jussi Saurio
9c9869f485 Merge 'Support sqlite_master schema table name alias' from Anton Harniakou
Related to #1641. Adds support for `sqlite_master` schema table name.

Reviewed-by: Diego Reis (@el-yawd)

Closes #1669
2025-06-09 08:23:58 +03:00
Jussi Saurio
bf26b8913f Merge 'bindings/javascript: Refactor presentation mode and enhance test suite' from Diego Reis
Throughout the cleaning I discovered that the current pluck mode is
broken, so I took the lead and also fixed it.
EDIT: Address comments on #1620 by improving our documentation

Closes #1663
2025-06-09 08:22:08 +03:00
Jussi Saurio
0e552e3f23 Merge 'js-bindings/implement .name property' from Anton Harniakou
Returns the string that was used to open the database connection.

Reviewed-by: Diego Reis (@el-yawd)

Closes #1662
2025-06-09 08:21:26 +03:00
Jussi Saurio
eec7c0529c Merge 'Beginnings of AUTOVACUUM' from Zaid Humayun
This PR adds the beginnings of
[AUTOVACUUM](https://www.sqlite.org/lang_vacuum.html) to Limbo. It adds
a feature flag called `omit_autovacuum` which is analogous to
`SQLITE_OMIT_AUTOVACUUM`. It is off by default, same as SQLite.
It introduces the concept of [pointer map pages](https://www.sqlite.org/
fileformat.html#pointer_map_or_ptrmap_pages) which are reverse index
pages used to map pages to their parents. This is used to swap pages
(when a table is deleted for instance) to keep root pages clustered at
the beginning of the file. It's also used while creating a table to
ensure that root pages are clustered at the beginning (although, this
isn't completely implemented yet)
Finally, it also adds a couple of missing instructions like `Int64` that
are required for `PRAGMA` commands related to `auto_vacuum` settings
<img width="1512" alt="Screenshot 2025-05-28 at 8 47 51 PM"
src="https://github.com/user-
attachments/assets/d52eb74f-5b79-4d52-9401-1bdc2dcc304d" />

Closes #1600
2025-06-09 08:20:24 +03:00
Jussi Saurio
51637ccad2 Merge 'Reverse Parse Limbo ast and Plans' from Pedro Muniz
This PR implements the `ToSqlString` trait to most of the `ast` structs
and to the `SelectPlan`, `UpdatePlan`, `DeletePlan`,
`CompoundSelectPlan`.
Inside the files in the `to_sql_string` folder, I annotated many `TODOs`
with things that seem to diverge from SQLite syntax. The most egregious
by far was that Create Trigger statements do not use the standard
`delete`, `select`, `update`, and `insert` statements. The parser uses
different structs for those statements only in Create Trigger. E.g
`ast::TriggerCmdUpdate` instead of `ast::Update` and so on.
Also, as this iteration of reverse parsing is not particularly efficient
in the number of string allocations it does. I tested different methods
of achieving this by using `format!`, pushing directly to a `String`, or
just pushing to `Vec<String>` and joining all the string with a space
separator. I focused mainly on trying to get the syntax to print
correctly without major hurdles in understanding the code.
Lastly, I intend in the future to use this code in the simulator to
expand the its available syntax.

Closes #1619
2025-06-09 08:14:19 +03:00
Jussi Saurio
cbfb94d054 Merge 'bindings/java: Add support for Linux build' from Diego Reis
Small PR.
It also adds the ~~massive~~ java's folders to gitignore

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

Closes #1646
2025-06-09 08:12:36 +03:00
김선우
853e12f8a1 Nit 2025-06-08 13:29:10 +09:00
김선우
d6a5d8647a Remove JDBC4ResultSetMetadata.java 2025-06-08 13:20:37 +09:00
김선우
166854cce2 Nit 2025-06-08 13:08:41 +09:00
김선우
208c6963e0 Implement getTables for JDBC4DatabaseMetaData 2025-06-08 13:07:19 +09:00
김선우
a00fe6d358 Extract resultSet to field and implement getMetadata() 2025-06-08 12:34:49 +09:00
김선우
71a2885707 Add JDBC4ResultSetMetadata 2025-06-08 12:30:38 +09:00
Anton Harniakou
41b5959724 Remove the FromValue trait 2025-06-07 10:11:47 +03:00
Anton Harniakou
f424bf0f46 Replace FromValue with TryFrom in ImmutableRecord method 2025-06-07 10:03:49 +03:00
Anton Harniakou
6230948544 Implement TryFrom<&'a RefValue> for 'a &str 2025-06-07 09:55:55 +03:00
Anton Harniakou
c48557a009 Implement TryFrom<&'a RefValue> for String 2025-06-07 09:54:05 +03:00
Anton Harniakou
8078904de6 Implement TryFrom<&'a RefValue> for i64 2025-06-07 09:51:56 +03:00
Zaid Humayun
e994adfb40 Persisting database header and pointer map page to cache
This commit ensures that the metadata in the database header and the pointer map pages allocated are correctly persisted to the page cache. This was not being done earlier.
2025-06-06 23:14:25 +05:30
Zaid Humayun
e7d09edf09 fix clippy warnings 2025-06-06 23:14:25 +05:30
Zaid Humayun
1f5025541c addresses comment https://github.com/tursodatabase/limbo/pull/1600#discussion_r2115796655 by @jussisaurio
this commit ensures that ptrmap operations return a CursorResult so operation can be suspended & later retried
2025-06-06 23:14:25 +05:30
Zaid Humayun
8efbce5980 Fixes tests after asserting MIN_PAGE_SIZE
this commit fixes tests that broke after addding the MIN_PAGE_SIZE assertion
2025-06-06 23:14:25 +05:30
Zaid Humayun
6e87761a34 Addresses comment https://github.com/tursodatabase/limbo/pull/1600#discussion_r2115842804 by @jussisaurio
this commit adds an assert into ptrmap_page_cycle_length
2025-06-06 23:14:25 +05:30
Zaid Humayun
20e20b8a32 Larger compiler directive. Addresses https://github.com/tursodatabase/limbo/pull/1600#discussion_r2115820195
this commit places all pointer map functionality within a module called ptrmap guarded by a compiler directive
2025-06-06 23:14:25 +05:30
Zaid Humayun
33fc60232c removed unnecessary comment 2025-06-06 23:14:25 +05:30
Zaid Humayun
8e6fb1d28f addresses comments by @jussisaurio 2025-06-06 23:14:25 +05:30
Zaid Humayun
0b5338ec7e fixed off by one error 2025-06-06 23:14:25 +05:30
Zaid Humayun
51a1b01ed9 removed comment 2025-06-06 23:14:25 +05:30
Zaid Humayun
7c83086eed removed inferred types 2025-06-06 23:14:25 +05:30
Zaid Humayun
275548e991 adds comment 2025-06-06 23:14:25 +05:30
Zaid Humayun
b9ae5e7ce9 removed omit_autovacuum from flags and fixed tests 2025-06-06 23:14:25 +05:30
Zaid Humayun
4b9ab35012 fixed clippy warnings 2025-06-06 23:14:25 +05:30
Zaid Humayun
5827a33517 Beginnings of AUTOVACUUM
This commit introduces AUTOVACUUM to Limbo. It introduces the concept of ptrmap pages and also adds some additional instructions that are required to make AUTOVACUUM PRAGMA work
2025-06-06 23:14:22 +05:30
Pere Diaz Bou
a0d017c990 Merge 'Fix: ensure PRAGMA cache_size changes persist only for current session' from meteorgan
According to [the
document](https://www.sqlite.org/pragma.html#pragma_cache_size):
```
When you change the cache size using the cache_size pragma, the change only endures for the current session. The cache size reverts to the default value when the database is closed and reopened.
```
so, we shouldn't persist cache_size to database header.
this PR also addresses two minor issues:
1. Sets the default cache_size to -2000 to align with SQLite's default
2. Uses the actual page size to calculate the cache size.

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

Closes #1672
2025-06-06 16:21:02 +02:00
Anton Harniakou
5944e07484 Use eq_ignore_ascii_case 2025-06-06 17:08:49 +03:00