transaction.go 608 B

1234567891011121314151617181920212223242526
  1. // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
  2. //
  3. // Copyright 2012 Julien Schmidt. All rights reserved.
  4. // http://www.julienschmidt.com
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla Public
  7. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  8. // You can obtain one at http://mozilla.org/MPL/2.0/.
  9. package mysql
  10. type mysqlTx struct {
  11. mc *mysqlConn
  12. }
  13. func (tx *mysqlTx) Commit() (err error) {
  14. err = tx.mc.exec("COMMIT")
  15. tx.mc = nil
  16. return
  17. }
  18. func (tx *mysqlTx) Rollback() (err error) {
  19. err = tx.mc.exec("ROLLBACK")
  20. tx.mc = nil
  21. return
  22. }