mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Fix when we set a LIMIT to 0
This commit is contained in:
parent
c25ffb5930
commit
b0df037f25
@ -676,8 +676,12 @@ static std::pair<UInt64, UInt64> getLimitLengthAndOffset(const ASTSelectQuery &
|
|||||||
UInt64 offset = 0;
|
UInt64 offset = 0;
|
||||||
|
|
||||||
if (query.limitLength())
|
if (query.limitLength())
|
||||||
|
{
|
||||||
length = getLimitUIntValue(query.limitLength(), context, "LIMIT");
|
length = getLimitUIntValue(query.limitLength(), context, "LIMIT");
|
||||||
if (query.limitOffset())
|
if (query.limitOffset() && length)
|
||||||
|
offset = getLimitUIntValue(query.limitOffset(), context, "OFFSET");
|
||||||
|
}
|
||||||
|
else if (query.limitOffset())
|
||||||
offset = getLimitUIntValue(query.limitOffset(), context, "OFFSET");
|
offset = getLimitUIntValue(query.limitOffset(), context, "OFFSET");
|
||||||
return {length, offset};
|
return {length, offset};
|
||||||
}
|
}
|
||||||
@ -689,7 +693,7 @@ static UInt64 getLimitForSorting(const ASTSelectQuery & query, const Context & c
|
|||||||
if (!query.distinct && !query.limitBy() && !query.limit_with_ties && !query.arrayJoinExpressionList() && query.limitLength())
|
if (!query.distinct && !query.limitBy() && !query.limit_with_ties && !query.arrayJoinExpressionList() && query.limitLength())
|
||||||
{
|
{
|
||||||
auto [limit_length, limit_offset] = getLimitLengthAndOffset(query, context);
|
auto [limit_length, limit_offset] = getLimitLengthAndOffset(query, context);
|
||||||
return limit_length != 0 ? limit_length + limit_offset : 0;
|
return limit_length + limit_offset;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2314,9 +2318,6 @@ void InterpreterSelectQuery::executePreLimit(QueryPipeline & pipeline, bool do_n
|
|||||||
{
|
{
|
||||||
auto [limit_length, limit_offset] = getLimitLengthAndOffset(query, *context);
|
auto [limit_length, limit_offset] = getLimitLengthAndOffset(query, *context);
|
||||||
|
|
||||||
if (limit_length == 0)
|
|
||||||
limit_offset = 0;
|
|
||||||
|
|
||||||
if (do_not_skip_offset)
|
if (do_not_skip_offset)
|
||||||
{
|
{
|
||||||
limit_length += limit_offset;
|
limit_length += limit_offset;
|
||||||
@ -2430,9 +2431,6 @@ void InterpreterSelectQuery::executeLimit(Pipeline & pipeline)
|
|||||||
UInt64 limit_offset;
|
UInt64 limit_offset;
|
||||||
std::tie(limit_length, limit_offset) = getLimitLengthAndOffset(query, *context);
|
std::tie(limit_length, limit_offset) = getLimitLengthAndOffset(query, *context);
|
||||||
|
|
||||||
if (limit_length == 0)
|
|
||||||
limit_offset = 0;
|
|
||||||
|
|
||||||
pipeline.transform([&](auto & stream)
|
pipeline.transform([&](auto & stream)
|
||||||
{
|
{
|
||||||
stream = std::make_shared<LimitBlockInputStream>(stream, limit_length, limit_offset, always_read_till_end, false, query.limit_with_ties, order_descr);
|
stream = std::make_shared<LimitBlockInputStream>(stream, limit_length, limit_offset, always_read_till_end, false, query.limit_with_ties, order_descr);
|
||||||
@ -2516,9 +2514,6 @@ void InterpreterSelectQuery::executeLimit(QueryPipeline & pipeline)
|
|||||||
UInt64 limit_offset;
|
UInt64 limit_offset;
|
||||||
std::tie(limit_length, limit_offset) = getLimitLengthAndOffset(query, *context);
|
std::tie(limit_length, limit_offset) = getLimitLengthAndOffset(query, *context);
|
||||||
|
|
||||||
if (limit_length == 0)
|
|
||||||
limit_offset = 0;
|
|
||||||
|
|
||||||
SortDescription order_descr;
|
SortDescription order_descr;
|
||||||
if (query.limit_with_ties)
|
if (query.limit_with_ties)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user