HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Incorrect database name `` after mysql@8 upgrade

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
afterincorrectdatabasemysqlnameupgrade

Problem

After MySQL upgrade we ran into a breaking change as we have some really strange queries like this one:

use somedatabase;
SELECT * FROM `Table` where ``.`Table`.`id` = 1


With MySQL@5 this query runs without any issue, uses somedatabase as the actual database.

With MySQL@8 the same query throws a Incorrect database name ''.

I didn't find anything mentioning this behaviour change in upgrade docs. Is there any way to force MySQL@8 to treat empty database name as the currently selected one?

(Yes, I know the best would be to fix those queries)

Solution

If this issue has anything to do with the version, then is seems to be something that has been "fixed" (in your case: "broken") by the developers of MySQL.

If you consult the MySQL Documentation for Identifier Qualifiers in the version 8.0 and then switch to the same documentation for version 5.7, then you can find this bit of information:

...

The syntax .tbl_name means the table tbl_name in the default database.

Note

This syntax is deprecated as of MySQL 5.7.20; expect it to be removed in a future version of MySQL.

...

It seems like the option to have a default database in the Identifier Qualifers was removed somewhere between 5.7.20 and the current 8.0 version. You might find it in the release notes 5.7x for one of the versions in between. And then again you might not find it.
Conclusion

MySQL warned in advance, that this feature would be removed. It seems like it has now been effectively removed, without the option to revert back to the < 5.7.19 syntax.

Context

StackExchange Database Administrators Q#317646, answer score: 2

Revisions (0)

No revisions yet.