Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDL should report an error when creating a generated column with function "grouping" #49909

Closed
lcwangchao opened this issue Dec 29, 2023 · 8 comments · Fixed by #49930
Closed
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.5 affects-7.1 affects-7.5 component/ddl This issue is related to DDL of TiDB. severity/moderate type/bug This issue is a bug. type/regression

Comments

@lcwangchao
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

> create table t(a int, b int as ((grouping(a))) stored);

2. What did you expect to see? (Required)

In MySQL, it reports an error:

mysql> create table t(a int, b int as ((grouping(a))) stored);
ERROR 1111 (HY000): Invalid use of group function

3. What did you see instead (Required)

mysql> create table t(a int, b int as ((grouping(a))) stored);
Query OK, 0 rows affected (0.09 sec)

4. What is your TiDB version? (Required)

master

@kennedy8312
Copy link

Could you please help confirm if the behavior in v6.1.0 is correct or not?

mysql> create table t(a int, b int as ((grouping(a))) stored);
ERROR 3102 (HY000): Expression of generated column 'b' contains a disallowed function.
mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.1.0
Edition: Community
Git Commit Hash: 1a89dec
Git Branch: heads/refs/tags/v6.1.0
UTC Build Time: 2022-06-05 05:09:33
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |

@kennedy8312
Copy link

/type regression

@kennedy8312
Copy link

Regression Analysis
There was an error preventing the create table on v7.1.0 but not v7.2.0.
SQbz1RuSHm
HLobDYzlWo

@kennedy8312
Copy link

Discussed with D3Hunter. The expected behavior should be a user error instead of a successful ddl. Adding the regression tag.
/type regression

@kennedy8312
Copy link

Regression Analysis
PR caused this regression: 44436

@kennedy8312
Copy link

Regression Analysis
Commit 8b67cea : Success
Commit aedbcd0 : Failure
-----------------Regression Test Result on 8b67cea-----------------
Server on 8b67cea started.
Validation passed. 8b67cea is a good label
-----------------Test Case-----------------
mysql -h 127.0.0.1 -P 4000 -u root -D test --local-infile=true < issue49909_testcase.sql
issue49909_testcase.sql:
drop table if exists t;
create table t(a int, b int as ((grouping(a))) stored);
-----------------Test Result-----------------
Result :
ERROR 3102 (HY000) at line 2: Expression of generated column 'b' contains a disallowed function.
-----------------TiDB Version-----------------
tidb_version()
Release Version: v7.2.0-alpha-360-g8b67cea5e1-dirty
Edition: Community
Git Commit Hash: 8b67cea
Git Branch: HEAD
UTC Build Time: 2024-03-04 06:43:21
GoVersion: go1.21.4
Race Enabled: false
Check Table Before Drop: false
Store: unistore

-----------------End of regression test on 8b67cea-----------------

@kennedy8312
Copy link

-----------------Regression Test Result on aedbcd0-----------------
Server on aedbcd0 started.
Validation failed at run 1. aedbcd0 is a bad label. Expected: ERROR 3102 (HY000) at line 2: Expression of generated column 'b' contains a disallowed function.. Actual:
-----------------Test Case-----------------
mysql -h 127.0.0.1 -P 4000 -u root -D test --local-infile=true < issue49909_testcase.sql
issue49909_testcase.sql:
drop table if exists t;
create table t(a int, b int as ((grouping(a))) stored);
-----------------Test Result-----------------
Result :

-----------------TiDB Version-----------------
tidb_version()
Release Version: v7.2.0-alpha-361-gaedbcd085b-dirty
Edition: Community
Git Commit Hash: aedbcd0
Git Branch: HEAD
UTC Build Time: 2024-03-04 06:44:13
GoVersion: go1.21.4
Race Enabled: false
Check Table Before Drop: false
Store: unistore

-----------------End of regression test on aedbcd0-----------------

@kennedy8312
Copy link

Regression Analysis
From v5.4.0 - v7.1.0, the create table ddl would be blocked by "ERROR 3102 (HY000) at line 2: Expression of generated column 'b' contains a disallowed function.". For v7.5, it is not blocked by any errors. The fix should be cherry-pick to v7.5 branch at least?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.5 affects-7.1 affects-7.5 component/ddl This issue is related to DDL of TiDB. severity/moderate type/bug This issue is a bug. type/regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants