Bug #107890 Create Partition Table Error Caused By Non-partition Field
Submitted: 15 Jul 2022 5:49 Modified: 15 Jul 2022 12:45
Reporter: Boy Zhang Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: partition table

[15 Jul 2022 5:49] Boy Zhang
When creating a partitioned table, if the SQL contains a random expression, DDL will fail, regardless of whether the random expression is related to the partition definition.

How to repeat:
create table t(a datetime, b timestamp not null default (current_timestamp)) partition by range columns(a) (partition p0 values less than('20220801'));

Suggested fix:
I understand that the errno of ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR is meaningful only when random expression appears in partition_options. Therefore, DDL should not report an error when the random expression has nothing to do with partition_options.
The logic of reporting errors based on safe_to_cache_query in the PT_part_value_item_expr::contextualize function can be removed, and it can be judged by whether the current expr is a random expression.
[15 Jul 2022 12:45] MySQL Verification Team
Hi Mr. Zhang,

Thank you for your bug report.

However, this is not a bug.

We have run your command on 8.0.29 and it ran just fine. We have only entered DATETIME constant correctly, as prescribed by our Reference Manual. We are just following SQL standard on that issue.

Not a bug.