Commit Graph

1743 Commits

Author SHA1 Message Date
Jussi Saurio
9f44d2a7ac Remove unused Table::Index variant and unused Table methods 2025-01-11 17:07:30 +02:00
Jussi Saurio
9909539b9d Store cursor type (table,index,pseudo,sorter) when allocating cursor 2025-01-11 17:04:16 +02:00
Jussi Saurio
3e2993f5f5 Merge pull request #626 from psvri/fix_csv_quote_import
Fix import csv failing when file contains single quote
2025-01-11 13:26:45 +02:00
Jussi Saurio
81332c6dc5 Merge pull request #651 from sonhmai/chore/fix-url
chore: update repository link in Cargo.toml
2025-01-11 13:25:22 +02:00
sonhmai
d5eb41a0e5 chore: update repository link in Cargo.toml 2025-01-11 15:30:54 +07:00
psvri
ce8600a695 Fix import csv failing when single quote is in string 2025-01-11 13:48:21 +05:30
Jussi Saurio
bcc85c37a0 Merge 'Implement -> and ->> operators for json' from Kacper Madej
Implements the `->` and `->>` operators. Also fixes a few
inconsistencies between sqlite and limbo for `json_extract` function.
Those three functions are similar, yet return slightly different data
types.

Closes #636
2025-01-11 09:42:16 +02:00
Kacper Madej
002d2e3dde Uncomment failing tests 2025-01-10 19:26:39 +07:00
Kacper Madej
7efa87ff31 Merge branch 'main' into right-arrow-json 2025-01-10 19:25:56 +07:00
Pekka Enberg
3bc86a3cfc Merge 'Add CI for java testing' from Kim Seon Woo
## Purpose of the PR
- Add CI for java testing
## Reference
https://github.com/tursodatabase/limbo/issues/615

Closes #643
2025-01-10 13:05:05 +02:00
김선우
071d9513ab Add CI for java testing 2025-01-10 19:13:52 +09:00
Pekka Enberg
d31ccf2933 Merge 'core/optimizer: do expression rewriting on all expressions' from Jussi Saurio
Fixes #640 , unblocks some tests in #636

Closes #641
2025-01-10 11:23:51 +02:00
Pekka Enberg
93e4b8d917 Merge 'bindings/java: Enhance exception handling logic' from Kim Seon Woo
### Purpose of this PR
- Enhance exception handling logic
  - When exceptions has to be thrown from Rust to Java, let's just
return the error message directly.
  - Removes JNI call to get error message using
`Java_org_github_tursodatabase_core_LimboDB_getErrorMessageUtf8`
- Add `throwJavaException` to assure that the exception throwing logic
works corretly

Closes #642
2025-01-10 11:22:08 +02:00
김선우
90258a44b4 Add throwJavaException 2025-01-10 17:47:27 +09:00
Jussi Saurio
1bcdf99eab core/optimizer: do expression rewriting on all expressions 2025-01-10 10:04:07 +02:00
Kacper Madej
1a46988a73 Fix hardcoded numbers in macros 2025-01-10 14:50:38 +07:00
Kacper Madej
1a85601261 Update docs 2025-01-10 13:41:47 +07:00
Kacper Madej
a2e1ef2439 Use newest SQLite on Github Actions 2025-01-10 13:31:38 +07:00
김선우
3e26e7ebc5 Remove newSQLException and add throwLimboException in the LimboDB.java 2025-01-10 14:58:35 +09:00
Kacper Madej
536fbe9d9e Fix imports 2025-01-10 12:24:08 +07:00
Kacper Madej
91d4ac3ac0 Fix expression chaining 2025-01-10 12:14:57 +07:00
Kacper Madej
0f4e5ad26d Implement simplified json path 2025-01-10 11:50:43 +07:00
Kacper Madej
743a8b2d94 Merge branch 'main' into right-arrow-json 2025-01-10 11:28:13 +07:00
Pekka Enberg
5c38cc88a9 Merge 'Implement open function in Java bindings' from Kim Seon Woo
## Purpose of this PR
- Implement open function
- Add basic structure for the following
  - exception handling
  - testing using gradle
## Changes
- Java
  - Remove unnecessary example code(Connection.java, Cursor.java,
Limbo.java)
  - Implement `open`
  - Add exception handling logic
  - Add junit test
- Rust
  - Add limbo_db.rs which implements native functions defined in
`Limbo.java`
  - Remove unnecessary example code in lib.rs
## TODOS
- Implement core features for AbstractDB.java and LimboDB.java (I'm
currently referencing sqlite-java, but there are some minor differences
as we use rust instead of C)
## Reference
- https://github.com/tursodatabase/limbo/issues/615

Closes #632
2025-01-09 18:05:42 +02:00
Pekka Enberg
317acb842b Merge 'Implement json_type' from Kacper Madej
Closes #631
2025-01-09 14:25:32 +02:00
Pekka Enberg
2bf7e31b64 Merge 'distinguish balance and balance_non_root' from Pere Diaz Bou
`balance_non_root` should be as close as possible to `balance_non_root`
in SQLite. This commits extract `balance_non_root` from `balance` and
renames `balance_leaf` to `balance` as it enables future work on a
complete `balance_non_root` procedure.

