If that's what you want, you can happily use Postgres' UPSERT implementation, and abandon subtransactions very easily.
https://www.postgresql.org/docs/current/sql-insert.html#SQL-...
https://www.postgresql.org/docs/current/sql-insert.html#SQL-...
edit: Ah, I bet the implicit suggestion was to do `INSERT ... ON CONFLICT DO NOTHING RETURNING *` and if no row was returned, you hope to know/guess the conflict and do an extra `SELECT`. I'll think more on this, thanks.
Therefore you can do DO UPDATE SET table_name.column = Excluded.column WHERE table_name.column IS DISTINCT FROM Excluded.column RETURNING *