Hello,
Jorgen Loland a écrit, Le 18.08.2010 11:01:
> #At file:///export/home/jl208045/mysql/mysql-next-mr-bugfixing-30597/ based on
> revid:joerg@stripped
>
> 3220 Jorgen Loland 2010-08-18
> Bug#30597: Change EXPLAIN output to include extrema of
> UNION components
>
> === modified file 'sql/sql_lex.h'
> --- a/sql/sql_lex.h 2010-08-16 18:21:24 +0000
> +++ b/sql/sql_lex.h 2010-08-18 09:01:38 +0000
> @@ -712,6 +712,13 @@ public:
> }
> st_select_lex* outer_select();
> st_select_lex* next_select() { return (st_select_lex*) next; }
> +
> + inline st_select_lex* last_select() {
you can declare this function "const", it doesn't change data.
> + st_select_lex* last= this;
> + for (; last->next_select(); last= last->next_select());
> + return last;
> + }
> +
> st_select_lex* next_select_in_list()
> {
> return (st_select_lex*) link_next;
>
> === modified file 'sql/sql_select.cc'
> --- a/sql/sql_select.cc 2010-08-12 13:55:41 +0000
> +++ b/sql/sql_select.cc 2010-08-18 09:01:38 +0000
> @@ -22048,10 +22048,21 @@ void select_describe(JOIN *join, bool ne
> cs));
> /* table */
> {
> + SELECT_LEX *last_select= join->unit->first_select()->last_select();
> + // # characters needed to print select_number of last select
> + int last_length= log10f((float)last_select->select_number)+1;
log10f is not yet used in MySQL ("grep" says).
But log10 is, somewhere in item_func.cc.
You can use log10f and time will tell whether it's available on all
platforms where we build (my 'man' page says that log10f is a C99
requirement), or use log10 (which would work for the job, as it takes a
double argument).
> SELECT_LEX *sl= join->unit->first_select();
> uint len= 6, lastop= 0;
> memcpy(table_name_buffer, STRING_WITH_LEN("<union"));
> - for (; sl && len + lastop + 5 < NAME_LEN; sl=
> sl->next_select())
> + /*
> + - len + lastop: current position in table_name_buffer
> + - 6 + last_length: the number of characters needed to print
> + '...,'<last_select->select_number>'>\0'
> + */
> + for (;
> + sl && len + lastop + 6 + last_length < NAME_LEN;
> + sl= sl->next_select())
> {
> len+= lastop;
> lastop= my_snprintf(table_name_buffer + len, NAME_LEN - len,
> @@ -22059,14 +22070,13 @@ void select_describe(JOIN *join, bool ne
> }
> if (sl || len + lastop >= NAME_LEN)
> {
> - memcpy(table_name_buffer + len, STRING_WITH_LEN("...>") + 1);
> + memcpy(table_name_buffer + len, STRING_WITH_LEN("...,") + 1);
in STRING_WITH_LEN we have sizeof (=5) - 1 =4, and it's enough to copy
the 4 characters without the end zero (as we add more chars with
my_snprintf below).
So "+ 1" is probably not needed. But you can keep it.
> len+= 4;
> + lastop= my_snprintf(table_name_buffer + len, NAME_LEN - len,
> + "%u,", last_select->select_number);
> }
> - else
> - {
> - len+= lastop;
> - table_name_buffer[len - 1]= '>'; // change ',' to '>'
> - }
> + len+= lastop;
> + table_name_buffer[len - 1]= '>'; // change ',' to '>'
> item_list.push_back(new Item_string(table_name_buffer, len, cs));
> }
> /* partitions */
Ok to push.
--
Mr. Guilhem Bichot <guilhem.bichot@stripped>
Oracle / MySQL / Optimizer team, Lead Software Engineer
Bordeaux, France
www.oracle.com / www.mysql.com