Closes #634
2025-01-09 14:24:46 +02:00
Kacper Madej
f4e331231b More tests 2025-01-09 17:22:19 +07:00
Kacper Madej
74e19e2148 Optimization 2025-01-09 17:16:58 +07:00
Jussi Saurio
10fd8bb234 Merge 'Support nested parenthesized conditional expressions in translator' from Preston Thorpe
This PR fixes queries like:
```sql
    SELECT count(*) FROM users WHERE ((age > 25 OR age < 18) AND (city = 'Boston' OR state = 'MA'));
```
Previously we would return `7516` rows instead of `146`, due to
disregarding the final `AND` from within the nested `OR` conditions,
unconditionally short circuiting when a TRUE is found in an OR
expression without any surrounding relevant context.
or:
```sql
    SELECT * FROM users WHERE (((age > 18 AND city = 'New Mario') OR age = 92) AND city = 'Lake Paul');
```
Previously we would incorrectly return the top row:
```
9984|Leah|Russell|..|..|6733 Weber Crossing|New Mario|SC|57707|78
9989|Timothy|Harrison|..|..|782 Wright Harbors|Lake Paul|ID|52330|92
```
Added localized jump targets for OR expressions within AND blocks to
prevent premature short-circuiting and `parent operator` to condition
metadata to trigger them.
If parent operator should instead be another function param on
`translate_conditional_expr`, instead of a field in condition_metadata,
let me know and I can change it.
EDIT: sorry I realize I should have included the other cleanup changes
in a different PR. I will fix this after work

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

Closes #633
2025-01-09 11:58:45 +02:00
Kacper Madej
dd533414ef Implement -> and ->> operators for json 2025-01-09 15:38:32 +07:00
Kacper Madej
eebf9bfaac Implement json_type 2025-01-09 11:29:17 +07:00
PThorpe92
97d0fc68b2 Add macro and helper to clean up expression translations 2025-01-08 19:29:56 -05:00
PThorpe92
183797898b Add tests for nested conditional expressions 2025-01-08 17:19:37 -05:00
PThorpe92
fa0e7d5729 Support nested parenthesized conditional exprs in translator 2025-01-08 17:16:17 -05:00
Pere Diaz Bou
6802bb7e6a distinguish balance and balance_non_root
`balance_non_root` should be as close as possible to `balance_non_root`
in SQLite. This commits extract `balance_non_root` from `balance` and
renames `balance_leaf` to `balance` as it enables future work on a
complete `balance_non_root` procedure.
2025-01-08 19:05:49 +01:00
김선우
b3762b3e92 Fix clippy 2025-01-08 23:01:24 +09:00
김선우
9e0e3dc81a Update rust side logic to open database 2025-01-08 22:51:33 +09:00
김선우
29e434754b Enhance LimboDB.java open logic 2025-01-08 22:50:48 +09:00
김선우
281ba8d552 Remove unused java files 2025-01-08 19:41:31 +09:00
Pekka Enberg
0ef4def900 Merge 'Optimizer bugfixes' from Jussi Saurio
Closes #629
- Fix bug with column being considered rowid alias based on
'primary_key' (non INTEGER pks are not rowid aliases)
- fix logic bug in check_index_scan() that swapped lhs/rhs but not the
comparison op
- Rename eliminate_between to rewrite_exprs and add true/false->1/0 case
there

Closes #630
2025-01-08 09:59:49 +02:00
Jussi Saurio
b062a5f528 Fix bug with column being considered rowid alias based on 'primary_key' 2025-01-08 08:20:13 +02:00
Jussi Saurio
925bd62cbc fix logic bug in check_index_scan() that swapped lhs/rhs but not the comparison op 2025-01-08 08:20:13 +02:00
Jussi Saurio
4a58898863 Rename eliminate_between to rewrite_exprs and add true/false->1/0 case there 2025-01-08 08:20:13 +02:00
Pekka Enberg
bc1fd20892 Merge 'Fix precision issue in datetime tests' from Preston Thorpe
This PR fixes the issue with tests running on slow systems such as
github actions, where a couple `datetime` tests would be off by very
small margins and fail (e.g. #626)
![image](https://github.com/user-
attachments/assets/57d5a7bf-5acc-41f6-839b-034cab771dce)

Closes #627
2025-01-07 20:36:35 +02:00
Pekka Enberg
3a853ada57 Merge 'Rename IO backends to support Linux platforms without io_uring' from Jorge López Tello
As was suggested in #502 I have renamed the IO backends from `darwin` to
`unix` and from `linux` to `io_uring`. The `unix` backend is now
available to Linux platforms without io_uring.

On the topic of letting platforms disable io_uring support, the primary
example is Google, which posted this
[blog](https://security.googleblog.com/2023/06/learnings-from-kctf-
vrps-42-linux.html) in 2023 about disabling io_uring by default in most
of their servers/platforms, including Android (prime candidate user for
a SQLite rewrite).

Closes #628
2025-01-07 20:33:36 +02:00
PThorpe92
345107ce21 Fix precision issue in datetime tests 2025-01-07 09:57:19 -05:00
Jorge López
511c0b495d Rename LinuxIOError to UringIOError to match the IO backend renames 2025-01-07 15:19:31 +01:00
Jorge López
e5a12bdf01 Rename linux backend to io_uring and darwin to unix. Add new feature flag to IO backend selection 2025-01-07 15:19:29 +01:00
Jorge López
737533e35f Prepare Cargo.toml for upcoming rewrite from macos->unix and linux->io_uring. Make io_uring an optional dependency that is only enabled with a new default feature io-uring. 2025-01-07 15:17:24 +01:00
Pekka Enberg
fbb5ddd8f1 Merge 'Simplify working with labels' from Jussi Saurio
TLDR: no need to call either of:
---
program.emit_insn_with_label_dependency() -> just call
program.emit_insn()
program.defer_label_resolution() -> just call program.resolve_label()
---
Changes:
- make BranchOffset an explicit enum (Label, Offset, Placeholder)
- remove program.emit_insn_with_label_dependency() - label dependency is
automatically detected
- for label to offset mapping, use a hashmap from label(negative i32) to
offset (positive u32)
- resolve all labels in program.build()
- remove program.defer_label_resolution() - all labels are resolved in
build()

Closes #625
2025-01-07 13:11:19 +02:00