Commit Graph

152 Commits

Author SHA1 Message Date
jussisaurio
db0e2ea54f Change another compat test to work around sqlite's weird choice to use the age index 2024-10-05 18:25:04 +03:00
jussisaurio
d8a695a991 rename tests 2024-10-05 18:25:04 +03:00
jussisaurio
43015f6949 Workaround for compat test 2024-10-05 18:25:04 +03:00
jussisaurio
02d6fa31d3 Fix .schema users not displaying indexes on the users table 2024-10-05 18:25:04 +03:00
jussisaurio
3a11887122 fixerinos 2024-10-05 18:25:04 +03:00
jussisaurio
ed19f47762 fix 2024-10-05 18:25:04 +03:00
jussisaurio
ff236c7781 Fix not advancing the cell index of pages 2024-10-05 18:25:04 +03:00
jussisaurio
3d56fbd91c stuff 2024-10-05 18:25:04 +03:00
jussisaurio
f02da18acd index scan wip foo doesnt work yet 2024-10-05 18:25:04 +03:00
Lauri Virtanen
9e80a0c4a8 Add randomblob(N) scalar function
Relates to issue #144
2024-10-03 00:05:23 +03:00
Pekka Enberg
6fcd818160 Merge 'Add unhex(X) scalar function' from Lauri Virtanen
This commit adds `unhex(X)` scalar function. Function with `unhex(X,Y)`
two arguments is not implemented yet.
Relates to issue #144

Closes #353
2024-10-02 11:01:15 +03:00
Lauri Virtanen
adc6f9b6cd Add unhex(X) scalar function
This commit adds `unhex(X)` scalar function. Function with `unhex(X,Y)`
two arguments is not implemented yet.

Relates to issue #144
2024-09-30 00:13:43 +03:00
Lauri Virtanen
f612ead8a3 Add zeroblob(N) scalar function
Relates to issue #144
2024-09-29 23:39:53 +03:00
JeanArhancet
222fea9cc8 fix: cmp number/text 2024-09-25 17:39:37 +02:00
Lauri Virtanen
0597c048fc Better support for BLOBs
- Limbo command line shell supports e.g. `SELECT x'616263';`
- `EXPLAIN SELECT x'616263';` lists the opcode

Missing:

- Command line shell not entirely compatible with SQLite when blobs have
  non-printable characters in the middle (e.g. `SELECT x'610062';`)
- Python bindings not supported (incoming soon)
2024-09-22 17:55:00 +03:00
baishen
5c00c576a5 Add support for hex scalar function 2024-09-22 08:50:08 -04:00
김선우
910c69aaef Remove unused tcl proc 2024-09-22 08:43:50 -04:00
jussisaurio
c738674c5d Merge 'fix: cmp integer/float' from Jean Arhancet
Closes https://github.com/penberg/limbo/issues/339

Reviewed-by: Lauri Virtanen <pere-altea@hotmail.com>

Closes #340
2024-09-21 18:06:04 +03:00
JeanArhancet
41c1708ee7 fix: cmp integer/float 2024-09-21 16:10:42 +02:00
Lauri Virtanen
67573e12e5 Add typeof(X) scalar function 2024-09-21 15:56:29 +03:00
김선우
eb55b7379c Fix failing test 2024-09-21 16:12:10 +09:00
김선우
bbd1eea9ae Add support for parenthesized conditions 2024-09-21 16:03:49 +09:00
Pekka Enberg
e364d10d9a Merge 'Implementation of scalar function glob() and GLOB operator' from RJ Barman
Related to #144
- Separates `glob` and `like` regex caches, since the same pattern would
result in a different regex depending on which rules you apply
- Also fixes the value of `constant_mask` when translating LIKE
expressions now that non-constant pattern values are supported.
Note that LIKE and GLOB are almost entirely the same, the only
difference being the matching rules (so in our case, the regex
construction).

Closes #334
2024-09-18 09:44:51 +03:00
rjhallsted
af09f0b7f4 Add testing 2024-09-16 16:18:26 -07:00
rjhallsted
f39dc534a6 add glob execution 2024-09-16 16:12:53 -07:00
rjhallsted
4aaa0b0989 Make LIKE expressions case-insensitive 2024-09-16 14:43:39 -07:00
Pekka Enberg
9bbfdab5fa Revert "Merge 'Add support for sqlite_version() scalar function' from Kim Seon Woo"
This reverts commit e365c12ce0, reversing
changes made to 21bd1a961e. The pull request broke some tests:

