mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-505: feature request: add \H option for mysql client prompt
Introduce `\H` option which behaves mostly like `\h`. The only exception is when the client connects to the server hosted on localhost. In this case, the hostname will be used instead.
This commit is contained in:
committed by
Sergey Vojtovich
parent
f2afeb3826
commit
eca060775e
@@ -5112,17 +5112,29 @@ static const char *construct_prompt()
|
|||||||
processed_prompt.append("unknown");
|
processed_prompt.append("unknown");
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
|
case 'H':
|
||||||
{
|
{
|
||||||
const char *prompt;
|
const char *prompt;
|
||||||
prompt= connected ? mysql_get_host_info(&mysql) : "not_connected";
|
prompt= connected ? mysql_get_host_info(&mysql) : "not_connected";
|
||||||
if (strstr(prompt, "Localhost"))
|
if (strstr(prompt, "Localhost"))
|
||||||
processed_prompt.append("localhost");
|
{
|
||||||
else
|
if (*c == 'h')
|
||||||
{
|
processed_prompt.append("localhost");
|
||||||
const char *end=strcend(prompt,' ');
|
else
|
||||||
processed_prompt.append(prompt, (uint) (end-prompt));
|
{
|
||||||
}
|
char hostname[HOST_NAME_MAX];
|
||||||
break;
|
if (gethostname(hostname, sizeof(hostname)) == 0)
|
||||||
|
processed_prompt.append(hostname);
|
||||||
|
else
|
||||||
|
processed_prompt.append("gethostname(2) failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char *end=strcend(prompt,' ');
|
||||||
|
processed_prompt.append(prompt, (uint) (end-prompt));
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case 'p':
|
case 'p':
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user