MySQL supports the IGNORE modifier on INSERT statements, which ignores
uniqueness errors resulting from the INSERT. This causes syntax errors
in PostgreSQL such as the following:
Error running :
INSERT IGNORE INTO `wp_options` ( `option_name`, `option_value`, `autoload` ) VALUES ('auto_updater.lock', '1433306517', 'no') /* LOCK */
---- converted to ----
INSERT IGNORE INTO wp_options ( option_name, option_value, autoload ) VALUES ('auto_updater.lock', '1433306517', 'no') /* LOCK */
----> ERROR: syntax error at or near "IGNORE"
LINE 1: INSERT IGNORE INTO wp_options ( option_name, option_value, a...
^
Provide support for INSERT IGNORE using a PostgreSQL DO statement with
an exception handler for uniqueness errors.
This has the drawback that it requires PostgreSQL 9.0 or later, support
for plpgsql, and USAGE privileges for plpgsql for the current user. But
these are all common, and it allows us to support INSERT IGNORE
statements generically. If this is later found to be too much of a
problem, it is possible to rewrite the query on a query-specific basis
to an INSERT SELECT statement without a FROM clause.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>