未验证 提交 db9423d4 编写于 作者: J JingShang Lu 提交者: GitHub

fix g4 of mysql dal (#5547)

上级 5fdb81a3
......@@ -587,3 +587,11 @@ notExistClause_
existClause_
: (IF EXISTS)?
;
pattern
: STRING_
;
connectionId_
: NUMBER_
;
......@@ -17,26 +17,33 @@
grammar DALStatement;
import Symbol, Keyword, MySQLKeyword, Literals, BaseRule;
import Symbol, Keyword, MySQLKeyword, Literals, BaseRule, DMLStatement;
use
: USE schemaName
;
desc
: (DESC | DESCRIBE) tableName
help
: HELP STRING_
;
explain
: (DESC | DESCRIBE | EXPLAIN)
(tableName (columnName | pattern)?
| explainType? (explainableStatement | FOR CONNECTION connectionId_)
| ANALYZE select)
;
showDatabases
: SHOW (DATABASES | SCHEMAS) (showLike | showWhereClause_)?
: SHOW (DATABASES | SCHEMAS) showFilter?
;
showTables
: SHOW EXTENDED? FULL? TABLES fromSchema? (showLike | showWhereClause_)?
: SHOW EXTENDED? FULL? TABLES fromSchema? showFilter?
;
showTableStatus
: SHOW TABLE STATUS fromSchema? (showLike | showWhereClause_)?
: SHOW TABLE STATUS fromSchema? showFilter?
;
showColumns
......@@ -108,7 +115,7 @@ showCollation
;
showCreateDatabase
: SHOW CREATE (DATABASE | SCHEMA) (IF NOT EXISTS)? schemaName
: SHOW CREATE (DATABASE | SCHEMA) notExistClause_ schemaName
;
showCreateEvent
......@@ -144,7 +151,7 @@ showEngines
;
showErrors
: SHOW ((ERRORS (LIMIT (NUMBER_ COMMA_)? NUMBER_)?) | (COUNT LP_ ASTERISK_ RP_ ERRORS))
: SHOW (COUNT LP_ ASTERISK_ RP_)? ERRORS (LIMIT (NUMBER_ COMMA_)? NUMBER_)?
;
showEvents
......@@ -160,7 +167,7 @@ showFunctionStatus
;
showGrant
: SHOW GRANTS ( FOR (userName | roleName) (USING roleName (COMMA_ roleName)+)?)
: SHOW GRANTS (FOR userOrRole (USING roleName (COMMA_ roleName)+)?)?
;
showMasterStatus
......@@ -192,7 +199,7 @@ showProcesslist
;
showProfile
: SHOW PROFILE ( showProfileType (COMMA_ showProfileType)*)? (FOR QUERY NUMBER_)? (LIMIT NUMBER_ (OFFSET NUMBER_))?
: SHOW PROFILE ( showProfileType (COMMA_ showProfileType)*)? (FOR QUERY NUMBER_)? (LIMIT NUMBER_ (OFFSET NUMBER_)?)?
;
showProfiles
......@@ -200,7 +207,7 @@ showProfiles
;
showRelaylogEvent
: SHOW RELAYLOG EVENTS (IN logName)? (FROM NUMBER_)? (LIMIT (NUMBER_ COMMA_)? NUMBER_) FOR CHANNEL channelName
: SHOW RELAYLOG EVENTS (IN logName)? (FROM NUMBER_)? (LIMIT (NUMBER_ COMMA_)? NUMBER_)? FOR CHANNEL channelName
;
showSlavehost
......@@ -208,11 +215,11 @@ showSlavehost
;
showSlaveStatus
: SHOW SLAVE STATUS (FOR CHANNEL channelName)
: SHOW SLAVE STATUS (FOR CHANNEL channelName)?
;
showStatus
: SHOW (GLOBAL | SESSION) STATUS showFilter?
: SHOW (GLOBAL | SESSION)? STATUS showFilter?
;
showTrriggers
......@@ -220,11 +227,11 @@ showTrriggers
;
showVariables
: SHOW (GLOBAL | SESSION)? VARIABLES showFilter
: SHOW (GLOBAL | SESSION)? VARIABLES showFilter?
;
showWarnings
: SHOW ((WARNINGS (LIMIT (NUMBER_ COMMA_)? NUMBER_)?) | (COUNT LP_ ASTERISK_ RP_ WARNINGS))
: SHOW (COUNT LP_ ASTERISK_ RP_)? WARNINGS (LIMIT (NUMBER_ COMMA_)? NUMBER_)?
;
setCharacter
......@@ -241,11 +248,11 @@ clone
cloneAction_
: LOCAL DATA DIRECTORY EQ_? cloneDir SEMI_
| INSTANCE FROM cloneInstance IDENTIFIED BY STRING_ (DATA DIRECTORY EQ_ cloneDir)? (REQUIRE NO? SSL)?
| INSTANCE FROM cloneInstance IDENTIFIED BY STRING_ (DATA DIRECTORY EQ_? cloneDir)? (REQUIRE NO? SSL)?
;
createUdf
: CREATE AGGREGATE FUNCTION functionName RETURNS ( STRING | INTEGER | REAL | DECIMAL) SONAME shardLibraryName
: CREATE AGGREGATE? FUNCTION functionName RETURNS (STRING | INTEGER | REAL | DECIMAL) SONAME shardLibraryName
;
installComponent
......@@ -320,7 +327,7 @@ cacheIndex
;
tableIndexList
: tableName (PARTITION LP_ partitionList RP_)? ((INDEX | KEY) LP_ indexName (COMMA_ indexName)* RP_)?
: tableName (PARTITION LP_ partitionList RP_)? ((INDEX | KEY) LP_ indexName (COMMA_ indexName)* RP_)? (IGNORE LEAVES)?
;
partitionList
......@@ -328,7 +335,7 @@ partitionList
;
flush
: FLUSH (NO_WRITE_TO_BINLOG | LOCAL)? (flushOption_ (COMMA_ flushOption_) * | tablesOption_)
: FLUSH (NO_WRITE_TO_BINLOG | LOCAL)? (flushOption_ (COMMA_ flushOption_)* | tablesOption_)
;
flushOption_
......@@ -358,7 +365,7 @@ resetOption_
;
resetPersist
: RESET PERSIST ((IF EXISTS)? IDENTIFIER_)
: RESET PERSIST (existClause_ IDENTIFIER_)
;
restart
......@@ -368,3 +375,16 @@ restart
shutdown
: SHUTDOWN
;
explainType
: FORMAT EQ_ formatName
;
explainableStatement
: select | tableStatement | delete | insert | replace | update
;
formatName
: 'TRADITIONAL' | JSON | 'TREE'
;
......@@ -52,7 +52,7 @@ execute
| setRole
| setPassword
| use
| desc
| explain
| showDatabases
| showTables
| showTableStatus
......
......@@ -23,7 +23,7 @@ import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.Variabl
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AnalyzeTableContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CacheIndexContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ChecksumTableContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DescContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ExplainContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FlushContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FromSchemaContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FromTableContext;
......@@ -212,7 +212,7 @@ public final class MySQLDALVisitor extends MySQLVisitor implements DALVisitor {
}
@Override
public ASTNode visitDesc(final DescContext ctx) {
public ASTNode visitExplain(final ExplainContext ctx) {
DescribeStatement result = new DescribeStatement();
result.setTable((SimpleTableSegment) visit(ctx.tableName()));
return result;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册