未验证 提交 5798d0c5 编写于 作者: D DuanZhengqiang 提交者: GitHub

support mysql alter instance, create, alter and drop logfile group statement (#6897)

* support mysql alter instance statement

* support mysql create, alter, drop logfile group statement

* support mysql create, alter, drop server statement
上级 589f42d9
......@@ -126,15 +126,17 @@ dropDatabase
alterInstance
: ALTER INSTANCE instanceAction
;
instanceAction
: ROTATE INNODB_ MASTER KEY | ROTATE BINLOG MASTER KEY | RELOAD TLS_ (FOR CHANNEL channel)? (NO ROLLBACK ON ERROR)?
: (ENABLE | DISABLE) INNODB_ REDO_LOG_
| ROTATE INNODB_ MASTER KEY
| ROTATE BINLOG MASTER KEY
| RELOAD TLS (FOR CHANNEL channel)? (NO ROLLBACK ON ERROR)?
;
channel
: MYSQL_ADMIN
: MYSQL_MAIN | MYSQL_ADMIN
;
createEvent
......@@ -278,18 +280,19 @@ createLogfileGroup
(NODEGROUP EQ_? identifier)?
WAIT?
(COMMENT EQ_? STRING_)?
ENGINE EQ_? identifier
(ENGINE EQ_? identifier)?
;
alterLogfileGroup
: ALTER LOGFILE GROUP identifier
ADD UNDOFILE STRING_
(INITIAL_SIZE EQ_? fileSizeLiteral_)?
WAIT? ENGINE EQ_? identifier
WAIT?
(ENGINE EQ_? identifier)?
;
dropLogfileGroup
: DROP LOGFILE GROUP identifier ENGINE EQ_? identifier
: DROP LOGFILE GROUP identifier (ENGINE EQ_? identifier)?
;
createTrigger
......
......@@ -80,6 +80,10 @@ TREE
: T R E E
;
MYSQL_MAIN
: M Y S Q L UL_ M A I N
;
MYSQL_ADMIN
: M Y S Q L UL_ A D M I N
;
......
......@@ -19,6 +19,18 @@ lexer grammar Literals;
import Alphabet, Symbol;
INNODB_
: 'INNODB'
;
REDO_LOG_
: 'REDO_LOG'
;
FILESIZE_LITERAL
: INT_ ('K'|'M'|'G'|'T')
;
IDENTIFIER_
: [A-Za-z_$0-9]*?[A-Za-z_$]+?[A-Za-z_$0-9]*
| BQ_ ~'`'+ BQ_
......@@ -46,22 +58,10 @@ BIT_NUM_
: '0b' ('0' | '1')+ | B SQ_ ('0' | '1')+ SQ_
;
INNODB_
: 'INNODB'
;
TLS_
: 'TLS'
;
NOT_SUPPORT_
: 'not support'
;
FILESIZE_LITERAL
: INT_ ('K'|'M'|'G'|'T')
;
fragment INT_
: [0-9]+
;
......
......@@ -45,6 +45,13 @@ execute
| createEvent
| alterEvent
| dropEvent
| alterInstance
| createLogfileGroup
| alterLogfileGroup
| dropLogfileGroup
| createServer
| alterServer
| dropServer
| setTransaction
| beginTransaction
| setAutoCommit
......
......@@ -26,7 +26,10 @@ import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterDa
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterDefinitionClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterEventContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterFunctionContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterInstanceContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterLogfileGroupContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterProcedureContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterServerContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterSpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AlterTableContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ChangeColumnSpecificationContext;
......@@ -40,7 +43,9 @@ import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateE
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateFunctionContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateIndexContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateLikeClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateLogfileGroupContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateProcedureContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateServerContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateTableContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateViewContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropColumnSpecificationContext;
......@@ -48,8 +53,10 @@ import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropDat
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropEventContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropFunctionContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropIndexContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropLogfileGroupContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropPrimaryKeySpecificationContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropProcedureContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropServerContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropTableContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.DropViewContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FirstOrAfterColumnContext;
......@@ -84,20 +91,27 @@ import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTabl
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.AlterDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.AlterEventStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.AlterFunctionStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.AlterInstanceStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.AlterLogfileGroupStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.AlterProcedureStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.AlterServerStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.AlterTableStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateEventStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateFunctionStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateIndexStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateLogfileGroupStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateProcedureStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateServerStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateTableStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.CreateViewStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropEventStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropFunctionStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropIndexStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropLogfileGroupStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropProcedureStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropServerStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropTableStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.DropViewStatement;
import org.apache.shardingsphere.sql.parser.sql.statement.ddl.RenameTableStatement;
......@@ -481,4 +495,39 @@ public final class MySQLDDLVisitor extends MySQLVisitor implements DDLVisitor {
public ASTNode visitDropEvent(final DropEventContext ctx) {
return new DropEventStatement();
}
@Override
public ASTNode visitAlterInstance(final AlterInstanceContext ctx) {
return new AlterInstanceStatement();
}
@Override
public ASTNode visitCreateLogfileGroup(final CreateLogfileGroupContext ctx) {
return new CreateLogfileGroupStatement();
}
@Override
public ASTNode visitAlterLogfileGroup(final AlterLogfileGroupContext ctx) {
return new AlterLogfileGroupStatement();
}
@Override
public ASTNode visitDropLogfileGroup(final DropLogfileGroupContext ctx) {
return new DropLogfileGroupStatement();
}
@Override
public ASTNode visitCreateServer(final CreateServerContext ctx) {
return new CreateServerStatement();
}
@Override
public ASTNode visitAlterServer(final AlterServerContext ctx) {
return new AlterServerStatement();
}
@Override
public ASTNode visitDropServer(final DropServerContext ctx) {
return new DropServerStatement();
}
}
......@@ -75,6 +75,20 @@ public enum VisitorRule {
ALTER_EVENT("AlterEvent", SQLStatementType.DDL),
DROP_EVENT("DropEvent", SQLStatementType.DDL),
ALTER_INSTANCE("AlterInstance", SQLStatementType.DDL),
CREATE_LOGFILE_GROUP("CreateLogfileGroup", SQLStatementType.DDL),
ALTER_LOGFILE_GROUP("AlterLogfileGroup", SQLStatementType.DDL),
DROP_LOGFILE_GROUP("DropLogfileGroup", SQLStatementType.DDL),
CREATE_SERVER("CreateServer", SQLStatementType.DDL),
ALTER_SERVER("AlterServer", SQLStatementType.DDL),
DROP_SERVER("DropServer", SQLStatementType.DDL),
SET_TRANSACTION("SetTransaction", SQLStatementType.TCL),
......
/*
* 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.statement.ddl;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* Alter instance statement.
*/
@RequiredArgsConstructor
@Getter
public final class AlterInstanceStatement extends DDLStatement {
}
/*
* 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.statement.ddl;
/**
* Alter logfile group statement.
*/
public final class AlterLogfileGroupStatement extends DDLStatement {
}
/*
* 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.statement.ddl;
/**
* Alter server statement.
*/
public final class AlterServerStatement extends DDLStatement {
}
/*
* 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.statement.ddl;
/**
* Create logfile group statement.
*/
public final class CreateLogfileGroupStatement extends DDLStatement {
}
/*
* 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.statement.ddl;
/**
* Create server statement.
*/
public final class CreateServerStatement extends DDLStatement {
}
/*
* 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.statement.ddl;
/**
* Drop logfile group statement.
*/
public final class DropLogfileGroupStatement extends DDLStatement {
}
/*
* 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.statement.ddl;
/**
* Drop server statement.
*/
public final class DropServerStatement extends DDLStatement {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册