ast

package
v0.0.0-...-aef99cd Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ast declares the types used to represent Oracle SQL and PL/SQL Abstract Syntax Trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fprint

func Fprint(w io.Writer, node Node)

Fprint prints the AST to the writer in a human-readable format.

func Walk

func Walk(v Visitor, node Node)

Walk traverses an AST in depth-first order.

func WalkAll

func WalkAll(v Visitor, node Node)

WalkAll traverses the entire AST in depth-first order, including both expression-level nodes AND statement-level nodes. Unlike Walk, which only visits expression nodes, WalkAll visits every node type.

Types

type AlterAction

type AlterAction struct {
	Type       token.Token // ADD, MODIFY, DROP, RENAME, etc.
	Column     *ColumnDef
	Constraint *ConstraintDef
	OldName    *Ident
	NewName    *Ident
}

AlterAction represents a single action in ALTER TABLE.

type AlterTableStmt

type AlterTableStmt struct {
	Name    *QualifiedName
	Actions []*AlterAction
	PosVal  Pos
	EndVal  Pos
}

AlterTableStmt represents ALTER TABLE.

func (*AlterTableStmt) End

func (a *AlterTableStmt) End() Pos

func (*AlterTableStmt) Pos

func (a *AlterTableStmt) Pos() Pos

type AssignmentStmt

type AssignmentStmt struct {
	Target Expr
	Value  Expr
	PosVal Pos
	EndVal Pos
}

AssignmentStmt represents var := expr

func (*AssignmentStmt) End

func (a *AssignmentStmt) End() Pos

func (*AssignmentStmt) Pos

func (a *AssignmentStmt) Pos() Pos

type BasicLit

type BasicLit struct {
	Kind   token.Token // token.INT, token.FLOAT, token.STRING, token.QSTRING, token.NSTRING
	Value  string      // the literal string as written
	PosVal Pos
	EndVal Pos
}

BasicLit represents a literal value of a basic type (string, integer, float).

func (*BasicLit) End

func (b *BasicLit) End() Pos

func (*BasicLit) Pos

func (b *BasicLit) Pos() Pos

type BetweenExpr

type BetweenExpr struct {
	Left   Expr
	Not    bool
	Low    Expr
	High   Expr
	PosVal Pos
}

BetweenExpr represents value [NOT] BETWEEN low AND high

func (*BetweenExpr) End

func (b *BetweenExpr) End() Pos

func (*BetweenExpr) Pos

func (b *BetweenExpr) Pos() Pos

type BinaryExpr

type BinaryExpr struct {
	Op    token.Token
	Left  Expr
	Right Expr
	OpPos Pos
}

BinaryExpr represents a binary operation expression: a + b, a AND b, etc.

func (*BinaryExpr) End

func (b *BinaryExpr) End() Pos

func (*BinaryExpr) Pos

func (b *BinaryExpr) Pos() Pos

type BindVar

type BindVar struct {
	Name   string
	PosVal Pos
	EndVal Pos
}

BindVar represents a bind variable: :var, :1, :"name"

func (*BindVar) End

func (b *BindVar) End() Pos

func (*BindVar) Pos

func (b *BindVar) Pos() Pos

type BoolLit

type BoolLit struct {
	Value  bool
	PosVal Pos
}

BoolLit represents TRUE or FALSE in PL/SQL.

func (*BoolLit) End

func (b *BoolLit) End() Pos

func (*BoolLit) Pos

func (b *BoolLit) Pos() Pos

type CTEDef

type CTEDef struct {
	Name    *Ident
	Columns []*Ident
	Query   *SelectStmt
}

CTEDef represents a single CTE: name [(cols)] AS (subquery)

type CallArg

type CallArg struct {
	Name  *Ident // nil for positional
	Value Expr
}

CallArg represents an argument in a procedure call: [name =>] value. Implements ast.Expr so it can be used wherever an expression is expected.

func (*CallArg) End

func (c *CallArg) End() Pos

func (*CallArg) Pos

func (c *CallArg) Pos() Pos

type CallExpr

type CallExpr struct {
	FuncName *QualifiedName
	Args     []Expr
	Distinct bool
	// Analytic clause (OVER ...)
	Over *OverClause
	// Ordered-set aggregate: WITHIN GROUP (ORDER BY ...)
	WithinGroup *WithinGroupClause
	Lparen      Pos
	Rparen      Pos
}

CallExpr represents a function call: func(args), func(DISTINCT arg), etc. Args may contain *CallArg for named parameters (param => value).

func (*CallExpr) End

func (c *CallExpr) End() Pos

func (*CallExpr) Pos

func (c *CallExpr) Pos() Pos

type CaseExpr

type CaseExpr struct {
	Expr    Expr // optional: searched CASE has nil Expr
	Whens   []*WhenClause
	Else    Expr // optional
	CasePos Pos
	EndPos  Pos
}

CaseExpr represents a CASE expression: CASE [expr] WHEN ... THEN ... ELSE ... END

func (*CaseExpr) End

func (c *CaseExpr) End() Pos

func (*CaseExpr) Pos

func (c *CaseExpr) Pos() Pos

type CaseStmt

type CaseStmt struct {
	Expr   Expr // optional expression for simple CASE
	Whens  []*CaseWhenBranch
	Else   []PlsqlStmt
	PosVal Pos
	EndPos Pos
}

CaseStmt represents CASE [expr] WHEN ... THEN ... END CASE

func (*CaseStmt) End

func (c *CaseStmt) End() Pos

func (*CaseStmt) Pos

func (c *CaseStmt) Pos() Pos

type CaseWhenBranch

type CaseWhenBranch struct {
	Cond Expr
	Body []PlsqlStmt
}

CaseWhenBranch represents WHEN condition THEN statements

type CastExpr

type CastExpr struct {
	Expr    Expr
	Type    *TypeSpec
	CastPos Pos
	Rparen  Pos
}

CastExpr represents CAST(expr AS type)

func (*CastExpr) End

func (c *CastExpr) End() Pos

func (*CastExpr) Pos

func (c *CastExpr) Pos() Pos

type CloseStmt

type CloseStmt struct {
	Cursor *Ident
	PosVal Pos
	EndVal Pos
}

