List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:March 8 2007 9:18pm
Subject:bk commit into 5.0 tree (cmiller:1.2421) BUG#26938
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of cmiller. When cmiller does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-03-08 16:18:02-05:00, cmiller@stripped +5 -0
  Bug#26938: SHOW PROFILE hangs if @@profiling not set to 1
  
  Our protocol expects that a query contains some data, either column
  metainfo or an error.  If we return control to the server after 
  sending nothing, then the client gets out-of-synch and hangs while
  expecting more data.  
  
  Now, regardless of whether we have any entries in the query history
  or not, we send the fields' metainfo.  If there is no history item 
  and therefore no rows to send, use a simple function that constructs
  and sends the fields and then returns after sending no rows.

  BitKeeper/etc/collapsed@stripped, 2007-03-08 14:50:24-05:00, cmiller@stripped +1 -0

  mysql-test/r/information_schema.result@stripped, 2007-03-08 16:18:01-05:00, cmiller@stripped +1 -1
    Older test update.

  mysql-test/r/profiling.result@stripped, 2007-03-08 16:18:01-05:00, cmiller@stripped +4 -0
    Results of new test lines.

  mysql-test/t/profiling.test@stripped, 2007-03-08 16:18:01-05:00, cmiller@stripped +4 -0
    Test that we can at least ask for profiles before the profile history
    has any entries.

  sql/sql_profile.cc@stripped, 2007-03-08 16:18:01-05:00, cmiller@stripped +44 -25
    Pull the query profile field-creation out into a seperate function
    and write a function that sends no rows at all and doesn't require 
    an instance of QUERY_PROFILE to send the fields.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	cmiller
# Host:	zippy.cornsilk.net
# Root:	/home/cmiller/work/mysql/mysql-5.0-comeng

--- 1.1/mysql-test/r/profiling.result	2007-03-08 16:18:06 -05:00
+++ 1.2/mysql-test/r/profiling.result	2007-03-08 16:18:06 -05:00
@@ -5,6 +5,10 @@ profiling_history_size	15
 select @@profiling;
 @@profiling
 0
+show profiles;
+Query_ID	Duration	Query
+show profile;
+Status	Duration
 set global profiling = ON;
 ERROR HY000: Variable 'profiling' is a SESSION variable and can't be used with SET GLOBAL
 set global profiling_history_size=100;

--- 1.1/mysql-test/t/profiling.test	2007-03-08 16:18:06 -05:00
+++ 1.2/mysql-test/t/profiling.test	2007-03-08 16:18:06 -05:00
@@ -2,6 +2,10 @@
 show session variables like 'profil%';
 select @@profiling;
 
+# off has no data
+show profiles;
+show profile;
+
 # setting global variable is an error
 --error ER_LOCAL_VARIABLE
 set global profiling = ON;

--- 1.4/sql/sql_profile.cc	2007-03-08 16:18:06 -05:00
+++ 1.5/sql/sql_profile.cc	2007-03-08 16:18:06 -05:00
@@ -261,21 +261,19 @@ void QUERY_PROFILE::reset()
   DBUG_VOID_RETURN;
 }
 
