Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
This is a leaf issue for PR #27466. It is intentionally separate from the DECIMAL common-domain scope of #27088 / PR #27483.
Branch Name
issue-25408-runtime-main (PR #27466)
Commit ID
1181297077afd7fb9de428a54e5cf8bbe1759add
Other Environment Information
- Local embedded MatrixOne engine through
pkg/tests/issues - SQL
PREPARE/EXECUTE USING - Boundary values around IEEE-754
2^53
Actual Behavior
On PR #27466, a string-backed prepared parameter used against an exact BIGINT UNSIGNED or BIT(64) column is converted through FLOAT64. Adjacent integer values above 2^53 then compare equal.
For BIGINT UNSIGNED with parameter '9007199254740993':
- Direct string comparison returns only row
2. - SQL prepared comparison returns rows
1,2.
For BIT(64) with the same parameter:
- Direct string comparison returns only row
2. - SQL prepared comparison returns rows
1,2.
The exact-base control at 6ff9be9646a6ac43e05ba3063de27b2248bbac62 returned only row 2 for the prepared BIGINT UNSIGNED witness, confirming that case as a PR #27466 regression.
Expected Behavior
Prepared execution must preserve the exact comparison domain established by BIGINT UNSIGNED and BIT(64). Direct and prepared forms must both return only row 2; no string-backed exact operand may be rounded through FLOAT64.
Steps to Reproduce
CREATE TABLE prepared_exact_integer_cmp (
id INT PRIMARY KEY,
u BIGINT UNSIGNED,
b BIT(64)
);
INSERT INTO prepared_exact_integer_cmp VALUES
(1, 9007199254740992, 9007199254740992),
(2, 9007199254740993, 9007199254740993),
(3, 9007199254740994, 9007199254740994);
SELECT id
FROM prepared_exact_integer_cmp
WHERE u = '9007199254740993'
ORDER BY id;
-- Expected and direct actual: 2
PREPARE pu FROM
'SELECT id FROM prepared_exact_integer_cmp WHERE u = ? ORDER BY id';
SET @p = '9007199254740993';
EXECUTE pu USING @p;
-- Expected: 2
-- PR #27466 actual: 1,2
SELECT id
FROM prepared_exact_integer_cmp
WHERE b = '9007199254740993'
ORDER BY id;
-- Expected and direct actual: 2
PREPARE pb FROM
'SELECT id FROM prepared_exact_integer_cmp WHERE b = ? ORDER BY id';
EXECUTE pb USING @p;
-- Expected: 2
-- PR #27466 actual: 1,2Additional information
The current PR-head implementation in pkg/sql/plan/visit_plan_rule.go recognizes a fixed exact prepared comparison only when a non-parameter operand is DECIMAL. Otherwise, a string-backed numeric argument is converted to FLOAT64, which loses integer identity above 2^53.
Ownership and acceptance:
- Planned fix: PR fix: rebind prepared numeric runtime types #27466.
- Out of scope for [Bug]: DECIMAL coercion and prepared runtime domains are inconsistent across expression consumers #27088 / PR fix: specialize prepared decimal common types #27483.
- Cover SQL
PREPAREand binaryCOM_STMTexecution. - Cover fresh execution and reuse across string, signed integer, unsigned integer, and NULL bindings.
- Assert exact row sets at
2^53 - 1,2^53,2^53 + 1, and adjacent values. - Preserve ordinary explicit CAST overflow behavior; the prepared fix must not broaden unrelated CAST semantics.
Activity
fix: preserve prepared arithmetic and exact integer semantics (#27795)
ck89119 commentedon Aug 31, 2026
Verified against the latest
main(3f05ced24a). This issue is no longer reproducible.The fix is present in
bebb63f02f(fix: preserve exact BIGINT and BIT prepared comparisons). I ran:The issue-specific SQL
PREPAREand COM_STMT regression cases both passed forBIGINT UNSIGNEDandBIT(64):The full targeted test passed as well. This issue can be closed.
Ariznawlll commentedon Sep 1, 2026
测试版本
main@33af6ae3c0c23e4f277137460577ea64678f7ecf原问题验证
BIGINT UNSIGNED与BIT(64)在2^53-1、2^53、2^53+1、2^53+2边界上,prepared 字符串参数均精确命中对应唯一行,未再发生浮点舍入误匹配。Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
不适用。问题可通过公开 prepared SQL 与精确结果集合验收。
回归测试
issue_27492_prepared_exact_integer.test/.result。测试证据
BIGINT UNSIGNED边界与 prepared 复用语义已用 MySQL 8.3 对照。BIT(64)文本比较转换与本 issue 的精确值契约不同,因此该部分 golden 依据 issue 契约,并由 MatrixOne direct/prepared 两条路径互相校验。测试结论
测试通过。
fix: preserve prepared arithmetic and exact integer semantics (matrix…
fix: preserve prepared arithmetic and exact integer semantics (matrix…
fix: preserve prepared arithmetic and exact integer semantics (matrix…