userkdg opened a new issue #14059:
URL: https://github.com/apache/shardingsphere/issues/14059
### Which version of ShardingSphere did you use?
the lastest master
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy
### Expected behavior
``` sql
alter table ec_oms_order
change column order_xx order_xxx text after address_cipher
```
### Actual behavior
``` sql
alter table ec_oms_order
change column order_xx order_xxx text after address
```
### Reason analyze (If you can)
alter table .. change ... sql parser bug.
as follow:
F:

- ``` ModifyColumnDefinitionSegment#previousColumnDefinition ``` token
(start/ stop) index equal ``` ModifyColumnDefinitionSegment#columnDefinition```
, the is unreasonable!
Q:

- sql antlr4 parser is good , but ast convert to pojo had bug.
resolve:
``` java
private ModifyColumnDefinitionSegment
generateModifyColumnDefinitionSegment(final ChangeColumnContext ctx) {
ColumnDefinitionSegment columnDefinition = (ColumnDefinitionSegment)
visit(ctx.columnDefinition());
columnDefinition.setColumnName(new ColumnSegment(
columnDefinition.getColumnName().getStartIndex(),
columnDefinition.getColumnName().getStopIndex(),
new IdentifierValue(ctx.columnInternalRef.getText())
));
ModifyColumnDefinitionSegment result = new
ModifyColumnDefinitionSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), (ColumnDefinitionSegment)
visit(ctx.columnDefinition()));
MySQLStatementParser.IdentifierContext identifier = ctx.identifier();
IdentifierValue preColName = (IdentifierValue)visit(identifier);
ColumnSegment preColSegment = new
ColumnSegment(identifier.getStart().getStartIndex(),
identifier.getStop().getStopIndex(), preColName);
result.setPreviousColumnDefinition(preColSegment);
if (null != ctx.place()) {
result.setColumnPosition((ColumnPositionSegment)
visit(ctx.place()));
}
return result;
}
```
- antlr4 support parser setPreviousColumnDefinition token
- the fixed will affect the encrypt code - ```
EncryptAlterTableTokenGenerator ```.
other: i think that encrypt code of ``` BaseEncryptSQLTokenGenerator ```
need to refactor ......
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
execute
``` sql
preview alter table ec_oms_order
change column order_xx order_xxx text after
address;
```
desc: address is cipher column, order_xx, order_xxx is plain columns.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]