Commit Graph

805 Commits

Author SHA1 Message Date
mazchew
671b61ba19 add time querying to io trait 2024-08-25 22:55:15 +08:00
Pekka Enberg
84ed081f19 Merge 'Added random number generation to I/O trait for simulation' from mason
Took a stab at the RNG portion of this [issue](https://github.com/penberg/limbo/issues/272), do let me know if there's anything that I can improve on/rework!

Thanks!

Closes #301
2024-08-22 18:43:01 +03:00
mazchew
156005694a added rng to io trait for simulation 2024-08-22 23:24:02 +08:00
Pekka Enberg
d11dd9d06c cargo dist: Disable static library installation
Looks to be broke on Windows:

https://github.com/axodotdev/cargo-dist/issues/1356
2024-08-22 18:06:36 +03:00
Pekka Enberg
6e8a1117fe sqlite3: Format source code with cargo fmt 2024-08-22 17:54:25 +03:00
Pekka Enberg
c69b2ab4f6 sqlite3: Fix LFS feature flag 2024-08-22 17:53:07 +03:00
Pekka Enberg
b1f508db87 Limbo 0.0.4 2024-08-22 17:44:28 +03:00
Pekka Enberg
51eebb8ea5 Merge 'Add support for nullif scalar function' from Kim Seon Woo
### EXPLAIN nullif(1,2)
<img width="1339" alt="image" src="https://github.com/user-attachments/assets/08230797-914d-4922-b52c-5b2b2b4c2a12">

### Issue
https://github.com/penberg/limbo/issues/144

Closes #299
2024-08-20 20:47:35 +03:00
Kim Seon Woo
8f617dd394 Apply fmt 2024-08-20 18:44:06 +02:00
Kim Seon Woo
8bb2a48cb6 Add support for nullif scalar function 2024-08-20 18:36:06 +02:00
Pekka Enberg
87ff71152a Merge 'Fix INSERT to empty tables panic' from Kim Seon Woo
`page` from `let page = page.borrow()` lives while `write_complete` is running.

Ensure that `page` is dropped

https://github.com/penberg/limbo/issues/257

Closes #293
2024-08-19 07:35:26 +03:00
Kim Seon Woo
9d878fda55 Remove failing test for now 2024-08-18 21:05:01 +02:00
Kim Seon Woo
a95fcc0fc1 Fix test to check whether error message is included 2024-08-18 21:00:37 +02:00
Kim Seon Woo
98f32b6182 Remove database.db 2024-08-18 21:00:37 +02:00
Kim Seon Woo
c6402aa341 Add tcl 2024-08-18 21:00:36 +02:00
Kim Seon Woo
78817d3804 Fix insert error 2024-08-18 21:00:03 +02:00
Kim Seon Woo
f406481849 Explain why it fails 2024-08-18 21:00:03 +02:00
Pekka Enberg
9404a561a9 Merge 'core: pretty-print EXPLAIN QUERY PLAN' from Piotr Sarna
Mimics SQLite's EXPLAIN QUERY PLAN pretty printer.

Example run on a preexisting db:
```
$ cargo run /tmp/srn "explain query plan select * from t natural join t join t2 on t.id = 2*t2.id where t.id in (select * from t);"
QUERY PLAN
`--JOIN ON t.id = 2 * t2.id
   |--JOIN
   |  |--SCAN t FILTER t.id IN (SELECT * FROM t)
   |  `--SCAN t
   `--SCAN t2

```

Fixes https://github.com/penberg/limbo/issues/295

Closes #296
2024-08-18 21:34:16 +03:00
Piotr Sarna
d8002ff03c core: pretty-print EXPLAIN QUERY PLAN
Mimics SQLite's EXPLAIN QUERY PLAN pretty printer.

Example run on a preexisting db:
```
$ cargo run /tmp/srn "explain query plan select * from t natural join t join t2 on t.id = 2*t2.id where t.id in (select * from t);"
QUERY PLAN
`--JOIN ON t.id = 2 * t2.id
   |--JOIN
   |  |--SCAN t FILTER t.id IN (SELECT * FROM t)
   |  `--SCAN t
   `--SCAN t2

```

Fixes https://github.com/penberg/limbo/issues/295
2024-08-18 20:11:19 +02:00
Pekka Enberg
ef30fe27d3 Update CHANGELOG 2024-08-18 16:37:06 +03:00
Pekka Enberg
edf0f754f6 Merge 'More structured query planner' from Jussi Saurio
Reader's guide to this PR:

The aim is to have a more structured and maintainable approach to generating bytecode from the query AST so that different parts of the query processing pipeline have clearer responsibilities, so that developing new functionality is easier. E.g.:

- If you want to implement join reordering -> you do it in `Optimizer`
- If you want to implement `GROUP BY` -> you change `QueryPlanNode::Aggregate` to include it, parse it in `Planner` and handle the code generation for it in `Emitter`

The pipeline is:

`SQL text -> Parser -> Planner -> Optimizer -> Emitter`

and this pipeline generates:

`SQL text -> AST -> Logical Plan -> Optimized Logical Plan -> SQLite Bytecode`

---

Module structure:

`plan.rs`: defines the `Operator` enum. An `Operator` is a tree of other `Operators`, e.g. an `Operator::Join` has `left` and `right` children, etc.

`planner.rs`: Parses an `ast::Select` into a `Plan` which is mainly a wrapper for a root `Operator`

`optimizer.rs`: Makes a new `Plan` from an input `Plan` - does predicate pushdown, constant elimination and turns `Scan` nodes into `SeekRowId` nodes where applicable

`emitter.rs`: Generates bytecode instructions from an input `Plan`.

---

Adds feature `EXPLAIN QUERY PLAN <stmt>` which shows the logical query plan instead of the bytecode plan

---

Other changes:

- Almost everything from `select.rs` removed; things like `translate_aggregation()` moved to `expr.rs`
- `where_clause.rs` removed, some things from it like `translate_condition_expr()` moved to `expr.rs`
- i.e.: there is nothing _new_ in `expr.rs`, stuff just moved there

---

Concerns:

- Perf impact: there's a lot more indirection than before (`Operator`s are very "traditional" trees where they refer to other operators via Boxes etc)

Closes #281
2024-08-18 16:36:51 +03:00
Pekka Enberg
68357ccb55 Update CHANGELOG 2024-08-18 15:53:24 +03:00
Pekka Enberg
9654840e64 Merge 'Add support for quote scalar function' from Jean Arhancet
Add support for quote scalar function. Related issue: #144

Closes #294
2024-08-18 15:53:09 +03:00
jussisaurio
a79c0c5b34 BytecodeGenerator struct was unnecessary 2024-08-17 14:35:44 +03:00
jussisaurio
2b71a5802d tweak 2024-08-17 14:24:20 +03:00
jussisaurio
b7fbe57ca7 Move translate_table_columns to expr.rs 2024-08-17 14:16:56 +03:00
jussisaurio
05a6616803 BytecodeGenerator struct 2024-08-17 14:12:57 +03:00
jussisaurio
d7d195a618 Cleanup and improve emitter.rs docs 2024-08-17 13:56:59 +03:00
jussisaurio
e8c894e532 More flexible Emitter via stateful operators 2024-08-17 12:55:16 +03:00
JeanArhancet
b6c720c90a feat: add quote function 2024-08-17 09:28:14 +02:00
jussisaurio
d70eb6b3d7 fix seekrowid operator not emitting result when root 2024-08-17 09:16:24 +03:00
jussisaurio
69f549d2b9 remove unnecessary unwrap_or 2024-08-17 09:07:29 +03:00
jussisaurio
2e7f240bb5 use table_columns() for seekrowid result_columns() 2024-08-17 09:04:27 +03:00
jussisaurio
25033d280c more accurate variable name 2024-08-16 19:58:59 +03:00
jussisaurio
17cc3717c8 rebase 2024-08-16 19:43:29 +03:00
jussisaurio
069826820e Finish renaming node -> operator 2024-08-16 19:42:03 +03:00
jussisaurio
97dc98336c fix comment 2024-08-16 19:42:03 +03:00
jussisaurio
e7cc04e157 Operator comments 2024-08-16 19:42:03 +03:00
jussisaurio
4c016b042b comment about bitmasks 2024-08-16 19:42:03 +03:00
jussisaurio
1130ccf203 mutable out parameter 2024-08-16 19:42:03 +03:00
jussisaurio
2d35641b86 whitespace 2024-08-16 19:42:03 +03:00
jussisaurio
989066eedf remove duplicate test after rebase 2024-08-16 19:42:03 +03:00
jussisaurio
9ab08ee2e6 is_rowid_alias instead of primary_key 2024-08-16 19:42:03 +03:00
jussisaurio
2e32ca0bdb More structured query planner 2024-08-16 19:42:03 +03:00
Pekka Enberg
c2944f6eeb Merge 'Add support for concat scalar function' from Kim Seon Woo
Add support for concat scalar function

### EXPLAIN SELECT concat('a', 1.5, 'b')
![image](https://github.com/user-attachments/assets/628e0e81-91bc-4533-9091-ded99dd20e0e)

## Related issue
https://github.com/penberg/limbo/issues/144

Closes #291
2024-08-16 16:37:38 +03:00
Kim Seon Woo
48d3c05fb0 Rebase 2024-08-16 21:40:30 +09:00
Pekka Enberg
a5bdfb62b8 Bump cargo-dist to 0.21.0 2024-08-16 14:42:24 +03:00
Pekka Enberg
cad0cd66d0 Update CHANGELOG.md 2024-08-16 14:38:53 +03:00
Pekka Enberg
c9c0d2808c Merge 'Add support for ifnull scalar function' from Kim Seon Woo
Add support for `ifnull` scalar function

### EXPLAIN SELECT ifnull(null, 20);
![image](https://github.com/user-attachments/assets/e367638f-9d70-4dfc-989d-7290b842c2ec)

### Related issue
https://github.com/penberg/limbo/issues/144

Closes #290
2024-08-16 14:37:08 +03:00
Pekka Enberg
ba3acedbc8 Merge 'Add support for substr scalar function' from Kim Seon Woo
Add support for `substr` scalar function. We can reuse the `substring` logic which is already implemted.

## Related issue
https://github.com/penberg/limbo/issues/144

Closes #289
2024-08-16 14:36:55 +03:00