summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/field.h6
-rw-r--r--sql/sp.cc9
2 files changed, 10 insertions, 5 deletions
diff --git a/sql/field.h b/sql/field.h
index 218308ead13..c32f365ec92 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -319,6 +319,12 @@ public:
/* convert decimal to longlong with overflow check */
longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag,
int *err);
+ /* The max. number of characters */
+ inline uint32 Field::char_length() const
+ {
+ return field_length / charset()->mbmaxlen;
+ }
+
friend bool reopen_table(THD *,struct st_table *,bool);
friend int cre_myisam(my_string name, register TABLE *form, uint options,
ulonglong auto_increment_value);
diff --git a/sql/sp.cc b/sql/sp.cc
index 53218aece56..93dfd68cef3 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -509,11 +509,10 @@ db_create_routine(THD *thd, int type, sp_head *sp)
goto done;
}
- if ((system_charset_info->cset->numchars(system_charset_info,
- sp->m_name.str,
- sp->m_name.str+sp->m_name.length) *
- table->field[MYSQL_PROC_FIELD_NAME]->charset()->mbmaxlen) >
- table->field[MYSQL_PROC_FIELD_NAME]->field_length)
+ if (system_charset_info->cset->numchars(system_charset_info,
+ sp->m_name.str,
+ sp->m_name.str+sp->m_name.length) >
+ table->field[MYSQL_PROC_FIELD_NAME]->char_length())
{
ret= SP_BAD_IDENTIFIER;
goto done;