CloseStmt represents CLOSE cursor

func (*CloseStmt) End

func (c *CloseStmt) End() Pos

func (*CloseStmt) Pos

func (c *CloseStmt) Pos() Pos

type ColumnDef

type ColumnDef struct {
	Name       *Ident
	Type       *TypeSpec
	Default    Expr
	Null       *bool // nil = not specified, true = NULL, false = NOT NULL
	PrimaryKey bool
	Unique     bool
	References *ReferencesClause
	Check      Expr
	Virtual    string // virtual column expression (if present)
	Identity   *IdentityClause
	PosVal     Pos
}

ColumnDef represents a column definition in CREATE TABLE.

func (*ColumnDef) End

func (c *ColumnDef) End() Pos

func (*ColumnDef) Pos

func (c *ColumnDef) Pos() Pos

type CommitStmt

type CommitStmt struct {
	Work    bool
	Comment string
	Write   string // WAIT | NOWAIT
	PosVal  Pos
	EndVal  Pos
}

CommitStmt represents COMMIT.

func (*CommitStmt) End

func (c *CommitStmt) End() Pos

func (*CommitStmt) Pos

func (c *CommitStmt) Pos() Pos

type ConstraintDef

type ConstraintDef struct {
	Name       *Ident
	Type       token.Token // PRIMARY, UNIQUE, CHECK, FOREIGN
	Columns    []*Ident
	CheckExpr  Expr
	References *ReferencesClause
}

ConstraintDef represents a table-level constraint.

type ContinueStmt

type ContinueStmt struct {
	Label  *Ident
	When   Expr
	PosVal Pos
	EndVal Pos
}

ContinueStmt represents CONTINUE [label] [WHEN condition]

func (*ContinueStmt) End

func (c *ContinueStmt) End() Pos

func (*ContinueStmt) Pos

func (c *ContinueStmt) Pos() Pos

type CreateIndexStmt

type CreateIndexStmt struct {
	Unique     bool
	Bitmap     bool
	Name       *QualifiedName
	Table      *QualifiedName
	Columns    []*IndexColumn
	Tablespace string
	Storage    *StorageClause
	PosVal     Pos
	EndVal     Pos
}

CreateIndexStmt represents CREATE INDEX.

func (*CreateIndexStmt) End

func (c *CreateIndexStmt) End() Pos

func (*CreateIndexStmt) Pos

func (c *CreateIndexStmt) Pos() Pos

type CreateSequenceStmt

type CreateSequenceStmt struct {
	Name      *QualifiedName
	StartWith int64
	Increment int64
	MaxValue  int64
	MinValue  int64
	Cycle     bool
	Cache     int64
	Order     bool
	PosVal    Pos
	EndVal    Pos
}

CreateSequenceStmt represents CREATE SEQUENCE.

func (*CreateSequenceStmt) End

func (c *CreateSequenceStmt) End() Pos

func (*CreateSequenceStmt) Pos

func (c *CreateSequenceStmt) Pos() Pos

type CreateSynonymStmt

type CreateSynonymStmt struct {
	OrReplace bool
	Public    bool
	Name      *QualifiedName
	For       *QualifiedName
	PosVal    Pos
	EndVal    Pos
}

CreateSynonymStmt represents CREATE SYNONYM.

func (*CreateSynonymStmt) End

func (c *CreateSynonymStmt) End() Pos

func (*CreateSynonymStmt) Pos

func (c *CreateSynonymStmt) Pos() Pos

type CreateTableStmt

type CreateTableStmt struct {
	OrReplace   bool
	Name        *QualifiedName
	Columns     []*ColumnDef
	Constraints []*ConstraintDef
	Tablespace  string
	Storage     *StorageClause
	PartitionBy *PartitionClause
	AsSelect    *SelectStmt // CREATE TABLE AS SELECT
	PosVal      Pos
	EndVal      Pos
}

CreateTableStmt represents CREATE TABLE.

func (*CreateTableStmt) End

func (c *CreateTableStmt) End() Pos

func (*CreateTableStmt) Pos

func (c *CreateTableStmt) Pos() Pos

type CreateViewStmt

type CreateViewStmt struct {
	OrReplace       bool
	Force           bool
	Name            *QualifiedName
	Columns         []*Ident
	As              *SelectStmt
	WithReadOnly    bool
	WithCheckOption bool
	PosVal          Pos
	EndVal          Pos
}

CreateViewStmt represents CREATE VIEW.

func (*CreateViewStmt) End

func (c *CreateViewStmt) End() Pos

func (*CreateViewStmt) Pos

func (c *CreateViewStmt) Pos() Pos

type CursorDecl

type CursorDecl struct {
	Name   *Ident
	Params []*ParamDecl
	Query  *SelectStmt
	Return *TypeSpec // RETURN type for weak ref cursors
	PosVal Pos
	EndVal Pos
}

CursorDecl represents a cursor declaration: CURSOR name [(params)] IS query

func (*CursorDecl) End

func (c *CursorDecl) End() Pos

func (*CursorDecl) Pos

func (c *CursorDecl) Pos() Pos

type CursorExpr

type CursorExpr struct {
	Query  *SelectStmt
	PosVal Pos
}

CursorExpr represents CURSOR(subquery) in expressions

func (*CursorExpr) End

func (c *CursorExpr) End() Pos

func (*CursorExpr) Pos

func (c *CursorExpr) Pos() Pos

type CursorForStmt

type CursorForStmt struct {
	Label  *Ident
	Record *Ident
	Cursor Expr // cursor name or (SELECT ...)
	Body   []PlsqlStmt
	PosVal Pos
	EndPos Pos
}

CursorForStmt represents FOR rec IN cursor LOOP ... END LOOP

func (*CursorForStmt) End

func (c *CursorForStmt) End() Pos

func (*CursorForStmt) Pos

func (c *CursorForStmt) Pos() Pos

type DDLStmt

type DDLStmt struct {
	Action token.Token // CREATE, ALTER, DROP, TRUNCATE
	Object token.Token // TABLE, INDEX, VIEW, SEQUENCE, etc.
	Name   *QualifiedName
	PosVal Pos
	EndVal Pos
}

