Bug #79507 String function insert is not working as doc says
Submitted: 3 Dec 2015 12:55 Modified: 3 Dec 2015 13:59
Reporter: Su Dylan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6.22, 5.5.48 OS:Any
Assigned to: CPU Architecture:Any

[3 Dec 2015 12:55] Su Dylan
Description:
Output:
=======
mysql> select insert('abc',4,3,'xyz');
+-------------------------+
| insert('abc',4,3,'xyz') |
+-------------------------+
| abcxyz                  |
+-------------------------+
1 row in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.22    |
+-----------+
1 row in set (0.00 sec)

Problem:
========
According to the documentation, it is expected to return 'abc'.

Quote:
Returns the original string if pos is not within the length of the string.

http://dev.mysql.com/doc/refman/5.6/en/string-functions.html#function_insert

How to repeat:
select insert('abc',4,3,'xyz');

Suggested fix:
"abc" is returned.
[3 Dec 2015 13:59] Umesh Shastry
Hello Su Dylan,

Thank you for the report and test case.
This issue is repeatable only on 5.5 latest build and latest 5.6/5.7 builds are not affected.

Thanks,
Umesh
[3 Dec 2015 13:59] Umesh Shastry
// 5.6.29 - not affected

[umshastr@hod03]/export/umesh/server/binaries/mysql-advanced-5.6.29: bin/mysql  -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.29-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select insert('abc',4,3,'xyz');
+-------------------------+
| insert('abc',4,3,'xyz') |
+-------------------------+
| abc                     |
+-------------------------+
1 row in set (0.00 sec)

mysql>

// 5.7.11 - not affected

[root@cluster-repo ~]# mysql -uroot -p test
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.7.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost:test>select insert('abc',4,3,'xyz');
+-------------------------+
| insert('abc',4,3,'xyz') |
+-------------------------+
| abc                     |
+-------------------------+
1 row in set (0.00 sec)

// 5.5.48 - affected

[umshastr@hod03]/export/umesh/server/binaries/mysql-5.5.48: bin/mysql  -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.48 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select insert('abc',4,3,'xyz');
+-------------------------+
| insert('abc',4,3,'xyz') |
+-------------------------+
| abcxyz                  |
+-------------------------+
1 row in set (0.00 sec)

mysql>
[3 Dec 2015 14:02] Umesh Shastry
// Typo in earlier 5.7 results, it was for 5.7.9
// 5.7.11

[umshastr@hod03]/export/umesh/server/binaries/mysql-advanced-5.7.11: bin/mysql  -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select insert('abc',4,3,'xyz');
+-------------------------+
| insert('abc',4,3,'xyz') |
+-------------------------+
| abc                     |
+-------------------------+
1 row in set (0.00 sec)