pgwire

package
v0.18.52 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package pgwire implements the PostgreSQL v3 wire protocol frontend. This allows psql, JDBC, ODBC, and any Postgres-compatible client to connect to Wadjet and execute SQL queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypeMod added in v0.18.5

func TypeMod(m wadjet.ColumnMeta) int32

TypeMod returns the PostgreSQL type modifier (atttypmod) for a result column, or -1 for a type that has none. It is exported so the differential oracle asserts the typmod a client is HANDED rather than a copy of this rule (benchmarks/tpch, ADR-0024 item 5).

The modifier is where PostgreSQL keeps the part of a declaration the OID does not carry: numeric's (precision, scale), varchar/bpchar's length, time/timestamp/interval's second precision. -1 means "unconstrained", which is protocol-legal and is what every unparameterised type sends — so writing the constant -1 for everything was less information rather than wrong information, and it went unnoticed until DECIMAL started declaring OID 1700 (#454). What a client loses is ResultSetMetaData.getPrecision()/getScale(): a column declared DECIMAL(9,2) reports 0 or "unlimited", and a tool that sizes a display column or round-trips DDL from a result set gets it wrong.

numeric packs the pair as ((precision << 16) | scale) + VARHDRSZ, exactly as PostgreSQL's numerictypmodin does (utils/adt/numeric.c). Precision 0 means the declaration did not reach us — a plan-declared schema for a zero-row result, an inferred type — and an unconstrained numeric is the honest answer there, not a fabricated (0,0).

The switch is keyed on the wadjet TypeID rather than the OID so that a type which later gains a parameter (a VARCHAR(n), a TIME(n)) is added here and not in the wire writer.

Types

type Config

type Config struct {
	Addr             string         // listen address, e.g. ":5433"
	TLSConfig        *tls.Config    // nil = plain TCP
	MaxConnections   int            // 0 = unlimited
	MaxConcurrentQry int            // 0 = unlimited concurrent queries
	QueryTimeout     time.Duration  // 0 = no timeout
	AuthProvider     *auth.Provider // nil = no auth enforcement
}

Config holds configuration for the pgwire server.

type Server

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

Server listens for PostgreSQL wire protocol connections and dispatches queries to a Wadjet DB instance.

func NewServer

func NewServer(db *wadjet.DB, cfg Config, logger *slog.Logger) *Server

NewServer creates a new PostgreSQL wire protocol server.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the listener's address (useful when using :0 for tests).

func (*Server) QueuedQueries

func (s *Server) QueuedQueries() int64

QueuedQueries returns the number of queries waiting for admission.

func (*Server) SetCoordinator

func (s *Server) SetCoordinator(coord *coordinator.Coordinator)

SetCoordinator attaches a coordinator so SELECT statements stream through coord.ExecuteSQL (native-DAG executor with batched output) instead of the legacy wadjet.DB.Query path which materializes all rows into a single CollectSink — root cause of the 2026-04-25 Q18 SF10 OOM.

When unset, all paths fall back to db.Query (current behavior; safe for any caller that hasn't migrated). When set, only SELECT queries route through coord; DDL / DESCRIBE / introspection stay on db.Query for now.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown gracefully stops the server.

func (*Server) Start

func (s *Server) Start(addr string) error

Start begins listening for connections on the given address.

Jump to

Keyboard shortcuts

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