Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 8040453

Browse files
committed
Consistency; remove superfluous headers, forward decls
Make param to ExecQueryExplain a reference.
1 parent 001ef6a commit 8040453

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/include/common/sql_node_visitor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class CreateFunctionStatement;
2121
class InsertStatement;
2222
class DeleteStatement;
2323
class DropStatement;
24+
class ExplainStatement;
2425
class PrepareStatement;
2526
class ExecuteStatement;
2627
class TransactionStatement;
@@ -80,6 +81,7 @@ class SqlNodeVisitor {
8081
virtual void Visit(parser::UpdateStatement *) {}
8182
virtual void Visit(parser::CopyStatement *) {}
8283
virtual void Visit(parser::AnalyzeStatement *){};
84+
virtual void Visit(parser::ExplainStatement *){};
8385

8486
virtual void Visit(expression::ComparisonExpression *expr);
8587
virtual void Visit(expression::AggregateExpression *expr);
@@ -93,8 +95,6 @@ class SqlNodeVisitor {
9395
virtual void Visit(expression::StarExpression *expr);
9496
virtual void Visit(expression::TupleValueExpression *expr);
9597
virtual void Visit(expression::SubqueryExpression *expr);
96-
97-
9898
};
9999

100100
} // namespace peloton

src/include/network/postgres_protocol_handler.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "common/portal.h"
2424
#include "common/statement.h"
2525
#include "common/statement_cache.h"
26-
#include "traffic_cop/traffic_cop.h"
2726
#include "protocol_handler.h"
2827
#include "traffic_cop/traffic_cop.h"
2928

@@ -34,7 +33,7 @@ namespace peloton {
3433

3534
namespace parser {
3635
class ExplainStatement;
37-
}
36+
} // namespace parser
3837

3938
namespace network {
4039

@@ -168,7 +167,7 @@ class PostgresProtocolHandler : public ProtocolHandler {
168167

169168
/* Execute a EXPLAIN query message */
170169
ResultType ExecQueryExplain(const std::string &query,
171-
parser::ExplainStatement *explain_stmt);
170+
parser::ExplainStatement &explain_stmt);
172171

173172
/* Process the PARSE message of the extended query protocol */
174173
void ExecParseMessage(InputPacket *pkt);

src/include/parser/explain_statement.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
namespace peloton {
1818

19-
class SqlNodeVisitor;
20-
2119
namespace parser {
2220

2321
/**
@@ -29,7 +27,7 @@ class ExplainStatement : public SQLStatement {
2927
ExplainStatement() : SQLStatement(StatementType::EXPLAIN) {}
3028
virtual ~ExplainStatement() {}
3129

32-
virtual void Accept(UNUSED_ATTRIBUTE SqlNodeVisitor *v) override {}
30+
void Accept(SqlNodeVisitor *v) override { v->Visit(this); }
3331

3432
std::unique_ptr<parser::SQLStatement> real_sql_stmt;
3533
};

src/network/postgres_protocol_handler.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "traffic_cop/traffic_cop.h"
3434
#include "type/value.h"
3535
#include "type/value_factory.h"
36-
#include "network/marshal.h"
3736
#include "util/string_util.h"
3837

3938
#define SSL_MESSAGE_VERNO 80877103
@@ -225,7 +224,7 @@ ProcessResult PostgresProtocolHandler::ExecQueryMessage(
225224
};
226225
case QueryType::QUERY_EXPLAIN: {
227226
auto status = ExecQueryExplain(
228-
query, static_cast<parser::ExplainStatement *>(sql_stmt.get()));
227+
query, static_cast<parser::ExplainStatement &>(*sql_stmt));
229228
ExecQueryMessageGetResult(status);
230229
return ProcessResult::COMPLETE;
231230
}
@@ -259,14 +258,11 @@ ProcessResult PostgresProtocolHandler::ExecQueryMessage(
259258
}
260259

261260
ResultType PostgresProtocolHandler::ExecQueryExplain(
262-
const std::string &query, parser::ExplainStatement *explain_stmt) {
263-
PL_ASSERT(explain_stmt != nullptr);
264-
261+
const std::string &query, parser::ExplainStatement &explain_stmt) {
265262
std::string error_message;
266263
std::unique_ptr<parser::SQLStatementList> unnamed_sql_stmt_list(
267264
new parser::SQLStatementList());
268-
unnamed_sql_stmt_list->PassInStatement(
269-
std::move(explain_stmt->real_sql_stmt));
265+
unnamed_sql_stmt_list->PassInStatement(std::move(explain_stmt.real_sql_stmt));
270266
auto stmt = traffic_cop_->PrepareStatement(
271267
"explain", query, std::move(unnamed_sql_stmt_list), error_message);
272268
ResultType status = ResultType::UNKNOWN;

0 commit comments

Comments
 (0)