I wrote: > I've got no strong opinion about this bit: >> As suggested upthread, returning a resultset would probably be better.
Actually, on further thought, I do like the resultset idea, because it'd remove the need for a complex rewrite of nextval_internal. Assuming the SRF is written in ValuePerCall style, each iteration can just call nextval_internal with no modifications needed in that function. There'll be a CHECK_FOR_INTERRUPTS somewhere in the query-level loop, or at least it's not nextval's fault if there's not. The situation is then no different from generate_series with a large loop count, or any other query that can generate lots of data. Of course, this does imply a lot more cycles expended per generated value --- but most of that is inherent in the larger amount of data being handed back. regards, tom lane