GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Why Go
  • Case Studies
  • Use Cases
  • Security
  • Learn
  • Effective Go
  • Go User Manual
  • Standard library
  • Release Notes
  • API
  • Packages
  • Recorded Talks
  • Meetups
  • Conferences

This view

  • Original page
  • New address

GeezerVison is showing pkg.go.dev — ast package - github.com/sqlc-dev/meyer/ast - Go Packages

Details

  • checked Valid go.mod file

    The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.

  • checked Redistributable license

    Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.

  • checked Tagged version

    Modules with tagged versions give importers more predictable builds.

  • unchecked Stable version

    When a project reaches major version v1 it is considered stable.

  • Learn more about best practices

Repository

github.com/sqlc-dev/meyer

Links

  • Open Source Insights Logo Open Source Insights

Documentation ¶

Overview ¶

Package ast declares the syntax tree for the SQLite SQL dialect.

Node names follow SQLite rather than PostgreSQL or sqlc: the tree is a direct rendering of src/parse.y, and every node carries a comment naming the grammar rule it comes from. Mapping onto another representation is a consumer's job.

Every node embeds Span and so reports byte offsets into the original input; sqlc slices the source with those offsets, so they are load-bearing rather than diagnostic (see PLAN.md).

Index ¶

  • func Statements(stmts []Stmt) string
  • func String(n Node) string
  • func Walk(n Node, fn func(Node) bool)
  • type AlterAction
    • func (a AlterAction) String() string
  • type AlterTableStmt
    • func (n *AlterTableStmt) Children() []Node
    • func (n *AlterTableStmt) String() string
  • type AnalyzeStmt
    • func (n *AnalyzeStmt) Children() []Node
  • type AttachStmt
    • func (n *AttachStmt) Children() []Node
  • type BeginStmt
    • func (n *BeginStmt) Children() []Node
  • type BetweenExpr
    • func (n *BetweenExpr) Children() []Node
  • type BinaryExpr
    • func (n *BinaryExpr) Children() []Node
  • type BindParam
    • func (n *BindParam) Children() []Node
  • type CTE
    • func (n *CTE) Children() []Node
  • type CaseExpr
    • func (n *CaseExpr) Children() []Node
  • type CaseWhen
    • func (n *CaseWhen) Children() []Node
  • type CastExpr
    • func (n *CastExpr) Children() []Node
  • type CollateExpr
    • func (n *CollateExpr) Children() []Node
  • type ColumnConstraint
    • func (n *ColumnConstraint) Children() []Node
  • type ColumnConstraintKind
    • func (k ColumnConstraintKind) String() string
  • type ColumnDef
    • func (n *ColumnDef) Children() []Node
  • type ColumnName
  • type CommitStmt
    • func (n *CommitStmt) Children() []Node
  • type CompoundOp
    • func (n *CompoundOp) Children() []Node
  • type ConflictAction
    • func (a ConflictAction) String() string
  • type CreateIndexStmt
    • func (n *CreateIndexStmt) Children() []Node
    • func (n *CreateIndexStmt) String() string
  • type CreateTableStmt
    • func (n *CreateTableStmt) Children() []Node
    • func (n *CreateTableStmt) String() string
  • type CreateTriggerStmt
    • func (n *CreateTriggerStmt) Children() []Node
    • func (n *CreateTriggerStmt) String() string
  • type CreateViewStmt
    • func (n *CreateViewStmt) Children() []Node
    • func (n *CreateViewStmt) String() string
  • type CreateVirtualTableStmt
    • func (n *CreateVirtualTableStmt) Children() []Node
    • func (n *CreateVirtualTableStmt) String() string
  • type DeferClause
    • func (n *DeferClause) Children() []Node
  • type DeleteStmt
    • func (n *DeleteStmt) Children() []Node
    • func (n *DeleteStmt) String() string
  • type DetachStmt
    • func (n *DetachStmt) Children() []Node
  • type Distinct
    • func (d Distinct) String() string
  • type DropIndexStmt
    • func (n *DropIndexStmt) Children() []Node
  • type DropTableStmt
    • func (n *DropTableStmt) Children() []Node
  • type DropTriggerStmt
    • func (n *DropTriggerStmt) Children() []Node
  • type DropViewStmt
    • func (n *DropViewStmt) Children() []Node
  • type ExistsExpr
    • func (n *ExistsExpr) Children() []Node
  • type ExplainStmt
    • func (n *ExplainStmt) Children() []Node
    • func (n *ExplainStmt) String() string
  • type Expr
  • type ForeignKeyAction
    • func (a ForeignKeyAction) String() string
  • type ForeignKeyArg
    • func (n *ForeignKeyArg) Children() []Node
  • type ForeignKeyClause
    • func (n *ForeignKeyClause) Children() []Node
  • type FrameBound
    • func (n *FrameBound) Children() []Node
  • type FrameBoundType
    • func (b FrameBoundType) String() string
  • type FrameExclude
    • func (e FrameExclude) String() string
  • type FrameType
    • func (f FrameType) String() string
  • type FuncCall
    • func (n *FuncCall) Children() []Node
  • type Ident
    • func (n *Ident) Children() []Node
  • type InExpr
    • func (n *InExpr) Children() []Node
  • type IndexedColumn
    • func (n *IndexedColumn) Children() []Node
  • type InsertStmt
    • func (n *InsertStmt) Children() []Node
    • func (n *InsertStmt) String() string
  • type IsExpr
    • func (n *IsExpr) Children() []Node
  • type JoinOperator
    • func (n *JoinOperator) Children() []Node
  • type JoinType
    • func (t JoinType) String() string
  • type LikeExpr
    • func (n *LikeExpr) Children() []Node
  • type Limit
    • func (n *Limit) Children() []Node
  • type Literal
    • func (n *Literal) Children() []Node
  • type LiteralKind
    • func (k LiteralKind) String() string
  • type Materialized
    • func (m Materialized) String() string
  • type Node
  • type NullCheckExpr
    • func (n *NullCheckExpr) Children() []Node
  • type NullTest
    • func (t NullTest) String() string
  • type NullsOrder
    • func (o NullsOrder) String() string
  • type Operator
    • func (o Operator) String() string
  • type OrderingTerm
    • func (n *OrderingTerm) Children() []Node
  • type ParamKind
    • func (k ParamKind) String() string
  • type ParenExpr
    • func (n *ParenExpr) Children() []Node
  • type PragmaStmt
    • func (n *PragmaStmt) Children() []Node
  • type QualifiedName
    • func (n *QualifiedName) Children() []Node
  • type QualifiedRef
    • func (n *QualifiedRef) Children() []Node
  • type QuoteStyle
    • func (q QuoteStyle) String() string
  • type RaiseExpr
    • func (n *RaiseExpr) Children() []Node
  • type ReindexStmt
    • func (n *ReindexStmt) Children() []Node
  • type ReleaseStmt
    • func (n *ReleaseStmt) Children() []Node
  • type ResultColumn
    • func (n *ResultColumn) Children() []Node
  • type RollbackStmt
    • func (n *RollbackStmt) Children() []Node
  • type SavepointStmt
    • func (n *SavepointStmt) Children() []Node
  • type SelectCore
  • type SelectQuery
    • func (n *SelectQuery) Children() []Node
  • type SelectStmt
    • func (n *SelectStmt) Children() []Node
    • func (n *SelectStmt) String() string
  • type SetPair
    • func (n *SetPair) Children() []Node
  • type SortOrder
    • func (o SortOrder) String() string
  • type Span
    • func (s Span) End() int
    • func (s Span) Pos() int
    • func (s *Span) SetSpan(sp Span)
  • type Star
    • func (n *Star) Children() []Node
  • type Stmt
  • type SubqueryExpr
    • func (n *SubqueryExpr) Children() []Node
  • type TableConstraint
    • func (n *TableConstraint) Children() []Node
  • type TableConstraintKind
    • func (k TableConstraintKind) String() string
  • type TableOption
    • func (n *TableOption) Children() []Node
  • type TableRef
    • func (n *TableRef) Children() []Node
  • type TransactionType
    • func (t TransactionType) String() string
  • type TriggerTime
    • func (t TriggerTime) String() string
  • type TypeName
    • func (n *TypeName) Children() []Node
  • type UnaryExpr
    • func (n *UnaryExpr) Children() []Node
  • type UpdateStmt
    • func (n *UpdateStmt) Children() []Node
    • func (n *UpdateStmt) String() string
  • type Upsert
    • func (n *Upsert) Children() []Node
  • type VacuumStmt
    • func (n *VacuumStmt) Children() []Node
  • type ValuesClause
    • func (n *ValuesClause) Children() []Node
  • type VectorExpr
    • func (n *VectorExpr) Children() []Node
  • type WindowDef
    • func (n *WindowDef) Children() []Node
  • type With
    • func (n *With) Children() []Node

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func Statements ¶

