Help us shape the future of Go! Take the 2026 Go Developer Survey

compiler

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTableName

func ParseTableName(node ast.Node) (*ast.TableName, error)

func ParseTypeName

func ParseTypeName(node ast.Node) (*ast.TypeName, error)

Types

type Column

type Column struct {
	Name         string
	OriginalName string
	DataType     string
	NotNull      bool
	Unsigned     bool
	IsArray      bool
	ArrayDims    int
	Comment      string
	Length       *int
	IsNamedParam bool
	IsFuncCall   bool

	// XXX: Figure out what PostgreSQL calls `foo.id`
	Scope      string
	Table      *ast.TableName
	TableAlias string
	Type       *ast.TypeName
	EmbedTable *ast.TableName

	// TypeExpr is the type as the analysis core wrote it, with the
	// arguments and nesting DataType and IsArray flatten away. It is unset
	// on the legacy path.
	TypeExpr *core.TypeExpr

	IsSqlcSlice bool // is this sqlc.slice()
	// contains filtered or unexported fields
}

func ConvertColumn

func ConvertColumn(rel *ast.TableName, c *catalog.Column) *Column

type Compiler

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

func NewCompiler

func NewCompiler(conf config.SQL, combo config.CombinedSettings, parserOpts opts.Parser, options ...Option) (*Compiler, error)

func (*Compiler) Catalog

func (c *Compiler) Catalog() *catalog.Catalog

func (*Compiler) Close

func (c *Compiler) Close(ctx context.Context)

func (*Compiler) OutputColumns

func (c *Compiler) OutputColumns(stmt ast.Node) ([]*catalog.Column, error)

OutputColumns determines which columns a statement will output

func (*Compiler) ParseCatalog

func (c *Compiler) ParseCatalog(schema []string) error

func (*Compiler) ParseQueries

func (c *Compiler) ParseQueries(queries []string, o opts.Parser) error

func (*Compiler) Result

func (c *Compiler) Result() *Result

type Function

type Function struct {
	Rel        *ast.FuncName
	ReturnType *ast.TypeName
	Outs       []*catalog.Argument
}

type Option

type Option func(*Compiler)

Option configures a Compiler.

func WithCoreAnalysis

func WithCoreAnalysis() Option

WithCoreAnalysis analyzes queries with the core catalog and analyzer rather than each engine's own analysis path. ClickHouse and GoogleSQL always do; this opts the remaining engines in.

type Parameter

type Parameter struct {
	Number int
	Column *Column
}

type Parser

type Parser interface {
	Parse(io.Reader) ([]ast.Statement, error)
	CommentSyntax() source.CommentSyntax
	IsReservedKeyword(string) bool
}

TODO: Rename this interface Engine

type Query

type Query struct {
	SQL      string
	Metadata metadata.Metadata
	Columns  []*Column
	Params   []Parameter

	// Needed for CopyFrom
	InsertIntoTable *ast.TableName

	// Needed for vet
	RawStmt *ast.RawStmt
}

type QueryCatalog

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

func (QueryCatalog) GetFunc

func (qc QueryCatalog) GetFunc(rel *ast.FuncName) (*Function, error)

func (QueryCatalog) GetTable

func (qc QueryCatalog) GetTable(rel *ast.TableName) (*Table, error)

type Relation

type Relation struct {
	Catalog string
	Schema  string
	Name    string
}

func ParseRelationString

func ParseRelationString(name string) (*Relation, error)

type Result

type Result struct {
	Catalog *catalog.Catalog
	Queries []*Query
}

type Table

type Table struct {
	Rel     *ast.TableName
	Columns []*Column
}

Jump to

Keyboard shortcuts

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