Martijn van Oosterhout <kleptog@xxxxxxxxx> 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