[MDEV-25779] long uniques aren't 32/64-bit portable Created: 2021-05-26 Updated: 2023-09-04 Resolved: 2023-09-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Create Table |
| Affects Version/s: | 10.4, 10.5 |
| Fix Version/s: | 10.11.2, 10.4.28, 10.5.19, 10.6.12, 10.8.7, 10.9.5, 10.10.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Golubchik | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
long uniques use internally Item_func_hash, which works as
But ulong has a different size on 32-bit and 64-bit. All other code that uses hash_sort(), seems to be using only the lower 32-bit of the returned hash value. This item uses all 64, which makes hash values dependent on whether the platform is 32-bit or 64-bit. Considerations:
|
| Comments |
| Comment by Alexander Barkov [ 2021-05-26 ] | ||||||||
|
Observation: The low level macros which is used all around the hash code:
is implemented in the way that after the hash calculation, this value:
is equal on all platforms. In other words, these two values are equal:
So the code which uses only the low 4 bytes of nr1 should be safe. For example, this code in ha_partition.cc is safe:
But Item_func_hash::val_int() is obviously not safe. | ||||||||
| Comment by Andrei Elkin [ 2022-02-22 ] | ||||||||
|
serg: Maybe Bar should own this one now? | ||||||||
| Comment by Marko Mäkelä [ 2023-09-03 ] | ||||||||
|
Wasn’t this addressed by |