(ctx context.Context, stmt spanner.Statement, opts spanner.QueryOptions)
| 266 | } |
| 267 | |
| 268 | func (s *Session) runQueryWithOptions(ctx context.Context, stmt spanner.Statement, opts spanner.QueryOptions) (*spanner.RowIterator, *spanner.ReadOnlyTransaction) { |
| 269 | if s.InReadWriteTransaction() { |
| 270 | // The current Go Spanner client library does not apply client-level directed read options to read-write transactions. |
| 271 | // Therefore, we explicitly set query-level options here to fail the query during a read-write transaction. |
| 272 | opts.DirectedReadOptions = s.clientConfig.DirectedReadOptions |
| 273 | opts.RequestTag = s.tc.tag |
| 274 | iter := s.tc.rwTxn.QueryWithOptions(ctx, stmt, opts) |
| 275 | s.tc.sendHeartbeat = true |
| 276 | return iter, nil |
| 277 | } |
| 278 | if s.InReadOnlyTransaction() { |
| 279 | opts.RequestTag = s.tc.tag |
| 280 | return s.tc.roTxn.QueryWithOptions(ctx, stmt, opts), s.tc.roTxn |
| 281 | } |
| 282 | |
| 283 | txn := s.client.Single() |
| 284 | return txn.QueryWithOptions(ctx, stmt, opts), txn |
| 285 | } |
| 286 | |
| 287 | // RunUpdate executes a DML statement on the running read-write transaction. |
| 288 | // It returns error if there is no running read-write transaction. |
no test coverage detected