apache / apache/shardingsphere

The generated encrypted column is too long

Open
#30,541 4 comments 0 reactions 0 assignees View on GitHub
feature: encrypt status: pending
Dominant language
Java
Stars
20.8k
Forks
6.9k
Avg merge
11h 38m
Merged PRs (30d)
326

Description

## Bug Report

### Which version of ShardingSphere did you use?
master 3bb9a429

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

### Expected behavior
Create table successfully.

### Actual behavior
In MySQL:
```java
java.sql.SQLSyntaxErrorException: Specified key was too long; max key length is 3072 bytes
```

### Reason analyze (If you can)
#27605 The generated encrypted column is too long, which leads to the inability to index.

### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
```sql
-- Logic SQL:
CREATE TABLE t1 (
id int NOT NULL auto_increment PRIMARY KEY,
b int NOT NULL,
c datetime NOT NULL,
INDEX idx_b(b),
INDEX idx_c(c)
) ENGINE=InnoDB
-- Actual SQL:
CREATE TABLE t1 (
id int NOT NULL auto_increment PRIMARY KEY,
b_cipher VARCHAR(4000),
c_cipher VARCHAR(4000),
INDEX idx_b(b_cipher),
INDEX idx_c(c_cipher)
) ENGINE=InnoDB
```

Contributor guide

Open the contributing guide

Research direction

Start by running the provided MySQL CREATE TABLE reproduction and compare the Logic SQL with the Actual SQL generated for encrypted columns. Trace the encrypted-column generation path and verify the fix by confirming that indexed encrypted columns stay within MySQL's key-length limit and the table is created successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql
Domain
databases, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.