func Statements(stmts []Stmt) string

Statements renders a whole script, one statement per line.

func String ¶

func String(n Node) string

String renders n as SQL.

func Walk ¶

func Walk(n Node, fn func(Node) bool)

Walk calls fn for n and, unless fn returns false, for its descendants in source order.

Types ¶

type AlterAction ¶

type AlterAction int

AlterAction enumerates the ALTER TABLE forms of the pinned build.

const (
	AlterRenameTable AlterAction = iota
	AlterRenameColumn
	AlterAddColumn
	AlterDropColumn
	AlterDropConstraint
	AlterDropNotNull
	AlterSetNotNull
	AlterAddConstraintCheck
)

func (AlterAction) String ¶

func (a AlterAction) String() string

type AlterTableStmt ¶

type AlterTableStmt struct {
	Span
	Table          *QualifiedName `json:"table"`
	Action         AlterAction    `json:"action"`
	ColumnKeyword  bool           `json:"columnKeyword,omitempty"`
	Column         *Ident         `json:"column,omitempty"`
	NewName        *Ident         `json:"newName,omitempty"`
	ConstraintName *Ident         `json:"constraintName,omitempty"`
	ColumnDef      *ColumnDef     `json:"columnDef,omitempty"`
	Expr           Expr           `json:"expr,omitempty"`
	OnConflict     ConflictAction `json:"onConflict,omitempty"`
}

AlterTableStmt is ALTER TABLE in all the forms the pinned build accepts.

cmd ::= ALTER TABLE fullname RENAME TO nm.
cmd ::= alter_add carglist. (ALTER TABLE ... ADD [COLUMN] nm typetoken)
cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm.
cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm.
cmd ::= ALTER TABLE fullname DROP CONSTRAINT nm.
cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm DROP NOT NULL.
cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm SET NOT NULL onconf.
cmd ::= ALTER TABLE fullname ADD [CONSTRAINT nm] CHECK LP expr RP onconf.

func (*AlterTableStmt) Children ¶

func (n *AlterTableStmt) Children() []Node

func (*AlterTableStmt) String ¶

func (n *AlterTableStmt) String() string

type AnalyzeStmt ¶

type AnalyzeStmt struct {
	Span
	Name *QualifiedName `json:"name,omitempty"`
}

AnalyzeStmt is ANALYZE [name [. name]].

cmd ::= ANALYZE. / cmd ::= ANALYZE nm dbnm.

func (*AnalyzeStmt) Children ¶

func (n *AnalyzeStmt) Children() []Node

type AttachStmt ¶

type AttachStmt struct {
	Span
	HasDatabase bool `json:"hasDatabase,omitempty"`
	File        Expr `json:"file"`
	Name        Expr `json:"name"`
	Key         Expr `json:"key,omitempty"`
}

AttachStmt is ATTACH [DATABASE] expr AS expr [KEY expr].

cmd ::= ATTACH database_kw_opt expr AS expr key_opt.

func (*AttachStmt) Children ¶

func (n *AttachStmt) Children() []Node

type BeginStmt ¶

type BeginStmt struct {
	Span
	Type TransactionType `json:"type,omitempty"`
	// HasType and HasTransaction record keywords that carry no meaning but
	// are part of the source: "trans_opt ::= TRANSACTION" has no name, so
	// Name alone cannot say whether the keyword was written.
	HasType        bool   `json:"hasType,omitempty"`
	HasTransaction bool   `json:"hasTransaction,omitempty"`
	Name           *Ident `json:"name,omitempty"`
}

BeginStmt is BEGIN [DEFERRED|IMMEDIATE|EXCLUSIVE] [TRANSACTION [name]].

cmd ::= BEGIN transtype trans_opt.

func (*BeginStmt) Children ¶

func (n *BeginStmt) Children() []Node

type BetweenExpr ¶

type BetweenExpr struct {
	Span
	Not bool `json:"not"`
	X   Expr `json:"x"`
	Lo  Expr `json:"lo"`
	Hi  Expr `json:"hi"`
}

BetweenExpr is "x BETWEEN lo AND hi", optionally negated.

expr ::= expr between_op expr AND expr.

func (*BetweenExpr) Children ¶

func (n *BetweenExpr) Children() []Node

type BinaryExpr ¶

type BinaryExpr struct {
	Span
	Op Operator `json:"op"`
	X  Expr     `json:"x"`
	Y  Expr     `json:"y"`
}

BinaryExpr is an infix operator application.

expr ::= expr AND expr. and the other %left/%right operator rules.

func (*BinaryExpr) Children ¶

func (n *BinaryExpr) Children() []Node

type BindParam ¶

type BindParam struct {
	Span
	Kind   ParamKind `json:"kind"`
	Number int       `json:"number"`
	Name   string    `json:"name,omitempty"` // without the sigil
	Raw    string    `json:"raw"`
}

BindParam is a parameter marker. Number is assigned the way sqlite3ExprAssignVarNumber does: explicit for ?NNN, otherwise one past the highest number used so far.

expr ::= VARIABLE.

func (*BindParam) Children ¶

func (n *BindParam) Children() []Node

type CTE ¶

type CTE struct {
	Span
	Name         *Ident       `json:"name"`
	Columns      []*Ident     `json:"columns,omitempty"`
	Materialized Materialized `json:"materialized,omitempty"`
	Select       *SelectStmt  `json:"select"`
}

CTE is one common table expression.

wqitem ::= withnm eidlist_opt wqas LP select RP.

func (*CTE) Children ¶

func (n *CTE) Children() []Node

type CaseExpr ¶

type CaseExpr struct {
	Span
	Operand Expr        `json:"operand,omitempty"`
	Whens   []*CaseWhen `json:"whens"`
	Else    Expr        `json:"else,omitempty"`
}

CaseExpr is a CASE expression. Operand is nil for the searched form.

expr ::= CASE case_operand case_exprlist case_else END.

func (*CaseExpr) Children ¶

func (n *CaseExpr) Children() []Node

type CaseWhen ¶

type CaseWhen struct {
	Span
	When Expr `json:"when"`
	Then Expr `json:"then"`
}

CaseWhen is one WHEN/THEN pair.

case_exprlist ::= case_exprlist WHEN expr THEN expr.

func (*CaseWhen) Children ¶

func (n *CaseWhen) Children() []Node

type CastExpr ¶

type CastExpr struct {
	Span
	X    Expr      `json:"x"`
	Type *TypeName `json:"type"`
}

