I wrote:
> I'm currently experimenting with an alternative approach, which leaves
> the nextOffset arithmetic as it was and instead special-cases the zero
> offset case this way:
Attached is a completed patch, which I've had no time to test yet, but
I have to leave for the evening right now --- so here it is in case
anyone is awake and wants to poke at it.
regards, tom lane