#4902 - Duplicate ID column in Search

This is a spacer post for a website comment topic. The content this topic relates to: #4902 - Duplicate ID column in Search
Hmm, this query is not failing on my machine which is running MySQL 8.0.18.

I could not reproduce this at all.

The issue has to be with the 'id' in the SELECT clause, as there is no ambiguous id anywhere else. 'id' comes in from 'r.*' but also 'r.id AS id'. But it's the same field, and we do this pattern pretty commonly.

The MySQL SELECT documentation has this clause saying it is fine:
"MySQL permits duplicate column names. That is, there can be more than one select_expr with the same name. This is an extension to standard SQL"

MariaDB has its own documentation (it can't use MySQL's for copyright reasons), and has no similar clause in it. But that is probably just because they didn't feel a need to go into the same in-depth detail that MySQL's already does.

I even tested on Postgres, and it was fine.

And I trawled the MySQL manual to see if there was some extra strict mode, and there wasn't.

And I tested on the very latest MariaDB and it was fine.

Maybe a bug in a very specific version of MariaDB or MySQL.

Or possibly it's an error message from a previous query, but the mysqli_error function is documented as "Returns the error code for the most recent function call", so it should not be possible. And besides, we should not be having previous queries failing with that either, it's not something we'd sweep under the rug.

All that said, I think I have a fix, and it puts us inline with what other parts of our code already do so I'm happy to include it.
Automated response: Unknown database configurations may have problem with repeated column names in SELECT queries

MySQL and MariaDB and Postgres (at least) seem to support selecting multiple columns under the same ID. But we had a report of it not working. Fix any obvious cases of this happening, and alter the XML DB driver to be very strict so that we can pick up on such cases if they happen in the future.

0 guests and 0 members have recently viewed this.