DDLStmt is a generic DDL statement (CREATE, ALTER, DROP, etc.)

func (*DDLStmt) End

func (d *DDLStmt) End() Pos

func (*DDLStmt) Pos

func (d *DDLStmt) Pos() Pos

type Decl

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

Decl is the interface satisfied by all declaration nodes (PL/SQL).

type DeleteStmt

type DeleteStmt struct {
	Hints     string
	Table     *QualifiedName
	Alias     *Ident
	From      []*TableRef // additional FROM for multi-table delete
	Where     Expr
	Returning *ReturningClause
	PosVal    Pos
	EndVal    Pos
}

DeleteStmt represents a DELETE statement.

func (*DeleteStmt) End

func (d *DeleteStmt) End() Pos

func (*DeleteStmt) Pos

func (d *DeleteStmt) Pos() Pos

type DropStmt

type DropStmt struct {
	Object   token.Token
	Name     *QualifiedName
	IfExists bool
	Cascade  bool
	Purge    bool
	PosVal   Pos
	EndVal   Pos
}

DropStmt represents DROP TABLE/INDEX/VIEW/SEQUENCE/etc.

func (*DropStmt) End

func (d *DropStmt) End() Pos

func (*DropStmt) Pos

func (d *DropStmt) Pos() Pos

type ElsifBranch

type ElsifBranch struct {
	Cond Expr
	Body []PlsqlStmt
}

ElsifBranch represents ELSIF condition THEN statements

type ExceptionDecl

type ExceptionDecl struct {
	Name   *Ident
	Pragma *PragmaDecl // optional EXCEPTION_INIT pragma
	PosVal Pos
	EndVal Pos
}

ExceptionDecl represents a user-defined exception declaration.

func (*ExceptionDecl) End

func (e *ExceptionDecl) End() Pos

func (*ExceptionDecl) Pos

func (e *ExceptionDecl) Pos() Pos

type ExceptionHandler

type ExceptionHandler struct {
	Exceptions []Expr // exception names or OTHERS
	Body       []PlsqlStmt
	PosVal     Pos
}

ExceptionHandler represents WHEN exception_list THEN statements

type ExecuteImmediateStmt

type ExecuteImmediateStmt struct {
	SQL       Expr
	Into      []Expr
	Using     []Expr
	Returning *ReturningClause
	PosVal    Pos
	EndVal    Pos
}

ExecuteImmediateStmt represents EXECUTE IMMEDIATE sql [INTO vars] [USING binds]

func (*ExecuteImmediateStmt) End

func (e *ExecuteImmediateStmt) End() Pos

func (*ExecuteImmediateStmt) Pos

func (e *ExecuteImmediateStmt) Pos() Pos

type ExistsExpr

type ExistsExpr struct {
	Subquery *Subquery
	PosVal   Pos
}

ExistsExpr represents EXISTS (subquery)

func (*ExistsExpr) End

func (e *ExistsExpr) End() Pos

func (*ExistsExpr) Pos

func (e *ExistsExpr) Pos() Pos

type ExitStmt

type ExitStmt struct {
	Label  *Ident
	When   Expr
	PosVal Pos
	EndVal Pos
}

ExitStmt represents EXIT [label] [WHEN condition]

func (*ExitStmt) End

func (e *ExitStmt) End() Pos

func (*ExitStmt) Pos

func (e *ExitStmt) Pos() Pos

type Expr

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

Expr is the interface satisfied by all expression nodes.

type FetchClause

type FetchClause struct {
	Percent  bool
	Next     bool // false = FIRST, true = NEXT
	Count    Expr
	WithTies bool
	Only     bool // true = ONLY, false = WITH TIES
	EndVal   Pos
}

FetchClause represents FETCH FIRST/NEXT n ROWS ONLY

func (*FetchClause) End

func (f *FetchClause) End() Pos

func (*FetchClause) Pos

func (f *FetchClause) Pos() Pos

type FetchStmt_plsql

type FetchStmt_plsql struct {
	Cursor *Ident
	Into   []Expr
	Bulk   bool
	Limit  Expr
	PosVal Pos
	EndVal Pos
}

FetchStmt_plsql represents FETCH cursor INTO var1, var2, ...

func (*FetchStmt_plsql) End

func (f *FetchStmt_plsql) End() Pos

func (*FetchStmt_plsql) Pos

func (f *FetchStmt_plsql) Pos() Pos

type File

type File struct {
	Stmts      []Stmt
	ErrorCount int // number of parse errors encountered (0 = clean parse)
}

File represents a parsed Oracle SQL file containing zero or more statements.

func (*File) End

func (f *File) End() Pos

func (*File) HasErrors

func (f *File) HasErrors() bool

HasErrors returns true if the parse encountered errors.

func (*File) Pos

func (f *File) Pos() Pos

type ForAllStmt

type ForAllStmt struct {
	Index          *Ident
	Low            Expr
	High           Expr
	IndicesOf      *Ident
	ValuesOf       *Ident
	SaveExceptions bool
	Body           PlsqlStmt
	PosVal         Pos
	EndVal         Pos
}

ForAllStmt represents FORALL i IN bounds [SAVE EXCEPTIONS] statement

func (*ForAllStmt) End

func (f *ForAllStmt) End() Pos

func (*ForAllStmt) Pos

func (f *ForAllStmt) Pos() Pos

type ForStmt

type ForStmt struct {
	Label   *Ident
	Index   *Ident
	Reverse bool
	Low     Expr
	High    Expr
	Body    []PlsqlStmt
	PosVal  Pos
	EndPos  Pos
}

ForStmt represents FOR i IN [REVERSE] low..high LOOP ... END LOOP

func (*ForStmt) End

func (f *ForStmt) End() Pos

func (*ForStmt) Pos

func (f *ForStmt) Pos() Pos

type ForUpdateClause

type ForUpdateClause struct {
	Of         []*QualifiedName
	Nowait     bool
	Wait       int // wait seconds, -1 if not specified
	SkipLocked bool
	Rparen     Pos // end position
}

ForUpdateClause represents FOR UPDATE [OF cols] [NOWAIT|WAIT n|SKIP LOCKED]