CastExpr is "CAST(expr AS type)".

expr ::= CAST LP expr AS typetoken RP.

func (*CastExpr) Children ¶

func (n *CastExpr) Children() []Node

type CollateExpr ¶

type CollateExpr struct {
	Span
	X    Expr   `json:"x"`
	Name *Ident `json:"name"`
}

CollateExpr is "expr COLLATE name".

expr ::= expr COLLATE ids.

func (*CollateExpr) Children ¶

func (n *CollateExpr) Children() []Node

type ColumnConstraint ¶

type ColumnConstraint struct {
	Span
	Name          *Ident               `json:"name,omitempty"`
	Kind          ColumnConstraintKind `json:"kind"`
	OnConflict    ConflictAction       `json:"onConflict,omitempty"`
	Order         SortOrder            `json:"order,omitempty"` // PRIMARY KEY ASC/DESC
	AutoIncrement bool                 `json:"autoIncrement,omitempty"`
	Expr          Expr                 `json:"expr,omitempty"` // CHECK, DEFAULT, GENERATED
	Collation     *Ident               `json:"collation,omitempty"`
	References    *ForeignKeyClause    `json:"references,omitempty"`
	GeneratedKind *Ident               `json:"generatedKind,omitempty"` // STORED / VIRTUAL
	AlwaysWord    bool                 `json:"alwaysWord,omitempty"`    // GENERATED ALWAYS spelling
	Deferrable    *DeferClause         `json:"deferrable,omitempty"`
}

ColumnConstraint is one column constraint. Name is the preceding CONSTRAINT clause, if any; SQLite attaches it to the constraint that follows.

ccons ::= CONSTRAINT nm. / NULL onconf. / NOT NULL onconf.
ccons ::= PRIMARY KEY sortorder onconf autoinc. / UNIQUE onconf.
ccons ::= CHECK LP expr RP. / DEFAULT .... / COLLATE ids.
ccons ::= REFERENCES nm eidlist_opt refargs. / defer_subclause.
ccons ::= [GENERATED ALWAYS] AS generated.

func (*ColumnConstraint) Children ¶

func (n *ColumnConstraint) Children() []Node

type ColumnConstraintKind ¶

type ColumnConstraintKind int

ColumnConstraintKind enumerates the "ccons" alternatives.

const (
	ColumnNull ColumnConstraintKind = iota
	ColumnNotNull
	ColumnPrimaryKey
	ColumnUnique
	ColumnCheck
	ColumnDefault
	ColumnCollate
	ColumnReferences
	ColumnGenerated
	ColumnDeferrable // a bare [NOT] DEFERRABLE clause
)

func (ColumnConstraintKind) String ¶

func (k ColumnConstraintKind) String() string

type ColumnDef ¶

type ColumnDef struct {
	Span
	Name        *ColumnName         `json:"name"`
	Type        *TypeName           `json:"type,omitempty"`
	Constraints []*ColumnConstraint `json:"constraints,omitempty"`
}

ColumnDef is one column of a CREATE TABLE (or of ALTER TABLE ADD COLUMN).

columnname ::= nm typetoken. / carglist ::= carglist ccons.

func (*ColumnDef) Children ¶

func (n *ColumnDef) Children() []Node

type ColumnName ¶

type ColumnName = Ident

ColumnName wraps the identifier naming a column, so that a ColumnDef's name keeps its own span distinct from the whole definition's.

type CommitStmt ¶

type CommitStmt struct {
	Span
	Keyword        string `json:"keyword"` // "COMMIT" or "END"
	HasTransaction bool   `json:"hasTransaction,omitempty"`
	Name           *Ident `json:"name,omitempty"`
}

CommitStmt is COMMIT or END, optionally followed by TRANSACTION [name].

cmd ::= COMMIT|END trans_opt.

func (*CommitStmt) Children ¶

func (n *CommitStmt) Children() []Node

type CompoundOp ¶

type CompoundOp struct {
	Span
	Op  string `json:"op"` // "UNION", "EXCEPT", "INTERSECT"
	All bool   `json:"all"`
}

CompoundOp is UNION, UNION ALL, EXCEPT or INTERSECT.

multiselect_op ::= UNION. / UNION ALL. / EXCEPT|INTERSECT.

func (*CompoundOp) Children ¶

func (n *CompoundOp) Children() []Node

type ConflictAction ¶

type ConflictAction int

ConflictAction is the conflict-resolution algorithm of an ON CONFLICT or OR clause.

const (
	ConflictDefault ConflictAction = iota
	ConflictRollback
	ConflictAbort
	ConflictFail
	ConflictIgnore
	ConflictReplace
)

func (ConflictAction) String ¶

func (a ConflictAction) String() string

type CreateIndexStmt ¶

type CreateIndexStmt struct {
	Span
	Unique      bool            `json:"unique,omitempty"`
	IfNotExists bool            `json:"ifNotExists,omitempty"`
	Name        *QualifiedName  `json:"name"`
	Table       *Ident          `json:"table"`
	Columns     []*OrderingTerm `json:"columns"`
	Where       Expr            `json:"where,omitempty"`
}

CreateIndexStmt is CREATE [UNIQUE] INDEX.

cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP
        where_opt.

func (*CreateIndexStmt) Children ¶

func (n *CreateIndexStmt) Children() []Node

func (*CreateIndexStmt) String ¶

func (n *CreateIndexStmt) String() string

type CreateTableStmt ¶

type CreateTableStmt struct {
	Span
	Temp        bool               `json:"temp,omitempty"`
	IfNotExists bool               `json:"ifNotExists,omitempty"`
	Name        *QualifiedName     `json:"name"`
	Columns     []*ColumnDef       `json:"columns,omitempty"`
	Constraints []*TableConstraint `json:"constraints,omitempty"`
	Options     []*TableOption     `json:"options,omitempty"` // WITHOUT ROWID, STRICT
	Select      *SelectStmt        `json:"select,omitempty"`
}

CreateTableStmt is CREATE TABLE, in both the column-list and the AS SELECT forms.

cmd ::= create_table create_table_args.
create_table ::= createkw temp TABLE ifnotexists nm dbnm.
create_table_args ::= LP columnlist conslist_opt RP table_option_set.
create_table_args ::= AS select.

func (*CreateTableStmt) Children ¶

func (n *CreateTableStmt) Children() []Node

func (*CreateTableStmt) String ¶

func (n *CreateTableStmt) String() string

type CreateTriggerStmt ¶

type CreateTriggerStmt struct {
	Span
	Temp        bool           `json:"temp,omitempty"`
	IfNotExists bool           `json:"ifNotExists,omitempty"`
	Name        *QualifiedName `json:"name"`
	Time        TriggerTime    `json:"time,omitempty"`
	HasTime     bool           `json:"hasTime,omitempty"`
	Event       string         `json:"event"` // DELETE, INSERT, UPDATE
	UpdateOf    []*Ident       `json:"updateOf,omitempty"`
	Table       *QualifiedName `json:"table"`
	ForEachRow  bool           `json:"forEachRow,omitempty"`
	When        Expr           `json:"when,omitempty"`
	Body        []Stmt         `json:"body"`
}

CreateTriggerStmt is CREATE [TEMP] TRIGGER.

cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END.
trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time
                 trigger_event ON fullname foreach_clause when_clause.

func (*CreateTriggerStmt) Children ¶

func (n *CreateTriggerStmt) Children() []Node

func (*CreateTriggerStmt) String ¶

func (n *CreateTriggerStmt) String() string

type CreateViewStmt ¶

