Skip to content

Commit ed43ceb

Browse files
author
thek@adventure.(none)
committed
Bug#27415 Text Variables in stored procedures
- Problem was reported as a SP variable using itself as right value inside SUBSTR caused corruption of data. - This bug could not be verified in either 5.0bk or 5.1bk - Added test case to prevent future regressions.
1 parent 35616ba commit ed43ceb

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

mysql-test/r/sp-vars.result

+41
Original file line numberDiff line numberDiff line change
@@ -1161,3 +1161,44 @@ CALL p1();
11611161
v_text
11621162
abc|def
11631163
DROP PROCEDURE p1;
1164+
DROP PROCEDURE IF EXISTS bug27415_text_test|
1165+
DROP PROCEDURE IF EXISTS bug27415_text_test2|
1166+
CREATE PROCEDURE bug27415_text_test(entity_id_str_in text)
1167+
BEGIN
1168+
DECLARE str_remainder text;
1169+
SET str_remainder = entity_id_str_in;
1170+
select 'before substr', str_remainder;
1171+
SET str_remainder = SUBSTRING(str_remainder, 3);
1172+
select 'after substr', str_remainder;
1173+
END|
1174+
CREATE PROCEDURE bug27415_text_test2(entity_id_str_in text)
1175+
BEGIN
1176+
DECLARE str_remainder text;
1177+
DECLARE str_remainder2 text;
1178+
SET str_remainder2 = entity_id_str_in;
1179+
select 'before substr', str_remainder2;
1180+
SET str_remainder = SUBSTRING(str_remainder2, 3);
1181+
select 'after substr', str_remainder;
1182+
END|
1183+
CALL bug27415_text_test('a,b,c')|
1184+
before substr str_remainder
1185+
before substr a,b,c
1186+
after substr str_remainder
1187+
after substr b,c
1188+
CALL bug27415_text_test('a,b,c')|
1189+
before substr str_remainder
1190+
before substr a,b,c
1191+
after substr str_remainder
1192+
after substr b,c
1193+
CALL bug27415_text_test2('a,b,c')|
1194+
before substr str_remainder2
1195+
before substr a,b,c
1196+
after substr str_remainder
1197+
after substr b,c
1198+
CALL bug27415_text_test('a,b,c')|
1199+
before substr str_remainder
1200+
before substr a,b,c
1201+
after substr str_remainder
1202+
after substr b,c
1203+
DROP PROCEDURE bug27415_text_test|
1204+
DROP PROCEDURE bug27415_text_test2|

mysql-test/t/sp-vars.test

+44
Original file line numberDiff line numberDiff line change
@@ -1367,4 +1367,48 @@ CALL p1();
13671367

13681368
DROP PROCEDURE p1;
13691369

1370+
#
1371+
# Bug #27415 Text Variables in stored procedures
1372+
# If the SP varible was also referenced on the right side
1373+
# the result was corrupted.
1374+
#
1375+
DELIMITER |;
1376+
1377+
--disable_warnings
1378+
DROP PROCEDURE IF EXISTS bug27415_text_test|
1379+
DROP PROCEDURE IF EXISTS bug27415_text_test2|
1380+
--enable_warnings
1381+
1382+
CREATE PROCEDURE bug27415_text_test(entity_id_str_in text)
1383+
BEGIN
1384+
DECLARE str_remainder text;
1385+
1386+
SET str_remainder = entity_id_str_in;
1387+
1388+
select 'before substr', str_remainder;
1389+
SET str_remainder = SUBSTRING(str_remainder, 3);
1390+
select 'after substr', str_remainder;
1391+
END|
1392+
1393+
CREATE PROCEDURE bug27415_text_test2(entity_id_str_in text)
1394+
BEGIN
1395+
DECLARE str_remainder text;
1396+
DECLARE str_remainder2 text;
1397+
1398+
SET str_remainder2 = entity_id_str_in;
1399+
select 'before substr', str_remainder2;
1400+
SET str_remainder = SUBSTRING(str_remainder2, 3);
1401+
select 'after substr', str_remainder;
1402+
END|
1403+
1404+
CALL bug27415_text_test('a,b,c')|
1405+
CALL bug27415_text_test('a,b,c')|
1406+
CALL bug27415_text_test2('a,b,c')|
1407+
CALL bug27415_text_test('a,b,c')|
1408+
1409+
DROP PROCEDURE bug27415_text_test|
1410+
DROP PROCEDURE bug27415_text_test2|
1411+
1412+
DELIMITER ;|
1413+
13701414
# End of 5.0 tests.

0 commit comments

Comments
 (0)