func (*ForUpdateClause) End

func (f *ForUpdateClause) End() Pos

func (*ForUpdateClause) Pos

func (f *ForUpdateClause) Pos() Pos

type FunctionDecl

type FunctionDecl struct {
	OrReplace      bool
	Schema         *Ident
	Name           *Ident
	Params         []*ParamDecl
	ReturnType     *PlsqlType
	Deterministic  bool
	ParallelEnable bool
	Pipelined      bool
	ResultCache    bool
	AuthId         token.Token
	Block          *PlsqlBlock
	IsNested       bool // true for nested subprogram in DECLARE section
	PosVal         Pos
	EndVal         Pos
}

FunctionDecl represents CREATE [OR REPLACE] FUNCTION name ... When IsNested is true, this is a nested subprogram in a declaration section.

func (*FunctionDecl) End

func (f *FunctionDecl) End() Pos

func (*FunctionDecl) Pos

func (f *FunctionDecl) Pos() Pos

type GotoStmt

type GotoStmt struct {
	Label  *Ident
	PosVal Pos
	EndVal Pos
}

GotoStmt represents GOTO label

func (*GotoStmt) End

func (g *GotoStmt) End() Pos

func (*GotoStmt) Pos

func (g *GotoStmt) Pos() Pos

type GrantStmt

type GrantStmt struct {
	Privileges []string // system privilege names or object privileges
	On         *QualifiedName
	To         []string
	WithAdmin  bool
	WithGrant  bool
	PosVal     Pos
	EndVal     Pos
}

GrantStmt represents GRANT.

func (*GrantStmt) End

func (g *GrantStmt) End() Pos

func (*GrantStmt) Pos

func (g *GrantStmt) Pos() Pos

type Ident

type Ident struct {
	Name   string // raw name as written
	Quoted bool   // true if double-quoted
	PosVal Pos
	EndVal Pos
}

Ident represents a single unqualified identifier.

func (*Ident) End

func (i *Ident) End() Pos

func (*Ident) Lowered

func (i *Ident) Lowered() string

Lowered returns the lower-cased name for case-insensitive comparison.

func (*Ident) Pos

func (i *Ident) Pos() Pos

func (*Ident) String

func (i *Ident) String() string

type IdentityClause

type IdentityClause struct {
	Always    bool // true = ALWAYS, false = BY DEFAULT
	StartWith int64
	Increment int64
	Cache     int64
	Cycle     bool
}

IdentityClause represents GENERATED [ALWAYS|BY DEFAULT] AS IDENTITY

type IfStmt

type IfStmt struct {
	Cond   Expr
	Then   []PlsqlStmt
	Elsif  []*ElsifBranch
	Else   []PlsqlStmt
	PosVal Pos
	EndPos Pos
}

IfStmt represents IF ... THEN ... ELSIF ... ELSE ... END IF

func (*IfStmt) End

func (i *IfStmt) End() Pos

func (*IfStmt) Pos

func (i *IfStmt) Pos() Pos

type InExpr

type InExpr struct {
	Left     Expr
	Not      bool
	Values   []Expr    // IN (val1, val2, ...)
	Subquery *Subquery // IN (SELECT ...)
	PosVal   Pos
}

InExpr represents value IN (list) or value IN (subquery)

func (*InExpr) End

func (i *InExpr) End() Pos

func (*InExpr) Pos

func (i *InExpr) Pos() Pos

type IndexColumn

type IndexColumn struct {
	Expr Expr // column name or expression for function-based index
	Desc bool // true = DESC, false = ASC
}

IndexColumn represents a column in an index definition.

type InsertStmt

type InsertStmt struct {
	Hints   string
	Table   *QualifiedName
	Alias   *Ident
	Columns []*Ident
	// Insert source
	Values   [][]Expr    // INSERT ... VALUES (...), (...)
	Subquery *SelectStmt // INSERT ... SELECT
	// Multi-table insert
	MultiTable    *MultiTableInsert
	DefaultValues bool
	PosVal        Pos
	EndVal        Pos
}

InsertStmt represents an INSERT statement.

func (*InsertStmt) End

func (i *InsertStmt) End() Pos

func (*InsertStmt) Pos

func (i *InsertStmt) Pos() Pos

type IntervalExpr

type IntervalExpr struct {
	Value  string
	Unit   string
	PosVal Pos
	EndVal Pos
}

IntervalExpr represents an INTERVAL literal: INTERVAL '1' DAY

func (*IntervalExpr) End

func (i *IntervalExpr) End() Pos

func (*IntervalExpr) Pos

func (i *IntervalExpr) Pos() Pos

type IsExpr

type IsExpr struct {
	Left   Expr
	Not    bool
	Kind   token.Token // NULL_KW, TRUE_KW, FALSE_KW, etc.
	PosVal Pos
}

IsExpr represents value IS [NOT] NULL, IS [NOT] TRUE, etc.

func (*IsExpr) End

func (i *IsExpr) End() Pos

func (*IsExpr) Pos

func (i *IsExpr) Pos() Pos

type JoinClause

type JoinClause struct {
	Left    *TableRef
	Type    token.Token // JOIN, LEFT_JOIN, RIGHT_JOIN, FULL_JOIN, CROSS_JOIN
	Natural bool
	Right   *TableRef
	On      Expr     // ON condition
	Using   []*Ident // USING (col1, col2, ...)
	PosVal  Pos
}

JoinClause represents a JOIN expression.

func (*JoinClause) End

func (j *JoinClause) End() Pos

func (*JoinClause) Pos

func (j *JoinClause) Pos() Pos

type LabelStmt

type LabelStmt struct {
	Name   *Ident
	PosVal Pos
	EndVal Pos
}

LabelStmt represents <<label>>

func (*LabelStmt) End

func (l *LabelStmt) End() Pos

func (*LabelStmt) Pos

func (l *LabelStmt) Pos() Pos

type LikeExpr

type LikeExpr struct {
	Left    Expr
	Not     bool
	Pattern Expr
	Escape  Expr // optional
	PosVal  Pos
}

LikeExpr represents value [NOT] LIKE pattern [ESCAPE esc]

func (*LikeExpr) End

