diff --git a/dataprovider/sqlcommon.go b/dataprovider/sqlcommon.go index d6cd1819..fca2c7b7 100644 --- a/dataprovider/sqlcommon.go +++ b/dataprovider/sqlcommon.go @@ -1081,15 +1081,15 @@ func sqlCommonExecSQLAndUpdateDBVersion(dbHandle *sql.DB, sqlQueries []string, n } func sqlCommonExecuteTx(ctx context.Context, dbHandle *sql.DB, txFn func(*sql.Tx) error) error { + if config.Driver == CockroachDataProviderName { + return crdb.ExecuteTx(ctx, dbHandle, nil, txFn) + } + tx, err := dbHandle.BeginTx(ctx, nil) if err != nil { return err } - if config.Driver == CockroachDataProviderName { - return crdb.ExecuteTx(ctx, dbHandle, nil, txFn) - } - err = txFn(tx) if err != nil { // we don't change the returned error