Pekka Enberg
a4d9f70ef8
Merge 'Strict table support' from Ihor Andrianov
...
Closes #884
Support for
```CREATE TABLE test(id INTEGER) STRICT;```
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com >
Closes #1268
2025-04-09 16:45:56 +03:00
PThorpe92
224f913ae7
Handle composite key indexes on insert
2025-04-08 08:55:14 -04:00
PThorpe92
1f29307fe8
Support proper index handling when doing insertions
2025-04-08 08:55:14 -04:00
Ihor Andrianov
4a08b98bab
implemented strict table
2025-04-07 20:01:39 +03: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:

Creating a unique index on a column that has 2 existing identical rows:

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
PThorpe92
c9edf71fb8
Support insert default values syntax
2025-04-05 21:27:21 -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
Diego Reis
43daba9942
core/translate: Add support for default values in INSERT statements
2025-04-04 01:32:13 -03:00
PThorpe92
38e54ca85e
Update schema dot command to show virtual tables
2025-02-17 20:44:45 -05:00
PThorpe92
8b5772fe1c
Implement VUpdate (insert/delete for virtual tables
2025-02-17 20:44:44 -05:00
PThorpe92
9c8083231c
Implement create virtual table and VUpdate opcode
2025-02-17 20:44:44 -05:00
Pekka Enberg
ac54c35f92
Switch to workspace dependencies
...
...makes it easier to specify a version, which is needed for `cargo publish`.
2025-02-12 17:28:04 +02:00
Pekka Enberg
6ea7fa06d2
Merge 'prepare perf: make ProgramBuilder aware of plan to count/estimate required memory' from Jussi Saurio
...
Use knowledge of query plan to inform how much memory to initially
allocate for `ProgramBuilder` vectors
Some of them are exact, some are semi-random estimates
```sql
Prepare `SELECT 1`/Limbo/SELECT 1
time: [756.93 ns 758.11 ns 759.59 ns]
change: [-4.5974% -4.3153% -4.0393%] (p = 0.00 < 0.05)
Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
2 (2.00%) low severe
1 (1.00%) low mild
3 (3.00%) high mild
1 (1.00%) high severe
Prepare `SELECT * FROM users LIMIT 1`/Limbo/SELECT * FROM users LIMIT 1
time: [1.4739 µs 1.4769 µs 1.4800 µs]
change: [-7.9364% -7.7171% -7.4979%] (p = 0.00 < 0.05)
Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild
Prepare `SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1) > 1 ORDER BY cou...`
time: [3.7440 µs 3.7520 µs 3.7596 µs]
change: [-5.4627% -5.1578% -4.8445%] (p = 0.00 < 0.05)
Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high severe
```
Closes #899
2025-02-05 18:24:16 +02:00
Jussi Saurio
795576b2ec
dont eagerly allocate result column name strings
2025-02-05 17:53:23 +02:00
Jussi Saurio
f599b5a752
Make programbuilder aware of plan to count/estimate required memory
2025-02-05 14:22:42 +02:00
Jorge López
2cc8cb9ad8
syntactic changes: use assert_eq!() instead of assert!() for equality comparisons
2025-01-18 18:37:50 +01:00
Levy A.
2f2c96fa2c
chore: cargo fmt
2025-01-13 21:31:33 -03:00
Levy A.
eff5de50c5
refactor: make translate_* functions accept ProgramBuilder
...
simplifies function signatures and allows attaching more context to
ProgramStatus on `translate::translate`, useful for query parameters.
2025-01-13 20:41:56 -03:00
Jussi Saurio
9909539b9d
Store cursor type (table,index,pseudo,sorter) when allocating cursor
2025-01-11 17:04:16 +02:00
Jussi Saurio
731ff1480f
Simplify working with labels
...
TLDR: no need to call either of:
program.emit_insn_with_label_dependency() -> just call program.emit_insn()
program.defer_label_resolution() -> just call program.resolve_label()
Changes:
- make BranchOffset an explicit enum (Label, Offset, Placeholder)
- remove program.emit_insn_with_label_dependency() - label dependency is automatically detected
- for label to offset mapping, use a hashmap from label(negative i32) to offset (positive u32)
- resolve all labels in program.build()
- remove program.defer_label_resolution() - all labels are resolved in build()
2025-01-07 12:53:10 +02:00
Jussi Saurio
f434b24e63
Fix limbo/core to work with new boxed ast types
2025-01-05 13:51:34 +02:00
Jussi Saurio
d1f74fa3cb
Emitter cleanup part 2: add Resolver
2025-01-04 12:23:19 +02:00
Pekka Enberg
33dbd6c892
core: External functions
2024-12-31 13:56:32 +02:00
Pekka Enberg
dad3a5b069
core/translate: Move translate_insert() to top
...
The translate_insert() function is the entry point to translating an
INSERT statement so let's make it the first function in insert.rs.
2024-12-31 11:33:17 +02:00
Lauri Virtanen
854005b977
Run cargo clippy --fix && cargo fmt
2024-12-29 19:22:28 +02:00
PThorpe92
f6cd707544
Add clippy CI, fix or ignore warnings where appropriate
2024-12-29 10:25:41 -05:00
jussisaurio
c4e2a344ae
parse error instead of assert! for unsupported features
2024-12-25 21:14:58 +02:00
jussisaurio
050b8744ea
Dont use coroutine when inserting a single row
2024-12-25 21:14:58 +02:00
jussisaurio
c78a3e952a
clean up implementation
2024-12-25 21:14:58 +02:00
jussisaurio
51541dd8dc
fix issues with insert
2024-12-25 21:14:08 +02:00
jussisaurio
885b6ecd76
Remove 'cursor_hint': it is never needed
2024-11-26 17:31:51 +02:00
jussisaurio
cc902ed25d
GROUP BY and ORDER BY mostly work
2024-11-26 17:31:51 +02:00
jussisaurio
3f9e60633f
select refactor: order by and basic agg kinda work
2024-11-26 17:31:51 +02:00
Pere Diaz Bou
c0e51c4ca6
wip wal
2024-11-05 15:29:53 +01:00
jussisaurio
f02da18acd
index scan wip foo doesnt work yet
2024-10-05 18:25:04 +03:00
Pekka Enberg
b67640c437
Merge 'core: constraint check uniqueness' from Pere Diaz Bou
...
```bash
limbo> insert into products values (1, 'asdf', 432);
Runtime error: UNIQUE constraint failed: products.id (19)
```
Closes #336
2024-09-20 13:27:10 +03:00
Pere Diaz Bou
c8e5673f7a
core: constraint check uniqueness
2024-09-20 11:45:55 +02:00
김선우
28884181be
Fix clippy
2024-09-15 16:23:27 +09:00
jussisaurio
a108dea825
GROUP BY
2024-09-14 16:14:45 +03:00
gandeevanr
23a7d389b1
added unit tests for NewRowid
2024-08-08 19:04:10 -07:00
gandeevanr
a9cb8157b5
initial pass at implementing NewRowId
2024-08-07 09:04:09 -07:00
gandeevanr
2b86f89d8d
use the correct integer PK column idx as the row-id alias
2024-08-04 18:53:54 -07:00
sonhmai
0e7bd95e4e
core: fix clippy
2024-08-03 20:14:26 +07:00
Pekka Enberg
f8a43361db
core: Move pager.rs to storage module
2024-08-01 11:52:50 +03:00
Pere Diaz Bou
84bf0ea96a
core: remove a bunch of warnings
...
Signed-off-by: Pere Diaz Bou <pere-altea@hotmail.com >
2024-07-31 17:27:02 +02:00
Pere Diaz Bou
7846a3b29c
core: fix calculation of record header size varint
2024-07-31 17:27:02 +02:00
Pere Diaz Bou
e6f8b34f2b
core: insert_to_page almost complete
2024-07-31 17:27:02 +02:00
Pere Diaz Bou
a09f3485f9
core: fix op generation
2024-07-31 17:27:02 +02:00
Pere Diaz Bou
6357e88b46
core: implement vdbe opcodes minus newrowid
2024-07-31 17:25:01 +02:00