Resolve mismatch between JIT and non-JIT hashing adf97c156 taught expression evaluation to produce hash values. That required both JIT and non-JIT versions. The JIT version wasn't quite correct as it didn't truncate the produced hash value down to 32 bits before rotating and combining with the previously stored intermediate hash value when hashing multiple keys.
When a hash function returned a negative int32, the value was sign-extended to 64 bits, and the JIT code's 1-bit left rotation then shifted those set upper bits into the lower 32, setting every bit of the intermediate hash to 1 no matter what the earlier keys hashed to. This meant all rows for which an earlier key had a negative hash value effectively hashed only on the remaining keys, causing many hash collisions resulting in slow hash aggregates and hash joins. Here we fix by adjusting the JIT code to match what the non-JIT version does. Backpatch to 18, where adf97c156 was introduced. Reported-by: Tor Erik Linnerud <[email protected]> Author: David Rowley <[email protected]> Reviewed-by: Ayush Tiwari <[email protected]> Discussion: https://postgr.es/m/caegp1v12rrmzo1h3kz+zcs66a9xlosoulaybxu92nd97e3j...@mail.gmail.com Backpatch-through: 18 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0c6d95e134a195aba19f8c8544934db22a48a3c2 Modified Files -------------- src/backend/jit/llvm/llvmjit_expr.c | 41 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-)
