shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

about proxy issue

Open motume opened this issue 1 year ago • 4 comments

ssproxy-5.3.3(apache-shardingsphere-5.3.3-SNAPSHOT-shardingsphere-proxy-bin.tar.gz), tbase(version:PostgreSQL 10.0 TBase V2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit).

We use the TBase database, and we use shardingSphere-proxy as database middleware. After the proxy is successfully deployed, add encrypt rules for table ,try to insert record to table from proxy. but ERROR: org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment cannot be cast to org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.complex.ComplexExpressionSegment

log is below: [ERROR] 2024-04-01 09:47:48.844 [ShardingSphere-Command-2] o.a.s.p.f.c.CommandExecutorTask - Exception occur: java.lang.ClassCastException: org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment cannot be cast to org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.complex.ComplexExpressionSegment at org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.InsertValue.getValue(InsertValue.java:63) at org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.InsertValue.toString(InsertValue.java:45) at java.lang.String.valueOf(String.java:2994) at java.lang.StringBuilder.append(StringBuilder.java:131) at org.apache.shardingsphere.encrypt.rewrite.token.pojo.EncryptInsertValuesToken.toString(EncryptInsertValuesToken.java:36) at org.apache.shardingsphere.infra.rewrite.sql.impl.RouteSQLBuilder.getSQLTokenText(RouteSQLBuilder.java:42) at org.apache.shardingsphere.infra.rewrite.sql.impl.AbstractSQLBuilder.toSQL(AbstractSQLBuilder.java:55) at org.apache.shardingsphere.infra.rewrite.engine.RouteSQLRewriteEngine.addSQLRewriteUnits(RouteSQLRewriteEngine.java:96) at org.apache.shardingsphere.infra.rewrite.engine.RouteSQLRewriteEngine.rewrite(RouteSQLRewriteEngine.java:72) at org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry.rewrite(SQLRewriteEntry.java:80) at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.rewrite(KernelProcessor.java:66) at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:52) at org.apache.shardingsphere.proxy.backend.connector.DatabaseConnector.generateExecutionContexts(DatabaseConnector.java:215) at org.apache.shardingsphere.proxy.backend.connector.DatabaseConnector.execute(DatabaseConnector.java:208) at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor.execute(PostgreSQLComQueryExecutor.java:77) at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.doExecuteCommand(CommandExecutorTask.java:116) at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:111) at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78) at com.alibaba.ttl.TtlRunnable.run(TtlRunnable.java:60) 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)


create table t_user(id int,name varchar(15), phone varchar(15),c_name varchar(45),c_phone varchar(45),age int,c_age int,primary key(id));

ENCRYPT RULE: CREATE ENCRYPT RULE t_user (COLUMNS((NAME=phone,CIPHER=c_phone,ENCRYPT_ALGORITHM(TYPE(NAME='AES',PROPERTIES('aes-key-value'='123456abc'))))));

motume avatar Apr 01 '24 02:04 motume

Hi @motume It seems that the insert SQL parsing is incorrect. Please provide the insert SQL statement.

RaigorJiang avatar Apr 04 '24 14:04 RaigorJiang

insert into t_user (id,name,age,phone) VALUES (5,"hyz",88,"138");

motume avatar Apr 08 '24 00:04 motume

insert SQL is as below: insert into t_user (id,name,age,phone) VALUES (5,"hyz",88,"138");

motume avatar Apr 08 '24 00:04 motume

Can you try a stable version to instead of SNAPSHOT?

terrymanu avatar Jul 29 '24 10:07 terrymanu

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

github-actions[bot] avatar Aug 12 '24 20:08 github-actions[bot]