I use sha3 hashes in php (7.2) and I was going to continue using them in MySQL, but MySQL doesn't have support for them yet.
If I write my own UDF and call it, say, sha3
, but then some future MySQL version adds a native sha3
function, what happens?
I'll probably name it something else anyway to avoid the possible conflict, but this could happen with any function eventually, so I'm certainly curious.
Just in case anyone is looking for sha3 support in MySQL, I have written a MySQL UDF that does exactly that using rhash that intends to function exactly like the native sha2 function, which you can download here (installation and usage instructions are in the comments) https://gist.github.com/BrianLeishman/a0f40e7a0a87a7069c5c56a768ff3179
Also, it's worth noting that sha3 is supposed to be faster than sha2 (I think), but my function is 4x as slow as native sha2 (when generating 100,000 hashes), but hopefully the future native sha3 will solve that issue.
I've added a separate UDF for returning the hashes without hex encoding called unhex_sha3
, which is should literally act as unhex(sha3(...
, and this version is almost exactly native speed (compared to sha2
), since I can avoid the pointless translation between hex encoding and back.
https://gist.github.com/BrianLeishman/d7903a4acba75707c05fc581e1c714c3