Skip to content

Fix SQL semantics and add VARBINARY - #390

Merged
KKould merged 10 commits into
mainfrom
fix/sql-semantics
Oct 25, 2026
Merged

KKould merged 10 commits into
mainfrom
fix/sql-semantics

Conversation

@KKould

@KKould KKould commented Oct 25, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Several SQL semantics diverged from SQLite/PostgreSQL behavior, and binary values and uncorrelated quantified subqueries in SELECT were unsupported.

Issue link:

What is changed and how it works?

  • Support uncorrelated quantified subqueries (IN/ANY/ALL) in the SELECT list by sharing MarkApply preparation with WHERE.
  • Add VARBINARY values with casts, comparison, and spill/serialization support.
  • Unify numeric-string comparisons and make the parser recursion limit configurable via DataBaseBuilder::parser_recursion_limit.
  • Map REPLACE to overwrite semantics, bind index DDL options explicitly, honor AVG(DISTINCT), and reject DISTINCT * arguments.
  • Strengthen regression coverage for codecs, statistics, checkpoint recovery, parameter ranges, and ALTER atomicity.

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

  • Validation: make test passes (533 tests) and all SLT files pass.
  • Behavior changes: numeric-string comparisons, REPLACE, and AVG(DISTINCT) now return different results than before.

Share MarkApply preparation between WHERE and SELECT consumers, bind marker output positions through an expression iterator, and remove placeholder predicates. Reject UPDATE targets that are not base tables and cover view writes.
Cover scalar identity and spill codecs, persistent statistics, checkpoint recovery, parameter ranges, ORM writes and ALTER failure atomicity. Consolidate scalar-function SLT files and exclude test-only regions from coverage. Fix ORM HAVING binding against the actual aggregate outputs.
- Deduplicate non-null AVG inputs only when DISTINCT is requested and
  preserve DISTINCT in aggregate display.
- Reject DISTINCT wildcard arguments before wildcard lowering while keeping
  COUNT(*) and COUNT(DISTINCT '*') valid.
- Cover simple, grouped, empty, and cached DISTINCT aggregate results.
@KKould KKould added the bug Something isn't working label Oct 25, 2026
@KKould KKould self-assigned this Oct 25, 2026
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.46032% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.53%. Comparing base (c78efe9) to head (e3dc1d3).

Files with missing lines Patch % Lines
src/types/value.rs 80.00% 7 Missing ⚠️
src/binder/parser.rs 94.82% 6 Missing ⚠️
src/binder/expr.rs 50.00% 4 Missing ⚠️
src/orm/mod.rs 62.50% 3 Missing ⚠️
src/types/evaluator/date.rs 40.00% 3 Missing ⚠️
src/types/evaluator/datetime.rs 40.00% 3 Missing ⚠️
src/types/evaluator/time32.rs 57.14% 3 Missing ⚠️
src/types/evaluator/time64.rs 70.00% 3 Missing ⚠️
src/binder/select.rs 96.92% 2 Missing ⚠️
src/types/evaluator/bytes.rs 85.71% 1 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #390      +/-   ##
==========================================
- Coverage   93.68%   93.53%   -0.16%     
==========================================
  Files         260      260              
  Lines       48783    34412   -14371     
==========================================
- Hits        45704    32188   -13516     
+ Misses       3079     2224     -855     
Flag Coverage Δ
rust 93.53% <92.46%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/binder/aggregate.rs 97.26% <100.00%> (-0.75%) ⬇️
src/binder/create_table.rs 76.66% <ø> (-11.01%) ⬇️
src/binder/distinct.rs 98.66% <ø> (-0.60%) ⬇️
src/binder/mod.rs 84.42% <ø> (-2.33%) ⬇️
src/catalog/column.rs 89.58% <ø> (-1.28%) ⬇️
src/catalog/table.rs 98.43% <ø> (-0.36%) ⬇️
src/db.rs 95.98% <100.00%> (+2.56%) ⬆️
src/db/prepared.rs 93.47% <100.00%> (-1.08%) ⬇️
src/execution/dml/analyze.rs 95.45% <ø> (-2.56%) ⬇️
src/execution/dml/copy_from_file.rs 96.61% <ø> (-0.89%) ⬇️
... and 89 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KKould
KKould merged commit eeb2306 into main Oct 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant