This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 8d58e969fa9 Optimize encrypt g4 definition (#27944)
8d58e969fa9 is described below
commit 8d58e969fa9f14b1dd5c4bc2774c333d87cd616f
Author: Raigor <[email protected]>
AuthorDate: Sun Aug 6 14:02:00 2023 +0800
Optimize encrypt g4 definition (#27944)
---
.../parser/src/main/antlr4/imports/encrypt/BaseRule.g4 | 15 ++++++++++++++-
.../src/main/antlr4/imports/encrypt/RDLStatement.g4 | 6 +++---
.../src/main/antlr4/imports/encrypt/RQLStatement.g4 | 2 +-
.../parser/core/EncryptDistSQLStatementVisitor.java | 2 +-
4 files changed, 19 insertions(+), 6 deletions(-)
diff --git
a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
index 9dd14a52aa7..a8e8c47f9cb 100644
---
a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
+++
b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
@@ -32,12 +32,25 @@ algorithmTypeName
;
buildInEncryptAlgorithmType
+ : standardEncryptAlgorithm
+ | assistedEncryptAlgorithm
+ | likeEncryptAlgorithm
+ ;
+
+standardEncryptAlgorithm
: MD5
| AES
| RC4
| SM3
| SM4
- | CHAR_DIGEST_LIKE
+ ;
+
+assistedEncryptAlgorithm
+ : MD5
+ ;
+
+likeEncryptAlgorithm
+ : CHAR_DIGEST_LIKE
;
propertiesDefinition
diff --git
a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/RDLStatement.g4
b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/RDLStatement.g4
index 8e6d4458bc0..41fee7b83f0 100644
---
a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/RDLStatement.g4
+++
b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/RDLStatement.g4
@@ -32,11 +32,11 @@ dropEncryptRule
;
encryptRuleDefinition
- : tableName LP_ COLUMNS LP_ encryptColumnDefinition (COMMA_
encryptColumnDefinition)* RP_ RP_
+ : tableName encryptTableRuleDefinition
;
-resourceName
- : IDENTIFIER_
+encryptTableRuleDefinition
+ : LP_ COLUMNS LP_ encryptColumnDefinition (COMMA_
encryptColumnDefinition)* RP_ RP_
;
encryptColumnDefinition
diff --git
a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/RQLStatement.g4
b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/RQLStatement.g4
index 45687c5665c..7be1c5c88e5 100644
---
a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/RQLStatement.g4
+++
b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/RQLStatement.g4
@@ -20,7 +20,7 @@ grammar RQLStatement;
import BaseRule;
showEncryptRules
- : SHOW ENCRYPT (TABLE tableRule | RULES) (FROM databaseName)?
+ : SHOW ENCRYPT (TABLE? tableRule | RULES) (FROM databaseName)?
;
tableRule
diff --git
a/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
b/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
index 54fbe703b00..39155d1eddb 100644
---
a/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
+++
b/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
@@ -79,7 +79,7 @@ public final class EncryptDistSQLStatementVisitor extends
EncryptDistSQLStatemen
@Override
public ASTNode visitEncryptRuleDefinition(final
EncryptRuleDefinitionContext ctx) {
return new EncryptRuleSegment(getIdentifierValue(ctx.tableName()),
- ctx.encryptColumnDefinition().stream().map(each ->
(EncryptColumnSegment) visit(each)).collect(Collectors.toList()));
+
ctx.encryptTableRuleDefinition().encryptColumnDefinition().stream().map(each ->
(EncryptColumnSegment) visit(each)).collect(Collectors.toList()));
}
@Override