Commit Graph

5131 Commits

Author SHA1 Message Date
Jussi Saurio
b30ed90bea Merge 'sim/aws: fix vibecoding errors in logic' from Jussi Saurio
- Entire stdout+stderr was passed to both title and body for the github
issue, resulting in a failure due to github's validation
Fixes:
- Pass only the line containing "simulation failed:" as title
- Pass max 50 lines following title as body
- Truncate title and body to 255 and 65536 chars respectively before
posting github issue, just to be sure

Closes #1711
2025-06-11 09:45:58 +03:00
Jussi Saurio
0acce8d035 Merge 'Simulator: Better Shrinking' from Pedro Muniz
This PR attempts to get the specific query that failed in the simulator
and get the correct tables that were used in the Query. Also, implements
a fix where after clearing miscellaneous queries, we did not check again
if the the interaction still referenced any of the tables that were
involved in the failure.

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

Closes #1712
2025-06-11 09:45:48 +03:00
Jussi Saurio
4d45577c5a Merge 'Simulator integrity_check' from Pedro Muniz
Adds a Sqlite integrity check after the simulator completes a run. Also
changed error handling in the simulator to use `anyhow` to lazily add
context to error methods instead of eagerly using `.or` and losing the
original error.

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

Closes #1697
2025-06-11 09:45:38 +03:00
pedrocarlo
cf1983ccfe retain the last failing interaction + remove select properties 2025-06-11 03:14:31 -03:00
pedrocarlo
63cf648e2e filter for the tables that the failing query depended on + second pass after query clear 2025-06-11 02:52:26 -03:00
Jussi Saurio
f276ff0b72 sim/aws: fix vibecoding errors in logic
- Entire stdout+stderr was passed to both title and body for the github
  issue, resulting in a failure due to github's validation

Fixes:

- Pass only the line containing "simulation failed:" as title
- Pass max 50 lines following title as body
- Truncate title and body to 255 and 65536 chars respectively
  before posting github issue, just to be sure
2025-06-11 08:40:04 +03:00
Jussi Saurio
72058da9dc Merge 'bindings/javascript: Add pragma() support' from Anton Harniakou
This PR adds column names to the ouput of js pragma function.

Reviewed-by: Diego Reis (@el-yawd)
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1608
2025-06-10 18:24:13 +03:00
pedrocarlo
82538dbe8e add integrity_check to sim 2025-06-10 12:17:59 -03:00
Jussi Saurio
4794b022a5 Merge 'Fix incorrect handling of OR clauses in HAVING' from Jussi Saurio
thanks to @pedrocarlo for reminding me we have this old-ass bug I never
bothered to fix

Closes #1708
2025-06-10 18:14:39 +03:00
Jussi Saurio
3d50822284 Merge 'fix: Incorrect placeholder label in where clause translation' from Pedro Muniz
Closes #1705

Closes #1707
2025-06-10 18:14:04 +03:00
Jussi Saurio
85972fd744 Merge 'Fix rowid to_sql_string' from Pedro Muniz
Addresses the panic encountered here:
https://github.com/tursodatabase/limbo/pull/1690 . Sorry about that.

Closes #1693
2025-06-10 18:11:51 +03:00
Jussi Saurio
f7cc9334a8 Merge 'Remove leftover info trace' from Jussi Saurio
Closes #1704
2025-06-10 18:11:28 +03:00
pedrocarlo
0da9d65d3e test 2025-06-10 12:07:38 -03:00
Jussi Saurio
18dd87eff1 Fix incorrect handling of OR clauses in HAVING 2025-06-10 18:02:14 +03:00
pedrocarlo
80c480517a incorrect placeholder label in where clause translation 2025-06-10 12:00:19 -03:00
Jussi Saurio
ace1e02fc0 Remove leftover info trace 2025-06-10 16:51:34 +03:00
pedrocarlo
f3ef60e1f1 use anyhow in simulator for lazily evaluated error context instead of eager evaluation with .or 2025-06-10 10:50:39 -03:00
pedrocarlo
b942414bb4 add anyhow to workspace dependency 2025-06-10 10:50:39 -03:00
pedrocarlo
36f60e4dd1 Fix rowid to_sql_string printing 2025-06-10 10:48:05 -03:00
Pere Diaz Bou
a4237dbe6e Merge 'Fix incorrect usage of indexes with non-contiguous columns' from Jussi Saurio
Due to the left-prefix rule of indexes, for an index key to be usable,
it needs to:
- Use the columns in contiguous order (0, 1, 2...)
  * eg if WHERE refers to cols 0 and 2, only 0 can be used
