Skip to content

fix(frontend): reuse prepared DML specialization by semantic domain - #27802

Open
daviszhen wants to merge 9 commits into
matrixorigin:mainfrom
daviszhen:revert-8b0a5ff873-tpcc-regression
Open

fix(frontend): reuse prepared DML specialization by semantic domain#27802
daviszhen wants to merge 9 commits into
matrixorigin:mainfrom
daviszhen:revert-8b0a5ff873-tpcc-regression

Conversation

@daviszhen

@daviszhen daviszhen commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #27804

What this PR does / why we need it:

The original full revert exposed correctness regressions already covered by current main, including forced multi-CN predicates and INSERT IGNORE ... SELECT. This update keeps the correctness machinery from #27493 and fixes the TPCC regression by reusing execute-time specialization for stable prepared-statement semantic domains.

  • retains runtime type specialization and DML write-expression preservation;
  • caches the specialized plan and Compile for stable prepared DML parameter domains instead of deep-copying, rebinding, and recompiling on every execution;
  • preserves ParamRef provenance in cached plans so a cache hit reads the current execution values rather than values from the first execution;
  • separates generic, numeric-prefix, numeric-overload, and direct-result modes in the cache key, including binary-protocol provenance and the canonical runtime domain;
  • misses the cache and rebuilds when the runtime semantic domain changes;
  • carries the same specialization mode through compile retries;
  • merges the latest upstream main at 4cbdc2cf46 and integrates its prepared numeric-overload path.

Validation

  • go test ./pkg/frontend ./pkg/sql/plan ./pkg/sql/plan/function ./pkg/sql/colexec -count=1
  • go test ./pkg/tests/dml -run '^TestForcedMultiCNDeleteAndInsertIgnore$' -count=1
  • go test ./pkg/tests/issues -run '^TestIssue27443BinaryPreparedDMLAndAggregate$' -count=1
  • focused runtime cache, semantic-key, numeric-overload, and compile-retry tests
  • go vet ./pkg/frontend ./pkg/sql/plan ./pkg/sql/plan/function ./pkg/sql/colexec ./pkg/tests/dml ./pkg/tests/issues
  • golangci-lint run -c .golangci.yml ./pkg/frontend
  • BenchmarkBinaryDMLRuntimeSpecializationCache: 9.1 us/op, 1496 B/op, 26 allocs/op (100 iterations on the local validation host)
  • git diff --check

…origin#27493)"

This reverts commit 8b0a5ff because it regressed TPCC performance.

Preserve the later direct prepared-result specialization from matrixorigin#27713. Explicitly keep INSERT, UPDATE, DELETE, and MERGE on the cached parameterized compile path so removing the reverted DML write-root rewriter cannot reintroduce positional write corruption.
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@daviszhen daviszhen changed the title revert: prepared DML and aggregate runtime specialization fix(frontend): keep prepared DML on cached execution path Aug 28, 2026
@matrix-meow matrix-meow added size/S Denotes a PR that changes [10,99] lines and removed size/XXL Denotes a PR that changes 2000+ lines labels Aug 28, 2026
@mergify mergify Bot added the kind/test-ci label Aug 28, 2026
…pcc-regression

# Conflicts:
#	pkg/frontend/computation_wrapper.go
#	pkg/frontend/computation_wrapper_test.go
@daviszhen daviszhen changed the title fix(frontend): keep prepared DML on cached execution path fix(frontend): reuse prepared DML specialization by semantic domain Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants