Class MySqlAntlrDdlParser
java.lang.Object
io.debezium.relational.ddl.AbstractDdlParser
io.debezium.antlr.AntlrDdlParser<MySqlLexer,MySqlParser>
io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser
- All Implemented Interfaces:
DdlParser
An ANTLR based parser for MySQL DDL statements.
- Author:
- Roman Kuchár <kucharrom@gmail.com>.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<String,String> private final MySqlValueConvertersprivate final Tables.TableFilterFields inherited from class io.debezium.antlr.AntlrDdlParser
databaseTables, dataTypeResolverFields inherited from class io.debezium.relational.ddl.AbstractDdlParser
ddlChanges, logger, skipComments, skipViews, systemVariables -
Constructor Summary
ConstructorsConstructorDescriptionMySqlAntlrDdlParser(boolean throwErrorsFromTreeWalk, boolean includeViews, boolean includeComments, MySqlValueConverters converters, Tables.TableFilter tableFilter) MySqlAntlrDdlParser(MySqlValueConverters converters) MySqlAntlrDdlParser(MySqlValueConverters converters, Tables.TableFilter tableFilter) -
Method Summary
Modifier and TypeMethodDescriptioncharsetForTable(TableId tableId) Get the name of the character set for the give table name.Provides a map of default character sets by database/schema name.protected MySqlLexercreateNewLexerInstance(org.antlr.v4.runtime.CharStream charStreams) protected MySqlParsercreateNewParserInstance(org.antlr.v4.runtime.CommonTokenStream commonTokenStream) protected SystemVariablesprotected AntlrDdlParserListenerGet the name of the character set for the current database, via the "character_set_database" system property.static StringescapeOption(String option) extractCharset(MySqlParser.CharsetNameContext charsetNode, MySqlParser.CollationNameContext collationNode) Obtains the charset name either form charset if present or from collation.extractEnumAndSetOptions(List<String> enumValues) Extracts the enumeration values properly parsed and escaped.protected DataTypeResolverprotected booleanparseName(MySqlParser.UidContext uidContext) Parse a name fromMySqlParser.UidContext.voidparsePrimaryIndexColumnNames(MySqlParser.IndexColumnNamesContext indexColumnNamesContext, TableEditor tableEditor) Parse column names for primary index fromMySqlParser.IndexColumnNamesContext.parseQualifiedTableId(MySqlParser.FullIdContext fullIdContext) Parse qualified table identification fromMySqlParser.FullIdContext.protected org.antlr.v4.runtime.tree.ParseTreeparseTree(MySqlParser parser) voidrunIfNotNull(Runnable function, Object... nullableObjects) Runs a function if all given object are not null.Methods inherited from class io.debezium.antlr.AntlrDdlParser
databaseTables, dataTypeResolver, debugParsed, debugSkipped, getParsingExceptionsFromWalker, getText, getText, parse, signalAlterDatabase, signalAlterTable, signalAlterTable, signalAlterView, signalCreateDatabase, signalCreateIndex, signalCreateTable, signalCreateView, signalDropDatabase, signalDropIndex, signalDropTable, signalDropTable, signalDropView, signalSetVariable, signalTruncateTable, signalUseDatabase, skipComments, skipViews, withoutQuotesMethods inherited from class io.debezium.relational.ddl.AbstractDdlParser
accumulateParsingFailure, accumulateParsingFailure, commentParsed, createColumnFromConstant, currentSchema, debugParsed, debugSkipped, getDdlChanges, isQuote, isQuoted, removeLineFeeds, resolveTableId, setCurrentDatabase, setCurrentSchema, setTypeInfoForConstant, signalAlterDatabase, signalAlterTable, signalAlterView, signalChangeEvent, signalCreateDatabase, signalCreateIndex, signalCreateTable, signalCreateView, signalDropDatabase, signalDropIndex, signalDropView, signalSetVariable, signalTruncateTable, signalUseDatabase, systemVariables, withoutQuotes
-
Field Details
-
charsetNameForDatabase
-
converters
-
tableFilter
-
-
Constructor Details
-
MySqlAntlrDdlParser
public MySqlAntlrDdlParser() -
MySqlAntlrDdlParser
-
MySqlAntlrDdlParser
-
MySqlAntlrDdlParser
public MySqlAntlrDdlParser(boolean throwErrorsFromTreeWalk, boolean includeViews, boolean includeComments, MySqlValueConverters converters, Tables.TableFilter tableFilter)
-
-
Method Details
-
parseTree
- Specified by:
parseTreein classAntlrDdlParser<MySqlLexer,MySqlParser>
-
createParseTreeWalkerListener
- Specified by:
createParseTreeWalkerListenerin classAntlrDdlParser<MySqlLexer,MySqlParser>
-
createNewLexerInstance
- Specified by:
createNewLexerInstancein classAntlrDdlParser<MySqlLexer,MySqlParser>
-
createNewParserInstance
protected MySqlParser createNewParserInstance(org.antlr.v4.runtime.CommonTokenStream commonTokenStream) - Specified by:
createNewParserInstancein classAntlrDdlParser<MySqlLexer,MySqlParser>
-
createNewSystemVariablesInstance
- Specified by:
createNewSystemVariablesInstancein classAbstractDdlParser
-
isGrammarInUpperCase
protected boolean isGrammarInUpperCase()- Specified by:
isGrammarInUpperCasein classAntlrDdlParser<MySqlLexer,MySqlParser>
-
initializeDataTypeResolver
- Specified by:
initializeDataTypeResolverin classAntlrDdlParser<MySqlLexer,MySqlParser>
-
charsetNameForDatabase
Provides a map of default character sets by database/schema name.- Returns:
- map of default character sets.
-
parseName
Parse a name fromMySqlParser.UidContext.- Parameters:
uidContext- uid context- Returns:
- name without quotes.
-
parseQualifiedTableId
Parse qualified table identification fromMySqlParser.FullIdContext.AbstractDdlParser.currentSchema()will be used if definition of schema name is not part of the context.- Parameters:
fullIdContext- full id context.- Returns:
- qualified
TableId.
-
parsePrimaryIndexColumnNames
public void parsePrimaryIndexColumnNames(MySqlParser.IndexColumnNamesContext indexColumnNamesContext, TableEditor tableEditor) Parse column names for primary index fromMySqlParser.IndexColumnNamesContext. This method will updates column to be not optional and set primary key column names to table.- Parameters:
indexColumnNamesContext- primary key index column names context.tableEditor- editor for table where primary key index is parsed.
-
currentDatabaseCharset
Get the name of the character set for the current database, via the "character_set_database" system property.- Returns:
- the name of the character set for the current database, or null if not known ...
-
charsetForTable
Get the name of the character set for the give table name.- Returns:
- the name of the character set for the given table, or null if not known ...
-
runIfNotNull
Runs a function if all given object are not null.- Parameters:
function- function to run; may not be nullnullableObjects- object to be tested, if they are null.
-
extractEnumAndSetOptions
Extracts the enumeration values properly parsed and escaped.- Parameters:
enumValues- the raw enumeration values from the parsed column definition- Returns:
- the list of options allowed for the
ENUMorSET; never null.
-
escapeOption
-
getConverters
-
getTableFilter
-
extractCharset
public String extractCharset(MySqlParser.CharsetNameContext charsetNode, MySqlParser.CollationNameContext collationNode) Obtains the charset name either form charset if present or from collation.- Parameters:
charsetNode-collationNode-- Returns:
- character set
-