Bug #54447 Docs: CURRENT_DATABASE and CURRENT_SCHEMA are not valid functions
Submitted: 11 Jun 2010 23:39 Modified: 16 Jun 2010 16:50
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[11 Jun 2010 23:39] Roel Van de Paar
Description:
http://dev.mysql.com/doc/refman/5.1/en/information-schema.html

Lists: 

'... you can often select information for the default database by adding an AND TABLE_SCHEMA = CURRENT_SCHEMA() condition to the WHERE clause of a query that retrieves information from an INFORMATION_SCHEMA table.'

But:

mysql> SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME=CURRENT_SCHEMA();
ERROR 1305 (42000): FUNCTION testit1.CURRENT_SCHEMA does not exist
mysql> select version()\G
version(): 5.1.47-enterprise-gpl-advanced-log

http://dev.mysql.com/doc/refman/5.0/en/information-schema.html

Lists:
'... you can often select information for the default database by adding an AND TABLE_SCHEMA = CURRENT_DATABASE() condition to the WHERE clause of a query that retrieves information from an INFORMATION_SCHEMA table.'

But:

mysql> SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME=CURRENT_DATABASE();
ERROR 1305 (42000): FUNCTION roelt.CURRENT_DATABASE does not exist

How to repeat:
Correct function: 
http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_database

mysql> SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME=DATABASE()\G
*************************** 1. row ***************************
              CATALOG_NAME: NULL
               SCHEMA_NAME: roelt
DEFAULT_CHARACTER_SET_NAME: latin1
    DEFAULT_COLLATION_NAME: latin1_swedish_ci
                  SQL_PATH: NULL

Suggested fix:
Correct statements
[16 Jun 2010 16:50] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Corrected CURRENT_DATABASE() to DATABASE() and CURRENT_SCHEMA() to SCHEMA().