Upsert: Don't rely on catching duplicate key exceptions so heavily.

Our previous upsert logic was:

begin
  INSERT
rescue duplicate_key_value
  UPDATE
end

This works fine, but the default postgresql server config logs the
entire statement on errors, including duplicate keys, which means that
this will rapidly fill the server logs with huge amounts of spew if
MoSQL is running on a collection with a high update volume. Instead,
switch to

if UPDATE updated 0 rows
  begin
   INSERT
  rescue duplicate_key_value
  end
end

This conceivably will have performance impact for INSERT-heavy
workloads (doubling the number of RTTs), but we can worry about that
if and when it becomes an issue for someone.