Fixed tests

This commit is contained in:
Alexey Milovidov 2019-06-15 21:22:48 +03:00
parent fad6013270
commit b079631f61
4 changed files with 15 additions and 12 deletions

View File

@ -807,13 +807,6 @@ private:
if (!parsed_query) if (!parsed_query)
return true; return true;
/// Replace ASTQueryParameter with ASTLiteral for prepared statements.
ReplaceQueryParameterVisitor visitor(query_parameters);
visitor.visit(parsed_query);
/// Get new query after substitutions.
query = serializeAST(*parsed_query);
processed_rows = 0; processed_rows = 0;
progress.reset(); progress.reset();
show_progress_bar = false; show_progress_bar = false;
@ -909,6 +902,13 @@ private:
/// Process the query that doesn't require transferring data blocks to the server. /// Process the query that doesn't require transferring data blocks to the server.
void processOrdinaryQuery() void processOrdinaryQuery()
{ {
/// Replace ASTQueryParameter with ASTLiteral for prepared statements.
ReplaceQueryParameterVisitor visitor(query_parameters);
visitor.visit(parsed_query);
/// Get new query after substitutions. Note that it cannot be done for INSERT query with embedded data.
query = serializeAST(*parsed_query);
connection->sendQuery(query, query_id, QueryProcessingStage::Complete, &context.getSettingsRef(), nullptr, true); connection->sendQuery(query, query_id, QueryProcessingStage::Complete, &context.getSettingsRef(), nullptr, true);
sendExternalTables(); sendExternalTables();
receiveResult(); receiveResult();

View File

@ -170,10 +170,6 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
/// TODO Parser should fail early when max_query_size limit is reached. /// TODO Parser should fail early when max_query_size limit is reached.
ast = parseQuery(parser, begin, end, "", max_query_size); ast = parseQuery(parser, begin, end, "", max_query_size);
/// Replace ASTQueryParameter with ASTLiteral for prepared statements.
ReplaceQueryParameterVisitor visitor(context.getQueryParameters());
visitor.visit(ast);
auto * insert_query = ast->as<ASTInsertQuery>(); auto * insert_query = ast->as<ASTInsertQuery>();
if (insert_query && insert_query->settings_ast) if (insert_query && insert_query->settings_ast)
@ -185,7 +181,9 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
insert_query->has_tail = has_query_tail; insert_query->has_tail = has_query_tail;
} }
else else
{
query_end = end; query_end = end;
}
} }
catch (...) catch (...)
{ {
@ -205,6 +203,10 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
try try
{ {
/// Replace ASTQueryParameter with ASTLiteral for prepared statements.
ReplaceQueryParameterVisitor visitor(context.getQueryParameters());
visitor.visit(ast);
/// Get new query after substitutions. /// Get new query after substitutions.
if (context.hasQueryParameters()) if (context.hasQueryParameters())
query = serializeAST(*ast); query = serializeAST(*ast);

View File

@ -2,3 +2,4 @@
1 Hello, world 2005-05-05 05:05:05 1 Hello, world 2005-05-05 05:05:05
2 test 2005-05-25 15:00:00 2 test 2005-05-25 15:00:00
2 test 2005-05-25 15:00:00 2 test 2005-05-25 15:00:00
Code: 36. DB::Exception: Substitution `s` is not set

View File

@ -3,7 +3,7 @@
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh . $CURDIR/../shell_config.sh
EXCEPTION_TEXT="Code: 36. DB::Exception: Expected correct value in parameter with name 'injection'" EXCEPTION_TEXT="Code: 36."
EXCEPTION_SUCCESS_TEXT="OK" EXCEPTION_SUCCESS_TEXT="OK"
EXCEPTION_FAIL_TEXT="FAIL" EXCEPTION_FAIL_TEXT="FAIL"