Documentation
¶
Overview ¶
Package db is the only place that holds a connection to the database: a lazy, bounded pool and two transaction runners (read-only and read-write) that apply the session settings and clean up after every call.
Index ¶
- func AtLeast(version string, major, minor int) bool
- type ConnectError
- type DB
- func (d *DB) Close()
- func (d *DB) Info(ctx context.Context) (Info, error)
- func (d *DB) ReadOnly(ctx context.Context, fn func(ctx context.Context, tx pgx.Tx) error) error
- func (d *DB) ReadWrite(ctx context.Context, fn func(ctx context.Context, tx pgx.Tx) error) error
- func (d *DB) VectorTypes(ctx context.Context, t pgx.Tx) (map[uint32]bool, error)
- type Info
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnectError ¶
type ConnectError struct{ Err error }
ConnectError reports a failure to obtain a connection to the database.
func (*ConnectError) Error ¶
func (e *ConnectError) Error() string
Error returns "cannot connect to the database: " followed by the driver message, which holds no password.
func (*ConnectError) Unwrap ¶
func (e *ConnectError) Unwrap() error
Unwrap returns the driver error.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the connection pool of the process and its transaction runners.
func (*DB) Close ¶
func (d *DB) Close()
Close closes the pool, waiting for the connections in use to be released.
func (*DB) Info ¶
Info returns the server version and installed extensions, fetched on first use and cached on success.
func (*DB) ReadWrite ¶
ReadWrite runs fn in a transaction that is committed when fn succeeds and rolled back otherwise. Tools call it only in unrestricted mode.
func (*DB) VectorTypes ¶ added in v0.4.0
VectorTypes returns the OIDs of pgvector's vector and halfvec types, empty without pgvector. A stale answer is read again through t, the caller's transaction, so that a fresh one costs no transaction of its own.