Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

chore!: rename ExecuteSqlParams -> SqlParams #986

Merged
merged 2 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/cloud/spanner/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ RowStream Client::ExecuteQuery(Transaction transaction,
}

RowStream Client::ExecuteQuery(QueryPartition const& partition) {
return conn_->ExecuteQuery(internal::MakeExecuteSqlParams(partition));
return conn_->ExecuteQuery(internal::MakeSqlParams(partition));
}

ProfileQueryResult Client::ProfileQuery(SqlStatement statement) {
Expand Down
18 changes: 9 additions & 9 deletions google/cloud/spanner/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ class Connection {

/// Wrap the arguments to `ExecuteQuery()`, `ExecuteDml()`, `ProfileQuery()`,
/// or `ProfileDml()`.
struct ExecuteSqlParams {
struct SqlParams {
Transaction transaction;
SqlStatement statement;
google::cloud::optional<std::string> partition_token;

ExecuteSqlParams(Transaction transaction, SqlStatement statement,
google::cloud::optional<std::string> partition_token = {})
SqlParams(Transaction transaction, SqlStatement statement,
google::cloud::optional<std::string> partition_token = {})
: transaction(std::move(transaction)),
statement(std::move(statement)),
partition_token(std::move(partition_token)) {}
Expand All @@ -111,7 +111,7 @@ class Connection {

/// Wrap the arguments to `PartitionQuery()`.
struct PartitionQueryParams {
ExecuteSqlParams sql_params;
SqlParams sql_params;
PartitionOptions partition_options;
};

Expand Down Expand Up @@ -141,19 +141,19 @@ class Connection {
PartitionReadParams) = 0;

/// Define the interface for a google.spanner.v1.Spanner.ExecuteSql RPC
virtual RowStream ExecuteQuery(ExecuteSqlParams) = 0;
virtual RowStream ExecuteQuery(SqlParams) = 0;

/// Define the interface for a google.spanner.v1.Spanner.ExecuteSql RPC
virtual StatusOr<DmlResult> ExecuteDml(ExecuteSqlParams) = 0;
virtual StatusOr<DmlResult> ExecuteDml(SqlParams) = 0;

/// Define the interface for a google.spanner.v1.Spanner.ExecuteSql RPC
virtual ProfileQueryResult ProfileQuery(ExecuteSqlParams) = 0;
virtual ProfileQueryResult ProfileQuery(SqlParams) = 0;

/// Define the interface for a google.spanner.v1.Spanner.ExecuteSql RPC
virtual StatusOr<ProfileDmlResult> ProfileDml(ExecuteSqlParams) = 0;
virtual StatusOr<ProfileDmlResult> ProfileDml(SqlParams) = 0;

/// Define the interface for a google.spanner.v1.Spanner.ExecuteSql RPC
virtual StatusOr<ExecutionPlan> AnalyzeSql(ExecuteSqlParams) = 0;
virtual StatusOr<ExecutionPlan> AnalyzeSql(SqlParams) = 0;

/// Define the interface for a google.spanner.v1.Spanner.ExecutePartitionedDml
/// RPC
Expand Down
28 changes: 14 additions & 14 deletions google/cloud/spanner/internal/connection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ StatusOr<std::vector<ReadPartition>> ConnectionImpl::PartitionRead(
});
}

RowStream ConnectionImpl::ExecuteQuery(ExecuteSqlParams params) {
RowStream ConnectionImpl::ExecuteQuery(SqlParams params) {
return internal::Visit(std::move(params.transaction),
[this, &params](SessionHolder& session,
spanner_proto::TransactionSelector& s,
Expand All @@ -143,7 +143,7 @@ RowStream ConnectionImpl::ExecuteQuery(ExecuteSqlParams params) {
});
}

StatusOr<DmlResult> ConnectionImpl::ExecuteDml(ExecuteSqlParams params) {
StatusOr<DmlResult> ConnectionImpl::ExecuteDml(SqlParams params) {
return internal::Visit(std::move(params.transaction),
[this, &params](SessionHolder& session,
spanner_proto::TransactionSelector& s,
Expand All @@ -153,7 +153,7 @@ StatusOr<DmlResult> ConnectionImpl::ExecuteDml(ExecuteSqlParams params) {
});
}

ProfileQueryResult ConnectionImpl::ProfileQuery(ExecuteSqlParams params) {
ProfileQueryResult ConnectionImpl::ProfileQuery(SqlParams params) {
return internal::Visit(std::move(params.transaction),
[this, &params](SessionHolder& session,
spanner_proto::TransactionSelector& s,
Expand All @@ -163,7 +163,7 @@ ProfileQueryResult ConnectionImpl::ProfileQuery(ExecuteSqlParams params) {
});
}

StatusOr<ProfileDmlResult> ConnectionImpl::ProfileDml(ExecuteSqlParams params) {
StatusOr<ProfileDmlResult> ConnectionImpl::ProfileDml(SqlParams params) {
return internal::Visit(std::move(params.transaction),
[this, &params](SessionHolder& session,
spanner_proto::TransactionSelector& s,
Expand All @@ -173,7 +173,7 @@ StatusOr<ProfileDmlResult> ConnectionImpl::ProfileDml(ExecuteSqlParams params) {
});
}

StatusOr<ExecutionPlan> ConnectionImpl::AnalyzeSql(ExecuteSqlParams params) {
StatusOr<ExecutionPlan> ConnectionImpl::AnalyzeSql(SqlParams params) {
return internal::Visit(std::move(params.transaction),
[this, &params](SessionHolder& session,
spanner_proto::TransactionSelector& s,
Expand Down Expand Up @@ -395,7 +395,7 @@ StatusOr<std::vector<ReadPartition>> ConnectionImpl::PartitionReadImpl(
template <typename ResultType>
StatusOr<ResultType> ConnectionImpl::ExecuteSqlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params,
std::int64_t seqno, SqlParams params,
google::spanner::v1::ExecuteSqlRequest::QueryMode query_mode,
std::function<StatusOr<std::unique_ptr<ResultSourceInterface>>(
google::spanner::v1 ::ExecuteSqlRequest& request)> const&
Expand Down Expand Up @@ -440,7 +440,7 @@ StatusOr<ResultType> ConnectionImpl::ExecuteSqlImpl(
template <typename ResultType>
ResultType ConnectionImpl::CommonQueryImpl(
SessionHolder& session, spanner_proto::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params,
std::int64_t seqno, SqlParams params,
google::spanner::v1::ExecuteSqlRequest::QueryMode query_mode) {
// Capture a copy of of these member variables to ensure the `shared_ptr<>`
// remains valid through the lifetime of the lambda. Note that the local
Expand Down Expand Up @@ -481,14 +481,14 @@ ResultType ConnectionImpl::CommonQueryImpl(

RowStream ConnectionImpl::ExecuteQueryImpl(
SessionHolder& session, spanner_proto::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params) {
std::int64_t seqno, SqlParams params) {
return CommonQueryImpl<RowStream>(session, s, seqno, std::move(params),
spanner_proto::ExecuteSqlRequest::NORMAL);
}

ProfileQueryResult ConnectionImpl::ProfileQueryImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params) {
std::int64_t seqno, SqlParams params) {
return CommonQueryImpl<ProfileQueryResult>(
session, s, seqno, std::move(params),
spanner_proto::ExecuteSqlRequest::PROFILE);
Expand All @@ -497,7 +497,7 @@ ProfileQueryResult ConnectionImpl::ProfileQueryImpl(
template <typename ResultType>
StatusOr<ResultType> ConnectionImpl::CommonDmlImpl(
SessionHolder& session, spanner_proto::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params,
std::int64_t seqno, SqlParams params,
google::spanner::v1::ExecuteSqlRequest::QueryMode query_mode) {
auto function_name = __func__;
// Capture a copy of of these member variables to ensure the `shared_ptr<>`
Expand Down Expand Up @@ -529,22 +529,22 @@ StatusOr<ResultType> ConnectionImpl::CommonDmlImpl(

StatusOr<DmlResult> ConnectionImpl::ExecuteDmlImpl(
SessionHolder& session, spanner_proto::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params) {
std::int64_t seqno, SqlParams params) {
return CommonDmlImpl<DmlResult>(session, s, seqno, std::move(params),
spanner_proto::ExecuteSqlRequest::NORMAL);
}

StatusOr<ProfileDmlResult> ConnectionImpl::ProfileDmlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params) {
std::int64_t seqno, SqlParams params) {
return CommonDmlImpl<ProfileDmlResult>(
session, s, seqno, std::move(params),
spanner_proto::ExecuteSqlRequest::PROFILE);
}

StatusOr<ExecutionPlan> ConnectionImpl::AnalyzeSqlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params) {
std::int64_t seqno, SqlParams params) {
auto result =
CommonDmlImpl<ProfileDmlResult>(session, s, seqno, std::move(params),
spanner_proto::ExecuteSqlRequest::PLAN);
Expand All @@ -556,7 +556,7 @@ StatusOr<ExecutionPlan> ConnectionImpl::AnalyzeSqlImpl(

StatusOr<std::vector<QueryPartition>> ConnectionImpl::PartitionQueryImpl(
SessionHolder& session, spanner_proto::TransactionSelector& s,
ExecuteSqlParams const& params, PartitionOptions partition_options) {
SqlParams const& params, PartitionOptions partition_options) {
if (!session) {
// Since the session may be sent to other machines, it should not be
// returned to the pool when the Transaction is destroyed.
Expand Down
28 changes: 14 additions & 14 deletions google/cloud/spanner/internal/connection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class ConnectionImpl : public Connection,
RowStream Read(ReadParams) override;
StatusOr<std::vector<ReadPartition>> PartitionRead(
PartitionReadParams) override;
RowStream ExecuteQuery(ExecuteSqlParams) override;
StatusOr<DmlResult> ExecuteDml(ExecuteSqlParams) override;
ProfileQueryResult ProfileQuery(ExecuteSqlParams) override;
StatusOr<ProfileDmlResult> ProfileDml(ExecuteSqlParams) override;
StatusOr<ExecutionPlan> AnalyzeSql(ExecuteSqlParams) override;
RowStream ExecuteQuery(SqlParams) override;
StatusOr<DmlResult> ExecuteDml(SqlParams) override;
ProfileQueryResult ProfileQuery(SqlParams) override;
StatusOr<ProfileDmlResult> ProfileDml(SqlParams) override;
StatusOr<ExecutionPlan> AnalyzeSql(SqlParams) override;
StatusOr<PartitionedDmlResult> ExecutePartitionedDml(
ExecutePartitionedDmlParams) override;
StatusOr<std::vector<QueryPartition>> PartitionQuery(
Expand Down Expand Up @@ -102,31 +102,31 @@ class ConnectionImpl : public Connection,

RowStream ExecuteQueryImpl(SessionHolder& session,
google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params);
std::int64_t seqno, SqlParams params);

StatusOr<DmlResult> ExecuteDmlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params);
std::int64_t seqno, SqlParams params);

ProfileQueryResult ProfileQueryImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params);
std::int64_t seqno, SqlParams params);

StatusOr<ProfileDmlResult> ProfileDmlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params);
std::int64_t seqno, SqlParams params);

StatusOr<ExecutionPlan> AnalyzeSqlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params);
std::int64_t seqno, SqlParams params);

StatusOr<PartitionedDmlResult> ExecutePartitionedDmlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecutePartitionedDmlParams params);

StatusOr<std::vector<QueryPartition>> PartitionQueryImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
ExecuteSqlParams const& params, PartitionOptions partition_options);
SqlParams const& params, PartitionOptions partition_options);

StatusOr<BatchDmlResult> ExecuteBatchDmlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
Expand Down Expand Up @@ -165,7 +165,7 @@ class ConnectionImpl : public Connection,
template <typename ResultType>
StatusOr<ResultType> ExecuteSqlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params,
std::int64_t seqno, SqlParams params,
google::spanner::v1::ExecuteSqlRequest::QueryMode query_mode,
std::function<StatusOr<std::unique_ptr<ResultSourceInterface>>(
google::spanner::v1 ::ExecuteSqlRequest& request)> const&
Expand All @@ -174,13 +174,13 @@ class ConnectionImpl : public Connection,
template <typename ResultType>
ResultType CommonQueryImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params,
std::int64_t seqno, SqlParams params,
google::spanner::v1::ExecuteSqlRequest::QueryMode query_mode);

template <typename ResultType>
StatusOr<ResultType> CommonDmlImpl(
SessionHolder& session, google::spanner::v1::TransactionSelector& s,
std::int64_t seqno, ExecuteSqlParams params,
std::int64_t seqno, SqlParams params,
google::spanner::v1::ExecuteSqlRequest::QueryMode query_mode);

Database db_;
Expand Down
11 changes: 5 additions & 6 deletions google/cloud/spanner/mocks/mock_spanner_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ class MockConnection : public spanner::Connection {
MOCK_METHOD1(Read, spanner::RowStream(ReadParams));
MOCK_METHOD1(PartitionRead, StatusOr<std::vector<spanner::ReadPartition>>(
PartitionReadParams));
MOCK_METHOD1(ExecuteQuery, spanner::RowStream(ExecuteSqlParams));
MOCK_METHOD1(ExecuteDml, StatusOr<spanner::DmlResult>(ExecuteSqlParams));
MOCK_METHOD1(ProfileQuery, spanner::ProfileQueryResult(ExecuteSqlParams));
MOCK_METHOD1(ProfileDml,
StatusOr<spanner::ProfileDmlResult>(ExecuteSqlParams));
MOCK_METHOD1(AnalyzeSql, StatusOr<spanner::ExecutionPlan>(ExecuteSqlParams));
MOCK_METHOD1(ExecuteQuery, spanner::RowStream(SqlParams));
MOCK_METHOD1(ExecuteDml, StatusOr<spanner::DmlResult>(SqlParams));
MOCK_METHOD1(ProfileQuery, spanner::ProfileQueryResult(SqlParams));
MOCK_METHOD1(ProfileDml, StatusOr<spanner::ProfileDmlResult>(SqlParams));
MOCK_METHOD1(AnalyzeSql, StatusOr<spanner::ExecutionPlan>(SqlParams));
MOCK_METHOD1(ExecutePartitionedDml, StatusOr<spanner::PartitionedDmlResult>(
ExecutePartitionedDmlParams));
MOCK_METHOD1(PartitionQuery, StatusOr<std::vector<spanner::QueryPartition>>(
Expand Down
3 changes: 1 addition & 2 deletions google/cloud/spanner/query_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ QueryPartition MakeQueryPartition(std::string const& transaction_id,
sql_statement);
}

Connection::ExecuteSqlParams MakeExecuteSqlParams(
QueryPartition const& query_partition) {
Connection::SqlParams MakeSqlParams(QueryPartition const& query_partition) {
return {internal::MakeTransactionFromIds(query_partition.session_id(),
query_partition.transaction_id()),
query_partition.sql_statement(), query_partition.partition_token()};
Expand Down
5 changes: 2 additions & 3 deletions google/cloud/spanner/query_partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ QueryPartition MakeQueryPartition(std::string const& transaction_id,
std::string const& session_id,
std::string const& partition_token,
SqlStatement const& sql_statement);
Connection::ExecuteSqlParams MakeExecuteSqlParams(
QueryPartition const& query_partition);
Connection::SqlParams MakeSqlParams(QueryPartition const& query_partition);
} // namespace internal

/**
Expand Down Expand Up @@ -106,7 +105,7 @@ class QueryPartition {
friend QueryPartition internal::MakeQueryPartition(
std::string const& transaction_id, std::string const& session_id,
std::string const& partition_token, SqlStatement const& sql_statement);
friend Connection::ExecuteSqlParams internal::MakeExecuteSqlParams(
friend Connection::SqlParams internal::MakeSqlParams(
QueryPartition const& query_partition);
friend StatusOr<std::string> SerializeQueryPartition(
QueryPartition const& query_partition);
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/spanner/query_partition_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ TEST(QueryPartitionTest, FailedDeserialize) {
EXPECT_FALSE(partition.ok());
}

TEST(QueryPartitionTest, MakeExecuteSqlParams) {
TEST(QueryPartitionTest, MakeSqlParams) {
QueryPartitionTester expected_partition(internal::MakeQueryPartition(
"foo", "session", "token",
SqlStatement("select * from foo where name = @name",
{{"name", Value("Bob")}})));

Connection::ExecuteSqlParams params =
internal::MakeExecuteSqlParams(expected_partition.Partition());
Connection::SqlParams params =
internal::MakeSqlParams(expected_partition.Partition());

EXPECT_EQ(params.statement,
SqlStatement("select * from foo where name = @name",
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/spanner/samples/mock_execute_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ TEST(MockSpannerClient, SuccessfulExecuteQuery) {
// Setup the connection mock to return the results previously setup:
//! [mock-execute-query]
EXPECT_CALL(*conn, ExecuteQuery(_))
.WillOnce([&source](spanner::Connection::ExecuteSqlParams const&)
.WillOnce([&source](spanner::Connection::SqlParams const&)
-> spanner::RowStream {
return spanner::RowStream(std::move(source));
});
Expand Down