Page MenuHomePhabricator

Database->insertSelect() generates invalid SQL when * is passed as $conds
Closed, ResolvedPublic

Description

According to InsertSelect documentation:

$conds Condition array. See $conds in IDatabase::select() for the details of the format of condition arrays. May be "*" to copy the whole table.

However, passing '*' to the $conds array causes an exception because it tries to generate a query that looks like this:
SELECT (fields) FROM (table) WHERE * FOR UPDATE

Since this is not from a command line, it tries to do a select first and then an insert, instead of a native insert select.

The following methods of Database class are handling the "*" correctly in $conds:

  • update
  • deleteJoin
  • delete

This looks like a regression, because there are extensions using it example. But I don't know for how long it's broken...

I see it a bit inconsistent that some methods accept an empty $conds for a full select, and other accept *.

Event Timeline

@daniel Is this possibly related to changes that you've been making?

For reference, which DB type? And CLI or Web?

For reference, which DB type? And CLI or Web?

Mysql and web

I think any callers should use '', not '*', which doesn't make much sense to me. That said, we already started the pattern, so it may as well work here too.

Change 463849 had a related patch set uploaded (by Aaron Schulz; owner: Aaron Schulz):
[mediawiki/core@master] rdbms: make * consistently act like in select/insertSelect methods

https://gerrit.wikimedia.org/r/463849

Change 463849 merged by jenkins-bot:
[mediawiki/core@master] rdbms: make * consistently act like in select/insertSelect methods

https://gerrit.wikimedia.org/r/463849