type CreateViewStmt struct {
	Span
	Temp        bool             `json:"temp,omitempty"`
	IfNotExists bool             `json:"ifNotExists,omitempty"`
	Name        *QualifiedName   `json:"name"`
	Columns     []*IndexedColumn `json:"columns,omitempty"`
	Select      *SelectStmt      `json:"select"`
}

CreateViewStmt is CREATE [TEMP] VIEW.

cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select.

func (*CreateViewStmt) Children ¶

func (n *CreateViewStmt) Children() []Node

func (*CreateViewStmt) String ¶

func (n *CreateViewStmt) String() string

type CreateVirtualTableStmt ¶

type CreateVirtualTableStmt struct {
	Span
	IfNotExists bool           `json:"ifNotExists,omitempty"`
	Name        *QualifiedName `json:"name"`
	Module      *Ident         `json:"module"`
	HasArgs     bool           `json:"hasArgs,omitempty"`
	Args        []string       `json:"args,omitempty"`
}

CreateVirtualTableStmt is CREATE VIRTUAL TABLE ... USING module(args). Module arguments are kept as their raw source text, exactly as SQLite does (the "anylist" production accepts any balanced token sequence).

create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm.
cmd ::= create_vtab LP vtabarglist RP.

func (*CreateVirtualTableStmt) Children ¶

func (n *CreateVirtualTableStmt) Children() []Node

func (*CreateVirtualTableStmt) String ¶

func (n *CreateVirtualTableStmt) String() string

type DeferClause ¶

type DeferClause struct {
	Span
	Not               bool `json:"not,omitempty"`
	InitiallyDeferred bool `json:"initiallyDeferred,omitempty"`
	HasInitially      bool `json:"hasInitially,omitempty"`
}

DeferClause is "[NOT] DEFERRABLE [INITIALLY DEFERRED|IMMEDIATE]".

defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt.
defer_subclause ::= DEFERRABLE init_deferred_pred_opt.

func (*DeferClause) Children ¶

func (n *DeferClause) Children() []Node

type DeleteStmt ¶

type DeleteStmt struct {
	Span
	With       *With           `json:"with,omitempty"`
	Table      *QualifiedName  `json:"table"`
	Alias      *Ident          `json:"alias,omitempty"`
	IndexedBy  *Ident          `json:"indexedBy,omitempty"`
	NotIndexed bool            `json:"notIndexed,omitempty"`
	Where      Expr            `json:"where,omitempty"`
	Returning  []*ResultColumn `json:"returning,omitempty"`
	OrderBy    []*OrderingTerm `json:"orderBy,omitempty"`
	Limit      *Limit          `json:"limit,omitempty"`
}

DeleteStmt is a DELETE statement.

cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret.
cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret orderby_opt
        limit_opt.

As for UPDATE, the second form is the one SQLITE_ENABLE_UPDATE_DELETE_LIMIT compiles in, and OrderBy and Limit are set only for a parse made with parser.Options.UpdateDeleteLimit.

func (*DeleteStmt) Children ¶

func (n *DeleteStmt) Children() []Node

func (*DeleteStmt) String ¶

func (n *DeleteStmt) String() string

type DetachStmt ¶

type DetachStmt struct {
	Span
	HasDatabase bool `json:"hasDatabase,omitempty"`
	Name        Expr `json:"name"`
}

DetachStmt is DETACH [DATABASE] expr.

cmd ::= DETACH database_kw_opt expr.

func (*DetachStmt) Children ¶

func (n *DetachStmt) Children() []Node

type Distinct ¶

type Distinct int

Distinct records the DISTINCT/ALL qualifier of a SELECT.

const (
	DistinctNone Distinct = iota
	DistinctDistinct
	DistinctAll
)

func (Distinct) String ¶

func (d Distinct) String() string

type DropIndexStmt ¶

type DropIndexStmt struct {
	Span
	IfExists bool           `json:"ifExists,omitempty"`
	Name     *QualifiedName `json:"name"`
}

DropIndexStmt is DROP INDEX.

cmd ::= DROP INDEX ifexists fullname.

func (*DropIndexStmt) Children ¶

func (n *DropIndexStmt) Children() []Node

type DropTableStmt ¶

type DropTableStmt struct {
	Span
	IfExists bool           `json:"ifExists,omitempty"`
	Name     *QualifiedName `json:"name"`
}

DropTableStmt is DROP TABLE.

cmd ::= DROP TABLE ifexists fullname.

func (*DropTableStmt) Children ¶

func (n *DropTableStmt) Children() []Node

type DropTriggerStmt ¶

type DropTriggerStmt struct {
	Span
	IfExists bool           `json:"ifExists,omitempty"`
	Name     *QualifiedName `json:"name"`
}

DropTriggerStmt is DROP TRIGGER.

cmd ::= DROP TRIGGER ifexists fullname.

func (*DropTriggerStmt) Children ¶

func (n *DropTriggerStmt) Children() []Node

type DropViewStmt ¶

type DropViewStmt struct {
	Span
	IfExists bool           `json:"ifExists,omitempty"`
	Name     *QualifiedName `json:"name"`
}

DropViewStmt is DROP VIEW.

cmd ::= DROP VIEW ifexists fullname.

func (*DropViewStmt) Children ¶

func (n *DropViewStmt) Children() []Node

type ExistsExpr ¶

type ExistsExpr struct {
	Span
	Select *SelectStmt `json:"select"`
}

ExistsExpr is "EXISTS (select)".

expr ::= EXISTS LP select RP.

func (*ExistsExpr) Children ¶

func (n *ExistsExpr) Children() []Node

type ExplainStmt ¶

type ExplainStmt struct {
	Span
	QueryPlan bool `json:"queryPlan,omitempty"`
	Stmt      Stmt `json:"stmt"`
}

ExplainStmt wraps another statement in EXPLAIN or EXPLAIN QUERY PLAN.

ecmd ::= explain cmdx SEMI.
explain ::= EXPLAIN. / explain ::= EXPLAIN QUERY PLAN.

func (*ExplainStmt) Children ¶

func (n *ExplainStmt) Children() []Node

func (*ExplainStmt) String ¶

func (n *ExplainStmt) String() string

type Expr ¶

type Expr interface {
	Node
	// contains filtered or unexported methods
}

Expr is implemented by all expression nodes.

type ForeignKeyAction ¶

type ForeignKeyAction int

ForeignKeyAction is the action of an ON DELETE / ON UPDATE clause.

const (
	FKNoAction ForeignKeyAction = iota
	FKSetNull
	FKSetDefault
	FKCascade
	FKRestrict
)

func (ForeignKeyAction) String ¶

func (a ForeignKeyAction) String() string

type ForeignKeyArg ¶

type ForeignKeyArg struct {
	Span
	Match  *Ident           `json:"match,omitempty"`
	Event  string           `json:"event,omitempty"` // INSERT, DELETE, UPDATE
	Action ForeignKeyAction `json:"action,omitempty"`
}

ForeignKeyArg is one refarg: a MATCH clause or an ON <event> action.

func (*ForeignKeyArg) Children ¶

func (n *ForeignKeyArg) Children() []Node

type ForeignKeyClause ¶

type ForeignKeyClause struct {
	Span
	Table   *Ident           `json:"table"`
	Columns []*IndexedColumn `json:"columns,omitempty"`
	Args    []*ForeignKeyArg `json:"args,omitempty"`
}

ForeignKeyClause is a REFERENCES clause and its arguments.

ccons ::= REFERENCES nm eidlist_opt refargs.
refarg ::= MATCH nm. / ON INSERT refact. / ON DELETE refact. / ON UPDATE refact.

func (*ForeignKeyClause) Children ¶

func (n *ForeignKeyClause) Children() []Node

