Commit Graph

2425 Commits

Author SHA1 Message Date
Glauber Costa
ac6dc9f9e8 clarify README and future plans 2025-02-04 19:44:04 -05:00
Pekka Enberg
20ffcb9d48 Merge 'core: Switch to parking_lot for RwLock' from Pekka Enberg
We really need to make the WAL lock less expensive, but switching to
`parking_lot` is anyway something we should do.
Before:
```
Execute `SELECT 1`/Limbo
                        time:   [56.230 ns 56.463 ns 56.688 ns]
```
After:
```
Execute `SELECT 1`/Limbo
                        time:   [52.003 ns 52.132 ns 52.287 ns]
```

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #887
2025-02-04 20:55:54 +02:00
Pekka Enberg
1aca47a384 Replace cover art with Turso branding
I socially engineerd Jamie into generating a Turso branded cover image
by merging something he hated, which was AI-generated image of a dark
forest. Thanks Jamie!
2025-02-04 20:47:33 +02:00
Pekka Enberg
f004528e35 Update README.md 2025-02-04 20:07:21 +02:00
Pekka Enberg
68606d4d8c Update README.md cover art 2025-02-04 20:03:18 +02:00
Pekka Enberg
541270e38f Update README.md 2025-02-04 19:56:47 +02:00
Pekka Enberg
002ffb2e4d Update README.md 2025-02-04 19:35:07 +02:00
Pekka Enberg
4ad865af1d Merge 'Add Go example to main repo README' from Preston Thorpe
Now that we have a release that includes the Go bindings, we can have an
example where `go get github.com/tursodatabase/limbo` is used 👍

Closes #888
2025-02-04 19:31:47 +02:00
PThorpe92
1cbd33499e Add Go example to README 2025-02-04 11:53:11 -05:00
Pekka Enberg
e4d7474372 core: Switch to parking_lot for RwLock
We really need to make the WAL lock less expensive, but switching to
`parking_lot` is anyway something we should do.

Before:

```
Execute `SELECT 1`/Limbo
                        time:   [56.230 ns 56.463 ns 56.688 ns]
```

After:

```
Execute `SELECT 1`/Limbo
                        time:   [52.003 ns 52.132 ns 52.287 ns]
```
2025-02-04 18:38:33 +02:00
Pekka Enberg
750164fb85 Merge 'Sqlean Time extension' from Pedro Muniz
This PR implements a sqlean time compatible extension. I would
appreciate some help to review my code and see if there are ways to
enhance it. Also, if there is some edge case, I have missed please tell
me.
https://github.com/nalgeon/sqlean/blob/main/docs/time.md

Closes #854
2025-02-04 18:27:44 +02:00
Pekka Enberg
733f7de688 Merge branch 'main' into feature/time-ext 2025-02-04 18:27:14 +02:00
Pekka Enberg
f69804969c Merge 'Adding checkpoint result' from Sonny
### What?
adding checkpoint result returning number of pages in wal and num pages
checkpointed.
Part of #696
### Context
SQLite returns in checkpoint result of calling `pragma wal_checkpoint;`
`0|3|3` while limbo returns `0|0|0`.
https://sqlite.org/pragma.html#pragma_wal_checkpoint
- 1st col: 1 (checkpoint SQLITE_BUSY) or 0 (not busy).
- 2nd col: # modified pages written to wal file
- 3rd col: # pages moved to db after checkpoint
This PR aims to add 2nd and 3rd column to the checkpoint result.
SQLite
```
sqlite3 test.db
sqlite> pragma journal_mode=wal;
wal
sqlite> pragma journal_mode;
wal
sqlite> create table t1 (id text);
sqlite> insert into t1(id) values (1),(2);
sqlite> select * from t1;
1
2
sqlite> pragma wal_checkpoint;
0|3|3
```
Limbo
```
./target/debug/limbo test.db
Limbo v0.0.13
Enter ".help" for usage hints.
limbo> pragma journal_mode;
wal
limbo> create table t1(id text);
limbo> insert into t1(id) values (1),(2);
limbo> select * from t1;
1
2
# current the 2nd and 3rd columns are hard coded in limbo to 0
limbo> pragma wal_checkpoint;
0|0|0
```

Closes #827
2025-02-04 18:26:24 +02:00
Pekka Enberg
a045866a6c Merge 'core: Fix benchmark panic if syscall is interrupted' from Pekka Enberg
Fixes the following panics:
Benchmarking Execute `SELECT * FROM users LIMIT ?`/Limbo/100: Profiling
for 5.0000 sthread 'main' panicked at core/benches/benchmark.rs:69:43:
called `Result::unwrap()` on an `Err` value: IOError(Os { code: 4, kind:
Interrupted, message: "Interrupted system call" })
note: run with `RUST_BACKTRACE=1` environment variable to display a
backtrace

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #882
2025-02-04 18:25:34 +02:00
Pekka Enberg
b20ad42892 Merge 'github: Fix Python release workflow' from Pekka Enberg
We need to switch to `download-artifact@v4` because v3 is dead...

