Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> I don't think rules can do what you want.
A trigger might work, ignoring the problem of race conditions between
two inserts happening concurrently (which a rule can't handle either).
regards, tom lane