Skip to content

Commit

Permalink
Protocol Buffers set_allocated_xxx() methods are no longer used
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Jun 6, 2024
1 parent 2cdb106 commit b4ab13d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
10 changes: 2 additions & 8 deletions src/ogawayama/stub/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,12 @@ ErrorCode Transaction::Impl::execute_statement(PreparedStatementPtr& prepared, c
::jogasaki::proto::sql::common::PreparedStatement prepaed_statement{};
prepaed_statement.set_handle(ps_impl->get_id());
prepaed_statement.set_has_result_records(ps_impl->has_result_records());
request.set_allocated_prepared_statement_handle(&prepaed_statement);
*(request.mutable_prepared_statement_handle()) = prepaed_statement;

for (auto& e : parameters) {
*(request.add_parameters()) = std::visit(parameter(e.first), e.second);
}
auto response_opt = transport_.send(request);
request.clear_parameters();
request.release_prepared_statement_handle();
request.clear_transaction_handle();

if (!response_opt) {
return ErrorCode::SERVER_FAILURE;
Expand Down Expand Up @@ -274,16 +271,13 @@ ErrorCode Transaction::Impl::execute_query(PreparedStatementPtr& prepared, const
::jogasaki::proto::sql::common::PreparedStatement prepaed_statement{};
prepaed_statement.set_handle(ps_impl->get_id());
prepaed_statement.set_has_result_records(ps_impl->has_result_records());
request.set_allocated_prepared_statement_handle(&prepaed_statement);
*(request.mutable_prepared_statement_handle()) = prepaed_statement;
try {
for (auto& e : parameters) {
*(request.add_parameters()) = std::visit(parameter(e.first), e.second);
}
std::size_t query_index = get_query_index();
auto response_opt = transport_.send(request, query_index);
request.clear_parameters();
request.release_prepared_statement_handle();
request.clear_transaction_handle();
if (!response_opt) {
return ErrorCode::SERVER_FAILURE;
}
Expand Down
17 changes: 6 additions & 11 deletions src/ogawayama/transport/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,16 @@ class transport {
tateyama::proto::endpoint::request::WireInformation wire_information{};
tateyama::proto::endpoint::request::WireInformation::IpcInformation ipc_information{};
ipc_information.set_connection_information(std::to_string(getpid()));
wire_information.set_allocated_ipc_information(&ipc_information);
*(wire_information.mutable_ipc_information()) = ipc_information;

tateyama::proto::endpoint::request::Handshake handshake{};
handshake.set_allocated_client_information(&information);
handshake.set_allocated_wire_information(&wire_information);
tateyama::proto::endpoint::request::Request request{};
request.set_allocated_handshake(&handshake);
auto response = send<tateyama::proto::endpoint::response::Handshake>(request);
(void)request.release_handshake();
*(handshake.mutable_client_information()) = information;
*(handshake.mutable_wire_information()) = wire_information;

(void)wire_information.release_ipc_information();
(void)handshake.release_wire_information();
tateyama::proto::endpoint::request::Request request{};
*(request.mutable_handshake()) = handshake;

(void)handshake.release_client_information();
return response;
return send<tateyama::proto::endpoint::response::Handshake>(request);
}

std::optional<std::string> receive(tateyama::common::wire::message_header::index_type index) {
Expand Down

0 comments on commit b4ab13d

Please sign in to comment.