Google Cloud Spanner C++ Client 2.13.0
A C++ Client Library for Google Cloud Spanner
|
Performs database client operations on Spanner. More...
#include <google/cloud/spanner/client.h>
Public Member Functions | |
Client (std::shared_ptr< Connection > conn, Options opts={}) | |
Constructs a Client object using the specified conn and opts . More... | |
Client ()=delete | |
No default construction. More... | |
RowStream | Read (std::string table, KeySet keys, std::vector< std::string > columns, Options opts={}) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
RowStream | Read (Transaction::SingleUseOptions transaction_options, std::string table, KeySet keys, std::vector< std::string > columns, Options opts={}) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
RowStream | Read (Transaction transaction, std::string table, KeySet keys, std::vector< std::string > columns, Options opts={}) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
RowStream | Read (ReadPartition const &partition, Options opts={}) |
Reads rows from a subset of rows in a database. More... | |
StatusOr< std::vector< ReadPartition > > | PartitionRead (Transaction transaction, std::string table, KeySet keys, std::vector< std::string > columns, Options opts={}) |
Creates a set of partitions that can be used to execute a read operation in parallel. More... | |
RowStream | ExecuteQuery (SqlStatement statement, Options opts={}) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (Transaction::SingleUseOptions transaction_options, SqlStatement statement, Options opts={}) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (Transaction transaction, SqlStatement statement, Options opts={}) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (QueryPartition const &partition, Options opts={}) |
Executes a SQL query on a subset of rows in a database. More... | |
ProfileQueryResult | ProfileQuery (SqlStatement statement, Options opts={}) |
Profiles a SQL query. More... | |
ProfileQueryResult | ProfileQuery (Transaction::SingleUseOptions transaction_options, SqlStatement statement, Options opts={}) |
Profiles a SQL query. More... | |
ProfileQueryResult | ProfileQuery (Transaction transaction, SqlStatement statement, Options opts={}) |
Profiles a SQL query. More... | |
StatusOr< std::vector< QueryPartition > > | PartitionQuery (Transaction transaction, SqlStatement statement, Options opts=Options{}) |
Creates a set of partitions that can be used to execute a query operation in parallel. More... | |
StatusOr< DmlResult > | ExecuteDml (Transaction transaction, SqlStatement statement, Options opts={}) |
Executes a SQL DML statement. More... | |
StatusOr< ProfileDmlResult > | ProfileDml (Transaction transaction, SqlStatement statement, Options opts={}) |
Profiles a SQL DML statement. More... | |
StatusOr< ExecutionPlan > | AnalyzeSql (Transaction transaction, SqlStatement statement, Options opts={}) |
Analyzes the execution plan of a SQL statement. More... | |
StatusOr< BatchDmlResult > | ExecuteBatchDml (Transaction transaction, std::vector< SqlStatement > statements, Options opts={}) |
Executes a batch of SQL DML statements. More... | |
StatusOr< CommitResult > | Commit (std::function< StatusOr< Mutations >(Transaction)> const &mutator, std::unique_ptr< TransactionRerunPolicy > rerun_policy, std::unique_ptr< BackoffPolicy > backoff_policy, Options opts={}) |
Commits a read-write transaction. More... | |
StatusOr< CommitResult > | Commit (std::function< StatusOr< Mutations >(Transaction)> const &mutator, Options opts={}) |
Commits a read-write transaction. More... | |
StatusOr< CommitResult > | Commit (Mutations mutations, Options opts={}) |
Commits the mutations , using the options , atomically in order. More... | |
StatusOr< CommitResult > | Commit (Transaction transaction, Mutations mutations, Options opts={}) |
Commits a read-write transaction. More... | |
StatusOr< CommitResult > | CommitAtLeastOnce (Transaction::ReadWriteOptions transaction_options, Mutations mutations, Options opts={}) |
Commits a write transaction with at-least-once semantics. More... | |
Status | Rollback (Transaction transaction, Options opts={}) |
Rolls back a read-write transaction, releasing any locks it holds. More... | |
StatusOr< PartitionedDmlResult > | ExecutePartitionedDml (SqlStatement statement, Options opts={}) |
Executes a Partitioned DML SQL query. More... | |
Copy and move support | |
Client (Client const &)=default | |
Client & | operator= (Client const &)=default |
Client (Client &&)=default | |
Client & | operator= (Client &&)=default |
Backwards compatibility for ClientOptions. | |
Client (std::shared_ptr< Connection > conn, ClientOptions const &opts) | |
Client (std::shared_ptr< Connection > conn, std::initializer_list< internal::NonConstructible >) | |
Backwards compatibility for ReadOptions. | |
RowStream | Read (std::string table, KeySet keys, std::vector< std::string > columns, ReadOptions const &read_options) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
RowStream | Read (std::string table, KeySet keys, std::vector< std::string > columns, std::initializer_list< internal::NonConstructible >) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
RowStream | Read (Transaction::SingleUseOptions transaction_options, std::string table, KeySet keys, std::vector< std::string > columns, ReadOptions const &read_options) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
RowStream | Read (Transaction::SingleUseOptions transaction_options, std::string table, KeySet keys, std::vector< std::string > columns, std::initializer_list< internal::NonConstructible >) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
RowStream | Read (Transaction transaction, std::string table, KeySet keys, std::vector< std::string > columns, ReadOptions const &read_options) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
RowStream | Read (Transaction transaction, std::string table, KeySet keys, std::vector< std::string > columns, std::initializer_list< internal::NonConstructible >) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery() . More... | |
Backwards compatibility for ReadOptions and PartitionOptions. | |
StatusOr< std::vector< ReadPartition > > | PartitionRead (Transaction transaction, std::string table, KeySet keys, std::vector< std::string > columns, ReadOptions const &read_options, PartitionOptions const &partition_options) |
Creates a set of partitions that can be used to execute a read operation in parallel. More... | |
StatusOr< std::vector< ReadPartition > > | PartitionRead (Transaction transaction, std::string table, KeySet keys, std::vector< std::string > columns, std::initializer_list< internal::NonConstructible >) |
Creates a set of partitions that can be used to execute a read operation in parallel. More... | |
Backwards compatibility for QueryOptions. | |
RowStream | ExecuteQuery (SqlStatement statement, QueryOptions const &opts) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (Transaction::SingleUseOptions transaction_options, SqlStatement statement, QueryOptions const &opts) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (Transaction::SingleUseOptions transaction_options, SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (Transaction transaction, SqlStatement statement, QueryOptions const &opts) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (Transaction transaction, SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Executes a SQL query. More... | |
RowStream | ExecuteQuery (QueryPartition const &partition, QueryOptions const &opts) |
Executes a SQL query on a subset of rows in a database. More... | |
RowStream | ExecuteQuery (QueryPartition const &partition, std::initializer_list< internal::NonConstructible >) |
Executes a SQL query on a subset of rows in a database. More... | |
ProfileQueryResult | ProfileQuery (SqlStatement statement, QueryOptions const &opts) |
Profiles a SQL query. More... | |
ProfileQueryResult | ProfileQuery (SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Profiles a SQL query. More... | |
ProfileQueryResult | ProfileQuery (Transaction::SingleUseOptions transaction_options, SqlStatement statement, QueryOptions const &opts) |
Profiles a SQL query. More... | |
ProfileQueryResult | ProfileQuery (Transaction::SingleUseOptions transaction_options, SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Profiles a SQL query. More... | |
ProfileQueryResult | ProfileQuery (Transaction transaction, SqlStatement statement, QueryOptions const &opts) |
Profiles a SQL query. More... | |
ProfileQueryResult | ProfileQuery (Transaction transaction, SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Profiles a SQL query. More... | |
StatusOr< DmlResult > | ExecuteDml (Transaction transaction, SqlStatement statement, QueryOptions const &opts) |
Executes a SQL DML statement. More... | |
StatusOr< DmlResult > | ExecuteDml (Transaction transaction, SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Executes a SQL DML statement. More... | |
StatusOr< ProfileDmlResult > | ProfileDml (Transaction transaction, SqlStatement statement, QueryOptions const &opts) |
Executes a SQL query. More... | |
StatusOr< ProfileDmlResult > | ProfileDml (Transaction transaction, SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Executes a SQL query. More... | |
StatusOr< ExecutionPlan > | AnalyzeSql (Transaction transaction, SqlStatement statement, QueryOptions const &opts) |
Analyzes the execution plan of a SQL statement. More... | |
StatusOr< ExecutionPlan > | AnalyzeSql (Transaction transaction, SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Analyzes the execution plan of a SQL statement. More... | |
StatusOr< PartitionedDmlResult > | ExecutePartitionedDml (SqlStatement statement, QueryOptions const &opts) |
Executes a Partitioned DML SQL query. More... | |
StatusOr< PartitionedDmlResult > | ExecutePartitionedDml (SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Executes a Partitioned DML SQL query. More... | |
Backwards compatibility for PartitionOptions. | |
StatusOr< std::vector< QueryPartition > > | PartitionQuery (Transaction transaction, SqlStatement statement, PartitionOptions const &partition_options) |
Creates a set of partitions that can be used to execute a query operation in parallel. More... | |
StatusOr< std::vector< QueryPartition > > | PartitionQuery (Transaction transaction, SqlStatement statement, std::initializer_list< internal::NonConstructible >) |
Creates a set of partitions that can be used to execute a query operation in parallel. More... | |
Backwards compatibility for CommitOptions. | |
StatusOr< CommitResult > | Commit (std::function< StatusOr< Mutations >(Transaction)> const &mutator, std::unique_ptr< TransactionRerunPolicy > rerun_policy, std::unique_ptr< BackoffPolicy > backoff_policy, CommitOptions const &commit_options) |
Commits a read-write transaction. More... | |
StatusOr< CommitResult > | Commit (std::function< StatusOr< Mutations >(Transaction)> const &mutator, std::unique_ptr< TransactionRerunPolicy > rerun_policy, std::unique_ptr< BackoffPolicy > backoff_policy, std::initializer_list< internal::NonConstructible >) |
Commits a read-write transaction. More... | |
StatusOr< CommitResult > | Commit (std::function< StatusOr< Mutations >(Transaction)> const &mutator, CommitOptions const &commit_options) |
Commits a read-write transaction. More... | |
StatusOr< CommitResult > | Commit (std::function< StatusOr< Mutations >(Transaction)> const &mutator, std::initializer_list< internal::NonConstructible >) |
StatusOr< CommitResult > | Commit (Mutations mutations, CommitOptions const &commit_options) |
Commits the mutations , using the options , atomically in order. More... | |
StatusOr< CommitResult > | Commit (Mutations mutations, std::initializer_list< internal::NonConstructible >) |
Commits the mutations , using the options , atomically in order. More... | |
StatusOr< CommitResult > | Commit (Transaction transaction, Mutations mutations, CommitOptions const &commit_options) |
Commits a read-write transaction. More... | |
StatusOr< CommitResult > | Commit (Transaction transaction, Mutations mutations, std::initializer_list< internal::NonConstructible >) |
Commits a read-write transaction. More... | |
Friends | |
Equality | |
bool | operator== (Client const &a, Client const &b) |
bool | operator!= (Client const &a, Client const &b) |
Performs database client operations on Spanner.
Applications use this class to perform operations on Spanner Databases.
Client
objects are relatively cheap to create, copy, and move. However, each Client
object must be created with a std::shared_ptr<Connection>
, which itself is relatively expensive to create. Therefore, connection instances should be shared when possible. See the MakeConnection()
method and the Connection
interface for more details.
Instances of this class created via copy-construction or copy-assignment share the underlying pool of connections. Access to these copies via multiple threads is guaranteed to work. Two threads operating on the same instance of this class is not guaranteed to work.
This class uses StatusOr<T>
to report errors. When an operation fails to perform its work the returned StatusOr<T>
contains the error details. If the ok()
member function in the StatusOr<T>
returns true
then it contains the expected result. For more information, see the Error Handling Guide.
Most operations that take an SqlStatement
may also be modified with query Options
. These options can be set at various levels, with more specific levels taking precedence over broader ones. For example, Options
that are passed directly to Client::ExecuteQuery()
will take precedence over the Client
-level defaults (if any), which will themselves take precedence over any environment variables. The following table shows the environment variables that may optionally be set and the query Options
setting that they affect.
Environment Variable | Options setting |
---|---|
SPANNER_OPTIMIZER_VERSION | QueryOptimizerVersionOption |
SPANNER_OPTIMIZER_STATISTICS_PACKAGE | QueryOptimizerStatisticsPackageOption |
|
inlineexplicit |
Constructs a Client
object using the specified conn
and opts
.
See MakeConnection()
for how to create a connection to Spanner. To help with unit testing, callers may create fake/mock Connection
objects that are injected into the Client
.
|
delete |
No default construction.
|
default |
|
default |
|
inlineexplicit |
|
inlineexplicit |
StatusOr< ExecutionPlan > google::cloud::spanner::Client::AnalyzeSql | ( | Transaction | transaction, |
SqlStatement | statement, | ||
Options | opts = {} |
||
) |
Analyzes the execution plan of a SQL statement.
Analyzing provides the ExecutionPlan
, but does not execute the SQL statement.
Operations inside read-write transactions might return ABORTED
. If this occurs, the application should restart the transaction from the beginning.
transaction | Execute this query as part of an existing transaction. |
statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
|
inline |
Analyzes the execution plan of a SQL statement.
|
inline |
Analyzes the execution plan of a SQL statement.
|
inline |
Commits the mutations
, using the options
, atomically in order.
StatusOr< CommitResult > google::cloud::spanner::Client::Commit | ( | Mutations | mutations, |
Options | opts = {} |
||
) |
Commits the mutations
, using the options
, atomically in order.
This function uses the re-run loop described above with the default policies.
|
inline |
Commits the mutations
, using the options
, atomically in order.
|
inline |
Commits a read-write transaction.
StatusOr< CommitResult > google::cloud::spanner::Client::Commit | ( | std::function< StatusOr< Mutations >(Transaction)> const & | mutator, |
Options | opts = {} |
||
) |
Commits a read-write transaction.
Same as above, but uses the default rerun and backoff policies.
mutator | the function called to create mutations |
opts | (optional) The options to use for this call. |
|
inline |
|
inline |
Commits a read-write transaction.
StatusOr< CommitResult > google::cloud::spanner::Client::Commit | ( | std::function< StatusOr< Mutations >(Transaction)> const & | mutator, |
std::unique_ptr< TransactionRerunPolicy > | rerun_policy, | ||
std::unique_ptr< BackoffPolicy > | backoff_policy, | ||
Options | opts = {} |
||
) |
Commits a read-write transaction.
Calls the mutator
in the context of a new read-write transaction. The mutator
can execute read/write operations using the transaction, and returns any additional Mutations
to commit.
If the mutator
succeeds and the transaction commits, then Commit()
returns the CommitResult
.
If the mutator
returns a non-rerunnable status (according to the rerun_policy
), the transaction is rolled back and that status is returned. Similarly, if the transaction fails to commit with a non- rerunnable status, that status is returned.
Otherwise the whole process repeats (subject to rerun_policy
and backoff_policy
), by building a new transaction and re-running the mutator
. The lock priority of the operation increases after each rerun, meaning that the next attempt has a slightly better chance of success.
Note that the mutator
should only return a rerunnable status when the transaction is no longer usable (e.g., it was aborted). Otherwise the transaction will be leaked.
mutator | the function called to create mutations |
rerun_policy | controls for how long (or how many times) the mutator will be rerun after the transaction aborts. |
backoff_policy | controls how long Commit waits between reruns. |
opts | (optional) The options to use for this call. Expected options include any of the following types: |
Rethrows | any exception thrown by `mutator` (after rolling back the transaction). However, a RuntimeStatusError exception is instead consumed and converted into a mutator return value of the enclosed Status . |
|
inline |
Commits a read-write transaction.
|
inline |
Commits a read-write transaction.
StatusOr< CommitResult > google::cloud::spanner::Client::Commit | ( | Transaction | transaction, |
Mutations | mutations, | ||
Options | opts = {} |
||
) |
Commits a read-write transaction.
The commit might return a kAborted
error. This can occur at any time. Commonly the cause is conflicts with concurrent transactions, however it can also happen for a variety of other reasons. If Commit
returns kAborted
, the caller may try to reapply the mutations within a new read-write transaction (which should share lock priority with the aborted transaction so that the new attempt has a slightly better chance of success).
Commit
with a read-only transaction.Commit
overloads if you want to simply reapply mutations after a kAborted
error.transaction | The transaction to commit. |
mutations | The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list. |
opts | (optional) The options to use for this call. |
StatusOr
containing the result of the commit or error status on failure.
|
inline |
Commits a read-write transaction.
StatusOr< CommitResult > google::cloud::spanner::Client::CommitAtLeastOnce | ( | Transaction::ReadWriteOptions | transaction_options, |
Mutations | mutations, | ||
Options | opts = {} |
||
) |
Commits a write transaction with at-least-once semantics.
Apply the given mutations atomically, using a single RPC, and therefore without replay protection. That is, it is possible that the mutations will be applied more than once. If the mutations are not idempotent, this may lead to a failure (for example, an insert may fail with "already exists" even though the row did not exist before the call was made). Accordingly, this call may only be appropriate for idempotent, latency- sensitive and/or high-throughput blind writing.
Commit
overloads if you want exactly-once semantics or want to reapply mutations after a kAborted
error.transaction_options | Execute the commit in a temporary transaction with these options. |
mutations | The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list. |
opts | (optional) The options to use for this call. |
StatusOr
containing the result of the commit or error status on failure. StatusOr< BatchDmlResult > google::cloud::spanner::Client::ExecuteBatchDml | ( | Transaction | transaction, |
std::vector< SqlStatement > | statements, | ||
Options | opts = {} |
||
) |
Executes a batch of SQL DML statements.
This method allows many statements to be run with lower latency than submitting them sequentially with ExecuteDml
.
Statements are executed in order, sequentially. Execution will stop at the first failed statement; the remaining statements will not run.
As with all read-write transactions, the results will not be visible outside of the transaction until it is committed. For that reason, it is advisable to run this method from a Commit
mutator.
BatchDmlResult::status
field.transaction | The read-write transaction to execute the operation in. |
statements | The list of statements to execute in this batch. Statements are executed serially, such that the effects of statement i are visible to statement i+1. Each statement must be a DML statement. Execution will stop at the first failed statement; the remaining statements will not run. Must not be empty. |
opts | (optional) The options to use for this call. Expected options are any of the types in the following option lists.
|
StatusOr< DmlResult > google::cloud::spanner::Client::ExecuteDml | ( | Transaction | transaction, |
SqlStatement | statement, | ||
Options | opts = {} |
||
) |
Executes a SQL DML statement.
Operations inside read-write transactions might return ABORTED
. If this occurs, the application should restart the transaction from the beginning.
transaction | Execute this query as part of an existing transaction. |
statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
|
inline |
Executes a SQL DML statement.
|
inline |
Executes a SQL DML statement.
StatusOr< PartitionedDmlResult > google::cloud::spanner::Client::ExecutePartitionedDml | ( | SqlStatement | statement, |
Options | opts = {} |
||
) |
Executes a Partitioned DML SQL query.
statement | the SQL statement to execute. Please see the spanner documentation for the restrictions on the SQL statements supported by this function. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
|
inline |
Executes a Partitioned DML SQL query.
|
inline |
Executes a Partitioned DML SQL query.
RowStream google::cloud::spanner::Client::ExecuteQuery | ( | QueryPartition const & | partition, |
Options | opts = {} |
||
) |
Executes a SQL query on a subset of rows in a database.
Requires a prior call to PartitionQuery
to obtain the partition information; see the documentation of that method for full details.
RowStream
can exceed 100 MiB, and no column value can exceed 10 MiB.partition | A QueryPartition , obtained by calling PartitionQuery . |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
|
inline |
Executes a SQL query on a subset of rows in a database.
|
inline |
Executes a SQL query on a subset of rows in a database.
RowStream google::cloud::spanner::Client::ExecuteQuery | ( | SqlStatement | statement, |
Options | opts = {} |
||
) |
Executes a SQL query.
Operations inside read-write transactions might return ABORTED
. If this occurs, the application should restart the transaction from the beginning.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
SELECT * ...
queries are supported, but there's no guarantee about the order, nor number, of returned columns. Therefore, the caller must look up the wanted values in each row by column name. When the desired column names are known in advance, it is better to list them explicitly in the query's SELECT statement, so that unnecessary values are not returned/ignored, and the column order is known. This enables more efficient and simpler code.
Can also execute a DML statement with a returning clause in a read/write transaction.
RowStream
can exceed 100 MiB, and no column value can exceed 10 MiB.SELECT *
. THEN RETURN
. statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
|
inline |
Executes a SQL query.
|
inline |
Executes a SQL query.
RowStream google::cloud::spanner::Client::ExecuteQuery | ( | Transaction | transaction, |
SqlStatement | statement, | ||
Options | opts = {} |
||
) |
Executes a SQL query.
Operations inside read-write transactions might return ABORTED
. If this occurs, the application should restart the transaction from the beginning.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
SELECT * ...
queries are supported, but there's no guarantee about the order, nor number, of returned columns. Therefore, the caller must look up the wanted values in each row by column name. When the desired column names are known in advance, it is better to list them explicitly in the query's SELECT statement, so that unnecessary values are not returned/ignored, and the column order is known. This enables more efficient and simpler code.
Can also execute a DML statement with a returning clause in a read/write transaction.
RowStream
can exceed 100 MiB, and no column value can exceed 10 MiB.SELECT *
. THEN RETURN
. statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
transaction | Execute this query as part of an existing transaction. |
|
inline |
Executes a SQL query.
|
inline |
Executes a SQL query.
RowStream google::cloud::spanner::Client::ExecuteQuery | ( | Transaction::SingleUseOptions | transaction_options, |
SqlStatement | statement, | ||
Options | opts = {} |
||
) |
Executes a SQL query.
Operations inside read-write transactions might return ABORTED
. If this occurs, the application should restart the transaction from the beginning.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
SELECT * ...
queries are supported, but there's no guarantee about the order, nor number, of returned columns. Therefore, the caller must look up the wanted values in each row by column name. When the desired column names are known in advance, it is better to list them explicitly in the query's SELECT statement, so that unnecessary values are not returned/ignored, and the column order is known. This enables more efficient and simpler code.
Can also execute a DML statement with a returning clause in a read/write transaction.
RowStream
can exceed 100 MiB, and no column value can exceed 10 MiB.SELECT *
. THEN RETURN
. statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
transaction_options | Execute this query in a single-use transaction with these options. |
|
inline |
Executes a SQL query.
|
inline |
Executes a SQL query.
StatusOr< std::vector< QueryPartition > > google::cloud::spanner::Client::PartitionQuery | ( | Transaction | transaction, |
SqlStatement | statement, | ||
Options | opts = Options{} |
||
) |
Creates a set of partitions that can be used to execute a query operation in parallel.
Each of the returned partitions can be passed to ExecuteQuery
to specify a subset of the query result to read.
Partitions become invalid when the session used to create them is deleted, is idle for too long, begins a new transaction, or becomes too old. When any of these happen, it is not possible to resume the query, and the whole operation must be restarted from the beginning.
transaction | The transaction to execute the operation in. Must be a read-only snapshot transaction. |
statement | The SQL statement to execute. |
opts | Options used for this request. |
StatusOr
containing a vector of QueryPartition
s or error status on failure.
|
inline |
Creates a set of partitions that can be used to execute a query operation in parallel.
|
inline |
Creates a set of partitions that can be used to execute a query operation in parallel.
StatusOr< std::vector< ReadPartition > > google::cloud::spanner::Client::PartitionRead | ( | Transaction | transaction, |
std::string | table, | ||
KeySet | keys, | ||
std::vector< std::string > | columns, | ||
Options | opts = {} |
||
) |
Creates a set of partitions that can be used to execute a read operation in parallel.
Each of the returned partitions can be passed to Read
to specify a subset of the read result to read.
There are no ordering guarantees on rows returned among the returned partition, or even within each individual Read
call issued with a given partition.
Partitions become invalid when the session used to create them is deleted, is idle for too long, begins a new transaction, or becomes too old. When any of these happen, it is not possible to resume the read, and the whole operation must be restarted from the beginning.
transaction | The transaction to execute the operation in. Must be a read-only snapshot transaction. |
table | The name of the table in the database to be read. |
keys | Identifies the rows to be yielded. If read_options.index_name is set, names keys in that index; otherwise names keys in the primary index of table . It is not an error for keys to name rows that do not exist in the database; Read yields nothing for nonexistent rows. |
columns | The columns of table to be returned for each row matching this request. |
opts | Options used for this request. |
StatusOr
containing a vector of ReadPartition
or error status on failure.
|
inline |
Creates a set of partitions that can be used to execute a read operation in parallel.
|
inline |
Creates a set of partitions that can be used to execute a read operation in parallel.
StatusOr< ProfileDmlResult > google::cloud::spanner::Client::ProfileDml | ( | Transaction | transaction, |
SqlStatement | statement, | ||
Options | opts = {} |
||
) |
Profiles a SQL DML statement.
Profiling executes the DML statement, provides the modified row count, ExecutionPlan
, and execution statistics.
Operations inside read-write transactions might return ABORTED
. If this occurs, the application should restart the transaction from the beginning.
transaction | Execute this query as part of an existing transaction. |
statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
|
inline |
Executes a SQL query.
|
inline |
Executes a SQL query.
ProfileQueryResult google::cloud::spanner::Client::ProfileQuery | ( | SqlStatement | statement, |
Options | opts = {} |
||
) |
Profiles a SQL query.
Profiling executes the query, provides the resulting rows, ExecutionPlan
, and execution statistics.
Operations inside read-write transactions might return kAborted
. If this occurs, the application should restart the transaction from the beginning.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
ExecutionPlan
are available.ProfileQueryResult
can exceed 100 MiB, and no column value can exceed 10 MiB.statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
|
inline |
Profiles a SQL query.
|
inline |
Profiles a SQL query.
ProfileQueryResult google::cloud::spanner::Client::ProfileQuery | ( | Transaction | transaction, |
SqlStatement | statement, | ||
Options | opts = {} |
||
) |
Profiles a SQL query.
Profiling executes the query, provides the resulting rows, ExecutionPlan
, and execution statistics.
Operations inside read-write transactions might return kAborted
. If this occurs, the application should restart the transaction from the beginning.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
ExecutionPlan
are available.ProfileQueryResult
can exceed 100 MiB, and no column value can exceed 10 MiB.statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
transaction | Execute this query as part of an existing transaction. |
|
inline |
Profiles a SQL query.
|
inline |
Profiles a SQL query.
ProfileQueryResult google::cloud::spanner::Client::ProfileQuery | ( | Transaction::SingleUseOptions | transaction_options, |
SqlStatement | statement, | ||
Options | opts = {} |
||
) |
Profiles a SQL query.
Profiling executes the query, provides the resulting rows, ExecutionPlan
, and execution statistics.
Operations inside read-write transactions might return kAborted
. If this occurs, the application should restart the transaction from the beginning.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
ExecutionPlan
are available.ProfileQueryResult
can exceed 100 MiB, and no column value can exceed 10 MiB.statement | The SQL statement to execute. |
opts | (optional) The Options to use for this call. If given, these will take precedence over the options set at the client and environment levels. |
transaction_options | Execute this query in a single-use transaction with these options. |
|
inline |
Profiles a SQL query.
|
inline |
Profiles a SQL query.
RowStream google::cloud::spanner::Client::Read | ( | ReadPartition const & | partition, |
Options | opts = {} |
||
) |
Reads rows from a subset of rows in a database.
Requires a prior call to PartitionRead
to obtain the partition information; see the documentation of that method for full details.
ReadResult
can exceed 100 MiB, and no column value can exceed 10 MiB.partition | A ReadPartition , obtained by calling PartitionRead . |
opts | Options used for this request. |
RowStream google::cloud::spanner::Client::Read | ( | std::string | table, |
KeySet | keys, | ||
std::vector< std::string > | columns, | ||
Options | opts = {} |
||
) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
ReadResult
can exceed 100 MiB, and no column value can exceed 10 MiB.table | The name of the table in the database to be read. |
keys | Identifies the rows to be yielded. If read_options.index_name is set, names keys in that index; otherwise names keys in the primary index of table . It is not an error for keys to name rows that do not exist in the database; Read yields nothing for nonexistent rows. |
columns | The columns of table to be returned for each row matching this request. |
opts | Options used for this request. |
|
inline |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
|
inline |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
RowStream google::cloud::spanner::Client::Read | ( | Transaction | transaction, |
std::string | table, | ||
KeySet | keys, | ||
std::vector< std::string > | columns, | ||
Options | opts = {} |
||
) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
ReadResult
can exceed 100 MiB, and no column value can exceed 10 MiB.table | The name of the table in the database to be read. |
keys | Identifies the rows to be yielded. If read_options.index_name is set, names keys in that index; otherwise names keys in the primary index of table . It is not an error for keys to name rows that do not exist in the database; Read yields nothing for nonexistent rows. |
columns | The columns of table to be returned for each row matching this request. |
opts | Options used for this request. |
transaction | Execute this read as part of an existing transaction. |
|
inline |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
|
inline |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
RowStream google::cloud::spanner::Client::Read | ( | Transaction::SingleUseOptions | transaction_options, |
std::string | table, | ||
KeySet | keys, | ||
std::vector< std::string > | columns, | ||
Options | opts = {} |
||
) |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
Callers can optionally supply a Transaction
or Transaction::SingleUseOptions
used to create a single-use transaction - or neither, in which case a single-use transaction with default options is used.
ReadResult
can exceed 100 MiB, and no column value can exceed 10 MiB.table | The name of the table in the database to be read. |
keys | Identifies the rows to be yielded. If read_options.index_name is set, names keys in that index; otherwise names keys in the primary index of table . It is not an error for keys to name rows that do not exist in the database; Read yields nothing for nonexistent rows. |
columns | The columns of table to be returned for each row matching this request. |
opts | Options used for this request. |
transaction_options | Execute this read in a single-use transaction with these options. |
|
inline |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
|
inline |
Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteQuery()
.
Status google::cloud::spanner::Client::Rollback | ( | Transaction | transaction, |
Options | opts = {} |
||
) |
Rolls back a read-write transaction, releasing any locks it holds.
At any time before Commit
, the client can call Rollback
to abort the transaction. It is a good idea to call this for any read-write transaction that includes one or more Read
, ExecuteQuery
, or ExecuteDml
requests and ultimately decides not to commit.
Rollback
with a read-only transaction.transaction | The transaction to roll back. |
opts | (optional) The options to use for this call. |