- Stop at the first range operator
  * eg if WHERE: col1 = 5 AND col2 > 5 AND col3 = 5, only col1 and col2
can be used.
This wasn't properly tested, and resulted in simulator failures (e.g.
seed `10818913476224476676` which no longer fails with this fix). Added
some regression tests for this behavior, as well.

Reviewed-by: Preston Thorpe (@PThorpe92)
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1698
2025-06-10 15:10:25 +02:00
Jussi Saurio
547ca6cf2a Fix incorrect usage of indexes with non-contiguous columns
Due to the left-prefix rule of indexes, for an index key to be usable,
it needs to:

- Use the columns in contiguous order (0, 1, 2...)
  * eg if WHERE refers to cols 0 and 2, only 0 can be used
- Stop at the first range operator
  * eg if WHERE: col1 = 5 AND col2 > 5 AND col3 = 5, only col1 and col2
    can be used.

This wasn't properly tested, and resulted in simulator failures. Added
some regression tests for this behavior.
2025-06-10 15:21:26 +03:00
Pere Diaz Bou
9770ffb902 Merge 'BTree traversal refactor and bugfixes' from Pere Diaz Bou
The major change in this PR is the following:
- It refactors deserializing the record from the cell so that it does
not happen in `next()` or `prev()`, but lazily when it is needed. This
will allow a further enhancement where we only read a _partial_ section
of the record payload, e.g. when `Insn::Column` is requested by the
VDBE, we can only deserialize the relevant column.
It also fixes multiple bugs in `BTreeCursor`
Follow-ups:
ASAP: fix performance regression (probably due to too much record
invalidation)
ASAP: do post-balance seek key calculation only when balance will be
needed
ASAP: fix balancing scenario where interior index cell is deleted - even
if leaf doesnt require balance, parent might. both need to be checked
LATER: implement safe way to use indexes for UPDATE -- ephemeral indexes
needed, see FIXME in `optimizer/mod.rs`
LATER: implement on-demand serialization of parts of the record, instead
of entire record

Closes #1664
2025-06-10 13:38:20 +02:00
Jussi Saurio
f8df870fb7 Fix implementation of InteriorNodeReplacement(interior index cell being deleted) 2025-06-10 14:16:26 +03:00
Jussi Saurio
6d2ca58235 get_prev_record() small fixes 2025-06-10 14:16:26 +03:00
Jussi Saurio
07c947b47d use GE for idx delete seek, although it doesnt really matter 2025-06-10 14:16:26 +03:00
Jussi Saurio
9caa8334be add FIXME about balance after interior node replacement 2025-06-10 14:16:26 +03:00
Jussi Saurio
10caca25c9 advance in balance_non_root() if -1 idx 2025-06-10 14:16:26 +03:00
Jussi Saurio
d827eeade0 For now always calculate post-balance seek key 2025-06-10 14:16:26 +03:00
Jussi Saurio
976c2f72ef OpIdxDeleteState needs another state to be re-entrant 2025-06-10 14:16:26 +03:00
Jussi Saurio
58172641fd Use SeekOP:LT after post-deletebalancing to end up pointing to the left of the deleted row 2025-06-10 14:16:26 +03:00
Jussi Saurio
e1bc268a65 fix CREATE TABLE hang 2025-06-10 14:16:26 +03:00
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