Documentation
¶
Overview ¶
Package oracle runs a real PostgreSQL (embedded-postgres) and answers "what does PG say about this statement?" via PREPARE / Describe.
It is the ground truth for differential tests of the pure-Go analyzer. It is not used at lint time.
Index ¶
- Variables
- func Release(v pgparse.Version) string
- type Column
- type Description
- type Oracle
- func (o *Oracle) Close() error
- func (o *Oracle) Conn() *pgx.Conn
- func (o *Oracle) ConnString() string
- func (o *Oracle) Describe(ctx context.Context, sql string) (*Description, error)
- func (o *Oracle) Reconnect(ctx context.Context, database string) error
- func (o *Oracle) Session(ctx context.Context, database string) (*Oracle, error)
- func (o *Oracle) Version() pgparse.Version
- type PgError
- type Source
- type Type
Constants ¶
This section is empty.
Variables ¶
var Version = binaries[pgparse.Default]
Version is the release the oracle runs for the default major version.
Functions ¶
Types ¶
type Column ¶
type Column struct {
Name string
Type Type
// Source is set when the column comes straight from a table column.
Source *Source
}
Column is one result column of a described statement.
type Description ¶
Description is PG's answer for one statement.
func (*Description) String ¶
func (d *Description) String() string
String renders a Description in the golden-file format used by differential tests.
type Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
Oracle owns one embedded PostgreSQL instance and one connection to it.
func Start ¶
Start boots a fresh PostgreSQL, applies schemaSQL, and returns a ready Oracle.
Booting is made cheap by a cache (see cacheDir): the binaries are extracted once, and the data directory is a copy of one initialized once, so a Start costs a directory copy and a server start rather than an archive extraction and an initdb (~0.3s instead of ~4s). Data lives in a temp dir removed by Close.
func StartVersion ¶ added in v1.2.0
StartVersion is Start on the PostgreSQL major version v.
func (*Oracle) Conn ¶
Conn exposes the underlying connection for tooling (catalog dump). Tests use Describe.
func (*Oracle) ConnString ¶
ConnString is the connection string of the running server (for pools and other clients).
func (*Oracle) Describe ¶
Describe prepares sql (anonymous statement, nothing persists server-side) and returns PG's parameter and result-column types. A statement PG rejects returns a *PgError.
func (*Oracle) Reconnect ¶
Reconnect closes the current connection and opens one to another database on the same server. Used by the regress probe, which isolates each test file in its own database created from a template.
type PgError ¶
type PgError struct {
Code string // SQLSTATE
Message string
Position int32 // 1-based byte offset into the SQL, 0 if none
}
PgError is the PostgreSQL error for a statement that fails to prepare.