Fixed segfault in case of WHERE <non-UInt8 type expression>. [#CLICKHOUSE-3616]

Prohibited non-UInt8 constants in WHERE expressions.
Fixed KILL QUERY syntax highlighting.
This commit is contained in:
Vitaliy Lyudvichenko 2018-03-05 17:45:19 +03:00
parent 28b46655db
commit 1d247d0e31
2 changed files with 7 additions and 8 deletions

View File

@ -33,19 +33,18 @@ FilterBlockInputStream::FilterBlockInputStream(const BlockInputStreamPtr & input
expression->execute(header); expression->execute(header);
filter_column = header.getPositionByName(filter_column_name); filter_column = header.getPositionByName(filter_column_name);
auto & column_elem = header.safeGetByPosition(filter_column);
/// Isn't the filter already constant? /// Isn't the filter already constant?
ColumnPtr column = header.safeGetByPosition(filter_column).column; if (column_elem.column)
constant_filter_description = ConstantFilterDescription(*column_elem.column);
if (column)
constant_filter_description = ConstantFilterDescription(*column);
if (!constant_filter_description.always_false if (!constant_filter_description.always_false
&& !constant_filter_description.always_true) && !constant_filter_description.always_true)
{ {
/// Replace the filter column to a constant with value 1. /// Replace the filter column to a constant with value 1.
auto & header_filter_elem = header.getByPosition(filter_column); FilterDescription filter_description_check(*column_elem.column);
header_filter_elem.column = header_filter_elem.type->createColumnConst(header.rows(), UInt64(1)); column_elem.column = column_elem.type->createColumnConst(header.rows(), UInt64(1));
} }
} }

View File

@ -10,12 +10,12 @@ String ASTKillQueryQuery::getID() const
void ASTKillQueryQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const void ASTKillQueryQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{ {
settings.ostr << "KILL QUERY WHERE "; settings.ostr << (settings.hilite ? hilite_keyword : "") << "KILL QUERY WHERE " << (settings.hilite ? hilite_none : "");
if (where_expression) if (where_expression)
where_expression->formatImpl(settings, state, frame); where_expression->formatImpl(settings, state, frame);
settings.ostr << " " << (test ? "TEST" : (sync ? "SYNC" : "ASYNC")); settings.ostr << " " << (settings.hilite ? hilite_keyword : "") << (test ? "TEST" : (sync ? "SYNC" : "ASYNC")) << (settings.hilite ? hilite_none : "");
} }
} }