Bug #10660 syntax error in prepared statement (SHOW)
Submitted: 16 May 2005 9:35 Modified: 17 May 2005 7:41
Reporter: Georg Richter Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1, 5.0 OS:Any (all)
Assigned to: CPU Architecture:Any

[16 May 2005 9:35] Georg Richter
Description:
When using a placeholder (?) in a prepared statement (which uses SHOW command) parser returns a syntax error.

If placeholders aren't supported, errormessage should be changed.

How to repeat:
mysql> prepare s1 from "SHOW DATABASES LIKE 'foo'";
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> prepare s2 from "SHOW DATABASES LIKE ?";
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 '?' at line 1
[17 May 2005 7:41] Sergei Golubchik
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

error message is correct - it's a syntax error. Just as

mysql> show databases like concat('m', '%');
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 'concat('m', '%')' at line 1

In short - no expression is allowed in SHOW DATABASES, use SELECT FROM INFORMATION_SCHEMA.SCHEMATA