Commit Graph

5176 Commits

Author SHA1 Message Date
pedrocarlo
c82f4fa0bb adjust creation of columns to avoid name collision 2025-06-11 11:32:18 -03:00
pedrocarlo
1410aaa0be mostly fix binary predicate generation 2025-06-11 11:32:18 -03:00
pedrocarlo
b60037255b small fix to binary true predicate + fuzz test for true_binary_predicate. More tests to come 2025-06-11 11:32:18 -03:00
pedrocarlo
3068c3398e add more operators execution for binary 2025-06-11 11:32:18 -03:00
pedrocarlo
3e1a4bed8b namespace exec_like to Value + complete the test logic for Unary Operators 2025-06-11 11:32:18 -03:00
pedrocarlo
6b58c4a33f migrate to using limbo_core::Value inside Simulator 2025-06-11 11:32:18 -03:00
pedrocarlo
2424b1b1c9 add unary to expr_to_value 2025-06-11 11:32:18 -03:00
pedrocarlo
dc901a019c implement true_unary + false_unary 2025-06-11 11:32:18 -03:00
pedrocarlo
176ec3b0ea adjustments to binary functions + backtrack return Option<T> + start of unary Predicate 2025-06-11 11:32:18 -03:00
pedrocarlo
c12fc23516 extract logic for binary generation outside of predicate.rs 2025-06-11 11:32:18 -03:00
pedrocarlo
7385ac96ec clippy 2025-06-11 11:32:18 -03:00
pedrocarlo
5a1bacc760 adjust generation for ast::Expr 2025-06-11 11:32:17 -03:00
pedrocarlo
62e7b1f64c fix generation for string literal in a different place + simplify test assertion 2025-06-11 11:32:17 -03:00
pedrocarlo
470093ca03 fix generation for string literal 2025-06-11 11:32:17 -03:00
pedrocarlo
b30718ca4b add simulator log to gitignore 2025-06-11 11:32:17 -03:00
pedrocarlo
fac4b4e6fb fix generation and expr evaluation 2025-06-11 11:32:17 -03:00
pedrocarlo
9f2608bded remove previous predicate struct and rewrite generation with the new the struct 2025-06-11 11:32:17 -03:00
pedrocarlo
3e369b9dde drop in replacement for predicate that uses ast::Expr under the hood 2025-06-11 11:32:17 -03:00
pedrocarlo
f230703279 move numeric file for NonNan visibility 2025-06-11 11:32:17 -03:00
pedrocarlo
f535ff1398 add optional serde implementations for parser ast 2025-06-11 11:32:17 -03:00
pedrocarlo
f1146e716c inital implementation for ast generation 2025-06-11 11:32:06 -03:00
pedrocarlo
acb8a47911 sanitize string for ast::Literal 2025-06-11 11:31:47 -03:00
Jussi Saurio
6bb10d4d45 Merge 'Disable index usage in DELETE because it does not work safely' from Jussi Saurio
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1715
2025-06-11 12:23:03 +03:00
Jussi Saurio
e9d1f0823b Disable index usage in DELETE because it does not work safely 2025-06-11 12:15:20 +03:00
Jussi Saurio
32cacd81ef Merge 'Add affinity-based type coercion for seek and comparison operation' from Krishna Vishal
This PR implements SQLite-compatible affinity-based type coercion for
seek operations and comparison operators, bringing Limbo's behavior
closer to SQLite's type conversion rules.
### Key Changes
- Added affinity handling to all comparison operators (`Eq`, `Ne`, `Lt`,
`Le`, `Gt`, `Ge`).
- Added `get_expr_affinity()` to determine expression affinity based on
column types and casts.
- Added affinity functionality `CmpInsFlags` which carries the affinity
information from translation layer to execution layer.
- Added comprehensive `apply_numeric_affinity()` function that handles
many edge cases when converting to numerical quantities.
- Implemented `comparison_affinity()` that follows SQLite's affinity
precedence rules.
- Added fuzz tests for partial numeric strings, hex literals, and
various numeric formats.
### SQLite Compatibility Improvements
This implementation now correctly handles cases like:
- `SELECT * FROM t WHERE x < X'41'` (blob comparisons)
- `SELECT * FROM t WHERE x < '123abc'` (partial numeric strings)
- `SELECT * FROM t WHERE x < 4.9 ` (float precision in seeks)
- Mixed-type comparisons with proper affinity conversion
Thanks 🤝@PThorpe92 and @pedrocarlo for helping improve my planner
understanding.
Closes: https://github.com/tursodatabase/limbo/issues/1607

