You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/07/21 06:36:22 UTC

[GitHub] [shardingsphere] strongduanmu opened a new issue, #19418: Incorrect integer value exception occurs when execute `insert into tb1_cipher values(3,'c',3);`

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

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   https://github.com/apache/shardingsphere/commit/8f898cc6501afb985dc157b7d9bbe414bdfae247
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ShardingSphere-Proxy
   
   ### Expected behavior
   
   Execute `insert into tb1_cipher values(3,'c',3);` successfully.
   
   ### Actual behavior
   
   ```
   [INFO ] 2022-07-21 14:29:38.168 [ShardingSphere-Command-2] ShardingSphere-SQL - Logic SQL: insert into tb1_cipher values(3,'c',3)
   [INFO ] 2022-07-21 14:29:38.168 [ShardingSphere-Command-2] ShardingSphere-SQL - SQLStatement: MySQLInsertStatement(super=InsertStatement(super=AbstractSQLStatement(parameterCount=0, parameterMarkerSegments=[], commentSegments=[]), table=SimpleTableSegment(tableName=TableNameSegment(startIndex=12, stopIndex=21, identifier=IdentifierValue(value=tb1_cipher, quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty), insertColumns=Optional[InsertColumnsSegment(startIndex=22, stopIndex=22, columns=[])], insertSelect=Optional.empty, values=[InsertValuesSegment(startIndex=29, stopIndex=37, values=[LiteralExpressionSegment(startIndex=30, stopIndex=30, literals=3), LiteralExpressionSegment(startIndex=32, stopIndex=34, literals=c), LiteralExpressionSegment(startIndex=36, stopIndex=36, literals=3)])]), setAssignment=Optional.empty, onDuplicateKeyColumns=Optional.empty)
   [INFO ] 2022-07-21 14:29:38.168 [ShardingSphere-Command-2] ShardingSphere-SQL - Actual SQL: ds_0 ::: insert into tb1_cipher(id, aa, contact_cipher, contact) values(3, 'c', 'rPPLyyXIrNk2WYMlTPYTDQ==', 3)
   [ERROR] 2022-07-21 14:29:38.253 [ShardingSphere-Command-2] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
   java.sql.SQLException: Incorrect integer value: 'c' for column 'aa' at row 1
   	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
   	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3978)
   	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3914)
   	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
   	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
   	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2491)
   	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2449)
   	at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:845)
   	at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:939)
   	at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:103)
   	at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
   	at org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.impl.ProxyStatementExecutorCallback.execute(ProxyStatementExecutorCallback.java:40)
   	at org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback.executeSQL(ProxyJDBCExecutorCallback.java:73)
   	at org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback.executeSQL(ProxyJDBCExecutorCallback.java:66)
   	at org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback.executeSQL(ProxyJDBCExecutorCallback.java:44)
   	at org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:89)
   	at org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:69)
   	at org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.syncExecute(ExecutorEngine.java:135)
   	at org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.parallelExecute(ExecutorEngine.java:131)
   	at org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.execute(ExecutorEngine.java:116)
   	at org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:65)
   	at org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.ProxyJDBCExecutor.execute(ProxyJDBCExecutor.java:71)
   	at org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.useDriverToExecute(ProxySQLExecutor.java:173)
   	at org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:133)
   	at org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:127)
   	at org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:139)
   	at org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:71)
   	at org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:63)
   	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:95)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:112)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   	at java.lang.Thread.run(Thread.java:748)
   ```
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   Execute following sql on native database.
   
   ```sql
   USE demo_ds_0;
   CREATE TABLE `tb1_cipher` (
     `id` int(11) NOT NULL,
     `contact` varchar(30) DEFAULT NULL,
     `aa` int(11) DEFAULT NULL,
     `contact_cipher` varchar(60) DEFAULT NULL,
     PRIMARY KEY (`id`)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
   ```
   
   Then execute next sqls on ShardingSphere-Proxy:
   
   ```sql
   CREATE DATABASE encrypt_db;
   
   ADD RESOURCE ds_0 (
       URL="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false",
       USER=root,
       PASSWORD=123456,
       PROPERTIES("maximumPoolSize"=50,"idleTimeout"="30000")
   );
   
   CREATE ENCRYPT RULE tb1_cipher (
       COLUMNS(
       (NAME=`contact`,PLAIN=`contact`,CIPHER=`contact_cipher`,TYPE(NAME=AES,PROPERTIES('aes-key-value'='t5714OQKZAxsmMh')))
   ),QUERY_WITH_CIPHER_COLUMN=FALSE);
   
   SHOW CREATE TABLE tb1_cipher;
   
   insert into tb1_cipher values(3,'c',3);
   ```
   
   ### 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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tuichenchuxin closed issue #19418: Incorrect integer value exception occurs when execute `insert into tb1_cipher values(3,'c',3);`

Posted by GitBox <gi...@apache.org>.
tuichenchuxin closed issue #19418: Incorrect integer value exception occurs when execute `insert into tb1_cipher values(3,'c',3);`
URL: https://github.com/apache/shardingsphere/issues/19418


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] strongduanmu commented on issue #19418: Incorrect integer value exception occurs when execute `insert into tb1_cipher values(3,'c',3);`

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #19418:
URL: https://github.com/apache/shardingsphere/issues/19418#issuecomment-1191151605

   I found `insert into tb1_cipher values(3,'c',3);` has a potential problem, if we complete the encrypt wash and switch the query to the cipher column `QUERY_WITH_CIPHER_COLUMN=TRUE`, this time if we delete plain column, which will cause a change in the order of fields in metadata.
   The change of the field order will cause `insert into tb1_cipher values(3,'c',3);` to execute abnormally, so the more recommended way to use is `insert into tb1_cipher(id,contact,aa) values(3,'c' ,3);`.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org