| Bug #118048 | create partition table has same part field name with variable report error | ||
|---|---|---|---|
| Submitted: | 24 Apr 4:27 | Modified: | 5 Jun 13:01 |
| Reporter: | zkong kong | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: DDL | Severity: | S3 (Non-critical) |
| Version: | 8.0.41 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[5 Jun 13:01]
MySQL Verification Team
Hello!
Thank you for the bug report.
Imho this is not a bug, quoting from the manual -
Prohibited constructs. The following constructs are not permitted in partitioning expressions:
Stored procedures, stored functions, loadable functions, or plugins.
Declared variables or user variables.
For more info please see https://dev.mysql.com/doc/refman/8.0/en/partitioning-limitations.html
The following procedure works without any error
create procedure p1()
begin
create table t(a int primary key, c int) partition by hash(a) partitions 3;
end;|
Regards,
Ashwini Patil

Description: A simple partition table sql: create table t(a int primary key, c int) partition by hash(a) partitions 3; Which execute within a procedure report error: mysql> create procedure p1() -> begin -> declare a int; -> set a=10; -> create table t(a int primary key, c int) partition by hash(a) partitions 3; -> end;| ERROR 1064 (42000): Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed near 'a) partitions 3; end' at line 5 How to repeat: delimiter | create procedure p1() begin declare a int; set a=10; create table t(a int primary key, c int) partition by hash(a) partitions 3; end;| Suggested fix: In procedure the hash field a is not replaced by variable a?