Bug #26975 table_list->db not updated?
Submitted: 8 Mar 2007 23:53 Modified: 7 May 2007 15:03
Reporter: Chongfeng Hu Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.1-falcon-BK, 5.2.0 falcon-alpha OS:Any (any)
Assigned to: Assigned Account CPU Architecture:Any
Tags: DB, table_list, table_name

[8 Mar 2007 23:53] Chongfeng Hu
Description:
both TABLE_LIST->table_name and TABLE_LIST->db are needed to access a specific table in the database. However, in file sql/sql_show.cc, in function int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list), only table_list->table_name is updated, table_list->db is not. This may cause serious problems in case table_list->db's database happens to have a table with the same name as table_list->table_name.

How to repeat:
I found this spot with the help of a code-analysis tool.

Suggested fix:
update table_list->db too.
[29 Mar 2007 7:56] Valeriy Kravchuk
Thank you for a bug report. Verified just as described with code review on latest 5.1-falcon-BK sources.
[4 Apr 2007 14:44] Martin Hansson
Can you please give an example of a scenario when this would be a problem?

TABLE_LIST->db is filled in during execution of the function add_table_to_list (in file sql_parse.cc) Since this function is only involved with information_schema tables -It creates temporary tables to represent tables in information_schema- this is correct. It's not possible for a user to add tables inside information_schema unless by (ab)using the plugin interface. So can you be more specific about when this poses a problem?
[4 May 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[5 May 2007 5:30] Valeriy Kravchuk
One can add any table to INFORMATION_SCHEMA (ab)using plugin interface, and, surely, one can create a table with any name (VIEWS, for example, or any other from INFORMATION_SCHEMA) in any other database. If this will NOT lead to problems, then there is no bug. I am not good enough in code review to be sure.
[7 May 2007 15:00] Martin Hansson
I cannot see a problem with creating tables in other databases with the same names as INFORMATION_SCHEMA tables. The following works perfectly, for example:

create database test;
use test;
create table tables( a int );
insert into tables values (1);
select * from tables, information_schema.tables;
[7 May 2007 15:02] Martin Hansson
I cannot see a problem with creating tables in other databases with the same names as INFORMATION_SCHEMA tables. The following works perfectly, for example:

create database test;
use test;
create table tables( a int );
insert into tables values (1);
select * from tables, information_schema.tables;
[7 May 2007 15:03] Martin Hansson
I cannot see a problem with creating tables in other databases with the same names as INFORMATION_SCHEMA tables. The following works perfectly, for example:

create database test;
use test;
create table tables( a int );
insert into tables values (1);
select * from tables, information_schema.tables;