This patch implements ON CONFLICT DO SELECT. This feature would be very handy in bunch of cases, for example idempotent APIs. I’ve worked around the lack of this by using three statements, like: SELECT -> INSERT if not found -> SELECT again for concurrency safety. (And having to do that dance is driving me nuts)
Apart from the convenience, it’ll also have a performance boost in cases with high latency.
This patch is 85% the work of Andreas Karlsson and the reviewers (Dean Rasheed, Joel Jacobson, Kirill Reshke) in this thread: https://www.postgresql.org/message-id/flat/2b5db2e6-8ece-44d0-9890-f256fdca9f7e%40proxel.se, which unfortunately seems to have stalled. I’ve fixed up all the issues mentioned in that thread (at least I think so), plus some minor extra stuff: