core/db: Improve I/O When Updating Rows

When updating a row, we are currently doing an INSERT OR REPLACE INTO.  The
downside to this is that the row is deleted if it exists and then a new row is
inserted.  So, we are hitting the disk twice.  One for the deletion and one for
the insertion.

This patch changes this statement to an INSERT INTO and if the insert fails
because a row with that key exists, we will IGNORE the failure.  Then we will
attempt to perform an UPDATE on the existing row if that row wasn't just
INSERTed.

ASTERISK-24050 #close
Reported by: Michael L. Young
patches:
  astdb-insert-update-io-help_trunk_v2.diff
                                     uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/3815/


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@419222 f38db490-d61c-443f-a65b-d21fe96a405b