Page MenuHomePhabricator

Database::upsert does not handle sequences for the insert
Closed, InvalidPublic

Description

The function Database::upsert (added with gerrit 62106) has to get new sequence numbers to support databases, which does not have AUTO_INCREMENT, see Database::nextSequenceValue

This makes the function unusable in Oracle, Postgres and Mssql on tables with a sequence.


Version: 1.22.0
Severity: major
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=38916

Details

Reference
bz56542

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:34 AM
bzimport set Reference to bz56542.
bzimport added a subscriber: Unknown Object (MLST).

This can be done already by adding the sequence value to the insert rows given to upsert, but that means more sequence numbers are used, because not all rows must be inserted. But when "nextval" on a INSERT IGNORE will also reserve the next sequence number for ignored rows, than there is no different as given it outside.

Maybe something like done in DatabaseOracle can be used, where the field for the sequence is added automatically to the insert part, this avoids changes to the rest of core. triggers on oracle maybe another option.

I have no oracle to do this.

Doesn't Postgres have DEFAULT NEXTVAL('some_seq') and SERIAL columns?

Postgres is using DEFAULT NEXTVAL, but not Oracle. I found that Oracle will support DEFAULT NEXTVAL with version 12c, but MediaWiki supports Oracle 9.0.1 or later at the moment.

Mssql also has sequence support (Implemented Database::nextSequenceValue), but I do not know how that works there (looks not like nativ sequences).

For upsert on Oracle bug 53710 exists, postgres has no problem, so there is no need to keep this open (but it is not a real dup, so marking INVALID)