-bool QUERY_PROFILE::show(uint options)
-{  
-  THD *thd= profiling->thd;
-  List<Item> field_list;
-  DBUG_ENTER("QUERY_PROFILE::show");
 
-  field_list.push_back(new Item_empty_string("Status", MYSQL_ERRMSG_SIZE));
-  field_list.push_back(new Item_return_int("Duration", TIME_FLOAT_DIGITS,
+static void create_query_profile_fields(uint options, List<Item> *field_list)
+{
+
+  field_list->push_back(new Item_empty_string("Status", MYSQL_ERRMSG_SIZE));
+  field_list->push_back(new Item_return_int("Duration", TIME_FLOAT_DIGITS,
                                            MYSQL_TYPE_DOUBLE));
 
   if (options & PROFILE_CPU)
   {
-    field_list.push_back(new Item_return_int("CPU_user", TIME_FLOAT_DIGITS,
+    field_list->push_back(new Item_return_int("CPU_user", TIME_FLOAT_DIGITS,
                                              MYSQL_TYPE_DOUBLE));
-    field_list.push_back(new Item_return_int("CPU_system", TIME_FLOAT_DIGITS, 
+    field_list->push_back(new Item_return_int("CPU_system", TIME_FLOAT_DIGITS, 
                                              MYSQL_TYPE_DOUBLE));
   }
   
@@ -285,55 +283,71 @@ bool QUERY_PROFILE::show(uint options)
   
   if (options & PROFILE_CONTEXT)
   {
-    field_list.push_back(new Item_return_int("Context_voluntary", 10,
+    field_list->push_back(new Item_return_int("Context_voluntary", 10,
                                              MYSQL_TYPE_LONG));
-    field_list.push_back(new Item_return_int("Context_involuntary", 10,
+    field_list->push_back(new Item_return_int("Context_involuntary", 10,
                                              MYSQL_TYPE_LONG));
   }
 
   if (options & PROFILE_BLOCK_IO)
   {
-    field_list.push_back(new Item_return_int("Block_ops_in", 10,
+    field_list->push_back(new Item_return_int("Block_ops_in", 10,
                                              MYSQL_TYPE_LONG));
-    field_list.push_back(new Item_return_int("Block_ops_out", 10,
+    field_list->push_back(new Item_return_int("Block_ops_out", 10,
                                              MYSQL_TYPE_LONG));
   }
   
   if (options & PROFILE_IPC)
   {
-    field_list.push_back(new Item_return_int("Messages_sent", 10,
+    field_list->push_back(new Item_return_int("Messages_sent", 10,
                                              MYSQL_TYPE_LONG));
-    field_list.push_back(new Item_return_int("Messages_received", 10,
+    field_list->push_back(new Item_return_int("Messages_received", 10,
                                              MYSQL_TYPE_LONG));
   }
   
   if (options & PROFILE_PAGE_FAULTS)
   {
-    field_list.push_back(new Item_return_int("Page_faults_major", 10,
+    field_list->push_back(new Item_return_int("Page_faults_major", 10,
                                              MYSQL_TYPE_LONG));
-    field_list.push_back(new Item_return_int("Page_faults_minor", 10,
+    field_list->push_back(new Item_return_int("Page_faults_minor", 10,
                                              MYSQL_TYPE_LONG));
   }
   
   if (options & PROFILE_SWAPS)
   {
-    field_list.push_back(new Item_return_int("Swaps", 10, MYSQL_TYPE_LONG));
+    field_list->push_back(new Item_return_int("Swaps", 10, MYSQL_TYPE_LONG));
   }
   
   if (options & PROFILE_SOURCE)
   {
-    field_list.push_back(new Item_empty_string("Source_function",
+    field_list->push_back(new Item_empty_string("Source_function",
                                                MYSQL_ERRMSG_SIZE));  
-    field_list.push_back(new Item_empty_string("Source_file",
+    field_list->push_back(new Item_empty_string("Source_file",
                                                MYSQL_ERRMSG_SIZE));
-    field_list.push_back(new Item_return_int("Source_line", 10,
+    field_list->push_back(new Item_return_int("Source_line", 10,
                                              MYSQL_TYPE_LONG));
   }
   
+}
+
+static bool query_profile_empty_show(THD *thd, uint options)
+{
+  List<Item> field_list;
+  (void) create_query_profile_fields(options, &field_list);
   if (thd->protocol->send_fields(&field_list,
                                  Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-    DBUG_RETURN(TRUE);
+    return(TRUE);
+
+  send_eof(thd);
+  return FALSE;
+}
 
+bool QUERY_PROFILE::show(uint options)
+{
+  DBUG_ENTER("QUERY_PROFILE::show");
+
+  THD *thd= profiling->thd;
+  List<Item> field_list;
   Protocol *protocol= thd->protocol;
   SELECT_LEX *sel= &thd->lex->select_lex;
   SELECT_LEX_UNIT *unit= &thd->lex->unit;
@@ -344,6 +358,11 @@ bool QUERY_PROFILE::show(uint options)
   struct rusage *last_rusage= &(profile_start.rusage);
 #endif
 
+  (void) create_query_profile_fields(options, &field_list);
+  if (thd->protocol->send_fields(&field_list,
+                                 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
+    DBUG_RETURN(TRUE);
+
   List_iterator<PROFILE_ENTRY> it(entries);
   PROFILE_ENTRY *entry;
   while ((entry= it++) != NULL)
@@ -665,10 +684,10 @@ bool PROFILING::show(uint options, uint 
 bool PROFILING::show_last(uint options)
 {
   DBUG_ENTER("PROFILING::show_last");
-  if (!history.is_empty()) {
+  if (!history.is_empty()) 
     DBUG_RETURN(last->show(options));
-  }
-  DBUG_RETURN(TRUE);
+  else
+    DBUG_RETURN(query_profile_empty_show(thd, options));
 }
 
 

--- 1.26/BitKeeper/etc/collapsed	2007-03-08 16:18:06 -05:00
+++ 1.27/BitKeeper/etc/collapsed	2007-03-08 16:18:06 -05:00
@@ -57,3 +57,4 @@
 45ddaf15_Ld7IAEpUUP3FJjJ-oSEFg
 45ddc763DodLG1BqH_wRBJXMbCSB5A
 45ddc8282KnaNGuijqCTphlXV_eeog
+45f051bamtY9kA_UvekkH6eFviLyIQ

--- 1.122/mysql-test/r/information_schema.result	2007-03-08 16:18:06 -05:00
+++ 1.123/mysql-test/r/information_schema.result	2007-03-08 16:18:06 -05:00
@@ -1096,7 +1096,7 @@ table_schema='information_schema' and
 group by column_type order by num;
 column_type	group_concat(table_schema, '.', table_name)	num
 varchar(20)	information_schema.COLUMNS,information_schema.PROFILING	2
-varchar(7)	information_schema.PROFILING,information_schema.PROFILING,information_schema.PROFILING,information_schema.ROUTINES,information_schema.VIEWS	5
+varchar(7)	information_schema.ROUTINES,information_schema.VIEWS	2
 create table t1(f1 char(1) not null, f2 char(9) not null)
 default character set utf8;
 select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
Thread
bk commit into 5.0 tree (cmiller:1.2421) BUG#26938Chad MILLER8 Mar