type FrameBound ¶

type FrameBound struct {
	Span
	Type FrameBoundType `json:"type"`
	Expr Expr           `json:"expr,omitempty"`
}

FrameBound is one endpoint of a window frame.

frame_bound ::= expr PRECEDING|FOLLOWING. / CURRENT ROW.
frame_bound_s ::= UNBOUNDED PRECEDING. / frame_bound_e ::= UNBOUNDED FOLLOWING.

func (*FrameBound) Children ¶

func (n *FrameBound) Children() []Node

type FrameBoundType ¶

type FrameBoundType int

FrameBoundType enumerates the window frame endpoints.

const (
	BoundUnboundedPreceding FrameBoundType = iota
	BoundPreceding
	BoundCurrentRow
	BoundFollowing
	BoundUnboundedFollowing
)

func (FrameBoundType) String ¶

func (b FrameBoundType) String() string

type FrameExclude ¶

type FrameExclude int

FrameExclude is the EXCLUDE clause of a frame specification.

const (
	ExcludeNone FrameExclude = iota
	ExcludeNoOthers
	ExcludeCurrentRow
	ExcludeGroup
	ExcludeTies
)

func (FrameExclude) String ¶

func (e FrameExclude) String() string

type FrameType ¶

type FrameType int

FrameType is RANGE, ROWS or GROUPS.

const (
	FrameNone FrameType = iota
	FrameRange
	FrameRows
	FrameGroups
)

func (FrameType) String ¶

func (f FrameType) String() string

type FuncCall ¶

type FuncCall struct {
	Span
	Name     *Ident          `json:"name"`
	Distinct bool            `json:"distinct"`
	All      bool            `json:"all"` // the redundant ALL qualifier
	Star     bool            `json:"star"`
	Args     []Expr          `json:"args,omitempty"`
	OrderBy  []*OrderingTerm `json:"orderBy,omitempty"` // aggregate inner ORDER BY
	Filter   Expr            `json:"filter,omitempty"`  // FILTER (WHERE ...)
	Over     *WindowDef      `json:"over,omitempty"`
}

FuncCall is a function invocation, including aggregate and window forms.

expr ::= idj LP distinct exprlist RP [filter_over].
expr ::= idj LP distinct exprlist ORDER BY sortlist RP [filter_over].
expr ::= idj LP STAR RP [filter_over].

func (*FuncCall) Children ¶

func (n *FuncCall) Children() []Node

type Ident ¶

type Ident struct {
	Span
	Name  string     `json:"name"`  // dequoted
	Raw   string     `json:"raw"`   // exactly as it appeared
	Quote QuoteStyle `json:"quote"` // QuoteNone when unquoted
}

Ident is a name: a table, column, function, alias, collation, ...

nm ::= idj. / nm ::= STRING.

func (*Ident) Children ¶

func (n *Ident) Children() []Node

type InExpr ¶

type InExpr struct {
	Span
	Not     bool           `json:"not"`
	X       Expr           `json:"x"`
	Parens  bool           `json:"parens"`
	List    []Expr         `json:"list,omitempty"`
	Select  *SelectStmt    `json:"select,omitempty"`
	Table   *QualifiedName `json:"table,omitempty"`
	Args    []Expr         `json:"args,omitempty"` // table-valued function args
	HasArgs bool           `json:"hasArgs,omitempty"`
}

InExpr is "x IN ...". Exactly one of List, Select and Table is set; an empty parenthesised list leaves all three unset with Parens true.

expr ::= expr in_op LP exprlist RP.
expr ::= expr in_op LP select RP.
expr ::= expr in_op nm dbnm paren_exprlist.

func (*InExpr) Children ¶

func (n *InExpr) Children() []Node

type IndexedColumn ¶

type IndexedColumn struct {
	Span
	Name      *Ident    `json:"name"`
	Collation *Ident    `json:"collation,omitempty"`
	Order     SortOrder `json:"order,omitempty"`
}

IndexedColumn is one entry of an "eidlist": a column name with the COLLATE and ASC/DESC decorations SQLite still parses for historical schemas.

eidlist ::= eidlist COMMA nm collate sortorder.

func (*IndexedColumn) Children ¶

func (n *IndexedColumn) Children() []Node

type InsertStmt ¶

type InsertStmt struct {
	Span
	With          *With           `json:"with,omitempty"`
	Replace       bool            `json:"replace,omitempty"` // spelled REPLACE
	OrConflict    ConflictAction  `json:"orConflict,omitempty"`
	Table         *QualifiedName  `json:"table"`
	Alias         *Ident          `json:"alias,omitempty"`
	Columns       []*Ident        `json:"columns,omitempty"`
	Select        *SelectStmt     `json:"select,omitempty"`
	DefaultValues bool            `json:"defaultValues,omitempty"`
	Upserts       []*Upsert       `json:"upserts,omitempty"`
	Returning     []*ResultColumn `json:"returning,omitempty"`
}

InsertStmt is INSERT, INSERT OR <action>, or REPLACE.

cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert.
cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning.

func (*InsertStmt) Children ¶

func (n *InsertStmt) Children() []Node

func (*InsertStmt) String ¶

func (n *InsertStmt) String() string

type IsExpr ¶

type IsExpr struct {
	Span
	Not      bool `json:"not"`
	Distinct bool `json:"distinct"` // the DISTINCT FROM spelling was used
	X        Expr `json:"x"`
	Y        Expr `json:"y"`
}

IsExpr is "IS", "IS NOT", "IS DISTINCT FROM" or "IS NOT DISTINCT FROM".

expr ::= expr IS expr. and its three siblings.

func (*IsExpr) Children ¶

func (n *IsExpr) Children() []Node

type JoinOperator ¶

type JoinOperator struct {
	Span
	Type  JoinType `json:"type"`
	Words []string `json:"words,omitempty"` // the keywords as written
}

JoinOperator is the operator attaching a FROM item to the one before it.

joinop ::= COMMA|JOIN. / JOIN_KW JOIN. / JOIN_KW nm JOIN.
joinop ::= JOIN_KW nm nm JOIN.

func (*JoinOperator) Children ¶

func (n *JoinOperator) Children() []Node

type JoinType ¶

type JoinType int

JoinType is the bitmask of join keywords, matching sqlite3JoinType.

const (
	JoinInner JoinType = 1 << iota
	JoinCross
	JoinNatural
	JoinLeft
	JoinRight
	JoinOuter
	JoinComma // the item was separated by "," rather than a JOIN keyword
)

func (JoinType) String ¶

func (t JoinType) String() string

String spells a join out the way sqlite3JoinType's bitmask reads.

type LikeExpr ¶

type LikeExpr struct {
	Span
	Op     *Ident `json:"op"` // the LIKE/GLOB/REGEXP/MATCH token, as written
	Not    bool   `json:"not"`
	X      Expr   `json:"x"`
	Y      Expr   `json:"y"`
	Escape Expr   `json:"escape,omitempty"`
}

LikeExpr is a LIKE/GLOB/REGEXP/MATCH application, optionally negated and optionally with an ESCAPE operand.

expr ::= expr likeop expr. / expr ::= expr likeop expr ESCAPE expr.

func (*LikeExpr) Children ¶

func (n *LikeExpr) Children() []Node

type Limit ¶

type Limit struct {
	Span
	Count  Expr `json:"count"`
	Offset Expr `json:"offset,omitempty"`
	Comma  bool `json:"comma,omitempty"`
}

Limit is a LIMIT clause. In the "LIMIT x, y" spelling SQLite swaps the operands, so Count is y and Offset is x; Comma records the spelling.

