plpgsqltree

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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) CopyNode

func (s *Assert) CopyNode() *Assert

func (*Assert) Format

func (s *Assert) Format(ctx *tree.FmtCtx)

func (*Assert) PlpgSQLStatementTag

func (s *Assert) PlpgSQLStatementTag() string

func (*Assert) WalkStmt

func (s *Assert) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Assignment

type Assignment struct {
	Statement
	Var   Variable
	Value Expr
}

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) (newStmt Statement, changed bool)

type Block

type Block struct {
	StatementImpl
	Label      string
	Decls      []Statement
	Body       []Statement
	Exceptions []Exception
}

pl_block

func (*Block) CopyNode

func (s *Block) CopyNode() *Block

func (*Block) Format

func (s *Block) Format(ctx *tree.FmtCtx)

TODO(drewk): format Label and Exceptions fields.

func (*Block) PlpgSQLStatementTag

func (s *Block) PlpgSQLStatementTag() string

func (*Block) WalkStmt

func (s *Block) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Call

type Call struct {
	StatementImpl
	Expr   Expr
	IsCall bool
	Target Variable
}

stmt_call

func (*Call) CopyNode

func (s *Call) CopyNode() *Call

func (*Call) Format

func (s *Call) Format(ctx *tree.FmtCtx)

func (*Call) PlpgSQLStatementTag

func (s *Call) PlpgSQLStatementTag() string

func (*Call) WalkStmt

func (s *Call) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

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) CopyNode

func (s *Case) CopyNode() *Case

func (*Case) Format

func (s *Case) Format(ctx *tree.FmtCtx)

TODO(drewk): fix the whitespace/newline formatting for CASE (see the stmt_case test file).

func (*Case) PlpgSQLStatementTag

func (s *Case) PlpgSQLStatementTag() string

func (*Case) WalkStmt

func (s *Case) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type CaseWhen

type CaseWhen struct {
	StatementImpl
	// TODO(drewk): Change to Expr
	Expr  string
	Stmts []Statement
}

func (*CaseWhen) CopyNode

func (s *CaseWhen) CopyNode() *CaseWhen

func (*CaseWhen) Format

func (s *CaseWhen) Format(ctx *tree.FmtCtx)

func (*CaseWhen) PlpgSQLStatementTag

func (s *CaseWhen) PlpgSQLStatementTag() string

func (*CaseWhen) WalkStmt

func (s *CaseWhen) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Close

type Close struct {
	StatementImpl
	CurVar Variable
}

stmt_close

func (*Close) Format

func (s *Close) Format(ctx *tree.FmtCtx)

func (*Close) PlpgSQLStatementTag

func (s *Close) PlpgSQLStatementTag() string

func (*Close) WalkStmt

func (s *Close) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Commit

type Commit struct {
	StatementImpl
	Chain bool
}

stmt_commit

func (*Commit) Format

func (s *Commit) Format(ctx *tree.FmtCtx)

func (*Commit) PlpgSQLStatementTag

func (s *Commit) PlpgSQLStatementTag() string

func (*Commit) WalkStmt

func (s *Commit) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Condition

type Condition struct {
	SqlErrState string
	SqlErrName  string
}

type Continue

type Continue struct {
	StatementImpl
	Label     string
	Condition Expr
}

stmt_continue

func (*Continue) CopyNode

func (s *Continue) CopyNode() *Continue

func (*Continue) Format

func (s *Continue) Format(ctx *tree.FmtCtx)

func (*Continue) PlpgSQLStatementTag

func (s *Continue) PlpgSQLStatementTag() string

func (*Continue) WalkStmt

func (s *Continue) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type CursorDeclaration

type CursorDeclaration struct {
	StatementImpl
	Name   Variable
	Scroll tree.CursorScrollOption
	Query  tree.Statement
}

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) (newStmt Statement, changed bool)

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) (newStmt Statement, changed bool)

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) (newStmt Statement, changed bool)

type ElseIf

type ElseIf struct {
	StatementImpl
	Condition Expr
	Stmts     []Statement
}

func (*ElseIf) CopyNode

func (s *ElseIf) CopyNode() *ElseIf

func (*ElseIf) Format

func (s *ElseIf) Format(ctx *tree.FmtCtx)

func (*ElseIf) PlpgSQLStatementTag

func (s *ElseIf) PlpgSQLStatementTag() string

func (*ElseIf) WalkStmt

func (s *ElseIf) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Exception

type Exception struct {
	StatementImpl
	Conditions []Condition
	Action     []Statement
}

