[MDEV-6289] Unexpected results when querying information_schema Created: 2014-06-02 Updated: 2014-07-24 Resolved: 2014-07-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.3.12, 5.5.38, 10.0.11 |
| Fix Version/s: | 5.5.39, 10.0.13 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marten Jacobs | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | upstream | ||
| Environment: |
Arch Linux (up-to-date 2014/06/02) under Virtuozzo. Issue occurs when connected through ssh tunnel with Sequel Pro and when using mysqli in php (at least). |
||
| Description |
|
This issue is similar (but not exactly the same) to an issue I've reported earlier under I'm using information_schema.SCHEMATA to make sure that a database exists before switching to it in my PHP app. The issue: The following query unexpectedly returns an empty result set on this version (I've had no issues on previous versions, except the one in the issue I've mentioned before):
This is unexpected, because the following query returns multiple rows, while it should be more restrictive:
Upon further research I found out that removing the ORDER BY clause from the first query helps, so for now I will change the first query into the following, which does work (but will probably have decreased performance):
|
| Comments |
| Comment by Elena Stepanova [ 2014-06-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Marten, I presume the structure of `web_dbs` is the same as in Thanks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marten Jacobs [ 2014-06-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Dear Elena, After doing some testing, I found that other tables did seem to work. I tried to isolate the problem, and was able to find it had something to do with the unique key on the db column. To test this, I created two tables with these commands:
After this, and making sure that the same server has at least one database named test(1-4), running
returns an empty set on my install, while these all return the same (correct) result:
The unique key obviously has some effect on the command handling, as EXPLAIN EXTENDED returns different results:
I hope this helps you! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-06-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Marten, Thanks a lot for the test case. It is reproducible as described on MariaDB 5.3-10.0, and also on MySQL 5.6. Test case (same as above, just all together with schema creation):
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-07-22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re-filed at bugs.mysql.com as http://bugs.mysql.com/bug.php?id=73357 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-07-22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Analysis: There is something wrong going on here:
Here, I_S tables are pre-filled with data. In the query without ORDER BY: get_schema_tables_result() is called once, and execution inside the function reaches this call:
In the query with ORDER BY, get_schema_tables_result() is called twice: the first time with executed_place=PROCESSED_BY_JOIN_EXEC, the second time with executed_place=PROCESSED_BY_CREATE_SORT_INDEX. However, fill_table() is never called. I suspect it's not ORDER BY that is the problem, it is the join order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-07-23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Fix pushed into 5.5 tree. martenjacobs, thanks for taking time to report this! |