Skip to content

Commit f24d08d

Browse files
committed
MDEV-35437 Suppress "This function has the same name" warnings in I_S queries
Sending "This function has the same name" during I_S quries was too verbose. Suppressing these warnings. Now warnings are sent only during CREATE FUNCTION and during function call.
1 parent eff9c19 commit f24d08d

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

mysql-test/main/sp.result

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9101,3 +9101,27 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
91019101
#
91029102
# End of 10.7 tests
91039103
#
9104+
#
9105+
# Start of 11.8 tests
9106+
#
9107+
#
9108+
# MDEV-35437 Suppress "This function has the same name" warnings in I_S queries
9109+
#
9110+
CREATE FUNCTION upper() RETURNS TEXT RETURN 'upper';
9111+
Warnings:
9112+
Note 1585 This function 'upper' has the same name as a native function
9113+
SELECT test.upper();
9114+
test.upper()
9115+
upper
9116+
Warnings:
9117+
Note 1585 This function 'upper' has the same name as a native function
9118+
SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test' AND ROUTINE_NAME='upper';
9119+
ROUTINE_NAME
9120+
upper
9121+
SELECT SPECIFIC_NAME FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA='test' AND SPECIFIC_NAME='upper';
9122+
SPECIFIC_NAME
9123+
upper
9124+
DROP FUNCTION upper;
9125+
#
9126+
# End of 11.8 tests
9127+
#

mysql-test/main/sp.test

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10699,3 +10699,24 @@ CREATE PROCEDURE sp() SELECT @;
1069910699
--echo #
1070010700
--echo # End of 10.7 tests
1070110701
--echo #
10702+
10703+
10704+
--echo #
10705+
--echo # Start of 11.8 tests
10706+
--echo #
10707+
10708+
--echo #
10709+
--echo # MDEV-35437 Suppress "This function has the same name" warnings in I_S queries
10710+
--echo #
10711+
10712+
CREATE FUNCTION upper() RETURNS TEXT RETURN 'upper';
10713+
SELECT test.upper();
10714+
# I_S queries should not produce warnings
10715+
SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test' AND ROUTINE_NAME='upper';
10716+
SELECT SPECIFIC_NAME FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA='test' AND SPECIFIC_NAME='upper';
10717+
DROP FUNCTION upper;
10718+
10719+
10720+
--echo #
10721+
--echo # End of 11.8 tests
10722+
--echo #

sql/sql_show.cc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7174,6 +7174,27 @@ int store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
71747174
}
71757175

71767176

7177+
/*
7178+
Suppress "This function 'func' has the same name as a native function"
7179+
during INFORMATION_SCHEMA.ROUTINES queries.
7180+
*/
7181+
class Native_fct_name_collision_error_handler : public Internal_error_handler
7182+
{
7183+
public:
7184+
bool handle_condition(THD *thd,
7185+
uint sql_errno,
7186+
const char* sqlstate,
7187+
Sql_condition::enum_warning_level *level,
7188+
const char* msg,
7189+
Sql_condition ** cond_hdl) override
7190+
{
7191+
if (sql_errno == ER_NATIVE_FCT_NAME_COLLISION)
7192+
return true;
7193+
return false;
7194+
}
7195+
};
7196+
7197+
71777198
int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
71787199
{
71797200
TABLE *proc_table;
@@ -7184,6 +7205,7 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
71847205
char definer[USER_HOST_BUFF_SIZE];
71857206
enum enum_schema_tables schema_table_idx=
71867207
get_schema_table_idx(tables->schema_table);
7208+
Native_fct_name_collision_error_handler err_handler;
71877209
DBUG_ENTER("fill_schema_proc");
71887210

71897211
strxmov(definer, thd->security_ctx->priv_user, "@",
@@ -7254,7 +7276,8 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
72547276

72557277
if (res)
72567278
goto err;
7257-
7279+
thd->push_internal_handler(&err_handler);
7280+
72587281
res= schema_table_idx == SCH_PROCEDURES ?
72597282
store_schema_proc(thd, table, proc_table, &lookup, full_access,definer) :
72607283
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)
72647287
store_schema_proc(thd, table, proc_table, &lookup, full_access, definer) :
72657288
store_schema_params(thd, table, proc_table, &lookup, full_access, definer);
72667289
}
7290+
thd->pop_internal_handler();
72677291

72687292
err:
72697293
if (proc_table->file->inited)

0 commit comments

Comments
 (0)