summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc34
-rw-r--r--client/mysqltest.cc56
2 files changed, 51 insertions, 39 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 9c6320fe10a..bea015d721e 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -5112,17 +5112,31 @@ static const char *construct_prompt()
processed_prompt.append("unknown");
break;
case 'h':
+ case 'H':
{
- const char *prompt;
- prompt= connected ? mysql_get_host_info(&mysql) : "not_connected";
- if (strstr(prompt, "Localhost"))
- processed_prompt.append("localhost");
- else
- {
- const char *end=strcend(prompt,' ');
- processed_prompt.append(prompt, (uint) (end-prompt));
- }
- break;
+ const char *prompt;
+ prompt= connected ? mysql_get_host_info(&mysql) : "not_connected";
+ 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));
+ }
+ break;
}
case 'p':
{
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index f09ad3107cc..afb746cd62f 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -6571,37 +6571,35 @@ int read_line(char *buf, int size)
if (!skip_char)
{
- /* Could be a multibyte character */
- /* This code is based on the code in "sql_load.cc" */
-#ifdef USE_MB
- int charlen = my_mbcharlen(charset_info, (unsigned char) c);
- /* We give up if multibyte character is started but not */
- /* completed before we pass buf_end */
- if ((charlen > 1) && (p + charlen) <= buf_end)
+ *p++= c;
+ if (use_mb(charset_info))
{
- int i;
- char* mb_start = p;
-
- *p++ = c;
-
- for (i= 1; i < charlen; i++)
- {
- c= my_getc(cur_file->file);
- if (feof(cur_file->file))
- goto found_eof;
- *p++ = c;
- }
- if (! my_ismbchar(charset_info, mb_start, p))
- {
- /* It was not a multiline char, push back the characters */
- /* We leave first 'c', i.e. pretend it was a normal char */
- while (p-1 > mb_start)
- my_ungetc(*--p);
- }
+ const char *mb_start= p - 1;
+ /* Could be a multibyte character */
+ /* See a similar code in "sql_load.cc" */
+ for ( ; p < buf_end; )
+ {
+ int charlen= my_charlen(charset_info, mb_start, p);
+ if (charlen > 0)
+ break; /* Full character */
+ if (MY_CS_IS_TOOSMALL(charlen))
+ {
+ /* We give up if multibyte character is started but not */
+ /* completed before we pass buf_end */
+ c= my_getc(cur_file->file);
+ if (feof(cur_file->file))
+ goto found_eof;
+ *p++ = c;
+ continue;
+ }
+ DBUG_ASSERT(charlen == MY_CS_ILSEQ);
+ /* It was not a multiline char, push back the characters */
+ /* We leave first 'c', i.e. pretend it was a normal char */
+ while (p - 1 > mb_start)
+ my_ungetc(*--p);
+ break;
+ }
}
- else
-#endif
- *p++= c;
}
}
die("The input buffer is too small for this query.x\n" \