pgsql

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DbSlowMethodMilliseconds = 500

DbSlowMethodMilliseconds defines the maximum number of Milliseconds to define a DB operation slow

Functions

func DbMeasureQuerySince

func DbMeasureQuerySince(query string, start time.Time)

DbMeasureQuerySince emit DB operation perf, and logs a Warning for slow operations

func DbMeasureSince

func DbMeasureSince(start time.Time)

DbMeasureSince emit DB operation perf, and logs a Warning for slow operations

Types

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider represents SQL client instance

func New

func New(p xdb.Provider) (*Provider, error)

New creates a Provider instance

func (*Provider) BeginTx

func (p *Provider) BeginTx(ctx context.Context, opts *sql.TxOptions) (xdb.Provider, error)

BeginTx starts a transaction.

The provided context is used until the transaction is committed or rolled back. If the context is cancelled, the sql package will roll back the transaction. Tx.Commit will return an error if the context provided to BeginTx is cancelled.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

func (*Provider) Builder

func (p *Provider) Builder() xsql.SQLDialect

Builder returns SQL dialect

func (*Provider) CheckErrIDConflict

func (p *Provider) CheckErrIDConflict(ctx context.Context, err error, id uint64)

CheckErrIDConflict prints decomposed ID if error is ID conflict

func (*Provider) Close

func (p *Provider) Close() (err error)

Close connection and release resources

func (*Provider) Commit

func (p *Provider) Commit() error

func (*Provider) ConnectionString

func (p *Provider) ConnectionString() string

func (*Provider) DB

func (p *Provider) DB() xdb.DB

DB returns underlying DB connection

func (*Provider) ExecContext

func (p *Provider) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*Provider) IDTime

func (p *Provider) IDTime(id uint64) time.Time

IDTime returns time when ID was generated

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) NextID

func (p *Provider) NextID() xdb.ID

NextID returns unique ID

func (*Provider) QueryContext

func (p *Provider) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

func (*Provider) QueryRowContext

func (p *Provider) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

QueryRowContext executes a query that is expected to return at most one row. QueryRowContext always returns a non-nil value. Errors are deferred until Row's Scan method is called. If the query selects no rows, the *Row's Scan will return ErrNoRows. Otherwise, the *Row's Scan scans the first selected row and discards the rest.

func (*Provider) Rollback

func (p *Provider) Rollback() error

func (*Provider) Tx

func (p *Provider) Tx() xdb.Tx

Tx returns underlying DB transaction

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL