Skip to content

Commit

Permalink
Fixed an error when using update sentence. (vesoft-inc#1830)
Browse files Browse the repository at this point in the history
Fixed an error that the space could not be found when executing multiple statements (use space statements)
when executing update vertex/edge.

for example:

USE issue1827_update;UPDATE VERTEX 100 SET player.age = 31;
  • Loading branch information
monadbobo authored Mar 2, 2020
1 parent 3208cab commit 179272f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/graph/UpdateEdgeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ UpdateEdgeExecutor::UpdateEdgeExecutor(Sentence *sentence,
sentence_ = static_cast<UpdateEdgeSentence*>(sentence);
}


Status UpdateEdgeExecutor::prepare() {
return Status::OK();
}

Status UpdateEdgeExecutor::prepareData() {
DCHECK(sentence_ != nullptr);
Status status = Status::OK();

Expand Down Expand Up @@ -242,6 +245,11 @@ void UpdateEdgeExecutor::insertReverselyEdge(storage::cpp2::UpdateResponse &&rpc

void UpdateEdgeExecutor::execute() {
FLOG_INFO("Executing UpdateEdge: %s", sentence_->toString().c_str());
auto status = prepareData();
if (!status.ok()) {
doError(std::move(status));
return;
}
std::string filterStr = filter_ ? Expression::encode(filter_) : "";
auto returns = getReturnColumns();
auto future = ectx()->getStorageClient()->updateEdge(spaceId_,
Expand Down
1 change: 1 addition & 0 deletions src/graph/UpdateEdgeExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class UpdateEdgeExecutor final : public Executor {
void setupResponse(cpp2::ExecutionResponse &resp) override;

private:
Status prepareData();
// To do some preparing works on the clauses
Status prepareSet();

Expand Down
12 changes: 11 additions & 1 deletion src/graph/UpdateVertexExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ UpdateVertexExecutor::UpdateVertexExecutor(Sentence *sentence,
sentence_ = static_cast<UpdateVertexSentence*>(sentence);
}


Status UpdateVertexExecutor::prepare() {
return Status::OK();
}

Status UpdateVertexExecutor::prepareData() {
DCHECK(sentence_ != nullptr);

spaceId_ = ectx()->rctx()->session()->space();
Expand Down Expand Up @@ -185,6 +188,13 @@ void UpdateVertexExecutor::finishExecution(storage::cpp2::UpdateResponse &&rpcRe

void UpdateVertexExecutor::execute() {
FLOG_INFO("Executing UpdateVertex: %s", sentence_->toString().c_str());

auto status = prepareData();
if (!status.ok()) {
doError(std::move(status));
return;
}

std::string filterStr = filter_ ? Expression::encode(filter_) : "";
auto returns = getReturnColumns();
auto future = ectx()->getStorageClient()->updateVertex(spaceId_,
Expand Down
1 change: 1 addition & 0 deletions src/graph/UpdateVertexExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class UpdateVertexExecutor final : public Executor {
void setupResponse(cpp2::ExecutionResponse &resp) override;

private:
Status prepareData();
// To do some preparing works on the clauses
Status prepareSet();

Expand Down

0 comments on commit 179272f

Please sign in to comment.