fix: rebind prepared numeric runtime types - #27466
Conversation
|
Dependency and combined-path acceptance after PR #27483: PR #27483 should land first because it owns the DECIMAL common-domain behavior and overlaps with this PR in The combined #27483 + #27466 head must validate this SQL CREATE TABLE t (
id INT PRIMARY KEY,
d DECIMAL(20,4)
);
INSERT INTO t VALUES
(1, 9007199254740992.0000),
(2, 9007199254740992.0001),
(3, 9007199254740993.0000);
PREPARE q FROM 'SELECT id FROM t WHERE d BETWEEN ? AND ? ORDER BY id';
SET @lo = '9007199254740992.0001';
SET @hi = '9007199254740992.0001';
EXECUTE q USING @lo, @hi;Expected: On current PR #27466 head This is intentionally an acceptance requirement for PR #27466 after merging #27483, not additional scope for PR #27483. The exact |
What type of PR is this?
Which issue(s) this PR fixes:
issue #25408
What this PR does / why we need it:
This is the second of three scoped changes for prepared runtime parameter handling. PR #27329 fixed only
LIMIT/OFFSET; this PR fixes runtime numeric rebinding and producer-to-consumer type lineage. Type-signature compile-cache reuse remains a separate follow-up.Previously, SQL
EXECUTE ... USINGdid not pass user-variable runtime types into the specialization path used by COM_STMT. Even when an immediate numeric expression was rebound, derived tables, set operations, aggregates, windows, scalar subqueries, DML consumers, and CTAS schemas could retain the prepare-time physical type. That caused invalid casts, wrong overloads, stale vector layouts, panics, and incorrect persisted values.This change:
DOUBLEdomain, while keeping string predicates such asconcat(v, '') = ?in the string domain;Regression coverage includes SQL PREPARE and COM_STMT, integer/unsigned/DECIMAL/FLOAT/DOUBLE/BOOL/string domains, 65-digit integers, 30-digit decimals, scientific notation and underflow, nested expressions, derived tables, UNION, aggregate/window/scalar-subquery consumers, DISTINCT aggregates, UPDATE/DELETE, BIT assignment provenance, explicit casts, REGEXP direction, and CTAS value/schema consistency.
Validation:
mo-cgo-test ./pkg/sql/plan -count=1mo-cgo-test ./pkg/frontend -count=1mo-cgo-test ./pkg/tests/issues -run '^TestIssue25408PreparedRuntimeNumericRebind$' -count=1golangci-lint run -c .golangci.yml ./pkg/sql/plan ./pkg/frontend ./pkg/tests/issues(0 issues)