FlyingZC opened a new issue, #18697:
URL: https://github.com/apache/shardingsphere/issues/18697

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   `master`
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   `ShardingSphere-JDBC`
   
   ### Expected behavior
   keep correct quotation marks.
   
   ### Actual behavior
   When I want to support create table sql with multiple back quotes, like 
`CREATE TABLE ```ab````cd``` (i INT);`,the table name is resolved to `abcd`.
   
   ### Reason analyze (If you can)
   
`org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue#IdentifierValue(java.lang.String)`
 uses the method 
`org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil#getExactlyValue(java.lang.String)`
 to handle table name,this method removes all back quotes.
   
   Before:
   <img width="1217" alt="image" 
src="https://user-images.githubusercontent.com/19788130/176399071-232fc5cc-38cb-417b-83dd-d46adba27152.png";>
   
   After:
   <img width="1265" alt="image" 
src="https://user-images.githubusercontent.com/19788130/176399199-a6d5478b-e34e-46fd-ad99-1ca3d28ff090.png";>
   
   The execution result of this sql in mysql:
   <img width="602" alt="image" 
src="https://user-images.githubusercontent.com/19788130/176399540-ac8c81b3-8ece-42a8-8ddd-0c5521b1ac27.png";>
   
   StackTrace:
   
   ```
   <init>:31, IdentifierValue 
(org.apache.shardingsphere.sql.parser.sql.common.value.identifier)
   <init>:41, IdentifierValue 
(org.apache.shardingsphere.sql.parser.sql.common.value.identifier)
   visitTableName:322, MySQLStatementSQLVisitor 
(org.apache.shardingsphere.sql.parser.mysql.visitor.statement.impl)
   visitTableName:223, MySQLStatementSQLVisitor 
(org.apache.shardingsphere.sql.parser.mysql.visitor.statement.impl)
   accept:31379, MySQLStatementParser$TableNameContext 
(org.apache.shardingsphere.sql.parser.autogen)
   visit:18, AbstractParseTreeVisitor (org.antlr.v4.runtime.tree)
   visitCreateTable:238, MySQLDDLStatementSQLVisitor 
(org.apache.shardingsphere.sql.parser.mysql.visitor.statement.impl)
   visitCreateTable:182, MySQLDDLStatementSQLVisitor 
(org.apache.shardingsphere.sql.parser.mysql.visitor.statement.impl)
   accept:1931, MySQLStatementParser$CreateTableContext 
(org.apache.shardingsphere.sql.parser.autogen)
   visit:55, SQLVisitorEngine (org.apache.shardingsphere.sql.parser.api)
   parseSQLStatement:78, SQLParserParameterizedTest 
(org.apache.shardingsphere.test.sql.parser.parameterized.engine)
   assertSupportedSQL:72, SQLParserParameterizedTest 
(org.apache.shardingsphere.test.sql.parser.parameterized.engine)
   invoke:-1, GeneratedMethodAccessor5 (sun.reflect)
   invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
   invoke:498, Method (java.lang.reflect)
   runReflectiveCall:50, FrameworkMethod$1 (org.junit.runners.model)
   run:12, ReflectiveCallable (org.junit.internal.runners.model)
   invokeExplosively:47, FrameworkMethod (org.junit.runners.model)
   evaluate:17, InvokeMethod (org.junit.internal.runners.statements)
   runLeaf:325, ParentRunner (org.junit.runners)
   runChild:78, BlockJUnit4ClassRunner (org.junit.runners)
   runChild:57, BlockJUnit4ClassRunner (org.junit.runners)
   run:290, ParentRunner$3 (org.junit.runners)
   schedule:71, ParentRunner$1 (org.junit.runners)
   runChildren:288, ParentRunner (org.junit.runners)
   access$000:58, ParentRunner (org.junit.runners)
   evaluate:268, ParentRunner$2 (org.junit.runners)
   run:363, ParentRunner (org.junit.runners)
   runChild:128, Suite (org.junit.runners)
   runChild:27, Suite (org.junit.runners)
   run:290, ParentRunner$3 (org.junit.runners)
   schedule:71, ParentRunner$1 (org.junit.runners)
   runChildren:288, ParentRunner (org.junit.runners)
   access$000:58, ParentRunner (org.junit.runners)
   evaluate:268, ParentRunner$2 (org.junit.runners)
   run:363, ParentRunner (org.junit.runners)
   run:137, JUnitCore (org.junit.runner)
   startRunnerWithArgs:69, JUnit4IdeaTestRunner (com.intellij.junit4)
   execute:38, IdeaTestRunner$Repeater$1 (com.intellij.rt.junit)
   repeat:11, TestsRepeater (com.intellij.rt.execution.junit)
   startRunnerWithArgs:35, IdeaTestRunner$Repeater (com.intellij.rt.junit)
   prepareStreamsAndStart:235, JUnitStarter (com.intellij.rt.junit)
   main:54, JUnitStarter (com.intellij.rt.junit)
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
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]

Reply via email to