func (l *LikeExpr) End() Pos

func (*LikeExpr) Pos

func (l *LikeExpr) Pos() Pos

type LoopStmt

type LoopStmt struct {
	Label  *Ident
	Body   []PlsqlStmt
	PosVal Pos
	EndPos Pos
}

LoopStmt represents LOOP ... END LOOP [label]

func (*LoopStmt) End

func (l *LoopStmt) End() Pos

func (*LoopStmt) Pos

func (l *LoopStmt) Pos() Pos

type MergeSource

type MergeSource struct {
	Table    *QualifiedName
	Subquery *SelectStmt
	Alias    *Ident
}

MergeSource represents the USING clause source.

type MergeStmt

type MergeStmt struct {
	Hints       string
	Table       *QualifiedName
	Alias       *Ident
	Using       *MergeSource
	On          Expr
	WhenClauses []*MergeWhen
	PosVal      Pos
	EndVal      Pos
}

MergeStmt represents a MERGE statement.

func (*MergeStmt) End

func (m *MergeStmt) End() Pos

func (*MergeStmt) Pos

func (m *MergeStmt) Pos() Pos

type MergeWhen

type MergeWhen struct {
	Matched    bool       // true = MATCHED, false = NOT MATCHED
	Condition  Expr       // optional additional condition
	Update     []*SetExpr // for UPDATE
	InsertCols []*Ident   // for INSERT columns
	InsertVals []Expr     // for INSERT values
	Delete     bool       // DELETE where
	DeleteCond Expr
}

MergeWhen represents WHEN MATCHED / NOT MATCHED ... THEN UPDATE / INSERT

type MultiTableInsert

type MultiTableInsert struct {
	All      bool // true = ALL, false = FIRST
	Whens    []*MultiTableWhen
	Else     *MultiTableInto
	Subquery *SelectStmt
}

MultiTableInsert represents INSERT ALL / INSERT FIRST ... WHEN ... THEN ... INTO

type MultiTableInto

type MultiTableInto struct {
	Table   *QualifiedName
	Columns []*Ident
	Values  []Expr
}

MultiTableInto represents INTO table [(cols)] VALUES (...)

type MultiTableWhen

type MultiTableWhen struct {
	Condition Expr
	Into      *MultiTableInto
}

MultiTableWhen represents WHEN condition THEN INTO table VALUES (...)

type Node

type Node interface {
	// Pos returns the source position of the node's first token.
	Pos() token.Pos
	// End returns the source position of the node's last token + 1.
	End() token.Pos
	// contains filtered or unexported methods
}

Node is the interface satisfied by all AST nodes.

type NullLit

type NullLit struct {
	PosVal Pos
}

NullLit represents the NULL literal.

func (*NullLit) End

func (n *NullLit) End() Pos

func (*NullLit) Pos

func (n *NullLit) Pos() Pos

type NullStmt

type NullStmt struct {
	PosVal Pos
	EndVal Pos
}

NullStmt represents the NULL statement.

func (*NullStmt) End

func (n *NullStmt) End() Pos

func (*NullStmt) Pos

func (n *NullStmt) Pos() Pos

type OpenStmt

type OpenStmt struct {
	Cursor  *Ident
	Params  []Expr
	ForExpr Expr // OPEN cursor FOR query
	Using   []Expr
	PosVal  Pos
	EndVal  Pos
}

OpenStmt represents OPEN cursor [(params)] or OPEN cursor FOR query [USING binds]

func (*OpenStmt) End

func (o *OpenStmt) End() Pos

func (*OpenStmt) Pos

func (o *OpenStmt) Pos() Pos

type OrderByElem

type OrderByElem struct {
	Expr      Expr
	Direction token.Token // ASC or DESC (0 = default/ASC)
	Nulls     token.Token // NULLS_FIRST, NULLS_LAST (0 = default)
}

OrderByElem represents a single element in ORDER BY.

type OverClause

type OverClause struct {
	PartitionBy []Expr
	OrderBy     []*OrderByElem
	Windowing   *WindowingClause
}

OverClause represents the OVER (analytic) clause.

type PackageBody

type PackageBody struct {
	OrReplace   bool
	Schema      *Ident
	Name        *Ident
	Decls       []Decl      // package body declarations
	Body        []PlsqlStmt // initialization section
	Subprograms []Decl      // procedure/function implementations
	PosVal      Pos
	EndPos      Pos
}

PackageBody represents CREATE [OR REPLACE] PACKAGE BODY name IS ... END [name]

func (*PackageBody) End

func (p *PackageBody) End() Pos

func (*PackageBody) Pos

func (p *PackageBody) Pos() Pos

type PackageSpec

type PackageSpec struct {
	OrReplace bool
	Schema    *Ident
	Name      *Ident
	Decls     []Decl // types, variables, cursors, subprogram specs
	AuthId    token.Token
	PosVal    Pos
	EndPos    Pos
}

PackageSpec represents CREATE [OR REPLACE] PACKAGE name IS ... END [name]

func (*PackageSpec) End

func (p *PackageSpec) End() Pos

func (*PackageSpec) Pos

func (p *PackageSpec) Pos() Pos

type ParamDecl

type ParamDecl struct {
	Name    *Ident
	Mode    token.Token // IN, OUT, INOUT (IN OUT = INOUT)
	NoCopy  bool
	Type    *PlsqlType
	Default Expr
	PosVal  Pos
	EndVal  Pos
}

ParamDecl represents a parameter: name [IN|OUT|IN OUT] type [:= expr | DEFAULT expr]

func (*ParamDecl) End

func (p *ParamDecl) End() Pos

func (*ParamDecl) Pos

func (p *ParamDecl) Pos() Pos

type ParenExpr

type ParenExpr struct {
	Expr   Expr
	Lparen Pos
	Rparen Pos
}

ParenExpr represents a parenthesized expression: (expr)

func (*ParenExpr) End

func (p *ParenExpr) End() Pos

func (*ParenExpr) Pos

func (p *ParenExpr) Pos() Pos

type PartitionClause

type PartitionClause struct {
	Type         token.Token // RANGE, LIST, HASH
	Columns      []*Ident
	Partitions   []*PartitionDef
	SubPartition *PartitionClause
}

