This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 6dabf07 Fix mysql g4 file (#8446)
6dabf07 is described below
commit 6dabf0757a642c8645e74573dacf47d6b10f2f49
Author: JingShang Lu <[email protected]>
AuthorDate: Tue Dec 1 19:02:20 2020 +0800
Fix mysql g4 file (#8446)
* fix mysql g4 file
* fix
* add some testcase
---
.../src/main/antlr4/imports/mysql/BaseRule.g4 | 42 ++++++++++++++++++----
.../src/main/antlr4/imports/mysql/DALStatement.g4 | 37 +++++++++++--------
.../src/main/antlr4/imports/mysql/DDLStatement.g4 | 36 ++++++++++++++-----
.../src/main/antlr4/imports/mysql/DMLStatement.g4 | 4 +++
.../src/main/antlr4/imports/mysql/RLStatement.g4 | 24 ++++++-------
.../src/main/antlr4/imports/mysql/TCLStatement.g4 | 23 ++++++------
.../sql/parser/autogen/MySQLStatement.g4 | 41 ++++++++++++++++++++-
.../impl/MySQLDALStatementSQLVisitor.java | 14 --------
.../impl/MySQLDDLStatementSQLVisitor.java | 2 +-
.../statement/impl/MySQLStatementSQLVisitor.java | 6 ++--
.../impl/MySQLTCLStatementSQLVisitor.java | 7 ++++
.../sql/parser/core/visitor/SQLVisitorRule.java | 6 ++--
.../sql/common/statement/tcl/XAStatement.java | 26 ++++++++++++++
.../statement/mysql/tcl/MySQLXAStatement.java | 29 +++++++++++++++
.../jaxb/cases/domain/SQLParserTestCases.java | 5 +++
.../cases/domain/statement/tcl/XATestCase.java | 26 ++++++++++++++
.../src/main/resources/case/dal/set.xml | 5 +++
.../main/resources/case/tcl/set-transaction.xml | 7 ++++
.../src/main/resources/sql/supported/dal/set.xml | 1 +
.../src/main/resources/sql/supported/tcl/tcl.xml | 7 ++++
20 files changed, 271 insertions(+), 77 deletions(-)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
index 0b09d05..a202324 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
@@ -85,7 +85,7 @@ nullValueLiterals
;
collationName
- : identifier | STRING_ | BINARY
+ : textOrIdentifier | BINARY
;
identifier
@@ -152,6 +152,14 @@ variable
: (AT_? AT_)? scope? DOT_? internalVariableName
;
+userVariable
+ : AT_ textOrIdentifier
+ ;
+
+systemVariable
+ : AT_ AT_ scope? textOrIdentifier (DOT_ identifier)?
+ ;
+
scope
: GLOBAL | PERSIST | PERSIST_ONLY | SESSION | LOCAL
;
@@ -175,7 +183,7 @@ schemaNames
;
charsetName
- : identifier | BINARY | DEFAULT
+ : textOrIdentifier | BINARY
;
schemaPairs
@@ -245,8 +253,8 @@ name
: identifier
;
-tableNames
- : LP_? tableName (COMMA_ tableName)* RP_?
+tableList
+ : tableName (COMMA_ tableName)*
;
viewNames
@@ -317,6 +325,10 @@ triggerTime
: BEFORE | AFTER
;
+tableOrTables
+ : TABLE | TABLES
+ ;
+
userOrRole
: userName | roleName
;
@@ -765,11 +777,11 @@ collectionOptions
;
characterSet
- : charset EQ_? charsetName
+ : charset charsetName
;
collateClause
- : COLLATE EQ_? collationName
+ : COLLATE collationName
;
ignoredIdentifier
@@ -820,3 +832,21 @@ noWriteToBinLog
: LOCAL
| NO_WRITE_TO_BINLOG
;
+
+channelOption
+ : FOR CHANNEL STRING_
+ ;
+
+preparedStatement
+ : PREPARE identifier FROM (stringLiterals | userVariable)
+ | executeStatement
+ | (DEALLOCATE | DROP) PREPARE identifier
+ ;
+
+executeStatement
+ : EXECUTE identifier (USING executeVarList)?
+ ;
+
+executeVarList
+ : userVariable (COMMA_ userVariable)*
+ ;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DALStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DALStatement.g4
index a7f2cd6..d6cc922 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DALStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DALStatement.g4
@@ -58,10 +58,6 @@ showCreateTable
: SHOW CREATE TABLE tableName
;
-showOther
- : SHOW
- ;
-
fromSchema
: (FROM | IN) schemaName
;
@@ -239,7 +235,7 @@ setCharacter
;
setName
- : SET NAMES (charsetName (COLLATE collationName)? | DEFAULT)
+ : SET NAMES (EQ_ expr | charsetName collateClause? | DEFAULT)
;
clone
@@ -247,7 +243,7 @@ clone
;
cloneAction
- : LOCAL DATA DIRECTORY EQ_? cloneDir SEMI_
+ : LOCAL DATA DIRECTORY EQ_? cloneDir
| INSTANCE FROM cloneInstance IDENTIFIED BY STRING_ (DATA DIRECTORY EQ_?
cloneDir)? (REQUIRE NO? SSL)?
;
@@ -255,6 +251,14 @@ createUdf
: CREATE AGGREGATE? FUNCTION functionName RETURNS (STRING | INTEGER | REAL
| DECIMAL) SONAME shardLibraryName
;
+install
+ : installComponent | installPlugin
+ ;
+
+uninstall
+ :uninstallComponent | uninstallPlugin
+ ;
+
installComponent
: INSTALL COMPONENT componentName (COMMA_ componentName)*
;
@@ -272,13 +276,16 @@ uninstallPlugin
;
analyzeTable
- : ANALYZE (NO_WRITE_TO_BINLOG | LOCAL)? TABLE (tableNames
- | tableName UPDATE HISTOGRAM ON columnNames (WITH NUMBER_ BUCKETS)
- | tableName DROP HISTOGRAM ON columnNames)
+ : ANALYZE (NO_WRITE_TO_BINLOG | LOCAL)? tableOrTables tableList histogram?
+ ;
+
+histogram
+ : UPDATE HISTOGRAM ON columnNames (WITH NUMBER_ BUCKETS)?
+ | DROP HISTOGRAM ON columnNames
;
checkTable
- : CHECK TABLE tableNames checkTableOption
+ : CHECK tableOrTables tableList checkTableOption?
;
checkTableOption
@@ -286,14 +293,14 @@ checkTableOption
;
checksumTable
- : CHECKSUM TABLE tableNames (QUICK | EXTENDED)
+ : CHECKSUM tableOrTables tableList (QUICK | EXTENDED)?
;
optimizeTable
- : OPTIMIZE (NO_WRITE_TO_BINLOG | LOCAL)? TABLE tableNames
+ : OPTIMIZE (NO_WRITE_TO_BINLOG | LOCAL)? tableOrTables tableList
;
repairTable
- : REPAIR (NO_WRITE_TO_BINLOG | LOCAL)? TABLE tableNames QUICK? EXTENDED?
USE_FRM?
+ : REPAIR (NO_WRITE_TO_BINLOG | LOCAL)? tableOrTables tableList QUICK?
EXTENDED? USE_FRM?
;
alterResourceGroup
@@ -358,10 +365,12 @@ loadIndexInfo
resetStatement
: RESET resetOption (COMMA_ resetOption)*
+ | resetPersist
;
resetOption
- : MASTER | SLAVE | QUERY CACHE
+ : MASTER (TO binaryLogFileIndexNumber)?
+ | SLAVE ALL? channelOption?
;
resetPersist
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
index fdacc9d..c773ea6 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
@@ -22,11 +22,12 @@ import Symbol, Keyword, MySQLKeyword, Literals, BaseRule,
DMLStatement, DALState
alterStatement
: alterTable
| alterDatabase
- | alterFunction
+ | alterProcedure
| alterFunction
| alterEvent
| alterView
| alterTablespaceInnodb
+ | alterTablespaceNdb
| alterLogfileGroup
| alterInstance
| alterServer
@@ -186,7 +187,7 @@ partitionNames
;
dropTable
- : DROP TEMPORARY? (TABLE | TABLES) existClause? tableNames restrict?
+ : DROP TEMPORARY? tableOrTables existClause? tableList restrict?
;
dropIndex
@@ -220,9 +221,9 @@ alterDatabase
;
createDatabaseSpecification_
- : DEFAULT? characterSet
- | DEFAULT? COLLATE EQ_? collationName
- | DEFAULT? ENCRYPTION EQ_? y_or_n=STRING_
+ : defaultCollation
+ | defaultCollation
+ | defaultEncryption
;
alterDatabaseSpecification_
@@ -542,7 +543,7 @@ createTableOption
| option = (CHECKSUM | TABLE_CHECKSUM) EQ_? NUMBER_
| option = DELAY_KEY_WRITE EQ_? NUMBER_
| option = ROW_FORMAT EQ_? format = (DEFAULT | DYNAMIC | FIXED |
COMPRESSED | REDUNDANT | COMPACT)
- | option = UNION EQ_? LP_ tableNames RP_
+ | option = UNION EQ_? LP_ tableList RP_
| defaultCharset
| defaultCollation
| option = INSERT_METHOD EQ_? method = (NO| FIRST| LAST)
@@ -556,6 +557,22 @@ createTableOption
| option = SECONDARY_ENGINE_ATTRIBUTE EQ_ jsonAttribute = STRING_
;
+createSRSStatement
+ : CREATE OR REPLACE SPATIAL REFERENCE SYSTEM NUMBER_ srsAttribute*
+ | CREATE SPATIAL REFERENCE SYSTEM notExistClause? NUMBER_ srsAttribute*
+ ;
+
+dropSRSStatement
+ : DROP SPATIAL REFERENCE SYSTEM notExistClause? NUMBER_
+ ;
+
+srsAttribute
+ : NAME STRING_
+ | DEFINITION STRING_
+ | ORGANIZATION STRING_ IDENTIFIED BY NUMBER_
+ | DESCRIPTION STRING_
+ ;
+
place
: FIRST | AFTER columnName
;
@@ -742,9 +759,10 @@ declareHandlerStatement
;
getDiagnosticsStatement
- : GET (CURRENT | STACKED)? DIAGNOSTICS
- ((statementInformationItem (COMMA_ statementInformationItem)*)
- | (CONDITION conditionNumber conditionInformationItem (COMMA_
conditionInformationItem)*))
+ : GET (CURRENT | STACKED)? DIAGNOSTICS (
+ (statementInformationItem (COMMA_ statementInformationItem)*
+ | (CONDITION conditionNumber conditionInformationItem (COMMA_
conditionInformationItem)*))
+ )
;
statementInformationItem
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DMLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DMLStatement.g4
index 28513e9..fa63608 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DMLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DMLStatement.g4
@@ -178,6 +178,10 @@ importStatement
: IMPORT TABLE FROM STRING_ (COMMA_ STRING_)?
;
+loadStatement
+ : loadDataStatement | loadXmlStatement
+ ;
+
loadDataStatement
: LOAD DATA
(LOW_PRIORITY | CONCURRENT)? LOCAL?
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/RLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/RLStatement.g4
index 68ba12d..a6167b2 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/RLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/RLStatement.g4
@@ -19,6 +19,10 @@ grammar RLStatement;
import Symbol, Keyword, MySQLKeyword, Literals, BaseRule;
+change
+ : changeMasterTo | changeReplicationFilter
+ ;
+
changeMasterTo
: CHANGE MASTER TO masterDefs channelOption?
;
@@ -35,6 +39,10 @@ stopSlave
: STOP SLAVE threadTypes channelOption*
;
+groupReplication
+ : startGroupReplication | stopGroupReplication
+ ;
+
startGroupReplication
: START GROUP_REPLICATION
;
@@ -47,14 +55,6 @@ purgeBinaryLog
: PURGE (BINARY | MASTER) LOGS (TO logName | BEFORE datetimeExpr)
;
-resetMaster
- : RESET MASTER (TO binaryLogFileIndexNumber)?
- ;
-
-resetSlave
- : RESET SLAVE ALL? channelOption?
- ;
-
threadTypes
: threadType+
;
@@ -74,10 +74,6 @@ connectionOptions
: (USER EQ_ STRING_)? (PASSWORD EQ_ STRING_)? (DEFAULT_AUTH EQ_ STRING_)?
(PLUGIN_DIR EQ_ STRING_)?
;
-channelOption
- : FOR CHANNEL STRING_
- ;
-
masterDefs
: masterDef (COMMA_ masterDef)*
;
@@ -132,8 +128,8 @@ filterDefs
filterDef
: REPLICATE_DO_DB EQ_ LP_ schemaNames? RP_
| REPLICATE_IGNORE_DB EQ_ LP_ schemaNames? RP_
- | REPLICATE_DO_TABLE EQ_ LP_ tableNames? RP_
- | REPLICATE_IGNORE_TABLE EQ_ LP_ tableNames? RP_
+ | REPLICATE_DO_TABLE EQ_ LP_ tableList? RP_
+ | REPLICATE_IGNORE_TABLE EQ_ LP_ tableList? RP_
| REPLICATE_WILD_DO_TABLE EQ_ LP_ wildTables? RP_
| REPLICATE_WILD_IGNORE_TABLE EQ_ LP_ wildTables? RP_
| REPLICATE_REWRITE_DB EQ_ LP_ schemaPairs? RP_
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/TCLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/TCLStatement.g4
index e8852c0..07a748e 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/TCLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/TCLStatement.g4
@@ -36,11 +36,11 @@ beginTransaction
;
commit
- : COMMIT optionWork? optionChain? optionRelease?
+ : COMMIT WORK? optionChain? optionRelease?
;
rollback
- : ROLLBACK (optionWork? TO SAVEPOINT? identifier | optionWork?
optionChain? optionRelease?)
+ : ROLLBACK (WORK? TO SAVEPOINT? identifier | WORK? optionChain?
optionRelease?)
;
savepoint
@@ -48,7 +48,7 @@ savepoint
;
begin
- : BEGIN optionWork?
+ : BEGIN WORK?
;
lock
@@ -64,12 +64,13 @@ releaseSavepoint
;
xa
- : (START | BEGIN) xid (JOIN | RESUME)
- | END xid (SUSPEND (FOR MIGRATE)?)?
- | PREPARE xid
- | COMMIT xid (ONE PHASE)?
- | ROLLBACK xid
- | RECOVER (CONVERT xid)?
+ : XA ((START | BEGIN) xid (JOIN | RESUME)
+ | END xid (SUSPEND (FOR MIGRATE)?)?
+ | PREPARE xid
+ | COMMIT xid (ONE PHASE)?
+ | ROLLBACK xid
+ | RECOVER (CONVERT xid)?
+ )
;
transactionCharacteristic
@@ -84,10 +85,6 @@ accessMode
: READ (WRITE | ONLY)
;
-optionWork
- : WORK
- ;
-
optionChain
: AND NO? CHAIN
;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/MySQLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/MySQLStatement.g4
index 1331d9b..90a60ee 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/MySQLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/MySQLStatement.g4
@@ -48,6 +48,10 @@ execute
| dropView
| createTrigger
| dropTrigger
+ | alterResourceGroup
+ | createResourceGroup
+ | dropResourceGroup
+ | preparedStatement
| setTransaction
| beginTransaction
| setAutoCommit
@@ -64,18 +68,53 @@ execute
| dropRole
| setDefaultRole
| setRole
+ | createTablespaceInnodb
+ | createTablespaceNdb
+ | dropTablespace
+ | createSRSStatement
+ | dropSRSStatement
+ | flush
+ | getDiagnosticsStatement
+ | groupReplication
+ | handlerStatement
+ | help
+ | importStatement
+ | install
+ | kill
+ | loadStatement
+ | lock
+ | cacheIndex
+ | loadIndexInfo
+ | optimizeTable
+ | purgeBinaryLog
+ | releaseSavepoint
+ | resetStatement
| setPassword
+ | setTransaction
+ | setResourceGroup
+ | resignalStatement
+ | signalStatement
+ | restart
+ | shutdown
+ | begin
| use
| explain
+ | doStatement
| show
| setVariable
| setName
| setCharacter
| call
- | changeMasterTo
+ | change
+ | checkTable
+ | checksumTable
+ | clone
| startSlave
| stopSlave
| analyzeTable
| renameTable
+ | uninstall
+ | unlock
+ | xa
) (SEMI_ EOF? | EOF)
;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
index e0f2004..805d939 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
@@ -51,7 +51,6 @@ import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ShowDat
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ShowErrorsContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ShowIndexContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ShowLikeContext;
-import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ShowOtherContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ShowStatusContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ShowTableStatusContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ShowTablesContext;
@@ -285,11 +284,6 @@ public final class MySQLDALStatementSQLVisitor extends
MySQLStatementSQLVisitor
result.setTable((SimpleTableSegment) visit(ctx.tableName()));
return result;
}
-
- @Override
- public ASTNode visitShowOther(final ShowOtherContext ctx) {
- return new MySQLShowOtherStatement();
- }
@Override
public ASTNode visitShowVariables(final ShowVariablesContext ctx) {
@@ -327,14 +321,6 @@ public final class MySQLDALStatementSQLVisitor extends
MySQLStatementSQLVisitor
characterSet.setAssignValue(assignValue);
MySQLSetStatement result = new MySQLSetStatement();
result.getVariableAssigns().add(characterSet);
- if (null != ctx.collationName()) {
- VariableAssignSegment collation = new VariableAssignSegment();
- VariableSegment collationVariable = new VariableSegment();
- collationVariable.setVariable(ctx.COLLATE().getText());
- collation.setVariable(collationVariable);
- collation.setAssignValue(ctx.collationName().getText());
- result.getVariableAssigns().add(collation);
- }
return result;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDDLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDDLStatementSQLVisitor.java
index 9af658c..6da958e 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDDLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDDLStatementSQLVisitor.java
@@ -404,7 +404,7 @@ public final class MySQLDDLStatementSQLVisitor extends
MySQLStatementSQLVisitor
@Override
public ASTNode visitDropTable(final DropTableContext ctx) {
MySQLDropTableStatement result = new MySQLDropTableStatement();
- result.getTables().addAll(((CollectionValue<SimpleTableSegment>)
visit(ctx.tableNames())).getValue());
+ result.getTables().addAll(((CollectionValue<SimpleTableSegment>)
visit(ctx.tableList())).getValue());
return result;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
index 84c0cc3..4e51f2d 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
@@ -64,6 +64,7 @@ import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.SingleT
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.StringLiteralsContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.NumberLiteralsContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TableFactorContext;
+import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TableListContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TableReferenceContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TableReferencesContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TemporalLiteralsContext;
@@ -83,7 +84,6 @@ import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ViewNam
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ViewNamesContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ColumnNameContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ColumnNamesContext;
-import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TableNamesContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.IndexNameContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ExprContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.BooleanPrimaryContext;
@@ -312,14 +312,14 @@ public abstract class MySQLStatementSQLVisitor extends
MySQLStatementBaseVisitor
}
@Override
- public final ASTNode visitTableNames(final TableNamesContext ctx) {
+ public ASTNode visitTableList(final TableListContext ctx) {
CollectionValue<SimpleTableSegment> result = new CollectionValue<>();
for (TableNameContext each : ctx.tableName()) {
result.getValue().add((SimpleTableSegment) visit(each));
}
return result;
}
-
+
@Override
public final ASTNode visitViewNames(final ViewNamesContext ctx) {
CollectionValue<SimpleTableSegment> result = new CollectionValue<>();
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLTCLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLTCLStatementSQLVisitor.java
index ca252f6..7918c2f 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLTCLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLTCLStatementSQLVisitor.java
@@ -29,6 +29,7 @@ import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ScopeCo
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.SetAutoCommitContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.SetTransactionContext;
import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TransactionCharacteristicContext;
+import
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.XaContext;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.tcl.AutoCommitSegment;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.tcl.MySQLBeginTransactionStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.tcl.MySQLCommitStatement;
@@ -36,6 +37,7 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.tcl.MySQ
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.tcl.MySQLSavepointStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.tcl.MySQLSetAutoCommitStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.tcl.MySQLSetTransactionStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.tcl.MySQLXAStatement;
/**
* TCL Statement SQL visitor for MySQL.
@@ -98,4 +100,9 @@ public final class MySQLTCLStatementSQLVisitor extends
MySQLStatementSQLVisitor
public ASTNode visitSavepoint(final SavepointContext ctx) {
return new MySQLSavepointStatement();
}
+
+ @Override
+ public ASTNode visitXa(final XaContext ctx) {
+ return new MySQLXAStatement();
+ }
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
index 3a320af..156dcb2 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
@@ -186,8 +186,10 @@ public enum SQLVisitorRule {
START_SLAVE("StartSlave", SQLStatementType.RL),
- STOP_SLAVE("StopSlave", SQLStatementType.RL);
-
+ STOP_SLAVE("StopSlave", SQLStatementType.RL),
+
+ XA("Xa", SQLStatementType.TCL);
+
private final String name;
@Getter
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/tcl/XAStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/tcl/XAStatement.java
new file mode 100644
index 0000000..eafb9a0
--- /dev/null
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/tcl/XAStatement.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.common.statement.tcl;
+
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+
+/**
+ * Set transaction statement.
+ */
+public abstract class XAStatement extends AbstractSQLStatement implements
TCLStatement {
+}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/tcl/MySQLXAStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/tcl/MySQLXAStatement.java
new file mode 100644
index 0000000..ee3cde7
--- /dev/null
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/tcl/MySQLXAStatement.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.tcl;
+
+import lombok.ToString;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.XAStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+
+/**
+ * MySQL savepoint statement.
+ */
+@ToString
+public final class MySQLXAStatement extends XAStatement implements
MySQLStatement {
+}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index 497f633..aa1ff90 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -81,6 +81,7 @@ import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.tcl.SavepointStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.tcl.SetAutoCommitStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.tcl.SetTransactionStatementTestCase;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.tcl.XATestCase;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -280,6 +281,9 @@ public final class SQLParserTestCases {
@XmlElement(name = "call")
private final List<CallStatementTestCase> callProcedureTestCase = new
LinkedList<>();
+
+ @XmlElement(name = "xa")
+ private final List<XATestCase> xaTestCase = new LinkedList<>();
/**
* Get all SQL parser test cases.
@@ -349,6 +353,7 @@ public final class SQLParserTestCases {
putAll(dropFunctionTestCase, result);
putAll(dropDatabaseTestCase, result);
putAll(callProcedureTestCase, result);
+ putAll(xaTestCase, result);
return result;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/tcl/XATestCase.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/tcl/XATestCase.java
new file mode 100644
index 0000000..cf0338b
--- /dev/null
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/tcl/XATestCase.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.tcl;
+
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+/**
+ * Set transaction statement test case.
+ */
+public final class XATestCase extends SQLParserTestCase {
+}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dal/set.xml
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dal/set.xml
index 60293ef..b751089 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dal/set.xml
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dal/set.xml
@@ -75,4 +75,9 @@
<variable name="extra_float_digits" />
</variable-assign>
</set-variable>
+ <set-variable sql-case-id="set_names" >
+ <variable-assign value="'utf8'" >
+ <variable name="charset" />
+ </variable-assign>
+ </set-variable>
</sql-parser-test-cases>
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/tcl/set-transaction.xml
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/tcl/set-transaction.xml
index 3e93b22..303c174 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/tcl/set-transaction.xml
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/tcl/set-transaction.xml
@@ -23,4 +23,11 @@
<set-transaction sql-case-id="setTransactionReadOnly" />
<set-transaction sql-case-id="setTransactionWithName" />
<set-transaction sql-case-id="setTransactionSnapshot" />
+ <xa sql-case-id="xa-recover" />
+ <xa sql-case-id="xa-start" />
+ <xa sql-case-id="xa-begin" />
+ <xa sql-case-id="xa-end" />
+ <xa sql-case-id="xa-prepare" />
+ <xa sql-case-id="xa-commit" />
+ <xa sql-case-id="xa-rollback" />
</sql-parser-test-cases>
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dal/set.xml
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dal/set.xml
index ef088b1..96303e1 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dal/set.xml
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dal/set.xml
@@ -35,4 +35,5 @@
<sql-case id="set_parameter_equal_boolean" value="SET extra_float_digits =
true" db-types="PostgreSQL" />
<sql-case id="set_parameter_equal_list" value="SET extra_float_digits =
1,2,3" db-types="PostgreSQL" />
<sql-case id="set_parameter_equal_number_with_signal" value="SET
extra_float_digits = -10.5" db-types="PostgreSQL" />
+ <sql-case id="set_names" value="SET NAMES 'utf8' COLLATE
'utf8_general_ci'" db-types="MySQL" />
</sql-cases>
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/tcl/tcl.xml
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/tcl/tcl.xml
index 61e8eb4..8d3510f 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/tcl/tcl.xml
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/tcl/tcl.xml
@@ -48,4 +48,11 @@
<sql-case id="commit_in_pg" value="COMMIT TRANSACTION AND NO CHAIN"
db-types="PostgreSQL" />
<sql-case id="rollback_in_pg" value="ROLLBACK TRANSACTION AND CHAIN"
db-types="PostgreSQL" />
<sql-case id="begin_with_transaction_mode" value="BEGIN TRANSACTION
ISOLATION LEVEL READ COMMITTED" db-types="PostgreSQL" />
+ <sql-case id="xa-recover" value="XA RECOVER" db-types="MySQL" />
+ <sql-case id="xa-start" value="XA start 'abcdef7' join" db-types="MySQL" />
+ <sql-case id="xa-begin" value="XA begin 'abcdef7' join" db-types="MySQL" />
+ <sql-case id="xa-end" value="XA end 'abcdef7'" db-types="MySQL" />
+ <sql-case id="xa-prepare" value="XA prepare 'abcdef7'" db-types="MySQL" />
+ <sql-case id="xa-commit" value="XA commit 'abcdef7'" db-types="MySQL" />
+ <sql-case id="xa-rollback" value="XA rollback 'abcdef7'" db-types="MySQL"
/>
</sql-cases>