Kacper Kołodziej
d4bff2c93e
add octet_length scalar function
2024-12-10 22:56:38 +01:00
krishvishal
134b5576ad
Ran cargo fmt
2024-12-09 22:55:54 +05:30
krishvishal
1e23af7d24
Added last_insert_rowid() function.
...
Need to fix its behavior. Problem is probably with `Cursor` implementation.
2024-12-09 17:41:28 +05:30
Alex Miller
f7bb7f8dee
Fix typo and improve comment
2024-12-08 14:20:23 -08:00
Alex Miller
c2e3957d73
I misunderstood what a constant instruction was
2024-12-08 14:12:45 -08:00
Alex Miller
eb00226cfe
Add support for CASE expressions.
...
There's two forms of case:
CASE (WHEN [bool expr] THEN [value])+ (ELSE [value])? END
which checks a series of boolean conditions, and:
CASE expr (WHEN [expr] THEN [value})+ (ELSE [value])? END
Which checks a series of equality conditions.
This implements support for both. Note that the ELSE is optional, and
will be equivalent to `ELSE null` if not specified.
sqlite3 gives the implementation as:
sqlite> explain select case a WHEN a THEN b WHEN c THEN d ELSE 0 END from casetest;
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Init 0 16 0 0 Start at 16
1 OpenRead 0 3 0 4 0 root=3 iDb=0; casetest
2 Rewind 0 15 0 0
3 Column 0 0 2 0 r[2]= cursor 0 column 0
4 Column 0 0 3 0 r[3]= cursor 0 column 0
5 Ne 3 8 2 BINARY-8 83 if r[2]!=r[3] goto 8
6 Column 0 1 1 0 r[1]= cursor 0 column 1
7 Goto 0 13 0 0
8 Column 0 2 3 0 r[3]= cursor 0 column 2
9 Ne 3 12 2 BINARY-8 83 if r[2]!=r[3] goto 12
10 Column 0 3 1 0 r[1]= cursor 0 column 3
11 Goto 0 13 0 0
12 Integer 0 1 0 0 r[1]=0
13 ResultRow 1 1 0 0 output=r[1]
14 Next 0 3 0 1
15 Halt 0 0 0 0
16 Transaction 0 0 2 0 1 usesStmtJournal=0
17 Goto 0 1 0 0
and after this patch, limbo gives:
addr opcode p1 p2 p3 p4 p5 comment
---- ----------------- ---- ---- ---- ------------- -- -------
0 Init 0 18 0 0 Start at 18
1 OpenReadAsync 0 4 0 0 table=casetest, root=4
2 OpenReadAwait 0 0 0 0
3 RewindAsync 0 0 0 0
4 RewindAwait 0 17 0 0 Rewind table casetest
5 Column 0 0 2 0 r[2]=casetest.a
6 Column 0 0 3 0 r[3]=casetest.a
7 Ne 2 3 10 0 if r[2]!=r[3] goto 10
8 Column 0 1 1 0 r[1]=casetest.b
9 Goto 0 14 0 0
10 Column 0 2 3 0 r[3]=casetest.c
11 Ne 2 3 14 0 if r[2]!=r[3] goto 14
12 Column 0 3 1 0 r[1]=casetest.d
13 Goto 0 14 0 0
14 ResultRow 1 1 0 0 output=r[1]
15 NextAsync 0 0 0 0
16 NextAwait 0 5 0 0
17 Halt 0 0 0 0
18 Transaction 0 0 0 0
19 Integer 0 1 0 0 r[1]=0
20 Goto 0 1 0 0
And then as there's nowhere to annotate this new support in COMPAT.md, I
added a corresponding heading for SELECT expressions and what is/isn't
supported.
2024-12-08 14:09:03 -08:00
Alex Miller
27ef95e0ab
LLM recommended a better way to write args matching
2024-12-07 21:15:04 -08:00
Alex Miller
183ea8e362
Implement support for iif().
...
In sqlite, iif() looks like:
sqlite> create table iiftest(a int, b int, c int);
sqlite> explain select iif(a,b,c) from iiftest;
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Init 0 11 0 0 Start at 11
1 OpenRead 0 2 0 3 0 root=2 iDb=0; iiftest
2 Rewind 0 10 0 0
3 Column 0 0 2 0 r[2]= cursor 0 column 0
4 IfNot 2 7 1 0
5 Column 0 1 1 0 r[1]= cursor 0 column 1
6 Goto 0 8 0 0
7 Column 0 2 1 0 r[1]= cursor 0 column 2
8 ResultRow 1 1 0 0 output=r[1]
9 Next 0 3 0 1
10 Halt 0 0 0 0
11 Transaction 0 0 1 0 1 usesStmtJournal=0
12 Goto 0 1 0 0
And with this change, in limbo it looks like:
addr opcode p1 p2 p3 p4 p5 comment
---- ----------------- ---- ---- ---- ------------- -- -------
0 Init 0 14 0 0 Start at 14
1 OpenReadAsync 0 2 0 0 table=iiftest, root=2
2 OpenReadAwait 0 0 0 0
3 RewindAsync 0 0 0 0
4 RewindAwait 0 13 0 0 Rewind table iiftest
5 Column 0 0 2 0 r[2]=iiftest.a
6 IfNot 2 9 1 0 if !r[2] goto 9
7 Column 0 1 1 0 r[1]=iiftest.b
8 Goto 0 10 0 0
9 Column 0 2 1 0 r[1]=iiftest.c
10 ResultRow 1 1 0 0 output=r[1]
11 NextAsync 0 0 0 0
12 NextAwait 0 5 0 0
13 Halt 0 0 0 0
14 Transaction 0 0 0 0
15 Goto 0 1 0 0
2024-12-07 21:04:03 -08:00
jussisaurio
3f80e41e7a
support HAVING
2024-11-30 10:05:13 +02:00
jussisaurio
885b6ecd76
Remove 'cursor_hint': it is never needed
2024-11-26 17:31:51 +02:00
jussisaurio
008be10cfd
Add TODO about expression equality comparisons
2024-11-26 17:31:51 +02:00
jussisaurio
9a557516b8
Fixes for expressions with aggregate arguments + limit 0
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
jussisaurio
d0466e1cae
introduce Column member of ast::Expr and bind idents to columns
2024-11-26 17:31:51 +02:00
Lauri Virtanen
cafbf5499f
Support divide operator in expressions
2024-11-24 22:10:07 +02:00
jussisaurio
b86501f12e
Merge 'implement CAST(col as type)' from Jussi Saurio
...
Closes #398
Reviewed-by: Pere Diaz Bou <pere-altea@hotmail.com >
Closes #404
2024-11-18 20:53:58 +02:00
Pekka Enberg
5efc218e6e
Merge 'support subtract in translate_expr() (not in condition expressions yet)' from Jussi Saurio
...
closes #402
Closes #403
2024-11-18 09:28:23 +02:00
jussisaurio
62761d2b34
uppercase only once
2024-11-17 22:22:03 +02:00
jussisaurio
ddd0cc041c
implement CAST(col as type)
2024-11-17 22:12:22 +02:00
jussisaurio
491bdd3bfc
support subtract in translate_expr() (not in condition expressions yet)
2024-11-17 18:47:16 +02:00
jussisaurio
9a4864bc6a
support parenthesized(single expr) in translate_expr()
2024-11-17 18:36:30 +02:00
Pekka Enberg
cd5db55cf2
core: Make JSON support configurable
...
This adds a `json` feature flag, which allows users to disable JSON
support if needed.
2024-11-16 09:49:09 +02:00
jussisaurio
f634e7f7a3
clippy fix
2024-10-13 12:08:54 +03:00
jussisaurio
b3c57d5691
core/translate: (refactor) use btreetablereference struct instead of tuple
2024-10-13 11:25:33 +03:00
Lauri Virtanen
0ae1412193
Add instr(X,Y) scalar function
...
Relates to issue #144
2024-10-06 20:19:37 +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
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
Lauri Virtanen
67573e12e5
Add typeof(X) scalar function
2024-09-21 15:56:29 +03:00
김선우
bbd1eea9ae
Add support for parenthesized conditions
2024-09-21 16:03:49 +09:00
김선우
e9ba458514
Add support for sqlite_version
2024-09-18 17:57:51 +09:00
Pekka Enberg
a8b8c1d2c9
Merge 'Fix clippy ' from Kim Seon Woo
...
### Changes
- Remove clippy warning messages
- Add `#[allow(clippy...)]` in places where it might be better not to
fix
### TODO
recommended changes by `cargo fmt` on my local and github differs on
`sqlite3/src/lib.rs`. Should check for the reason
=> just upgrade the rust toolchain
Closes #329
2024-09-18 09:46:07 +03:00
rjhallsted
f6b7a3fba4
Remove duplication of glob and like translation
2024-09-16 16:31:37 -07:00
rjhallsted
b87b874ed0
WIP commit on glob support
2024-09-16 15:51:32 -07:00
김선우
b68efa32d9
Merge branch 'main' into feature/fix-clippy
2024-09-16 21:58:07 +09: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
김선우
28884181be
Fix clippy
2024-09-15 16:23:27 +09: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
jussisaurio
b6e88ca883
cargo clippy --fix --allow-dirty && cargo fmt
2024-09-15 09:35:39 +03:00