strongduanmu opened a new issue, #26166:
URL: https://github.com/apache/shardingsphere/issues/26166
## Bug Report
### Which version of ShardingSphere did you use?
a7ad1d659836a881b94081c05db550b41796f154
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy
### Expected behavior
Execute following sql successfully.
```
SELECT * FROM (SELECT u.user_name, e.id, e.user_id, e.order_id FROM
t_encrypt AS e INNER JOIN t_user AS u ON e.id = u.id) AS temp;
```
### Actual behavior
```
[INFO ] 2023-06-08 15:14:38.422 [Connection-1-ThreadExecutor]
ShardingSphere-SQL - Logic SQL: SELECT * FROM (SELECT u.user_name, e.id,
e.user_id, e.order_id FROM t_encrypt AS e INNER JOIN t_user AS u ON e.id =
u.id) AS temp
[INFO ] 2023-06-08 15:14:38.422 [Connection-1-ThreadExecutor]
ShardingSphere-SQL - Actual SQL: ds_0 ::: SELECT temp.user_name, temp.id,
temp.user_cipher AS user_id, temp.order_encrypt AS order_id FROM (SELECT
u.user_name_cipher, e.id, e.user_cipher, e.order_encrypt FROM t_encrypt AS e
INNER JOIN t_user AS u ON e.id = u.id) AS temp
[ERROR] 2023-06-08 15:14:38.424 [Connection-1-ThreadExecutor]
o.a.s.p.f.c.CommandExecutorTask - Exception occur:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column
'temp.user_name' in 'field list'
at
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at
java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at
java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2675)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2439)
at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:829)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:923)
at
com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:102)
at
com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at
org.apache.shardingsphere.proxy.backend.connector.jdbc.executor.callback.impl.ProxyStatementExecutorCallback.execute(ProxyStatementExecutorCallback.java:42)
at
org.apache.shardingsphere.proxy.backend.connector.jdbc.executor.callback.ProxyJDBCExecutorCallback.executeSQL(ProxyJDBCExecutorCallback.java:69)
at
org.apache.shardingsphere.proxy.backend.connector.jdbc.executor.callback.ProxyJDBCExecutorCallback.executeSQL(ProxyJDBCExecutorCallback.java:46)
at
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:87)
at
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:66)
at
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.syncExecute(ExecutorEngine.java:133)
at
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.parallelExecute(ExecutorEngine.java:129)
at
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.execute(ExecutorEngine.java:114)
at
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:67)
at
org.apache.shardingsphere.proxy.backend.connector.jdbc.executor.ProxyJDBCExecutor.execute(ProxyJDBCExecutor.java:75)
at
org.apache.shardingsphere.proxy.backend.connector.ProxySQLExecutor.useDriverToExecute(ProxySQLExecutor.java:204)
at
org.apache.shardingsphere.proxy.backend.connector.ProxySQLExecutor.execute(ProxySQLExecutor.java:163)
at
org.apache.shardingsphere.proxy.backend.connector.DatabaseConnector.doExecute(DatabaseConnector.java:276)
at
org.apache.shardingsphere.proxy.backend.connector.DatabaseConnector.doExecute(DatabaseConnector.java:262)
at
org.apache.shardingsphere.proxy.backend.connector.DatabaseConnector.execute(DatabaseConnector.java:212)
at
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:99)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.doExecuteCommand(CommandExecutorTask.java:126)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:121)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
```
### Reason analyze (If you can)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
Encrypt config:
```yaml
databaseName: encrypt_db
dataSources:
ds_0:
url:
jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !ENCRYPT
encryptors:
aes_encryptor:
type: AES
props:
aes-key-value: 123456abc
rc4_encryptor:
type: RC4
props:
rc4-key-value: 123456abc
tables:
t_encrypt:
columns:
user_id:
cipher:
name: user_cipher
encryptorName: aes_encryptor
order_id:
cipher:
name: order_encrypt
encryptorName: rc4_encryptor
t_user:
columns:
user_name:
cipher:
name: user_name_cipher
encryptorName: aes_encryptor
```
Init sql
```sql
create table t_encrypt (id int primary key, user_id varchar(200),order_id
varchar(200), name varchar(200));
insert into t_encrypt(id, user_id, order_id, name) values(1, "123", "234",
"zhangsan"), (2, "222", "333", "lisi");
CREATE TABLE t_user (id INT PRIMARY KEY, user_name varchar(200) DEFAULT
NULL, password varchar(200) DEFAULT NULL);
insert into t_user(id, user_name, password) values(1, 'zhangsan', 'sdasdas');
```
Then execute `SELECT * FROM (SELECT u.user_name, e.id, e.user_id, e.order_id
FROM t_encrypt AS e INNER JOIN t_user AS u ON e.id = u.id) AS temp;
`
### 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]