func (*Exception) CopyNode

func (s *Exception) CopyNode() *Exception

func (*Exception) Format

func (s *Exception) Format(ctx *tree.FmtCtx)

func (*Exception) PlpgSQLStatementTag

func (s *Exception) PlpgSQLStatementTag() string

func (*Exception) WalkStmt

func (s *Exception) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Execute

type Execute struct {
	StatementImpl
	SqlStmt tree.Statement
	Strict  bool // INTO STRICT flag
	Target  []Variable
}

stmt_execsql

func (*Execute) CopyNode

func (s *Execute) CopyNode() *Execute

func (*Execute) Format

func (s *Execute) Format(ctx *tree.FmtCtx)

func (*Execute) PlpgSQLStatementTag

func (s *Execute) PlpgSQLStatementTag() string

func (*Execute) WalkStmt

func (s *Execute) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Exit

type Exit struct {
	StatementImpl
	Label     string
	Condition Expr
}

stmt_exit

func (*Exit) CopyNode

func (s *Exit) CopyNode() *Exit

func (*Exit) Format

func (s *Exit) Format(ctx *tree.FmtCtx)

func (*Exit) PlpgSQLStatementTag

func (s *Exit) PlpgSQLStatementTag() string

func (*Exit) WalkStmt

func (s *Exit) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Expr

type Expr = tree.Expr

type Fetch

type Fetch struct {
	StatementImpl
	Cursor tree.CursorStmt
	Target []Variable
	IsMove bool
}

stmt_fetch stmt_move (where IsMove = true)

func (*Fetch) Format

func (s *Fetch) Format(ctx *tree.FmtCtx)

func (*Fetch) PlpgSQLStatementTag

func (s *Fetch) PlpgSQLStatementTag() string

func (*Fetch) WalkStmt

func (s *Fetch) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type ForCursor

type ForCursor struct {
	ForQuery
	CurVar   int // TODO(drewk): is this CursorVariable?
	ArgQuery Expr
}

func (*ForCursor) Format

func (s *ForCursor) Format(ctx *tree.FmtCtx)

func (*ForCursor) PlpgSQLStatementTag

func (s *ForCursor) PlpgSQLStatementTag() string

func (*ForCursor) WalkStmt

func (s *ForCursor) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type ForDynamic

type ForDynamic struct {
	ForQuery
	Query  Expr
	Params []Expr
}

func (*ForDynamic) Format

func (s *ForDynamic) Format(ctx *tree.FmtCtx)

func (*ForDynamic) PlpgSQLStatementTag

func (s *ForDynamic) PlpgSQLStatementTag() string

func (*ForDynamic) WalkStmt

func (s *ForDynamic) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

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) (newStmt Statement, changed bool)

type ForInt

type ForInt struct {
	StatementImpl
	Label   string
	Var     Variable
	Lower   Expr
	Upper   Expr
	Step    Expr
	Reverse int
	Body    []Statement
}

stmt_for

func (*ForInt) Format

func (s *ForInt) Format(ctx *tree.FmtCtx)

func (*ForInt) PlpgSQLStatementTag

func (s *ForInt) PlpgSQLStatementTag() string

func (*ForInt) WalkStmt

func (s *ForInt) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type ForQuery

type ForQuery struct {
	StatementImpl
	Label string
	Var   Variable
	Body  []Statement
}

func (*ForQuery) Format

func (s *ForQuery) Format(ctx *tree.FmtCtx)

func (*ForQuery) PlpgSQLStatementTag

func (s *ForQuery) PlpgSQLStatementTag() string

func (*ForQuery) WalkStmt

func (s *ForQuery) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type ForSelect

type ForSelect struct {
	ForQuery
	Query Expr
}

func (*ForSelect) Format

func (s *ForSelect) Format(ctx *tree.FmtCtx)

func (*ForSelect) PlpgSQLStatementTag

func (s *ForSelect) PlpgSQLStatementTag() string

func (*ForSelect) WalkStmt

func (s *ForSelect) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

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) (newStmt Statement, changed bool)

type GetDiagnosticsItem

