mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
Even more
This commit is contained in:
parent
772eccf03d
commit
c304032707
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <Interpreters/QueryParameterVisitor.h>
|
||||
#include <Parsers/IAST.h>
|
||||
#include <Parsers/ASTQueryParameter.h>
|
||||
#include <Parsers/ParserQuery.h>
|
||||
#include <Parsers/parseQuery.h>
|
||||
@ -9,26 +8,36 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
QueryParameterVisitor::QueryParameterVisitor(NameSet & parameters_name)
|
||||
: query_parameters(parameters_name)
|
||||
{
|
||||
}
|
||||
class ASTQueryParameter;
|
||||
|
||||
void QueryParameterVisitor::visit(const ASTPtr & ast)
|
||||
class QueryParameterVisitor
|
||||
{
|
||||
for (const auto & child : ast->children)
|
||||
public:
|
||||
QueryParameterVisitor(NameSet & parameters_name)
|
||||
: query_parameters(parameters_name)
|
||||
{
|
||||
if (const auto & query_parameter = child->as<ASTQueryParameter>())
|
||||
visitQueryParameter(*query_parameter);
|
||||
else
|
||||
visit(child);
|
||||
}
|
||||
}
|
||||
|
||||
void QueryParameterVisitor::visitQueryParameter(const ASTQueryParameter & query_parameter)
|
||||
{
|
||||
query_parameters.insert(query_parameter.name);
|
||||
}
|
||||
void visit(const ASTPtr & ast)
|
||||
{
|
||||
for (const auto & child : ast->children)
|
||||
{
|
||||
if (const auto & query_parameter = child->as<ASTQueryParameter>())
|
||||
visitQueryParameter(*query_parameter);
|
||||
else
|
||||
visit(child);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
NameSet & query_parameters;
|
||||
|
||||
void visitQueryParameter(const ASTQueryParameter & query_parameter)
|
||||
{
|
||||
query_parameters.insert(query_parameter.name);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
NameSet analyzeReceiveQueryParams(const std::string & query)
|
||||
{
|
||||
|
@ -1,26 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <Core/Names.h>
|
||||
#include <Parsers/IAST.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
class ASTQueryParameter;
|
||||
|
||||
class QueryParameterVisitor
|
||||
{
|
||||
public:
|
||||
QueryParameterVisitor(NameSet & parameters_name);
|
||||
|
||||
void visit(const ASTPtr & ast);
|
||||
|
||||
private:
|
||||
NameSet & query_parameters;
|
||||
|
||||
void visitQueryParameter(const ASTQueryParameter & query_parameter);
|
||||
};
|
||||
|
||||
/// Find parameters in a query and collect them into set.
|
||||
NameSet analyzeReceiveQueryParams(const std::string & query);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user