mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Backport #68098 to 24.5: Fix UB in hopEnd, hopStart, tumbleEnd, and tumbleStart
This commit is contained in:
parent
634fb35e9d
commit
76f27f0e65
@ -269,7 +269,12 @@ struct TimeWindowImpl<TUMBLE_START>
|
|||||||
{
|
{
|
||||||
auto type = WhichDataType(arguments[0].type);
|
auto type = WhichDataType(arguments[0].type);
|
||||||
if (type.isTuple())
|
if (type.isTuple())
|
||||||
return std::static_pointer_cast<const DataTypeTuple>(arguments[0].type)->getElement(0);
|
{
|
||||||
|
const auto & tuple_elems = std::static_pointer_cast<const DataTypeTuple>(arguments[0].type)->getElements();
|
||||||
|
if (tuple_elems.empty())
|
||||||
|
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Tuple passed to {} should not be empty", function_name);
|
||||||
|
return tuple_elems[0];
|
||||||
|
}
|
||||||
else if (type.isUInt32())
|
else if (type.isUInt32())
|
||||||
return std::make_shared<DataTypeDateTime>();
|
return std::make_shared<DataTypeDateTime>();
|
||||||
else
|
else
|
||||||
@ -627,7 +632,12 @@ struct TimeWindowImpl<HOP_START>
|
|||||||
{
|
{
|
||||||
auto type = WhichDataType(arguments[0].type);
|
auto type = WhichDataType(arguments[0].type);
|
||||||
if (type.isTuple())
|
if (type.isTuple())
|
||||||
return std::static_pointer_cast<const DataTypeTuple>(arguments[0].type)->getElement(0);
|
{
|
||||||
|
const auto & tuple_elems = std::static_pointer_cast<const DataTypeTuple>(arguments[0].type)->getElements();
|
||||||
|
if (tuple_elems.empty())
|
||||||
|
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Tuple passed to {} should not be empty", function_name);
|
||||||
|
return tuple_elems[0];
|
||||||
|
}
|
||||||
else if (type.isUInt32())
|
else if (type.isUInt32())
|
||||||
return std::make_shared<DataTypeDateTime>();
|
return std::make_shared<DataTypeDateTime>();
|
||||||
else
|
else
|
||||||
|
@ -67,3 +67,7 @@ SELECT toDateTime(hopEnd(toDateTime('2020-01-09 12:00:01', 'US/Samoa'), INTERVAL
|
|||||||
2020-01-10 00:00:00
|
2020-01-10 00:00:00
|
||||||
SELECT hopEnd(hop(toDateTime('2019-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, INTERVAL '3' DAY, 'US/Samoa'));
|
SELECT hopEnd(hop(toDateTime('2019-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, INTERVAL '3' DAY, 'US/Samoa'));
|
||||||
2019-01-10 00:00:00
|
2019-01-10 00:00:00
|
||||||
|
SELECT hopStart(tuple()); -- { serverError ILLEGAL_COLUMN }
|
||||||
|
SELECT hopEnd(tuple()); -- { serverError ILLEGAL_COLUMN }
|
||||||
|
SELECT tumbleStart(tuple()); -- { serverError ILLEGAL_COLUMN }
|
||||||
|
SELECT tumbleEnd(tuple()); -- { serverError ILLEGAL_COLUMN }
|
||||||
|
@ -36,3 +36,8 @@ SELECT hopEnd(toDateTime('2020-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, I
|
|||||||
SELECT toDateTime(hopEnd(toDateTime('2020-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, INTERVAL '3' DAY, 'US/Samoa'), 'US/Samoa');
|
SELECT toDateTime(hopEnd(toDateTime('2020-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, INTERVAL '3' DAY, 'US/Samoa'), 'US/Samoa');
|
||||||
SELECT toDateTime(hopEnd(toDateTime('2020-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, INTERVAL '3' DAY, 'US/Samoa'), 'US/Samoa');
|
SELECT toDateTime(hopEnd(toDateTime('2020-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, INTERVAL '3' DAY, 'US/Samoa'), 'US/Samoa');
|
||||||
SELECT hopEnd(hop(toDateTime('2019-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, INTERVAL '3' DAY, 'US/Samoa'));
|
SELECT hopEnd(hop(toDateTime('2019-01-09 12:00:01', 'US/Samoa'), INTERVAL '1' DAY, INTERVAL '3' DAY, 'US/Samoa'));
|
||||||
|
|
||||||
|
SELECT hopStart(tuple()); -- { serverError ILLEGAL_COLUMN }
|
||||||
|
SELECT hopEnd(tuple()); -- { serverError ILLEGAL_COLUMN }
|
||||||
|
SELECT tumbleStart(tuple()); -- { serverError ILLEGAL_COLUMN }
|
||||||
|
SELECT tumbleEnd(tuple()); -- { serverError ILLEGAL_COLUMN }
|
||||||
|
Loading…
Reference in New Issue
Block a user