apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.95k stars 6.74k forks source link

like-query-encrypt column duplicated #32923

Closed jumanjihu closed 1 month ago

jumanjihu commented 1 month ago

Which version of ShardingSphere did you use?

5.3.2

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

shardingsphere-jdbc-core

Expected behavior

different phone with diferent like query column encrypt value

Actual behavior

some different phone with the same like query column encrypt value, for example:

phone_encrypt           |display_name      |like_query_phone|phone_encrypt           |display_name        |like_query_phone|
------------------------+------------------+----------------+------------------------+--------------------+----------------+
+PLjCCgZ4PA67YBhZotDfg==|正三                |08850144551     |gZv1/40nUfiXHaEX6WHepg==|苍溪县李斯高粱酒坊        |08850144551     |

Reason analyze (If you can)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

sql is just simple “batch insert into xxx” for already existed data, and like query column uses CHAR_DIGEST_LIKE algrithm.

Example codes for reproduce this issue (such as a github link).

java code:

  AlgorithmConfiguration likeEncryptor = new AlgorithmConfiguration("CHAR_DIGEST_LIKE", props);
  encryptors.put(LIKE_ENCRYPTOR_NAME, likeEncryptor);

  new EncryptColumnRuleConfiguration( xxxx,xxx,xxxx....., LIKE_ENCRYPTOR_NAME,.....)

sql code:

  `phone_encrypt` varchar(64) DEFAULT NULL COMMENT '加密手机号',
  `assisted_query_phone` varchar(64) DEFAULT NULL COMMENT '加密手机号查询辅助列',
  `like_query_phone` varchar(64) DEFAULT NULL COMMENT '加密手机号模糊查询辅助列',

mybatis code :

<insert id="batchInsert">
       INSERT INTO `user_new` (
            <include refid="Columns" />
        )
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
                #{item.id,jdbcType=BIGINT},
                #{item.userName,jdbcType=VARCHAR},
                #{item.realName,jdbcType=VARCHAR},
                #{item.displayName,jdbcType=VARCHAR},
                #{item.displayCode,jdbcType=VARCHAR},
                #{item.phone,jdbcType=VARCHAR},
                xxxxxxx
             )
      </foreach>
 </insert>
strongduanmu commented 1 month ago

Hi @jumanjihu, can you format your code and mysql result with markdown, it's hard to read the issue now.

jumanjihu commented 1 month ago

Hi @jumanjihu, can you format your code and mysql result with markdown, it's hard to read the issue now.

ok

terrymanu commented 1 month ago

What is your configuration details?

github-actions[bot] commented 1 month ago

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