tidb icon indicating copy to clipboard operation
tidb copied to clipboard

Failed to modify column's default value when has expression index

Open wd0517 opened this issue 1 year ago • 3 comments

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

wd0517 avatar Apr 06 '24 02:04 wd0517

introduced by #43350

aytrack avatar Apr 07 '24 10:04 aytrack

/type regression

kennedy8312 avatar Apr 22 '24 16:04 kennedy8312

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.

zimulala avatar Apr 28 '24 09:04 zimulala

I think the current behavior confirm to our previous choice https://github.com/pingcap/tidb/issues/43455#issuecomment-1526986848

tiancaiamao avatar May 08 '24 08:05 tiancaiamao

@tiancaiamao Could please check if anything need to do with the error message for this case?

kennedy8312 avatar Jun 03 '24 06:06 kennedy8312