Commit graph

2962 commits

Author SHA1 Message Date
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
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
Pere Diaz Bou
cb4efdbc19 Merge 'LimboRwLock write and read lock fixes' from Pere Diaz Bou
Some checks are pending
Python / linux (x86_64) (push) Waiting to run
Python / macos-x86_64 (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / build-wasm (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
JavaScript / stable - x86_64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-pc-windows-msvc - node@20 (push) Waiting to run
JavaScript / stable - x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
JavaScript / Test bindings on x86_64-apple-darwin - node@18 (push) Blocked by required conditions
JavaScript / Test bindings on x86_64-apple-darwin - node@20 (push) Blocked by required conditions
JavaScript / Test bindings on Linux-x64-gnu - node@18 (push) Blocked by required conditions
JavaScript / Test bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
JavaScript / Build universal macOS binary (push) Blocked by required conditions
JavaScript / Publish (push) Blocked by required conditions
Python / check-requirements (push) Waiting to run
Python / lint (push) Waiting to run
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
* `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
Anton Harniakou
8471704e00 Don't use hard-coded column names 2025-06-09 10:40:04 +03:00
Anton Harniakou
d802075ea9 Resolve merge conflict: Add columns names to result set for pragma statement output 2025-06-09 10:40:04 +03:00
Anton Harniakou
74d4726b0c Use expect to get a better error message if accessing unavailable column 2025-06-09 10:40:04 +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
2075e5f3eb Fix UPDATE always inserting only nulls into non-unique 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
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
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
김선우
0193e1525b Nit 2025-06-07 17:51:24 +09:00
김선우
f52f881bc8 Remove unnecessary comment 2025-06-07 17:44:47 +09:00
김선우
a9c096bb01 Skip increasing n_changes for insn::Insert when it's UPDATE query 2025-06-07 17:23:23 +09:00
김선우
762b61ce55 Add insn::InsertFlags 2025-06-07 17:22:41 +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