diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/Makefile.am | 4 | ||||
-rw-r--r-- | sql/sp.cc | 4 | ||||
-rw-r--r-- | sql/sp_head.cc | 30 | ||||
-rw-r--r-- | sql/sql_acl.cc | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_show.cc | 6 | ||||
-rw-r--r-- | sql/sql_trigger.cc | 2 |
7 files changed, 25 insertions, 29 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am index 1437751bf2f..d701c18a4d7 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -97,7 +97,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ stacktrace.c repl_failsafe.h repl_failsafe.cc \ sql_olap.cc sql_view.cc \ gstream.cc spatial.cc sql_help.cc sql_cursor.cc \ - tztime.cc my_time.c my_decimal.cc\ + tztime.cc my_time.c my_user.c my_decimal.cc\ sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \ sp_cache.cc parse_file.cc sql_trigger.cc \ examples/ha_example.cc ha_archive.cc \ @@ -133,6 +133,8 @@ link_sources: mysql_tzinfo_to_sql.cc @LN_CP_F@ $(top_srcdir)/sql-common/client.c client.c rm -f my_time.c @LN_CP_F@ $(top_srcdir)/sql-common/my_time.c my_time.c + rm -f my_user.c + @LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c mysql_tzinfo_to_sql.o: $(mysql_tzinfo_to_sql_SOURCES) $(CXXCOMPILE) -c $(INCLUDES) -DTZINFO2SQL $< diff --git a/sql/sp.cc b/sql/sp.cc index a9b1a462d5f..37a9c02124e 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -480,7 +480,7 @@ db_create_routine(THD *thd, int type, sp_head *sp) { int ret; TABLE *table; - char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; + char definer[USER_HOST_BUFF_SIZE]; char olddb[128]; bool dbchanged; DBUG_ENTER("db_create_routine"); @@ -940,7 +940,7 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp, ulong level; sp_head *new_sp; const char *returns= ""; - char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; + char definer[USER_HOST_BUFF_SIZE]; String retstr(64); DBUG_PRINT("info", ("found: 0x%lx", (ulong)sp)); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 12f9260e7b1..d3045467f91 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -31,6 +31,8 @@ #define SP_STMT_PRINT_MAXLEN 40 +#include <my_user.h> + Item_result sp_map_result_type(enum enum_field_types type) { @@ -1752,29 +1754,21 @@ sp_head::set_info(longlong created, longlong modified, void - sp_head::set_definer(const char *definer, uint definerlen) { - const char *p= strrchr(definer, '@'); + uint user_name_len; + char user_name_str[USERNAME_LENGTH + 1]; + uint host_name_len; + char host_name_str[HOSTNAME_LENGTH + 1]; - if (!p) - { - m_definer_user.str= (char*) ""; - m_definer_user.length= 0; - m_definer_host.str= (char*) ""; - m_definer_host.length= 0; - } - else - { - const uint user_name_len= p - definer; - const uint host_name_len= definerlen - user_name_len - 1; + parse_user(definer, definerlen, user_name_str, &user_name_len, + host_name_str, &host_name_len); - m_definer_user.str= strmake_root(mem_root, definer, user_name_len); - m_definer_user.length= user_name_len; + m_definer_user.str= strmake_root(mem_root, user_name_str, user_name_len); + m_definer_user.length= user_name_len; - m_definer_host.str= strmake_root(mem_root, p + 1, host_name_len); - m_definer_host.length= host_name_len; - } + m_definer_host.str= strmake_root(mem_root, host_name_str, host_name_len); + m_definer_host.length= host_name_len; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 7bb84895da5..130674b47f9 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2490,7 +2490,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, ulong rights, ulong col_rights, bool revoke_grant) { - char grantor[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; + char grantor[USER_HOST_BUFF_SIZE]; int old_row_exists = 1; int error=0; ulong store_table_rights, store_col_rights; @@ -2608,7 +2608,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, const char *db, const char *routine_name, bool is_proc, ulong rights, bool revoke_grant) { - char grantor[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; + char grantor[USER_HOST_BUFF_SIZE]; int old_row_exists= 1; int error=0; ulong store_proc_rights; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9cdb288c045..76d24ede8f5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -214,7 +214,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, { int return_val= 0; uint temp_len, user_len; - char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2]; + char temp_user[USER_HOST_BUFF_SIZE]; struct user_conn *uc; DBUG_ASSERT(user != 0); @@ -743,7 +743,7 @@ static void reset_mqh(LEX_USER *lu, bool get_them= 0) { USER_CONN *uc; uint temp_len=lu->user.length+lu->host.length+2; - char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2]; + char temp_user[USER_HOST_BUFF_SIZE]; memcpy(temp_user,lu->user.str,lu->user.length); memcpy(temp_user+lu->user.length+1,lu->host.str,lu->host.length); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 089314078a6..d15df686e40 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2887,7 +2887,7 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) int res= 0; TABLE *table= tables->table; bool full_access; - char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; + char definer[USER_HOST_BUFF_SIZE]; Open_tables_state open_tables_state_backup; DBUG_ENTER("fill_schema_proc"); @@ -3029,7 +3029,7 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, { CHARSET_INFO *cs= system_charset_info; DBUG_ENTER("get_schema_views_record"); - char definer[HOSTNAME_LENGTH + USERNAME_LENGTH + 2]; + char definer[USER_HOST_BUFF_SIZE]; uint definer_len; if (tables->view) @@ -3213,7 +3213,7 @@ static int get_schema_triggers_record(THD *thd, struct st_table_list *tables, LEX_STRING trigger_name; LEX_STRING trigger_stmt; ulong sql_mode; - char definer_holder[HOSTNAME_LENGTH + USERNAME_LENGTH + 2]; + char definer_holder[USER_HOST_BUFF_SIZE]; LEX_STRING definer_buffer; definer_buffer.str= definer_holder; if (triggers->get_trigger_info(thd, (enum trg_event_type) event, diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index bbc32950c2d..c70914edc31 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -317,7 +317,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, LEX_STRING dir, file, trigname_file; LEX_STRING *trg_def, *name; ulonglong *trg_sql_mode; - char trg_definer_holder[HOSTNAME_LENGTH + USERNAME_LENGTH + 2]; + char trg_definer_holder[USER_HOST_BUFF_SIZE]; LEX_STRING *trg_definer; Item_trigger_field *trg_field; struct st_trigname trigname; |