Commit Graph

2890 Commits

Author SHA1 Message Date
Ihor Andrianov
287c04bde0 remove repeated code 2025-02-12 02:34:13 +02:00
Ihor Andrianov
a5fcbed21a fix infinite loop error 2025-02-12 00:10:56 +02:00
Pekka Enberg
ebceefacde Merge 'simulator: add NoREC testing property' from Alperen Keleş
NoREC is a correctness property for testing optimizers, proposed by
Rigger and Su in [Detecting Optimization Bugs in Database Engines via
Non-Optimizing Reference Engine
Construction](https://www.manuelrigger.at/preprints/NoREC.pdf)
This PR adds a NoREC property to the tester.

Closes #973
2025-02-11 17:44:56 +02:00
Pekka Enberg
4c064790b2 Merge 'simulator: add DROP TABLE <t> support' from Alperen Keleş
I wanted to assist the current development in an up-to-date fashion,
this PR adds drop table(which is being implemented currently in
https://github.com/tursodatabase/limbo/pull/897) testing support to the
generator.
Unfortunately, we don't have feature flags in the simulator yet, so the
users should manually fix the generation probability in
`simulator/generation/plan.rs#L644` and
`simulator/generation/property.rs#L629`.

Closes #949
2025-02-11 17:44:49 +02:00
Pekka Enberg
3dd49855d0 Merge 'testing/extensions: Fix tests on macOS' from meteorgan
fix the extensions tests on MacOS

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #982
2025-02-11 17:41:37 +02:00
meteorgan
7a7c70f8e1 test(extensions): remove the extension suffix so that it can be run on MacOS 2025-02-11 21:45:39 +08:00
Pekka Enberg
cafdef8332 Merge 'core: Add default column name' from wyhaya
Fix #926
```
limbo> select 1, 2, 1+2*3, 'Hello';
┌───┬───┬───────────┬─────────┐
│ 1 │ 2 │ 1 + 2 * 3 │ 'Hello' │
├───┼───┼───────────┼─────────┤
│ 1 │ 2 │         7 │ Hello   │
└───┴───┴───────────┴─────────┘
```

Closes #979
2025-02-11 09:59:23 +02:00
wyhaya
351a032cc1 core: Add default column name 2025-02-11 07:03:51 +00:00
Pekka Enberg
cd27068807 Merge 'cli: Add .exit command' from wyhaya
This PR add the `.exit ?<CODE>` command, which will allow limbo to exit
with the specified code (similar to SQLite3 and DuckDB).
```bash
echo '.exit' | cargo run -p limbo ; echo $?
# ...
# 0

echo '.exit 1' | cargo run -p limbo ; echo $?
# ...
# 1
```

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #978
2025-02-11 07:59:59 +02:00
Pekka Enberg
cca8ef9e6b Merge 'cli: handle remaining input on EOF' from Konstantinos Artopoulos
Fixes #966

Closes #975
2025-02-11 07:55:34 +02:00
wyhaya
2482c03111 cli: Add .exit command 2025-02-11 03:11:42 +00:00
Konstantinos Artopoulos
839e1ce3e8 fix(cli): handle remaining input on EOF 2025-02-11 00:02:20 +02:00
alpaylan
747b6d15e3 add NoREC optimizer testing property 2025-02-10 15:42:49 -05:00
Pekka Enberg
1da43266e9 Merge 'Json path refine' from Ihor Andrianov
Hey! I've rebuilt the JSON path parser to make it easier to maintain and
catch more edge cases.
Main stuff:
- Removed pest dependency in favor of hand-written parser
- Better memory usage (pre-allocates space, use Cow)
- Handles quoted keys properly now
- Added tests for weird edge cases
- Added PPState (Shoutout ThePrimeagen)

Closes #970
2025-02-10 19:39:20 +02:00
Pekka Enberg
db3cb131f4 Update README.md 2025-02-10 19:25:43 +02:00
Pekka Enberg
a531f635cf Update README.md 2025-02-10 19:11:28 +02:00
Pekka Enberg
0e2c9f9b53 Update README.md
Add links to package repositories.
2025-02-10 18:53:37 +02:00
Pekka Enberg
b75629e5af Merge 'bindings/java: Implement DatabaseMetaData ' from Kim Seon Woo
## Purpose of this PR
- Implement `DatabaseMetaData`
## Changes
- Add `JDBC4DatabaseMetaData` which implements minimal
`DatabaseMetaData`
## Note
- This has to be merged after
https://github.com/tursodatabase/limbo/pull/916
## Reference
- [Issue](https://github.com/tursodatabase/limbo/issues/615)

Closes #944
2025-02-10 17:39:59 +02:00
Pekka Enberg
199193588e Merge 'Fix floating point truncation in JSON #877' from lgualtieri75
Fixes #877

Closes #967
2025-02-10 17:38:59 +02:00
김선우
29e023ac79 Merge branch 'main' into java-bindings-database-metadata 2025-02-10 23:00:02 +09:00
Ihor Andrianov
b8b0f860d7 clippy 2025-02-10 15:34:47 +02:00
Ihor Andrianov
aad0522f56 refactor to make parser more readable 2025-02-10 15:13:36 +02:00
Ihor Andrianov
a10955cbcf refine quoted key handling, add RawString option for SQLite compat 2025-02-10 15:12:07 +02:00
Ihor Andrianov
ee16c49c6c add support for quoted path 2025-02-10 15:09:27 +02:00
Ihor Andrianov
f84a6b878a fixed edge cases and add some tests, remove pest grammar 2025-02-10 15:09:26 +02:00
Ihor Andrianov
166532cc81 simplify json path parsing 2025-02-10 15:09:23 +02:00
l.gualtieri
3487969c40 fix floating point numbers get truncated in json #877 2025-02-10 12:23:43 +01:00
Pekka Enberg
8f49024dd1 Fix build_text() call site to use new API 2025-02-10 13:07:19 +02:00
Pekka Enberg
5205c23eed Merge 'Initial support for WITH clauses (common table expressions)' from Jussi Saurio
Adds initial limited support for CTEs.
- No MATERIALIZED
- No RECURSIVE
- No named CTE columns
- Only SELECT statements supported inside CTE
Basically this kind of WITH clause can just be rewritten as a subquery,
so this PR adds some plumbing to rewrite them using the existing
subquery machinery.
It also introduces the concept of a `Scope` where a child query can
refer to its parent, useful for CTEs like:
```
do_execsql_test nested-subquery-cte {
    with nested_sub as (
        select concat(name, '!!!') as loud_hat
        from products where name = 'hat'
    ),
    sub as (
        select upper(nested_sub.loud_hat) as loudest_hat from nested_sub
    )
    select sub.loudest_hat from sub;
} {HAT!!!}
```
I think we need to expand the use of `Scope` to all of our identifier
resolutions (currently we don't explicitly have logic for determining
what a given query can see), but I didn't want to bloat the PR too much.
Hence, this implementation is probably full of all sorts of bugs, but
I've added equivalent tests for ALL the existing subquery tests,
rewritten in CTE form.

Closes #920
2025-02-10 12:15:07 +02:00
Pekka Enberg
fa883d1c6b Merge 'bindings/java: Refactor to favor composition over inheritance ' from Kim Seon Woo
## Changes
- AS-IS
  - `LimboConnection` implements `Connection`
  - `JDBC4Connection` implements `LimboConnection`
- TO-BE
  - `LimboConnection` doesn't implement `Connection`. It is used to
represent connection to limbo only.
  - `JDBC4Connection` implements `Connection` directly. Holds
`LimboConnection` in member field.
- This helps remove the complexity of java's `Connection` interface away
from `LimboConnection`. We can focus on implementing limbo's feature
inside `LimboConnection` and let `JDBC4Connection` handle the
interoperability with jdbc world.
## Reference
https://github.com/tursodatabase/limbo/issues/615

Closes #916
2025-02-10 12:13:30 +02:00
Pekka Enberg
d221f158cc Merge 'Add read implementation of user_version pragma with ReadCookie opcode' from Jonathan Webb
Just a bare bones implementation of ReadCookie and support for the
user_version pragma

Closes #909
2025-02-10 12:12:15 +02:00
Pekka Enberg
0638550be7 Merge 'Remove unnecessary reference counting from completion I/O callbacks' from Preston Thorpe
I am on a bit of a mission to revisit a lot of the ref counting, this
was an easy first win.
It seems to be a linear path of function calls or hashmaps which can own
the completions directly, no cloning needed.

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

Closes #912
2025-02-10 12:11:30 +02:00
Pekka Enberg
a3875ef130 Update COMPAT.md 2025-02-10 11:25:15 +02:00
Pekka Enberg
604ca4085d Merge 'Make record values private' from Tiago
This is an attempt to move towards #881. I am not sure this is the
direction you want to take. In any case, I thought I would take a crack
at converting `values` from `Record` to private and see how bad it would
be.
In the end, as you can see, it is not so bad. I think performance-wise
it shouldn't be a bad hit with Rust's zero-cost abstraction. Also,
during the process I noticed a couple improvements that could be made
here and there but I honestly wanted to start with something small
enough that wouldn't be too hard to review.
Anyway, let me know if this is really how you would like to proceed.

Closes #962
2025-02-10 11:23:21 +02:00
Pekka Enberg
fcad8d125e Merge 'refactor: remove RC<String> requirement for build_text and new text' from Pedro Muniz
This PR aims to simplify text creation and to reduce allocation overhead
of creating a new OwnedValue::Text. Instead of creating Rc<String> every
time you need to create a text, you just pass the string slice and the
Rc<String> is created at the end. This change, at least on my machine,
has removed a lot of variability in the benchmarking performance, while
maintaining roughly the same performance.

Closes #961
2025-02-10 11:21:50 +02:00
Pekka Enberg
00a546e775 Merge 'Fix string funcs' from Nikita Sivukhin
Add fuzz test for string functions and fix 2 bugs in implementation of
`LTRIM/RTRIM/TRIM` and `QUOTE`:
- `QUOTE` needs to escape internal quote(`'`) symbols
- `LTRIM`/`RTRIM`/`TRIM` needs to check if they have additional argument

Closes #958
2025-02-10 11:17:51 +02:00
Pekka Enberg
b7933a956f docs: Fold typical_query.md to internals.md 2025-02-10 11:15:57 +02:00
Pekka Enberg
c24be74496 Merge 'Remove flaky pragma cli tests' from Sonny
Remove flaky pragma cli tests. Solves #964
Tests for similar behavior already covered in TCL and Rust connection
api tests. So flaky problem in these is not worth exploring. We just
removed them.
covered in Rust integration https://github.com/tursodatabase/limbo/blob/
55058cade30391345ef0385ef2db900c65a65ee2/tests/integration/wal/test_wal.
rs#L9C1-L27C64
covered in TCL https://github.com/tursodatabase/limbo/blob/55058cade3039
1345ef0385ef2db900c65a65ee2/testing/pragma.test#L10

Closes #965
2025-02-10 11:10:14 +02:00
Pekka Enberg
e51661c109 Update internals.md 2025-02-10 11:09:26 +02:00
sonhmai
faab51ac35 remove flaky pragma cli tests.
Tests for similar behavior already covered in TCL and Rust connection api tests. So flaky problem in these is not worth exploring. We just removed them.
2025-02-10 16:01:29 +07:00
Pekka Enberg
55058cade3 Merge 'Fix cast' from Nikita Sivukhin
Fix codegen for `CAST` expression and also adjust implementation of
`CAST: Real -> Int` because `SQLite` use "closest integer between the
REAL value and zero" as a CAST result.

Closes #956
2025-02-10 10:53:56 +02:00
Pekka Enberg
09b402e261 Merge 'Fix coalesce' from Nikita Sivukhin
Add `COALESCE` function in fuzz test and fix bug (found by fuzzer with
`COALESCE`) related to the resolution of labels which needs to be
resolved to next emitted instruction.
Before, code assumed that no two labels will need to be resolved to next
emitted instruction. But this assumption is wrong (at least in current
codegen logic) for example for following expression `COALESCE(0,
COALESCE(0, 0))`. Here, both `COALESCE` functions will create label and
resolve it to next emitted instruction in the end of generation. So, in
this case one of the labels will be actually "orphaned" and never be
assigned any position in the emitted code.

Closes #955
2025-02-10 10:53:44 +02:00
Pekka Enberg
31886e8f4c Merge 'Fix case and emit' from Nikita Sivukhin
(after fixing complicated b-tree bugs - I want to end my day with the
joy of fixing simple bugs)
This PR fix bug in emit (which was introduced after switch from
`HashMap` to `Vec`) and also align `CASE` codegen in case of `NULL`
result from `WHEN` clause with SQLite behaviour.

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

Closes #953
2025-02-10 10:53:31 +02:00
Tiago Ribeiro
d00b44d7cd Update integration tests to use the new retrieval methods to access Record values. 2025-02-10 00:31:31 -07:00
Tiago Ribeiro
c071e47b03 Update cli to use the new retrieval methods to access Record values. 2025-02-10 00:31:28 -07:00
Tiago Ribeiro
d807b533f7 Update sqlite3 c binding to use the new retrieval methods to access Record values. 2025-02-10 00:27:52 -07:00
Tiago Ribeiro
7867e54110 Update simulator to use the new retrieval methods to access Record values. 2025-02-10 00:27:51 -07:00
Tiago Ribeiro
c69d69a3a2 Update python bindings to use the new retrieval methods to access Record values. 2025-02-10 00:27:51 -07:00
Tiago Ribeiro
4b67e67b31 Update wasm bindings to use the new retrieval methods to access Record values. 2025-02-10 00:27:51 -07:00
Tiago Ribeiro
729524efbd Update java bindings to use the new retrieval methods to access Record values. 2025-02-10 00:27:51 -07:00