compiler

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedStatementType = errors.New("parseQuery: unsupported statement type")

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
	DataType     string
	NotNull      bool
	IsArray      bool
	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
	// 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) *Compiler

func (*Compiler) Catalog

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

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
}

type Parameter

type Parameter struct {
	Number int
	Column *Column
}

type Parser

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

TODO: Rename this interface Engine

type Query

type Query struct {
	SQL      string
	Name     string
	Cmd      string // TODO: Pick a better name. One of: one, many, exec, execrows, copyFrom
	Columns  []*Column
	Params   []Parameter
	Comments []string

	// XXX: Hack
	Filename string

	// Needed for CopyFrom
	InsertIntoTable *ast.TableName
}

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