Commit 1c68b9e9 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-505 - feature request: add \H option for mysql client prompt

An addition to original patch:
- use FN_REFLEN instead of HOST_NAME_MAX (the latter can be undefined)
- avoid calling gethostname() on every prompt construction by caching it
parent eca06077
......@@ -5122,8 +5122,10 @@ static const char *construct_prompt()
processed_prompt.append("localhost");
else
{
char hostname[HOST_NAME_MAX];
if (gethostname(hostname, sizeof(hostname)) == 0)
static char hostname[FN_REFLEN];
if (hostname[0])
processed_prompt.append(hostname);
else if (gethostname(hostname, sizeof(hostname)) == 0)
processed_prompt.append(hostname);
else
processed_prompt.append("gethostname(2) failed");
......
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