You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/11/03 12:03:16 UTC
[GitHub] [shardingsphere] flycash opened a new pull request #13444: Support MySQL show relay log events
flycash opened a new pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444
Fixes #13134.
Changes proposed in this pull request:
- overide visitLogName, visitChannelName
- introduce ChannelNameSegment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu merged pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
strongduanmu merged pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#discussion_r742451951
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLShowRelaylogEventsStatement.java
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.ChannelNameSegment;
+
+import java.util.List;
+
+/**
+ * MySQL show relay log events statement.
+ */
+@ToString
+@Getter
+@Setter
+public final class MySQLShowRelaylogEventsStatement extends AbstractSQLStatement implements DALStatement, MySQLStatement {
+
+ private StringLiteralValue logName;
+
+ private NumberLiteralValue from;
+
+ private List<NumberLiteralValue> limit;
+
+ private ChannelNameSegment channel;
Review comment:
@flycash Can we use String type to replace StringLiteralValue and ChannelNameSegment? They seem to be a string.
##########
File path: shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dal/ShowRelaylogEventsStatementTestCase.java
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.dal;
+
+import lombok.Getter;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.channel.ExpectedChannelNameSegment;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.List;
+
+/**
+ * show relay log events statement test case.
Review comment:
@flycash The first letter of javadoc needs to be capitalized.
##########
File path: 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
##########
@@ -452,6 +459,44 @@ public ASTNode visitShowCreateTrigger(final ShowCreateTriggerContext ctx) {
result.setName(((IdentifierValue) visit(ctx.triggerName())).getValue());
return result;
}
+
+ @Override
+ public ASTNode visitShowRelaylogEvent(final MySQLStatementParser.ShowRelaylogEventContext ctx) {
+ MySQLShowRelaylogEventsStatement result = new MySQLShowRelaylogEventsStatement();
+ ChannelNameSegment channel = (ChannelNameSegment) visit(ctx.channelName());
+ result.setChannel(channel);
+ Optional.ofNullable(ctx.logName())
+ .map(this::visit)
+ .map(node -> (StringLiteralValue) node)
+ .ifPresent(result::setLogName);
+ List<TerminalNode> numbers = ctx.NUMBER_();
+ Optional.ofNullable(ctx.FROM())
+ .ifPresent(node -> result.setFrom(new NumberLiteralValue(numbers.remove(0).getText())));
+ Optional.ofNullable(ctx.LIMIT())
+ .ifPresent(node -> result.setLimit(numbers.stream()
+ .map(ParseTree::getText)
+ .map(NumberLiteralValue::new)
+ .collect(Collectors.toList())));
+ return result;
+ }
+
+ @Override
+ public ASTNode visitLogName(final MySQLStatementParser.LogNameContext ctx) {
+ return visit(ctx.stringLiterals());
+ }
+
+ @Override
+ public ASTNode visitChannelName(final MySQLStatementParser.ChannelNameContext ctx) {
+ ChannelNameSegment result = new ChannelNameSegment();
+ result.setStartIndex(ctx.start.getStartIndex());
+ result.setStopIndex(ctx.stop.getStopIndex());
+ result.setIdentifiers(ctx.identifier().stream()
Review comment:
@flycash Please use the new visit method to encapsulate these logic.
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/ChannelNameSegment.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.segment;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+
+import java.util.List;
+
+@Getter
+@Setter
+public class ChannelNameSegment implements SQLSegment {
Review comment:
@flycash Please add javadoc for ChannelNameSegment if we need this segment.
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLShowRelaylogEventsStatement.java
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.ChannelNameSegment;
+
+import java.util.List;
+
+/**
+ * MySQL show relay log events statement.
+ */
+@ToString
+@Getter
+@Setter
+public final class MySQLShowRelaylogEventsStatement extends AbstractSQLStatement implements DALStatement, MySQLStatement {
+
+ private StringLiteralValue logName;
+
+ private NumberLiteralValue from;
+
+ private List<NumberLiteralValue> limit;
Review comment:
@flycash Does the limit here have the same meaning as the limit of the paging query? If yes, please use LimitSegement.
##########
File path: 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
##########
@@ -452,6 +459,44 @@ public ASTNode visitShowCreateTrigger(final ShowCreateTriggerContext ctx) {
result.setName(((IdentifierValue) visit(ctx.triggerName())).getValue());
return result;
}
+
+ @Override
+ public ASTNode visitShowRelaylogEvent(final MySQLStatementParser.ShowRelaylogEventContext ctx) {
+ MySQLShowRelaylogEventsStatement result = new MySQLShowRelaylogEventsStatement();
+ ChannelNameSegment channel = (ChannelNameSegment) visit(ctx.channelName());
+ result.setChannel(channel);
+ Optional.ofNullable(ctx.logName())
+ .map(this::visit)
+ .map(node -> (StringLiteralValue) node)
+ .ifPresent(result::setLogName);
+ List<TerminalNode> numbers = ctx.NUMBER_();
+ Optional.ofNullable(ctx.FROM())
+ .ifPresent(node -> result.setFrom(new NumberLiteralValue(numbers.remove(0).getText())));
+ Optional.ofNullable(ctx.LIMIT())
+ .ifPresent(node -> result.setLimit(numbers.stream()
+ .map(ParseTree::getText)
+ .map(NumberLiteralValue::new)
+ .collect(Collectors.toList())));
+ return result;
+ }
+
+ @Override
+ public ASTNode visitLogName(final MySQLStatementParser.LogNameContext ctx) {
Review comment:
@flycash Please use static import instead.
##########
File path: 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
##########
@@ -452,6 +459,44 @@ public ASTNode visitShowCreateTrigger(final ShowCreateTriggerContext ctx) {
result.setName(((IdentifierValue) visit(ctx.triggerName())).getValue());
return result;
}
+
+ @Override
+ public ASTNode visitShowRelaylogEvent(final MySQLStatementParser.ShowRelaylogEventContext ctx) {
+ MySQLShowRelaylogEventsStatement result = new MySQLShowRelaylogEventsStatement();
+ ChannelNameSegment channel = (ChannelNameSegment) visit(ctx.channelName());
+ result.setChannel(channel);
+ Optional.ofNullable(ctx.logName())
Review comment:
@flycash Can you use the new visit method to encapsulate this logic? The use of lambda expressions here does not seem very clear.
##########
File path: shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/impl/ShowRelaylogEventsStatementAssert.java
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.asserts.statement.dal.impl;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowRelaylogEventsStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.ChannelNameSegment;
+import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.channel.ExpectedChannelNameSegment;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.ShowRelaylogEventsStatementTestCase;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * show relay log events statement assert.
Review comment:
@flycash Please use static import instead.
##########
File path: shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/channel/ExpectedChannelNameSegment.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.segment.impl.channel;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.AbstractExpectedSQLSegment;
+
+import javax.xml.bind.annotation.XmlElement;
+import java.util.List;
+
+@Setter
+@Getter
+public class ExpectedChannelNameSegment extends AbstractExpectedSQLSegment {
Review comment:
@flycash Please add final for ExpectedChannelNameSegment and add a blank line after this line.
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLShowRelaylogEventsStatement.java
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.ChannelNameSegment;
+
+import java.util.List;
+
+/**
+ * MySQL show relay log events statement.
+ */
+@ToString
+@Getter
+@Setter
+public final class MySQLShowRelaylogEventsStatement extends AbstractSQLStatement implements DALStatement, MySQLStatement {
+
+ private StringLiteralValue logName;
+
+ private NumberLiteralValue from;
Review comment:
What is the meaning of from?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tuichenchuxin commented on pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
tuichenchuxin commented on pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#issuecomment-963733256
@flycash Please have a look at failed ci test. And I still suggest to keep logName and channelName is enough.We don't need the field about position, offset or row count.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] flycash commented on pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
flycash commented on pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#issuecomment-963772111
But I don't know why the CI failed. It seems that I didn't changes these code:

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] flycash commented on pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
flycash commented on pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#issuecomment-963774020
I check other PRs' CI, all failed due to the same problem. I think some merged PRs may have some problem
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tuichenchuxin commented on pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
tuichenchuxin commented on pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#issuecomment-963783275
@flycash This ci problem has been fixed, please pull master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#discussion_r742451951
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLShowRelaylogEventsStatement.java
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.ChannelNameSegment;
+
+import java.util.List;
+
+/**
+ * MySQL show relay log events statement.
+ */
+@ToString
+@Getter
+@Setter
+public final class MySQLShowRelaylogEventsStatement extends AbstractSQLStatement implements DALStatement, MySQLStatement {
+
+ private StringLiteralValue logName;
+
+ private NumberLiteralValue from;
+
+ private List<NumberLiteralValue> limit;
+
+ private ChannelNameSegment channel;
Review comment:
@flycash Can we use String type to replace StringLiteralValue and ChannelNameSegment? They seem to be a string.
##########
File path: shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dal/ShowRelaylogEventsStatementTestCase.java
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.dal;
+
+import lombok.Getter;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.channel.ExpectedChannelNameSegment;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.List;
+
+/**
+ * show relay log events statement test case.
Review comment:
@flycash The first letter of javadoc needs to be capitalized.
##########
File path: 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
##########
@@ -452,6 +459,44 @@ public ASTNode visitShowCreateTrigger(final ShowCreateTriggerContext ctx) {
result.setName(((IdentifierValue) visit(ctx.triggerName())).getValue());
return result;
}
+
+ @Override
+ public ASTNode visitShowRelaylogEvent(final MySQLStatementParser.ShowRelaylogEventContext ctx) {
+ MySQLShowRelaylogEventsStatement result = new MySQLShowRelaylogEventsStatement();
+ ChannelNameSegment channel = (ChannelNameSegment) visit(ctx.channelName());
+ result.setChannel(channel);
+ Optional.ofNullable(ctx.logName())
+ .map(this::visit)
+ .map(node -> (StringLiteralValue) node)
+ .ifPresent(result::setLogName);
+ List<TerminalNode> numbers = ctx.NUMBER_();
+ Optional.ofNullable(ctx.FROM())
+ .ifPresent(node -> result.setFrom(new NumberLiteralValue(numbers.remove(0).getText())));
+ Optional.ofNullable(ctx.LIMIT())
+ .ifPresent(node -> result.setLimit(numbers.stream()
+ .map(ParseTree::getText)
+ .map(NumberLiteralValue::new)
+ .collect(Collectors.toList())));
+ return result;
+ }
+
+ @Override
+ public ASTNode visitLogName(final MySQLStatementParser.LogNameContext ctx) {
+ return visit(ctx.stringLiterals());
+ }
+
+ @Override
+ public ASTNode visitChannelName(final MySQLStatementParser.ChannelNameContext ctx) {
+ ChannelNameSegment result = new ChannelNameSegment();
+ result.setStartIndex(ctx.start.getStartIndex());
+ result.setStopIndex(ctx.stop.getStopIndex());
+ result.setIdentifiers(ctx.identifier().stream()
Review comment:
@flycash Please use the new visit method to encapsulate these logic.
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/ChannelNameSegment.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.segment;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+
+import java.util.List;
+
+@Getter
+@Setter
+public class ChannelNameSegment implements SQLSegment {
Review comment:
@flycash Please add javadoc for ChannelNameSegment if we need this segment.
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLShowRelaylogEventsStatement.java
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.ChannelNameSegment;
+
+import java.util.List;
+
+/**
+ * MySQL show relay log events statement.
+ */
+@ToString
+@Getter
+@Setter
+public final class MySQLShowRelaylogEventsStatement extends AbstractSQLStatement implements DALStatement, MySQLStatement {
+
+ private StringLiteralValue logName;
+
+ private NumberLiteralValue from;
+
+ private List<NumberLiteralValue> limit;
Review comment:
@flycash Does the limit here have the same meaning as the limit of the paging query? If yes, please use LimitSegement.
##########
File path: 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
##########
@@ -452,6 +459,44 @@ public ASTNode visitShowCreateTrigger(final ShowCreateTriggerContext ctx) {
result.setName(((IdentifierValue) visit(ctx.triggerName())).getValue());
return result;
}
+
+ @Override
+ public ASTNode visitShowRelaylogEvent(final MySQLStatementParser.ShowRelaylogEventContext ctx) {
+ MySQLShowRelaylogEventsStatement result = new MySQLShowRelaylogEventsStatement();
+ ChannelNameSegment channel = (ChannelNameSegment) visit(ctx.channelName());
+ result.setChannel(channel);
+ Optional.ofNullable(ctx.logName())
+ .map(this::visit)
+ .map(node -> (StringLiteralValue) node)
+ .ifPresent(result::setLogName);
+ List<TerminalNode> numbers = ctx.NUMBER_();
+ Optional.ofNullable(ctx.FROM())
+ .ifPresent(node -> result.setFrom(new NumberLiteralValue(numbers.remove(0).getText())));
+ Optional.ofNullable(ctx.LIMIT())
+ .ifPresent(node -> result.setLimit(numbers.stream()
+ .map(ParseTree::getText)
+ .map(NumberLiteralValue::new)
+ .collect(Collectors.toList())));
+ return result;
+ }
+
+ @Override
+ public ASTNode visitLogName(final MySQLStatementParser.LogNameContext ctx) {
Review comment:
@flycash Please use static import instead.
##########
File path: 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
##########
@@ -452,6 +459,44 @@ public ASTNode visitShowCreateTrigger(final ShowCreateTriggerContext ctx) {
result.setName(((IdentifierValue) visit(ctx.triggerName())).getValue());
return result;
}
+
+ @Override
+ public ASTNode visitShowRelaylogEvent(final MySQLStatementParser.ShowRelaylogEventContext ctx) {
+ MySQLShowRelaylogEventsStatement result = new MySQLShowRelaylogEventsStatement();
+ ChannelNameSegment channel = (ChannelNameSegment) visit(ctx.channelName());
+ result.setChannel(channel);
+ Optional.ofNullable(ctx.logName())
Review comment:
@flycash Can you use the new visit method to encapsulate this logic? The use of lambda expressions here does not seem very clear.
##########
File path: shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/impl/ShowRelaylogEventsStatementAssert.java
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.asserts.statement.dal.impl;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowRelaylogEventsStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.ChannelNameSegment;
+import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.channel.ExpectedChannelNameSegment;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.ShowRelaylogEventsStatementTestCase;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * show relay log events statement assert.
Review comment:
@flycash Please use static import instead.
##########
File path: shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/channel/ExpectedChannelNameSegment.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.segment.impl.channel;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.AbstractExpectedSQLSegment;
+
+import javax.xml.bind.annotation.XmlElement;
+import java.util.List;
+
+@Setter
+@Getter
+public class ExpectedChannelNameSegment extends AbstractExpectedSQLSegment {
Review comment:
@flycash Please add final for ExpectedChannelNameSegment and add a blank line after this line.
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLShowRelaylogEventsStatement.java
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.ChannelNameSegment;
+
+import java.util.List;
+
+/**
+ * MySQL show relay log events statement.
+ */
+@ToString
+@Getter
+@Setter
+public final class MySQLShowRelaylogEventsStatement extends AbstractSQLStatement implements DALStatement, MySQLStatement {
+
+ private StringLiteralValue logName;
+
+ private NumberLiteralValue from;
Review comment:
What is the meaning of from?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tristaZero commented on pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#issuecomment-963786011
Hey @flycash Welcome, thanks for your continued feedback.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tuichenchuxin commented on pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
tuichenchuxin commented on pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#issuecomment-960371781
@flycash Thank you for your pr. I have a suggestion, for this statement
```
SHOW RELAYLOG EVENTS (IN logName)? (FROM NUMBER_)? (LIMIT (NUMBER_ COMMA_)? NUMBER_)? FOR CHANNEL channelName
```
I think we may not need to visit every part. What we need to know is just which this statement is, and where it will route to execute. So, may be `MySQLShowRelaylogEventsStatement` class with logName or channelName is enough?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] flycash commented on pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
flycash commented on pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#issuecomment-963355845
Hi, I have resolve all issues and I am not sure if I got your points. Please help to check it @tuichenchuxin @strongduanmu
And I rename from -> position, limit -> offset, rowCount.

It looks like shardingsphere did not support channel options here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] flycash commented on pull request #13444: Support MySQL show relay log events
Posted by GitBox <gi...@apache.org>.
flycash commented on pull request #13444:
URL: https://github.com/apache/shardingsphere/pull/13444#issuecomment-963759661
@tuichenchuxin Hi, I removed these three fields and please check it again
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org