Implement hierarchical Accept
for AuthQuery
and StreamQuery
Reviewers: teon.banek, mtomic Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1708
This commit is contained in:
parent
06ae2ffecc
commit
d9db38dca6
@ -2267,7 +2267,12 @@ cpp<#
|
||||
AuthQuery() = default;
|
||||
|
||||
DEFVISITABLE(TreeVisitor<TypedValue>);
|
||||
DEFVISITABLE(HierarchicalTreeVisitor);
|
||||
bool Accept(HierarchicalTreeVisitor &visitor) override {
|
||||
if (visitor.PreVisit(*this)) {
|
||||
if (password_) password_->Accept(visitor);
|
||||
}
|
||||
return visitor.PostVisit(*this);
|
||||
}
|
||||
|
||||
AuthQuery *Clone(AstStorage &storage) const override {
|
||||
return storage.Create<AuthQuery>(
|
||||
@ -2342,7 +2347,24 @@ cpp<#
|
||||
StreamQuery() = default;
|
||||
|
||||
DEFVISITABLE(TreeVisitor<TypedValue>);
|
||||
DEFVISITABLE(HierarchicalTreeVisitor);
|
||||
bool Accept(HierarchicalTreeVisitor &visitor) override {
|
||||
if (visitor.PreVisit(*this)) {
|
||||
bool cont = true;
|
||||
if (cont && stream_uri_)
|
||||
cont = stream_uri_->Accept(visitor);
|
||||
if (cont && stream_topic_)
|
||||
cont = stream_topic_->Accept(visitor);
|
||||
if (cont && transform_uri_)
|
||||
cont = transform_uri_->Accept(visitor);
|
||||
if (cont && batch_interval_in_ms_)
|
||||
cont = batch_interval_in_ms_->Accept(visitor);
|
||||
if (cont && batch_size_)
|
||||
cont = batch_size_->Accept(visitor);
|
||||
if (cont && limit_batches_)
|
||||
cont = limit_batches_->Accept(visitor);
|
||||
}
|
||||
return visitor.PostVisit(*this);
|
||||
}
|
||||
|
||||
StreamQuery *Clone(AstStorage &storage) const override {
|
||||
auto *stream_uri = stream_uri_ ? stream_uri_->Clone(storage) : nullptr;
|
||||
|
@ -77,11 +77,11 @@ using TreeCompositeVisitor = ::utils::CompositeVisitor<
|
||||
Aggregation, Function, Reduce, Coalesce, Extract, All, Single, Create,
|
||||
Match, Return, With, Pattern, NodeAtom, EdgeAtom, Delete, Where,
|
||||
SetProperty, SetProperties, SetLabels, RemoveProperty, RemoveLabels, Merge,
|
||||
Unwind>;
|
||||
Unwind, AuthQuery, StreamQuery>;
|
||||
|
||||
using TreeLeafVisitor =
|
||||
::utils::LeafVisitor<Identifier, PrimitiveLiteral, ParameterLookup,
|
||||
IndexQuery, AuthQuery, StreamQuery>;
|
||||
IndexQuery>;
|
||||
|
||||
class HierarchicalTreeVisitor : public TreeCompositeVisitor,
|
||||
public TreeLeafVisitor {
|
||||
|
@ -46,6 +46,7 @@ class PrivilegeExtractor : public HierarchicalTreeVisitor {
|
||||
AddPrivilege(AuthQuery::Privilege::REMOVE);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Visit(Identifier &) override { return true; }
|
||||
bool Visit(PrimitiveLiteral &) override { return true; }
|
||||
bool Visit(ParameterLookup &) override { return true; }
|
||||
@ -55,13 +56,14 @@ class PrivilegeExtractor : public HierarchicalTreeVisitor {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Visit(AuthQuery &) override {
|
||||
bool PreVisit(AuthQuery &) override {
|
||||
AddPrivilege(AuthQuery::Privilege::AUTH);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool Visit(StreamQuery &) override {
|
||||
|
||||
bool PreVisit(StreamQuery &) override {
|
||||
AddPrivilege(AuthQuery::Privilege::STREAM);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -220,9 +220,9 @@ bool SymbolGenerator::PostVisit(Match &) {
|
||||
|
||||
bool SymbolGenerator::Visit(IndexQuery &) { return true; }
|
||||
|
||||
bool SymbolGenerator::Visit(AuthQuery &) { return true; }
|
||||
bool SymbolGenerator::PreVisit(AuthQuery &) { return false; }
|
||||
|
||||
bool SymbolGenerator::Visit(StreamQuery &) { return true; }
|
||||
bool SymbolGenerator::PreVisit(StreamQuery &) { return false; }
|
||||
|
||||
// Expressions
|
||||
|
||||
|
@ -47,8 +47,8 @@ class SymbolGenerator : public HierarchicalTreeVisitor {
|
||||
bool PreVisit(Match &) override;
|
||||
bool PostVisit(Match &) override;
|
||||
bool Visit(IndexQuery &) override;
|
||||
bool Visit(AuthQuery &) override;
|
||||
bool Visit(StreamQuery &) override;
|
||||
bool PreVisit(AuthQuery &) override;
|
||||
bool PreVisit(StreamQuery &) override;
|
||||
|
||||
// Expressions
|
||||
ReturnType Visit(Identifier &) override;
|
||||
|
@ -53,8 +53,8 @@ class UsedSymbolsCollector : public HierarchicalTreeVisitor {
|
||||
bool Visit(PrimitiveLiteral &) override { return true; }
|
||||
bool Visit(ParameterLookup &) override { return true; }
|
||||
bool Visit(query::IndexQuery &) override { return true; }
|
||||
bool Visit(query::AuthQuery &) override { return true; }
|
||||
bool Visit(query::StreamQuery &) override { return true; }
|
||||
bool PreVisit(query::AuthQuery &) override { return false; }
|
||||
bool PreVisit(query::StreamQuery &) override { return false; }
|
||||
|
||||
std::unordered_set<Symbol> symbols_;
|
||||
const SymbolTable &symbol_table_;
|
||||
|
@ -415,14 +415,14 @@ class ReturnBodyContext : public HierarchicalTreeVisitor {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Visit(query::AuthQuery &) override {
|
||||
bool PreVisit(query::AuthQuery &) override {
|
||||
has_aggregation_.emplace_back(false);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Visit(query::StreamQuery &) override {
|
||||
bool PreVisit(query::StreamQuery &) override {
|
||||
has_aggregation_.emplace_back(false);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Creates NamedExpression with an Identifier for each user declared symbol.
|
||||
|
Loading…
Reference in New Issue
Block a user