Closes #1680
2025-06-11 09:52:02 +03:00
Jussi Saurio
b30ed90bea Merge 'sim/aws: fix vibecoding errors in logic' from Jussi Saurio
- Entire stdout+stderr was passed to both title and body for the github
issue, resulting in a failure due to github's validation
Fixes:
- Pass only the line containing "simulation failed:" as title
- Pass max 50 lines following title as body
- Truncate title and body to 255 and 65536 chars respectively before
posting github issue, just to be sure

Closes #1711
2025-06-11 09:45:58 +03:00
Jussi Saurio
0acce8d035 Merge 'Simulator: Better Shrinking' from Pedro Muniz
This PR attempts to get the specific query that failed in the simulator
and get the correct tables that were used in the Query. Also, implements
a fix where after clearing miscellaneous queries, we did not check again
if the the interaction still referenced any of the tables that were
involved in the failure.

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

Closes #1712
2025-06-11 09:45:48 +03:00
Jussi Saurio
4d45577c5a Merge 'Simulator integrity_check' from Pedro Muniz
Adds a Sqlite integrity check after the simulator completes a run. Also
changed error handling in the simulator to use `anyhow` to lazily add
context to error methods instead of eagerly using `.or` and losing the
original error.

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

Closes #1697
2025-06-11 09:45:38 +03:00
pedrocarlo
cf1983ccfe retain the last failing interaction + remove select properties 2025-06-11 03:14:31 -03:00
pedrocarlo
63cf648e2e filter for the tables that the failing query depended on + second pass after query clear 2025-06-11 02:52:26 -03:00
Jussi Saurio
f276ff0b72 sim/aws: fix vibecoding errors in logic
- Entire stdout+stderr was passed to both title and body for the github
  issue, resulting in a failure due to github's validation

Fixes:

- Pass only the line containing "simulation failed:" as title
- Pass max 50 lines following title as body
- Truncate title and body to 255 and 65536 chars respectively
  before posting github issue, just to be sure
2025-06-11 08:40:04 +03:00
Krishna Vishal
1c6a65ded4 Change seek op match from unit variants to struct variants. 2025-06-11 00:44:07 +05:30
Krishna Vishal
7db6e2dfea Decrease db rows and increase random values 2025-06-11 00:33:48 +05:30
Krishna Vishal
0d5cbc4f1d Add affinity check as a function as ast::Operator impl 2025-06-11 00:33:48 +05:30
Krishna Vishal
712c94537c Add affinity flags to IS and IS NOT opeartors 2025-06-11 00:33:48 +05:30
krishvishal
c8da564aeb smol edit 2025-06-11 00:33:48 +05:30
krishvishal
5a1da026e6 Unify comparison function to reduce code duplication 2025-06-11 00:33:47 +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
d13abad4b1 Handle Blob type together with Text type in op_seek 2025-06-11 00:33:47 +05:30
krishvishal
6c04c18f87 Add affinity flag to comparison opcodes 2025-06-11 00:33:47 +05:30
krishvishal
f0dda1702f Fix AFFINITY_MASK value 2025-06-11 00:33:47 +05:30
krishvishal
faa9aedbae Add affinity based type coercion to comparison ops 2025-06-11 00:33:47 +05:30
krishvishal
7bd1589615 Added affinity inference and conversion for comparison ops.
Added affinity helper function for `CmpInsFlags`
2025-06-11 00:33:44 +05:30
krishvishal
9130b25111 Add jump_if_null flag for rowid alias based seeks 2025-06-11 00:33:05 +05:30
krishvishal
3b2980c7c0 Fix op_seek to handle affinity coercion 2025-06-11 00:33:05 +05:30
krishvishal
e68293a1d1 Add affinity conversion to op_gt, op_le, op_lt, op_eq, op_ne 2025-06-11 00:33:05 +05:30
krishvishal
30ccbe46c7 Added apply_numeric_affinity function to handle string conversion
to integer. Exising functions' behavior is tailored to `CAST` ops.
SQLite has different behavior when it comes to handling string to
`integer` conversion in CAST vs predicate ops.
2025-06-11 00:33:05 +05:30
krishvishal
9eb2235135 A simple fuzz test for fuzzing seeking ops 2025-06-11 00:33:05 +05:30
krishvishal
20e6e73057 Fix affinity in op_seek when there's string integer comparison 2025-06-11 00:33:03 +05:30