mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #19959 from depressed-pho/fix-segv-fromModifiedJulianDay
Fix a segfault in fromModifiedJulianDay()
This commit is contained in:
commit
4d0973cf25
@ -163,7 +163,7 @@ namespace DB
|
|||||||
|
|
||||||
FunctionBaseImplPtr build(const ColumnsWithTypeAndName & arguments, const DataTypePtr & return_type) const override
|
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 };
|
DataTypes argument_types = { from_type };
|
||||||
FunctionBaseImplPtr base;
|
FunctionBaseImplPtr base;
|
||||||
auto call = [&](const auto & types) -> bool
|
auto call = [&](const auto & types) -> bool
|
||||||
@ -185,7 +185,7 @@ namespace DB
|
|||||||
* here causes a SEGV. So we must somehow create a
|
* here causes a SEGV. So we must somehow create a
|
||||||
* dummy implementation and return it.
|
* 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);
|
return std::make_unique<FunctionBaseFromModifiedJulianDay<Name, DataTypeInt32, nullOnErrors>>(argument_types, return_type);
|
||||||
else
|
else
|
||||||
// Should not happen.
|
// Should not happen.
|
||||||
|
@ -3,6 +3,7 @@ Invocation with constant
|
|||||||
1858-11-17
|
1858-11-17
|
||||||
2020-11-01
|
2020-11-01
|
||||||
\N
|
\N
|
||||||
|
\N
|
||||||
or null
|
or null
|
||||||
2020-11-01
|
2020-11-01
|
||||||
\N
|
\N
|
||||||
|
@ -5,6 +5,7 @@ SELECT fromModifiedJulianDay(-1);
|
|||||||
SELECT fromModifiedJulianDay(0);
|
SELECT fromModifiedJulianDay(0);
|
||||||
SELECT fromModifiedJulianDay(59154);
|
SELECT fromModifiedJulianDay(59154);
|
||||||
SELECT fromModifiedJulianDay(NULL);
|
SELECT fromModifiedJulianDay(NULL);
|
||||||
|
SELECT fromModifiedJulianDay(CAST(NULL, 'Nullable(Int64)'));
|
||||||
SELECT fromModifiedJulianDay(-678942); -- { serverError 490 }
|
SELECT fromModifiedJulianDay(-678942); -- { serverError 490 }
|
||||||
SELECT fromModifiedJulianDay(2973484); -- { serverError 490 }
|
SELECT fromModifiedJulianDay(2973484); -- { serverError 490 }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user