Closes #883
2025-02-04 18:25:26 +02:00
Pekka Enberg
bf1ef13c91 Merge 'Add Printf Support' from Zaid Humayun
Add basic printf function support in limbo
![Screenshot 2025-02-04 at 8 08 23 PM](https://github.com/user-
attachments/assets/b12931eb-8e79-4c8a-af77-c25c34cc5834)

Closes #886
2025-02-04 17:53:27 +02:00
Zaid Humayun
15b46e73eb test fix 2025-02-04 21:02:51 +05:30
Zaid Humayun
39d57ba541 test fix again 2025-02-04 20:58:03 +05:30
Zaid Humayun
4cb6f8cc6a fixing: failing test was expecting 2.50000
this test is behaving differently in different environments
2025-02-04 20:53:10 +05:30
Zaid Humayun
6a863b3da9 printf: this commit adds support for https://github.com/tursodatabase/limbo/issues/885 tracking printf functionality
this commit introduces basic support for printf functionality and doesn't include advanced modifiers like width etc.
2025-02-04 20:05:14 +05:30
Pekka Enberg
1817b75d9b github: Fix Python release workflow
We need to switch to `download-artifact@v4` because v3 is dead...
2025-02-04 15:55:19 +02:00
Pekka Enberg
73a345aa4d Limbo 0.0.14 2025-02-04 15:13:18 +02:00
Pekka Enberg
31552f0862 core/json: Kill some unwrap() calls 2025-02-04 14:55:19 +02:00
Pekka Enberg
2d9a54ccba Merge 'implement json_pretty' from Pedro Muniz
This PR implements json_pretty. At the moment, support for jsonb is
being added, so this function suffers from the same limitations as in
json(x). Also, I have not found a way to implement the same conversion
of Blob -> String that SQLite does. From my own experimentation, I
believe SQLite converts blobs to a lossy ascii representation, but I
would appreciate some help on this.

Closes #860
2025-02-04 14:51:47 +02:00
Pekka Enberg
0050f4aeea Merge 'Support column aliases in GROUP BY, ORDER BY and HAVING' from Jussi Saurio
Closes #744
```sql
# Wanda = 9, Whitney = 11, William = 111
do_execsql_test column_alias_in_group_by_order_by_having {
  select first_name as fn, count(1) as fn_count from users where fn in ('Wanda', 'Whitney', 'William') group by fn having fn_count > 10 order by fn_count;
} {Whitney|11
William|111}
```

Closes #864
2025-02-04 14:51:05 +02:00
Pekka Enberg
b4a3cadf58 Merge 'Improve in-memory IO performance, remove runtime borrow checking' from Preston Thorpe
Despite likely replacing this in-memory IO setup in the near future with
a `mmap` implementation (#859) , in the spirit of everyone getting
bitten by the perf bug lately I thought I would speed up our in-memory
IO a bit.

Closes #861
2025-02-04 14:50:38 +02:00
Pekka Enberg
e2cf2d2c37 Merge 'doc: refine function contributing doc' from Sonny
improved function contributing doc a bit.

Closes #873
2025-02-04 14:50:11 +02:00
Pekka Enberg
1a1366e46b Merge 'core: Kill Statement::query() method' from Pekka Enberg
It's a pointless wrapper on top of `step()` that introduce additional
memory allocation and deallocation.

Closes #880
2025-02-04 14:01:57 +02:00
Pekka Enberg
097e56c19f core: Kill Statement::query() method
It's a pointless wrapper on top of `step()` that introduce additional
memory allocation and deallocation.
2025-02-04 13:46:11 +02:00
Pekka Enberg
7dbfdba59f core: Fix benchmark panic if syscall is interrupted
Fixes the following panics:

Benchmarking Execute `SELECT * FROM users LIMIT ?`/Limbo/100: Profiling for 5.0000 sthread 'main' panicked at core/benches/benchmark.rs:69:43:
called `Result::unwrap()` on an `Err` value: IOError(Os { code: 4, kind: Interrupted, message: "Interrupted system call" })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2025-02-04 13:24:55 +02:00
Pekka Enberg
fb0a560d76 Merge 'dont store insn comments unless the query is EXPLAIN' from Jussi Saurio
We spend a lot of time especially in `GROUP BY` queries providing
helpful comments for `EXPLAIN`, even when the query is not an `EXPLAIN`.
So let's not do that
Closes #784
```sql
Prepare `SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1) > 1 ORDER BY cou...
                        time:   [4.2724 µs 4.2783 µs 4.2848 µs]
                        change: [-6.1063% -5.7376% -5.3626%] (p = 0.00 < 0.05)
                        Performance has improved.
