Fix SQL function execution to be safe with long-lived FmgrInfos.
Tom Lane <tgl@sss.pgh.pa.us>
Fix SQL function execution to be safe with long-lived FmgrInfos. fmgr_sql had been designed on the assumption that the FmgrInfo it's called with has only query lifespan. This is demonstrably unsafe in connection with range types, as shown in bug #7881 from Andrew Gierth. Fix things so that we re-generate the function's cache data if the (sub)transaction it was made in is no longer active. Back-patch to 9.2. This might be needed further back, but it's not clear whether the case can realistically arise without range types, so for now I'll desist from back-patching further.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/xact.c | modified | +21 −0 |
| src/backend/executor/functions.c | modified | +76 −12 |
| src/include/access/xact.h | modified | +1 −0 |