Bug #16803 "ln -s /dev/null .mysql_history" doesn't work!
Submitted: 26 Jan 2006 13:02 Modified: 22 May 2006 1:37
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.19-BK, 5.0.18 OS:Linux (Linux, Mac OS X 10.4.3)
Assigned to: Magnus Blåudd

[26 Jan 2006 13:02] [ name withheld ]
Description:
BUG with MySQL 5.0.18 on OS X 10.4.3:

As ROOT:

[~]> cd **USER**
[~]> ln -s /dev/null .mysql_history

As **USER** (no root user!):

[~]> mysql -u root -p

do some MySQL thinks...

.mysql_history symbolic link is DELETED, and a "normal" .mysql_history file appear...

How to repeat:
As ROOT:

[~]> cd **USER**
[~]> ln -s /dev/null .mysql_history

As **USER** (no root user!):

[~]> mysql -u root -p

do some MySQL thinks...
[31 Jan 2006 8:29] Valerii Kravchuk
Thank you for a bug report. Verified just as described with latest 5.0.19-BK build on Linux:

openxs@suse:~> ls -la .mysql_history
-rw-------  1 openxs users 14663 2006-01-28 11:44 .mysql_history
openxs@suse:~> mv .mysql_history mysql_history.old
openxs@suse:~> ln -s /dev/null .mysql_history
openxs@suse:~> ls -la .mysql_history
lrwxrwxrwx  1 openxs users 9 2006-01-29 00:43 .mysql_history -> /dev/null
openxs@suse:~> cd dbs/5.0/
openxs@suse:~/dbs/5.0> bin/mysqld_safe &
[1] 6017
openxs@suse:~/dbs/5.0> WARNING: Found /home/openxs/dbs/5.0/var/my.cnf
Datadir is deprecated place for my.cnf, please move it to /home/openxs/dbs/5.0

Starting mysqld daemon with databases from /home/openxs/dbs/5.0/var

openxs@suse:~/dbs/5.0> bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.0.19

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.0.19    |
+-----------+
1 row in set (0.00 sec)

mysql> select version(); -- I pressed arrow up to get this, so history still here 
+-----------+
| version() |
+-----------+
| 5.0.19    |
+-----------+
1 row in set (0.00 sec)

mysql> exit
Bye
openxs@suse:~/dbs/5.0> ls -la ~/.mysql_history
-rw-------  1 openxs users 18 2006-01-29 00:43 /home/openxs/.mysql_history
openxs@suse:~/dbs/5.0> cat ~/.mysql_history
select version();

So, it is either a bug, or our manual (http://dev.mysql.com/doc/refman/5.0/en/mysql-command-options.html) should be changed, because currently it is cl;early written:

"If you do not want to maintain a history file, first remove .mysql_history if it exists, and then use either of the following techniques:

- Set the MYSQL_HISTFILE variable to /dev/null. To cause this setting to take effect each time you log in, put the setting in one of your shell's startup files.
- Create .mysql_history as a symbolic link to /dev/null:

shell> ln -s /dev/null $HOME/.mysql_history

You need do this only once."

This was proved to be wrong by the test above.
[31 Jan 2006 10:00] Domas Mituzas
the culprit (in client.cc):
    if (!write_history(histfile_tmp))
      my_rename(histfile_tmp, histfile, MYF(MY_WME));

as new file is created and then rename()d, old symlinks are lost. Either it needs additional checks or using symlink for this should be discouraged.
[13 Feb 2006 13:52] 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/2516
[9 May 2006 9:02] 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/6137
[12 May 2006 15:15] Magnus Blåudd
Pushed to 5.0.22
[19 May 2006 11:16] Magnus Blåudd
Pushed to 5.1.11
[22 May 2006 1:37] Paul Dubois
Noted in 5.0.22, 5.1.11 changelogs.

Symlinking <filename>.mysql_history</filename> to
<filename>/dev/null</filename> to suppress statement history
saving by <command>mysql</command> did not work.
(<command>mysql</command> deleted the symlink and recreated
<filename>.mysql_history</filename> as a regular file, and
then wrote history to it.)