Unfortunately you're wrong. That statement isn't safe under concurrency. Consider what happens if:
a) Another transaction inserts a row with a conflicting key inbetween your UPDATE and INSERT
b) If there already is a conflicting row in the table, but you can't see it yet because either the other transaction hasn't committed yet, or you're using REPEATABLE READ and the other transaction has committed after you.