type GetDiagnosticsItem struct {
	Kind GetDiagnosticsKind
	// TODO(jane): 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) CopyNode

func (s *If) CopyNode() *If

func (*If) Format

func (s *If) Format(ctx *tree.FmtCtx)

func (*If) PlpgSQLStatementTag

func (s *If) PlpgSQLStatementTag() string

func (*If) WalkStmt

func (s *If) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Loop

type Loop struct {
	StatementImpl
	Label string
	Body  []Statement
}

stmt_loop

func (*Loop) CopyNode

func (s *Loop) CopyNode() *Loop

func (*Loop) Format

func (s *Loop) Format(ctx *tree.FmtCtx)

func (*Loop) PlpgSQLStatementTag

func (s *Loop) PlpgSQLStatementTag() string

func (*Loop) WalkStmt

func (s *Loop) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Null

type Null struct {
	StatementImpl
}

stmt_null

func (*Null) Format

func (s *Null) Format(ctx *tree.FmtCtx)

func (*Null) PlpgSQLStatementTag

func (s *Null) PlpgSQLStatementTag() string

func (*Null) WalkStmt

func (s *Null) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Open

type Open struct {
	StatementImpl
	CurVar Variable
	Scroll tree.CursorScrollOption
	Query  tree.Statement
}

stmt_open

func (*Open) CopyNode

func (s *Open) CopyNode() *Open

func (*Open) Format

func (s *Open) Format(ctx *tree.FmtCtx)

func (*Open) PlpgSQLStatementTag

func (s *Open) PlpgSQLStatementTag() string

func (*Open) WalkStmt

func (s *Open) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Perform

type Perform struct {
	StatementImpl
	Expr Expr
}

stmt_perform

func (*Perform) Format

func (s *Perform) Format(ctx *tree.FmtCtx)

func (*Perform) PlpgSQLStatementTag

func (s *Perform) PlpgSQLStatementTag() string

func (*Perform) WalkStmt

func (s *Perform) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Raise

type Raise struct {
	StatementImpl
	LogLevel string
	Code     string
	CodeName string
	Message  string
	Params   []Expr
	Options  []RaiseOption
}

stmt_raise

func (*Raise) CopyNode

func (s *Raise) CopyNode() *Raise

func (*Raise) Format

func (s *Raise) Format(ctx *tree.FmtCtx)

func (*Raise) PlpgSQLStatementTag

func (s *Raise) PlpgSQLStatementTag() string

func (*Raise) WalkStmt

func (s *Raise) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type RaiseOption

type RaiseOption struct {
	OptType string
	Expr    Expr
}

func (*RaiseOption) Format

func (s *RaiseOption) Format(ctx *tree.FmtCtx)

type Return

type Return struct {
	StatementImpl
	Expr   Expr
	RetVar Variable
}

stmt_return

func (*Return) CopyNode

func (s *Return) CopyNode() *Return

func (*Return) Format

func (s *Return) Format(ctx *tree.FmtCtx)

func (*Return) PlpgSQLStatementTag

func (s *Return) PlpgSQLStatementTag() string

func (*Return) WalkStmt

func (s *Return) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type ReturnNext

type ReturnNext struct {
	StatementImpl
	Expr   Expr
	RetVar Variable
}

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) (newStmt Statement, changed bool)

type ReturnQuery

type ReturnQuery struct {
	StatementImpl
	Query        Expr
	DynamicQuery Expr
	Params       []Expr
}

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) (newStmt Statement, changed bool)

type Rollback

type Rollback struct {
	StatementImpl
	Chain bool
}

stmt_rollback

func (*Rollback) Format

func (s *Rollback) Format(ctx *tree.FmtCtx)

func (*Rollback) PlpgSQLStatementTag

func (s *Rollback) PlpgSQLStatementTag() string

func (*Rollback) WalkStmt

func (s *Rollback) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

type Statement

type Statement interface {
	tree.NodeFormatter
	GetLineNo() int
	GetStmtID() uint

	WalkStmt(StatementVisitor) (newStmt Statement, changed bool)
	// 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(Chengxiong): 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(Chengxiong): 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.
	Visit(stmt Statement) (newStmt Statement, changed bool)
}

StatementVisitor defines methods that are called plpgsql statements during a statement walk.

type TaggedStatement

type TaggedStatement interface {
	PlpgSQLStatementTag() string
}

type Variable

type Variable = tree.Name

type While

type While struct {
	StatementImpl
	Label     string
	Condition Expr
	Body      []Statement
}

stmt_while

func (*While) CopyNode

func (s *While) CopyNode() *While

func (*While) Format

func (s *While) Format(ctx *tree.FmtCtx)

func (*While) PlpgSQLStatementTag

func (s *While) PlpgSQLStatementTag() string

func (*While) WalkStmt

func (s *While) WalkStmt(visitor StatementVisitor) (newStmt Statement, changed bool)

Jump to

Keyboard shortcuts

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