Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked open and closed issues.
No existing issue was found for FLOOR evaluating a NULL character value as an empty string.
Branch Name
main
Commit ID
f0c31cd4b830be32442cf329e0a3fb08aa9c16c3
Other Environment Information
- Local standalone MatrixOne built from the commit above
- Reference: MySQL 8.3.0
Actual Behavior
FLOOR() does not preserve NULL when its resolved input type is VARCHAR. It appends a NULL result, then continues and attempts to parse the NULL row's empty payload as a floating-point number:
SELECT FLOOR(CAST(NULL AS CHAR));
-- MatrixOne: strconv.ParseFloat: parsing "": invalid syntax
-- MySQL: NULLThe same error aborts a query when a VARCHAR column contains a NULL row:
CREATE TABLE src(id INT PRIMARY KEY, s VARCHAR(20));
INSERT INTO src VALUES (1,'1.9'),(2,NULL),(3,'-1.1');
SELECT id,FLOOR(s) FROM src ORDER BY id;
-- MatrixOne: strconv.ParseFloat: parsing "": invalid syntax
-- MySQL: (1,1), (2,NULL), (3,-2)As a consequence, CTAS over the expression also aborts and does not create its target table. Filtering NULL rows before evaluation or guarding them with CASE avoids the error. An untyped FLOOR(NULL) and a prepared NULL parameter both return NULL, so the defect is specific to the VARCHAR execution overload.
Each constant, single-row column, mixed-vector, guarded, prepared, and CTAS form was executed three times with the same result. The source table and connection remain healthy after every error.
Expected Behavior
FLOOR() must propagate NULL for character expressions just as it does for numeric expressions. A NULL row must not be passed to strconv.ParseFloat, and valid rows in the same vector must remain queryable.
Steps to Reproduce
DROP DATABASE IF EXISTS codex_floor_varchar_null;
CREATE DATABASE codex_floor_varchar_null;
USE codex_floor_varchar_null;
SELECT FLOOR(NULL); -- NULL control
SELECT FLOOR(CAST(NULL AS CHAR)); -- error
CREATE TABLE src(id INT PRIMARY KEY, s VARCHAR(20));
INSERT INTO src VALUES (1,'1.9'),(2,NULL),(3,'-1.1');
SELECT id,FLOOR(s) FROM src WHERE id=1; -- (1,1)
SELECT id,FLOOR(s) FROM src WHERE id=2; -- error
SELECT id,FLOOR(s) FROM src ORDER BY id; -- error
SELECT id,FLOOR(s) FROM src WHERE s IS NOT NULL ORDER BY id; -- works
CREATE TABLE copied AS SELECT id,FLOOR(s) AS v FROM src; -- errorRoot Cause
FloorStr in pkg/sql/plan/function/func_binary.go builds the result NULL bitmap correctly. In the WithAnyNullValue loop, however, the rsNull.Contains(i) branch appends a NULL but does not continue. Execution then calls GetStrValue(i) and strconv.ParseFloat for the same NULL row, whose payload is an empty byte slice. The comparable generic unary helpers skip NULL rows before invoking their scalar callbacks.
Activity
fix: preserve NULL VARCHAR values in FLOOR (#28510)
Lundomn commentedon Sep 9, 2026
转测 QA(对应已合并 PR #28510):
func_math_string_numeric连续 2 次16/16通过;git diff --check通过。请 QA 完成上述验收后反馈通过/失败及覆盖范围;通过后由 QA 关闭 Issue #28486,失败或需补测时保持 open。
slyunnn commentedon Sep 10, 2026
Regression and extended verification for #28486 (2026-09-10)
Verification Environment
origin/mainat2a6fe7f61358e846a20aafba3b50903a61608682—test(hakeeper): cover empty target removal through checker (#28481).mo-servicebinary was rebuilt from that commit and restarted before verification;mo-service -versionreported2a6fe7f613.2 CN / 1 TN / 1 Log service / Proxy.127.0.0.1:6001, CN1127.0.0.1:16001, and CN2127.0.0.1:16002; each accepted a fresh MySQL connection andSELECT 1.mysqlclient and MOTR. SQL prepared coverage usesPREPARE/EXECUTE.d3794ea96498e4ff1847ebbca6857a230ddfcd39, merged by #28510,fix(function): preserve NULL VARCHAR values in FLOOR.What Was Covered
FLOOR(CAST(NULL AS CHAR))returnedNULL, alongside theFLOOR(NULL)control, through Proxy6001, CN116001, and CN216002.VARCHARvectors withNULLin the first, middle, and last positions preserved values, order, row count, andNULLcorrespondence.NULLinput andCASEselection-mask paths returnedNULLonly for selectedNULLrows.PREPARE/EXECUTEwith a typedNULLparameter returnedNULL.NULL,1, and-2results.FLOOR(123.342, 1)returned123.3.NULLcharacter inputs retained the expectedERROR 1105/strconv.ParseFloatfailure.TestFloorStrSkipsNullAndMaskedRowsandTestFloorStrDecimalPlacesMustBeConstantpassed.19/19statements through Proxy6001, CN116001, and CN216002.FLOOR(CAST('1.29' AS CHAR), 1): the current SQL resolver rejects thatVARCHARtwo-argument form withERROR 20203; the constant-decimal-place behavior of the internalFloorStroverload is directly covered by the exact-head unit test above.Findings
FLOORnow propagatesNULLVARCHARrows before parsing, so they no longer reachstrconv.ParseFloatas empty payloads. Non-NULLmalformed strings still return their original parse error.MOTR / BVT Coverage
test/distributed/cases/function/func_math_floor_varchar_null.test.test/issue-28486-floor-null-varchar.416f403ea54417fea080078dadcb53879139698b,test: add MOTR regression for #28486.suites/14_issue_regression/t/issue_28486_floor_null_varchar.testand its recorded result file.1c6db07123661c26a51ffa5d9a3c850bc4cc3e8b.NULLpropagation and does not depend on row count, block/batch boundaries, memory/spill, concurrency, skew, network transfer, or resource scale.Final Conclusion
Fixed. The original reproduction and required extended coverage passed on the rebuilt latest
origin/mainruntime through the complete2 CN / 1 TN / 1 Log service / Proxytopology. No additional large-data regression is required.fix: preserve NULL VARCHAR values in FLOOR (matrixorigin#28510)
fix: preserve NULL VARCHAR values in FLOOR (matrixorigin#28510)
fix: preserve NULL VARCHAR values in FLOOR (matrixorigin#28510)