Documentation
¶
Index ¶
- Constants
- func Completion(ctx context.Context, cCtx base.CompletionContext, statement string, ...) ([]base.Candidate, error)
- func DealWithDelimiter(statement string) (string, error)
- func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error)
- func ExtractDelimiter(stmt string) (string, error)
- func GenerateRestoreSQL(ctx context.Context, rCtx base.RestoreContext, statement string, ...) (string, error)
- func GetCharSetName(ctx parser.IDataTypeContext) string
- func GetCollationName(ctx parser.IFieldDefinitionContext) string
- func GetQuerySpan(ctx context.Context, gCtx base.GetQuerySpanContext, ...) (*base.QuerySpan, error)
- func GetStatementTypes(asts []base.AST) ([]string, error)
- func IsAutoIncrement(ctx parser.IFieldDefinitionContext) bool
- func IsDelimiter(stmt string) bool
- func IsTimeType(ctx parser.IDataTypeContext) bool
- func IsTopMySQLRule(ctx *antlr.BaseParserRuleContext) bool
- func NormalizeConstraintName(ctx parser.IConstraintNameContext) string
- func NormalizeIdentifierListWithParentheses(ctx parser.IIdentifierListWithParenthesesContext) []string
- func NormalizeIndexName(ctx parser.IIndexNameContext) string
- func NormalizeIndexRef(ctx parser.IIndexRefContext) (string, string, string)
- func NormalizeKeyList(ctx parser.IKeyListContext) []string
- func NormalizeKeyListVariants(ctx parser.IKeyListVariantsContext) []string
- func NormalizeKeyListWithExpression(ctx parser.IKeyListWithExpressionContext) []string
- func NormalizeMySQLCharsetName(ctx parser.ICharsetNameContext) string
- func NormalizeMySQLCollationName(ctx parser.ICollationNameContext) string
- func NormalizeMySQLColumnInternalRef(ctx parser.IColumnInternalRefContext) string
- func NormalizeMySQLColumnName(ctx parser.IColumnNameContext) (string, string, string)
- func NormalizeMySQLColumnRef(ctx parser.IColumnRefContext) (string, string, string)
- func NormalizeMySQLDataType(ctx parser.IDataTypeContext, compact bool) string
- func NormalizeMySQLEventName(ctx parser.IEventNameContext) (string, string)
- func NormalizeMySQLFieldIdentifier(ctx parser.IFieldIdentifierContext) (string, string, string)
- func NormalizeMySQLFunctionName(ctx parser.IFunctionNameContext) (string, string)
- func NormalizeMySQLFunctionRef(ctx parser.IFunctionRefContext) (string, string)
- func NormalizeMySQLIdentifier(identifier parser.IIdentifierContext) string
- func NormalizeMySQLIdentifierList(ctx parser.IIdentifierListContext) []string
- func NormalizeMySQLProcedureName(ctx parser.IProcedureNameContext) (string, string)
- func NormalizeMySQLProcedureRef(ctx parser.IProcedureRefContext) (string, string)
- func NormalizeMySQLPureIdentifier(pureIdentifier parser.IPureIdentifierContext) string
- func NormalizeMySQLSchemaName(ctx parser.ISchemaNameContext) string
- func NormalizeMySQLSchemaRef(ctx parser.ISchemaRefContext) string
- func NormalizeMySQLSelectAlias(selectAlias parser.ISelectAliasContext) string
- func NormalizeMySQLSignedLiteral(ctx parser.ISignedLiteralContext) string
- func NormalizeMySQLTableName(ctx parser.ITableNameContext) (string, string)
- func NormalizeMySQLTableRef(ctx parser.ITableRefContext) (string, string)
- func NormalizeMySQLTableRefWithWildcard(ctx parser.ITableRefWithWildcardContext) (string, string)
- func NormalizeMySQLTextLiteral(ctx parser.ITextLiteralContext) string
- func NormalizeMySQLTextOrIdentifier(ctx parser.ITextOrIdentifierContext) string
- func NormalizeMySQLTextStringLiteral(ctx parser.ITextStringLiteralContext) string
- func NormalizeMySQLTriggerName(ctx parser.ITriggerNameContext) (string, string)
- func NormalizeMySQLViewName(ctx parser.IViewNameContext) (string, string)
- func NormalizeMySQLViewRef(ctx parser.IViewRefContext) (string, string)
- func ParseMySQL(statement string) ([]*base.ParseResult, error)
- func RestoreDelimiter(statement string) (string, error)
- func SplitSQL(statement string) ([]base.SingleSQL, error)
- func TransformDMLToSelect(ctx context.Context, tCtx base.TransformContext, statement string, ...) ([]base.BackupStatement, error)
- type CTETableListener
- type Completer
- type CompletionMap
- type ObjectFlags
- type SelectAliasListener
- type StatementInfo
- type StatementType
- type StatementTypeChecker
- func (checker *StatementTypeChecker) EnterAlterStatement(ctx *mysql.AlterStatementContext)
- func (checker *StatementTypeChecker) EnterCallStatement(ctx *mysql.CallStatementContext)
- func (checker *StatementTypeChecker) EnterCreateStatement(ctx *mysql.CreateStatementContext)
- func (checker *StatementTypeChecker) EnterDeleteStatement(ctx *mysql.DeleteStatementContext)
- func (checker *StatementTypeChecker) EnterDoStatement(ctx *mysql.DoStatementContext)
- func (checker *StatementTypeChecker) EnterDropStatement(ctx *mysql.DropStatementContext)
- func (checker *StatementTypeChecker) EnterExplainStatement(ctx *mysql.ExplainStatementContext)
- func (checker *StatementTypeChecker) EnterHandlerStatement(ctx *mysql.HandlerStatementContext)
- func (checker *StatementTypeChecker) EnterImportStatement(ctx *mysql.ImportStatementContext)
- func (checker *StatementTypeChecker) EnterInsertStatement(ctx *mysql.InsertStatementContext)
- func (checker *StatementTypeChecker) EnterLoadDataFileTail(ctx *mysql.LoadDataFileTailContext)
- func (checker *StatementTypeChecker) EnterPreparedStatement(ctx *mysql.PreparedStatementContext)
- func (checker *StatementTypeChecker) EnterQuery(ctx *mysql.QueryContext)
- func (checker *StatementTypeChecker) EnterRenameTableStatement(ctx *mysql.RenameTableStatementContext)
- func (checker *StatementTypeChecker) EnterReplaceStatement(ctx *mysql.ReplaceStatementContext)
- func (checker *StatementTypeChecker) EnterReplicationStatement(ctx *mysql.ReplicationStatementContext)
- func (checker *StatementTypeChecker) EnterSelectStatement(ctx *mysql.SelectStatementContext)
- func (checker *StatementTypeChecker) EnterTransactionOrLockingStatement(ctx *mysql.TransactionOrLockingStatementContext)
- func (checker *StatementTypeChecker) EnterTruncateTableStatement(ctx *mysql.TruncateTableStatementContext)
- func (checker *StatementTypeChecker) EnterUpdateStatement(ctx *mysql.UpdateStatementContext)
- type TableRefListener
- func (l *TableRefListener) EnterDerivedTable(ctx *mysql.DerivedTableContext)
- func (l *TableRefListener) EnterSubquery(_ *mysql.SubqueryContext)
- func (l *TableRefListener) ExitSubquery(_ *mysql.SubqueryContext)
- func (l *TableRefListener) ExitTableAlias(ctx *mysql.TableAliasContext)
- func (l *TableRefListener) ExitTableRef(ctx *mysql.TableRefContext)
- type TableReference
Constants ¶
const ( Join joinType = iota InnerJoin CrossJoin StraightJoin LeftOuterJoin RightOuterJoin NaturalInnerJoin NaturalLeftOuterJoin NaturalRightOuterJoin )
Variables ¶
This section is empty.
Functions ¶
func Completion ¶
func Completion(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) ([]base.Candidate, error)
Completion is the entry point of MySQL code completion.
func DealWithDelimiter ¶
DealWithDelimiter converts the delimiter statement to comment, also converts the following statement's delimiter to semicolon(`;`).
func Diagnose ¶
func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error)
func ExtractDelimiter ¶
ExtractDelimiter extracts the delimiter from the delimiter statement.
func GenerateRestoreSQL ¶
func GenerateRestoreSQL(ctx context.Context, rCtx base.RestoreContext, statement string, backupItem *storepb.PriorBackupDetail_Item) (string, error)
func GetCharSetName ¶
func GetCharSetName(ctx parser.IDataTypeContext) string
GetCharSetName get charset name from DataTypeContext.
func GetCollationName ¶
func GetCollationName(ctx parser.IFieldDefinitionContext) string
GetCollationName get collation name from FieldDefinitionContext.
func GetQuerySpan ¶
func GetQuerySpan( ctx context.Context, gCtx base.GetQuerySpanContext, statement, database, _ string, ignoreCaseSensitive bool, ) (*base.QuerySpan, error)
GetQuerySpan returns the query span for the given statement.
func IsAutoIncrement ¶
func IsAutoIncrement(ctx parser.IFieldDefinitionContext) bool
IsAutoIncrement check if this column is auto_increment.
func IsDelimiter ¶
IsDelimiter returns true if the statement is a delimiter statement.
func IsTimeType ¶
func IsTimeType(ctx parser.IDataTypeContext) bool
IsTimeType check if the dataType is time type.
func IsTopMySQLRule ¶
func IsTopMySQLRule(ctx *antlr.BaseParserRuleContext) bool
IsTopMySQLRule returns true if the given context is a top-level MySQL rule.
func NormalizeConstraintName ¶
func NormalizeConstraintName(ctx parser.IConstraintNameContext) string
NormalizeMySQLConstraintName normalize the given IConstraintName.
func NormalizeIdentifierListWithParentheses ¶
func NormalizeIdentifierListWithParentheses(ctx parser.IIdentifierListWithParenthesesContext) []string
NormalizeMySQLIdentifierListWithParentheses normalize the given IdentififerListWithparentheses.
func NormalizeIndexName ¶
func NormalizeIndexName(ctx parser.IIndexNameContext) string
NormalizeMySQLIndexName normalize the given IndexName.
func NormalizeIndexRef ¶
func NormalizeIndexRef(ctx parser.IIndexRefContext) (string, string, string)
NormalizeMySQLIndexName normalize the given IndeRef.
func NormalizeKeyList ¶
func NormalizeKeyList(ctx parser.IKeyListContext) []string
NormalizeMySQLKeyList normalize the given keyList.
func NormalizeKeyListVariants ¶
func NormalizeKeyListVariants(ctx parser.IKeyListVariantsContext) []string
NormalizeMySQLKeyListVariants normalize the given keyListVariants.
func NormalizeKeyListWithExpression ¶
func NormalizeKeyListWithExpression(ctx parser.IKeyListWithExpressionContext) []string
NormalizeMySQLKeyListWithExpression normalizes the given keyListWithExpression.
func NormalizeMySQLCharsetName ¶
func NormalizeMySQLCharsetName(ctx parser.ICharsetNameContext) string
NormalizeMySQLCharsetName noamalizes the given charset name.
func NormalizeMySQLCollationName ¶
func NormalizeMySQLCollationName(ctx parser.ICollationNameContext) string
NormalizeMySQLCollationName noamalizes the given collation name.
func NormalizeMySQLColumnInternalRef ¶
func NormalizeMySQLColumnInternalRef(ctx parser.IColumnInternalRefContext) string
NormalizeMySQLColumnInternalRef noamalizes the given columnInternalRef.
func NormalizeMySQLColumnName ¶
func NormalizeMySQLColumnName(ctx parser.IColumnNameContext) (string, string, string)
NormalizeMySQLColumnName normalizes the given column name.
func NormalizeMySQLColumnRef ¶
func NormalizeMySQLColumnRef(ctx parser.IColumnRefContext) (string, string, string)
func NormalizeMySQLDataType ¶
func NormalizeMySQLDataType(ctx parser.IDataTypeContext, compact bool) string
NormalizeMySQLDataType noamalizes the given dataType. campact for tidb parser compatibility. eg: varchar(5). compact is true, return varchar. compact is false, return varchar(5).
func NormalizeMySQLEventName ¶
func NormalizeMySQLEventName(ctx parser.IEventNameContext) (string, string)
NormalizeMySQLEventName normalizes the given event name.
func NormalizeMySQLFieldIdentifier ¶
func NormalizeMySQLFieldIdentifier(ctx parser.IFieldIdentifierContext) (string, string, string)
NormalizeMySQLFieldIdentifier normalizes the given field identifier.
func NormalizeMySQLFunctionName ¶
func NormalizeMySQLFunctionName(ctx parser.IFunctionNameContext) (string, string)
NormalizeMySQLFunctionName normalizes the given function name.
func NormalizeMySQLFunctionRef ¶
func NormalizeMySQLFunctionRef(ctx parser.IFunctionRefContext) (string, string)
NormalizeMySQLFunctionRef normalizes the given function ref.
func NormalizeMySQLIdentifier ¶
func NormalizeMySQLIdentifier(identifier parser.IIdentifierContext) string
NormalizeMySQLIdentifier normalizes the given identifier.
func NormalizeMySQLIdentifierList ¶
func NormalizeMySQLIdentifierList(ctx parser.IIdentifierListContext) []string
NormalizeMySQLIdentifierList normalizes the given identifier list.
func NormalizeMySQLProcedureName ¶
func NormalizeMySQLProcedureName(ctx parser.IProcedureNameContext) (string, string)
NormalizeMySQLProcedureName normalizes the given procedure name.
func NormalizeMySQLProcedureRef ¶
func NormalizeMySQLProcedureRef(ctx parser.IProcedureRefContext) (string, string)
NormalizeMySQLProcedureRef normalizes the given procedure ref.
func NormalizeMySQLPureIdentifier ¶
func NormalizeMySQLPureIdentifier(pureIdentifier parser.IPureIdentifierContext) string
func NormalizeMySQLSchemaName ¶
func NormalizeMySQLSchemaName(ctx parser.ISchemaNameContext) string
NormalizeMySQLSchemaName normalize the given schemaName.
func NormalizeMySQLSchemaRef ¶
func NormalizeMySQLSchemaRef(ctx parser.ISchemaRefContext) string
NormalizeMySQLSchemaRef normalize the given schemaRef.
func NormalizeMySQLSelectAlias ¶
func NormalizeMySQLSelectAlias(selectAlias parser.ISelectAliasContext) string
NormalizeMySQLSelectAlias normalizes the given select alias.
func NormalizeMySQLSignedLiteral ¶
func NormalizeMySQLSignedLiteral(ctx parser.ISignedLiteralContext) string
NormalizeMySQLSignedLiteral normalize the given SignedLiteral.
func NormalizeMySQLTableName ¶
func NormalizeMySQLTableName(ctx parser.ITableNameContext) (string, string)
NormalizeMySQLTableName normalizes the given table name.
func NormalizeMySQLTableRef ¶
func NormalizeMySQLTableRef(ctx parser.ITableRefContext) (string, string)
NormalizeMySQLTableRef normalizes the given table reference.
func NormalizeMySQLTableRefWithWildcard ¶
func NormalizeMySQLTableRefWithWildcard(ctx parser.ITableRefWithWildcardContext) (string, string)
func NormalizeMySQLTextLiteral ¶
func NormalizeMySQLTextLiteral(ctx parser.ITextLiteralContext) string
NormalizeMySQLTextLiteral normalize the given TextStringLiteral.
func NormalizeMySQLTextOrIdentifier ¶
func NormalizeMySQLTextOrIdentifier(ctx parser.ITextOrIdentifierContext) string
NormalizeMySQLTextOrIdentifier normalizes the given TextOrIdentifier.
func NormalizeMySQLTextStringLiteral ¶
func NormalizeMySQLTextStringLiteral(ctx parser.ITextStringLiteralContext) string
NormalizeMySQLTextStringLiteral normalize the given TextStringLiteral.
func NormalizeMySQLTriggerName ¶
func NormalizeMySQLTriggerName(ctx parser.ITriggerNameContext) (string, string)
NormalizeMySQLTriggerName normalizes the given trigger name.
func NormalizeMySQLViewName ¶
func NormalizeMySQLViewName(ctx parser.IViewNameContext) (string, string)
NormalizeMySQLViewName normalizes the given view name.
func NormalizeMySQLViewRef ¶
func NormalizeMySQLViewRef(ctx parser.IViewRefContext) (string, string)
func ParseMySQL ¶
func ParseMySQL(statement string) ([]*base.ParseResult, error)
ParseMySQL parses the given SQL statement and returns the AST.
func RestoreDelimiter ¶
RestoreDelimiter tries to restore the delimiter statement which is commented by DealWithDelimiter,
Assumes the delimiter comment takes up a single line and matches the syntax `-- DELIMITER ?`, also, one delimiter comment MUST only affect one statement, in the other words, the following statement cause UB: -- DELIMITER ; SELECT 1; SELECT 2; -- DELIMITER ;. If the current delimiter is `;`, and meet `-- DELIMITER ;`, we would skip this delimiter comment.
func TransformDMLToSelect ¶
Types ¶
type CTETableListener ¶
type CTETableListener struct {
*mysql.BaseMySQLParserListener
// contains filtered or unexported fields
}
func (*CTETableListener) EnterCommonTableExpression ¶
func (l *CTETableListener) EnterCommonTableExpression(ctx *mysql.CommonTableExpressionContext)
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 ObjectFlags ¶
type ObjectFlags int
const ( ObjectFlagsShowSchemas ObjectFlags = 1 << iota ObjectFlagsShowTables ObjectFlagsShowColumns ObjectFlagsShowFirst ObjectFlagsShowSecond )
type SelectAliasListener ¶
type SelectAliasListener struct {
*mysql.BaseMySQLParserListener
// contains filtered or unexported fields
}
func (*SelectAliasListener) EnterSelectAlias ¶
func (l *SelectAliasListener) EnterSelectAlias(ctx *mysql.SelectAliasContext)
type StatementInfo ¶
type StatementInfo struct {
Offset int
Statement string
Tree antlr.ParserRuleContext
Table *TableReference
StartPosition *store.Position
EndPosition *store.Position
}
func ExtractTables ¶
func ExtractTables(databaseName string, parseResult *base.ParseResult, offset int) ([]StatementInfo, error)
type StatementType ¶
type StatementType int
const ( StatementTypeUnknown StatementType = iota StatementTypeUpdate StatementTypeInsert StatementTypeDelete )
type StatementTypeChecker ¶
type StatementTypeChecker struct {
*mysql.BaseMySQLParserListener
IsDDL bool
IsDML bool
IsExplain bool
Text string
}
func (*StatementTypeChecker) EnterAlterStatement ¶
func (checker *StatementTypeChecker) EnterAlterStatement(ctx *mysql.AlterStatementContext)
DDL from g4 alterStatement createStatement dropStatement renameTableStatement truncateTableStatement importStatement EnterAlterStatement is called when production alterStatement is entered.
func (*StatementTypeChecker) EnterCallStatement ¶
func (checker *StatementTypeChecker) EnterCallStatement(ctx *mysql.CallStatementContext)
DML EnterCallStatement is called when production callStatement is entered.
func (*StatementTypeChecker) EnterCreateStatement ¶
func (checker *StatementTypeChecker) EnterCreateStatement(ctx *mysql.CreateStatementContext)
EnterCreateStatement is called when production createStatement is entered.
func (*StatementTypeChecker) EnterDeleteStatement ¶
func (checker *StatementTypeChecker) EnterDeleteStatement(ctx *mysql.DeleteStatementContext)
EnterDeleteStatement is called when production deleteStatement is entered.
func (*StatementTypeChecker) EnterDoStatement ¶
func (checker *StatementTypeChecker) EnterDoStatement(ctx *mysql.DoStatementContext)
EnterDoStatement is called when production doStatement is entered.
func (*StatementTypeChecker) EnterDropStatement ¶
func (checker *StatementTypeChecker) EnterDropStatement(ctx *mysql.DropStatementContext)
EnterDropStatement is called when production dropStatement is entered.
func (*StatementTypeChecker) EnterExplainStatement ¶
func (checker *StatementTypeChecker) EnterExplainStatement(ctx *mysql.ExplainStatementContext)
EnterExplainStatement is called when production explainStatement is entered.
func (*StatementTypeChecker) EnterHandlerStatement ¶
func (checker *StatementTypeChecker) EnterHandlerStatement(ctx *mysql.HandlerStatementContext)
EnterHandlerStatement is called when production handlerStatement is entered.
func (*StatementTypeChecker) EnterImportStatement ¶
func (checker *StatementTypeChecker) EnterImportStatement(ctx *mysql.ImportStatementContext)
EnterImportStatement is called when production importStatement is entered.
func (*StatementTypeChecker) EnterInsertStatement ¶
func (checker *StatementTypeChecker) EnterInsertStatement(ctx *mysql.InsertStatementContext)
EnterInsertStatement is called when production insertStatement is entered.
func (*StatementTypeChecker) EnterLoadDataFileTail ¶
func (checker *StatementTypeChecker) EnterLoadDataFileTail(ctx *mysql.LoadDataFileTailContext)
EnterLoadDataFileTail is called when production loadDataFileTail is entered.
func (*StatementTypeChecker) EnterPreparedStatement ¶
func (checker *StatementTypeChecker) EnterPreparedStatement(ctx *mysql.PreparedStatementContext)
EnterPreparedStatement is called when production preparedStatement is entered.
func (*StatementTypeChecker) EnterQuery ¶
func (checker *StatementTypeChecker) EnterQuery(ctx *mysql.QueryContext)
func (*StatementTypeChecker) EnterRenameTableStatement ¶
func (checker *StatementTypeChecker) EnterRenameTableStatement(ctx *mysql.RenameTableStatementContext)
EnterRenameTableStatement is called when production renameTableStatement is entered.
func (*StatementTypeChecker) EnterReplaceStatement ¶
func (checker *StatementTypeChecker) EnterReplaceStatement(ctx *mysql.ReplaceStatementContext)
EnterReplaceStatement is called when production replaceStatement is entered.
func (*StatementTypeChecker) EnterReplicationStatement ¶
func (checker *StatementTypeChecker) EnterReplicationStatement(ctx *mysql.ReplicationStatementContext)
EnterReplicationStatement is called when production replicationStatement is entered.
func (*StatementTypeChecker) EnterSelectStatement ¶
func (checker *StatementTypeChecker) EnterSelectStatement(ctx *mysql.SelectStatementContext)
EnterSelectStatement is called when production selectStatement is entered.
func (*StatementTypeChecker) EnterTransactionOrLockingStatement ¶
func (checker *StatementTypeChecker) EnterTransactionOrLockingStatement(ctx *mysql.TransactionOrLockingStatementContext)
EnterTransactionOrLockingStatement is called when production transactionOrLockingStatement is entered.
func (*StatementTypeChecker) EnterTruncateTableStatement ¶
func (checker *StatementTypeChecker) EnterTruncateTableStatement(ctx *mysql.TruncateTableStatementContext)
EnterTruncateTableStatement is called when production truncateTableStatement is entered.
func (*StatementTypeChecker) EnterUpdateStatement ¶
func (checker *StatementTypeChecker) EnterUpdateStatement(ctx *mysql.UpdateStatementContext)
EnterUpdateStatement is called when production updateStatement is entered.
type TableRefListener ¶
type TableRefListener struct {
*mysql.BaseMySQLParserListener
// contains filtered or unexported fields
}
func (*TableRefListener) EnterDerivedTable ¶
func (l *TableRefListener) EnterDerivedTable(ctx *mysql.DerivedTableContext)
func (*TableRefListener) EnterSubquery ¶
func (l *TableRefListener) EnterSubquery(_ *mysql.SubqueryContext)
func (*TableRefListener) ExitSubquery ¶
func (l *TableRefListener) ExitSubquery(_ *mysql.SubqueryContext)
func (*TableRefListener) ExitTableAlias ¶
func (l *TableRefListener) ExitTableAlias(ctx *mysql.TableAliasContext)
func (*TableRefListener) ExitTableRef ¶
func (l *TableRefListener) ExitTableRef(ctx *mysql.TableRefContext)
type TableReference ¶
type TableReference struct {
Database string
Table string
Alias string
StatementType StatementType
}