List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:August 18 2010 9:01am
Subject:bzr commit into mysql-next-mr-bugfixing branch (jorgen.loland:3220) Bug#30597
View as plain text  
#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
      
      Previously, EXPLAIN of a large union would truncate the 
      UNION RESULT row at the end of the list like this if the 
      string got too large:
      
      <union1,2,3,4,...>
      
      With this patch, truncation happens in the middle of the string
      like this:
      
      <union1,2,3,...,9>
      
      This makes it easier to understand the boundaries of the UNION.
     @ mysql-test/r/explain.result
        Added test for BUG#30597
     @ mysql-test/t/explain.test
        Added test for BUG#30597
     @ sql/sql_lex.h
        Add inline function st_select_lex::last_select()
     @ sql/sql_select.cc
        Truncate UNION RESULT row of large UNIONs in the middle of the string instead of in the end

    modified:
      mysql-test/r/explain.result
      mysql-test/t/explain.test
      sql/sql_lex.h
      sql/sql_select.cc
=== modified file 'mysql-test/r/explain.result'
--- a/mysql-test/r/explain.result	2010-08-05 14:09:06 +0000
+++ b/mysql-test/r/explain.result	2010-08-18 09:01:38 +0000
@@ -283,4 +283,95 @@ explain extended select 1 from `t1`, `t1
 where `t1`.`a`  > all ( (select `a` from `t1` ) union (select `a`) );
 ERROR 23000: Column 'a' in field list is ambiguous
 drop table t1;
+# 
+# BUG#30597: Change EXPLAIN output to include extrema of 
+#            UNION components
+# 
+EXPLAIN
+SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+2	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+3	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+4	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+5	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+6	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+7	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+9	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+10	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+11	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+12	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+13	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+14	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+15	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+16	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+17	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+18	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+19	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+20	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+21	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+22	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+23	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+24	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+25	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+26	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+27	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+28	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+29	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+30	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+31	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+32	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+33	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+34	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+35	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+36	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+37	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+38	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+39	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+40	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+41	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+42	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+43	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+44	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+45	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+46	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+47	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+48	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+49	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+50	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+51	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+52	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+53	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+54	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+55	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+56	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+57	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+58	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+59	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+60	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+61	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+62	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+63	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+64	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+65	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+NULL	UNION RESULT	<union1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,...,65>	ALL	NULL	NULL	NULL	NULL	NULL	
+# End BUG#30597
 End of 6.0 tests.

=== modified file 'mysql-test/t/explain.test'
--- a/mysql-test/t/explain.test	2010-08-05 14:09:06 +0000
+++ b/mysql-test/t/explain.test	2010-08-18 09:01:38 +0000
@@ -262,4 +262,31 @@ explain extended select 1 from `t1`, `t1
 where `t1`.`a`  > all ( (select `a` from `t1` ) union (select `a`) );
 drop table t1;
 
+--echo # 
+--echo # BUG#30597: Change EXPLAIN output to include extrema of 
+--echo #            UNION components
+--echo # 
+
+EXPLAIN
+ SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
+ ;
+
+--echo # End BUG#30597
+
 --echo End of 6.0 tests.

=== 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() { 
+    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;
+
       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);
         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 */


Attachment: [text/bzr-bundle] bzr/jorgen.loland@sun.com-20100818090138-8v8f6870s5jmgh96.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (jorgen.loland:3220) Bug#30597Jorgen Loland18 Aug
  • Re: bzr commit into mysql-next-mr-bugfixing branch (jorgen.loland:3220)Bug#30597Guilhem Bichot25 Aug
    • Re: bzr commit into mysql-next-mr-bugfixing branch (jorgen.loland:3220)Bug#30597Roy Lyseng26 Aug
    • Re: bzr commit into mysql-next-mr-bugfixing branch (jorgen.loland:3220)Bug#30597Jorgen Loland26 Aug
      • Re: bzr commit into mysql-next-mr-bugfixing branch (jorgen.loland:3220)Bug#30597Guilhem Bichot26 Aug