Documentation ¶
Index ¶
- Constants
- Variables
- func Connect(ctx context.Context) error
- func GetUsers(ctx context.Context) ([]string, error)
- func LogOpenTransactions()
- func SetPool(myPool PgxIface)
- func TrxForUser(ctx context.Context, userID string) (pgx.Tx, error)
- type PgxIface
- type PvDbTx
- func (t *PvDbTx) Begin(_ context.Context) (pgx.Tx, error)
- func (t *PvDbTx) BeginFunc(_ context.Context, _ func(pgx.Tx) error) (err error)
- func (t *PvDbTx) Commit(ctx context.Context) error
- func (t *PvDbTx) Conn() *pgx.Conn
- func (t *PvDbTx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (t *PvDbTx) Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)
- func (t *PvDbTx) LargeObjects() pgx.LargeObjects
- func (t *PvDbTx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
- func (t *PvDbTx) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (t *PvDbTx) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, ...) (pgconn.CommandTag, error)
- func (t *PvDbTx) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (t *PvDbTx) Rollback(ctx context.Context) error
- func (t *PvDbTx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
Constants ¶
const ( TWRRYtd = "twrr_ytd" TWRRMtd = "twrr_mtd" TWRRWtd = "twrr_wtd" TWRROneDay = "twrr_1d" )
Variables ¶
var (
ErrEmptyUserID = errors.New("userID cannot be an empty string")
)
var (
ErrUnsupported = errors.New("unsupported function")
)
Functions ¶
func LogOpenTransactions ¶
func LogOpenTransactions()
LogOpenTransactions writes an INFO log for each open transaction
func TrxForUser ¶
TrxForUser creates a transaction with the appropriate user set NOTE: the default use is pvapi which only has enough privileges to create new roles and switch to them. Any kind of real work must be done with a user role which limits access to only that user
Types ¶
type PvDbTx ¶
type PvDbTx struct {
// contains filtered or unexported fields
}
func (*PvDbTx) BeginFunc ¶
BeginFunc starts a pseudo nested transaction and executes f. If f does not return an err the pseudo nested transaction will be committed. If it does then it will be rolled back.
func (*PvDbTx) Commit ¶
Commit commits the transaction if this is a real transaction or releases the savepoint if this is a pseudo nested transaction. Commit will return ErrTxClosed if the Tx is already closed, but is otherwise safe to call multiple times. If the commit fails with a rollback status (e.g. the transaction was already in a broken state) then ErrTxCommitRollback will be returned.
func (*PvDbTx) Conn ¶
func (t *PvDbTx) Conn() *pgx.Conn
Conn returns the underlying *Conn that on which this transaction is executing.
func (*PvDbTx) LargeObjects ¶
func (t *PvDbTx) LargeObjects() pgx.LargeObjects
func (*PvDbTx) Rollback ¶
Rollback rolls back the transaction if this is a real transaction or rolls back to the savepoint if this is a pseudo nested transaction. Rollback will return ErrTxClosed if the Tx is already closed, but is otherwise safe to call multiple times. Hence, a defer tx.Rollback() is safe even if tx.Commit() will be called first in a non-error condition. Any other failure of a real transaction will result in the connection being closed.