PartitionClause represents PARTITION BY ...

type PartitionDef

type PartitionDef struct {
	Name       *Ident
	Values     Expr // VALUES LESS THAN (...), VALUES (...)
	Tablespace string
	Storage    *StorageClause
}

PartitionDef represents a single partition definition.

type PipeRowStmt

type PipeRowStmt struct {
	Value  Expr
	PosVal Pos
	EndVal Pos
}

PipeRowStmt represents PIPE ROW(value)

func (*PipeRowStmt) End

func (p *PipeRowStmt) End() Pos

func (*PipeRowStmt) Pos

func (p *PipeRowStmt) Pos() Pos

type PlaceholderExpr

type PlaceholderExpr struct {
	PosVal Pos
}

PlaceholderExpr is a temporary placeholder for expressions not yet fully typed in the AST.

func (*PlaceholderExpr) End

func (p *PlaceholderExpr) End() Pos

func (*PlaceholderExpr) Pos

func (p *PlaceholderExpr) Pos() Pos

type PlsqlBlock

type PlsqlBlock struct {
	Label      *Ident              // optional block label
	Declare    []Decl              // DECLARE section (variables, types, cursors, etc.)
	Body       []PlsqlStmt         // BEGIN ... body statements
	Exceptions []*ExceptionHandler // EXCEPTION section
	IsNamed    bool                // true for named blocks (procedure/function body), skips DECLARE
	EndPos     Pos
	PosVal     Pos
}

PlsqlBlock represents an anonymous or nested PL/SQL block. This is the fundamental PL/SQL structure: DECLARE ... BEGIN ... EXCEPTION ... END;

func (*PlsqlBlock) End

func (p *PlsqlBlock) End() Pos

func (*PlsqlBlock) Pos

func (p *PlsqlBlock) Pos() Pos

type PlsqlStmt

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

PlsqlStmt is the interface for all PL/SQL procedural statements.

type PlsqlType

type PlsqlType struct {
	Name           *QualifiedName
	PercentType    bool // true for %TYPE
	PercentRowtype bool // true for %ROWTYPE
	Size           *BasicLit
	Scale          *BasicLit
	Charset        string
	PosVal         Pos
	EndVal         Pos
}

PlsqlType represents a PL/SQL type reference (can be anchored %TYPE or %ROWTYPE).

func (*PlsqlType) End

func (p *PlsqlType) End() Pos

func (*PlsqlType) Pos

func (p *PlsqlType) Pos() Pos

type PlsqlTypeDef

type PlsqlTypeDef struct {
	Kind            token.Token // RECORD, TABLE, VARRAY, REF_CURSOR
	RecordFields    []*VarDecl
	OfType          *PlsqlType // for TABLE OF type
	IndexBy         *PlsqlType // INDEX BY type
	Varraysize      int        // for VARRAY(size)
	RefCursorReturn *TypeSpec  // RETURN type for REF CURSOR
	PosVal          Pos
}

PlsqlTypeDef represents the type definition part: IS RECORD (...), IS TABLE OF ..., IS REF CURSOR

type Pos

type Pos = token.Pos

token.Pos is an alias for convenience.

const NoPos Pos = 0

NoPos is the zero value of Pos; it means "no position information".

type PragmaDecl

type PragmaDecl struct {
	Kind      token.Token // AUTONOMOUS_TRANSACTION, EXCEPTION_INIT, SERIALLY_REUSABLE, INLINE
	Name      *Ident      // for EXCEPTION_INIT: exception name
	ErrorCode int64       // for EXCEPTION_INIT: error number
	PosVal    Pos
	EndVal    Pos
}

PragmaDecl represents a PRAGMA directive.

func (*PragmaDecl) End

func (p *PragmaDecl) End() Pos

func (*PragmaDecl) Pos

func (p *PragmaDecl) Pos() Pos

type ProcCallStmt

type ProcCallStmt struct {
	Name   *QualifiedName
	Args   []*CallArg
	PosVal Pos
	EndVal Pos
}

ProcCallStmt represents a procedure or function call as a statement.

func (*ProcCallStmt) End

func (p *ProcCallStmt) End() Pos

func (*ProcCallStmt) Pos

func (p *ProcCallStmt) Pos() Pos

type ProcedureDecl

type ProcedureDecl struct {
	OrReplace bool
	Schema    *Ident
	Name      *Ident
	Params    []*ParamDecl
	AuthId    token.Token // DEFINER or CURRENT_USER
	Block     *PlsqlBlock
	IsNested  bool // true for nested subprogram in DECLARE section
	PosVal    Pos
	EndVal    Pos
}

ProcedureDecl represents CREATE [OR REPLACE] PROCEDURE name ... When IsNested is true, this is a nested subprogram in a declaration section.

func (*ProcedureDecl) End

func (p *ProcedureDecl) End() Pos

func (*ProcedureDecl) Pos

func (p *ProcedureDecl) Pos() Pos

type QualifiedName

type QualifiedName struct {
	Parts  []*Ident // parts of the qualified name (length 1..N)
	Star   bool     // true if ends with .*
	PosVal Pos
}

QualifiedName represents a multi-part name like schema.table.column or table.*

func (*QualifiedName) End

func (q *QualifiedName) End() Pos

func (*QualifiedName) Pos

func (q *QualifiedName) Pos() Pos

type RaiseAppErrorStmt

type RaiseAppErrorStmt struct {
	Code    Expr
	Message Expr
	PosVal  Pos
	EndVal  Pos
}

RaiseAppErrorStmt represents RAISE_APPLICATION_ERROR(code, message)

func (*RaiseAppErrorStmt) End

func (r *RaiseAppErrorStmt) End() Pos

func (*RaiseAppErrorStmt) Pos

func (r *RaiseAppErrorStmt) Pos() Pos

type RaiseStmt

type RaiseStmt struct {
	Exception *Ident // nil for re-raise
	PosVal    Pos
	EndVal    Pos
}

RaiseStmt represents RAISE [exception]

func (*RaiseStmt) End

func (r *RaiseStmt) End() Pos

func (*RaiseStmt) Pos

func (r *RaiseStmt) Pos() Pos

