crdb: fix transactions handling

This commit is contained in:
Nicola Murino 2021-03-25 09:07:56 +01:00
parent 6bc5c64a3a
commit db274f1093
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB

View file

@ -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 { 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) tx, err := dbHandle.BeginTx(ctx, nil)
if err != nil { if err != nil {
return err return err
} }
if config.Driver == CockroachDataProviderName {
return crdb.ExecuteTx(ctx, dbHandle, nil, txFn)
}
err = txFn(tx) err = txFn(tx)
if err != nil { if err != nil {
// we don't change the returned error // we don't change the returned error