Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
23.10.8, 25.10.4
-
None
Description
Summary
DATE_SUB(column, INTERVAL NULL <unit>) and DATE_ADD(column, INTERVAL NULL <unit>) on a Columnstore table fail with:
ERROR 1815 (HY000): Internal error: An unexpected condition within the query
|
caused an internal processing error within Columnstore.
|
Additional Information: error in BatchPrimitiveProcessor
|
InnoDB correctly returns NULL for the same query. All INTERVAL unit types are affected.
Minimal Reproduction
CREATE TABLE t_null (dt DATETIME) ENGINE=Columnstore; |
INSERT INTO t_null VALUES ('2020-01-01 12:00:00'); |
|
|
-- Expected: NULL. Actual: ERROR 1815
|
SELECT DATE_SUB(dt, INTERVAL NULL DAY) FROM t_null; |
All interval types fail: SECOND, MINUTE, HOUR, DAY, MONTH, YEAR, DAY_HOUR, DAY_MINUTE, HOUR_SECOND, MINUTE_MICROSECOND, etc.
DATE_ADD is also affected. Literal DATE_SUB('2020-01-01', INTERVAL NULL DAY) works (returns NULL).
InnoDB comparison
CREATE TABLE t_null_i (dt DATETIME) ENGINE=InnoDB; |
INSERT INTO t_null_i VALUES ('2020-01-01 12:00:00'); |
SELECT dt, DATE_SUB(dt, INTERVAL NULL DAY), DATE_SUB(dt, INTERVAL NULL SECOND), DATE_ADD(dt, INTERVAL NULL MONTH) FROM t_null_i; |
-- Returns: NULL, NULL, NULL (correct)
|
Probable Root Cause
utils/funcexp/func_date_add.cpp, line 826: after evaluating parm[1]>data()>getStrVal(row, isNull), there is no check of isNull before calling helpers::dateAdd(). When the interval is NULL, getStrVal sets isNull=true and returns an empty string. getNumbers("") returns index ≤ 0, and line 94 throws runtime_error("expression type is not supported") which propagates as a BPP error.
Fix: check isNull after line 826, return 0 before calling dateAdd.
Version
MariaDB Columnstore 25.10.4 (stable-23.10)