postgres

package
v6.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrColumnCountMismatch = errors.New("postgres: describe column count mismatch")

ErrColumnCountMismatch is returned by the columnar path when the server Describe reports a different column count than the source declared.

View Source
var ErrEmptyColumnOrder = errors.New("postgres: source reports zero columns")

ErrEmptyColumnOrder is returned by the bulk insert path when the source reports zero columns; a multi-row INSERT would be degenerate without them.

View Source
var ErrUnregisteredColumnType = errors.New("postgres: unregistered column type OID")

ErrUnregisteredColumnType is returned by the columnar path when a target column has a type OID that pgx's type map cannot name for the array cast.

View Source
var ErrUnsupportedInsertMethod = errors.New("postgres: unsupported insert method")

ErrUnsupportedInsertMethod is returned when an insert request selects a method the PostgreSQL driver cannot serve.

View Source
var ErrUnsupportedType = errors.New("unsupported value type")

ErrUnsupportedType is returned when a query value has an unrecognized type.

Functions

func NewConnOnlyTx

func NewConnOnlyTx(conn *pgxpool.Conn, lg *zap.Logger, timeout time.Duration) *sqldriver.ConnOnlyTx[pgx.Rows]

func NewRows

func NewRows(pgxRows pgx.Rows) driver.Rows

Types

type Driver

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

func NewDriver

func NewDriver(
	ctx context.Context,
	opts driver.Options,
) (d *Driver, err error)

func (*Driver) Begin

func (d *Driver) Begin(ctx context.Context, isolation config.TxIsolationLevel) (driver.Tx, error)

func (*Driver) ClassifyError

func (*Driver) ClassifyError(err error) driver.ErrorFacts

func (*Driver) Insert

func (d *Driver) Insert(
	ctx context.Context,
	req *driver.InsertRequest,
) (*stats.Query, error)

Insert runs a typed driver.InsertRequest through the postgres driver. Each worker prepares a gen.Cursor partition, adapts it to a source.RowSource, and drains it through runInsertChunk. Generation is allocation-free after preparation; driver-side row materialization and COPY or bulk encoding may allocate.

func (*Driver) OpenSession added in v6.3.0

func (d *Driver) OpenSession(ctx context.Context) (driver.Session, error)

func (*Driver) PoolMaxConns added in v6.3.0

func (d *Driver) PoolMaxConns() int

func (*Driver) PoolStats added in v6.4.0

func (d *Driver) PoolStats() driver.PoolSnapshot

func (*Driver) RunQuery

func (d *Driver) RunQuery(
	ctx context.Context,
	sql string,
	args map[string]any,
) (*driver.QueryResult, error)

RunQuery executes sql with named :arg placeholders and returns rows cursor.

func (*Driver) RunRoutine added in v6.3.3

func (d *Driver) RunRoutine(
	ctx context.Context, isolation config.TxIsolationLevel, query string, args map[string]any,
) (*driver.QueryResult, error)

func (*Driver) SessionCapacity added in v6.3.0

func (d *Driver) SessionCapacity() int

func (*Driver) Teardown

func (d *Driver) Teardown(context.Context) error

type Executor

type Executor interface {
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	ExecContext(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryContext(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	CopyFrom(
		ctx context.Context,
		tableName pgx.Identifier,
		columnNames []string,
		rowSrc pgx.CopyFromSource,
	) (int64, error)
	BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
	Acquire(ctx context.Context) (*pgxpool.Conn, error)

	Ping(ctx context.Context) error
	Config() *pgxpool.Config
	Close()
}

type PgxDialect

type PgxDialect struct{}

PgxDialect implements sqlqueries.Dialect for PostgreSQL via pgx.

func (PgxDialect) Convert

func (PgxDialect) Convert(val any) (any, error)

func (PgxDialect) Deduplicate

func (PgxDialect) Deduplicate() bool

func (PgxDialect) Placeholder

func (PgxDialect) Placeholder(index int) string

func (PgxDialect) StatementDeadline

func (PgxDialect) StatementDeadline(timeout time.Duration) time.Duration

StatementDeadline returns timeout unchanged; there is no server-side hint to outlast, so the client deadline is the timeout itself.

func (PgxDialect) StatementTimeoutHint

func (PgxDialect) StatementTimeoutHint(sql string, _ time.Duration) (string, bool)

StatementTimeoutHint returns sql unchanged: pgx already turns a deadline into a PostgreSQL CancelRequest, so no session-level statement_timeout (and no pooled-connection state to leak) is needed.

type Rows

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

func (*Rows) Close

func (r *Rows) Close() error

func (*Rows) Columns

func (r *Rows) Columns() []string

func (*Rows) Err

func (r *Rows) Err() error

func (*Rows) Next

func (r *Rows) Next() bool

func (*Rows) ReadAll

func (r *Rows) ReadAll(limit int) [][]any

ReadAll reads up to limit rows and closes the cursor. limit <= 0 means no limit.

func (*Rows) Values

func (r *Rows) Values() []any

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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