提交 5f7a852b 编写于 作者: P PHO

Fix a segfault in fromModifiedJulianDay()

It was crashing when the argument type was Nullable(T) where T was any integral type other than Int32.
上级 8c0ec510
......@@ -163,7 +163,7 @@ namespace DB
FunctionBaseImplPtr build(const ColumnsWithTypeAndName & arguments, const DataTypePtr & return_type) const override
{
const DataTypePtr & from_type = arguments[0].type;
const DataTypePtr & from_type = removeNullable(arguments[0].type);
DataTypes argument_types = { from_type };
FunctionBaseImplPtr base;
auto call = [&](const auto & types) -> bool
......@@ -185,7 +185,7 @@ namespace DB
* here causes a SEGV. So we must somehow create a
* dummy implementation and return it.
*/
if (WhichDataType(from_type).isNullable()) // Nullable(Nothing)
if (WhichDataType(from_type).isNothing()) // Nullable(Nothing)
return std::make_unique<FunctionBaseFromModifiedJulianDay<Name, DataTypeInt32, nullOnErrors>>(argument_types, return_type);
else
// Should not happen.
......
......@@ -3,6 +3,7 @@ Invocation with constant
1858-11-17
2020-11-01
\N
\N
or null
2020-11-01
\N
......
......@@ -5,6 +5,7 @@ SELECT fromModifiedJulianDay(-1);
SELECT fromModifiedJulianDay(0);
SELECT fromModifiedJulianDay(59154);
SELECT fromModifiedJulianDay(NULL);
SELECT fromModifiedJulianDay(CAST(NULL, 'Nullable(Int64)'));
SELECT fromModifiedJulianDay(-678942); -- { serverError 490 }
SELECT fromModifiedJulianDay(2973484); -- { serverError 490 }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册