Commit Graph

160 Commits

Author SHA1 Message Date
Li Yazhou
03288e5170 add impl about scalar function soundex with test 2024-12-12 21:48:05 +08:00
Alex Miller
c4d4569dc9 Merge remote-tracking branch 'upstream/main' into expr-iif 2024-12-11 20:13:54 -08:00
alpaylan
da28ed51ca add implementation and tests for replace scalar function 2024-12-11 16:23:13 -05:00
Pekka Enberg
04f196113a Merge 'Add last_insert_rowid() function' from Krishna Vishal
- Changed `Cursor` trait to be able to get access to `root_page`
- SQLite only updates last_insert_rowid for non-schema inserts. So we
check if the `InsertAwait` is not for `root_page` before   updating
rowid
In SQLite it looks like this:
```
sqlite> EXPLAIN SELECT last_insert_rowid();
addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     4     0                    0
1     Function       0     0     1     last_insert_rowid(0) 0
2     ResultRow      1     1     0                    0
3     Halt           0     0     0                    0
4     Goto           0     1     0                    0
```
In limbo it will look like this:
```
limbo> EXPLAIN SELECT last_insert_rowid();
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     4     0                    0   Start at 4
1     Function           0     2     1     last_insert_rowid  0   r[1]=func()
2     ResultRow          1     1     0                    0   output=r[1]
3     Halt               0     0     0                    0
4     Transaction        0     0     0                    0
5     Goto               0     1     0                    0
```

Closes #427
2024-12-11 10:44:34 +02:00
Kacper Kołodziej
d4bff2c93e add octet_length scalar function 2024-12-10 22:56:38 +01:00
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
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
ddd0cc041c implement CAST(col as type) 2024-11-17 22:12:22 +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
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
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
김선우
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
af09f0b7f4 Add testing 2024-09-16 16:18:26 -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
김선우
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
김선우
fc07ca9d73 Add support for concat_ws 2024-09-14 23:47:45 +09:00
jussisaurio
0839211a49 Pass FuncCtx to Insn::Function to keep track of arg count 2024-09-14 12:38:14 +03:00
Rajiv Harlalka
6684fb46e4 FEAT: Implement the unixepoch function
Signed-off-by: Rajiv Harlalka <rajivharlalka009@gmail.com>
2024-08-30 20:27:58 +05:30
Kim Seon Woo
8bb2a48cb6 Add support for nullif scalar function 2024-08-20 18:36:06 +02:00
JeanArhancet
b6c720c90a feat: add quote function 2024-08-17 09:28:14 +02:00
Kim Seon Woo
48d3c05fb0 Rebase 2024-08-16 21:40:30 +09: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
김선우
8fbcd10e0e Add support for ifnull scalar function 2024-08-16 09:25:04 +09:00
김선우
27d9af2bf4 Add support for substr scalar function 2024-08-16 08:26:42 +09:00
김선우
77c3d130f3 Add char function support 2024-08-16 06:26:06 +09:00
김선우
aff13de125 Nit 2024-08-15 18:50:40 +09:00
김선우
3fa3c5c002 Add substr scala function 2024-08-15 18:27:18 +09:00
JeanArhancet
552090cb29 feat: add json support 2024-08-04 10:54:27 +02:00
sonhmai
789ae4becf feat: add time() scalar function partial support without modifier #158 2024-08-01 13:06:07 +07:00
macroexpansion
918b99b7a3 feat: add RTRIM(X) and RTRIM(X,Y) scalar function 2024-07-28 21:17:53 +07:00
macroexpansion
750f18be35 feat: add ltrim scalar function 2024-07-27 19:46:27 +07:00
Ethan Niser
aa6531f802 add unicode scalar function 2024-07-25 10:05:41 -07:00
Ethan Niser
07d6ebef24 rename SingleRow -> Scalar 2024-07-24 08:53:47 -07:00
jussisaurio
588ab1af06 Run formatting and enforce formatting in CI 2024-07-23 23:14:36 +03:00
gandeevanr
7bb3412e66 added compatibility tests for date 2024-07-23 09:19:17 -07:00
gandeevanr
871fae3286 Implement the Date() method 2024-07-23 09:19:08 -07:00
Brayan Jules
c227001737 support handling functions with the same name but different parameters number 2024-07-22 17:02:36 -04:00
Brayan Jules
dde00c3bc5 implementation of scalar functions min and max 2024-07-22 17:02:36 -04:00
Bennett Clement
865b3a04e9 Implement orderby translation 2024-07-22 00:27:46 +08:00