limit_opt ::= LIMIT expr. / LIMIT expr OFFSET expr. / LIMIT expr COMMA expr.

func (*Limit) Children ¶

func (n *Limit) Children() []Node

type Literal ¶

type Literal struct {
	Span
	Kind  LiteralKind `json:"kind"`
	Value string      `json:"value"` // dequoted for strings, raw otherwise
	Raw   string      `json:"raw"`
}

Literal is a constant.

term ::= NULL|FLOAT|BLOB. / term ::= STRING. / term ::= INTEGER.
term ::= QNUMBER. / term ::= CTIME_KW.

func (*Literal) Children ¶

func (n *Literal) Children() []Node

type LiteralKind ¶

type LiteralKind int

LiteralKind distinguishes the literal forms of the "term" production.

const (
	LitNull LiteralKind = iota
	LitInteger
	LitFloat
	LitString
	LitBlob
	LitCurrentDate
	LitCurrentTime
	LitCurrentTimestamp
)

func (LiteralKind) String ¶

func (k LiteralKind) String() string

type Materialized ¶

type Materialized int

Materialized records the optional MATERIALIZED hint on a CTE.

const (
	MaterializedAny Materialized = iota
	MaterializedYes
	MaterializedNo
)

func (Materialized) String ¶

func (m Materialized) String() string

type Node ¶

type Node interface {
	Pos() int
	End() int
	Children() []Node
}

Node is implemented by every syntax tree node. Positions are byte offsets into the original input.

type NullCheckExpr ¶

type NullCheckExpr struct {
	Span
	Test NullTest `json:"test"`
	X    Expr     `json:"x"`
}

NullCheckExpr is a postfix null test.

expr ::= expr ISNULL|NOTNULL. / expr ::= expr NOT NULL.

func (*NullCheckExpr) Children ¶

func (n *NullCheckExpr) Children() []Node

type NullTest ¶

type NullTest int

NullTest distinguishes the three spellings of a postfix null test. They are not interchangeable: "expr NOT NULL" takes its precedence from NOT, while ISNULL and NOTNULL are comparison-level operators, so "NOT x NOTNULL" and "NOT x NOT NULL" are different trees.

const (
	TestIsNull       NullTest = iota // ISNULL
	TestNotNull                      // NOTNULL
	TestNotNullWords                 // NOT NULL
)

func (NullTest) String ¶

func (t NullTest) String() string

type NullsOrder ¶

type NullsOrder int

NullsOrder is NULLS FIRST, NULLS LAST, or unstated.

const (
	NullsDefault NullsOrder = iota
	NullsFirst
	NullsLast
)

func (NullsOrder) String ¶

func (o NullsOrder) String() string

type Operator ¶

type Operator int

Operator identifies a unary or binary operator.

const (
	OpNone Operator = iota
	// Binary
	OpOr
	OpAnd
	OpEq
	OpNe
	OpLt
	OpLe
	OpGt
	OpGe
	OpBitAnd
	OpBitOr
	OpLShift
	OpRShift
	OpAdd
	OpSub
	OpMul
	OpDiv
	OpMod
	OpConcat
	OpPtr  // ->
	OpPtr2 // ->>
	// Unary
	OpNot
	OpBitNot
	OpPlus
	OpMinus
)

func (Operator) String ¶

func (o Operator) String() string

type OrderingTerm ¶

type OrderingTerm struct {
	Span
	Expr  Expr       `json:"expr"`
	Order SortOrder  `json:"order,omitempty"`
	Nulls NullsOrder `json:"nulls,omitempty"`
}

OrderingTerm is one entry of an ORDER BY (or index/aggregate) sort list.

sortlist ::= sortlist COMMA expr sortorder nulls.

func (*OrderingTerm) Children ¶

func (n *OrderingTerm) Children() []Node

type ParamKind ¶

type ParamKind int

ParamKind distinguishes SQLite's four bind-parameter spellings.

const (
	ParamAnon   ParamKind = iota // ?
	ParamNumber                  // ?NNN
	ParamColon                   // :name
	ParamAt                      // @name
	ParamDollar                  // $name
)

func (ParamKind) String ¶

func (k ParamKind) String() string

type ParenExpr ¶

type ParenExpr struct {
	Span
	X Expr `json:"x"`
}

ParenExpr preserves an explicit parenthesisation. SQLite discards these (expr ::= LP expr RP just yields the inner expression), but keeping them makes the round-trip renderer exact.

func (*ParenExpr) Children ¶

func (n *ParenExpr) Children() []Node

type PragmaStmt ¶

type PragmaStmt struct {
	Span
	Name     *QualifiedName `json:"name"`
	Value    string         `json:"value,omitempty"` // as written, "-" included
	Paren    bool           `json:"paren,omitempty"` // the LP ... RP spelling
	HasValue bool           `json:"hasValue,omitempty"`
}

PragmaStmt is a PRAGMA in any of its three value spellings.

cmd ::= PRAGMA nm dbnm.
cmd ::= PRAGMA nm dbnm EQ nmnum. / PRAGMA nm dbnm EQ minus_num.
cmd ::= PRAGMA nm dbnm LP nmnum RP. / PRAGMA nm dbnm LP minus_num RP.

func (*PragmaStmt) Children ¶

func (n *PragmaStmt) Children() []Node

type QualifiedName ¶

type QualifiedName struct {
	Span
	Schema *Ident `json:"schema,omitempty"`
	Name   *Ident `json:"name"`
}

QualifiedName is a "nm dbnm" pair: an optionally schema-qualified object name. Schema is nil when the name was unqualified.

fullname ::= nm. / fullname ::= nm DOT nm.

func (*QualifiedName) Children ¶

func (n *QualifiedName) Children() []Node

type QualifiedRef ¶

type QualifiedRef struct {
	Span
	Parts []*Ident `json:"parts"`
}

QualifiedRef is a dotted column reference with two or three parts.

expr ::= nm DOT nm. / expr ::= nm DOT nm DOT nm.

func (*QualifiedRef) Children ¶

func (n *QualifiedRef) Children() []Node

type QuoteStyle ¶

type QuoteStyle byte

QuoteStyle records how an identifier was spelled in the source. SQLite accepts four quoting styles for identifiers plus the unquoted form, and consumers (sqlc among them) need to tell them apart.

const (
	QuoteNone   QuoteStyle = 0
	QuoteDouble QuoteStyle = '"'
	QuoteBack   QuoteStyle = '`'
	QuoteSquare QuoteStyle = '['
	QuoteSingle QuoteStyle = '\'' // a string literal used in a name position
)

func (QuoteStyle) String ¶

func (q QuoteStyle) String() string

type RaiseExpr ¶

type RaiseExpr struct {
	Span
	Action  string `json:"action"` // IGNORE, ROLLBACK, ABORT or FAIL
	Message Expr   `json:"message,omitempty"`
}

RaiseExpr is the trigger-only RAISE() form.

expr ::= RAISE LP IGNORE RP. / expr ::= RAISE LP raisetype COMMA expr RP.

func (*RaiseExpr) Children ¶

func (n *RaiseExpr) Children() []Node

type ReindexStmt ¶

type ReindexStmt struct {
	Span
	Name *QualifiedName `json:"name,omitempty"`
}

ReindexStmt is REINDEX [name [. name]].

cmd ::= REINDEX. / cmd ::= REINDEX nm dbnm.

func (*ReindexStmt) Children ¶

func (n *ReindexStmt) Children() []Node

type ReleaseStmt ¶

type ReleaseStmt struct {
	Span
	SavepointKeyword bool   `json:"savepointKeyword,omitempty"`
	Name             *Ident `json:"name"`
}

