Bug #15904 --tmpdir requires trailing slash '/'
Submitted: 21 Dec 2005 9:57 Modified: 2 Feb 2006 17:20
Reporter: Kristian Nielsen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:Latest 5.1 bitkeeper OS:Linux (Linux/x86)
Assigned to: Magnus Blåudd CPU Architecture:Any

[21 Dec 2005 9:57] Kristian Nielsen
Description:
The --tmpdir option changed behaviour in 5.1.4 (and possibly in 5.1.3, haven't checked).

I *think* the change happened in or shortly after the push of the TDC changesets, not 100% sure though. The new behaviour is not present in 5.0.

Now, the --tmpdir option requires a trailing slash '/' to work the way I would expect it to:

 * --tmpdir=/tmp/x/ -> temporary tables created inside directory /tmp/x/.
 * --tmpdir=/tmp/x  -> temporary tables created in /tmp, with names prefixed with x (eg. /tmp/x#sql4eb3_1_0.frm).

If this is the expected behaviour, it should be clearly documented in the description of the --tmpdir command line option.

How to repeat:
Here is a simple way to start the server with --tmpdir:

    cd mysql-test
    ./mysql-test-run.pl --start-and-exit --tmpdir=/tmp/x alias
    ../client/mysql --socket=/tmp/x/master.sock -uroot
    use test
    create temporary table kntest (a varchar(100));
    # Don't exit the mysql client, as that will delete the temporary table

Now the directory /tmp will contain the temporary table files named /tmp/x#...
[12 Jan 2006 9:40] Magnus Blåudd
Can't repeat this anymore.

[msvensson@neptunus mysql-test]$ ./mysql-test-run.pl --start-and-exit --tmpdir=/tmp/x

[msvensson@neptunus ~]$ ls /tmp/x
master.sock

[msvensson@neptunus mysql-test]$ ../client/mysql --socket=/tmp/x/master.sock -uroot
mysql> use test
mysql> create temporary table kntest (a varchar(100));

[msvensson@neptunus ~]$ ls /tmp/x
@0023sql4910_1_0.frm  @0023sql4910_1_0.MYD  @0023sql4910_1_0.MYI  master.sock

Same result with heap and innodb tables.
[12 Jan 2006 13:10] Kristian Nielsen
Yes, I verified that the bug is indeed present in 5.1.3 and 5.1.4 (as downloaded from dev.mysql.com), but gone in 5.1.5.
[13 Jan 2006 0:09] Mike Hillyer
No changelog entry without a specific version and changeset, closing.
[23 Jan 2006 12:28] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/1492
[27 Jan 2006 7:11] Alexander Barkov
The patch looks ok to push for me.
[30 Jan 2006 14:21] Magnus Blåudd
Pushed to 5.1.6 a fix to make "CREATE TEMPORARY TABLE LIKE" put the temp table in the same place as "CREATE TEMPORARY TABLE".
[2 Feb 2006 17:20] Mike Hillyer
Documented in 5.1.6 changelog:

      <listitem>
        <para>
          Specifying a value for <literal>--tmptable</literal> without a
          trailing slash had unpredictable results.  (Bug #15904)
        </para>
      </listitem>