Andres Freund <and...@anarazel.de> writes: > On October 8, 2018 10:14:34 AM PDT, Tom Lane <t...@sss.pgh.pa.us> wrote: >> Surely there is some way that we can directly test whether we're inside >> a procedure or not? I think the logic should be basically >> ...
> Seems more reasonable from here. We are rapidly running out of time to get this fixed before RC1. In the interests of getting across the finish line, I took a look around, and found that indeed there does not seem to be any exported way to detect whether we're inside a procedure or not. Which seems pretty darn dumb from here. The best way to determine that seems to be to check that that the SPI stack is (a) nonempty and (b) has a "nonatomic" topmost entry. Barring objections, I'm going to make a quick hack that adds a SPI entry point along the lines of "bool SPI_inside_nonatomic_context(void)" to do that test, adapt the xact.c code as I said upthread, and commit with Peter's regression test case. regards, tom lane