Bug #44706 Temporary Table error being reported incorrectly
Submitted: 6 May 2009 22:38 Modified: 6 May 2009 22:43
Reporter: ryan c Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.0.45 OS:Any
Assigned to: CPU Architecture:Any
Tags: temporary table unknown database

[6 May 2009 22:38] ryan c
Description:
I ran into this weird problem on a Linux server and figured I'd report it here as it would have saved me about 12 hours of time if the error had been reported correctly.

If you try to run the following command, you will hit the following error if you do not have a /var/lib/mysql/tmp table (or whatever tmp is configured as in my.cnf).

Error

SQL query:

CREATE TEMPORARY TABLE tmp(
StudentName VARCHAR( 50 ) ,
AverageMark INT
)

MySQL said: Documentation
#1049 - Unknown database 'booksale_drupal' 

It reports the error as Unknown Database when in actuallity it SHOULD be reporting "Unable to write to %tmpdir";

How to repeat:
Simple.  Delete /var/lib/mysql/tmp   (or whatever mysql's tmp table is setup to be) and then run the following query:

CREATE TEMPORARY TABLE tmp(
StudentName VARCHAR( 50 ) ,
AverageMark INT
)

Suggested fix:
Change the verbage of the error to "Unable to write to %tmpdir" or something like that.
[6 May 2009 22:43] ryan c
Was just a coincidence, something else caused it but I dont know what it was.  Whatever it was, its fixed.