I wrote:
> I think the easiest way to fix this is to forget about the special
> initialization at outer level and just always initialize a new stack level
> to have the same hash as its parent. That leads to the first patch below
> --- but once you look at that, you realize that we've got unnecessarily
> many copies of stack->parent->hash into stack->hash, so what I actually
> propose now is the second patch below.
Meh, that wasn't quite right either --- need to reset stack->hash after
processing a sub-object, not only after a scalar VALUE. I think what I
committed is OK though.
regards, tom lane