postgres

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package postgres implements the PostgreSQL dialect driver. This file is the lexer profile: token boundaries only, no SQL understanding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frontend

type Frontend struct{}

Frontend is the pg_query-backed grammar frontend (design 02 §3).

func (Frontend) Parse

func (Frontend) Parse(sql string) (dialect.Tree, error)

func (Frontend) ProbeExpr

func (f Frontend) ProbeExpr(expr string) error

ProbeExpr checks that expr forms exactly one boolean-position expression: it must parse when parenthesized as a WHERE qual. Balance of parentheses is the caller's (rules') concern via the lexer; parse failure here means the body is not one expression.

func (Frontend) ProbeGroupBy

func (f Frontend) ProbeGroupBy(clause string) error

ProbeGroupBy checks that clause is exactly one statement-level GROUP BY clause and nothing more.

func (Frontend) ProbeInsertValue

func (f Frontend) ProbeInsertValue(expr string) error

ProbeInsertValue checks that expr is exactly one VALUES row item (including the DEFAULT keyword, which is only legal there).

func (Frontend) ProbeJoinItem

func (f Frontend) ProbeJoinItem(item string) error

ProbeJoinItem checks that item is a join item attachable to a preceding FROM entry: `SELECT 1 FROM sqletch_probe_t <item>` must parse into exactly one FROM tree and contribute nothing else.

func (Frontend) ProbeOrderBy

func (f Frontend) ProbeOrderBy(clause string) error

ProbeOrderBy checks that clause is exactly one statement-level ORDER BY clause and nothing more.

func (Frontend) ProbeOrderByKey

func (f Frontend) ProbeOrderByKey(expr string) error

ProbeOrderByKey checks that expr is exactly one sort key.

func (Frontend) ProbeSetItem

func (f Frontend) ProbeSetItem(item string) error

ProbeSetItem checks that item is exactly one UPDATE SET assignment.

type Oracle

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

Oracle is the server-backed PostgreSQL type oracle: it lets the database itself be the type checker via the extended protocol's Parse/Describe. See docs/design/04-type-oracle.md.

func NewOracle

func NewOracle(conn *pgx.Conn) *Oracle

func (*Oracle) Describe

func (o *Oracle) Describe(ctx context.Context, sql string) (dialect.Desc, error)

func (*Oracle) Plan

func (o *Oracle) Plan(ctx context.Context, sql string) error

Plan surfaces planner-stage errors invisible to prepare. GENERIC_PLAN (PostgreSQL 16+) plans a parameterized statement without values — exactly the shape-verification need.

func (*Oracle) PlanText

func (o *Oracle) PlanText(ctx context.Context, sql string) (string, error)

PlanText returns the planner's textual output for a shape — the `explain --analyze` payload. It goes through pgconn's raw simple query: GENERIC_PLAN takes bare $n placeholders without values, and pgx's higher-level paths would demand arguments for them.

func (*Oracle) ServerVersion

func (o *Oracle) ServerVersion(ctx context.Context) (string, error)

func (*Oracle) Snapshot

func (o *Oracle) Snapshot(ctx context.Context) (*cache.Catalog, error)

type Profile

type Profile struct{}

func (Profile) NextToken

func (Profile) NextToken(src []byte, pos int) (dialect.Token, error)

func (Profile) PlaceholderStyle

func (Profile) PlaceholderStyle() dialect.PlaceholderStyle

PlaceholderStyle declares PostgreSQL's numbered-with-reuse binding.

type TypeMap

type TypeMap struct{}

TypeMap maps PostgreSQL type OIDs to Go types for generated code. Deliberately conservative: unmapped types are a compile error (SQLETCH311) with the type name in the message — never a silent guess. Extensions require checking that pgx can Scan/Encode the Go type for that OID.

func (TypeMap) GoType

func (TypeMap) GoType(oid uint32) (dialect.GoTypeRef, bool)

func (TypeMap) TypeByName

func (TypeMap) TypeByName(name string) (dialect.TypeRef, bool)

TypeByName resolves a SQL type name from a `-- @param` hint.

func (TypeMap) WritableName

func (TypeMap) WritableName(oid uint32) (string, bool)

WritableName returns the `-- @param` spelling for an OID, so diagnostics can show the compliant rewrite. False when the type has no annotation spelling (it can then only be inferred).

Jump to

Keyboard shortcuts

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