Documentation
¶
Overview ¶
Package catalog is the static PostgreSQL system catalog (pg_catalog objects) the analyzer resolves types, functions, operators and casts against.
The data is dumped from the oracle's PostgreSQL by ./gen and embedded as TSV. User schema (tables, enums, domains, views, functions) is layered on top at analysis time by a separate package.
Index ¶
- func Available(major int) []string
- func Majors() []int
- type Aggregate
- type Cast
- type Catalog
- func (c *Catalog) AggregateByFn(fn OID) *Aggregate
- func (c *Catalog) CastBetween(source, target OID) *Cast
- func (c *Catalog) FuncByOID(oid OID) *Func
- func (c *Catalog) FuncsByName(name string) []*Func
- func (c *Catalog) OperatorByOID(oid OID) *Operator
- func (c *Catalog) OperatorsByName(name string) []*Operator
- func (c *Catalog) RangeForSubtype(sub OID) *Range
- func (c *Catalog) RangeOf(rng OID) *Range
- func (c *Catalog) RangeOfMulti(multi OID) *Range
- func (c *Catalog) RelationByName(schema, name string) *Relation
- func (c *Catalog) TypeByName(name string) *Type
- func (c *Catalog) TypeByOID(oid OID) *Type
- func (c *Catalog) WithExtensions(names []string) (*Catalog, error)
- type Extension
- type Func
- type OID
- type Operator
- type Range
- type RelColumn
- type Relation
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Aggregate ¶
type Aggregate struct {
FnOID OID
Kind byte // n normal, o ordered-set, h hypothetical-set
NDirectArg int16
TransType OID
}
Aggregate is a row of pg_aggregate.
type Cast ¶
type Cast struct {
OID OID
Source OID
Target OID
Func OID // 0 for binary-coercible / I/O casts
Context byte // e explicit only, a assignment, i implicit
Method byte // f function, b binary coercible, i I/O conversion
}
Cast is a row of pg_cast.
type Catalog ¶
type Catalog struct {
// Major is the PostgreSQL major version the catalog was dumped from; Version the
// release ("17.5").
Major int
Version string
// Extensions are the extensions merged in (WithExtensions), in load order.
Extensions []*Extension
Types []Type
Funcs []Func
Operators []Operator
Casts []Cast
Aggregates []Aggregate
Ranges []Range
// Relations are the system tables and views (pg_catalog, information_schema, an
// extension's), with their columns.
Relations []Relation
// contains filtered or unexported fields
}
Catalog is the loaded bootstrap catalog with lookup indexes.
func Load ¶
Load returns the embedded bootstrap catalog of a PostgreSQL major version. Parsing happens once per process per version.
func (*Catalog) AggregateByFn ¶
AggregateByFn returns the pg_aggregate row for an aggregate function oid, or nil.
func (*Catalog) CastBetween ¶
CastBetween returns the pg_cast entry from source to target, or nil if none is declared. Callers must also handle the implicit cases pg_cast does not list (same type, domains, arrays, unknown).
func (*Catalog) FuncsByName ¶
FuncsByName returns all pg_catalog functions named name (overloads), in oid order.
func (*Catalog) OperatorByOID ¶
OperatorByOID returns the operator with the given oid, or nil.
func (*Catalog) OperatorsByName ¶
OperatorsByName returns all pg_catalog operators with the given symbol (e.g. "="), in oid order.
func (*Catalog) RangeForSubtype ¶
RangeForSubtype returns the (first) range type over subtype, or nil.
func (*Catalog) RangeOfMulti ¶
RangeOfMulti returns the pg_range entry whose multirange type is multi, or nil.
func (*Catalog) RelationByName ¶
RelationByName returns the system relation schema.name, or nil.
func (*Catalog) TypeByName ¶
TypeByName returns the pg_catalog type with the given typname (e.g. "int4", "_text"), or nil.
func (*Catalog) WithExtensions ¶
WithExtensions returns a new catalog: this one plus the named extensions. An extension another requested one already bundles is not loaded twice. Objects are renumbered into a per-extension OID range; the namespace they were created in is kept (Type.Schema etc.).
type Extension ¶
type Extension struct {
Name string
Version string
Schema string // the namespace its objects were created in
Requires []string // extensions the dump bundles
}
Extension describes one dumped extension.
type Func ¶
type Func struct {
OID OID
Name string
Kind byte // prokind: f function, a aggregate, w window, p procedure
RetType OID
RetSet bool
Variadic OID // element type of the variadic parameter, 0 if none
NArgs int16
NArgDefault int16
IsStrict bool
Volatile byte // i immutable, s stable, v volatile
ArgTypes []OID // input args (proargtypes)
AllArgTypes []OID // all args incl. OUT/TABLE, nil when same as ArgTypes
ArgModes []byte // i in, o out, b inout, v variadic, t table; nil when all in
ArgNames []string // nil when unnamed
// Schema is the namespace of an extension's function; "" for pg_catalog.
Schema string
}
Func is a row of pg_proc.
type OID ¶
type OID uint32
OID is a PostgreSQL object identifier.
const ( Bool OID = 16 Bytea OID = 17 Char OID = 18 Name OID = 19 Int8 OID = 20 Int2 OID = 21 Int4 OID = 23 Text OID = 25 OIDType OID = 26 RegProc OID = 24 Tid OID = 27 Aclitem OID = 1033 MacAddr8 OID = 774 Money OID = 790 RegProcedure OID = 2202 RegOper OID = 2203 RegOperator OID = 2204 RegClass OID = 2205 RegType OID = 2206 RegRole OID = 4096 RegNamespace OID = 4089 RegCollation OID = 4191 TxidSnapshot OID = 2970 PgSnapshot OID = 5038 Xid8 OID = 5069 Xid OID = 28 Cid OID = 29 JSON OID = 114 XML OID = 142 Float4 OID = 700 Float8 OID = 701 Unknown OID = 705 BPChar OID = 1042 Varchar OID = 1043 Date OID = 1082 Time OID = 1083 Timestamp OID = 1114 TimestampTZ OID = 1184 Interval OID = 1186 TimeTZ OID = 1266 Numeric OID = 1700 Record OID = 2249 Cstring OID = 2275 Any OID = 2276 AnyArray OID = 2277 Void OID = 2278 Trigger OID = 2279 AnyElement OID = 2283 AnyNonArray OID = 2776 AnyEnum OID = 3500 UUID OID = 2950 JSONB OID = 3802 JSONPath OID = 4072 TSVector OID = 3614 AnyRange OID = 3831 AnyCompatible OID = 5077 AnyCompatibleArray OID = 5078 AnyCompatibleNonArray OID = 5079 AnyCompatibleRange OID = 5080 AnyMultirange OID = 4537 AnyCompatibleMultirange OID = 4538 )
Well-known type OIDs (pg_type.h). Only the ones the analyzer needs by name.
Well-known OIDs of the vector types PG never coerces arrays into (find_coercion_pathway).
const FirstNormalObjectID OID = 16384
FirstNormalObjectID is where PG starts handing out OIDs for user objects.
type Operator ¶
type Operator struct {
OID OID
Name string
Kind byte // b binary, l prefix
Left OID // 0 for prefix operators
Right OID
Result OID
Code OID // implementing pg_proc oid
Com OID
Negate OID
CanMerge bool
CanHash bool
// Schema is the namespace of an extension's operator; "" for pg_catalog.
Schema string
}
Operator is a row of pg_operator.
type Relation ¶
type Relation struct {
OID OID
Name string
Kind byte // relkind: r table, v view
Schema string
Columns []RelColumn
}
Relation is a system table or view (pg_class + pg_attribute) the analyzer can resolve like a user table: pg_catalog's, information_schema's, or an extension's.
type Type ¶
type Type struct {
OID OID
Name string
Kind byte // typtype: b base, c composite, d domain, e enum, p pseudo, r range, m multirange
Category byte // typcategory (§10.1 categories: N numeric, S string, D datetime, ...)
IsPreferred bool
Len int16
ByVal bool
Elem OID // element type for arrays, 0 otherwise
Array OID // the array type over this type, 0 if none
RelID OID // composite: pg_class oid
BaseType OID // domain: underlying type
Typmod int32
// Schema is the namespace of an extension's type ("public" usually); "" for pg_catalog.
Schema string
}
Type is a row of pg_type.
func (*Type) IsArray ¶
IsArray reports whether t is a true array type: it has an element type and is a varlena (get_element_type). Fixed-length types with typelem (point, line, ...) are not.
func (*Type) IsPolymorphic ¶
IsPolymorphic reports whether t is one of the any* pseudo types (§38.2.5).
Directories
¶
| Path | Synopsis |
|---|---|
|
Command gen dumps the bootstrap catalog (pg_catalog objects) of the oracle's PostgreSQL into internal/catalog/data/<major>/*.tsv, and extension catalogs into internal/catalog/data/<major>/ext/<name>/.
|
Command gen dumps the bootstrap catalog (pg_catalog objects) of the oracle's PostgreSQL into internal/catalog/data/<major>/*.tsv, and extension catalogs into internal/catalog/data/<major>/ext/<name>/. |