tidb-challenge-program / bug-hunting-issue

Bug hunting issues.
3 stars 0 forks source link

P2-[4.0 bug hunting]-[SQL Plan Management]-Internal error message when using CASE in partitioned table #16

Open mrigger opened 4 years ago

mrigger commented 4 years ago

Consider the following statements:

CREATE TABLE t0(c0 INT) PARTITION BY HASH((CASE WHEN 0 THEN 0 ELSE c0 END )) PARTITIONS 1; -- ERROR 1105 (HY000): UnknownType: *ast.WhenClause

When executing the CREATE, an internal error message is printed:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.25-TiDB- TiDB Server (Apache License 2.0), MySQL 5.7 compatible

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE TABLE t0(c0 INT) PARTITION BY HASH((CASE WHEN 0 THEN 0 ELSE c0 END )) PARTITIONS 1;
ERROR 1105 (HY000): UnknownType: *ast.WhenClause

I would expect that either an error is printed, explaining that this operator is forbidden, or that this operator is supported. For example, MySQL 8.0.19 prints This partition function is not allowed for this case.

I can reproduce this both in the 4.0 RC, and on the latest master (commit 72f457674238d28435b874af2899f7f684140a49).

Environment:

+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: 
Git Commit Hash: 
Git Branch: 
UTC Build Time: 2020-04-15 06:06:10
GoVersion: go1.13.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |

According to your classification, this seems to be a P2 bug (Incompatible behaviors, such as permissions, SQL errors, etc.).

shuke987 commented 4 years ago

/bug P2