From 7f8d57ef6aa7a06753cb06e6e93613b69f6844e5 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Aug 2002 08:29:15 +0300 Subject: ha_innobase.cc: Cleanup of latest rewrite of innobase_mysql_print_thd; from now on changing this code is forbidden unless a written permission is received from Heikki 3 days in advance sql/ha_innobase.cc: Cleanup of latest rewrite of innobase_mysql_print_thd; from now on changing this code is forbidden unless a written permission is received from Heikki 3 days in advance --- sql/ha_innobase.cc | 72 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 31 deletions(-) (limited to 'sql') diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 723100da1c4..69d539fc061 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -253,57 +253,66 @@ convert_error_code_to_mysql( extern "C" { /***************************************************************** Prints info of a THD object (== user session thread) to the -standard output. NOTE that mysql/innobase/trx/trx0trx.c must contain +standard output. NOTE that /mysql/innobase/trx/trx0trx.c must contain the prototype for this function! */ void innobase_mysql_print_thd( /*=====================*/ - char* buf, /* in/out: buffer where to print, must be at least + char* buf, /* in/out: buffer where to print, must be at least 400 bytes */ - void* input_thd)/* in: pointer to a MySQL THD object */ + void* input_thd)/* in: pointer to a MySQL THD object */ { - THD* thd; + THD* thd; + char* old_buf = buf; thd = (THD*) input_thd; - /* We can't use value of sprintf() as this is not portable */ - buf+= my_sprintf(buf, - (buf, "MySQL thread id %lu", - thd->thread_id)); - if (thd->host) - { - *buf++=' '; - buf=strnmov(buf, thd->host, 30); + /* 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++; + 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++='\n'; - 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); } } @@ -2470,6 +2479,7 @@ ha_innobase::rnd_pos( Stores a reference to the current row to 'ref' field of the handle. Note that in the case where we have generated the clustered index for the table, the function parameter is illogical: we MUST ASSUME that 'record' +is the current 'position' of the handle, because if row ref is actually the row id internally generated in InnoDB, then 'record' does not contain it. We just guess that the row id must be for the record where the handle was positioned the last time. */ -- cgit v1.2.1