diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index d365d36fac4..de043b04a79 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -9101,3 +9101,27 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp # # End of 10.7 tests # +# +# Start of 11.8 tests +# +# +# MDEV-35437 Suppress "This function has the same name" warnings in I_S queries +# +CREATE FUNCTION upper() RETURNS TEXT RETURN 'upper'; +Warnings: +Note 1585 This function 'upper' has the same name as a native function +SELECT test.upper(); +test.upper() +upper +Warnings: +Note 1585 This function 'upper' has the same name as a native function +SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test' AND ROUTINE_NAME='upper'; +ROUTINE_NAME +upper +SELECT SPECIFIC_NAME FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA='test' AND SPECIFIC_NAME='upper'; +SPECIFIC_NAME +upper +DROP FUNCTION upper; +# +# End of 11.8 tests +# diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index 8f3bca6b5b4..c027abb45c9 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -10699,3 +10699,24 @@ CREATE PROCEDURE sp() SELECT @; --echo # --echo # End of 10.7 tests --echo # + + +--echo # +--echo # Start of 11.8 tests +--echo # + +--echo # +--echo # MDEV-35437 Suppress "This function has the same name" warnings in I_S queries +--echo # + +CREATE FUNCTION upper() RETURNS TEXT RETURN 'upper'; +SELECT test.upper(); +# I_S queries should not produce warnings +SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test' AND ROUTINE_NAME='upper'; +SELECT SPECIFIC_NAME FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA='test' AND SPECIFIC_NAME='upper'; +DROP FUNCTION upper; + + +--echo # +--echo # End of 11.8 tests +--echo # diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0eb2df534bc..0fe5b936d3a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -7174,6 +7174,27 @@ int store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, } +/* + Suppress "This function 'func' has the same name as a native function" + during INFORMATION_SCHEMA.ROUTINES queries. +*/ +class Native_fct_name_collision_error_handler : public Internal_error_handler +{ +public: + bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + Sql_condition::enum_warning_level *level, + const char* msg, + Sql_condition ** cond_hdl) override + { + if (sql_errno == ER_NATIVE_FCT_NAME_COLLISION) + return true; + return false; + } +}; + + int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) { TABLE *proc_table; @@ -7184,6 +7205,7 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) char definer[USER_HOST_BUFF_SIZE]; enum enum_schema_tables schema_table_idx= get_schema_table_idx(tables->schema_table); + Native_fct_name_collision_error_handler err_handler; DBUG_ENTER("fill_schema_proc"); strxmov(definer, thd->security_ctx->priv_user, "@", @@ -7254,7 +7276,8 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) if (res) goto err; - + thd->push_internal_handler(&err_handler); + res= schema_table_idx == SCH_PROCEDURES ? store_schema_proc(thd, table, proc_table, &lookup, full_access,definer) : store_schema_params(thd, table, proc_table, &lookup, full_access, definer); @@ -7264,6 +7287,7 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) store_schema_proc(thd, table, proc_table, &lookup, full_access, definer) : store_schema_params(thd, table, proc_table, &lookup, full_access, definer); } + thd->pop_internal_handler(); err: if (proc_table->file->inited)