Merge pull request #41563 from Algunenano/groupBitmap_crash

Prevent crash when passing wrong aggregation states to groupBitmap*
This commit is contained in:
Anton Popov 2022-09-22 01:15:25 +02:00 committed by GitHub
commit a2b5a4bfa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -75,6 +75,12 @@ namespace
/// We need to look inside the type of its argument to obtain it.
const DataTypeAggregateFunction & datatype_aggfunc = dynamic_cast<const DataTypeAggregateFunction &>(*argument_type_ptr);
AggregateFunctionPtr aggfunc = datatype_aggfunc.getFunction();
if (aggfunc->getName() != AggregateFunctionGroupBitmapData<UInt8>::name())
throw Exception(
"Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name,
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
DataTypePtr nested_argument_type_ptr = aggfunc->getArgumentTypes()[0];
AggregateFunctionPtr res(createWithIntegerType<AggregateFunctionTemplate, AggregateFunctionGroupBitmapData>(

View File

@ -0,0 +1,2 @@
1
1

View File

@ -0,0 +1,6 @@
SELECT groupBitmapAnd(z) y FROM ( SELECT groupBitmapState(u) AS z FROM ( SELECT 123 AS u ) AS a1 );
SELECT groupBitmapAnd(y) FROM (SELECT groupBitmapAndState(z) y FROM ( SELECT groupBitmapState(u) AS z FROM ( SELECT 123 AS u ) AS a1 ) AS a2);
SELECT groupBitmapAnd(z) FROM ( SELECT minState(u) AS z FROM ( SELECT 123 AS u ) AS a1 ) AS a2; -- { serverError 43 }
SELECT groupBitmapOr(z) FROM ( SELECT maxState(u) AS z FROM ( SELECT '123' AS u ) AS a1 ) AS a2; -- { serverError 43 }
SELECT groupBitmapXor(z) FROM ( SELECT countState() AS z FROM ( SELECT '123' AS u ) AS a1 ) AS a2; -- { serverError 43 }