From 10c64545adb80ada4edaa322e9474d00281846f9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 May 2006 11:01:50 +0200 Subject: BUG#16803 "ln -s /dev/null .mysql_history" doesn't work! - Add a check to see if the .mysql_history file a symlink to /dev/null and in such case, skip reading and writing to it. client/mysql.cc: Add check to detect if the "mysql_history" file is a symlink to /dev/null. In that case, don't create histfile variable. That will make read_history and write_history to be skipped. --- client/mysql.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index 7b46aaf67ce..dcf80ff2b0b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -448,6 +448,14 @@ int main(int argc,char *argv[]) MYF(MY_WME)); if (histfile) sprintf(histfile,"%s/.mysql_history",getenv("HOME")); + char link_name[FN_REFLEN]; + if (my_readlink(link_name, histfile, 0) == 0 && + strncmp(link_name, "/dev/null", 10) == 0) + { + /* The .mysql_history file is a symlink to /dev/null, don't use it */ + my_free(histfile, MYF(MY_ALLOW_ZERO_PTR)); + histfile= 0; + } } if (histfile) { @@ -484,7 +492,7 @@ sig_handler mysql_end(int sig) { mysql_close(&mysql); #ifdef HAVE_READLINE - if (!status.batch && !quick && !opt_html && !opt_xml) + if (!status.batch && !quick && !opt_html && !opt_xml && histfile) { /* write-history */ if (verbose) -- cgit v1.2.1