ReleaseStmt is RELEASE [SAVEPOINT] <name>.

cmd ::= RELEASE savepoint_opt nm.

func (*ReleaseStmt) Children ¶

func (n *ReleaseStmt) Children() []Node

type ResultColumn ¶

type ResultColumn struct {
	Span
	Expr  Expr   `json:"expr"`
	Alias *Ident `json:"alias,omitempty"`
	HasAs bool   `json:"hasAs,omitempty"` // the alias was introduced by AS
}

ResultColumn is one entry of a select list.

selcollist ::= sclp scanpt expr scanpt as.

func (*ResultColumn) Children ¶

func (n *ResultColumn) Children() []Node

type RollbackStmt ¶

type RollbackStmt struct {
	Span
	HasTransaction   bool   `json:"hasTransaction,omitempty"`
	Name             *Ident `json:"name,omitempty"`      // TRANSACTION <name>
	Savepoint        *Ident `json:"savepoint,omitempty"` // TO [SAVEPOINT] <name>
	SavepointKeyword bool   `json:"savepointKeyword,omitempty"`
}

RollbackStmt is ROLLBACK, with or without a savepoint.

cmd ::= ROLLBACK trans_opt.
cmd ::= ROLLBACK trans_opt TO savepoint_opt nm.

func (*RollbackStmt) Children ¶

func (n *RollbackStmt) Children() []Node

type SavepointStmt ¶

type SavepointStmt struct {
	Span
	Name *Ident `json:"name"`
}

SavepointStmt is SAVEPOINT <name>.

cmd ::= SAVEPOINT nm.

func (*SavepointStmt) Children ¶

func (n *SavepointStmt) Children() []Node

type SelectCore ¶

type SelectCore interface {
	Node
	// contains filtered or unexported methods
}

SelectCore is one term of a compound select: a SELECT or a VALUES clause.

type SelectQuery ¶

type SelectQuery struct {
	Span
	Distinct Distinct        `json:"distinct,omitempty"`
	Columns  []*ResultColumn `json:"columns"`
	From     []*TableRef     `json:"from,omitempty"`
	Where    Expr            `json:"where,omitempty"`
	GroupBy  []Expr          `json:"groupBy,omitempty"`
	Having   Expr            `json:"having,omitempty"`
	Windows  []*WindowDef    `json:"windows,omitempty"`
	OrderBy  []*OrderingTerm `json:"orderBy,omitempty"`
	Limit    *Limit          `json:"limit,omitempty"`
}

SelectQuery is the SELECT form of a query core.

oneselect ::= SELECT distinct selcollist from where_opt groupby_opt
              having_opt [window_clause] orderby_opt limit_opt.

func (*SelectQuery) Children ¶

func (n *SelectQuery) Children() []Node

type SelectStmt ¶

type SelectStmt struct {
	Span
	With  *With        `json:"with,omitempty"`
	Cores []SelectCore `json:"cores"`
	Ops   []CompoundOp `json:"ops,omitempty"`
}

SelectStmt is a complete SELECT: an optional WITH clause followed by one or more query cores joined by compound operators.

select ::= WITH [RECURSIVE] wqlist selectnowith. / select ::= selectnowith.
selectnowith ::= selectnowith multiselect_op oneselect.

Cores is never empty and Ops has exactly len(Cores)-1 entries. ORDER BY and LIMIT belong to the core they were written on: SQLite's grammar hangs them off oneselect, and rejects a leading one only in a grammar action ("ORDER BY clause should come after UNION not before"), which is not a parse error.

func (*SelectStmt) Children ¶

func (n *SelectStmt) Children() []Node

func (*SelectStmt) String ¶

func (n *SelectStmt) String() string

type SetPair ¶

type SetPair struct {
	Span
	Columns []*Ident `json:"columns"`
	Paren   bool     `json:"paren,omitempty"`
	Value   Expr     `json:"value"`
}

SetPair is one assignment of an UPDATE ... SET or upsert DO UPDATE SET list. Columns holds more than one name for the "(a,b) = expr" form.

setlist ::= nm EQ expr. / setlist ::= LP idlist RP EQ expr.

func (*SetPair) Children ¶

func (n *SetPair) Children() []Node

type SortOrder ¶

type SortOrder int

SortOrder is ASC, DESC, or unstated.

const (
	SortDefault SortOrder = iota
	SortAsc
	SortDesc
)

func (SortOrder) String ¶

func (o SortOrder) String() string

type Span ¶

type Span struct {
	Start int `json:"start"`
	Stop  int `json:"end"`
}

Span carries a node's byte extent and is embedded in every node type.

func (Span) End ¶

func (s Span) End() int

func (Span) Pos ¶

func (s Span) Pos() int

func (*Span) SetSpan ¶

func (s *Span) SetSpan(sp Span)

SetSpan replaces the node's extent. The parser uses it to widen a statement's span once its terminating semicolon has been consumed.

type Star ¶

type Star struct {
	Span
	Table *Ident `json:"table,omitempty"`
}

Star is "*" or "tbl.*" in a result column list.

selcollist ::= sclp scanpt STAR. / selcollist ::= sclp scanpt nm DOT STAR.

func (*Star) Children ¶

func (n *Star) Children() []Node

type Stmt ¶

type Stmt interface {
	Node
	SetSpan(Span)
	// contains filtered or unexported methods
}

Stmt is implemented by all statement nodes. SetSpan is part of the interface because the parser widens a statement's span once it has seen the terminating semicolon, and a node that could not be widened would get a quietly wrong span rather than a compile error.

type SubqueryExpr ¶

type SubqueryExpr struct {
	Span
	Select *SelectStmt `json:"select"`
}

SubqueryExpr is a parenthesised SELECT used as a scalar.

expr ::= LP select RP.

func (*SubqueryExpr) Children ¶

func (n *SubqueryExpr) Children() []Node

type TableConstraint ¶

type TableConstraint struct {
	Span
	Name          *Ident              `json:"name,omitempty"`
	Kind          TableConstraintKind `json:"kind"`
	Columns       []*OrderingTerm     `json:"columns,omitempty"` // PRIMARY KEY / UNIQUE
	AutoIncrement bool                `json:"autoIncrement,omitempty"`
	OnConflict    ConflictAction      `json:"onConflict,omitempty"`
	Expr          Expr                `json:"expr,omitempty"` // CHECK
	FKColumns     []*IndexedColumn    `json:"fkColumns,omitempty"`
	References    *ForeignKeyClause   `json:"references,omitempty"`
	Deferrable    *DeferClause        `json:"deferrable,omitempty"`
}

TableConstraint is one table-level constraint.

tcons ::= CONSTRAINT nm.
tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf. / UNIQUE LP sortlist RP onconf.
tcons ::= CHECK LP expr RP onconf.
tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs
          defer_subclause_opt.

func (*TableConstraint) Children ¶

func (n *TableConstraint) Children() []Node

type TableConstraintKind ¶

type TableConstraintKind int

TableConstraintKind enumerates the "tcons" alternatives.

const (
	TablePrimaryKey TableConstraintKind = iota
	TableUnique
	TableCheck
	TableForeignKey
)

func (TableConstraintKind) String ¶

func (k TableConstraintKind) String() string

type TableOption ¶

type TableOption struct {
	Span
	Without bool   `json:"without,omitempty"`
	Name    *Ident `json:"name"`
}

TableOption is one entry of a table_option_set. SQLite rejects an unknown one from a grammar action rather than the grammar, so any name parses.

table_option ::= WITHOUT nm. / table_option ::= nm.

func (*TableOption) Children ¶

func (n *TableOption) Children() []Node

type TableRef ¶

