提交 02034c5d 编写于 作者: A Alexey Milovidov

Merging

上级 864dacd1
......@@ -431,6 +431,7 @@ namespace ErrorCodes
extern const int OPENSSL_ERROR = 454;
extern const int SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY = 455;
extern const int UNKNOWN_QUERY_PARAMETER = 456;
extern const int BAD_QUERY_PARAMETER = 457;
extern const int KEEPER_EXCEPTION = 999;
extern const int POCO_EXCEPTION = 1000;
......
......@@ -15,6 +15,13 @@
namespace DB
{
namespace ErrorCodes
{
extern const int UNKNOWN_QUERY_PARAMETER;
extern const int BAD_QUERY_PARAMETER;
}
void ReplaceQueryParameterVisitor::visit(ASTPtr & ast)
{
for (auto & child : ast->children)
......@@ -32,7 +39,7 @@ const String & ReplaceQueryParameterVisitor::getParamValue(const String & name)
if (search != query_parameters.end())
return search->second;
else
throw Exception("Substitution " + backQuote(name) + " is not set", ErrorCodes::BAD_ARGUMENTS);
throw Exception("Substitution " + backQuote(name) + " is not set", ErrorCodes::UNKNOWN_QUERY_PARAMETER);
}
void ReplaceQueryParameterVisitor::visitQueryParameter(ASTPtr & ast)
......@@ -49,7 +56,7 @@ void ReplaceQueryParameterVisitor::visitQueryParameter(ASTPtr & ast)
data_type->deserializeAsWholeText(temp_column, read_buffer, format_settings);
if (!read_buffer.eof())
throw Exception("Value " + value + " cannot be parsed as " + type_name + " for query parameter '" + ast_param.name + "'", ErrorCodes::BAD_ARGUMENTS);
throw Exception("Value " + value + " cannot be parsed as " + type_name + " for query parameter '" + ast_param.name + "'", ErrorCodes::BAD_QUERY_PARAMETER);
ast = addTypeConversionToAST(std::make_shared<ASTLiteral>(temp_column[0]), type_name);
}
......
......@@ -204,8 +204,11 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
try
{
/// Replace ASTQueryParameter with ASTLiteral for prepared statements.
ReplaceQueryParameterVisitor visitor(context.getQueryParameters());
visitor.visit(ast);
if (context.hasQueryParameters())
{
ReplaceQueryParameterVisitor visitor(context.getQueryParameters());
visitor.visit(ast);
}
/// Get new query after substitutions.
if (context.hasQueryParameters())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册