diff options
author | David Rowley <drowley@postgresql.org> | 2024-10-17 14:25:08 +1300 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2024-10-17 14:25:08 +1300 |
commit | 9ca67658d19e6c258eb4021a326ed7d38b3ab75f (patch) | |
tree | 8034b0b5bfb372ebdf68970faa90c052bfa050bc /src/backend/jit/llvm | |
parent | 089aac631b5ba53be0ecf8ea2e8d81388d69629c (diff) | |
download | postgresql-9ca67658d19e6c258eb4021a326ed7d38b3ab75f.tar.gz postgresql-9ca67658d19e6c258eb4021a326ed7d38b3ab75f.zip |
Don't store intermediate hash values in ExprState->resvalue
adf97c156 made it so ExprStates could support hashing and changed Hash
Join to use that instead of manually extracting Datums from tuples and
hashing them one column at a time.
When hashing multiple columns or expressions, the code added in that
commit stored the intermediate hash value in the ExprState's resvalue
field. That was a mistake as steps may be injected into the ExprState
between each hashing step that look at or overwrite the stored
intermediate hash value. EEOP_PARAM_SET is an example of such a step.
Here we fix this by adding a new dedicated field for storing
intermediate hash values and adjust the code so that all apart from the
final hashing step store their result in the intermediate field.
In passing, rename a variable so that it's more aligned to the
surrounding code and also so a few lines stay within the 80 char margin.
Reported-by: Andres Freund
Reviewed-by: Alena Rybakina <a.rybakina@postgrespro.ru>
Discussion: https://postgr.es/m/CAApHDvqo9eenEFXND5zZ9JxO_k4eTA4jKMGxSyjdTrsmYvnmZw@mail.gmail.com
Diffstat (limited to 'src/backend/jit/llvm')
-rw-r--r-- | src/backend/jit/llvm/llvmjit_expr.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c index 48ccdb942a2..0b3b5748ea2 100644 --- a/src/backend/jit/llvm/llvmjit_expr.c +++ b/src/backend/jit/llvm/llvmjit_expr.c @@ -1940,13 +1940,16 @@ llvm_compile_expr(ExprState *state) { LLVMValueRef v_tmp1; LLVMValueRef v_tmp2; + LLVMValueRef tmp; + + tmp = l_ptr_const(&op->d.hashdatum.iresult->value, + l_ptr(TypeSizeT)); /* * Fetch the previously hashed value from where the - * EEOP_HASHDATUM_FIRST operation stored it. + * previous hash operation stored it. */ - v_prevhash = l_load(b, TypeSizeT, v_resvaluep, - "prevhash"); + v_prevhash = l_load(b, TypeSizeT, tmp, "prevhash"); /* * Rotate bits left by 1 bit. Be careful not to @@ -2062,13 +2065,16 @@ llvm_compile_expr(ExprState *state) { LLVMValueRef v_tmp1; LLVMValueRef v_tmp2; + LLVMValueRef tmp; + + tmp = l_ptr_const(&op->d.hashdatum.iresult->value, + l_ptr(TypeSizeT)); /* * Fetch the previously hashed value from where the - * EEOP_HASHDATUM_FIRST_STRICT operation stored it. + * previous hash operation stored it. */ - v_prevhash = l_load(b, TypeSizeT, v_resvaluep, - "prevhash"); + v_prevhash = l_load(b, TypeSizeT, tmp, "prevhash"); /* * Rotate bits left by 1 bit. Be careful not to |