type TableRef struct {
	Span
	Join       *JoinOperator  `json:"join,omitempty"` // nil for the first item
	Name       *QualifiedName `json:"name,omitempty"`
	Args       []Expr         `json:"args,omitempty"` // table-valued function
	HasArgs    bool           `json:"hasArgs,omitempty"`
	Select     *SelectStmt    `json:"select,omitempty"`
	List       []*TableRef    `json:"list,omitempty"`
	Alias      *Ident         `json:"alias,omitempty"`
	HasAs      bool           `json:"hasAs,omitempty"`
	IndexedBy  *Ident         `json:"indexedBy,omitempty"`
	NotIndexed bool           `json:"notIndexed,omitempty"`
	On         Expr           `json:"on,omitempty"`
	Using      []*Ident       `json:"using,omitempty"`
}

TableRef is one item of a FROM clause. Following SQLite's SrcList, the list is flat and each item records how it attaches to the previous one. Exactly one of Name, Select and List describes the source.

seltablist ::= stl_prefix nm dbnm as [indexed_by] on_using.
seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using.
seltablist ::= stl_prefix LP select RP as on_using.
seltablist ::= stl_prefix LP seltablist RP as on_using.

func (*TableRef) Children ¶

func (n *TableRef) Children() []Node

type TransactionType ¶

type TransactionType int

TransactionType is the DEFERRED/IMMEDIATE/EXCLUSIVE qualifier of BEGIN.

const (
	TxnDeferred TransactionType = iota
	TxnImmediate
	TxnExclusive
)

func (TransactionType) String ¶

func (t TransactionType) String() string

type TriggerTime ¶

type TriggerTime int

TriggerTime is BEFORE, AFTER or INSTEAD OF.

const (
	TriggerBefore TriggerTime = iota
	TriggerAfter
	TriggerInsteadOf
)

func (TriggerTime) String ¶

func (t TriggerTime) String() string

type TypeName ¶

type TypeName struct {
	Span
	Name string   `json:"name"`           // the identifier tokens, space-joined
	Args []string `json:"args,omitempty"` // the signed numbers, as written
	Raw  string   `json:"raw"`            // the whole source span
}

TypeName is a column or cast type: one or more identifier tokens followed by an optional size specification.

typetoken ::= typename [LP signed [COMMA signed] RP].

func (*TypeName) Children ¶

func (n *TypeName) Children() []Node

type UnaryExpr ¶

type UnaryExpr struct {
	Span
	Op Operator `json:"op"`
	X  Expr     `json:"x"`
}

UnaryExpr is a prefix operator application.

expr ::= NOT expr. / expr ::= BITNOT expr. / expr ::= PLUS|MINUS expr.

func (*UnaryExpr) Children ¶

func (n *UnaryExpr) Children() []Node

type UpdateStmt ¶

type UpdateStmt struct {
	Span
	With       *With           `json:"with,omitempty"`
	OrConflict ConflictAction  `json:"orConflict,omitempty"`
	Table      *QualifiedName  `json:"table"`
	Alias      *Ident          `json:"alias,omitempty"`
	IndexedBy  *Ident          `json:"indexedBy,omitempty"`
	NotIndexed bool            `json:"notIndexed,omitempty"`
	Set        []*SetPair      `json:"set"`
	From       []*TableRef     `json:"from,omitempty"`
	Where      Expr            `json:"where,omitempty"`
	Returning  []*ResultColumn `json:"returning,omitempty"`
	OrderBy    []*OrderingTerm `json:"orderBy,omitempty"`
	Limit      *Limit          `json:"limit,omitempty"`
}

UpdateStmt is an UPDATE statement.

cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from
        where_opt_ret.
cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from
        where_opt_ret orderby_opt limit_opt.

The second form is the one SQLITE_ENABLE_UPDATE_DELETE_LIMIT compiles in. The pinned build defines neither it nor SQLITE_UDL_CAPABLE_PARSER, so OrderBy and Limit are only ever set for a parse that asked for them with parser.Options.UpdateDeleteLimit; without it they are a syntax error.

func (*UpdateStmt) Children ¶

func (n *UpdateStmt) Children() []Node

func (*UpdateStmt) String ¶

func (n *UpdateStmt) String() string

type Upsert ¶

type Upsert struct {
	Span
	Target      []*OrderingTerm `json:"target,omitempty"`
	TargetWhere Expr            `json:"targetWhere,omitempty"`
	DoNothing   bool            `json:"doNothing,omitempty"`
	Set         []*SetPair      `json:"set,omitempty"`
	Where       Expr            `json:"where,omitempty"`
}

Upsert is one ON CONFLICT clause of an INSERT.

upsert ::= ON CONFLICT [LP sortlist RP where_opt] DO UPDATE SET setlist where_opt.
upsert ::= ON CONFLICT [LP sortlist RP where_opt] DO NOTHING.

func (*Upsert) Children ¶

func (n *Upsert) Children() []Node

type VacuumStmt ¶

type VacuumStmt struct {
	Span
	Schema *Ident `json:"schema,omitempty"`
	Into   Expr   `json:"into,omitempty"`
}

VacuumStmt is VACUUM [schema] [INTO expr].

cmd ::= VACUUM vinto. / cmd ::= VACUUM nm vinto.

func (*VacuumStmt) Children ¶

func (n *VacuumStmt) Children() []Node

type ValuesClause ¶

type ValuesClause struct {
	Span
	Rows [][]Expr `json:"rows"`
}

ValuesClause is the VALUES form of a query core. SQLite models multi-row VALUES as a compound of single-row selects; meyer keeps it as one node.

values ::= VALUES LP nexprlist RP.
mvalues ::= values COMMA LP nexprlist RP. / mvalues COMMA LP nexprlist RP.

func (*ValuesClause) Children ¶

func (n *ValuesClause) Children() []Node

type VectorExpr ¶

type VectorExpr struct {
	Span
	List []Expr `json:"list"`
}

VectorExpr is a parenthesised row value with two or more elements.

expr ::= LP nexprlist COMMA expr RP.

func (*VectorExpr) Children ¶

func (n *VectorExpr) Children() []Node

type WindowDef ¶

type WindowDef struct {
	Span
	Name       *Ident          `json:"name,omitempty"` // WINDOW <name> AS (...)
	Base       *Ident          `json:"base,omitempty"` // inherited window name
	NameOnly   bool            `json:"nameOnly,omitempty"`
	Partition  []Expr          `json:"partition,omitempty"`
	OrderBy    []*OrderingTerm `json:"orderBy,omitempty"`
	Frame      FrameType       `json:"frame,omitempty"`
	StartBound *FrameBound     `json:"startBound,omitempty"`
	EndBound   *FrameBound     `json:"endBound,omitempty"`
	Exclude    FrameExclude    `json:"exclude,omitempty"`
}

WindowDef is a window definition: the body of an OVER(...) or of one entry in a WINDOW clause. A bare "OVER name" sets Base and nothing else.

window ::= [nm] [PARTITION BY nexprlist] [ORDER BY sortlist] frame_opt.
windowdefn ::= nm AS LP window RP.

func (*WindowDef) Children ¶

func (n *WindowDef) Children() []Node

type With ¶

type With struct {
	Span
	Recursive bool   `json:"recursive,omitempty"`
	CTEs      []*CTE `json:"ctes"`
}

With is a WITH clause.

with ::= WITH [RECURSIVE] wqlist.

func (*With) Children ¶

func (n *With) Children() []Node

Source Files ¶

View all Source files
  • ast.go
  • ddl.go
  • dml.go
  • expr.go
  • misc.go
  • render.go
  • select.go
Click to show internal directories.
Click to hide internal directories.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.