Fix insertSelect() with IGNORE in PostgreSQL
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 20 Sep 2017 16:55:55 +0000 (12:55 -0400)
committerAnomie <bjorsch@wikimedia.org>
Tue, 26 Sep 2017 01:32:27 +0000 (01:32 +0000)
commitd98a666d38ecb27cf3b100e3e3c056bf2e639d3c
tree1ce1b4a2c2f834858f48ff04e09c8e6e78f96835
parente69c953a26922b630fa2854a7508976da6eeacf2
Fix insertSelect() with IGNORE in PostgreSQL

I0e6a9e6d overlooked the special handling PG needs (prior to 9.5 anyway)
to properly emulate MySQL's IGNORE option when delegating to the parent
implementation.

For now, then, don't use the native implementation in PG when IGNORE is
specified. Instead, fall back to the non-native implementation that does
a select() then an insert() where PG can handle the IGNORE properly.

In the future we might use the ON CONFLICT DO NOTHING clause added in PG
9.5 to be able to do native insertSelect() with IGNORE (and to better
handle multi-row insert() with IGNORE, and we could use the related ON
CONFLICT DO UPDATE to implement upsert()). All that is left for a future
patch.

Change-Id: I7987d59580543de03d5c6a5ed7fa3ce551ac12f3
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/DatabasePostgres.php