mirror of
https://github.com/MariaDB/server.git
synced 2026-04-17 05:45:33 +02:00
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.
This commit is contained in:
parent
aafe85ecb1
commit
f8ca355ed8
2 changed files with 38 additions and 25 deletions
|
|
@ -1337,26 +1337,38 @@ int main(int argc,char *argv[])
|
|||
initialize_readline();
|
||||
if (!status.batch && !quick && !opt_html && !opt_xml)
|
||||
{
|
||||
/* read-history from file, default ~/.mysql_history*/
|
||||
if (getenv("MYSQL_HISTFILE"))
|
||||
histfile=my_strdup(PSI_NOT_INSTRUMENTED, getenv("MYSQL_HISTFILE"),MYF(MY_WME));
|
||||
else if (getenv("HOME"))
|
||||
const char *home;
|
||||
/* read-history from file, default ~/.mariadb_history*/
|
||||
if ((histfile= getenv("MARIADB_HISTFILE"))
|
||||
|| (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,
|
||||
strlen(getenv("HOME")) + strlen("/.mysql_history")+2, MYF(MY_WME));
|
||||
strlen(home) + strlen("/.mariadb_history")+2, 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);
|
||||
histfile= 0;
|
||||
sprintf(histfile,"%s/.mariadb_history", home);
|
||||
if (my_access(histfile, F_OK))
|
||||
{
|
||||
/* 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)
|
||||
histfile= NULL;
|
||||
|
||||
|
|
|
|||
25
man/mysql.1
25
man/mysql.1
|
|
@ -1630,28 +1630,29 @@ SELECT
|
|||
statements when using
|
||||
\fB\-\-safe\-updates\fR\&. (Default value is 1,000\&.)
|
||||
.RE
|
||||
.\" MYSQL_HISTFILE environment variable
|
||||
.\" environment variable: MYSQL_HISTFILE
|
||||
.\" MARIADB_HISTFILE environment variable
|
||||
.\" environment variable: MARIADB_HISTFILE
|
||||
.\" HOME environment variable
|
||||
.\" environment variable: HOME
|
||||
.\" mysql history file
|
||||
.\" command-line history: mysql
|
||||
.\" .mysql_history file
|
||||
.\" .mariadb_history file
|
||||
.PP
|
||||
On Unix, the
|
||||
\fBmysql\fR
|
||||
client writes a record of executed statements to a history file\&. By default, this file is named
|
||||
\&.mysql_history
|
||||
and is created in your home directory\&. To specify a different file, set the value of the
|
||||
MYSQL_HISTFILE
|
||||
environment variable\&.
|
||||
\&.mariadb_history
|
||||
and is created in your home directory\&. For backwards compatibility \&.mysql_history will be used if present and
|
||||
\&.mariadb_history is missing\&. To specify a different file, set the value of the
|
||||
MARIADB_HISTFILE
|
||||
environment variable\&. The environment variable MYSQL_HISTFILE will be used if MARIADB_HISTFILE isn't present\&.
|
||||
.PP
|
||||
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\&.
|
||||
.PP
|
||||
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:
|
||||
.sp
|
||||
.RS 4
|
||||
|
|
@ -1663,7 +1664,7 @@ if it exists, and then use either of the following techniques:
|
|||
.IP \(bu 2.3
|
||||
.\}
|
||||
Set the
|
||||
MYSQL_HISTFILE
|
||||
MARIADB_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\&.
|
||||
.RE
|
||||
|
|
@ -1677,7 +1678,7 @@ variable to
|
|||
.IP \(bu 2.3
|
||||
.\}
|
||||
Create
|
||||
\&.mysql_history
|
||||
\&.mariadb_history
|
||||
as a symbolic link to
|
||||
/dev/null:
|
||||
.sp
|
||||
|
|
@ -1685,7 +1686,7 @@ as a symbolic link to
|
|||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
shell> \fBln \-s /dev/null $HOME/\&.mysql_history\fR
|
||||
shell> \fBln \-s /dev/null $HOME/\&.mariadb_history\fR
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue