Martijn van Oosterhout <kleptog@xxxxxxxxx> writes: > What you need to do is copy the Datum you wish to return into the upper > memory context. I'm not seeing a helpful SPI utility function or > obvious example here you help you, but I'm sure it's something with > MemoryContextSwitchTo() and datumCopy(). SPI_palloc is what to use to allocate the result in the right place. My guess is that the reason the function appeared to work (most of the time) before is that it wasn't being tested in an assert-enabled build. CLOBBER_FREED_MEMORY is exposing the mistake. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general