type ReferencesClause

type ReferencesClause struct {
	Table    *QualifiedName
	Columns  []*Ident
	OnDelete token.Token // CASCADE, SET NULL, NO ACTION
}

ReferencesClause represents REFERENCES table [(cols)]

type ReturnStmt

type ReturnStmt struct {
	Value  Expr // nil for procedure return
	PosVal Pos
	EndVal Pos
}

ReturnStmt represents RETURN [expr]

func (*ReturnStmt) End

func (r *ReturnStmt) End() Pos

func (*ReturnStmt) Pos

func (r *ReturnStmt) Pos() Pos

type ReturningClause

type ReturningClause struct {
	Exprs  []Expr
	Into   []*Ident
	PosVal Pos
	EndVal Pos
}

ReturningClause represents RETURNING expr INTO var

func (*ReturningClause) End

func (r *ReturningClause) End() Pos

func (*ReturningClause) Pos

func (r *ReturningClause) Pos() Pos

type RevokeStmt

type RevokeStmt struct {
	Privileges []string
	On         *QualifiedName
	From       []string
	PosVal     Pos
	EndVal     Pos
}

RevokeStmt represents REVOKE.

func (*RevokeStmt) End

func (r *RevokeStmt) End() Pos

func (*RevokeStmt) Pos

func (r *RevokeStmt) Pos() Pos

type RollbackStmt

type RollbackStmt struct {
	Work        bool
	ToSavepoint *Ident
	PosVal      Pos
	EndVal      Pos
}

RollbackStmt represents ROLLBACK.

func (*RollbackStmt) End

func (r *RollbackStmt) End() Pos

func (*RollbackStmt) Pos

func (r *RollbackStmt) Pos() Pos

type SavepointStmt

type SavepointStmt struct {
	Name   *Ident
	PosVal Pos
	EndVal Pos
}

SavepointStmt represents SAVEPOINT.

func (*SavepointStmt) End

func (s *SavepointStmt) End() Pos

func (*SavepointStmt) Pos

func (s *SavepointStmt) Pos() Pos

type SelectElem

type SelectElem struct {
	Expr   Expr   // the expression or StarExpr
	Alias  *Ident // optional alias
	PosVal Pos
}

SelectElem represents a single element in the SELECT list.

func (*SelectElem) End

func (s *SelectElem) End() Pos

func (*SelectElem) Pos

func (s *SelectElem) Pos() Pos

type SelectStmt

type SelectStmt struct {
	With       *WithClause // optional WITH clause (CTE)
	Hints      string      // optimizer hints
	Distinct   bool
	All        bool
	SelectList []*SelectElem
	Into       []*QualifiedName // PL/SQL SELECT INTO variables (may be record.fields)
	From       []*TableRef      // FROM clause
	Where      Expr             // WHERE condition
	ConnectBy  Expr             // CONNECT BY (hierarchical)
	StartWith  Expr             // START WITH (hierarchical)
	GroupBy    []Expr           // GROUP BY expressions
	Having     Expr             // HAVING condition
	OrderBy    []*OrderByElem
	ForUpdate  *ForUpdateClause
	Offset     Expr         // OFFSET n ROWS
	Fetch      *FetchClause // FETCH FIRST/NEXT n ROWS ONLY
	Union      *UnionClause // UNION/INTERSECT/MINUS following query
	PosVal     Pos
	EndVal     Pos
}

SelectStmt represents a SELECT statement.

func (*SelectStmt) End

func (s *SelectStmt) End() Pos

func (*SelectStmt) Pos

func (s *SelectStmt) Pos() Pos

type SetExpr

type SetExpr struct {
	Column *QualifiedName
	Value  Expr
}

SetExpr represents col = value in SET clause.

type StarExpr

type StarExpr struct {
	Qualifier *QualifiedName // nil for bare *
	StarPos   Pos
}

StarExpr represents * or table.* in a SELECT list.

func (*StarExpr) End

func (s *StarExpr) End() Pos

func (*StarExpr) Pos

func (s *StarExpr) Pos() Pos

type Stmt

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

Stmt is the interface satisfied by all statement nodes (SELECT, INSERT, etc.).

type StorageClause

type StorageClause struct {
	Initial     int64
	Next        int64
	MaxExtents  int64
	PctFree     int
	PctUsed     int
	PctIncrease int
	Tablespace  string
}

StorageClause represents Oracle storage clause.

type SubprogramSpec

type SubprogramSpec struct {
	IsFunc     bool
	Name       *Ident
	Params     []*ParamDecl
	ReturnType *PlsqlType // only for functions
	PosVal     Pos
	EndVal     Pos
}

SubprogramSpec represents a procedure or function specification in a package.

func (*SubprogramSpec) End

func (s *SubprogramSpec) End() Pos

func (*SubprogramSpec) Pos

func (s *SubprogramSpec) Pos() Pos

type Subquery

type Subquery struct {
	Select *SelectStmt
	Lparen Pos
	Rparen Pos
}

Subquery represents a (SELECT ...) subquery in an expression context.

func (*Subquery) End

func (s *Subquery) End() Pos

func (*Subquery) Pos

func (s *Subquery) Pos() Pos

type SubstVar

type SubstVar struct {
	Name   string
	Double bool // true if &&
	PosVal Pos
	EndVal Pos
}

SubstVar represents a substitution variable: &var, &&var

func (*SubstVar) End

func (s *SubstVar) End() Pos

func (*SubstVar) Pos

func (s *SubstVar) Pos() Pos

type TableRef

type TableRef struct {
	Name            *QualifiedName
	FuncCall        *CallExpr // table-valued function: func(...) in FROM
	TableCollection Expr      // TABLE(collection_expr) in FROM
	Alias           *Ident
	Subquery        *Subquery   // FROM (SELECT ...)
	Join            *JoinClause // for join expressions
	Flashback       Expr        // AS OF flashback
	PosVal          Pos
}

TableRef represents a table reference in FROM clause.

func (*TableRef) End

func (t *TableRef) End() Pos

func (*TableRef) Pos

func (t *TableRef) Pos() Pos

type TriggerDecl

type TriggerDecl struct {
	OrReplace    bool
	Schema       *Ident
	Name         *Ident
	Before       bool // true = BEFORE, false = AFTER
	InsteadOf    bool
	Events       []*TriggerEvent
	On           *QualifiedName
	Referencing  *TriggerReferencing
	ForEachRow   bool
	When         Expr
	Enable       *bool // nil = default, true = ENABLE, false = DISABLE
	Follows      *Ident
	CompoundTrig *PlsqlBlock // for compound triggers
	Block        *PlsqlBlock
	PosVal       Pos
	EndVal       Pos
}

TriggerDecl represents CREATE [OR REPLACE] TRIGGER name ...

func (*TriggerDecl) End

func (t *TriggerDecl) End() Pos

func (*TriggerDecl) Pos

func (t *TriggerDecl) Pos() Pos

type TriggerEvent

type TriggerEvent struct {
	Kind token.Token // INSERT, UPDATE, DELETE
	Of   []*Ident    // UPDATE OF column list
}

TriggerEvent represents INSERT, UPDATE, DELETE in a trigger event list.

type TriggerReferencing

type TriggerReferencing struct {
	Old *Ident
	New *Ident
}

TriggerReferencing represents REFERENCING OLD AS ... NEW AS ...

type TruncateStmt

type TruncateStmt struct {
	Name         *QualifiedName
	ReuseStorage bool
	Cascade      bool
	PosVal       Pos
	EndVal       Pos
}

TruncateStmt represents TRUNCATE TABLE.

func (*TruncateStmt) End

func (t *TruncateStmt) End() Pos

func (*TruncateStmt) Pos

func (t *TruncateStmt) Pos() Pos

type TypeDecl

type TypeDecl struct {
	Name    *Ident
	TypeDef *PlsqlTypeDef
	PosVal  Pos
	EndVal  Pos
}

TypeDecl represents a PL/SQL type declaration: TYPE name IS ...

func (*TypeDecl) End

func (t *TypeDecl) End() Pos

func (*TypeDecl) Pos

func (t *TypeDecl) Pos() Pos

type TypeSpec

type TypeSpec struct {
	Name    string    // NUMBER, VARCHAR2, DATE, etc.
	Size    *BasicLit // length/precision
	Scale   *BasicLit // scale for NUMBER
	Charset string    // CHARACTER SET ...
	PosVal  Pos
	EndVal  Pos
}

TypeSpec represents a data type specification: NUMBER(10,2), VARCHAR2(100), etc.

func (*TypeSpec) End

func (t *TypeSpec) End() Pos

func (*TypeSpec) Pos

func (t *TypeSpec) Pos() Pos

type UnaryExpr

type UnaryExpr struct {
	Op    token.Token
	Expr  Expr
	OpPos Pos
}

UnaryExpr represents a unary operation expression: -a, NOT a, PRIOR a.

func (*UnaryExpr) End

func (u *UnaryExpr) End() Pos

func (*UnaryExpr) Pos

func (u *UnaryExpr) Pos() Pos

type UnionClause

type UnionClause struct {
	Type  token.Token // UNION, INTERSECT, MINUS
	All   bool
	Right *SelectStmt
}

UnionClause represents UNION [ALL], INTERSECT, MINUS set operations.

func (*UnionClause) End

func (u *UnionClause) End() Pos

func (*UnionClause) Pos

func (u *UnionClause) Pos() Pos

type UpdateStmt

type UpdateStmt struct {
	Hints     string
	Table     *QualifiedName
	Alias     *Ident
	SetClause []*SetExpr
	From      []*TableRef // FROM clause (for subquery-based update)
	Where     Expr
	Returning *ReturningClause
	PosVal    Pos
	EndVal    Pos
}

UpdateStmt represents an UPDATE statement.

func (*UpdateStmt) End

func (u *UpdateStmt) End() Pos

func (*UpdateStmt) Pos

func (u *UpdateStmt) Pos() Pos

type VarDecl

type VarDecl struct {
	Name    *Ident
	Const   bool
	Type    *PlsqlType
	NotNull bool
	Default Expr // := or DEFAULT value
	PosVal  Pos
	EndVal  Pos
}

VarDecl represents a variable declaration: name [CONSTANT] type [NOT NULL] [:= expr | DEFAULT expr]

func (*VarDecl) End

func (v *VarDecl) End() Pos

func (*VarDecl) Pos

func (v *VarDecl) Pos() Pos

type Visitor

type Visitor interface {
	Visit(node Node) (w Visitor)
}

Visitor is the interface for AST visitors.

type WhenClause

type WhenClause struct {
	Cond Expr
	Val  Expr
}

WhenClause represents WHEN condition THEN result.

type WhileStmt

type WhileStmt struct {
	Label  *Ident
	Cond   Expr
	Body   []PlsqlStmt
	PosVal Pos
	EndPos Pos
}

WhileStmt represents WHILE condition LOOP ... END LOOP

func (*WhileStmt) End

func (w *WhileStmt) End() Pos

func (*WhileStmt) Pos

func (w *WhileStmt) Pos() Pos

type WindowBound

type WindowBound struct {
	Kind  token.Token // UNBOUNDED PRECEDING, CURRENT ROW, value PRECEDING/FOLLOWING
	Value Expr
}

WindowBound represents a single bound in a windowing clause.

type WindowingClause

type WindowingClause struct {
	Type  token.Token // ROWS or RANGE
	Start *WindowBound
	End   *WindowBound
}

WindowingClause represents ROWS/RANGE BETWEEN ... AND ...

type WithClause

type WithClause struct {
	Recursive bool
	CTEs      []*CTEDef
}

WithClause represents the WITH (subquery factoring) clause.

type WithinGroupClause

type WithinGroupClause struct {
	OrderBy []*OrderByElem
	EndVal  Pos
}

WithinGroupClause represents WITHIN GROUP (ORDER BY ...) for ordered-set aggregates.

func (*WithinGroupClause) End

func (w *WithinGroupClause) End() Pos

func (*WithinGroupClause) Pos

func (w *WithinGroupClause) Pos() Pos

Source Files

  • ast.go
  • plsql.go
  • stmt.go

Jump to

Keyboard shortcuts

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