mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merging
This commit is contained in:
parent
864dacd112
commit
02034c5d91
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user