mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix a segfault in fromModifiedJulianDay()
It was crashing when the argument type was Nullable(T) where T was any integral type other than Int32.
This commit is contained in:
parent
8c0ec5105b
commit
5f7a852b92
@ -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 }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user