From fd6a2f46a51486eae4990b516b8300002522114f Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Mon, 4 Jun 2018 20:47:33 +0100 Subject: [PATCH] MCOL-1429 Fix DAYNAME()/MONTHNAME() NULL result For NULL result -1 cast to a uint was used as an array index. This caused crashes with TIME data type. --- utils/funcexp/func_dayname.cpp | 4 +++- utils/funcexp/func_monthname.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/funcexp/func_dayname.cpp b/utils/funcexp/func_dayname.cpp index 3825bc1a3..325fb2f4a 100644 --- a/utils/funcexp/func_dayname.cpp +++ b/utils/funcexp/func_dayname.cpp @@ -145,7 +145,9 @@ string Func_dayname::getStrVal(rowgroup::Row& row, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { - uint32_t weekday = getIntVal(row, parm, isNull, op_ct); + int32_t weekday = getIntVal(row, parm, isNull, op_ct); + if (weekday == -1) + return ""; return helpers::weekdayFullNames[weekday]; } diff --git a/utils/funcexp/func_monthname.cpp b/utils/funcexp/func_monthname.cpp index dbe5aa513..8d8200775 100644 --- a/utils/funcexp/func_monthname.cpp +++ b/utils/funcexp/func_monthname.cpp @@ -47,7 +47,9 @@ string Func_monthname::getStrVal(rowgroup::Row& row, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { - uint32_t month = getIntVal(row, parm, isNull, op_ct); + int32_t month = getIntVal(row, parm, isNull, op_ct); + if (month == -1) + return ""; return helpers::monthFullNames[month]; }