aboutsummaryrefslogtreecommitdiff
path: root/src/backend/jit/llvm
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-11-27 10:07:43 -0800
committerAndres Freund <andres@anarazel.de>2018-11-27 10:07:43 -0800
commitaee085bc018ffb961bf0a2c3ac72a45bb3aa33a9 (patch)
tree9d509cb312c68e63a98997a0d27ce48bc017419b /src/backend/jit/llvm
parent5ef8f08b541da5df1ac00a3c880578a8e3bf447c (diff)
downloadpostgresql-aee085bc018ffb961bf0a2c3ac72a45bb3aa33a9.tar.gz
postgresql-aee085bc018ffb961bf0a2c3ac72a45bb3aa33a9.zip
Fix jit compilation bug on wide tables.
The function generated to perform JIT compiled tuple deforming failed when HeapTupleHeader's t_hoff was bigger than a signed int8. I'd failed to realize that LLVM's getelementptr would treat an int8 index argument as signed, rather than unsigned. That means that a hoff larger than 127 would result in a negative offset being applied. Fix that by widening the index to 32bit. Add a testcase with a wide table. Don't drop it, as it seems useful to verify other tools deal properly with wide tables. Thanks to Justin Pryzby for both reporting a bug and then reducing it to a reproducible testcase! Reported-By: Justin Pryzby Author: Andres Freund Discussion: https://postgr.es/m/20181115223959.GB10913@telsasoft.com Backpatch: 11, just as jit compilation was
Diffstat (limited to 'src/backend/jit/llvm')
-rw-r--r--src/backend/jit/llvm/llvmjit_deform.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/jit/llvm/llvmjit_deform.c b/src/backend/jit/llvm/llvmjit_deform.c
index 795f67114e6..e406d392d4e 100644
--- a/src/backend/jit/llvm/llvmjit_deform.c
+++ b/src/backend/jit/llvm/llvmjit_deform.c
@@ -208,10 +208,16 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
v_infomask2,
"maxatt");
+ /*
+ * Need to zext, as getelementptr otherwise treats hoff as a signed 8bit
+ * integer, which'd yield a negative offset for t_hoff > 127.
+ */
v_hoff =
- l_load_struct_gep(b, v_tuplep,
- FIELDNO_HEAPTUPLEHEADERDATA_HOFF,
- "t_hoff");
+ LLVMBuildZExt(b,
+ l_load_struct_gep(b, v_tuplep,
+ FIELDNO_HEAPTUPLEHEADERDATA_HOFF,
+ ""),
+ LLVMInt32Type(), "t_hoff");
v_tupdata_base =
LLVMBuildGEP(b,