Mercurial > gemma
view pkg/imports/misc.go @ 2750:6446bf6d2a89
search: use global search only in global context
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 21 Mar 2019 12:23:52 +0100 |
parents | 542d3441c2d8 |
children | a996f2ca9fa5 |
line wrap: on
line source
// SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // // Copyright (C) 2018 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann <sascha.teichmann@intevation.de> package imports import ( "context" "database/sql" "fmt" "strings" ) type stringCounter map[string]int func (sc stringCounter) String() string { var b strings.Builder for t, c := range sc { if b.Len() > 0 { b.WriteString(", ") } b.WriteString(fmt.Sprintf("%s: %d", t, c)) } return b.String() } func Savepoint( ctx context.Context, tx *sql.Tx, name string, ) error { _, err := tx.ExecContext(ctx, "SAVEPOINT "+name) return err } func RollbackToSavepoint( ctx context.Context, tx *sql.Tx, name string, ) error { _, err := tx.ExecContext(ctx, "ROLLBACK TO SAVEPOINT "+name) return err } func ReleaseSavepoint( ctx context.Context, tx *sql.Tx, name string, ) error { _, err := tx.ExecContext(ctx, "RELEASE SAVEPOINT "+name) return err }