On this page
Package semtype implements the semantic type system for pgdesign, mapping user-defined enums, scalar domains, composite types, and state machines.
#internal/semtype
#internal/semtype
Package semtype implements the semantic type system for pgdesign, mapping user-defined enums, scalar domains, composite types, and state machines.
#KindScalar
const KindScalar Kind = iota#KindEnum
const KindEnum Kind = iota#KindComposite
const KindComposite Kind = iota#KindStateMachine
const KindStateMachine Kind = iota#Kind
type Kind intKind represents the kind of a type definition.
#CompositeField
type CompositeField structCompositeField represents a single field in a composite type.
#SMStateDef
type SMStateDef structSMStateDef represents a state in a state machine type definition.
#SMTransitionDef
type SMTransitionDef structSMTransitionDef represents a transition in a state machine type definition.
#TypeDef
type TypeDef structTypeDef defines a semantic type with its PostgreSQL mapping and constraints.
#Registry
type Registry structRegistry holds named TypeDefs with thread-safe read access.
#UserSMState
type UserSMState structUserSMState represents a state in a user-defined state machine type.
#UserSMTransition
type UserSMTransition structUserSMTransition represents a transition in a user-defined state machine type.
#UserTypeDef
type UserTypeDef structUserTypeDef represents a user-defined type loaded from configuration.
#ResolvedColumn
type ResolvedColumn structResolvedColumn represents the final resolved attributes for a column after applying type defaults and column-level overrides.
#NewBuiltinRegistry
func NewBuiltinRegistry() *RegistryNewBuiltinRegistry creates a Registry pre-populated with all builtin types.
#NewRegistry
func NewRegistry() *RegistryNewRegistry creates an empty Registry.
#Kind.String
func (k Kind) String() string#Registry.AddExtensionTypes
func (r *Registry) AddExtensionTypes(typeNames []string)AddExtensionTypes registers extension-provided type names as valid base types for scalar definitions. This allows extensions like pgvector to provide types (e.g., "vector") that pass the allowlist check without mutating global state.
#Registry.Register
func (r *Registry) Register(td *TypeDef) errorRegister adds a type definition to the registry. Decision tree: 1. Name not in registry: register normally. 2. Name exists + identical definition: accept silently (idempotent for multi-file schemas). 3. Name exists + different definition + existing is builtin: allow shadowing if sealed fields (Kind, BaseType.Base) match. Emits I101 on success, E114 on sealed field mismatch. 4. Name exists + different definition + existing is not builtin: E105 error.
#Registry.ShadowDiags
func (r *Registry) ShadowDiags() diagnostic.DiagnosticsShadowDiags returns diagnostics accumulated during Register() calls for builtin shadowing (I101 info, E114 errors). Call after LoadUserTypes().
#Registry.IsBuiltin
func (r *Registry) IsBuiltin(name string) boolIsBuiltin returns true if the named type exists in the registry with Source "builtin".
#Registry.BuiltinNames
func (r *Registry) BuiltinNames() []stringBuiltinNames returns the names of all registered builtin types (Source "builtin"), sorted for deterministic iteration. It lets generators and tooling draw column types from the real registry rather than a hardcoded copy that could silently drift when the builtin set changes.
#Registry.Resolve
func (r *Registry) Resolve(name string) (*TypeDef, error)Resolve looks up a type by name. Returns an error if the type is not found.
#Registry.StateMachineTypes
func (r *Registry) StateMachineTypes() []*TypeDefStateMachineTypes returns all registered state machine type definitions, sorted by name for deterministic output.
#Registry.LoadUserTypes
func (r *Registry) LoadUserTypes(types []UserTypeDef) diagnostic.DiagnosticsLoadUserTypes validates and registers user-defined types into the registry. Types with extends references are topologically sorted before processing so that parent types are always loaded before their children. Returns diagnostics for any validation failures.
#Registry.ResolveColumn
func (r *Registry) ResolveColumn(typeName string, nullable *bool, defaultOverride *string, defaultExprOverride *string, array *bool) (*ResolvedColumn, error)ResolveColumn resolves a column's final attributes by looking up the type and applying column-level overrides.