Commit Graph

80 Commits

Author SHA1 Message Date
Jussi Saurio
025ea8808a Merge 'WAL insert: mark pages as dirty' from Nikita Sivukhin
WAL insert API introduced in the #2231 works incorrectly as it never
mark inserted pages as dirty.
This PR fixes this issue and also add simple fuzz test which fails
without fixes.

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

Closes #2245
2025-07-24 12:58:01 +03:00
Nikita Sivukhin
435ca7fe7a add fuzz tests for raw WAL API 2025-07-24 11:49:39 +04:00
Jussi Saurio
52b4c22be9 Merge 'fix: SUM returns correct float for mixed numeric/non-numeric types & return value on empty set' from Axel Tobieson Rova
# Fix SUM aggregate function for mixed types
Fixes #2133
The SUM aggregate function was returning incorrect results when
processing tables with mixed numeric and non-numeric values. According
to SQLite documentation:
> "If any input to sum() is neither an integer nor a NULL, then sum()
returns a floating point value"
[*](https://sqlite.org/lang_aggfunc.html)
Now both SQLite and Turso yield the same output of 44.0.
--
I modified `Sum` to increment only for numeric values, skipping non-
numeric values. However, if we have mixed numeric values or non-numeric
values, we return a float output. Added a flag to keep track of it.
as pointed out by @FHaggs , If there are no non-NULL input rows then
sum() returns NULL but total() returns 0.0. I decided to include it in
this PR as well. Empty was such a natural test case.

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

Closes #2182
2025-07-24 10:08:01 +03:00
Axel
9d05344258 Fix Sum() return value if there are no non-NULL input rows
Add simple fuzz test for total and sum.
2025-07-22 17:38:09 +02:00
Jussi Saurio
022f679fab chore: make every CREATE TABLE stmt in entire repo have 1 space after tbl name
`BTreeTable::to_sql` makes us incompatible with SQLite by losing e.g. the original whitespace provided during the CREATE TABLE command.

For now let's fix our tests by regex-replacing every CREATE TABLE in
the entire repo to have exactly 1 space after the table name in the
CREATE TABLE statement.
2025-07-22 11:35:21 +03:00
Jussi Saurio
615ccf6789 test/fuzz: fix rowid_seek_fuzz
The original `rowid_seek_fuzz` test had a design flaw: it inserted contiguous
integers, which prevented issues such as the one fixed in #2065 from being
discovered.

Further, the test has at some point also been neutered a bit by only inserting
100 values which makes the btree very small, hiding interactions between interior
pages and neighboring leaf pages.

This should not be merged until #2065 is merged.
2025-07-14 12:57:59 +03:00
Jussi Saurio
a48b6d049a Another post-rebase clippy round with 1.88.0 2025-07-12 19:10:56 +03:00
Nils Koch
1a91966c7e fix clippy errors for rust 1.88.0 (manual fix) 2025-07-12 18:58:55 +03:00
Nils Koch
828d4f5016 fix clippy errors for rust 1.88.0 (auto fix) 2025-07-12 18:58:41 +03:00
Jussi Saurio
897f59fab1 test/fuzz: add ignored fuzz test for min()/max() - ignored because of bugs 2025-07-10 21:02:57 +03:00
meteorgan
f44d818400 cargo fmt 2025-07-08 22:57:20 +08:00
meteorgan
6768f073c8 add tests for except operator 2025-07-08 22:57:20 +08:00
Pekka Enberg
9c1b7897ac Fix URLs to point to github.com/tursodatabase/turso 2025-06-30 11:23:53 +03:00
meteorgan
c060905d00 add INTERSECT to compound_select_fuzz 2025-06-27 11:50:19 +08:00
Pekka Enberg
2fc5c0ce5c Switch to runtime flag for enabling indexes
Makes it easier to test the feature:

```
$ cargo run --  --experimental-indexes
Limbo v0.0.22
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
limbo> CREATE TABLE t(x);
limbo> CREATE INDEX t_idx ON t(x);
limbo> DROP INDEX t_idx;
```
2025-06-26 10:07:28 +03:00
Nils Koch
2827b86917 chore: fix clippy warnings 2025-06-23 19:52:13 +01:00
Luca Muscat
7cf77fb35b Fix fuzz issue #1763 by using the log2 & log10 functions where applicable
It is easy to chalk this fuzzer issue to erratic floating point
behaviour, but this is not the case here.

Currently, `exec_math_log` calculates log with arbitrary bases by using
the following formula: `log_a(b) ~= ln(b) / ln(a)`. This calculation is
an approximation with lots of its floating point precision lost to
dividing the results of natural logarithms.

By using the specialized versions of the log functions (`log2` &
`log10`), we can avoid this loss of precision.

SQLite also uses these specialized log functions when possible, so it
doesn't hurt to do the same thing when aiming for parity.
2025-06-20 10:52:13 +02:00
Pere Diaz Bou
34592b172c run index tests with flags instead of ignore 2025-06-17 19:33:23 +02:00
Pere Diaz Bou
de1f29dadf core_tester index fuzz tests with flag 2025-06-17 19:33:23 +02:00
Krishna Vishal
7db6e2dfea Decrease db rows and increase random values 2025-06-11 00:33:48 +05:30
krishvishal
5837f7329f clean up 2025-06-11 00:33:47 +05:30
krishvishal
e01f4d55f7 Reduce fuzz iters 2025-06-11 00:33:47 +05:30
krishvishal
9eb2235135 A simple fuzz test for fuzzing seeking ops 2025-06-11 00:33:05 +05:30
Jussi Saurio
d5623e752b make compound_select_fuzz() test more likely to generate duplicate rows 2025-05-25 21:27:45 +03:00
Jussi Saurio
d893a55c55 UNION 2025-05-25 21:23:04 +03:00
Jussi Saurio
8ed5334ca7 tests/fuzz: add compound_select_fuzz() 2025-05-24 13:12:41 +03:00
Jussi Saurio
cbb3efab82 Fuzz: modify rowid_seek_fuzz so that it catches this regression in the future 2025-05-23 14:28:25 +03:00
pedrocarlo
f28ce2b757 add collations to btree cursor 2025-05-19 15:22:55 -03:00
pedrocarlo
3526a206e4 support Unique properly by creating a vec of auto indices 2025-05-14 11:34:39 -03:00
pedrocarlo
2b3285d669 test opening in read only mode 2025-05-02 16:31:11 -03:00
Jussi Saurio
48071b7ad7 tests/fuzz/compound_index_seek: order select cols by definition order 2025-04-23 17:34:32 +03:00
Jussi Saurio
517390a4ea tests/fuzz/compound_index_seek: show which table had failed query 2025-04-23 16:57:43 +03:00
Jussi Saurio
8477ff0d3d tests/fuzz: amend compound index key fuzz to include nonindexed columns some of the time 2025-04-18 15:13:13 +03:00
Jussi Saurio
95bc644244 tests/fuzz: make compound key fuzz test a bit stricter with ordering 2025-04-16 14:10:25 +03:00
Jussi Saurio
8757510606 test/fuzz: revamp compound key seek fuzz test to include desc indexes and be more efficient 2025-04-16 13:58:12 +03:00
Jussi Saurio
1141cbaf3b logical_expr_fuzz: add primary keys to test table to detect issues w index usage 2025-04-12 11:12:48 +03:00
Jussi Saurio
3d1b4c5292 test/fuzz: modify compound index scan fuzz to utilize both pk columns in where clause 2025-04-10 15:06:18 +03:00
Jussi Saurio
d9bae633c0 Add rowid_seek_fuzz() test 2025-04-09 10:14:29 +03:00
Jussi Saurio
431ef2fa6a Add TCL/differential fuzz tests for verifying index scan behavior 2025-04-09 10:14:29 +03:00
Pere Diaz Bou
ee55116ca6 return row as reference to registers 2025-03-29 22:04:08 +01:00
Pere Diaz Bou
bf37fd3314 wip 2025-03-29 22:02:49 +01:00
Pere Diaz Bou
d01423df83 fix clippy 2025-03-27 17:54:32 +01:00
Pekka Enberg
19a348c91a Merge 'Print seed for failed fuzz tests' from Pedro Muniz
Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1047
2025-03-04 10:25:47 +02:00
Pekka Enberg
936ae307b7 core: Kill value type
We currently have two value types, `Value` and `OwnedValue`. The
original thinking was that `Value` is external type and `OwnedValue` is
internal type. However, this just results in unnecessary transformation
between the types as data crosses the Limbo library boundary.

Let's just follow SQLite here and consolidate on a single value type
(where `sqlite3_value` is just an alias for the internal `Mem` type).
The way this will eventually work is that we can have bunch of
pre-allocated `OwnedValue` objects in `ProgramState` and basically
return a reference to them all the way to the application itself, which
extracts the actual value.
2025-02-26 10:57:45 +02:00
pedrocarlo
521d4d85ca adding seed to output of failed tests 2025-02-19 14:23:09 -03:00
Jussi Saurio
55ff1d2061 remove comment 2025-02-17 10:59:04 +02:00
Jussi Saurio
7eaa3f4da0 Extract variable 2025-02-17 10:58:38 +02:00
Jussi Saurio
6940ca84bd Add more column <op> column binary op possibilities to fuzzer 2025-02-17 10:57:58 +02:00
Jussi Saurio
e07007896f tests/fuzz: use mostly the same expression options in select and predicate position 2025-02-17 07:43:09 +02:00
Nikita Sivukhin
0679357fda insert numbers from different categories in order to cover cases of different serial type usage 2025-02-16 12:33:26 +04:00