Avoid crash with big int in prewhere

This commit is contained in:
Antonio Andelic 2022-10-24 08:37:52 +00:00
parent 729692f862
commit 5579d139eb
3 changed files with 17 additions and 2 deletions

View File

@ -628,12 +628,12 @@ Block MergeTreeBaseSelectProcessor::transformHeader(
else
{
WhichDataType which(removeNullable(recursiveRemoveLowCardinality(prewhere_column.type)));
if (which.isInt() || which.isUInt())
if (which.isNativeInt() || which.isNativeUInt())
prewhere_column.column = prewhere_column.type->createColumnConst(block.rows(), 1u)->convertToFullColumnIfConst();
else if (which.isFloat())
prewhere_column.column = prewhere_column.type->createColumnConst(block.rows(), 1.0f)->convertToFullColumnIfConst();
else
throw Exception("Illegal type " + prewhere_column.type->getName() + " of column for filter.",
throw Exception("Illegal type " + prewhere_column.type->getName() + " of column for filter",
ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER);
}
}

View File

@ -0,0 +1,15 @@
CREATE TABLE prewhere_int128 (a Int128) ENGINE=MergeTree ORDER BY a;
SELECT a FROM prewhere_int128 WHERE a; -- { serverError 59 }
DROP TABLE prewhere_int128;
CREATE TABLE prewhere_int256 (a Int256) ENGINE=MergeTree ORDER BY a;
SELECT a FROM prewhere_int256 WHERE a; -- { serverError 59 }
DROP TABLE prewhere_int256;
CREATE TABLE prewhere_uint128 (a UInt128) ENGINE=MergeTree ORDER BY a;
SELECT a FROM prewhere_uint128 WHERE a; -- { serverError 59 }
DROP TABLE prewhere_uint128;
CREATE TABLE prewhere_uint256 (a UInt256) ENGINE=MergeTree ORDER BY a;
SELECT a FROM prewhere_uint256 WHERE a; -- { serverError 59 }
DROP TABLE prewhere_uint256;