transaction.go 642 B

123456789101112131415161718192021222324252627
  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() (e error) {
  14. debug("Tx Commit")
  15. e = tx.mc.exec("COMMIT")
  16. tx.mc = nil
  17. return
  18. }
  19. func (tx *mysqlTx) Rollback() (e error) {
  20. debug("Tx Rollback")
  21. e = tx.mc.exec("ROLLBACK")
  22. tx.mc = nil
  23. return
  24. }