-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1559 from kuzudb/statement-ready-only
Check statement read only through visitor pattern
- Loading branch information
Showing
8 changed files
with
46 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "binder/visitor/statement_read_write_analyzer.h" | ||
|
||
namespace kuzu { | ||
namespace binder { | ||
|
||
bool StatementReadWriteAnalyzer::isReadOnly(const kuzu::binder::BoundStatement& statement) { | ||
visit(statement); | ||
return readOnly; | ||
} | ||
|
||
void StatementReadWriteAnalyzer::visitQueryPart(const NormalizedQueryPart& queryPart) { | ||
readOnly = !queryPart.hasUpdatingClause(); | ||
} | ||
|
||
} // namespace binder | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/include/binder/visitor/statement_read_write_analyzer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "binder/bound_statement_visitor.h" | ||
|
||
namespace kuzu { | ||
namespace binder { | ||
|
||
class StatementReadWriteAnalyzer : public BoundStatementVisitor { | ||
public: | ||
StatementReadWriteAnalyzer() : BoundStatementVisitor(), readOnly{false} {} | ||
|
||
bool isReadOnly(const BoundStatement& statement); | ||
|
||
private: | ||
void visitQueryPart(const NormalizedQueryPart& queryPart) final; | ||
|
||
private: | ||
bool readOnly; | ||
}; | ||
|
||
} // namespace binder | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters