New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement more traits on Datum #704
Implement more traits on Datum #704
Conversation
...Okay, |
Yep, in my case I have code that hashes |
So I am trying to understand the purpose of the hash that you are generating, because when you hash a Datum, you are either hashing a value (and so the value may be something other than 8 bytes in size and you are hashing in additional zeros which may or may not be intended) or you are hashing a pointer, and thus probably not hashing the actual thing you may want to hash (and would hash if it was in fact And I see you appear to be using this to hash what seem to be in fact double-precision floats...? I assume you do not support executing code on 32-bit or 128-bit architectures, so I will not quibble with you over the correctness of hashing doubles as usizes, but...? Floats don't impl Hash either because the wonkiness of floats has odd consequences regarding NaN (especially for the count-distinct problem!). I am reluctant to approve |
I updated the PR to only implement Just to note though: Another note: The Postgres hashing system will hash all NaNs the same in PG15; prior to PG15 NaNs hashed the same if their bits hashed the same. I should note that in the toolkit documentation. |
Ahh that makes a bit more sense. Yeah, I think it's fine to hash Datums with a specialized construct, it just doesn't necessarily make sense for that to use the |
Implements
From<bool>
,Eq
, andHash
onDatum
. All of these traits are also implemented onusize
, so this makes upgrading to pgx 0.5 (whereDatum
is now astruct
) easier.