Documentation
¶
Index ¶
- func Completion(ctx context.Context, cCtx base.CompletionContext, statement string, ...) ([]base.Candidate, error)
- func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error)
- func EquivalentType(tp parser.IDatatypeContext, text string) (bool, error)
- func EraseString(ctx EraseContext, rule antlr.ParserRuleContext, tokens antlr.TokenStream) string
- func GenerateRestoreSQL(ctx context.Context, rCtx base.RestoreContext, statement string, ...) (string, error)
- func GetQuerySpan(ctx context.Context, gCtx base.GetQuerySpanContext, ...) (*base.QuerySpan, error)
- func GetStatementTypes(asts []base.AST) ([]string, error)
- func IsOracleKeyword(text string) bool
- func IsTopLevelStatement(ctx antlr.Tree) bool
- func NormalizeColumnName(columnName parser.IColumn_nameContext) (string, string, string)
- func NormalizeConstraintName(constraintName parser.IConstraint_nameContext) (string, string)
- func NormalizeIDExpression(idExpression parser.IId_expressionContext) string
- func NormalizeIdentifierContext(identifier parser.IIdentifierContext) string
- func NormalizeIndexName(indexName parser.IIndex_nameContext) (string, string)
- func NormalizeQuotedString(ctx plsql.IQuoted_stringContext) string
- func NormalizeSchemaName(schemaName parser.ISchema_nameContext) string
- func NormalizeTableAlias(ctx plsql.ITable_aliasContext) string
- func NormalizeTableName(tableName parser.ITable_nameContext) string
- func NormalizeTableViewName(currentSchema string, ctx parser.ITableview_nameContext) ([]string, string, string)
- func ParsePLSQL(sql string) ([]*base.ParseResult, error)
- func ParsePLSQLForStringsManipulation(sql string) (antlr.Tree, antlr.TokenStream, error)
- func SplitSQL(statement string) ([]base.SingleSQL, error)
- func SplitSQLForCompletion(statement string) ([]base.SingleSQL, error)
- func TransformDMLToSelect(_ context.Context, tCtx base.TransformContext, statement string, ...) ([]base.BackupStatement, error)
- type AliasListener
- type CTETableListener
- type Completer
- type CompletionMap
- type EraseContext
- type ObjectFlags
- type StatementType
- type StringsManipulator
- type StringsManipulatorActionAddColumn
- type StringsManipulatorActionAddColumnOption
- type StringsManipulatorActionAddIndex
- type StringsManipulatorActionAddTable
- type StringsManipulatorActionAddTableConstraint
- type StringsManipulatorActionColumnOptionBase
- type StringsManipulatorActionDropColumn
- type StringsManipulatorActionDropColumnOption
- type StringsManipulatorActionDropIndex
- type StringsManipulatorActionDropTable
- type StringsManipulatorActionDropTableConstraint
- type StringsManipulatorActionModifyColumnOption
- type StringsManipulatorActionModifyColumnType
- type StringsManipulatorActionModifyIndex
- type StringsManipulatorActionModifyTableConstraint
- type TableRefListener
- type TableReference
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Completion ¶
func Diagnose ¶
func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error)
func EquivalentType ¶
func EquivalentType(tp parser.IDatatypeContext, text string) (bool, error)
EquivalentType returns true if the given type is equivalent to the given text.
func EraseString ¶
func EraseString(ctx EraseContext, rule antlr.ParserRuleContext, tokens antlr.TokenStream) string
func GenerateRestoreSQL ¶
func GenerateRestoreSQL(ctx context.Context, rCtx base.RestoreContext, statement string, backupItem *storepb.PriorBackupDetail_Item) (string, error)
func GetQuerySpan ¶
func IsOracleKeyword ¶
IsOracleKeyword returns true if the given text is an Oracle keyword.
func IsTopLevelStatement ¶
func NormalizeColumnName ¶
func NormalizeColumnName(columnName parser.IColumn_nameContext) (string, string, string)
NormalizeColumnName returns the normalized column name from the given context.
func NormalizeConstraintName ¶
func NormalizeConstraintName(constraintName parser.IConstraint_nameContext) (string, string)
NormalizeConstraintName returns the normalized constraint name from the given context.
func NormalizeIDExpression ¶
func NormalizeIDExpression(idExpression parser.IId_expressionContext) string
NormalizeIDExpression returns the normalized identifier from the given context.
func NormalizeIdentifierContext ¶
func NormalizeIdentifierContext(identifier parser.IIdentifierContext) string
NormalizeIdentifierContext returns the normalized identifier from the given context.
func NormalizeIndexName ¶
func NormalizeIndexName(indexName parser.IIndex_nameContext) (string, string)
NormalizeIndexName returns the normalized index name from the given context.
func NormalizeQuotedString ¶
func NormalizeQuotedString(ctx plsql.IQuoted_stringContext) string
NormalizeQuotedString returns the string without the quotes.
func NormalizeSchemaName ¶
func NormalizeSchemaName(schemaName parser.ISchema_nameContext) string
NormalizeSchemaName returns the normalized schema name from the given context.
func NormalizeTableAlias ¶
func NormalizeTableAlias(ctx plsql.ITable_aliasContext) string
func NormalizeTableName ¶
func NormalizeTableName(tableName parser.ITable_nameContext) string
NormalizeTableName returns the normalized table name from the given context.
func NormalizeTableViewName ¶
func NormalizeTableViewName(currentSchema string, ctx parser.ITableview_nameContext) ([]string, string, string)
NormalizeTableViewName normalizes the table name and schema name. Return empty string if it's xml table.
func ParsePLSQL ¶
func ParsePLSQL(sql string) ([]*base.ParseResult, error)
ParsePLSQL parses the given PLSQL and returns a list of parse results. It first parses the whole statement to get the AST, then splits by unit_statement and sql_plus_command nodes, and re-parses each individual statement.
func ParsePLSQLForStringsManipulation ¶
ParsePLSQLForStringsManipulation parses the whole SQL without splitting. This is used for strings manipulation which needs to see all statements together.
func SplitSQL ¶
SplitSQL splits the given SQL statement into multiple SQL statements. TODO(zp): Consolidate with split logic in ParsePLSQL?
func TransformDMLToSelect ¶
func TransformDMLToSelect(_ context.Context, tCtx base.TransformContext, statement string, sourceDatabase string, targetDatabase string, tablePrefix string) ([]base.BackupStatement, error)
TransformDMLToSelect transforms DML statement to SELECT statement. For Oracle, we only consider the managed on schema mode.
Types ¶
type AliasListener ¶
type AliasListener struct {
*plsql.BasePlSqlParserListener
// contains filtered or unexported fields
}
func (*AliasListener) EnterColumn_alias ¶
func (l *AliasListener) EnterColumn_alias(ctx *plsql.Column_aliasContext)
type CTETableListener ¶
type CTETableListener struct {
*plsql.BasePlSqlParserListener
// contains filtered or unexported fields
}
func (*CTETableListener) EnterFactoring_element ¶
func (l *CTETableListener) EnterFactoring_element(ctx *plsql.Factoring_elementContext)
type Completer ¶
type Completer struct {
// contains filtered or unexported fields
}
func NewStandardCompleter ¶
func NewTrickyCompleter ¶
type CompletionMap ¶
func (CompletionMap) Insert ¶
func (m CompletionMap) Insert(entry base.Candidate)
type EraseContext ¶
type EraseContext struct {
// contains filtered or unexported fields
}
type ObjectFlags ¶
type ObjectFlags int
const ( ObjectFlagsShowSchemas ObjectFlags = 1 << iota ObjectFlagsShowTables ObjectFlagsShowColumns ObjectFlagsShowFirst ObjectFlagsShowSecond )
type StatementType ¶
type StatementType int
const ( StatementTypeUnknown StatementType = iota StatementTypeUpdate StatementTypeInsert StatementTypeDelete )
type StringsManipulator ¶
type StringsManipulator struct {
// contains filtered or unexported fields
}
func NewStringsManipulator ¶
func NewStringsManipulator(tree antlr.Tree, stream antlr.TokenStream) *StringsManipulator
func (*StringsManipulator) Manipulate ¶
func (s *StringsManipulator) Manipulate(actions ...base.StringsManipulatorAction) (string, error)
type StringsManipulatorActionAddColumn ¶
type StringsManipulatorActionAddColumn struct {
base.StringsManipulatorActionBase
Table string
ColumnDefinition string
}
func NewAddColumnAction ¶
func NewAddColumnAction(schemaName, tableName, columnDefinition string) *StringsManipulatorActionAddColumn
func (*StringsManipulatorActionAddColumn) GetSecondLevelNaming ¶
func (*StringsManipulatorActionAddColumn) GetSecondLevelNaming() string
func (*StringsManipulatorActionAddColumn) GetTopLevelNaming ¶
func (s *StringsManipulatorActionAddColumn) GetTopLevelNaming() string
type StringsManipulatorActionAddColumnOption ¶
type StringsManipulatorActionAddColumnOption struct {
StringsManipulatorActionColumnOptionBase
Table string
Column string
NewOptionDefine string
}
func NewAddColumnOptionAction ¶
func NewAddColumnOptionAction(schemaName, tableName string, columnName string, optionType base.ColumnOptionType, newOptionDefine string) *StringsManipulatorActionAddColumnOption
func (*StringsManipulatorActionAddColumnOption) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionAddColumnOption) GetSecondLevelNaming() string
func (*StringsManipulatorActionAddColumnOption) GetTopLevelNaming ¶
func (s *StringsManipulatorActionAddColumnOption) GetTopLevelNaming() string
type StringsManipulatorActionAddIndex ¶
type StringsManipulatorActionAddIndex struct {
base.StringsManipulatorActionBase
Table string
IndexDefine string
}
func NewAddIndexAction ¶
func NewAddIndexAction(schemaName, tableName, indexDefine string) *StringsManipulatorActionAddIndex
func (*StringsManipulatorActionAddIndex) GetSecondLevelNaming ¶
func (*StringsManipulatorActionAddIndex) GetSecondLevelNaming() string
func (*StringsManipulatorActionAddIndex) GetTopLevelNaming ¶
func (s *StringsManipulatorActionAddIndex) GetTopLevelNaming() string
type StringsManipulatorActionAddTable ¶
type StringsManipulatorActionAddTable struct {
base.StringsManipulatorActionBase
Table string
TableDefinition string
}
func NewAddTableAction ¶
func NewAddTableAction(schemaName, tableName, tableDefinition string) *StringsManipulatorActionAddTable
func (*StringsManipulatorActionAddTable) GetSecondLevelNaming ¶
func (*StringsManipulatorActionAddTable) GetSecondLevelNaming() string
func (*StringsManipulatorActionAddTable) GetTopLevelNaming ¶
func (s *StringsManipulatorActionAddTable) GetTopLevelNaming() string
type StringsManipulatorActionAddTableConstraint ¶
type StringsManipulatorActionAddTableConstraint struct {
base.StringsManipulatorActionBase
Table string
Type base.TableConstraintType
NewConstraintDefine string
}
func NewAddTableConstraintAction ¶
func NewAddTableConstraintAction(schemaName, tableName string, constraintType base.TableConstraintType, newConstraintDefine string) *StringsManipulatorActionAddTableConstraint
func (*StringsManipulatorActionAddTableConstraint) GetSecondLevelNaming ¶
func (*StringsManipulatorActionAddTableConstraint) GetSecondLevelNaming() string
func (*StringsManipulatorActionAddTableConstraint) GetTopLevelNaming ¶
func (s *StringsManipulatorActionAddTableConstraint) GetTopLevelNaming() string
type StringsManipulatorActionColumnOptionBase ¶
type StringsManipulatorActionColumnOptionBase struct {
base.StringsManipulatorActionBase
Type base.ColumnOptionType
}
func (*StringsManipulatorActionColumnOptionBase) GetOptionType ¶
func (s *StringsManipulatorActionColumnOptionBase) GetOptionType() base.ColumnOptionType
type StringsManipulatorActionDropColumn ¶
type StringsManipulatorActionDropColumn struct {
base.StringsManipulatorActionBase
Table string
Column string
}
func NewDropColumnAction ¶
func NewDropColumnAction(schemaName, tableName, columnName string) *StringsManipulatorActionDropColumn
func (*StringsManipulatorActionDropColumn) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionDropColumn) GetSecondLevelNaming() string
func (*StringsManipulatorActionDropColumn) GetTopLevelNaming ¶
func (s *StringsManipulatorActionDropColumn) GetTopLevelNaming() string
type StringsManipulatorActionDropColumnOption ¶
type StringsManipulatorActionDropColumnOption struct {
StringsManipulatorActionColumnOptionBase
Table string
Column string
}
func NewDropColumnOptionAction ¶
func NewDropColumnOptionAction(schemaName, tableName string, columnName string, option base.ColumnOptionType) *StringsManipulatorActionDropColumnOption
func (*StringsManipulatorActionDropColumnOption) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionDropColumnOption) GetSecondLevelNaming() string
func (*StringsManipulatorActionDropColumnOption) GetTopLevelNaming ¶
func (s *StringsManipulatorActionDropColumnOption) GetTopLevelNaming() string
type StringsManipulatorActionDropIndex ¶
type StringsManipulatorActionDropIndex struct {
base.StringsManipulatorActionBase
Table string
Index string
}
func NewDropIndexAction ¶
func NewDropIndexAction(schemaName, tableName, indexName string) *StringsManipulatorActionDropIndex
func (*StringsManipulatorActionDropIndex) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionDropIndex) GetSecondLevelNaming() string
func (*StringsManipulatorActionDropIndex) GetTopLevelNaming ¶
func (s *StringsManipulatorActionDropIndex) GetTopLevelNaming() string
type StringsManipulatorActionDropTable ¶
type StringsManipulatorActionDropTable struct {
base.StringsManipulatorActionBase
Table string
}
func NewDropTableAction ¶
func NewDropTableAction(schemaName, tableName string) *StringsManipulatorActionDropTable
func (*StringsManipulatorActionDropTable) GetSecondLevelNaming ¶
func (*StringsManipulatorActionDropTable) GetSecondLevelNaming() string
func (*StringsManipulatorActionDropTable) GetTopLevelNaming ¶
func (s *StringsManipulatorActionDropTable) GetTopLevelNaming() string
type StringsManipulatorActionDropTableConstraint ¶
type StringsManipulatorActionDropTableConstraint struct {
base.StringsManipulatorActionBase
Table string
Constraint base.TableConstraintType
ConstraintName string
}
func NewDropTableConstraintAction ¶
func NewDropTableConstraintAction(schemaName, tableName string, constraintName string) *StringsManipulatorActionDropTableConstraint
func (*StringsManipulatorActionDropTableConstraint) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionDropTableConstraint) GetSecondLevelNaming() string
func (*StringsManipulatorActionDropTableConstraint) GetTopLevelNaming ¶
func (s *StringsManipulatorActionDropTableConstraint) GetTopLevelNaming() string
type StringsManipulatorActionModifyColumnOption ¶
type StringsManipulatorActionModifyColumnOption struct {
StringsManipulatorActionColumnOptionBase
Table string
Column string
NewOptionDefine string
}
func NewModifyColumnOptionAction ¶
func NewModifyColumnOptionAction(schemaName, tableName string, columnName string, oldOption base.ColumnOptionType, newOptionDefine string) *StringsManipulatorActionModifyColumnOption
func (*StringsManipulatorActionModifyColumnOption) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionModifyColumnOption) GetSecondLevelNaming() string
func (*StringsManipulatorActionModifyColumnOption) GetTopLevelNaming ¶
func (s *StringsManipulatorActionModifyColumnOption) GetTopLevelNaming() string
type StringsManipulatorActionModifyColumnType ¶
type StringsManipulatorActionModifyColumnType struct {
base.StringsManipulatorActionBase
Table string
Column string
Type string
}
func NewModifyColumnTypeAction ¶
func NewModifyColumnTypeAction(schemaName, tableName, columnName, columnType string) *StringsManipulatorActionModifyColumnType
func (*StringsManipulatorActionModifyColumnType) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionModifyColumnType) GetSecondLevelNaming() string
func (*StringsManipulatorActionModifyColumnType) GetTopLevelNaming ¶
func (s *StringsManipulatorActionModifyColumnType) GetTopLevelNaming() string
type StringsManipulatorActionModifyIndex ¶
type StringsManipulatorActionModifyIndex struct {
base.StringsManipulatorActionBase
Table string
IndexName string
NewIndexDefine string
}
func NewModifyIndexAction ¶
func NewModifyIndexAction(schemaName, tableName, indexName string, newIndexDefine string) *StringsManipulatorActionModifyIndex
func (*StringsManipulatorActionModifyIndex) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionModifyIndex) GetSecondLevelNaming() string
func (*StringsManipulatorActionModifyIndex) GetTopLevelNaming ¶
func (s *StringsManipulatorActionModifyIndex) GetTopLevelNaming() string
type StringsManipulatorActionModifyTableConstraint ¶
type StringsManipulatorActionModifyTableConstraint struct {
base.StringsManipulatorActionBase
Table string
OldConstraint base.TableConstraintType
OldConstraintName string
NewConstraintDefine string
}
func NewModifyTableConstraintAction ¶
func NewModifyTableConstraintAction(schemaName, tableName string, oldConstraint base.TableConstraintType, oldConstraintName string, newConstraintDefine string) *StringsManipulatorActionModifyTableConstraint
func (*StringsManipulatorActionModifyTableConstraint) GetSecondLevelNaming ¶
func (s *StringsManipulatorActionModifyTableConstraint) GetSecondLevelNaming() string
func (*StringsManipulatorActionModifyTableConstraint) GetTopLevelNaming ¶
func (s *StringsManipulatorActionModifyTableConstraint) GetTopLevelNaming() string
type TableRefListener ¶
type TableRefListener struct {
*plsql.BasePlSqlParserListener
// contains filtered or unexported fields
}
func (*TableRefListener) ExitDml_table_expression_clause ¶
func (l *TableRefListener) ExitDml_table_expression_clause(ctx *plsql.Dml_table_expression_clauseContext)
func (*TableRefListener) ExitTable_alias ¶
func (l *TableRefListener) ExitTable_alias(ctx *plsql.Table_aliasContext)