Closed 15102552479 closed 1 month ago
求各位大神指点
The markdown format in your issue is incorrect. To facilitate reading, could you please revise it?
OK
I don't think the content is clear enough, for example: what is the sql mean before Bug Report
?
I don't understand about Expected behavior
too.
Basically, I'm using encryption features with AES encryption. I've tried the 5.2.1, 5.4.1, and 5.5.0 versions of sharding-jdbc, but none of them support aliases. For example, this SQL statement will give an error directly: "select * from (select ISNULL(GROUP_CONCAT(id)) as ids ,patient_id, visit_sn from test GROUP BY patient_id) a;". However, removing the outer alias makes it work: "select ISNULL(GROUP_CONCAT(id)) as ids ,patient_id, visit_sn from test GROUP BY patient_id;". It's clear that the SQL parser does not support aliasing in this format.
Firstly, could you revise your first comment to make it clear?
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
AES encrypt bug:sharding-sphere5.5.0 1.table CREATE TABLE
test
(id
int NOT NULL AUTO_INCREMENT COMMENT 'id',patient_id
varchar(255) DEFAULT NULL COMMENT '换着ID',visit_sn
varchar(255) DEFAULT NULL, PRIMARY KEY (id
) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;Bug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Which version of ShardingSphere did you use?
version:5.5.0
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
Expected behavior
Encrypt table "test", field "visit_sn", use sql "select ISNULL(GROUP_CONCAT(id)) as ids ,patient_id, visit_sn from test GROUP BY patient_id;" is correct.but use sql "select * from (select ISNULL(GROUP_CONCAT(id)) as ids ,patient_id, visit_sn from test GROUP BY patient_id) a;" is incorrect. I think the result is the same in both cases
Actual behavior
use the second sql: Exception:Loading class
com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. java.sql.SQLException: Unsupported SQL operation: Can not support encrypt shorthand expand with subquery statement. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.executeQuery(ShardingSphereStatement.java:188) at org.apache.shardingsphere.driver.api.ShardingJDBCDemo.querycourse(ShardingJDBCDemo.java:167) at org.apache.shardingsphere.driver.api.ShardingJDBCDemo.main(ShardingJDBCDemo.java:135)Reason analyze (If you can)
I think is a bug
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
1.select * from (select ISNULL(GROUP_CONCAT(id)) as ids ,patient_id, visit_sn from test GROUP BY patient_id) a; 2.java code `package org.apache.shardingsphere.driver.api;
import com.zaxxer.hikari.HikariDataSource; import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration; import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration; import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration; import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration; import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import javax.sql.DataSource; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.*;
/**
public class ShardingJDBCDemo {
// test.droptable(dataSource); // test.createtable(dataSource);
// test.addcourse(dataSource); //K1 调试的起点 查询数据 test.querycourse(dataSource); }
// String sql = "insert into test(patient_id, visit_sn) values ('A', 'A')"; //ShardingResultSet // boolean execute = statement.execute(sql); // System.out.println("execute:"+execute); // String sql = "select from (select ISNULL(GROUP_CONCAT(t1.id)) as ids ,t1.patient_id, t1.visit_sn from test t1 LEFT JOIN test_surgery t2 on t1.id = t2.tid GROUP BY patient_id) a;"; // String sql = "select ISNULL(GROUP_CONCAT(id)) as ids ,patient_id, visit_sn from test GROUP BY patient_id;"; String sql = "select from (select ISNULL(GROUP_CONCAT(id)) as ids ,patient_id, visit_sn from test GROUP BY patient_id) a;"; ResultSet result = statement.executeQuery(sql); while (result.next()) { System.out.println("id:" + result.getString("ids")); System.out.println("patient_id:" + result.getString("patient_id")); System.out.println("visit_sn:" + result.getString("visit_sn")); } } catch (SQLException e) { e.printStackTrace(); } finally { if (null != conn) { conn.close(); } } }
}
3.
Loading classcom.mysql.jdbc.Driver'. This is deprecated. The new driver class is
com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. java.sql.SQLException: Unsupported SQL operation: Can not support encrypt shorthand expand with subquery statement. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.executeQuery(ShardingSphereStatement.java:188) at org.apache.shardingsphere.driver.api.ShardingJDBCDemo.querycourse(ShardingJDBCDemo.java:167) at org.apache.shardingsphere.driver.api.ShardingJDBCDemo.main(ShardingJDBCDemo.java:135)`Example codes for reproduce this issue (such as a github link).