mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Name resolution context added (BUG#6443)
This commit is contained in:
@ -3240,11 +3240,13 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
|
||||
int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
{
|
||||
ST_FIELD_INFO *field_info= schema_table->fields_info;
|
||||
Name_resolution_context *context= &thd->lex->select_lex.context;
|
||||
for ( ; field_info->field_name; field_info++)
|
||||
{
|
||||
if (field_info->old_name)
|
||||
{
|
||||
Item_field *field= new Item_field(NullS, NullS, field_info->field_name);
|
||||
Item_field *field= new Item_field(context,
|
||||
NullS, NullS, field_info->field_name);
|
||||
if (field)
|
||||
{
|
||||
field->set_name(field_info->old_name,
|
||||
@ -3264,12 +3266,14 @@ int make_schemata_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
char tmp[128];
|
||||
LEX *lex= thd->lex;
|
||||
SELECT_LEX *sel= lex->current_select;
|
||||
Name_resolution_context *context= &sel->context;
|
||||
|
||||
if (!sel->item_list.elements)
|
||||
{
|
||||
ST_FIELD_INFO *field_info= &schema_table->fields_info[1];
|
||||
String buffer(tmp,sizeof(tmp), system_charset_info);
|
||||
Item_field *field= new Item_field(NullS, NullS, field_info->field_name);
|
||||
Item_field *field= new Item_field(context,
|
||||
NullS, NullS, field_info->field_name);
|
||||
if (!field || add_item_to_list(thd, field))
|
||||
return 1;
|
||||
buffer.length(0);
|
||||
@ -3291,6 +3295,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
char tmp[128];
|
||||
String buffer(tmp,sizeof(tmp), thd->charset());
|
||||
LEX *lex= thd->lex;
|
||||
Name_resolution_context *context= &lex->select_lex.context;
|
||||
|
||||
ST_FIELD_INFO *field_info= &schema_table->fields_info[2];
|
||||
buffer.length(0);
|
||||
@ -3302,7 +3307,8 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
buffer.append(lex->wild->ptr());
|
||||
buffer.append(")");
|
||||
}
|
||||
Item_field *field= new Item_field(NullS, NullS, field_info->field_name);
|
||||
Item_field *field= new Item_field(context,
|
||||
NullS, NullS, field_info->field_name);
|
||||
if (add_item_to_list(thd, field))
|
||||
return 1;
|
||||
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
|
||||
@ -3310,7 +3316,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
{
|
||||
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
|
||||
field_info= &schema_table->fields_info[3];
|
||||
field= new Item_field(NullS, NullS, field_info->field_name);
|
||||
field= new Item_field(context, NullS, NullS, field_info->field_name);
|
||||
if (add_item_to_list(thd, field))
|
||||
return 1;
|
||||
field->set_name(field_info->old_name, strlen(field_info->old_name),
|
||||
@ -3325,6 +3331,8 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
int fields_arr[]= {3, 14, 13, 6, 15, 5, 16, 17, 18, -1};
|
||||
int *field_num= fields_arr;
|
||||
ST_FIELD_INFO *field_info;
|
||||
Name_resolution_context *context= &thd->lex->select_lex.context;
|
||||
|
||||
for (; *field_num >= 0; field_num++)
|
||||
{
|
||||
field_info= &schema_table->fields_info[*field_num];
|
||||
@ -3332,7 +3340,8 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
*field_num == 17 ||
|
||||
*field_num == 18))
|
||||
continue;
|
||||
Item_field *field= new Item_field(NullS, NullS, field_info->field_name);
|
||||
Item_field *field= new Item_field(context,
|
||||
NullS, NullS, field_info->field_name);
|
||||
if (field)
|
||||
{
|
||||
field->set_name(field_info->old_name,
|
||||
@ -3351,10 +3360,13 @@ int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
int fields_arr[]= {0, 2, 1, 3, -1};
|
||||
int *field_num= fields_arr;
|
||||
ST_FIELD_INFO *field_info;
|
||||
Name_resolution_context *context= &thd->lex->select_lex.context;
|
||||
|
||||
for (; *field_num >= 0; field_num++)
|
||||
{
|
||||
field_info= &schema_table->fields_info[*field_num];
|
||||
Item_field *field= new Item_field(NullS, NullS, field_info->field_name);
|
||||
Item_field *field= new Item_field(context,
|
||||
NullS, NullS, field_info->field_name);
|
||||
if (field)
|
||||
{
|
||||
field->set_name(field_info->old_name,
|
||||
@ -3373,10 +3385,13 @@ int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
int fields_arr[]= {2, 3, 4, 19, 16, 15, 14, 18, -1};
|
||||
int *field_num= fields_arr;
|
||||
ST_FIELD_INFO *field_info;
|
||||
Name_resolution_context *context= &thd->lex->select_lex.context;
|
||||
|
||||
for (; *field_num >= 0; field_num++)
|
||||
{
|
||||
field_info= &schema_table->fields_info[*field_num];
|
||||
Item_field *field= new Item_field(NullS, NullS, field_info->field_name);
|
||||
Item_field *field= new Item_field(context,
|
||||
NullS, NullS, field_info->field_name);
|
||||
if (field)
|
||||
{
|
||||
field->set_name(field_info->old_name,
|
||||
@ -3442,12 +3457,11 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
|
||||
|
||||
if (table_list->field_translation)
|
||||
{
|
||||
Field_translator *end= table_list->field_translation +
|
||||
sel->item_list.elements;
|
||||
Field_translator *end= table_list->field_translation_end;
|
||||
for (transl= table_list->field_translation; transl < end; transl++)
|
||||
{
|
||||
if (!transl->item->fixed &&
|
||||
transl->item->fix_fields(thd, table_list, &transl->item))
|
||||
transl->item->fix_fields(thd, &transl->item))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
@ -3464,11 +3478,12 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
|
||||
{
|
||||
char *name= item->name;
|
||||
transl[i].item= item;
|
||||
if (!item->fixed && item->fix_fields(thd, table_list, &transl[i].item))
|
||||
if (!item->fixed && item->fix_fields(thd, &transl[i].item))
|
||||
DBUG_RETURN(1);
|
||||
transl[i++].name= name;
|
||||
}
|
||||
table_list->field_translation= transl;
|
||||
table_list->field_translation_end= transl + sel->item_list.elements;
|
||||
}
|
||||
|
||||
DBUG_RETURN(0);
|
||||
@ -3495,7 +3510,7 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
|
||||
ST_SCHEMA_TABLE *schema_table= get_schema_table(schema_table_idx);
|
||||
LEX_STRING db, table;
|
||||
DBUG_ENTER("mysql_schema_select");
|
||||
/*
|
||||
/*
|
||||
We have to make non const db_name & table_name
|
||||
because of lower_case_table_names
|
||||
*/
|
||||
@ -3503,7 +3518,7 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
|
||||
information_schema_name.length, 0);
|
||||
make_lex_string(thd, &table, schema_table->table_name,
|
||||
strlen(schema_table->table_name), 0);
|
||||
if (schema_table->old_format(thd, schema_table) || /* Handle old syntax */
|
||||
if (schema_table->old_format(thd, schema_table) || /* Handle old syntax */
|
||||
!sel->add_table_to_list(thd, new Table_ident(thd, db, table, 0),
|
||||
0, 0, TL_READ, (List<String> *) 0,
|
||||
(List<String> *) 0))
|
||||
|
Reference in New Issue
Block a user