Commit f8ca355e authored by Daniel Black's avatar Daniel Black

MDEV-26548: replace .mysql_history with .mariadb_history

Fall back to using .mysql_history if .mariadb_history isn't
present and .mysql_history is present.

Also replace the use of MYSQL_HISTFILE as an environment variable
with MARIADB_HISTFILE and fall back to using MYSQL_HISTFILE if
MARIADB_HISTFILE isn't present.
parent aafe85ec
...@@ -1337,26 +1337,38 @@ int main(int argc,char *argv[]) ...@@ -1337,26 +1337,38 @@ int main(int argc,char *argv[])
initialize_readline(); initialize_readline();
if (!status.batch && !quick && !opt_html && !opt_xml) if (!status.batch && !quick && !opt_html && !opt_xml)
{ {
/* read-history from file, default ~/.mysql_history*/ const char *home;
if (getenv("MYSQL_HISTFILE")) /* read-history from file, default ~/.mariadb_history*/
histfile=my_strdup(PSI_NOT_INSTRUMENTED, getenv("MYSQL_HISTFILE"),MYF(MY_WME)); if ((histfile= getenv("MARIADB_HISTFILE"))
else if (getenv("HOME")) || (histfile= getenv("MYSQL_HISTFILE")))
histfile=my_strdup(PSI_NOT_INSTRUMENTED, histfile, MYF(MY_WME));
else if ((home= getenv("HOME")))
{ {
histfile=(char*) my_malloc(PSI_NOT_INSTRUMENTED, histfile=(char*) my_malloc(PSI_NOT_INSTRUMENTED,
strlen(getenv("HOME")) + strlen("/.mysql_history")+2, MYF(MY_WME)); strlen(home) + strlen("/.mariadb_history")+2, MYF(MY_WME));
if (histfile) 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 */ sprintf(histfile,"%s/.mariadb_history", home);
my_free(histfile); if (my_access(histfile, F_OK))
histfile= 0; {
/* no .mariadb_history, look for historical name and use if present */
sprintf(histfile,"%s/.mysql_history", home);
/* and go back to original if not found */
if (my_access(histfile, F_OK))
sprintf(histfile,"%s/.mariadb_history", home);
}
char link_name[FN_REFLEN];
if (my_readlink(link_name, histfile, 0) == 0 &&
strncmp(link_name, "/dev/null", 10) == 0)
{
/* The .mariadb_history file is a symlink to /dev/null, don't use it */
my_free(histfile);
histfile= 0;
}
} }
} }
/* We used to suggest setting MYSQL_HISTFILE=/dev/null. */ /* We used to suggest setting MARIADB_HISTFILE=/dev/null. */
if (histfile && strncmp(histfile, "/dev/null", 10) == 0) if (histfile && strncmp(histfile, "/dev/null", 10) == 0)
histfile= NULL; histfile= NULL;
......
...@@ -1630,28 +1630,29 @@ SELECT ...@@ -1630,28 +1630,29 @@ SELECT
statements when using statements when using
\fB\-\-safe\-updates\fR\&. (Default value is 1,000\&.) \fB\-\-safe\-updates\fR\&. (Default value is 1,000\&.)
.RE .RE
.\" MYSQL_HISTFILE environment variable .\" MARIADB_HISTFILE environment variable
.\" environment variable: MYSQL_HISTFILE .\" environment variable: MARIADB_HISTFILE
.\" HOME environment variable .\" HOME environment variable
.\" environment variable: HOME .\" environment variable: HOME
.\" mysql history file .\" mysql history file
.\" command-line history: mysql .\" command-line history: mysql
.\" .mysql_history file .\" .mariadb_history file
.PP .PP
On Unix, the On Unix, the
\fBmysql\fR \fBmysql\fR
client writes a record of executed statements to a history file\&. By default, this file is named client writes a record of executed statements to a history file\&. By default, this file is named
\&.mysql_history \&.mariadb_history
and is created in your home directory\&. To specify a different file, set the value of the and is created in your home directory\&. For backwards compatibility \&.mysql_history will be used if present and
MYSQL_HISTFILE \&.mariadb_history is missing\&. To specify a different file, set the value of the
environment variable\&. MARIADB_HISTFILE
environment variable\&. The environment variable MYSQL_HISTFILE will be used if MARIADB_HISTFILE isn't present\&.
.PP .PP
The The
\&.mysql_history \&.mariadb_history
should be protected with a restrictive access mode because sensitive information might be written to it, such as the text of SQL statements that contain passwords\&. should be protected with a restrictive access mode because sensitive information might be written to it, such as the text of SQL statements that contain passwords\&.
.PP .PP
If you do not want to maintain a history file, first remove If you do not want to maintain a history file, first remove
\&.mysql_history \&.mariadb_history
if it exists, and then use either of the following techniques: if it exists, and then use either of the following techniques:
.sp .sp
.RS 4 .RS 4
...@@ -1663,7 +1664,7 @@ if it exists, and then use either of the following techniques: ...@@ -1663,7 +1664,7 @@ if it exists, and then use either of the following techniques:
.IP \(bu 2.3 .IP \(bu 2.3
.\} .\}
Set the Set the
MYSQL_HISTFILE MARIADB_HISTFILE
variable to 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\&. /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\&.
.RE .RE
...@@ -1677,7 +1678,7 @@ variable to ...@@ -1677,7 +1678,7 @@ variable to
.IP \(bu 2.3 .IP \(bu 2.3
.\} .\}
Create Create
\&.mysql_history \&.mariadb_history
as a symbolic link to as a symbolic link to
/dev/null: /dev/null:
.sp .sp
...@@ -1685,7 +1686,7 @@ as a symbolic link to ...@@ -1685,7 +1686,7 @@ as a symbolic link to
.RS 4 .RS 4
.\} .\}
.nf .nf
shell> \fBln \-s /dev/null $HOME/\&.mysql_history\fR shell> \fBln \-s /dev/null $HOME/\&.mariadb_history\fR
.fi .fi
.if n \{\ .if n \{\
.RE .RE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment