Documentation
¶
Overview ¶
Package ast declares the types used to represent Oracle SQL and PL/SQL Abstract Syntax Trees.
Index ¶
- func Fprint(w io.Writer, node Node)
- func Walk(v Visitor, node Node)
- func WalkAll(v Visitor, node Node)
- type AlterAction
- type AlterTableStmt
- type AssignmentStmt
- type BasicLit
- type BetweenExpr
- type BinaryExpr
- type BindVar
- type BoolLit
- type CTEDef
- type CallArg
- type CallExpr
- type CaseExpr
- type CaseStmt
- type CaseWhenBranch
- type CastExpr
- type CloseStmt
- type ColumnDef
- type CommitStmt
- type ConstraintDef
- type ContinueStmt
- type CreateIndexStmt
- type CreateSequenceStmt
- type CreateSynonymStmt
- type CreateTableStmt
- type CreateViewStmt
- type CursorDecl
- type CursorExpr
- type CursorForStmt
- type DDLStmt
- type Decl
- type DeleteStmt
- type DropStmt
- type ElsifBranch
- type ExceptionDecl
- type ExceptionHandler
- type ExecuteImmediateStmt
- type ExistsExpr
- type ExitStmt
- type Expr
- type FetchClause
- type FetchStmt_plsql
- type File
- type ForAllStmt
- type ForStmt
- type ForUpdateClause
- type FunctionDecl
- type GotoStmt
- type GrantStmt
- type Ident
- type IdentityClause
- type IfStmt
- type InExpr
- type IndexColumn
- type InsertStmt
- type IntervalExpr
- type IsExpr
- type JoinClause
- type LabelStmt
- type LikeExpr
- type LoopStmt
- type MergeSource
- type MergeStmt
- type MergeWhen
- type MultiTableInsert
- type MultiTableInto
- type MultiTableWhen
- type Node
- type NullLit
- type NullStmt
- type OpenStmt
- type OrderByElem
- type OverClause
- type PackageBody
- type PackageSpec
- type ParamDecl
- type ParenExpr
- type PartitionClause
- type PartitionDef
- type PipeRowStmt
- type PlaceholderExpr
- type PlsqlBlock
- type PlsqlStmt
- type PlsqlType
- type PlsqlTypeDef
- type Pos
- type PragmaDecl
- type ProcCallStmt
- type ProcedureDecl
- type QualifiedName
- type RaiseAppErrorStmt
- type RaiseStmt
- type ReferencesClause
- type ReturnStmt
- type ReturningClause
- type RevokeStmt
- type RollbackStmt
- type SavepointStmt
- type SelectElem
- type SelectStmt
- type SetExpr
- type StarExpr
- type Stmt
- type StorageClause
- type SubprogramSpec
- type Subquery
- type SubstVar
- type TableRef
- type TriggerDecl
- type TriggerEvent
- type TriggerReferencing
- type TruncateStmt
- type TypeDecl
- type TypeSpec
- type UnaryExpr
- type UnionClause
- type UpdateStmt
- type VarDecl
- type Visitor
- type WhenClause
- type WhileStmt
- type WindowBound
- type WindowingClause
- type WithClause
- type WithinGroupClause
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fprint ¶
Fprint prints the AST to the writer in a human-readable format.
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 ¶
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).
type BetweenExpr ¶
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 ¶
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 ¶
BindVar represents a bind variable: :var, :1, :"name"
type BoolLit ¶
BoolLit represents TRUE or FALSE in PL/SQL.
type CTEDef ¶
type CTEDef struct {
Name *Ident
Columns []*Ident
Query *SelectStmt
}
CTEDef represents a single CTE: name [(cols)] AS (subquery)
type CallArg ¶
CallArg represents an argument in a procedure call: [name =>] value. Implements ast.Expr so it can be used wherever an expression is expected.
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).
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
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
type CaseWhenBranch ¶
CaseWhenBranch represents WHEN condition THEN statements
type CastExpr ¶
CastExpr represents CAST(expr AS type)
type CloseStmt ¶
CloseStmt represents CLOSE cursor
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.
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 ¶
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.)
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.
type ElsifBranch ¶
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 ¶
ExistsExpr represents EXISTS (subquery)
func (*ExistsExpr) End ¶
func (e *ExistsExpr) End() Pos
func (*ExistsExpr) Pos ¶
func (e *ExistsExpr) Pos() Pos
type ExitStmt ¶
ExitStmt represents EXIT [label] [WHEN condition]
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) HasErrors ¶
HasErrors returns true if the parse encountered errors.
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
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 ¶
GotoStmt represents GOTO label
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.
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) Lowered ¶
Lowered returns the lower-cased name for case-insensitive comparison.
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
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)
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 ¶
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.
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 ¶
LabelStmt represents <<label>>
type LikeExpr ¶
LikeExpr represents value [NOT] LIKE pattern [ESCAPE esc]
type LoopStmt ¶
LoopStmt represents LOOP ... END LOOP [label]
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.
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 NullStmt ¶
NullStmt represents the NULL statement.
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]
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]
type ParenExpr ¶
ParenExpr represents a parenthesized expression: (expr)
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 ¶
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).
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 ¶
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 ¶
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 ¶
RaiseStmt represents RAISE [exception]
type ReferencesClause ¶
type ReferencesClause struct {
Table *QualifiedName
Columns []*Ident
OnDelete token.Token // CASCADE, SET NULL, NO ACTION
}
ReferencesClause represents REFERENCES table [(cols)]
type ReturnStmt ¶
ReturnStmt represents RETURN [expr]
func (*ReturnStmt) End ¶
func (r *ReturnStmt) End() Pos
func (*ReturnStmt) Pos ¶
func (r *ReturnStmt) Pos() Pos
type ReturningClause ¶
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 ¶
RollbackStmt represents ROLLBACK.
func (*RollbackStmt) End ¶
func (r *RollbackStmt) End() Pos
func (*RollbackStmt) Pos ¶
func (r *RollbackStmt) Pos() Pos
type SavepointStmt ¶
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.
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.
type SubstVar ¶
SubstVar represents a substitution variable: &var, &&var
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.
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 ¶
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 ...
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.
type UnaryExpr ¶
UnaryExpr represents a unary operation expression: -a, NOT a, PRIOR a.
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]
type Visitor ¶
Visitor is the interface for AST visitors.
type WhenClause ¶
WhenClause represents WHEN condition THEN result.
type WhileStmt ¶
WhileStmt represents WHILE condition LOOP ... END LOOP
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 ¶
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