Merge pull request #62413 from Avogar/fix-numbers-zero-step

Fix logical error 'numbers_storage.step != UInt64{0}'
This commit is contained in:
Kruglov Pavel 2024-04-09 10:54:36 +00:00 committed by GitHub
commit 6c952ce0f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 0 deletions

View File

@ -20,6 +20,7 @@ namespace ErrorCodes
{ {
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
extern const int ILLEGAL_TYPE_OF_ARGUMENT; extern const int ILLEGAL_TYPE_OF_ARGUMENT;
extern const int BAD_ARGUMENTS;
} }
namespace namespace
@ -78,6 +79,9 @@ StoragePtr TableFunctionNumbers<multithreaded>::executeImpl(
UInt64 length = arguments.size() >= 2 ? evaluateArgument(context, arguments[1]) : evaluateArgument(context, arguments[0]); UInt64 length = arguments.size() >= 2 ? evaluateArgument(context, arguments[1]) : evaluateArgument(context, arguments[0]);
UInt64 step = arguments.size() == 3 ? evaluateArgument(context, arguments[2]) : 1; UInt64 step = arguments.size() == 3 ? evaluateArgument(context, arguments[2]) : 1;
if (!step)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Table function {} requires step to be a positive number", getName());
auto res = std::make_shared<StorageSystemNumbers>( auto res = std::make_shared<StorageSystemNumbers>(
StorageID(getDatabaseName(), table_name), multithreaded, std::string{"number"}, length, offset, step); StorageID(getDatabaseName(), table_name), multithreaded, std::string{"number"}, length, offset, step);
res->startup(); res->startup();

View File

@ -0,0 +1,2 @@
select * from numbers(1, 10, 0); -- {serverError BAD_ARGUMENTS}