Documentation
¶
Index ¶
- type Assert
- type Assignment
- type Block
- type Call
- type Case
- type CaseWhen
- type Close
- type Condition
- type Continue
- type CursorDeclaration
- type Declaration
- type DoBlock
- type DynamicExecute
- type ElseIf
- type Exception
- type Execute
- type Exit
- type Expr
- type Fetch
- type ForEachArray
- type ForLoop
- type ForLoopControl
- type GetDiagnostics
- type GetDiagnosticsItem
- type GetDiagnosticsItemList
- type GetDiagnosticsKind
- type If
- type IntForLoopControl
- type Loop
- type Null
- type Open
- type Perform
- type Raise
- type RaiseOption
- type Return
- type ReturnNext
- type ReturnQuery
- type SQLStmtVisitor
- type Statement
- type StatementImpl
- type StatementVisitor
- type TransactionControl
- type TypeRefVisitor
- type Variable
- type While
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assert ¶
type Assert struct {
StatementImpl
Condition Expr
Message Expr
}
stmt_assert
func (*Assert) PlpgSQLStatementTag ¶
func (*Assert) WalkStmt ¶
func (s *Assert) WalkStmt(visitor StatementVisitor) Statement
type Assignment ¶
type Assignment struct {
StatementImpl
Var Variable
Value Expr
// Indirection is the optional name of a field in a composite variable. For
// example, in the assignment "foo.bar := 1", Indirection would be "bar".
Indirection tree.Name
}
stmt_assign
func (*Assignment) CopyNode ¶
func (s *Assignment) CopyNode() *Assignment
func (*Assignment) Format ¶
func (s *Assignment) Format(ctx *tree.FmtCtx)
func (*Assignment) PlpgSQLStatementTag ¶
func (s *Assignment) PlpgSQLStatementTag() string
func (*Assignment) WalkStmt ¶
func (s *Assignment) WalkStmt(visitor StatementVisitor) Statement
type Block ¶
type Block struct {
StatementImpl
Label string
Decls []Statement
Body []Statement
Exceptions []Exception
}
pl_block
func (*Block) PlpgSQLStatementTag ¶
func (*Block) WalkStmt ¶
func (s *Block) WalkStmt(visitor StatementVisitor) Statement
type Call ¶
type Call struct {
StatementImpl
Proc *tree.FuncExpr
}
stmt_call
func (*Call) PlpgSQLStatementTag ¶
func (*Call) WalkStmt ¶
func (s *Call) WalkStmt(visitor StatementVisitor) Statement
type Case ¶
type Case struct {
StatementImpl
// TODO(drewk): Change to Expr
TestExpr string
Var Variable
CaseWhenList []*CaseWhen
HaveElse bool
ElseStmts []Statement
}
stmt_case
func (*Case) Format ¶
TODO(drewk): fix the whitespace/newline formatting for CASE (see the stmt_case test file).
func (*Case) PlpgSQLStatementTag ¶
func (*Case) WalkStmt ¶
func (s *Case) WalkStmt(visitor StatementVisitor) Statement
type CaseWhen ¶
type CaseWhen struct {
StatementImpl
// TODO(drewk): Change to Expr
Expr string
Stmts []Statement
}
func (*CaseWhen) PlpgSQLStatementTag ¶
func (*CaseWhen) WalkStmt ¶
func (s *CaseWhen) WalkStmt(visitor StatementVisitor) Statement
type Close ¶
type Close struct {
StatementImpl
CurVar Variable
}
stmt_close
func (*Close) PlpgSQLStatementTag ¶
func (*Close) WalkStmt ¶
func (s *Close) WalkStmt(visitor StatementVisitor) Statement
type Continue ¶
type Continue struct {
StatementImpl
Label string
Condition Expr
}
stmt_continue
func (*Continue) PlpgSQLStatementTag ¶
func (*Continue) WalkStmt ¶
func (s *Continue) WalkStmt(visitor StatementVisitor) Statement
type CursorDeclaration ¶
type CursorDeclaration struct {
StatementImpl
Name Variable
Scroll tree.CursorScrollOption
Query tree.Statement
Annotations *tree.Annotations
}
func (*CursorDeclaration) CopyNode ¶
func (s *CursorDeclaration) CopyNode() *CursorDeclaration
func (*CursorDeclaration) Format ¶
func (s *CursorDeclaration) Format(ctx *tree.FmtCtx)
func (*CursorDeclaration) PlpgSQLStatementTag ¶
func (s *CursorDeclaration) PlpgSQLStatementTag() string
func (*CursorDeclaration) WalkStmt ¶
func (s *CursorDeclaration) WalkStmt(visitor StatementVisitor) Statement
type Declaration ¶
type Declaration struct {
StatementImpl
Var Variable
Constant bool
Typ tree.ResolvableTypeReference
Collate string
NotNull bool
Expr Expr
}
decl_stmt
func (*Declaration) CopyNode ¶
func (s *Declaration) CopyNode() *Declaration
func (*Declaration) Format ¶
func (s *Declaration) Format(ctx *tree.FmtCtx)
func (*Declaration) PlpgSQLStatementTag ¶
func (s *Declaration) PlpgSQLStatementTag() string
func (*Declaration) WalkStmt ¶
func (s *Declaration) WalkStmt(visitor StatementVisitor) Statement
type DoBlock ¶ added in v0.25.2
type DoBlock struct {
StatementImpl
// Block is the code block that defines the logic of the DO statement.
Block *Block
}
stmt_do
func (*DoBlock) IsDoBlockBody ¶ added in v0.25.2
func (s *DoBlock) IsDoBlockBody()
func (*DoBlock) PlpgSQLStatementTag ¶ added in v0.25.2
func (*DoBlock) VisitBody ¶ added in v0.25.2
func (s *DoBlock) VisitBody(v tree.Visitor) tree.DoBlockBody
func (*DoBlock) WalkStmt ¶ added in v0.25.2
func (s *DoBlock) WalkStmt(visitor StatementVisitor) Statement
type DynamicExecute ¶
type DynamicExecute struct {
StatementImpl
Query string
Into bool
Strict bool
Target Variable
Params []Expr
}
stmt_dynexecute TODO(chengxiong): query should be a better expression type.
func (*DynamicExecute) CopyNode ¶
func (s *DynamicExecute) CopyNode() *DynamicExecute
func (*DynamicExecute) Format ¶
func (s *DynamicExecute) Format(ctx *tree.FmtCtx)
func (*DynamicExecute) PlpgSQLStatementTag ¶
func (s *DynamicExecute) PlpgSQLStatementTag() string
func (*DynamicExecute) WalkStmt ¶
func (s *DynamicExecute) WalkStmt(visitor StatementVisitor) Statement
type ElseIf ¶
type ElseIf struct {
StatementImpl
Condition Expr
Stmts []Statement
}
func (*ElseIf) PlpgSQLStatementTag ¶
func (*ElseIf) WalkStmt ¶
func (s *ElseIf) WalkStmt(visitor StatementVisitor) Statement
type Exception ¶
type Exception struct {
StatementImpl
Conditions []Condition
Action []Statement
}
func (*Exception) PlpgSQLStatementTag ¶
func (*Exception) WalkStmt ¶
func (s *Exception) WalkStmt(visitor StatementVisitor) Statement
type Execute ¶
type Execute struct {
StatementImpl
SqlStmt tree.Statement
Strict bool // INTO STRICT flag
Target []Variable
Annotations *tree.Annotations
}
stmt_execsql
func (*Execute) PlpgSQLStatementTag ¶
func (*Execute) WalkStmt ¶
func (s *Execute) WalkStmt(visitor StatementVisitor) Statement
type Exit ¶
type Exit struct {
StatementImpl
Label string
Condition Expr
}
stmt_exit
func (*Exit) PlpgSQLStatementTag ¶
func (*Exit) WalkStmt ¶
func (s *Exit) WalkStmt(visitor StatementVisitor) Statement
type Fetch ¶
type Fetch struct {
StatementImpl
Cursor tree.CursorStmt
Target []Variable
IsMove bool
Annotations *tree.Annotations
}
stmt_fetch stmt_move (where IsMove = true)
func (*Fetch) PlpgSQLStatementTag ¶
func (*Fetch) WalkStmt ¶
func (s *Fetch) WalkStmt(visitor StatementVisitor) Statement
type ForEachArray ¶
type ForEachArray struct {
StatementImpl
Label string
Var *Variable
Slice int // TODO(drewk): not sure what this is
Expr Expr
Body []Statement
}
stmt_foreach_a
func (*ForEachArray) Format ¶
func (s *ForEachArray) Format(ctx *tree.FmtCtx)
func (*ForEachArray) PlpgSQLStatementTag ¶
func (s *ForEachArray) PlpgSQLStatementTag() string
func (*ForEachArray) WalkStmt ¶
func (s *ForEachArray) WalkStmt(visitor StatementVisitor) Statement
type ForLoop ¶ added in v0.25.2
type ForLoop struct {
StatementImpl
Label string
Target []Variable
Control ForLoopControl
Body []Statement
}
stmt_for
func (*ForLoop) PlpgSQLStatementTag ¶ added in v0.25.2
func (*ForLoop) WalkStmt ¶ added in v0.25.2
func (s *ForLoop) WalkStmt(visitor StatementVisitor) Statement
type ForLoopControl ¶ added in v0.25.2
type ForLoopControl interface {
Format(ctx *tree.FmtCtx)
// contains filtered or unexported methods
}
ForLoopControl is an interface covering the loop control structures for the integer range, query, and cursor FOR loops.
type GetDiagnostics ¶
type GetDiagnostics struct {
StatementImpl
IsStacked bool
DiagItems GetDiagnosticsItemList // TODO(drewk): what is this?
}
stmt_getdiag
func (*GetDiagnostics) Format ¶
func (s *GetDiagnostics) Format(ctx *tree.FmtCtx)
func (*GetDiagnostics) PlpgSQLStatementTag ¶
func (s *GetDiagnostics) PlpgSQLStatementTag() string
func (*GetDiagnostics) WalkStmt ¶
func (s *GetDiagnostics) WalkStmt(visitor StatementVisitor) Statement
type GetDiagnosticsItem ¶
type GetDiagnosticsItem struct {
Kind GetDiagnosticsKind
// TODO(drewk): TargetName is temporary -- should be removed and use Target.
TargetName string
Target int // where to assign it?
}
func (*GetDiagnosticsItem) Format ¶
func (s *GetDiagnosticsItem) Format(ctx *tree.FmtCtx)
type GetDiagnosticsItemList ¶
type GetDiagnosticsItemList []*GetDiagnosticsItem
type GetDiagnosticsKind ¶
type GetDiagnosticsKind int
GetDiagnosticsKind represents the type of error diagnostic item in stmt_getdiag.
const ( // GetDiagnosticsRowCount returns the number of rows processed by the recent // SQL command. GetDiagnosticsRowCount GetDiagnosticsKind = iota // GetDiagnosticsContext returns text describing the current call stack. GetDiagnosticsContext // GetDiagnosticsErrorContext returns text describing the exception's // callstack. GetDiagnosticsErrorContext // GetDiagnosticsErrorDetail returns the exceptions detail message. GetDiagnosticsErrorDetail // GetDiagnosticsErrorHint returns the exceptions hint message. GetDiagnosticsErrorHint // GetDiagnosticsReturnedSQLState returns the SQLSTATE error code related to // the exception. GetDiagnosticsReturnedSQLState // GetDiagnosticsColumnName returns the column name related to the exception. GetDiagnosticsColumnName // GetDiagnosticsConstraintName returns the constraint name related to // the exception. GetDiagnosticsConstraintName // GetDiagnosticsDatatypeName returns the data type name related to the // exception. GetDiagnosticsDatatypeName // GetDiagnosticsMessageText returns the exceptions primary message. GetDiagnosticsMessageText // GetDiagnosticsTableName returns the name of the table related to the // exception. GetDiagnosticsTableName // GetDiagnosticsSchemaName returns the name of the schema related to the // exception. GetDiagnosticsSchemaName )
func (GetDiagnosticsKind) String ¶
func (k GetDiagnosticsKind) String() string
String implements the fmt.Stringer interface.
type If ¶
type If struct {
StatementImpl
Condition Expr
ThenBody []Statement
ElseIfList []ElseIf
ElseBody []Statement
}
stmt_if
func (*If) PlpgSQLStatementTag ¶
func (*If) WalkStmt ¶
func (s *If) WalkStmt(visitor StatementVisitor) Statement
type IntForLoopControl ¶ added in v0.25.2
func (*IntForLoopControl) Format ¶ added in v0.25.2
func (c *IntForLoopControl) Format(ctx *tree.FmtCtx)
type Loop ¶
type Loop struct {
StatementImpl
Label string
Body []Statement
}
stmt_loop
func (*Loop) PlpgSQLStatementTag ¶
func (*Loop) WalkStmt ¶
func (s *Loop) WalkStmt(visitor StatementVisitor) Statement
type Null ¶
type Null struct {
StatementImpl
}
stmt_null
func (*Null) PlpgSQLStatementTag ¶
func (*Null) WalkStmt ¶
func (s *Null) WalkStmt(visitor StatementVisitor) Statement
type Open ¶
type Open struct {
StatementImpl
CurVar Variable
Scroll tree.CursorScrollOption
Query tree.Statement
Annotations *tree.Annotations
}
stmt_open
func (*Open) PlpgSQLStatementTag ¶
func (*Open) WalkStmt ¶
func (s *Open) WalkStmt(visitor StatementVisitor) Statement
type Perform ¶
type Perform struct {
StatementImpl
Expr Expr
}
stmt_perform
func (*Perform) PlpgSQLStatementTag ¶
func (*Perform) WalkStmt ¶
func (s *Perform) WalkStmt(visitor StatementVisitor) Statement
type Raise ¶
type Raise struct {
StatementImpl
LogLevel string
Code string
CodeName string
Message string
Params []Expr
Options []RaiseOption
}
stmt_raise
func (*Raise) PlpgSQLStatementTag ¶
func (*Raise) WalkStmt ¶
func (s *Raise) WalkStmt(visitor StatementVisitor) Statement
type RaiseOption ¶
func (*RaiseOption) Format ¶
func (s *RaiseOption) Format(ctx *tree.FmtCtx)
type Return ¶
type Return struct {
StatementImpl
Expr Expr
}
stmt_return
func (*Return) PlpgSQLStatementTag ¶
func (*Return) WalkStmt ¶
func (s *Return) WalkStmt(visitor StatementVisitor) Statement
type ReturnNext ¶
type ReturnNext struct {
StatementImpl
Expr Expr
}
func (*ReturnNext) CopyNode ¶ added in v0.25.2
func (s *ReturnNext) CopyNode() *ReturnNext
func (*ReturnNext) Format ¶
func (s *ReturnNext) Format(ctx *tree.FmtCtx)
func (*ReturnNext) PlpgSQLStatementTag ¶
func (s *ReturnNext) PlpgSQLStatementTag() string
func (*ReturnNext) WalkStmt ¶
func (s *ReturnNext) WalkStmt(visitor StatementVisitor) Statement
type ReturnQuery ¶
type ReturnQuery struct {
StatementImpl
SqlStmt tree.Statement
Annotations *tree.Annotations
}
func (*ReturnQuery) CopyNode ¶ added in v0.25.2
func (s *ReturnQuery) CopyNode() *ReturnQuery
func (*ReturnQuery) Format ¶
func (s *ReturnQuery) Format(ctx *tree.FmtCtx)
func (*ReturnQuery) PlpgSQLStatementTag ¶
func (s *ReturnQuery) PlpgSQLStatementTag() string
func (*ReturnQuery) WalkStmt ¶
func (s *ReturnQuery) WalkStmt(visitor StatementVisitor) Statement
type SQLStmtVisitor ¶ added in v0.25.2
type SQLStmtVisitor struct {
Fn tree.SimpleVisitFn
Visitor tree.Visitor
Err error
}
SQLStmtVisitor applies a visitor to every SQL statement and expression found while walking the PL/pgSQL AST. SQLStmtVisitor supports using tree.v.visitExprFn for callers that don't need the full Visitor interface.
*Only one of Fn or Visitor can be set.*
type Statement ¶
type Statement interface {
tree.NodeFormatter
GetLineNo() int
GetStmtID() uint
WalkStmt(StatementVisitor) Statement
PlpgSQLStatementTag() string
// contains filtered or unexported methods
}
func Walk ¶
func Walk(v StatementVisitor, stmt Statement) Statement
Walk traverses the plpgsql statement.
type StatementImpl ¶
type StatementImpl struct {
// TODO(drewk): figure out how to get line number from scanner.
LineNo int
/*
* Unique statement ID in this function (starting at 1; 0 is invalid/not
* set). This can be used by a profiler as the index for an array of
* per-statement metrics.
*/
// TODO(drewk): figure out how to get statement id from parser.
StmtID uint
}
func (*StatementImpl) GetLineNo ¶
func (s *StatementImpl) GetLineNo() int
func (*StatementImpl) GetStmtID ¶
func (s *StatementImpl) GetStmtID() uint
type StatementVisitor ¶
type StatementVisitor interface {
// Visit is called during a statement walk. If recurse is false for a given
// node, the node's children (if any) will not be visited.
Visit(stmt Statement) (newStmt Statement, recurse bool)
}
StatementVisitor defines methods that are called plpgsql statements during a statement walk.
type TransactionControl ¶ added in v0.25.2
type TransactionControl struct {
StatementImpl
Rollback bool
Chain bool
}
stmt_commit and stmt_rollback
func (*TransactionControl) Format ¶ added in v0.25.2
func (s *TransactionControl) Format(ctx *tree.FmtCtx)
func (*TransactionControl) PlpgSQLStatementTag ¶ added in v0.25.2
func (s *TransactionControl) PlpgSQLStatementTag() string
func (*TransactionControl) WalkStmt ¶ added in v0.25.2
func (s *TransactionControl) WalkStmt(visitor StatementVisitor) Statement
type TypeRefVisitor ¶ added in v0.25.2
type TypeRefVisitor struct {
Fn func(typ tree.ResolvableTypeReference) (newTyp tree.ResolvableTypeReference, err error)
Err error
}
TypeRefVisitor calls the given replace function on each type reference contained in the visited PLpgSQL statements. Note that this currently only includes `Declaration`. SQL statements and expressions are not visited.
type While ¶
type While struct {
StatementImpl
Label string
Condition Expr
Body []Statement
}
stmt_while
func (*While) PlpgSQLStatementTag ¶
func (*While) WalkStmt ¶
func (s *While) WalkStmt(visitor StatementVisitor) Statement