Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked open and closed issues.
#28137 covers the deliberately selected row-local NULL contract for arithmetic failures in POWER, EXP, and COT. No issue was found for non-finite output from DEGREES.
Branch Name
main
Commit ID
f0c31cd4b830be32442cf329e0a3fb08aa9c16c3
Other Environment Information
- Local standalone MatrixOne built from the commit above
- Reference: MySQL 8.3.0
Actual Behavior
DEGREES() multiplies a finite DOUBLE by 180/pi without checking whether the result is finite. Inputs above approximately 3.137e306 therefore produce SQL-visible positive or negative infinity:
SELECT DEGREES(CAST('3.14e306' AS DOUBLE));
-- MatrixOne: +Inf
-- MySQL: ERROR 1690, DOUBLE value is out of range
SELECT DEGREES(CAST('-3.14e306' AS DOUBLE));
-- MatrixOne: -Inf
-- MySQL: ERROR 1690, DOUBLE value is out of rangeThe value is not classified as NULL, compares equal to itself, and can be persisted by CTAS:
CREATE TABLE t AS
SELECT DEGREES(CAST('3.14e306' AS DOUBLE)) AS v;
SELECT v, v IS NULL, v=v, CAST(v AS CHAR) FROM t;
-- MatrixOne: +Inf, 0, 1, '+Inf'MySQL aborts the CTAS and does not create the table. In MatrixOne, the infinity also propagates through SUM, AVG, and MAX, so later relational processing treats it as an ordinary value.
The same result occurs with a DOUBLE column and through SQL PREPARE. Positive and negative forms, both CTAS forms, and the prepared forms were each repeated three times.
Expected Behavior
DEGREES() must not expose or persist a non-finite DOUBLE produced from finite SQL input. MySQL raises error 1690. If MatrixOne intentionally applies the row-local arithmetic-failure policy selected for #28137, the overflow row should become NULL; either behavior avoids materializing +Inf/-Inf as ordinary SQL values.
Steps to Reproduce
DROP DATABASE IF EXISTS codex_degrees_overflow;
CREATE DATABASE codex_degrees_overflow;
USE codex_degrees_overflow;
SELECT DEGREES(CAST('3e306' AS DOUBLE)); -- finite control
SELECT DEGREES(CAST('3.14e306' AS DOUBLE)); -- +Inf
SELECT DEGREES(CAST('-3.14e306' AS DOUBLE)); -- -Inf
CREATE TABLE src(id INT PRIMARY KEY, x DOUBLE);
INSERT INTO src VALUES (1,3e306),(2,3.14e306),(3,-3.14e306),(4,NULL);
SELECT id,DEGREES(x) FROM src ORDER BY id;
SELECT SUM(DEGREES(x)),AVG(DEGREES(x)),MAX(DEGREES(x)) FROM src;
PREPARE p FROM 'SELECT DEGREES(?)';
SET @x=CAST('3.14e306' AS DOUBLE);
EXECUTE p USING @x;
DEALLOCATE PREPARE p;
CREATE TABLE t AS
SELECT DEGREES(CAST('3.14e306' AS DOUBLE)) AS v;
SELECT v,v IS NULL,v=v,CAST(v AS CHAR) FROM t;Controls
DEGREES(1), zero,NULL, and finite results agree with MySQL.DEGREES(CAST('3e306' AS DOUBLE))remains finite in both engines.RADIANS(CAST('1e308' AS DOUBLE))remains finite and agrees with MySQL.- The server and connection remain healthy after all executions.
Root Cause
builtInDegrees in pkg/sql/plan/function/func_builtin.go uses opUnaryFixedToFixed and directly returns v * (180.0 / math.Pi). It does not check math.IsInf/math.IsNaN. By contrast, the arithmetic-failure implementations for EXP and POWER use *WithNullOnError helpers and reject non-finite intermediate results before appending them.
Activity
Fix SQL compatibility regressions across aggregates, casts, and prepa…
XuPeng-SH commentedon Nov 22, 2026
QA 交接:DEGREES 有限输入溢出时返回 SQL NULL
#32002 已合入
main,合并 SHAd9a43b3156dd6ee54f14bdd4197071e522efd285,最终 PR heada2b88df5。独立定向报告确认溢出返回 NULL、CTAS 列可空且未持久化 Infinity。 上述独立 QA 证据对应较早候选
005ea33b,不是当前合并版的实测。正式评审针对较早 headb1bc02f6,最终 head 的 Iceberg E2E 通过;合并队列记录未显示 Required 已满足。未在当前合并提交复跑,不推定 4.2 或整体 CI 通过。请在合入树核对正负溢出、正常边界、NULL、预编译和 CTAS 的实际值、可空元数据以及聚合行为。 转测不等于验收通过,工单保持开放。
Ariznawlll commentedon Nov 23, 2026
结论
通过。已在官方
main测试开始时的最新提交8f3ec29941cf36f4964f6726ec96e9c6658e2e81上,验证有限 DOUBLE 输入引起的DEGREES溢出不再暴露或持久化 Infinity;正负溢出按当前产品约定分别返回 SQL NULL。本次验证 main,未对 4.2-dev 的行为作结论。关键证据
git_version()返回上述完整 SHA;修复 #32002 合并提交是该测试版本的祖先。3e306结果为有限值1.7188733853924698e+308;零值、NULL、RADIANS(1e308)控制正常。Unhappy:±3.14e306分别返回 NULL;包含正常值、正负溢出及 NULL 的同表查询仅对应行变 NULL,SUM、AVG、MAX忽略 NULL 且COUNT为 1。IS NULL=1,自比较及转字符均返回 NULL;INSERT SELECT 混合写入后 5 行中仅 1 行非 NULL。builtInDegrees的有限输入溢出判断,并在相同源码版本运行TestDegreesFiniteOverflowReturnsNull -count=3,通过。黑盒 MOTR 用例通过正式 runner 重复 3 次:3/3,失败及跳过均为 0。69acc2bfbdaea638850f9789d585613aa3f74449,标记仅运行 main。PR 新一轮 CI 正在执行,不能将其表述为已通过;用户确认可在回归 PR 提交后先关闭,稍后合入。待解决点
无本次验收范围内的阻塞项。MySQL 对该溢出返回错误 1690,MO 当前选择逐行返回 NULL;本次依照研发交接中的 MO 契约验证,并未声称错误码兼容 MySQL。