|
@@ -14,7 +14,6 @@ import (
|
|
|
"context"
|
|
"context"
|
|
|
"database/sql"
|
|
"database/sql"
|
|
|
"database/sql/driver"
|
|
"database/sql/driver"
|
|
|
- "errors"
|
|
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// Ping implements driver.Pinger interface
|
|
// Ping implements driver.Pinger interface
|
|
@@ -41,15 +40,9 @@ func (mc *mysqlConn) Ping(ctx context.Context) error {
|
|
|
|
|
|
|
|
// BeginTx implements driver.ConnBeginTx interface
|
|
// BeginTx implements driver.ConnBeginTx interface
|
|
|
func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
|
|
func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
|
|
|
- if opts.ReadOnly {
|
|
|
|
|
- // TODO: support read-only transactions
|
|
|
|
|
- return nil, errors.New("mysql: read-only transactions not supported")
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if err := mc.watchCancel(ctx); err != nil {
|
|
if err := mc.watchCancel(ctx); err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
defer mc.finish()
|
|
defer mc.finish()
|
|
|
|
|
|
|
|
if sql.IsolationLevel(opts.Isolation) != sql.LevelDefault {
|
|
if sql.IsolationLevel(opts.Isolation) != sql.LevelDefault {
|
|
@@ -63,7 +56,7 @@ func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return mc.Begin()
|
|
|
|
|
|
|
+ return mc.begin(opts.ReadOnly)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mc *mysqlConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
|
|
func (mc *mysqlConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
|