Bug #2304 HANDLER does not retain database name with table aliases
Submitted: 7 Jan 2004 6:19 Modified: 13 Jan 2004 3:32
Reporter: Dean Ellis Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.18 OS:
Assigned to: Sergei Golubchik CPU Architecture:Any

[7 Jan 2004 6:19] Dean Ellis
Description:
Cross-database HANDLER statements do not retain the database name when resolving a table alias.  This does not appear to be documented.

How to repeat:
USE test;
CREATE TABLE hdlr ( a int primary key );
USE mysql;
HANDLER test.hdlr OPEN AS halias;
HANDLER halias READ `PRIMARY` FIRST;
HANDLER test.halias READ `PRIMARY` FIRST;
USE test;
HANDLER halias READ `PRIMARY` FIRST;
HANDLER halias CLOSE;
DROP TABLE hdlr;

Suggested fix:
Retaining the database is preferable; otherwise, document it.
[11 Jan 2004 15:21] Stephen Brownlow
Doing a "use database;" will also trigger this problem.

mysql> use CFS;
Database changed
mysql> handler XDSYN open as A3;
Query OK, 0 rows affected (0.00 sec)
mysql> use DAVG;
Database changed
mysql> handler A3 read key01 first;
ERROR 1109: Unknown table 'A3' in HANDLER
mysql> use CFS;
Database changed
mysql> handler A3 read key01 first;
<successful>

Stephen Brownlow,
Reporter of the problem.
[13 Jan 2004 3:32] Sergei Golubchik
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

fixed in 4.0.18