You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "chakkk309 (via GitHub)" <gi...@apache.org> on 2025/09/24 01:03:29 UTC
[PR] Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement [shardingsphere]
chakkk309 opened a new pull request, #36680:
URL: https://github.com/apache/shardingsphere/pull/36680
Fixes #36583.
Changes proposed in this pull request:
-
---
Before committing this PR, I'm sure that I have checked the following options:
- [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [ ] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the pull request.
- [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [ ] I have added corresponding unit tests for my changes.
- [ ] I have updated the Release Notes of the current development version. For more details, see [Update Release Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
--
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
Re: [PR] Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #36680:
URL: https://github.com/apache/shardingsphere/pull/36680#issuecomment-3434869933
> Hi @strongduanmu , this pr is ready to review~
Ok, I will review this pr later.
--
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
Re: [PR] Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu merged PR #36680:
URL: https://github.com/apache/shardingsphere/pull/36680
--
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
Re: [PR] Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement [shardingsphere]
Posted by "chakkk309 (via GitHub)" <gi...@apache.org>.
chakkk309 commented on PR #36680:
URL: https://github.com/apache/shardingsphere/pull/36680#issuecomment-3430320792
Hi @strongduanmu , this pr is ready to review~
--
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
Re: [PR] Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on code in PR #36680:
URL: https://github.com/apache/shardingsphere/pull/36680#discussion_r2380957090
##########
parser/sql/engine/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/engine/mysql/visitor/statement/MySQLStatementVisitor.java:
##########
@@ -1526,6 +1566,26 @@ private Collection<InsertValuesSegment> createInsertValuesSegments(final Collect
return result;
}
+ @Override
+ public ASTNode visitRowAlias(final RowAliasContext ctx) {
+ return new CommonExpressionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.getText());
Review Comment:
Why return CommonExpressionSegment?
##########
parser/sql/engine/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/engine/mysql/visitor/statement/MySQLStatementVisitor.java:
##########
@@ -1625,10 +1685,11 @@ public ASTNode visitUpdate(final UpdateContext ctx) {
@Override
public ASTNode visitSetAssignmentsClause(final SetAssignmentsClauseContext ctx) {
Collection<ColumnAssignmentSegment> assignments = new LinkedList<>();
- for (AssignmentContext each : ctx.assignment()) {
+ for (AssignmentContext each : ctx.assignmentList().assignment()) {
assignments.add((ColumnAssignmentSegment) visit(each));
}
- return new SetAssignmentSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), assignments);
+ SetAssignmentSegment setAssignment = new SetAssignmentSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), assignments);
+ return setAssignment;
Review Comment:
Please remove setAssignment and return `new xxx` directly.
##########
parser/sql/engine/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/engine/mysql/visitor/statement/MySQLStatementVisitor.java:
##########
@@ -1515,6 +1549,12 @@ public ASTNode visitInsertValuesClause(final InsertValuesClauseContext ctx) {
result.setInsertColumns(new InsertColumnsSegment(ctx.start.getStartIndex() - 1, ctx.start.getStartIndex() - 1, Collections.emptyList()));
}
result.getValues().addAll(createInsertValuesSegments(ctx.assignmentValues()));
+
+ if (null != ctx.valueReference()) {
+ ValueReferenceSegment valueRef = (ValueReferenceSegment) visit(ctx.valueReference());
+ result.setValueReference(valueRef);
+ }
+
Review Comment:
Please remove useless blank line.
##########
parser/sql/engine/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/engine/mysql/visitor/statement/MySQLStatementVisitor.java:
##########
@@ -1515,6 +1549,12 @@ public ASTNode visitInsertValuesClause(final InsertValuesClauseContext ctx) {
result.setInsertColumns(new InsertColumnsSegment(ctx.start.getStartIndex() - 1, ctx.start.getStartIndex() - 1, Collections.emptyList()));
}
result.getValues().addAll(createInsertValuesSegments(ctx.assignmentValues()));
+
Review Comment:
Please remove useless blank line.
##########
parser/sql/engine/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/engine/mysql/visitor/statement/MySQLStatementVisitor.java:
##########
@@ -1526,6 +1566,26 @@ private Collection<InsertValuesSegment> createInsertValuesSegments(final Collect
return result;
}
+ @Override
+ public ASTNode visitRowAlias(final RowAliasContext ctx) {
+ return new CommonExpressionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.getText());
Review Comment:
May use RowAliasSegment here is better.
##########
parser/sql/engine/dialect/mysql/src/main/antlr4/imports/mysql/DMLStatement.g4:
##########
@@ -20,9 +20,11 @@ grammar DMLStatement;
import BaseRule;
insert
- : INSERT insertSpecification INTO? tableName partitionNames? (insertValuesClause | setAssignmentsClause | insertSelectClause) onDuplicateKeyClause? returningClause?
+ : INSERT insertSpecification INTO? tableName partitionNames? insertBody onDuplicateKeyClause? returningClause?
;
+insertBody : insertValuesClause | setAssignmentsClause valueReference? | insertSelectClause valueReference? ;
Review Comment:
Please put the content after : on a new line.
--
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
Re: [PR] Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement [shardingsphere]
Posted by "chakkk309 (via GitHub)" <gi...@apache.org>.
chakkk309 commented on code in PR #36680:
URL: https://github.com/apache/shardingsphere/pull/36680#discussion_r2383950012
##########
parser/sql/engine/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/engine/mysql/visitor/statement/MySQLStatementVisitor.java:
##########
@@ -1625,10 +1685,11 @@ public ASTNode visitUpdate(final UpdateContext ctx) {
@Override
public ASTNode visitSetAssignmentsClause(final SetAssignmentsClauseContext ctx) {
Collection<ColumnAssignmentSegment> assignments = new LinkedList<>();
- for (AssignmentContext each : ctx.assignment()) {
+ for (AssignmentContext each : ctx.assignmentList().assignment()) {
assignments.add((ColumnAssignmentSegment) visit(each));
}
- return new SetAssignmentSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), assignments);
+ SetAssignmentSegment setAssignment = new SetAssignmentSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), assignments);
+ return setAssignment;
Review Comment:
Done
--
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
Re: [PR] Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement [shardingsphere]
Posted by "chakkk309 (via GitHub)" <gi...@apache.org>.
chakkk309 commented on PR #36680:
URL: https://github.com/apache/shardingsphere/pull/36680#issuecomment-3674714864
cc @strongduanmu this pr ready for review :)
--
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