Return rows from INSERT with ON CONFLICT without needing to update

It’s the recurring problem of SELECT or INSERT, related to (but different from) an UPSERT. The new UPSERT functionality in Postgres 9.5 is still instrumental. WITH ins AS ( INSERT INTO names(name) VALUES (‘bob’) ON CONFLICT ON CONSTRAINT names_name_key DO UPDATE SET name = NULL WHERE FALSE — never executed, but locks the row RETURNING … Read more