Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL)
-
None
Description
In MDEV-505, a prompt option \H was added. As I understand from the description, the main difference with \h is supposed to be the behavior for localhost: with \h it should remain localhost, and with \H it should become the real host name.
I don't see it happen:
MariaDB [(none)]> prompt \h >
|
PROMPT set to '\h > '
|
localhost > prompt \H >
|
PROMPT set to '\H > '
|
localhost > exit
|
Bye
|
$ hostname
|
jessie
|
And from the code I don't see how it could ever work:
if (strstr(prompt, "Localhost"))
|
{
|
if (*c == 'h')
|
processed_prompt.append("localhost");
|
else
|
{
|
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");
|
}
|
}
|
else
|
{
|
const char *end=strcend(prompt,' ');
|
processed_prompt.append(prompt, (uint) (end-prompt));
|
}
|
Note the capital L in the first line.
In the original blog post it's both:
prompt= connected ? mysql_get_host_info(&mysql) : "not_connected";
|
- if (strstr(prompt, "Localhost"))
|
- processed_prompt.append("localhost");
|
+
|
+ if (strstr(prompt, "Localhost") || strstr(prompt, "localhost"))
|
+ if ( *c == 'h' ) {
|
I don't know what Localhost part takes care of, but it's been there before, I suppose it's for a reason. Anyway, changing it back seems to make it work:
diff --git a/client/mysql.cc b/client/mysql.cc
|
index 65b7c19..e1a6011 100644
|
--- a/client/mysql.cc
|
+++ b/client/mysql.cc
|
@@ -5129,7 +5129,7 @@ static const char *construct_prompt()
|
{
|
const char *prompt;
|
prompt= connected ? mysql_get_host_info(&mysql) : "not_connected";
|
- if (strstr(prompt, "Localhost"))
|
+ if (strstr(prompt, "Localhost") || strstr(prompt, "localhost"))
|
{
|
if (*c == 'h')
|
processed_prompt.append("localhost");
|
MariaDB [(none)]> prompt \H >
|
PROMPT set to '\H > '
|
jessie > exit
|
Attachments
Issue Links
- relates to
-
MDEV-505 feature request: add \H option for mysql client prompt
- Closed