diff options
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r-- | sql/ha_innodb.cc | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 97dc26df184..eaf09325124 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -265,51 +265,60 @@ the prototype for this function! */ void innobase_mysql_print_thd( /*=====================*/ - char* buf, /* in/out: buffer where to print, must be at least - 300 bytes */ - void* input_thd)/* in: pointer to a MySQL THD object */ + char* buf, /* in/out: buffer where to print, must be at least + 400 bytes */ + void* input_thd)/* in: pointer to a MySQL THD object */ { - THD* thd; + THD* thd; + char* old_buf = buf; - thd = (THD*) input_thd; + thd = (THD*) input_thd; - /* We can't use value of sprintf() as this is not portable */ - buf+= my_sprintf(buf, + /* We cannot use the return value of normal sprintf() as this is + not portable to some old non-Posix Unixes, e.g., some old SCO + Unixes */ + + buf += my_sprintf(buf, (buf, "MySQL thread id %lu, query id %lu", thd->thread_id, thd->query_id)); - if (thd->host) - { - *buf++=' '; - buf=strnmov(buf, thd->host, 30); + if (thd->host) { + *buf = ' '; + buf++; + buf = strnmov(buf, thd->host, 30); } - if (thd->ip) - { - *buf++=' '; - buf=strnmov(buf, thd->ip, 20); + if (thd->ip) { + *buf = ' '; + buf++; + buf=strnmov(buf, thd->ip, 20); } - if (thd->user) - { - *buf++=' '; - buf=strnmov(buf, thd->user, 20); + if (thd->user) { + *buf = ' '; + buf++; + buf=strnmov(buf, thd->user, 20); } - if (thd->proc_info) - { - *buf++=' '; - buf=strnmov(buf, thd->proc_info, 50); + if (thd->proc_info) { + *buf = ' '; + buf++; + buf=strnmov(buf, thd->proc_info, 50); } - if (thd->query) - { - *buf++=' '; - buf=strnmov(buf, thd->query, 150); + if (thd->query) { + *buf = '\n'; + buf++; + buf=strnmov(buf, thd->query, 150); } - buf[0]='\n'; - buf[1]=0; - ut_a(strlen(buf) < 400); + buf[0] = '\n'; + buf[1] = '\0'; /* Note that we must put a null character here to end + the printed string */ + + /* We test the printed length did not overrun the buffer length of + 400 bytes */ + + ut_a(strlen(old_buf) < 400); } } |