提交 005f6b96 编写于 作者: A Alexey Milovidov

Added function "sleepEachRow" for testing purposes #1713

上级 b96ae0aa
......@@ -40,6 +40,7 @@ namespace ErrorCodes
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
extern const int FUNCTION_IS_SPECIAL;
extern const int ARGUMENT_OUT_OF_BOUND;
extern const int TOO_SLOW;
}
/** Helper functions
......@@ -624,7 +625,15 @@ public:
/// We do not sleep if the block is empty.
if (size > 0)
usleep(static_cast<unsigned>(seconds * (variant == FunctionSleepVariant::PerBlock ? 1 : size) * 1e6));
{
unsigned useconds = seconds * (variant == FunctionSleepVariant::PerBlock ? 1 : size) * 1e6;
/// When sleeping, the query cannot be cancelled. For abitily to cancel query, we limit sleep time.
if (useconds > 3000000) /// The choice is arbitary
throw Exception("The maximum sleep time is 3000000 microseconds. Requested: " + toString(useconds), ErrorCodes::TOO_SLOW);
usleep(useconds);
}
/// convertToFullColumn needed, because otherwise (constant expression case) function will not get called on each block.
block.getByPosition(result).column = block.getByPosition(result).type->createColumnConst(size, UInt64(0))->convertToFullColumnIfConst();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册