Bug #79581 Error 1064 on selects from Information Schema if routine name has '\0'
Submitted: 9 Dec 2015 21:10 Modified: 9 Dec 2015 22:28
Reporter: Sveta Smirnova (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Information schema Severity:S3 (Non-critical)
Version:5.5.46, 5.6.27, 5.7.9 OS:Any
Assigned to: CPU Architecture:Any

[9 Dec 2015 21:10] Sveta Smirnova
Description:
When db in table mysql.proc contains symbol '\0' all selects from INFORMATION_SCHEMA.PARAMETERS fail with error "query 'SELECT * From information_schema.PARAMETERS' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`test' at line 1"

How to repeat:
create procedure p1() begin end;
SELECT * From information_schema.PARAMETERS;
update mysql.proc set db='test\0' where db='test';
SELECT * From information_schema.PARAMETERS;

I don't know how such database was created in customer's environment (maybe broken dump/restore), but having such invalid entries in mysql.proc table should not affect Information Schema anyway.
[9 Dec 2015 22:28] MySQL Verification Team
Thank you for the bug report.

mysql 5.6 > update mysql.proc set db='test\0' where db='test';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.6 > SELECT * From information_schema.PARAMETERS;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`test' at line 1
mysql 5.6 > show variables like "%version%";
+-------------------------+---------------------------------------+
| Variable_name           | Value                                 |
+-------------------------+---------------------------------------+
| innodb_version          | 5.6.29                                |
| protocol_version        | 10                                    |
| slave_type_conversions  |                                       |
| version                 | 5.6.29                                |
| version_comment         | Source distribution PULL: 2015-DEC-05 |
| version_compile_machine | x86_64                                |
| version_compile_os      | Win64                                 |
+-------------------------+---------------------------------------+
7 rows in set (0.02 sec)

mysql 5.5 > update mysql.proc set db='test\0' where db='test';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.5 > SELECT * From information_schema.PARAMETERS;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
mysql 5.5 > show variables like "%version%";
+-------------------------+---------------------------------------+
| Variable_name           | Value                                 |
+-------------------------+---------------------------------------+
| innodb_version          | 5.5.48                                |
| protocol_version        | 10                                    |
| slave_type_conversions  |                                       |
| version                 | 5.5.48                                |
| version_comment         | Source distribution PULL: 2015-DEC-05 |
| version_compile_machine | AMD64                                 |
| version_compile_os      | Win64                                 |
+-------------------------+---------------------------------------+
7 rows in set (0.00 sec)

mysql 5.7 > update mysql.proc set db='test\0' where db='test';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.7 > SELECT * From information_schema.PARAMETERS;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`test' at line 1
mysql 5.7 > show variables like "%version%";
+-------------------------+---------------------------------------+
| Variable_name           | Value                                 |
+-------------------------+---------------------------------------+
| innodb_version          | 5.7.11                                |
| protocol_version        | 10                                    |
| slave_type_conversions  |                                       |
| tls_version             | 1                                     |
| version                 | 5.7.11                                |
| version_comment         | Source distribution PULL: 2015-DEC-05 |
| version_compile_machine | x86_64                                |
| version_compile_os      | Win64                                 |
+-------------------------+---------------------------------------+
8 rows in set (0.04 sec)