Re: BUG #18722: Processing arrays with plpgsql raises errors
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2024-11-24T22:49:12Z
Lists: pgsql-bugs
Attachments
- bug-18722-fix-v1.patch (text/x-diff) patch v1
I wrote: > What EEOP_NULLIF needs to do is pass a read-only pointer to the > equality function, so that the object is not modified and remains > available to return if we want to do so. > Attached is a quick WIP patch to handle that. It is missing a test > case, but the real omission is that llvm_compile_expr()'s EEOP_NULLIF > handling also needs to be fixed, and I'm pretty unsure how to do that. Here's a fleshed-out patch with a test case and JIT support. This is about the first time I've messed with LLVM, so I wouldn't mind some review of what I did in llvmjit_expr.c. In particular, do I correctly understand that "l_funcvalue(b, v_fcinfo, 0)" produces a reference to a copy of the initial value of args[0].value? It seems to work in testing --- the original R/W pointer is returned out of the expression --- but if we returned the R/O pointer instead it'd be mighty difficult to detect the resulting inefficiency. > I'm wondering now if any of our other conditional expressions have > similar bugs ... I was amused to discover that case.sql already had infrastructure suitable for testing this, thanks to bug #14472. regards, tom lane
Commits
-
Fix NULLIF()'s handling of read-write expanded objects.
- 48a6cd1ae636 13.19 landed
- a1168855e0df 14.16 landed
- 97be02ad0015 17.3 landed
- 80cd33bad172 15.11 landed
- 4aba56adcd29 16.7 landed
- 5b8728cd7f9d 18.0 landed