```
thread 'main' panicked at core/vdbe/mod.rs:1713:72:
index out of bounds: the len is 3 but the index is 3
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    while executing
"exec {*}$command"
    (procedure "evaluate_sql" line 3)
    invoked from within
"evaluate_sql $sqlite_exec $sql"
    (procedure "run_test" line 2)
    invoked from within
"run_test $::sqlite_exec $combined_sql $combined_expected_output"
    (procedure "do_execsql_test" line 5)
    invoked from within
"do_execsql_test sqlite_version {
  SELECT sqlite_version();
} {3.46.1}"
    (file "./testing/scalar-functions.test" line 434)
    invoked from within
"source $testdir/scalar-functions.test"
    (file "./testing/all.test" line 16)
make: *** [Makefile:59: test-compat] Error 1
```
2024-09-16 14:28:18 +03:00
Pekka Enberg
e365c12ce0 Merge 'Add support for sqlite_version() scalar function' from Kim Seon Woo
### sqlite
<img width="792" alt="image" src="https://github.com/user-
attachments/assets/1a9238db-d948-4583-a808-f9adfec7c534">
### limbo
<img width="809" alt="image" src="https://github.com/user-
attachments/assets/ea3e5f7e-bb3e-450d-be34-59ca00128beb">
### Changes
- Add support for `sqlite_version()` function
- Update function's explain message depending on the number of arguments

Closes #331
2024-09-16 14:18:19 +03:00
Pekka Enberg
21bd1a961e Merge 'Fix three issues with LIKE operator (#319)' from Jussi Saurio
Closes #319
1. Allow using a column as the pattern
2. Construct LIKE regexes with `^` and `$` so that eg the string
`'foobar'` does not match the pattern `'fooba'` unless the pattern
specifically has a wildcard
3. Support function expressions as the LIKE pattern

Closes #327
2024-09-16 14:17:48 +03:00
Pekka Enberg
95987f9824 Merge 'Support grouping by a function expression' from Jussi Saurio
Closes #326
2024-09-16 14:17:03 +03:00
김선우
6b40acabbc Add support for sqlite_version() scalar function 2024-09-16 18:38:42 +09:00
JeanArhancet
d03a734f21 feat: add sign function 2024-09-15 14:57:01 +02:00
jussisaurio
3f0162c76c Support grouping by a function expression 2024-09-15 09:58:46 +03:00
jussisaurio
6b8cd02f71 Fix function expressions in like pattern not working 2024-09-15 09:57:54 +03:00
jussisaurio
234c56ca81 Fix two issues with LIKE operator (#319) 2024-09-15 09:57:54 +03:00
김선우
8b3e4da8da Apply comments
- Specify the number of arguments using arg_count
- Add test for concat_ws
2024-09-15 10:04:30 +09:00
김선우
fc07ca9d73 Add support for concat_ws 2024-09-14 23:47:45 +09:00
jussisaurio
a108dea825 GROUP BY 2024-09-14 16:14:45 +03:00
jussisaurio
0839211a49 Pass FuncCtx to Insn::Function to keep track of arg count 2024-09-14 12:38:14 +03:00
rjhallsted
dc3d3a492a Fix register positions of binary expression arguments to fix where-like-fn case 2024-09-12 12:03:27 -07:00
sonhmai
9cc965186f core: support modifiers in date function 2024-09-03 14:28:07 +07:00
Rajiv Harlalka
3447a553e1 chore: move tests
Signed-off-by: Rajiv Harlalka <rajivharlalka009@gmail.com>
2024-08-30 20:34:48 +05:30
Rajiv Harlalka
e2013b0ef6 add unixepoch tests
Signed-off-by: Rajiv Harlalka <rajivharlalka009@gmail.com>
2024-08-30 20:28:35 +05:30
sonhmai
c32bb91dd5 core: support modifiers in time function 2024-08-24 18:31:34 +07: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
8bb2a48cb6 Add support for nullif scalar function 2024-08-20 18:36:06 +02: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
c6402aa341 Add tcl 2024-08-18 21:00:36 +02: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