Represents the result and profile stats of a data modifying operation using spanner::Client::ProfileDml()
.
More...
#include <google/cloud/spanner/results.h>
Represents the result and profile stats of a data modifying operation using spanner::Client::ProfileDml()
.
This class encapsulates the result of a Cloud Spanner DML operation, i.e., INSERT
, UPDATE
, or DELETE
.
- Note
ProfileDmlResult
returns the number of rows modified, execution statistics, and query plan.
- Example:
auto commit_result = client.Commit(
[&client,
auto update = client.ProfileDml(
std::move(txn),
"UPDATE Albums SET MarketingBudget = MarketingBudget * 2"
" WHERE SingerId = 1 AND AlbumId = 1"));
if (!update) return update.status();
dml_result = *std::move(update);
});
if (!commit_result) {
throw std::runtime_error(commit_result.status().message());
}
std::cout <<
"Rows modified: " << dml_result.
RowsModified();
if (execution_stats) {
for (auto const& stat : *execution_stats) {
std::cout << stat.first << ":\t" << stat.second << "\n";
}
}
Represents the result and profile stats of a data modifying operation using spanner::Client::ProfileD...
std::int64_t RowsModified() const
Returns the number of rows modified by the DML statement.
absl::optional< std::unordered_map< std::string, std::string > > ExecutionStats() const
Returns a collection of key value pair statistics for the SQL statement execution.
Represents a potentially parameterized SQL statement.
The representation of a Cloud Spanner transaction.
std::vector< Mutation > Mutations
An ordered sequence of mutations to pass to Client::Commit() or return from the Client::Commit() muta...
Definition at line 216 of file results.h.
◆ ProfileDmlResult() [1/3]
google::cloud::spanner::v1::ProfileDmlResult::ProfileDmlResult |
( |
| ) |
|
|
default |
◆ ProfileDmlResult() [2/3]
google::cloud::spanner::v1::ProfileDmlResult::ProfileDmlResult |
( |
std::unique_ptr< spanner_internal::ResultSourceInterface > |
source | ) |
|
|
inlineexplicit |
◆ ProfileDmlResult() [3/3]
google::cloud::spanner::v1::ProfileDmlResult::ProfileDmlResult |
( |
ProfileDmlResult && |
| ) |
|
|
default |
◆ ExecutionPlan()
Returns the plan of execution for the SQL statement.
Definition at line 100 of file results.cc.
◆ ExecutionStats()
absl::optional< std::unordered_map< std::string, std::string > > google::cloud::spanner::v1::ProfileDmlResult::ExecutionStats |
( |
| ) |
const |
Returns a collection of key value pair statistics for the SQL statement execution.
- Note
- Only available when the SQL statement is executed.
Definition at line 96 of file results.cc.
◆ operator=()
◆ RowsModified()
std::int64_t google::cloud::spanner::v1::ProfileDmlResult::RowsModified |
( |
| ) |
const |
Returns the number of rows modified by the DML statement.
- Note
- Partitioned DML only provides a lower bound of the rows modified, all other DML statements provide an exact count.
Definition at line 81 of file results.cc.