Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> writes:
> Looks good. Another approach would be to put the existing code in a
> PG_TRY() block and catching the duplicate key violation.
Not really feasible from a code-structure point of view, I'm afraid.
Also there is the issue of cleaning up leaked resources (buffer pins
etc), which would probably require a subtransaction to be safe,
at which point it's not looking so fast anymore ...
regards, tom lane