Commit implements the driver.Tx.Commit method.
()
| 314 | |
| 315 | // Commit implements the driver.Tx.Commit method. |
| 316 | func (c *conn) Commit() (err error) { |
| 317 | if atomic.LoadInt32(&c.closed) != 0 { |
| 318 | return driver.ErrBadConn |
| 319 | } |
| 320 | |
| 321 | if !c.inTransaction { |
| 322 | return sql.ErrTxDone |
| 323 | } |
| 324 | |
| 325 | defer func() { |
| 326 | c.queries = c.queries[:0] |
| 327 | c.inTransaction = false |
| 328 | }() |
| 329 | |
| 330 | if len(c.queries) > 0 { |
| 331 | // send query |
| 332 | if _, _, _, err = c.sendQuery(context.Background(), types.WriteQuery, c.queries); err != nil { |
| 333 | return |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | return |
| 338 | } |
| 339 | |
| 340 | // Rollback implements the driver.Tx.Rollback method. |
| 341 | func (c *conn) Rollback() error { |