Commit Graph

5001 Commits

Author SHA1 Message Date
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
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
Pekka Enberg
c7ec4a6270 Merge 'bindings/javascript: Add database property to Statement' from Anton Harniakou
Implements `.database` property on Statement object.
```js
let stmt = db.prepare("SELECT 1");
stmt.database == db // will return the database object the stmt was create with
```

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

Closes #1671
2025-06-05 18:33:59 +03:00
Pekka Enberg
12876227c3 Limbo 0.0.22-pre.1 2025-06-05 18:26:33 +03:00
meteorgan
5da21fe275 add some tests for pragma cache_size 2025-06-05 17:17:21 +08:00
meteorgan
a242bac340 Fix: ensure PRAGMA cache_size changes persist only for current session 2025-06-05 16:55:41 +08:00
Anton Harniakou
90f34643c3 Implement .database property 2025-06-05 10:00:06 +03:00
Anton Harniakou
1adaa927e6 Add tests 2025-06-05 09:59:20 +03:00
pedrocarlo
3c1b984b78 use table_references for PlanContext 2025-06-04 12:06:43 -03:00
pedrocarlo
22d1a1eaa8 fix blob printing 2025-06-04 12:06:43 -03:00
pedrocarlo
ebee9516ba clippy 2025-06-04 12:06:43 -03:00
pedrocarlo
5f379fe2d6 when no context is needed use Display Impl 2025-06-04 12:06:43 -03:00
pedrocarlo
bfc8cb6d4c move display and to_sql_string impls to separate modules for plan 2025-06-04 12:06:43 -03:00
pedrocarlo
f90bebbfbc small fix and remove dbg 2025-06-04 12:06:43 -03:00
pedrocarlo
fa0dff9843 Fix rebase changes 2025-06-04 12:06:43 -03:00
pedrocarlo
a96577529e impl ToSqlString for Update Plan 2025-06-04 12:06:43 -03:00
pedrocarlo
d243d1015c impl ToSqlString for Delete Plan 2025-06-04 12:06:43 -03:00
pedrocarlo
ff5aa17769 impl ToSqlString for CompoundSelect Plan 2025-06-04 12:06:43 -03:00
pedrocarlo
51014d01c3 impl ToSqlString for SelectPlan 2025-06-04 12:06:43 -03:00
pedrocarlo
6773dca595 impl ToSqlString for VACUUM stmt + tests 2025-06-04 12:06:43 -03:00
pedrocarlo
d86ff4dea3 impl ToSqlString for UPDATE stmt + tests 2025-06-04 12:06:42 -03:00
pedrocarlo
659ef8fcf7 impl ToSqlString for REINDEX, RELEASE, ROLLBACK, SAVEPOINT stmt + tests 2025-06-04 12:06:42 -03:00
pedrocarlo
e9cbd29dd1 impl ToSqlString for PRAGMA stmt + tests 2025-06-04 12:06:42 -03:00
pedrocarlo
260a26d612 impl ToSqlString for INSERT stmt + tests 2025-06-04 12:06:42 -03:00
pedrocarlo
5710976d95 impl ToSqlString for DROP INDEX, TABLE, TRIGGER, and VIEW stmt 2025-06-04 12:06:42 -03:00
pedrocarlo
8ff0a3c780 impl ToSqlString for DETACH stmt 2025-06-04 12:06:42 -03:00
pedrocarlo
0dc5ca668c test for DELETE + fixes 2025-06-04 12:06:42 -03:00
pedrocarlo
3b1da29b50 impl ToSqlString for DELETE stmt 2025-06-04 12:06:42 -03:00
pedrocarlo
6ba6fae2c6 CREATE VIRTUAL TABLE tests 2025-06-04 12:06:42 -03:00
pedrocarlo
c8f9e29262 impl ToSqlString for CREATE VIRTUAL TABLE stmt + fixes 2025-06-04 12:06:42 -03:00
pedrocarlo
563ab2fdf3 impl ToSqlString for CREATE VIEW stmt + tests 2025-06-04 12:06:42 -03:00
pedrocarlo
87b9540b4a test for create trigger + fixes 2025-06-04 12:06:42 -03:00
pedrocarlo
a22d06cd66 impl ToSqlString for CREATE TRIGGER stmt 2025-06-04 12:06:42 -03:00