Hi,

JIT slot_compile_deform assumes there's at least  'natts' in TupleDesc, eg
        /*
         * Iterate over each attribute that needs to be deformed, build code to
         * deform it.
         */
        for (attnum = 0; attnum < natts; attnum++)
        {
                Form_pg_attribute att = TupleDescAttr(desc, attnum);

but a new TupleDesc has no attribute and the caller only tests
TupleDesc is not null.
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
index 0da318218f..3831ed2f5a 100644
--- a/src/backend/jit/llvm/llvmjit_expr.c
+++ b/src/backend/jit/llvm/llvmjit_expr.c
@@ -336,7 +336,7 @@ llvm_compile_expr(ExprState *state)
 					 * function specific to tupledesc and the exact number of
 					 * to-be-extracted attributes.
 					 */
-					if (desc && (context->base.flags & PGJIT_DEFORM))
+					if (desc && desc->natts >= op->d.fetch.last_var && (context->base.flags & PGJIT_DEFORM))
 					{
 						LLVMValueRef params[1];
 						LLVMValueRef l_jit_deform;

Reply via email to