Commit Graph

2825 Commits

Author SHA1 Message Date
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
Pekka Enberg
bad5f2cad3 Merge 'Fix a handful of typos' from Aarni Koskela
I noticed the README had a prominent typo ("workin on"), so I decided to
run [crate-ci/typos](https://github.com/crate-ci/typos) on the repo and
fix what it flagged.

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

Closes #952
2025-02-10 07:41:01 +02:00
Pekka Enberg
2eda8a54d9 Merge 'Fix various bugs in B-Tree handling' from Nikita Sivukhin
This PR introduce simple fuzz test for BTree insertion algorithm and
fixes few bugs found by fuzzer
- BTree algorithm returned early although there were overflow pages on
stack and more rebalances were needed
- BTree balancing algorithm worked under assumption that single page
will be enough for rebalance - although this is not always true (if page
were tightly packed with relatively big cells, insertion of new very big
cell can require 3 split pages to distribute the content between them)
- `overflow_cells` wasn't cleared properly during rebalancing
- insertions of dividers to the parent node were implemented incorrectly
- `defragment_page` didn't reset
`PAGE_HEADER_OFFSET_FRAGMENTED_BYTES_COUNT` field which can lead to
suboptimal usage of pages

Closes #951
2025-02-10 07:40:27 +02:00
Pekka Enberg
e559b0c4b3 Merge 'Expose types in Wal' from Jorge López Tello
We expose Wal trait as public, but there are three types in its
signature that are private.
Notice I chose to expose limbo_core::result instead of
limbo_core::result::LimboResult, since LimboResult is the only type in
that module.

Closes #939
2025-02-10 07:38:59 +02:00
Nikita Sivukhin
7cdad64a5f fix assertion in test_quote 2025-02-09 23:50:11 +04:00
Nikita Sivukhin
f22bfad695 reduce amount of iterations in fuzz test 2025-02-09 23:44:38 +04:00
Nikita Sivukhin
5fa6a452c1 add TCL test for quoting of quotes 2025-02-09 23:43:34 +04:00
Nikita Sivukhin
cd4bfac059 fix quote functions 2025-02-09 23:43:34 +04:00
Nikita Sivukhin
cc7267b0bd fix trim function pattern handling 2025-02-09 23:43:34 +04:00
Nikita Sivukhin
459a78bc64 add fuzz test for few string functions 2025-02-09 23:43:34 +04:00
Nikita Sivukhin
5773f767af fix bug after refactoring in LIKE and GLOB 2025-02-09 23:42:53 +04:00
Nikita Sivukhin
a744dd8419 translate_and_mark helper with its previous signature is error prone - so replace it with more explicit option which accept target register 2025-02-09 23:18:46 +04:00
Nikita Sivukhin
d2fb772936 adjust CAST fuzzing options 2025-02-09 22:47:06 +04:00
Nikita Sivukhin
a37b74666f remove unnecessary floor() 2025-02-09 22:41:08 +04:00
Nikita Sivukhin
3c4d9a93af fix rounding of REAL to INTEGER
- SQLite rounds (x: f64) to the nearest number between x and 0 - so
  basically truncates the x
2025-02-09 22:32:54 +04:00
Nikita Sivukhin
e3e399f9b1 fixup fuzz 2025-02-09 22:31:13 +04:00
Nikita Sivukhin
dff1fdc853 fix codegen of CAST 2025-02-09 22:20:28 +04:00
Nikita Sivukhin
9a3af4bd06 add CAST expression in the fuzz test 2025-02-09 22:20:13 +04:00
Nikita Sivukhin
adfc1f1af3 extend TCL tests for COALESCE 2025-02-09 22:01:33 +04:00
Nikita Sivukhin
abcebf7915 add coalesce in fuzz test 2025-02-09 21:55:43 +04:00
Nikita Sivukhin
cf59771599 allow multiple labels to be resolved as next emitted instruction
- right-nested expression can generate multiple labels which needs to be
  resolved to next generated instruction
- for example, COALESCE(0, COALESCE(0, 1))
2025-02-09 21:54:48 +04:00
Nikita Sivukhin
0595e7308d add TCL "CASE ... WHEN" test for null evaluation result 2025-02-09 21:53:50 +04:00
Nikita Sivukhin
a61736bec1 adjust evaluation of NULL results in WHEN clauses with SQLite spec 2025-02-09 21:33:54 +04:00
Nikita Sivukhin
6d67016492 fix bug after switch from HashMap to Vec 2025-02-09 21:33:37 +04:00
Nikita Sivukhin
c3b7938266 add case expr in fuzzer and adjust probabilities 2025-02-09 21:33:14 +04:00
Aarni Koskela
eaea02c567 Fix a handful of typos 2025-02-09 18:08:29 +02:00
Pekka Enberg
e3eb2f1a9a Merge 'bindings/java: Remove AbstractDB ' from Kim Seon Woo
## Purpose of this PR
- Remove `AbstractDB` and put limbo db related methods into `LimboDB`
## Changes
- Remove `AbstractDB`
- Implement `close()`
## Reference
- [Issue](https://github.com/tursodatabase/limbo/issues/615)

Closes #946
2025-02-09 17:36:48 +02:00
Pekka Enberg
2a8687d13f Merge 'bindings/java: Implement some minor TODOs ' from Kim Seon Woo
## Changes
- Implement relatively important (TODO) methods first for
`JDBC4Connection`, `JDBC4Statement`, `JDBC4PreparedStatement`
## Reference
- [Issue](https://github.com/tursodatabase/limbo/issues/615)

Closes #945
2025-02-09 17:36:41 +02:00
Pekka Enberg
728e8ca4f1 Merge 'chore: remove unused dependencies' from meteorgan
remove unused dependencies

Closes #948
2025-02-09 17:36:18 +02:00
Nikita Sivukhin
1b9772e9ad fix clippy 2025-02-09 19:36:14 +04:00
Pekka Enberg
9e65d7ddea Merge 'perf/prepare: box even more stuff to shrink the YYMINORTYPE enum further' from Jussi Saurio
the boxings will continue until morale improves
<img width="621" alt="Screenshot 2025-02-09 at 14 16 21"
src="https://github.com/user-
attachments/assets/887d218d-3db7-4a64-ad81-b7431adb23bb" />

Closes #947
2025-02-09 17:36:03 +02:00
Nikita Sivukhin
32b5b0d019 introduce additional condition for cells distribution in order to avoid almost empty pages 2025-02-09 19:26:03 +04:00
Nikita Sivukhin
bc289d314a adjust test a bit 2025-02-09 19:20:48 +04:00
Nikita Sivukhin
e23ea35993 add simple B-tree validation func 2025-02-09 19:20:37 +04:00
Nikita Sivukhin
a59589844d fix insertion to the parent 2025-02-09 19:19:36 +04:00
Nikita Sivukhin
6c40f52fc8 separate fuzz tests in categories 2025-02-09 18:37:04 +04:00
Nikita Sivukhin
9049c91863 find cell in parent node 2025-02-09 18:36:37 +04:00
Nikita Sivukhin
9e4afd1d13 relax assertion 2025-02-09 18:36:26 +04:00
Nikita Sivukhin
8e6569434a add fuzz 2025-02-09 18:10:59 +04:00
Nikita Sivukhin
a62265eef4 hanle balancing cases when more than 1 level is affected 2025-02-09 18:10:19 +04:00
Nikita Sivukhin
d2251b1dd1 fix 2025-02-09 18:09:53 +04:00
Nikita Sivukhin
e8a585f87a adjust logging 2025-02-09 18:09:43 +04:00
김선우
2fa3a1e6ae Apply lint 2025-02-09 22:46:48 +09:00