mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fix for BUG#17523: natural join and information schema.
The cause of the bug was an ASSERT that checked the consistency of TABLE_SHARE::db and TABLE_LIST::db and failed for I_S tables. The fix relaxes the requirement for consistency for I_S.
This commit is contained in:
@ -677,6 +677,11 @@ select t1.b from v1a;
|
|||||||
ERROR 42S22: Unknown column 't1.b' in 'field list'
|
ERROR 42S22: Unknown column 't1.b' in 'field list'
|
||||||
select * from v1a join v1b on t1.b = t2.b;
|
select * from v1a join v1b on t1.b = t2.b;
|
||||||
ERROR 42S22: Unknown column 't1.b' in 'on clause'
|
ERROR 42S22: Unknown column 't1.b' in 'on clause'
|
||||||
|
select * from information_schema.statistics join information_schema.columns
|
||||||
|
using(table_name,column_name) where table_name='user';
|
||||||
|
TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||||
|
user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 20 60 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
|
||||||
|
user User NULL mysql 0 mysql PRIMARY 2 A 5 NULL NULL BTREE NULL mysql 2 NO char 5 16 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
|
@ -523,6 +523,12 @@ select t1.b from v1a;
|
|||||||
-- error 1054
|
-- error 1054
|
||||||
select * from v1a join v1b on t1.b = t2.b;
|
select * from v1a join v1b on t1.b = t2.b;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #17523 natural join and information_schema
|
||||||
|
#
|
||||||
|
select * from information_schema.statistics join information_schema.columns
|
||||||
|
using(table_name,column_name) where table_name='user';
|
||||||
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
|
19
sql/table.cc
19
sql/table.cc
@ -2595,8 +2595,15 @@ const char *Natural_join_column::db_name()
|
|||||||
if (view_field)
|
if (view_field)
|
||||||
return table_ref->view_db.str;
|
return table_ref->view_db.str;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Test that TABLE_LIST::db is the same as st_table_share::db to
|
||||||
|
ensure consistency. An exception are I_S schema tables, which
|
||||||
|
are inconsistent in this respect.
|
||||||
|
*/
|
||||||
DBUG_ASSERT(!strcmp(table_ref->db,
|
DBUG_ASSERT(!strcmp(table_ref->db,
|
||||||
table_ref->table->s->db));
|
table_ref->table->s->db) ||
|
||||||
|
(table_ref->schema_table &&
|
||||||
|
table_ref->table->s->db[0] == 0));
|
||||||
return table_ref->db;
|
return table_ref->db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2798,7 +2805,15 @@ const char *Field_iterator_table_ref::db_name()
|
|||||||
else if (table_ref->is_natural_join)
|
else if (table_ref->is_natural_join)
|
||||||
return natural_join_it.column_ref()->db_name();
|
return natural_join_it.column_ref()->db_name();
|
||||||
|
|
||||||
DBUG_ASSERT(!strcmp(table_ref->db, table_ref->table->s->db));
|
/*
|
||||||
|
Test that TABLE_LIST::db is the same as st_table_share::db to
|
||||||
|
ensure consistency. An exception are I_S schema tables, which
|
||||||
|
are inconsistent in this respect.
|
||||||
|
*/
|
||||||
|
DBUG_ASSERT(!strcmp(table_ref->db, table_ref->table->s->db) ||
|
||||||
|
(table_ref->schema_table &&
|
||||||
|
table_ref->table->s->db[0] == 0));
|
||||||
|
|
||||||
return table_ref->db;
|
return table_ref->db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user