Documentation
¶
Overview ¶
Package postgres implements the PostgreSQL dialect driver. This file is the lexer profile: token boundaries only, no SQL understanding.
Index ¶
- func DevConnConfig(dsn string) (cfg *pgx.ConnConfig, ambientDropped bool, err error)
- func StaleEntry(e *cache.OracleEntry) bool
- type DSNPolicyError
- type Frontend
- func (Frontend) Parse(sql string) (dialect.Tree, error)
- func (f Frontend) ProbeExpr(expr string) error
- func (f Frontend) ProbeGroupBy(clause string) error
- func (f Frontend) ProbeInsertValue(expr string) error
- func (f Frontend) ProbeJoinItem(item string) error
- func (f Frontend) ProbeOrderBy(clause string) error
- func (f Frontend) ProbeOrderByKey(expr string) error
- func (f Frontend) ProbeSetItem(item string) error
- type Oracle
- func (o *Oracle) Describe(ctx context.Context, sql string) (dialect.Desc, error)
- func (o *Oracle) Plan(ctx context.Context, sql string) error
- func (o *Oracle) PlanText(ctx context.Context, sql string) (string, error)
- func (o *Oracle) ServerVersion(ctx context.Context) (string, error)
- func (o *Oracle) Snapshot(ctx context.Context) (*cache.Catalog, error)
- type Profile
- type TypeMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DevConnConfig ¶ added in v0.0.9
func DevConnConfig(dsn string) (cfg *pgx.ConnConfig, ambientDropped bool, err error)
DevConnConfig parses a user-supplied dev-database DSN under the policy above. ambientDropped reports that an environment/passfile/service password was discarded because the host is not loopback (callers use it to explain an authentication failure). A refusal is a *DSNPolicyError; any other error is the DSN failing to parse.
func StaleEntry ¶ added in v0.0.8
func StaleEntry(e *cache.OracleEntry) bool
StaleEntry reports whether a committed oracle entry predates design 26: it names a user-defined type but records no kind. Describe records a kind for EVERY user-defined OID, so that combination cannot come from a current run; reading the entry anyway would make an enum look unmapped (SQLETCH311) instead of being re-described (D4). The caller treats a stale entry as a miss.
Types ¶
type DSNPolicyError ¶ added in v0.0.9
type DSNPolicyError struct {
// Key is the refused connection-string key, when the refusal is
// about a key.
Key string
// MultiHost is set when the DSN names more than one host/port.
MultiHost bool
}
DSNPolicyError is a refusal of database.dsn under the dev-database DSN policy. The CLI maps it to SQLETCH321 against sqletch.yaml.
func (*DSNPolicyError) Error ¶ added in v0.0.9
func (e *DSNPolicyError) Error() string
func (*DSNPolicyError) Hint ¶ added in v0.0.9
func (e *DSNPolicyError) Hint() string
Hint spells the compliant rewrite.
type Frontend ¶
type Frontend struct{}
Frontend is the pg_query-backed grammar frontend (design 02 §3).
func (Frontend) ProbeExpr ¶
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 ¶
ProbeGroupBy checks that clause is exactly one statement-level GROUP BY clause and nothing more.
func (Frontend) ProbeInsertValue ¶
ProbeInsertValue checks that expr is exactly one VALUES row item (including the DEFAULT keyword, which is only legal there).
func (Frontend) ProbeJoinItem ¶
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 ¶
ProbeOrderBy checks that clause is exactly one statement-level ORDER BY clause and nothing more.
func (Frontend) ProbeOrderByKey ¶
ProbeOrderByKey checks that expr is exactly one sort key.
func (Frontend) ProbeSetItem ¶
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 (*Oracle) Plan ¶
Plan surfaces planner-stage errors invisible to prepare. GENERIC_PLAN (PostgreSQL 16+) plans a parameterized statement without values — exactly the shape-verification need.
type Profile ¶
type Profile struct{}
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) TypeByName ¶
TypeByName resolves a SQL type name from a `-- @param` hint.