I wrote:
> I can throw together a patch for what I was thinking of.
Basically just make the recursive steps match on tgparentid instead
of name, like this.
I wonder whether anyplace else is making a similar mistake? Although
there's not much we will let you do to a foreign key trigger, so it
might not matter for anything else.
regards, tom lane