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

Commit 1066624

Browse files
authored
Merge branch 'master' into scripts
2 parents fdc076c + bd58ed6 commit 1066624

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/executor/plan_executor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void CompileAndExecutePlan(
6464
}
6565

6666
auto on_query_result =
67-
[&on_complete, &consumer](executor::ExecutionResult result) {
67+
[&on_complete, &consumer, plan](executor::ExecutionResult result) {
6868
std::vector<ResultValue> values;
6969
for (const auto &tuple : consumer.GetOutputTuples()) {
7070
for (uint32_t i = 0; i < tuple.tuple_.size(); i++) {
@@ -74,6 +74,7 @@ static void CompileAndExecutePlan(
7474
values.push_back(std::move(str));
7575
}
7676
}
77+
plan->ClearParameterValues();
7778
on_complete(result, std::move(values));
7879
};
7980

@@ -102,6 +103,7 @@ static void InterpretPlan(
102103
result.m_result = ResultType::FAILURE;
103104
result.m_error_message = "Failed initialization of query execution tree";
104105
CleanExecutorTree(executor_tree.get());
106+
plan->ClearParameterValues();
105107
on_complete(result, std::move(values));
106108
return;
107109
}
@@ -131,6 +133,7 @@ static void InterpretPlan(
131133
result.m_processed = executor_context->num_processed;
132134
result.m_result = ResultType::SUCCESS;
133135
CleanExecutorTree(executor_tree.get());
136+
plan->ClearParameterValues();
134137
on_complete(result, std::move(values));
135138
}
136139

@@ -174,7 +177,7 @@ void PlanExecutor::ExecutePlan(
174177
* @return number of executed tuples and logical_tile_list
175178
*/
176179
int PlanExecutor::ExecutePlan(
177-
const planner::AbstractPlan *plan, const std::vector<type::Value> &params,
180+
planner::AbstractPlan *plan, const std::vector<type::Value> &params,
178181
std::vector<std::unique_ptr<executor::LogicalTile>> &logical_tile_list) {
179182
PL_ASSERT(plan != nullptr);
180183
LOG_TRACE("PlanExecutor Start with transaction");

src/include/executor/plan_executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PlanExecutor {
7070
*/
7171
// FIXME This should be removed when PelotonService is removed/rewritten
7272
static int ExecutePlan(
73-
const planner::AbstractPlan *plan, const std::vector<type::Value> &params,
73+
planner::AbstractPlan *plan, const std::vector<type::Value> &params,
7474
std::vector<std::unique_ptr<executor::LogicalTile>> &logical_tile_list);
7575
};
7676

src/include/planner/abstract_plan.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ class AbstractPlan : public Printable {
7878

7979
// Setting values of the parameters in the prepare statement
8080
virtual void SetParameterValues(std::vector<type::Value> *values);
81+
82+
// FIXME. Clear the value_ vector.
83+
virtual void ClearParameterValues() {};
8184

8285
// Get the estimated cardinality of this plan
8386
int GetCardinality() const { return estimated_cardinality_; }

src/include/planner/insert_plan.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ class InsertPlan : public AbstractPlan {
6969

7070
void SetParameterValues(std::vector<type::Value> *values) override;
7171

72+
/*
73+
* Clear the parameter values of the current insert. The plan may be
74+
* cached in the statement / plan cache and may be reused.
75+
*/
76+
void ClearParameterValues() override { values_.clear(); }
77+
7278
storage::DataTable *GetTable() const { return target_table_; }
7379

7480
const planner::ProjectInfo *GetProjectInfo() const {

0 commit comments

Comments
 (0)