tidb
tidb copied to clipboard
Failed to modify column's default value when has expression index
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
mysql> create table t1 (a char(20) not null, index((lower(a))));
Query OK, 0 rows affected (0.09 sec)
mysql> alter table t1 modify a char(20) default null;
2. What did you expect to see? (Required)
Success.
3. What did you see instead (Required)
ERROR 3106 (HY000): '[ddl:3837]Column 'a' has an expression index dependency and cannot be dropped or renamed' is not supported for generated columns.
This error message does not match the operation and has a poor format.
I can reproduce this error in both nightly and v7.5.1, but in serverless (5.7.28-TiDB-v7.1.1-serverless) it works fine.
4. What is your TiDB version? (Required)
Release Version: v8.1.0-alpha-24-g555ce02352
Edition: Community
Git Commit Hash: 555ce0235229dc370cc8e63574437cf9ee60bdd0
Git Branch: HEAD
UTC Build Time: 2024-04-03 14:18:26
GoVersion: go1.21.6
Race Enabled: false
Check Table Before Drop: false
Store: tikv
From Django tests migrations.test_operations.OperationTests.test_alter_field_with_func_index
introduced by #43350
/type regression
In https://github.com/pingcap/tidb/issues/24321 (v4.0.0), I hope this kind of DDL error raised an issue, Because the generated column also didn't GA, and the generated column's user doc also said not to support (https://docs.pingcap.com/tidb/stable/generated-columns#limitations).
You cannot modify the expression of a stored generated column through the ALTER TABLE statement.
This PR (https://github.com/pingcap/tidb/pull/43350) will change the behavior, to become an error. But v7.1 (https://docs-archive.pingcap.com/tidb/v7.2/release-7.1.0) to start generating function has the GA.
So what are our options now? Still let it report an error or let it execute successfully? @bb7133 Help judge how to deal with this behavior. If we still choose to report errors, we may need to change the error message and change the bug level.
I think the current behavior confirm to our previous choice https://github.com/pingcap/tidb/issues/43455#issuecomment-1526986848
@tiancaiamao Could please check if anything need to do with the error message for this case?