Commit Graph

3778 Commits

Author SHA1 Message Date
Pere Diaz Bou
40f8bbe132 clippy 2025-04-08 11:31:38 +02:00
Pere Diaz Bou
8e88b0cd14 new_page_sizes as Vec<i64> 2025-04-08 11:31:38 +02:00
Pere Diaz Bou
3950ab1e52 account for divider cell size in page size 2025-04-08 11:31:38 +02:00
Pere Diaz Bou
f7de575873 Merge 'update sqlite download version to 2025 + remove www.' from Pere Diaz Bou
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1271
2025-04-08 11:30:53 +02:00
Pere Diaz Bou
b83b51e973 remove www. prefix 2025-04-08 11:16:32 +02:00
Pere Diaz Bou
03f531417c update sqlite download version to 2025 2025-04-08 11:12:20 +02:00
Pekka Enberg
33afc7cef3 Merge 'Improve validation of btree balancing' from Pere Diaz Bou
This pr sprinkles debug compile check to ensure things stay in a
reliable state.

Closes #1261
2025-04-07 19:35:00 +03:00
Pere Diaz Bou
6086284613 fix debug imports 2025-04-07 18:06:52 +02:00
Pere Diaz Bou
83f13596a4 decrease fuzz test steps again 2025-04-07 18:01:08 +02:00
Pere Diaz Bou
f137ddfdf8 add loop left pointer validation 2025-04-07 18:01:08 +02:00
Pere Diaz Bou
6ac2368ae2 update divider cell that is being balanced 2025-04-07 18:00:49 +02:00
Pere Diaz Bou
0541da46df add strict btree validation after non root balancing in debug mode 2025-04-07 18:00:49 +02:00
Pere Diaz Bou
ff8ec5455c fix divider cell selection 2025-04-07 18:00:30 +02:00
Pere Diaz Bou
9eb9e7021e Fix index table new divider cell pointer 2025-04-07 18:00:30 +02:00
Pere Diaz Bou
f4920cb96b assert new divider cell points to the correct place 2025-04-07 18:00:30 +02:00
Pere Diaz Bou
15ed7642c9 check all keys are present on every insert with fuzz test
Let's make sure every insert does still contain all keys. Previously we
did this at the end but it made it hard to debug issues that
`validate_btree` might not encounter.
2025-04-07 18:00:30 +02:00
Pekka Enberg
96ed7c5982 Merge 'Remainder fixes' from jachewz
This PR should close two related issues:
## 1. Remainder operand with lhs as text
Before:
```
limbo> SELECT 10 % '3';
┌──────────┐
│ 10 % '3' │
├──────────┤
│        3 │
└──────────┘
```
sqlite:
```
sqlite> SELECT 10 % '3';
1
```
After:
```
limbo> SELECT 10 % '3';
┌──────────┐
│ 10 % '3' │
├──────────┤
│        1 │
└──────────┘
```
## Overflow when min int64 % -1
Before:
```
limbo> SELECT -9223372036854775808 % -1;
thread 'main' panicked at core/vdbe/insn.rs:974:37:
attempt to calculate the remainder with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
sqlite:
```
sqlite> SELECT -9223372036854775808 % -1;
0
```
After:
```
limbo> SELECT -9223372036854775808 % -1;
┌─────────────────────────────┐
│ - 9223372036854775808 % - 1 │
├─────────────────────────────┤
│                           0 │
└─────────────────────────────┘
```
Tests for these cases are also added, and the `%` operator tests in
`math.test` were renamed to `remainder-` instead of `mod-` to
differentiate from tests for the `mod()` function.
Closes #1172

Closes #1267
2025-04-07 17:22:15 +03:00
jachewz
ebf467d04e rename math.test % operator tests from mod- to remainder- 2025-04-07 22:03:48 +10:00
jachewz
db15661b7e fix: i64 % -1 overflow panic 2025-04-07 22:03:48 +10:00
jachewz
a72b75e193 fix: remainder operator rhs text 2025-04-07 22:03:48 +10:00
Pekka Enberg
3a1b87eb21 Update README.md 2025-04-07 09:02:55 +03:00
Pekka Enberg
4ca8efac0d Merge 'Added 'Likely' Scalar Function' from Duncan Lutz
This patch implements the "likely(x)" scalar function, which simply
returns the original value provided to it as it's result.

Closes #1266
2025-04-07 08:52:38 +03:00
Duncan Lutz
aa7c64cb19 feat: added likely scalar function 2025-04-06 23:14:30 -06:00
Pekka Enberg
6eb89ca2a1 Merge 'Add deterministic Clock' from Avinash Sajjanshetty
Fixes #603
This patch adds a `Clock` trait whose member function `now` returns an
`Instant`. Now in sim, we can nicely make the clock deterministic.
The earlier method `get_current_time` returned `chrono::Local::now()`.
The `Instant` returned by `now` carries the same information.

Closes #1263
2025-04-06 23:27:36 +03:00
Avinash Sajjanshetty
3543e83b91 Impl Clock trait in bindings 2025-04-06 23:34:15 +05:30
Avinash Sajjanshetty
2873c36b31 Implement trait Clock for implemented IOs
Replace `chrono::Local::now()` to return `Instant` but containing
same info
2025-04-06 23:34:13 +05:30
Avinash Sajjanshetty
8d6d50d9d5 Update IO trait
- Remove existing `get_current_time() -> String`
- Add super trait bound `Clock`
2025-04-06 23:06:57 +05:30
Avinash Sajjanshetty
02ee2cf90e Add Clock trait 2025-04-06 23:02:41 +05:30
Jussi Saurio
c19e4fc69c Merge 'Aggregation without group by produces incorrect results for scalars' from Ihor Andrianov
Closes #954
Before:
<img width="669" alt="Знімок екрана 2025-03-27 о 21 49 19"
src="https://github.com/user-
attachments/assets/d005e690-7dab-41e5-bc03-b574cade3965" />
After:
<img width="676" alt="Знімок екрана 2025-03-27 о 21 49 44"
src="https://github.com/user-
attachments/assets/1f4eb6bf-a238-496e-9fa4-32382799ef86" />
SQLite:
<img width="656" alt="Знімок екрана 2025-03-27 о 21 50 04"
src="https://github.com/user-
attachments/assets/3eca184e-6ea5-47c1-824f-51d11256a7af" />

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1198
2025-04-06 20:00:30 +03:00
Pekka Enberg
2202fcdbe4 Merge 'Dot command completion' from Pedro Muniz
Closes #1201.
![cli](https://github.com/user-
attachments/assets/343bb27a-891e-4bb2-91f2-1d446979ac43)

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1253
2025-04-06 19:37:43 +03:00
Pekka Enberg
400ebe6b60 Merge 'Support offset clause in Update queries ' from Preston Thorpe
Closes #1245

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

Closes #1252
2025-04-06 19:37:18 +03:00
Preston Thorpe
62e0a137dd Merge branch 'main' into update_offset 2025-04-06 12:34:23 -04:00
Pekka Enberg
2d3fd01f91 Merge 'Support Create Index' from Preston Thorpe
Closes #1193
```console
│limbo> explain create index idxp on products(price);
│addr  opcode             p1    p2    p3    p4             p5  comment
│----  -----------------  ----  ----  ----  -------------  --  -------
│0     Init               0     39    0                    0   Start at 39
│1     CreateBtree        0     1     2                    0   r[1]=root iDb=0 flags=2
│2     OpenWriteAsync     0     1     0                    0
│3     OpenWriteAwait     0     0     0                    0
│4     NewRowId           0     2     0                    0
│5     String8            0     3     0     index          0   r[3]='index'
│6     String8            0     4     0     idxp           0   r[4]='idxp'
│7     String8            0     5     0     products       0   r[5]='products'
│8     Copy               1     6     1                    0   r[6]=r[1]
│9     String8            0     7     0     CREATE INDEX idxp ON products (price)  0   r[7]='CREATE INDEX idxp ON products (price)'
│10    MakeRecord         3     5     8                    0   r[8]=mkrec(r[3..7])
│11    InsertAsync        0     8     2                    0
│12    InsertAwait        0     0     0                    0
│13    SorterOpen         3     1     0     k(1,B)         0   cursor=3
│14    OpenPseudo         4     9     2                    0   2 columns in r[9]
│15    OpenReadAsync      2     273   0                    0   table=products, root=273
│16    OpenReadAwait      0     0     0                    0
│17    RewindAsync        2     0     0                    0
│18    RewindAwait        2     25    0                    0   Rewind table products
│19      Column           2     2     10                   0   r[10]=products.price
│20      RowId            2     11    0                    0   r[11]=products.rowid
│21      MakeRecord       10    2     12                   0   r[12]=mkrec(r[10..11])
│22      SorterInsert     3     12    0     0              0   key=r[12]
│23    NextAsync          2     0     0                    0
│24    NextAwait          2     19    0                    0
│25    OpenWriteAsync     1     1     0                    0
│26    OpenWriteAwait     0     0     0                    0
│27    SorterSort         3     33    0                    0
│28      SorterData       3     13    4                    0   r[13]=data
│29      SeekEnd          1     0     0                    0
│30      IdxInsertAsync   1     13    0                    0   key=r[13]
│31      IdxInsertAwait   1     0     0                    0
│32    SorterNext         3     28    0                    0
│33    Close              3     0     0                    0
│34    Close              2     0     0                    0
│35    Close              1     0     0                    0
│36    ParseSchema        0     0     0     name = 'idxp' AND type = 'index'  0   name = 'idxp' AND type = 'index'
│37    Close              0     0     0                    0
│38    Halt               0     0     0                    0
│39    Transaction        0     1     0                    0   write=true
│40    Goto               0     1     0                    0
```
This will create the initial index btree and insert whatever relevant
records that need to be inserted, it doesn't handle the case of
inserting new index keys when normal records are created afterwards.
That will prob be added in next PR to keep this one concise.
Limbo will properly use the index in a subsequent query:
![image](https://github.com/user-
attachments/assets/eb41e985-4a70-49a5-8218-62c25e4d16c5)
Creating a unique index on a column that has 2 existing identical rows:
![image](https://github.com/user-
attachments/assets/ea46c720-5235-4451-81f0-25497ed9ee92)

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1199
2025-04-06 19:32:36 +03:00
Pekka Enberg
e3c064fc47 Merge 'Allow reading altered tables by defaulting to null in Column insn' from Preston Thorpe
Closes #1259

Closes #1260
2025-04-06 13:33:16 +03:00
Pekka Enberg
c04ce28070 Merge 'Support insert default values syntax' from Preston Thorpe
`INSERT INTO products DEFAULT VALUES` previously wasn't supported. Quick
and easy

Closes #1262
2025-04-06 10:23:21 +03:00
PThorpe92
ff482fc753 Add test case for insert default values 2025-04-05 21:34:27 -04:00
PThorpe92
c9edf71fb8 Support insert default values syntax 2025-04-05 21:27:21 -04:00
PThorpe92
67eda10453 Allow reading altered tables by defaulting to null in Column insn 2025-04-05 16:19:56 -04:00
PThorpe92
83af71f140 Return accidentally deleted comment on SeekGE insn from merge conflict 2025-04-05 11:30:57 -04:00
PThorpe92
399994bf66 Fix ext tests start with no default schema 2025-04-05 11:19:40 -04:00
PThorpe92
bd04b10f17 Fix btree tests to adapt to new type for BTreeKey 2025-04-05 11:19:10 -04:00
PThorpe92
abc97c8774 Add doc comments to new btree key enum and remove unused lifetimes 2025-04-05 11:19:10 -04:00
PThorpe92
6b42808f1a Dont re-seek if we are inserting a new unique index 2025-04-05 11:19:10 -04:00
PThorpe92
a2b9d8d371 Use Correct flag on idx insert to prevent seeking 2025-04-05 11:19:09 -04:00
PThorpe92
068ab4ab27 Refactor btree to reuse existing insert and seek with idx keys 2025-04-05 11:19:09 -04:00
PThorpe92
007fbe8cc7 Fix unique index issue and prealloc in sql string for schema 2025-04-05 11:19:09 -04:00
PThorpe92
2c3fd509fe Remove unused imports and consolidate ordering comparison 2025-04-05 11:19:09 -04:00
PThorpe92
e020ba3dfe Add enum for interpreting a value as a register or literal for insns 2025-04-05 11:19:07 -04:00
PThorpe92
b0016a0ee2 Support create index with SeekEnd and IdxCreate opcode functionality 2025-04-05 11:15:36 -04:00
PThorpe92
45a8e5e226 Add close_cursors helper method to program builder 2025-04-05 11:06:18 -04:00