```
doesn't affect the other trivial prepare benchmarks

Closes #875
2025-02-04 13:10:37 +02:00
Pekka Enberg
da96072780 Merge 'Lower ownership requirement for Value' from Levy A.
If you have a `&str` you would need to allocate and copy the string just
to pass a reference to it again. Same goes if you have a slice of bytes.
In all (most?) situations, that is not what you want and sometimes
impossible to satisfy. Example:
```rs
impl From<&str> for Value<'_> {
    fn from(value: &str) -> Self {
        Self::Text(&value.to_owned())
    }
}
```
Here, there is no way to pass a reference to a `String` without making
the lifetime `'static`, since the string has to be dropped by the end of
the function or leaked. I would consider this a anti-pattern. There is
no reason to keep a shared reference to a owned value. (And can't think
of any situation where you would need such thing)
Now, this is possible:
```rs
impl<'a> From<&'a str> for Value<'a> {
    fn from(value: &'a str) -> Self {
        Self::Text(value)
    }
}
```

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #838
2025-02-04 13:10:10 +02:00
Pekka Enberg
ebe474c1fc Merge 'Dont fsync the WAL on read queries' from Jussi Saurio
```sql
Execute `SELECT * FROM users LIMIT ?`/Limbo/1
                        time:   [450.92 ns 452.30 ns 453.70 ns]
                        change: [-37.717% -37.400% -37.132%] (p = 0.00 < 0.05)
                        Performance has improved.
Execute `SELECT * FROM users LIMIT ?`/Limbo/10
                        time:   [2.7040 µs 2.7151 µs 2.7267 µs]
                        change: [-11.078% -10.679% -10.272%] (p = 0.00 < 0.05)
                        Performance has improved.
Execute `SELECT * FROM users LIMIT ?`/Limbo/50
                        time:   [12.871 µs 12.933 µs 13.004 µs]
                        change: [-3.9378% -3.4992% -3.0381%] (p = 0.00 < 0.05)
                        Performance has improved.
Execute `SELECT * FROM users LIMIT ?`/Limbo/100
                        time:   [25.638 µs 25.729 µs 25.817 µs]
                        change: [-2.5777% -2.0966% -1.6317%] (p = 0.00 < 0.05)
                        Performance has improved.
Execute `SELECT 1`/Limbo
                        time:   [59.180 ns 59.292 ns 59.414 ns]
                        change: [-81.323% -81.205% -81.094%] (p = 0.00 < 0.05)
                        Performance has improved.
```

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #876
2025-02-04 13:09:55 +02:00
Levy A.
dcd32e1ec8 fix: clippy + new errors 2025-02-03 16:58:13 -03:00
Levy A.
9df0b01689 refactor: lower ownership requirement 2025-02-03 16:52:42 -03:00
Jussi Saurio
1f888fea4f Dont fsync the WAL on read queries 2025-02-03 20:42:50 +02:00
Jussi Saurio
d182ddf514 dont store insn comments unless the query is EXPLAIN 2025-02-03 19:53:33 +02:00
sonhmai
022a8d7a83 core: return checkpoint result 2025-02-03 19:02:16 +07:00
sonhmai
1c803aa079 feat: add wal checkpoint result 2025-02-03 18:57:22 +07:00
Jussi Saurio
d4cb0a1223 Merge 'Fix logical codegen' from Nikita Sivukhin
Fix few logical codegen issues and add fuzz tests for logical
expressions
-  Right now Limbo fails to recognize `false` constant in case when any
unary operator is used on the AST path. This PR add unary operator
option in the rewrite code and handle such cases properly.
```sql
limbo> SELECT NOT FALSE;

  × Parse error: no such column: FALSE - should this be a string literal in single-quotes?

```
- `ifnull` implementation produced incorrect codegen due to "careless"
management of registers
```
limbo> SELECT ifnull(0, NOT 0)
[NULL here]
```
- `like` implementation produced incorrect codegen due to "careless"
management of registers
```
limbo> SELECT like('a%', 'a') = 1;
thread 'main' panicked at core/vdbe/mod.rs:1902:41:
internal error: entered unreachable code: Like on non-text registers
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
Depends on https://github.com/tursodatabase/limbo/pull/867 (need
`GrammarGenerator` from this branch)

Closes #869
2025-02-03 12:39:41 +02:00
Jussi Saurio
d41dfd0c5d Merge 'Fix rowid search codegen' from Nikita Sivukhin
This PR fixes a bug when index search used incorrect operator if index
column were the "rhs" in the expression (not "lhs" as usual, e.g.
`SELECT * FROM t WHERE 1 < rowid_alias`)

Reviewed-by: Jussi Saurio (@jussisaurio)

Closes #870
2025-02-03 12:38:04 +02:00
sonhmai
d4e1aae368 doc: refine function contributing doc 2025-02-03 15:57:33 +07:00
Jussi Saurio
1e5501650a Support column aliases in GROUP BY, ORDER BY and HAVING 2025-02-03 10:44:05 +02:00
Nikita Sivukhin
f43a326649 add examples of tests found by fuzzer 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
529c2df6f6 add few scalar function with binary result in logical fuzz test 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
979612cb34 fix miscompilation of like function 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
11c47f5e44 fix miscomplation of ifnull scalar function 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
17d06a1d28 adjust options for logical fuzz test 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
c2950d144e add logical expression fuzz tests 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
a4a80f37bc rewrite unary expressions too - in order to support "NOT FALSE" expressions 2025-02-03 11:25:14 +04:00