Commit 56d4eb21 authored by Praveenkumar Hulakund's avatar Praveenkumar Hulakund

Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE

Analysis:
-------------------------------
According to the Manual
(http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html):
"Column, index, stored routine, and event names are not case sensitive on any
platform, nor are column aliases."

In other words, 'lower_case_table_names' does not affect the behaviour of 
those identifiers.

On the other hand, trigger names are case sensitive on some platforms,
and case insensitive on others. 'lower_case_table_names' does not affect
the behaviour of trigger names either.

The bug was that SHOW statements did case sensitive comparison
for stored procedure / stored function / event names.

Fix:
Modified the code so that comparison in case insensitive for routines 
and events for "SHOW" operation.
parent e0581c7d
......@@ -109,6 +109,7 @@ DROP FUNCTION db1.f1;
DROP TABLE db1.t1;
DROP DATABASE db1;
DROP DATABASE db2;
USE test;
#
# Bug#13105873:valgrind warning:possible crash in foreign
# key handling on subsequent create table if not exists
......@@ -128,4 +129,121 @@ CALL p1();
Warnings:
Note 1050 Table 't2' already exists
DROP DATABASE testdb;
USE test;
End of 5.1 tests
#
# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
#
SET @@SQL_MODE = '';
CREATE FUNCTION testf_bug11763507() RETURNS INT
BEGIN
RETURN 0;
END
$
CREATE PROCEDURE testp_bug11763507()
BEGIN
SELECT "PROCEDURE testp_bug11763507";
END
$
CREATE EVENT teste_bug11763507 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO SELECT 1 $
SELECT testf_bug11763507();
testf_bug11763507()
0
SELECT TESTF_bug11763507();
TESTF_bug11763507()
0
SHOW FUNCTION STATUS LIKE 'testf_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testf_bug11763507 FUNCTION root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
SHOW FUNCTION STATUS WHERE NAME='testf_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testf_bug11763507 FUNCTION root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
SHOW FUNCTION STATUS LIKE 'TESTF_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testf_bug11763507 FUNCTION root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
SHOW FUNCTION STATUS WHERE NAME='TESTF_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testf_bug11763507 FUNCTION root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION testf_bug11763507;
Function sql_mode Create Function character_set_client collation_connection Database Collation
testf_bug11763507 CREATE DEFINER=`root`@`localhost` FUNCTION `testf_bug11763507`() RETURNS int(11)
BEGIN
RETURN 0;
END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION TESTF_bug11763507;
Function sql_mode Create Function character_set_client collation_connection Database Collation
testf_bug11763507 CREATE DEFINER=`root`@`localhost` FUNCTION `testf_bug11763507`() RETURNS int(11)
BEGIN
RETURN 0;
END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW FUNCTION CODE testf_bug11763507;
Pos Instruction
0 freturn 3 0
SHOW FUNCTION CODE TESTF_bug11763507;
Pos Instruction
0 freturn 3 0
CALL testp_bug11763507();
PROCEDURE testp_bug11763507
PROCEDURE testp_bug11763507
CALL TESTP_bug11763507();
PROCEDURE testp_bug11763507
PROCEDURE testp_bug11763507
SHOW PROCEDURE STATUS LIKE 'testp_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testp_bug11763507 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
SHOW PROCEDURE STATUS WHERE NAME='testp_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testp_bug11763507 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
SHOW PROCEDURE STATUS LIKE 'TESTP_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testp_bug11763507 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
SHOW PROCEDURE STATUS WHERE NAME='TESTP_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testp_bug11763507 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE PROCEDURE testp_bug11763507;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
testp_bug11763507 CREATE DEFINER=`root`@`localhost` PROCEDURE `testp_bug11763507`()
BEGIN
SELECT "PROCEDURE testp_bug11763507";
END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE PROCEDURE TESTP_bug11763507;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
testp_bug11763507 CREATE DEFINER=`root`@`localhost` PROCEDURE `testp_bug11763507`()
BEGIN
SELECT "PROCEDURE testp_bug11763507";
END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW PROCEDURE CODE testp_bug11763507;
Pos Instruction
0 stmt 0 "SELECT "PROCEDURE testp_bug11763507""
SHOW PROCEDURE CODE TESTP_bug11763507;
Pos Instruction
0 stmt 0 "SELECT "PROCEDURE testp_bug11763507""
SHOW EVENTS LIKE 'teste_bug11763507';
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
test teste_bug11763507 root@localhost SYSTEM ONE TIME # # # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW EVENTS LIKE 'TESTE_bug11763507';
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
test teste_bug11763507 root@localhost SYSTEM ONE TIME # # # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE EVENT teste_bug11763507;
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
teste_bug11763507 SYSTEM # latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE EVENT TESTE_bug11763507;
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
teste_bug11763507 SYSTEM # latin1 latin1_swedish_ci latin1_swedish_ci
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'testf_bug11763507';
specific_name
testf_bug11763507
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'TESTF_bug11763507';
specific_name
testf_bug11763507
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='testf_bug11763507';
specific_name
testf_bug11763507
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='TESTF_bug11763507';
specific_name
testf_bug11763507
DROP EVENT teste_bug11763507;
DROP PROCEDURE testp_bug11763507;
DROP FUNCTION testf_bug11763507;
#END OF BUG#11763507 test.
......@@ -138,6 +138,7 @@ DROP FUNCTION db1.f1;
DROP TABLE db1.t1;
DROP DATABASE db1;
DROP DATABASE db2;
USE test;
--echo #
--echo # Bug#13105873:valgrind warning:possible crash in foreign
......@@ -161,5 +162,90 @@ CALL p1();
--echo # below stmt should not return valgrind warnings
CALL p1();
DROP DATABASE testdb;
USE test;
--echo End of 5.1 tests
--echo #
--echo # Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
--echo #
SET @@SQL_MODE = '';
DELIMITER $;
CREATE FUNCTION testf_bug11763507() RETURNS INT
BEGIN
RETURN 0;
END
$
CREATE PROCEDURE testp_bug11763507()
BEGIN
SELECT "PROCEDURE testp_bug11763507";
END
$
CREATE EVENT teste_bug11763507 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO SELECT 1 $
DELIMITER ;$
# STORED FUNCTIONS
SELECT testf_bug11763507();
SELECT TESTF_bug11763507();
--replace_column 5 # 6 #
SHOW FUNCTION STATUS LIKE 'testf_bug11763507';
--replace_column 5 # 6 #
SHOW FUNCTION STATUS WHERE NAME='testf_bug11763507';
--replace_column 5 # 6 #
SHOW FUNCTION STATUS LIKE 'TESTF_bug11763507';
--replace_column 5 # 6 #
SHOW FUNCTION STATUS WHERE NAME='TESTF_bug11763507';
SHOW CREATE FUNCTION testf_bug11763507;
SHOW CREATE FUNCTION TESTF_bug11763507;
SHOW FUNCTION CODE testf_bug11763507;
SHOW FUNCTION CODE TESTF_bug11763507;
# STORED PROCEDURE
CALL testp_bug11763507();
CALL TESTP_bug11763507();
--replace_column 5 # 6 #
SHOW PROCEDURE STATUS LIKE 'testp_bug11763507';
--replace_column 5 # 6 #
SHOW PROCEDURE STATUS WHERE NAME='testp_bug11763507';
--replace_column 5 # 6 #
SHOW PROCEDURE STATUS LIKE 'TESTP_bug11763507';
--replace_column 5 # 6 #
SHOW PROCEDURE STATUS WHERE NAME='TESTP_bug11763507';
SHOW CREATE PROCEDURE testp_bug11763507;
SHOW CREATE PROCEDURE TESTP_bug11763507;
SHOW PROCEDURE CODE testp_bug11763507;
SHOW PROCEDURE CODE TESTP_bug11763507;
# EVENTS
--replace_column 6 # 7 # 8 # 9 #
SHOW EVENTS LIKE 'teste_bug11763507';
--replace_column 6 # 7 # 8 # 9 #
SHOW EVENTS LIKE 'TESTE_bug11763507';
--replace_column 4 #
SHOW CREATE EVENT teste_bug11763507;
--replace_column 4 #
SHOW CREATE EVENT TESTE_bug11763507;
# INFORMATION SCHEMA
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'testf_bug11763507';
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'TESTF_bug11763507';
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='testf_bug11763507';
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='TESTF_bug11763507';
DROP EVENT teste_bug11763507;
DROP PROCEDURE testp_bug11763507;
DROP FUNCTION testf_bug11763507;
--echo #END OF BUG#11763507 test.
......@@ -4323,7 +4323,8 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
(sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0)
{
restore_record(table, s->default_values);
if (!wild || !wild[0] || !wild_compare(sp_name.c_ptr_safe(), wild, 0))
if (!wild || !wild[0] || !wild_case_compare(system_charset_info,
sp_name.c_ptr_safe(), wild))
{
int enum_idx= (int) proc_table->field[5]->val_int();
table->field[3]->store(sp_name.ptr(), sp_name.length(), cs);
......@@ -5325,7 +5326,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
DBUG_RETURN(1);
}
if (!(!wild || !wild[0] || !wild_compare(et.name.str, wild, 0)))
if (!(!wild || !wild[0] || !wild_case_compare(scs, et.name.str, wild)))
DBUG_RETURN(0);
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment