diff options
author | unknown <lenz@mysql.com> | 2005-08-12 15:55:26 +0200 |
---|---|---|
committer | unknown <lenz@mysql.com> | 2005-08-12 15:55:26 +0200 |
commit | c9415c77b5ce586b4134b91a92447fe175c4e7b2 (patch) | |
tree | b2417662a082c65775f689dec544321c5a1aaeb8 /sql | |
parent | 3f27ee6d21ffcd1a8b4627e10b824f151a2bb187 (diff) | |
parent | 8ad10851231a59f9b25b754754af6f609555b826 (diff) | |
download | mariadb-git-c9415c77b5ce586b4134b91a92447fe175c4e7b2.tar.gz |
Merge lgrimmer@bk-internal:/home/bk/mysql-5.0
into mysql.com:/space/my/mysql-5.0
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_innodb.cc | 65 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 2 |
2 files changed, 45 insertions, 22 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 02a1ac8e6f6..2a12b372c56 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -554,19 +554,20 @@ innobase_mysql_end_print_arbitrary_thd(void) } /***************************************************************** -Prints info of a THD object (== user session thread) to the -standard output. NOTE that /mysql/innobase/trx/trx0trx.c must contain -the prototype for this function! */ +Prints info of a THD object (== user session thread) to the given file. +NOTE that /mysql/innobase/trx/trx0trx.c must contain the prototype for +this function! */ extern "C" void innobase_mysql_print_thd( /*=====================*/ - FILE* f, /* in: output stream */ - void* input_thd)/* in: pointer to a MySQL THD object */ + FILE* f, /* in: output stream */ + void* input_thd, /* in: pointer to a MySQL THD object */ + uint max_query_len) /* in: max query length to print, or 0 to + use the default max length */ { const THD* thd; const char* s; - char buf[301]; thd = (const THD*) input_thd; @@ -593,25 +594,47 @@ innobase_mysql_print_thd( } if ((s = thd->query)) { - /* determine the length of the query string */ - uint32 i, len; + /* 3100 is chosen because currently 3000 is the maximum + max_query_len we ever give this. */ + char buf[3100]; + uint len; + + /* If buf is too small, we dynamically allocate storage + in this. */ + char* dyn_str = NULL; + + /* Points to buf or dyn_str. */ + char* str = buf; - len = thd->query_length; - - if (len > 300) { - len = 300; /* ADDITIONAL SAFETY: print at most - 300 chars to reduce the probability of - a seg fault if there is a race in - thd->query_length in MySQL; after - May 14, 2004 probably no race any more, - but better be safe */ + if (max_query_len == 0) + { + /* ADDITIONAL SAFETY: the default is to print at + most 300 chars to reduce the probability of a + seg fault if there is a race in + thd->query_length in MySQL; after May 14, 2004 + probably no race any more, but better be + safe */ + max_query_len = 300; } + + len = min(thd->query_length, max_query_len); - /* Use strmake to reduce the timeframe - for a race, compared to fwrite() */ - i= (uint) (strmake(buf, s, len) - buf); + if (len > (sizeof(buf) - 1)) + { + dyn_str = my_malloc(len + 1, MYF(0)); + str = dyn_str; + } + + /* Use strmake to reduce the timeframe for a race, + compared to fwrite() */ + len = (uint) (strmake(str, s, len) - str); putc('\n', f); - fwrite(buf, 1, i, f); + fwrite(str, 1, len, f); + + if (dyn_str) + { + my_free(dyn_str, MYF(0)); + } } putc('\n', f); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 11c763ee173..094a0c56319 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1570,7 +1570,7 @@ Item *Item_func_sysconst::safe_charset_converter(CHARSET_INFO *tocs) return NULL; } conv->str_value.copy(); - conv->str_value.shrink_to_length(); + conv->str_value.mark_as_const(); return conv; } |