Adding Item_string_sys and Item_string_ascii to reduce duplicate code
This commit is contained in:
parent
e42f4e3199
commit
1e66871713
26
sql/item.h
26
sql/item.h
@ -2929,6 +2929,32 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Item_string_sys :public Item_string
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Item_string_sys(const char *str, uint length)
|
||||||
|
:Item_string(str, length, system_charset_info)
|
||||||
|
{ }
|
||||||
|
Item_string_sys(const char *str)
|
||||||
|
:Item_string(str, strlen(str), system_charset_info)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Item_string_ascii :public Item_string
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Item_string_ascii(const char *str, uint length)
|
||||||
|
:Item_string(str, length, &my_charset_latin1,
|
||||||
|
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII)
|
||||||
|
{ }
|
||||||
|
Item_string_ascii(const char *str)
|
||||||
|
:Item_string(str, strlen(str), &my_charset_latin1,
|
||||||
|
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
longlong
|
longlong
|
||||||
longlong_from_string_with_check(CHARSET_INFO *cs, const char *cptr,
|
longlong_from_string_with_check(CHARSET_INFO *cs, const char *cptr,
|
||||||
const char *end);
|
const char *end);
|
||||||
|
@ -7551,7 +7551,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
|
|||||||
}
|
}
|
||||||
DBUG_ASSERT(rolename || username);
|
DBUG_ASSERT(rolename || username);
|
||||||
|
|
||||||
Item_string *field=new Item_string("",0,&my_charset_latin1);
|
Item_string *field=new Item_string_ascii("", 0);
|
||||||
List<Item> field_list;
|
List<Item> field_list;
|
||||||
field->name=buff;
|
field->name=buff;
|
||||||
field->max_length=1024;
|
field->max_length=1024;
|
||||||
|
@ -203,15 +203,13 @@ bool Explain_query::print_explain_str(THD *thd, String *out_str)
|
|||||||
|
|
||||||
static void push_str(List<Item> *item_list, const char *str)
|
static void push_str(List<Item> *item_list, const char *str)
|
||||||
{
|
{
|
||||||
item_list->push_back(new Item_string(str,
|
item_list->push_back(new Item_string_sys(str));
|
||||||
strlen(str), system_charset_info));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void push_string(List<Item> *item_list, String *str)
|
static void push_string(List<Item> *item_list, String *str)
|
||||||
{
|
{
|
||||||
item_list->push_back(new Item_string(str->ptr(), str->length(),
|
item_list->push_back(new Item_string_sys(str->ptr(), str->length()));
|
||||||
system_charset_info));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -262,8 +260,7 @@ int Explain_union::print_explain(Explain_query *query,
|
|||||||
len+= lastop;
|
len+= lastop;
|
||||||
table_name_buffer[len - 1]= '>'; // change ',' to '>'
|
table_name_buffer[len - 1]= '>'; // change ',' to '>'
|
||||||
}
|
}
|
||||||
const CHARSET_INFO *cs= system_charset_info;
|
item_list.push_back(new Item_string_sys(table_name_buffer, len));
|
||||||
item_list.push_back(new Item_string(table_name_buffer, len, cs));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* `partitions` column */
|
/* `partitions` column */
|
||||||
@ -298,8 +295,7 @@ int Explain_union::print_explain(Explain_query *query,
|
|||||||
{
|
{
|
||||||
extra_buf.append(STRING_WITH_LEN("Using filesort"));
|
extra_buf.append(STRING_WITH_LEN("Using filesort"));
|
||||||
}
|
}
|
||||||
const CHARSET_INFO *cs= system_charset_info;
|
item_list.push_back(new Item_string_sys(extra_buf.ptr(), extra_buf.length()));
|
||||||
item_list.push_back(new Item_string(extra_buf.ptr(), extra_buf.length(), cs));
|
|
||||||
|
|
||||||
//output->unit.offset_limit_cnt= 0;
|
//output->unit.offset_limit_cnt= 0;
|
||||||
if (output->send_data(item_list))
|
if (output->send_data(item_list))
|
||||||
@ -349,12 +345,10 @@ int Explain_select::print_explain(Explain_query *query,
|
|||||||
if (message)
|
if (message)
|
||||||
{
|
{
|
||||||
List<Item> item_list;
|
List<Item> item_list;
|
||||||
const CHARSET_INFO *cs= system_charset_info;
|
|
||||||
Item *item_null= new Item_null();
|
Item *item_null= new Item_null();
|
||||||
|
|
||||||
item_list.push_back(new Item_int((int32) select_id));
|
item_list.push_back(new Item_int((int32) select_id));
|
||||||
item_list.push_back(new Item_string(select_type,
|
item_list.push_back(new Item_string_sys(select_type));
|
||||||
strlen(select_type), cs));
|
|
||||||
for (uint i=0 ; i < 7; i++)
|
for (uint i=0 ; i < 7; i++)
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
if (explain_flags & DESCRIBE_PARTITIONS)
|
if (explain_flags & DESCRIBE_PARTITIONS)
|
||||||
@ -362,7 +356,7 @@ int Explain_select::print_explain(Explain_query *query,
|
|||||||
if (explain_flags & DESCRIBE_EXTENDED)
|
if (explain_flags & DESCRIBE_EXTENDED)
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
|
|
||||||
item_list.push_back(new Item_string(message,strlen(message),cs));
|
item_list.push_back(new Item_string_sys(message));
|
||||||
|
|
||||||
if (output->send_data(item_list))
|
if (output->send_data(item_list))
|
||||||
return 1;
|
return 1;
|
||||||
@ -560,7 +554,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
|
|||||||
extra_buf.append(STRING_WITH_LEN("Using filesort"));
|
extra_buf.append(STRING_WITH_LEN("Using filesort"));
|
||||||
}
|
}
|
||||||
|
|
||||||
item_list.push_back(new Item_string(extra_buf.ptr(), extra_buf.length(), cs));
|
item_list.push_back(new Item_string_sys(extra_buf.ptr(), extra_buf.length()));
|
||||||
|
|
||||||
if (output->send_data(item_list))
|
if (output->send_data(item_list))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -626,7 +626,7 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen,
|
|||||||
{
|
{
|
||||||
Item *cond= new Item_func_like(new Item_field(pfname),
|
Item *cond= new Item_func_like(new Item_field(pfname),
|
||||||
new Item_string(mask,mlen,pfname->charset()),
|
new Item_string(mask,mlen,pfname->charset()),
|
||||||
new Item_string("\\",1,&my_charset_latin1),
|
new Item_string_ascii("\\"),
|
||||||
FALSE);
|
FALSE);
|
||||||
if (thd->is_fatal_error)
|
if (thd->is_fatal_error)
|
||||||
return 0; // OOM
|
return 0; // OOM
|
||||||
|
@ -22950,13 +22950,11 @@ int print_explain_message_line(select_result_sink *result,
|
|||||||
ha_rows *rows,
|
ha_rows *rows,
|
||||||
const char *message)
|
const char *message)
|
||||||
{
|
{
|
||||||
const CHARSET_INFO *cs= system_charset_info;
|
|
||||||
Item *item_null= new Item_null();
|
Item *item_null= new Item_null();
|
||||||
List<Item> item_list;
|
List<Item> item_list;
|
||||||
|
|
||||||
item_list.push_back(new Item_int((int32) select_number));
|
item_list.push_back(new Item_int((int32) select_number));
|
||||||
item_list.push_back(new Item_string(select_type,
|
item_list.push_back(new Item_string_sys(select_type));
|
||||||
strlen(select_type), cs));
|
|
||||||
/* `table` */
|
/* `table` */
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
|
|
||||||
@ -22983,7 +22981,7 @@ int print_explain_message_line(select_result_sink *result,
|
|||||||
|
|
||||||
/* `Extra` */
|
/* `Extra` */
|
||||||
if (message)
|
if (message)
|
||||||
item_list.push_back(new Item_string(message,strlen(message),cs));
|
item_list.push_back(new Item_string_sys(message));
|
||||||
else
|
else
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
|
|
||||||
@ -23042,45 +23040,39 @@ int print_explain_row(select_result_sink *result,
|
|||||||
ha_rows *rows,
|
ha_rows *rows,
|
||||||
const char *extra)
|
const char *extra)
|
||||||
{
|
{
|
||||||
const CHARSET_INFO *cs= system_charset_info;
|
|
||||||
Item *item_null= new Item_null();
|
Item *item_null= new Item_null();
|
||||||
List<Item> item_list;
|
List<Item> item_list;
|
||||||
Item *item;
|
Item *item;
|
||||||
|
|
||||||
item_list.push_back(new Item_int((int32) select_number));
|
item_list.push_back(new Item_int((int32) select_number));
|
||||||
item_list.push_back(new Item_string(select_type,
|
item_list.push_back(new Item_string_sys(select_type));
|
||||||
strlen(select_type), cs));
|
item_list.push_back(new Item_string_sys(table_name));
|
||||||
item_list.push_back(new Item_string(table_name,
|
|
||||||
strlen(table_name), cs));
|
|
||||||
if (options & DESCRIBE_PARTITIONS)
|
if (options & DESCRIBE_PARTITIONS)
|
||||||
{
|
{
|
||||||
if (partitions)
|
if (partitions)
|
||||||
{
|
{
|
||||||
item_list.push_back(new Item_string(partitions,
|
item_list.push_back(new Item_string_sys(partitions));
|
||||||
strlen(partitions), cs));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *jtype_str= join_type_str[jtype];
|
const char *jtype_str= join_type_str[jtype];
|
||||||
item_list.push_back(new Item_string(jtype_str,
|
item_list.push_back(new Item_string_sys(jtype_str));
|
||||||
strlen(jtype_str), cs));
|
|
||||||
|
|
||||||
item= possible_keys? new Item_string(possible_keys, strlen(possible_keys),
|
item= possible_keys? new Item_string_sys(possible_keys) : item_null;
|
||||||
cs) : item_null;
|
|
||||||
item_list.push_back(item);
|
item_list.push_back(item);
|
||||||
|
|
||||||
/* 'index */
|
/* 'index */
|
||||||
item= index ? new Item_string(index, strlen(index), cs) : item_null;
|
item= index ? new Item_string_sys(index) : item_null;
|
||||||
item_list.push_back(item);
|
item_list.push_back(item);
|
||||||
|
|
||||||
/* 'key_len */
|
/* 'key_len */
|
||||||
item= key_len ? new Item_string(key_len, strlen(key_len), cs) : item_null;
|
item= key_len ? new Item_string_sys(key_len) : item_null;
|
||||||
item_list.push_back(item);
|
item_list.push_back(item);
|
||||||
|
|
||||||
/* 'ref' */
|
/* 'ref' */
|
||||||
item= ref ? new Item_string(ref, strlen(ref), cs) : item_null;
|
item= ref ? new Item_string_sys(ref) : item_null;
|
||||||
item_list.push_back(item);
|
item_list.push_back(item);
|
||||||
|
|
||||||
/* 'rows' */
|
/* 'rows' */
|
||||||
@ -23099,7 +23091,7 @@ int print_explain_row(select_result_sink *result,
|
|||||||
|
|
||||||
/* 'Extra' */
|
/* 'Extra' */
|
||||||
if (extra)
|
if (extra)
|
||||||
item_list.push_back(new Item_string(extra, strlen(extra), cs));
|
item_list.push_back(new Item_string_sys(extra));
|
||||||
else
|
else
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
|
|
||||||
@ -23112,7 +23104,6 @@ int print_explain_row(select_result_sink *result,
|
|||||||
int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
||||||
SELECT_LEX *select_lex, uint8 explain_flags)
|
SELECT_LEX *select_lex, uint8 explain_flags)
|
||||||
{
|
{
|
||||||
const CHARSET_INFO *cs= system_charset_info;
|
|
||||||
Item *item_null= new Item_null();
|
Item *item_null= new Item_null();
|
||||||
List<Item> item_list;
|
List<Item> item_list;
|
||||||
if (on_the_fly)
|
if (on_the_fly)
|
||||||
@ -23129,9 +23120,7 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
|||||||
/* id */
|
/* id */
|
||||||
item_list.push_back(new Item_null);
|
item_list.push_back(new Item_null);
|
||||||
/* select_type */
|
/* select_type */
|
||||||
item_list.push_back(new Item_string(select_lex->type,
|
item_list.push_back(new Item_string_sys(select_lex->type));
|
||||||
strlen(select_lex->type),
|
|
||||||
cs));
|
|
||||||
/* table */
|
/* table */
|
||||||
{
|
{
|
||||||
SELECT_LEX *sl= select_lex->master_unit()->first_select();
|
SELECT_LEX *sl= select_lex->master_unit()->first_select();
|
||||||
@ -23153,15 +23142,14 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
|||||||
len+= lastop;
|
len+= lastop;
|
||||||
table_name_buffer[len - 1]= '>'; // change ',' to '>'
|
table_name_buffer[len - 1]= '>'; // change ',' to '>'
|
||||||
}
|
}
|
||||||
item_list.push_back(new Item_string(table_name_buffer, len, cs));
|
item_list.push_back(new Item_string_sys(table_name_buffer, len));
|
||||||
}
|
}
|
||||||
/* partitions */
|
/* partitions */
|
||||||
if (explain_flags & DESCRIBE_PARTITIONS)
|
if (explain_flags & DESCRIBE_PARTITIONS)
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
/* type */
|
/* type */
|
||||||
item_list.push_back(new Item_string(join_type_str[JT_ALL],
|
item_list.push_back(new Item_string_sys(join_type_str[JT_ALL]));
|
||||||
strlen(join_type_str[JT_ALL]),
|
|
||||||
cs));
|
|
||||||
/* possible_keys */
|
/* possible_keys */
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
/* key*/
|
/* key*/
|
||||||
@ -23177,10 +23165,9 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
|||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
/* extra */
|
/* extra */
|
||||||
if (select_lex->master_unit()->global_parameters->order_list.first)
|
if (select_lex->master_unit()->global_parameters->order_list.first)
|
||||||
item_list.push_back(new Item_string("Using filesort",
|
item_list.push_back(new Item_string_sys("Using filesort", 14));
|
||||||
14, cs));
|
|
||||||
else
|
else
|
||||||
item_list.push_back(new Item_string("", 0, cs));
|
item_list.push_back(new Item_string_sys("", 0));
|
||||||
|
|
||||||
if (result->send_data(item_list))
|
if (result->send_data(item_list))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -11124,8 +11124,8 @@ opt_escape:
|
|||||||
{
|
{
|
||||||
Lex->escape_used= FALSE;
|
Lex->escape_used= FALSE;
|
||||||
$$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ?
|
$$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ?
|
||||||
new (thd->mem_root) Item_string("", 0, &my_charset_latin1) :
|
new (thd->mem_root) Item_string_ascii("", 0) :
|
||||||
new (thd->mem_root) Item_string("\\", 1, &my_charset_latin1));
|
new (thd->mem_root) Item_string_ascii("\\", 1));
|
||||||
if ($$ == NULL)
|
if ($$ == NULL)
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
@ -14792,19 +14792,19 @@ set_expr_or_default:
|
|||||||
| DEFAULT { $$=0; }
|
| DEFAULT { $$=0; }
|
||||||
| ON
|
| ON
|
||||||
{
|
{
|
||||||
$$=new (thd->mem_root) Item_string("ON", 2, system_charset_info);
|
$$=new (thd->mem_root) Item_string_sys("ON", 2);
|
||||||
if ($$ == NULL)
|
if ($$ == NULL)
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| ALL
|
| ALL
|
||||||
{
|
{
|
||||||
$$=new (thd->mem_root) Item_string("ALL", 3, system_charset_info);
|
$$=new (thd->mem_root) Item_string_sys("ALL", 3);
|
||||||
if ($$ == NULL)
|
if ($$ == NULL)
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| BINARY
|
| BINARY
|
||||||
{
|
{
|
||||||
$$=new (thd->mem_root) Item_string("binary", 6, system_charset_info);
|
$$=new (thd->mem_root) Item_string_sys("binary", 6);
|
||||||
if ($$ == NULL)
|
if ($$ == NULL)
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user