mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
reduce code duplication a little
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
#include "sql_priv.h"
|
#include "sql_priv.h"
|
||||||
#include "unireg.h"
|
#include "unireg.h"
|
||||||
#include "sql_base.h" // close_thread_tables
|
#include "sql_base.h" // close_thread_tables
|
||||||
|
#include "sql_parse.h"
|
||||||
#include "event_db_repository.h"
|
#include "event_db_repository.h"
|
||||||
#include "key.h" // key_copy
|
#include "key.h" // key_copy
|
||||||
#include "sql_db.h" // get_default_db_collation
|
#include "sql_db.h" // get_default_db_collation
|
||||||
@ -702,19 +703,17 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
|
|||||||
|
|
||||||
restore_record(table, s->default_values); // Get default values for fields
|
restore_record(table, s->default_values); // Get default values for fields
|
||||||
|
|
||||||
if (system_charset_info->cset->
|
if (check_string_char_length(&parse_data->dbname, 0,
|
||||||
numchars(system_charset_info, parse_data->dbname.str,
|
table->field[ET_FIELD_DB]->char_length(),
|
||||||
parse_data->dbname.str + parse_data->dbname.length) >
|
system_charset_info, 1))
|
||||||
table->field[ET_FIELD_DB]->char_length())
|
|
||||||
{
|
{
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), parse_data->dbname.str);
|
my_error(ER_TOO_LONG_IDENT, MYF(0), parse_data->dbname.str);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (system_charset_info->cset->
|
if (check_string_char_length(&parse_data->name, 0,
|
||||||
numchars(system_charset_info, parse_data->name.str,
|
table->field[ET_FIELD_NAME]->char_length(),
|
||||||
parse_data->name.str + parse_data->name.length) >
|
system_charset_info, 1))
|
||||||
table->field[ET_FIELD_NAME]->char_length())
|
|
||||||
{
|
{
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), parse_data->name.str);
|
my_error(ER_TOO_LONG_IDENT, MYF(0), parse_data->name.str);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -488,12 +488,8 @@ check_routine_name(LEX_STRING *ident)
|
|||||||
my_error(ER_SP_WRONG_NAME, MYF(0), ident->str);
|
my_error(ER_SP_WRONG_NAME, MYF(0), ident->str);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (check_string_char_length(ident, "", NAME_CHAR_LEN,
|
if (check_ident_length(ident))
|
||||||
system_charset_info, 1))
|
|
||||||
{
|
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), ident->str);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -4329,11 +4329,8 @@ create_sp_error:
|
|||||||
}
|
}
|
||||||
case SQLCOM_SHOW_CREATE_TRIGGER:
|
case SQLCOM_SHOW_CREATE_TRIGGER:
|
||||||
{
|
{
|
||||||
if (lex->spname->m_name.length > NAME_LEN)
|
if (check_ident_length(&lex->spname->m_name))
|
||||||
{
|
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
if (show_create_trigger(thd, lex->spname))
|
if (show_create_trigger(thd, lex->spname))
|
||||||
goto error; /* Error has been already logged. */
|
goto error; /* Error has been already logged. */
|
||||||
@ -6019,12 +6016,9 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
|
|||||||
LEX *lex= thd->lex;
|
LEX *lex= thd->lex;
|
||||||
DBUG_ENTER("add_field_to_list");
|
DBUG_ENTER("add_field_to_list");
|
||||||
|
|
||||||
if (check_string_char_length(field_name, "", NAME_CHAR_LEN,
|
if (check_ident_length(field_name))
|
||||||
system_charset_info, 1))
|
|
||||||
{
|
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), field_name->str); /* purecov: inspected */
|
|
||||||
DBUG_RETURN(1); /* purecov: inspected */
|
DBUG_RETURN(1); /* purecov: inspected */
|
||||||
}
|
|
||||||
if (type_modifier & PRI_KEY_FLAG)
|
if (type_modifier & PRI_KEY_FLAG)
|
||||||
{
|
{
|
||||||
Key *key;
|
Key *key;
|
||||||
@ -7688,6 +7682,17 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool check_ident_length(LEX_STRING *ident)
|
||||||
|
{
|
||||||
|
if (check_string_char_length(ident, 0, NAME_CHAR_LEN, system_charset_info, 1))
|
||||||
|
{
|
||||||
|
my_error(ER_TOO_LONG_IDENT, MYF(0), ident->str);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check if path does not contain mysql data home directory
|
Check if path does not contain mysql data home directory
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
|
|||||||
bool check_string_char_length(LEX_STRING *str, const char *err_msg,
|
bool check_string_char_length(LEX_STRING *str, const char *err_msg,
|
||||||
uint max_char_length, CHARSET_INFO *cs,
|
uint max_char_length, CHARSET_INFO *cs,
|
||||||
bool no_error);
|
bool no_error);
|
||||||
|
bool check_ident_length(LEX_STRING *ident);
|
||||||
CHARSET_INFO* merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl);
|
CHARSET_INFO* merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl);
|
||||||
bool check_host_name(LEX_STRING *str);
|
bool check_host_name(LEX_STRING *str);
|
||||||
bool check_identifier_name(LEX_STRING *str, uint max_char_length,
|
bool check_identifier_name(LEX_STRING *str, uint max_char_length,
|
||||||
|
@ -3312,12 +3312,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
|||||||
my_error(ER_TOO_MANY_KEY_PARTS,MYF(0),tmp);
|
my_error(ER_TOO_MANY_KEY_PARTS,MYF(0),tmp);
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
if (check_string_char_length(&key->name, "", NAME_CHAR_LEN,
|
if (check_ident_length(&key->name))
|
||||||
system_charset_info, 1))
|
|
||||||
{
|
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), key->name.str);
|
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
|
||||||
key_iterator2.rewind ();
|
key_iterator2.rewind ();
|
||||||
if (key->type != Key::FOREIGN_KEY)
|
if (key->type != Key::FOREIGN_KEY)
|
||||||
{
|
{
|
||||||
|
@ -455,12 +455,8 @@ int mysql_create_function(THD *thd,udf_func *udf)
|
|||||||
my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0));
|
my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0));
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
if (check_string_char_length(&udf->name, "", NAME_CHAR_LEN,
|
if (check_ident_length(&udf->name))
|
||||||
system_charset_info, 1))
|
|
||||||
{
|
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), udf->name.str);
|
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Turn off row binlogging of this statement and use statement-based
|
Turn off row binlogging of this statement and use statement-based
|
||||||
|
@ -4670,12 +4670,8 @@ part_name:
|
|||||||
{
|
{
|
||||||
partition_info *part_info= Lex->part_info;
|
partition_info *part_info= Lex->part_info;
|
||||||
partition_element *p_elem= part_info->curr_part_elem;
|
partition_element *p_elem= part_info->curr_part_elem;
|
||||||
if (check_string_char_length(&$1, "", NAME_CHAR_LEN,
|
if (check_ident_length(&$1))
|
||||||
system_charset_info, true))
|
|
||||||
{
|
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), $1.str);
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
|
||||||
p_elem->partition_name= $1.str;
|
p_elem->partition_name= $1.str;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -4971,12 +4967,8 @@ sub_part_definition:
|
|||||||
sub_name:
|
sub_name:
|
||||||
ident_or_text
|
ident_or_text
|
||||||
{
|
{
|
||||||
if (check_string_char_length(&$1, "", NAME_CHAR_LEN,
|
if (check_ident_length(&$1))
|
||||||
system_charset_info, true))
|
|
||||||
{
|
|
||||||
my_error(ER_TOO_LONG_IDENT, MYF(0), $1.str);
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
|
||||||
Lex->part_info->curr_part_elem->partition_name= $1.str;
|
Lex->part_info->curr_part_elem->partition_name= $1.str;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
Reference in New Issue
Block a user