Documentation ¶
Index ¶
- func AdvisoryUnlock(ctx context.Context, q QueryerContext, id int64) (bool, error)
- func Connect(connectionString string) (*sqlx.DB, error)
- func Quote(o interface{}) string
- func QuoteIdent(s string) string
- func QuoteIdentStrings(in []string) []string
- func QuoteIdentWithDots(s string) string
- func TryAdvisoryLock(ctx context.Context, q QueryerContext, id int64) (bool, error)
- func TryAdvisoryXactLock(ctx context.Context, tx *sqlx.Tx, id int64) (bool, error)
- type Connection
- type DB
- type DefaultConnection
- type ExecerContext
- type Instance
- func (d *Instance) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (d *Instance) GetDatabase() *sqlx.DB
- func (d *Instance) NewTx(ctx context.Context, createTransaction bool) (TransactionExecerContext, error)
- func (d *Instance) QueryContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
- func (d *Instance) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- type NullTransaction
- type QueryerContext
- type SwitchableDatabaseConnection
- type Transaction
- type TransactionExecerContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdvisoryUnlock ¶ added in v0.3.0
TryAdvisoryLock will release a previously-acquired exclusive session-level advisory lock. Returns true if the lock is successfully released. If the lock was not held, false is returned, and in addition, an SQL warning will be reported by the server.
https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS
func QuoteIdentStrings ¶ added in v0.4.0
QuoteIdentStrings escapes identifiers in PG.
func QuoteIdentWithDots ¶ added in v0.4.0
QuoteIdentWithDots escapes identifiers in PG.
public.test -> "public"."test"
func TryAdvisoryLock ¶ added in v0.3.0
TryAdvisoryLock will try to obtain session-level exclusive lock. This will either obtain the lock immediately and return true, or return false without waiting if the lock cannot be acquired immediately.
https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS
func TryAdvisoryXactLock ¶
TryAdvisoryXactLock will try to obtain transaction-level exclusive lock. It will not wait for the lock to become available. It will either obtain the lock immediately and return true, or return false if the lock cannot be acquired immediately. If acquired, is automatically released at the end of the current transaction and cannot be released explicitly.
https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS
Types ¶
type Connection ¶ added in v0.4.0
type DB ¶ added in v0.4.0
type DB interface { ExecerContext QueryerContext GetDatabase() *sqlx.DB NewTx(ctx context.Context, createTransaction bool) (TransactionExecerContext, error) }
type DefaultConnection ¶ added in v0.4.0
type DefaultConnection struct{}
type ExecerContext ¶ added in v0.4.0
type Instance ¶ added in v0.4.0
type Instance struct { DB // contains filtered or unexported fields }
func (*Instance) ExecContext ¶ added in v0.4.0
func (*Instance) GetDatabase ¶ added in v0.4.0
func (*Instance) NewTx ¶ added in v0.4.0
func (d *Instance) NewTx(ctx context.Context, createTransaction bool) (TransactionExecerContext, error)
NewTx is a helper that creates real transaction or null one based on createTransaction flag.
func (*Instance) QueryContext ¶ added in v0.4.0
type NullTransaction ¶ added in v0.3.0
type NullTransaction struct {
// contains filtered or unexported fields
}
NullTransaction represents fake transaction.
func (*NullTransaction) Commit ¶ added in v0.3.0
func (t *NullTransaction) Commit() error
func (*NullTransaction) ExecContext ¶ added in v0.3.0
func (*NullTransaction) Rollback ¶ added in v0.3.0
func (t *NullTransaction) Rollback() error
type QueryerContext ¶ added in v0.4.0
type SwitchableDatabaseConnection ¶ added in v0.9.0
type SwitchableDatabaseConnection struct {
DatabaseName string
}
type Transaction ¶ added in v0.3.0
type Transaction struct {
// contains filtered or unexported fields
}
Transaction represents database transaction.
func (*Transaction) Commit ¶ added in v0.3.0
func (t *Transaction) Commit() error
func (*Transaction) ExecContext ¶ added in v0.3.0
func (*Transaction) Rollback ¶ added in v0.3.0
func (t *Transaction) Rollback() error
type TransactionExecerContext ¶ added in v0.3.0
type TransactionExecerContext interface { ExecerContext Rollback() error Commit() error }