Documentation
¶
Overview ¶
Package tsqlparser provides a parser for Microsoft T-SQL.
This package can be used to parse T-SQL stored procedures and other T-SQL statements into an Abstract Syntax Tree (AST) that can be analyzed and interpreted in Go.
Example usage:
program, errors := tsqlparser.Parse(tsqlCode)
if len(errors) > 0 {
// handle errors
}
// work with program.Statements
Index ¶
- func Parse(input string) (*ast.Program, []string)
- func Tokenize(input string) []token.Token
- func Walk(v Visitor, node ast.Node)
- type AlterFunctionStatement
- type AlterIndexStatement
- type AlterProcedureStatement
- type AlterTableAction
- type AlterTableStatement
- type AlterTriggerStatement
- type AlterViewStatement
- type BeginEndBlock
- type BeginTransactionStatement
- type BetweenExpression
- type BinaryLiteral
- type BreakStatement
- type BulkInsertStatement
- type CTEDef
- type CaseExpression
- type CastExpression
- type CloseCursorStatement
- type CollateExpression
- type ColumnConstraint
- type ColumnDefinition
- type CommitTransactionStatement
- type ContinueStatement
- type ConvertExpression
- type CreateFunctionStatement
- type CreateIndexStatement
- type CreateProcedureStatement
- type CreateTableStatement
- type CreateTriggerStatement
- type CreateViewStatement
- type CursorOptions
- type DataType
- type DeallocateCursorStatement
- type DeclareCursorStatement
- type DeclareStatement
- type DeleteStatement
- type DerivedTable
- type DropIndexStatement
- type DropObjectStatement
- type DropTableStatement
- type ExecParameter
- type ExecStatement
- type ExistsExpression
- type Expression
- type FetchStatement
- type FloatLiteral
- type ForClause
- type FrameBound
- type FromClause
- type FunctionCall
- type FunctionType
- type GoStatement
- type GotoStatement
- type Identifier
- type IdentitySpec
- type IfStatement
- type InExpression
- type IndexColumn
- type InfixExpression
- type InsertStatement
- type Inspector
- type IntegerLiteral
- type IsNullExpression
- type JoinClause
- type LabelStatement
- type LikeExpression
- type MergeActionType
- type MergeStatement
- type MergeWhenClause
- type MergeWhenType
- type NextValueForExpression
- type NullLiteral
- type OpenCursorStatement
- type OrderByItem
- type OutputClause
- type OverClause
- type ParameterDef
- type ParseExpression
- type PivotTable
- type PrefixExpression
- type PrintStatement
- type Program
- type QualifiedIdentifier
- type QueryOption
- type RaiserrorStatement
- type ReturnStatement
- type RollbackTransactionStatement
- type SaveTransactionStatement
- type SelectColumn
- type SelectStatement
- type SetClause
- type SetOptionStatement
- type SetStatement
- type SetTransactionIsolationStatement
- type Statement
- type StringLiteral
- type SubqueryExpression
- type TableConstraint
- type TableName
- type TableTypeDefinition
- type TableValuedFunction
- type ThrowStatement
- type Token
- type TopClause
- type TriggerTiming
- type TruncateTableStatement
- type TryCatchStatement
- type TupleExpression
- type UnionClause
- type UnpivotTable
- type UpdateStatement
- type UseStatement
- type ValuesTable
- type Variable
- type VariableDef
- type Visitor
- type WaitforStatement
- type WhenClause
- type WhileStatement
- type WindowFrame
- type WithStatement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlterIndexStatement ¶
type AlterIndexStatement = ast.AlterIndexStatement
ALTER INDEX / BULK INSERT
type AlterProcedureStatement ¶
type AlterProcedureStatement = ast.AlterProcedureStatement
Helper types
type BeginTransactionStatement ¶
type BeginTransactionStatement = ast.BeginTransactionStatement
Statement types
type CommitTransactionStatement ¶
type CommitTransactionStatement = ast.CommitTransactionStatement
Statement types
type CreateFunctionStatement ¶
type CreateFunctionStatement = ast.CreateFunctionStatement
Helper types
type CreateProcedureStatement ¶
type CreateProcedureStatement = ast.CreateProcedureStatement
Statement types
type CreateTableStatement ¶
type CreateTableStatement = ast.CreateTableStatement
Stage 1: Table Infrastructure
type CreateViewStatement ¶
type CreateViewStatement = ast.CreateViewStatement
Stage 5: DDL Completion
type DeallocateCursorStatement ¶
type DeallocateCursorStatement = ast.DeallocateCursorStatement
Statement types
type DeclareCursorStatement ¶
type DeclareCursorStatement = ast.DeclareCursorStatement
Stage 2: Cursor Support
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
Inspector provides a convenient way to inspect AST nodes.
func NewInspector ¶
NewInspector creates a new Inspector for the given program.
func (*Inspector) FindFunctionCalls ¶
func (insp *Inspector) FindFunctionCalls() []*ast.FunctionCall
FindFunctionCalls returns all function calls in the AST.
func (*Inspector) FindSelectStatements ¶
func (insp *Inspector) FindSelectStatements() []*ast.SelectStatement
FindSelectStatements returns all SELECT statements in the AST.
func (*Inspector) FindVariables ¶
FindVariables returns all variable references in the AST.
type NextValueForExpression ¶
type NextValueForExpression = ast.NextValueForExpression
Stage 10 additions
type RollbackTransactionStatement ¶
type RollbackTransactionStatement = ast.RollbackTransactionStatement
Statement types
type SaveTransactionStatement ¶
type SaveTransactionStatement = ast.SaveTransactionStatement
Helper types
type SetTransactionIsolationStatement ¶
type SetTransactionIsolationStatement = ast.SetTransactionIsolationStatement
Helper types
type TruncateTableStatement ¶
type TruncateTableStatement = ast.TruncateTableStatement
Statement types
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ast defines the Abstract Syntax Tree nodes for T-SQL.
|
Package ast defines the Abstract Syntax Tree nodes for T-SQL. |
|
cmd
|
|
|
example
command
Example: Parsing and analyzing T-SQL stored procedures
|
Example: Parsing and analyzing T-SQL stored procedures |
|
Package lexer implements a lexical scanner for T-SQL.
|
Package lexer implements a lexical scanner for T-SQL. |
|
Package parser implements a parser for T-SQL.
|
Package parser implements a parser for T-SQL. |
|
pkg
|
|
|
version
Package version provides version information for tsqlparser.
|
Package version provides version information for tsqlparser. |
|
Package token defines constants representing the lexical tokens of T-SQL.
|
Package token defines constants representing the lexical tokens of T-SQL. |