Documentation
¶
Index ¶
- func AdvisoryUnlock(ctx context.Context, q QueryerContext, id int64) (bool, error)
- func Quote(o any) 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 DB
- type ExecerContext
- type Instance
- func (d *Instance) ExecContext(ctx context.Context, query string, args ...any) (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 ...any) (*sqlx.Rows, error)
- func (d *Instance) SelectContext(ctx context.Context, dest any, query string, args ...any) error
- type NullTransaction
- type QueryerContext
- type Transaction
- type TransactionExecerContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdvisoryUnlock ¶
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 ¶
QuoteIdentStrings escapes identifiers in PG.
func QuoteIdentWithDots ¶
QuoteIdentWithDots escapes identifiers in PG.
public.test -> "public"."test"
func TryAdvisoryLock ¶
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 DB ¶
type DB interface {
ExecerContext
QueryerContext
GetDatabase() *sqlx.DB
NewTx(ctx context.Context, createTransaction bool) (TransactionExecerContext, error)
}
type ExecerContext ¶
type Instance ¶
type Instance struct {
DB
// contains filtered or unexported fields
}
func (*Instance) ExecContext ¶
func (*Instance) GetDatabase ¶
func (*Instance) NewTx ¶
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 ¶
type NullTransaction ¶
type NullTransaction struct {
// contains filtered or unexported fields
}
NullTransaction represents fake transaction.
func (*NullTransaction) Commit ¶
func (t *NullTransaction) Commit() error
func (*NullTransaction) ExecContext ¶
func (*NullTransaction) Rollback ¶
func (t *NullTransaction) Rollback() error
type QueryerContext ¶
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction represents database transaction.
func (*Transaction) Commit ¶
func (t *Transaction) Commit() error
func (*Transaction) ExecContext ¶
func (*Transaction) Rollback ¶
func (t *Transaction) Rollback() error
type TransactionExecerContext ¶
type TransactionExecerContext interface {
ExecerContext
Rollback() error
Commit() error
}