Fix after review for

ChangeSet
  1.1803 05/01/24
  Additional fix for WL#1629: SHOW with WHERE(discussed with PeterG) 
parent a6315a8a
...@@ -264,6 +264,18 @@ prepare stmt4 from ' show tables from test like ''t2%'' '; ...@@ -264,6 +264,18 @@ prepare stmt4 from ' show tables from test like ''t2%'' ';
execute stmt4; execute stmt4;
Tables_in_test (t2%) Tables_in_test (t2%)
t2 t2
prepare stmt4 from ' show columns from t2 where field in (select ?) ';
SET @arg00="a";
execute stmt4 using @arg00;
Field Type Null Key Default Extra
a int(11) NO PRI
SET @arg00="b";
execute stmt4 using @arg00;
Field Type Null Key Default Extra
b char(10) YES NULL
SET @arg00=1;
execute stmt4 using @arg00;
Field Type Null Key Default Extra
prepare stmt4 from ' show columns from t2 from test like ''a%'' '; prepare stmt4 from ' show columns from t2 from test like ''a%'' ';
execute stmt4; execute stmt4;
Field Type Null Key Default Extra Field Type Null Key Default Extra
......
...@@ -290,6 +290,14 @@ prepare stmt4 from ' show databases '; ...@@ -290,6 +290,14 @@ prepare stmt4 from ' show databases ';
execute stmt4; execute stmt4;
prepare stmt4 from ' show tables from test like ''t2%'' '; prepare stmt4 from ' show tables from test like ''t2%'' ';
execute stmt4; execute stmt4;
prepare stmt4 from ' show columns from t2 where field in (select ?) ';
SET @arg00="a";
execute stmt4 using @arg00;
SET @arg00="b";
execute stmt4 using @arg00;
SET @arg00=1;
execute stmt4 using @arg00;
prepare stmt4 from ' show columns from t2 from test like ''a%'' '; prepare stmt4 from ' show columns from t2 from test like ''a%'' ';
execute stmt4; execute stmt4;
create index t2_idx on t2(b); create index t2_idx on t2(b);
......
...@@ -2135,8 +2135,18 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list, ...@@ -2135,8 +2135,18 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
{ {
if (!my_strcasecmp(system_charset_info, trans[i].name, name)) if (!my_strcasecmp(system_charset_info, trans[i].name, name))
{ {
if (table_list->schema_table_reformed)
{
/*
Translation table items are always Item_fields
and fixed already('mysql_schema_table' function).
So we can return ->field. It is used only for
'show & where' commands.
*/
DBUG_RETURN(((Item_field*) (trans[i].item))->field);
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
if (check_grants_view && !table_list->schema_table_reformed && if (check_grants_view &&
check_grant_column(thd, &table_list->grant, check_grant_column(thd, &table_list->grant,
table_list->view_db.str, table_list->view_db.str,
table_list->view_name.str, table_list->view_name.str,
......
...@@ -3207,22 +3207,10 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) ...@@ -3207,22 +3207,10 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
{ {
if (!transl->item->fixed && if (!transl->item->fixed &&
transl->item->fix_fields(thd, table_list, &transl->item)) transl->item->fix_fields(thd, table_list, &transl->item))
{
DBUG_RETURN(1); DBUG_RETURN(1);
}
}
if (sel->where && !sel->where->fixed &&
sel->where->fix_fields(thd, table_list, &sel->where))
{
DBUG_RETURN(1);
}
for (transl= table_list->field_translation; transl < end; transl++)
{
transl->item->rename((char *)transl->name);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
List_iterator_fast<Item> it(sel->item_list); List_iterator_fast<Item> it(sel->item_list);
if (!(transl= if (!(transl=
(Field_translator*)(thd->current_arena-> (Field_translator*)(thd->current_arena->
...@@ -3236,9 +3224,7 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) ...@@ -3236,9 +3224,7 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
char *name= item->name; char *name= item->name;
transl[i].item= item; transl[i].item= item;
if (!item->fixed && item->fix_fields(thd, table_list, &transl[i].item)) if (!item->fixed && item->fix_fields(thd, table_list, &transl[i].item))
{
DBUG_RETURN(1); DBUG_RETURN(1);
}
transl[i++].name= name; transl[i++].name= name;
} }
table_list->field_translation= transl; table_list->field_translation= transl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment