'Why expression in the MySQL HASH partitioning must be greater than 0 (zero)?

In the MySQL document, it is written as follows.

For HASH partitioning, the user-supplied expression must evaluate to an integer value greater than 0.

I searched web, however I could not found the reason why the expression must be greater than 0.

In another MySQL document page, it is written as follows.

When PARTITION BY HASH is used, the storage engine determines which partition of num partitions to use based on the modulus of the result of the expression. In other words, for a given expression expr, the partition in which the record is stored is partition number N, where N = MOD(expr, num).

In the above formula N = MOD(expr, num), I think that it would work even if the result of expr is 0.

Is the phrase "greater than 0" actually "greater than or equal to 0" ?



Solution 1:[1]

I think that this is not correct information. Or it is incorrectly formulated.

There is no any problems with zero or negative partitioning expression value, even in MySQL 5.6.

DEMO

The fiddle shows that MySQL simply ignores the value sign and uses the modulo of the expression value.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Akina