List:Commits« Previous MessageNext Message »
From:Guilhem Bichot Date:May 20 2011 12:38pm
Subject:bzr commit into mysql-trunk branch (guilhem.bichot:3309)
View as plain text  
#At file:///home/mysql_src/bzrrepos_new/mysql-next-mr-opt-backporting-wl4800/ based on revid:jorgen.loland@stripped

 3309 Guilhem Bichot	2011-05-20
      review comments

    removed:
      unittest/gunit/opt_notrace-t.cc
    modified:
      WL4800_TODO.txt
      sql/opt_trace.cc
      sql/opt_trace.h
      sql/opt_trace2server.cc
      sql/sql_select.cc
      unittest/gunit/CMakeLists.txt
=== modified file 'WL4800_TODO.txt'
--- a/WL4800_TODO.txt	2011-05-04 20:53:28 +0000
+++ b/WL4800_TODO.txt	2011-05-20 12:38:41 +0000
@@ -40,7 +40,7 @@ range access anyway.
 (1)CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b));
    INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3);
    SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
-Guilhem asks: Can we fix this before push? If not, how to handle it?
+Jorgen said he'll fix in the wl4800 branch.
 
 C4) Jorgen wrote: Make --opt-trace-protocol dump traces to a separate file so that mtr
 can run with it without failing all tests.
@@ -85,6 +85,3 @@ included everywhere. Of opt_trace.h, sql
 Opt_trace_context. Should declaration of Opt_trace_context move to a
 separate smaller include file, to be included in sql_class.h?
 Guilhem suggests: yes.
-
-C10) Guilhem to Tor: can we delete opt_notrace-t.cc now? I think I
-replied in some old mail about this file.

=== modified file 'sql/opt_trace.cc'
--- a/sql/opt_trace.cc	2011-05-05 15:47:46 +0000
+++ b/sql/opt_trace.cc	2011-05-20 12:38:41 +0000
@@ -211,6 +211,7 @@ public:
   void assert_current_struct(const Opt_trace_struct *s) const
   { DBUG_ASSERT(current_struct == s); }
 
+  /// @see Opt_trace_context::missing_privilege()
   void missing_privilege();
 
   bool support_I_S() const { return I_S_disabled == 0; }
@@ -915,21 +916,21 @@ Opt_trace_context::default_features=
 
 Opt_trace_context::~Opt_trace_context()
 {
-  if (unlikely(impl != NULL))
+  if (unlikely(pimpl != NULL))
   {
     /* There may well be some few ended traces left: */
     purge_stmts(true);
     /* All should have moved to 'del' list: */
-    DBUG_ASSERT(impl->all_stmts_for_I_S.elements() == 0);
+    DBUG_ASSERT(pimpl->all_stmts_for_I_S.elements() == 0);
     /* All of 'del' list should have been deleted: */
-    DBUG_ASSERT(impl->all_stmts_to_del.elements() == 0);
-    delete impl;
+    DBUG_ASSERT(pimpl->all_stmts_to_del.elements() == 0);
+    delete pimpl;
   }
 }
 
 
 bool Opt_trace_context::start(bool support_I_S_arg,
-                              bool support_dbug_or_support_missing_priv,
+                              bool support_dbug_or_missing_priv,
                               bool end_marker_arg, bool one_line_arg,
                               long offset_arg, long limit_arg,
                               ulong max_mem_size_arg, ulonglong features_arg)
@@ -944,14 +945,14 @@ bool Opt_trace_context::start(bool suppo
 
   /*
     Decide on optimizations possible to realize the requested support.
-    If I_S or debug output is requested, need to create an Opt_trace_stmt.
+    If I_S or debug output is requested, we need to create an Opt_trace_stmt.
     Same if we should support calls to Opt_trace_context::missing_privilege(),
     because that function requires an Opt_trace_stmt.
   */
-  if (!support_I_S_arg && !support_dbug_or_support_missing_priv)
+  if (!support_I_S_arg && !support_dbug_or_missing_priv)
   {
     // The statement will not do tracing.
-    if (likely(impl == NULL) || impl->current_stmt_in_gen == NULL)
+    if (likely(pimpl == NULL) || pimpl->current_stmt_in_gen == NULL)
     {
       /*
         This should be the most commonly taken branch in a release binary,
@@ -977,8 +978,8 @@ bool Opt_trace_context::start(bool suppo
 
   DBUG_EXECUTE_IF("no_new_opt_trace_stmt", DBUG_ASSERT(0););
 
-  if (impl == NULL)
-    impl= new Opt_trace_context_impl(); // OOM-unsafe new.
+  if (pimpl == NULL)
+    pimpl= new Opt_trace_context_impl(); // OOM-unsafe new.
 
   /*
     If tracing is disabled by some caller, then don't change settings (offset
@@ -992,32 +993,32 @@ bool Opt_trace_context::start(bool suppo
       be some 'SET OPTIMIZER_TRACE="enabled=[on|off]"' to trace only certain
       sub-statements.
     */
-    impl->end_marker= end_marker_arg;
-    impl->one_line= one_line_arg;
-    impl->offset= offset_arg;
-    impl->limit= limit_arg;
-    impl->max_mem_size= max_mem_size_arg;
+    pimpl->end_marker= end_marker_arg;
+    pimpl->one_line= one_line_arg;
+    pimpl->offset= offset_arg;
+    pimpl->limit= limit_arg;
+    pimpl->max_mem_size= max_mem_size_arg;
     // MISC always on
-    impl->features= Opt_trace_context::feature_value(features_arg |
+    pimpl->features= Opt_trace_context::feature_value(features_arg |
                                                      Opt_trace_context::MISC);
   }
-  if (support_I_S_arg && impl->offset >= 0)
+  if (support_I_S_arg && pimpl->offset >= 0)
   {
     /* If outside the offset/limit window, no need to support I_S */
-    if (impl->since_offset_0 < impl->offset)
+    if (pimpl->since_offset_0 < pimpl->offset)
     {
       DBUG_PRINT("opt", ("disabled: since_offset_0(%ld) < offset(%ld)",
-                         impl->since_offset_0, impl->offset));
+                         pimpl->since_offset_0, pimpl->offset));
       support_I_S_arg= false;
     }
-    else if (impl->since_offset_0 >= (impl->offset + impl->limit))
+    else if (pimpl->since_offset_0 >= (pimpl->offset + pimpl->limit))
     {
       DBUG_PRINT("opt", ("disabled: since_offset_0(%ld) >="
                          " offset(%ld) + limit(%ld)",
-                         impl->since_offset_0, impl->offset, impl->limit));
+                         pimpl->since_offset_0, pimpl->offset, pimpl->limit));
       support_I_S_arg= false;
     }
-    impl->since_offset_0++;
+    pimpl->since_offset_0++;
   }
   {
     /*
@@ -1029,8 +1030,8 @@ bool Opt_trace_context::start(bool suppo
 
     DBUG_PRINT("opt",("new stmt %p support_I_S %d", stmt, support_I_S_arg));
 
-    if (unlikely(impl->stack_of_current_stmts
-                 .append(impl->current_stmt_in_gen)))
+    if (unlikely(pimpl->stack_of_current_stmts
+                 .append(pimpl->current_stmt_in_gen)))
       goto err;                            // append() above called my_error()
 
     /*
@@ -1041,17 +1042,17 @@ bool Opt_trace_context::start(bool suppo
     */
     Dynamic_array<Opt_trace_stmt *> *list;
     if (support_I_S_arg)
-      list= &impl->all_stmts_for_I_S;
+      list= &pimpl->all_stmts_for_I_S;
     else
     {
       stmt->disable_I_S();           // no need to fill a not-shown JSON trace
-      list= &impl->all_stmts_to_del;
+      list= &pimpl->all_stmts_to_del;
     }
 
     if (unlikely(list->append(stmt)))
         goto err;
 
-    impl->current_stmt_in_gen= stmt;
+    pimpl->current_stmt_in_gen= stmt;
 
     // As we just added one trace, maybe the previous ones are unneeded now
     purge_stmts(false);
@@ -1069,13 +1070,13 @@ err:
 void Opt_trace_context::end()
 {
   DBUG_ASSERT(I_S_disabled >= 0);
-  if (likely(impl == NULL))
+  if (likely(pimpl == NULL))
     return;
-  if (impl->current_stmt_in_gen != NULL)
+  if (pimpl->current_stmt_in_gen != NULL)
   {
-    impl->current_stmt_in_gen->end();
-    Opt_trace_stmt * const parent= impl->stack_of_current_stmts.pop();
-    impl->current_stmt_in_gen= parent;
+    pimpl->current_stmt_in_gen->end();
+    Opt_trace_stmt * const parent= pimpl->stack_of_current_stmts.pop();
+    pimpl->current_stmt_in_gen= parent;
     if (parent != NULL)
     {
       /*
@@ -1105,21 +1106,21 @@ void Opt_trace_context::end()
     purge_stmts(false);
   }
   else
-    DBUG_ASSERT(impl->stack_of_current_stmts.elements() == 0);
+    DBUG_ASSERT(pimpl->stack_of_current_stmts.elements() == 0);
 }
 
 
 bool Opt_trace_context::support_I_S() const
 {
-  return (impl != NULL) && (impl->current_stmt_in_gen != NULL) &&
-    impl->current_stmt_in_gen->support_I_S();
+  return (pimpl != NULL) && (pimpl->current_stmt_in_gen != NULL) &&
+    pimpl->current_stmt_in_gen->support_I_S();
 }
 
 
 void Opt_trace_context::purge_stmts(bool purge_all)
 {
   DBUG_ENTER("Opt_trace_context::purge_stmts");
-  if (!purge_all && impl->offset >= 0)
+  if (!purge_all && pimpl->offset >= 0)
   {
     /* This case is managed in @c Opt_trace_context::start() */
     DBUG_VOID_RETURN;
@@ -1133,10 +1134,10 @@ void Opt_trace_context::purge_stmts(bool
     incremented to 1, which is past the array's end, so break out of the loop:
     cell 0 (old cell 1) was not deleted, wrong).
   */
-  for (idx= (impl->all_stmts_for_I_S.elements() - 1) ; idx >= 0 ; idx--)
+  for (idx= (pimpl->all_stmts_for_I_S.elements() - 1) ; idx >= 0 ; idx--)
   {
     if (!purge_all &&
-        ((impl->all_stmts_for_I_S.elements() + impl->offset) <= idx))
+        ((pimpl->all_stmts_for_I_S.elements() + pimpl->offset) <= idx))
     {
       /* OFFSET mandates that this trace should be kept; move to previous */
     }
@@ -1148,9 +1149,9 @@ void Opt_trace_context::purge_stmts(bool
       */
       DBUG_EXECUTE_IF("opt_trace_oom_in_purge",
                       DBUG_SET("+d,simulate_out_of_memory"););
-      if (likely(!impl->all_stmts_to_del
-                 .append(impl->all_stmts_for_I_S.at(idx))))
-        impl->all_stmts_for_I_S.del(idx);
+      if (likely(!pimpl->all_stmts_to_del
+                 .append(pimpl->all_stmts_for_I_S.at(idx))))
+        pimpl->all_stmts_for_I_S.del(idx);
       else
       {
         /*
@@ -1164,9 +1165,9 @@ void Opt_trace_context::purge_stmts(bool
     }
   }
   /* Examine list of "to be freed" traces and free what can be */
-  for (idx= (impl->all_stmts_to_del.elements() - 1) ; idx >= 0 ; idx--)
+  for (idx= (pimpl->all_stmts_to_del.elements() - 1) ; idx >= 0 ; idx--)
   {
-    Opt_trace_stmt *stmt= impl->all_stmts_to_del.at(idx);
+    Opt_trace_stmt *stmt= pimpl->all_stmts_to_del.at(idx);
 #ifndef DBUG_OFF
     bool skip_del= false;
     DBUG_EXECUTE_IF("opt_trace_oom_in_purge", skip_del= true;);
@@ -1201,7 +1202,7 @@ void Opt_trace_context::purge_stmts(bool
     }
     else
     {
-      impl->all_stmts_to_del.del(idx);
+      pimpl->all_stmts_to_del.del(idx);
       delete stmt;
     }
   }
@@ -1213,23 +1214,23 @@ size_t Opt_trace_context::allowed_mem_si
 {
   size_t mem_size= 0;
   int idx;
-  for (idx= (impl->all_stmts_for_I_S.elements() - 1) ; idx >= 0 ; idx--)
+  for (idx= (pimpl->all_stmts_for_I_S.elements() - 1) ; idx >= 0 ; idx--)
   {
-    const Opt_trace_stmt *stmt= impl->all_stmts_for_I_S.at(idx);
+    const Opt_trace_stmt *stmt= pimpl->all_stmts_for_I_S.at(idx);
     mem_size+= stmt->alloced_length();
   }
   // Even to-be-deleted traces use memory, so consider them in sum
-  for (idx= (impl->all_stmts_to_del.elements() - 1) ; idx >= 0 ; idx--)
+  for (idx= (pimpl->all_stmts_to_del.elements() - 1) ; idx >= 0 ; idx--)
   {
-    const Opt_trace_stmt *stmt= impl->all_stmts_to_del.at(idx);
+    const Opt_trace_stmt *stmt= pimpl->all_stmts_to_del.at(idx);
     mem_size+= stmt->alloced_length();
   }
   /* The current statement is in exactly one of the two lists above */
-  mem_size-= impl->current_stmt_in_gen->alloced_length();
-  size_t rc= (mem_size <= impl->max_mem_size) ?
-    (impl->max_mem_size - mem_size) : 0;
+  mem_size-= pimpl->current_stmt_in_gen->alloced_length();
+  size_t rc= (mem_size <= pimpl->max_mem_size) ?
+    (pimpl->max_mem_size - mem_size) : 0;
   DBUG_PRINT("opt", ("rc %llu max_mem_size %llu",
-                     (ulonglong)rc, (ulonglong)impl->max_mem_size));
+                     (ulonglong)rc, (ulonglong)pimpl->max_mem_size));
   return rc;
 }
 
@@ -1237,23 +1238,23 @@ size_t Opt_trace_context::allowed_mem_si
 void Opt_trace_context::set_query(const char *query, size_t length,
                                   const CHARSET_INFO *charset)
 {
-  impl->current_stmt_in_gen->set_query(query, length, charset);
+  pimpl->current_stmt_in_gen->set_query(query, length, charset);
 }
 
 
 const char *Opt_trace_context::get_tail(size_t size)
 {
-  return (impl == NULL) ? "" :
-    impl->current_stmt_in_gen->trace_buffer_tail(size);
+  return (pimpl == NULL) ? "" :
+    pimpl->current_stmt_in_gen->trace_buffer_tail(size);
 }
 
 
 void Opt_trace_context::reset()
 {
-  if (impl == NULL)
+  if (pimpl == NULL)
     return;
   purge_stmts(true);
-  impl->since_offset_0= 0;
+  pimpl->since_offset_0= 0;
 }
 
 
@@ -1286,7 +1287,7 @@ void Opt_trace_context::missing_privileg
 
     Which is why this function needs an existing current_stmt_in_gen.
   */
-  impl->current_stmt_in_gen->missing_privilege();
+  pimpl->current_stmt_in_gen->missing_privilege();
 }
 
 
@@ -1294,13 +1295,13 @@ const Opt_trace_stmt
 *Opt_trace_context::get_next_stmt_for_I_S(long *got_so_far) const
 {
   const Opt_trace_stmt *p;
-  if ((impl == NULL) ||
-      (*got_so_far >= impl->limit) ||
-      (*got_so_far >= impl->all_stmts_for_I_S.elements()))
+  if ((pimpl == NULL) ||
+      (*got_so_far >= pimpl->limit) ||
+      (*got_so_far >= pimpl->all_stmts_for_I_S.elements()))
     p= NULL;
   else
   {
-    p= impl->all_stmts_for_I_S.at(*got_so_far);
+    p= pimpl->all_stmts_for_I_S.at(*got_so_far);
     DBUG_ASSERT(p != NULL);
     (*got_so_far)++;
   }

=== modified file 'sql/opt_trace.h'
--- a/sql/opt_trace.h	2011-05-04 20:53:28 +0000
+++ b/sql/opt_trace.h	2011-05-20 12:38:41 +0000
@@ -25,6 +25,7 @@
 struct st_schema_table;
 struct TABLE_LIST;
 struct TABLE;
+class sp_head;
 class sp_instr;
 
 /**
@@ -395,14 +396,14 @@ class Opt_trace_context
 {
 public:
 
-  Opt_trace_context() : impl(NULL), I_S_disabled(0) {}
+  Opt_trace_context() : pimpl(NULL), I_S_disabled(0) {}
   ~Opt_trace_context();
 
   /**
      Starts a new trace.
      @param  support_I_S      Whether this statement should have its trace in
                               information_schema
-     @param  support_dbug_or_support_missing_priv 'true' if this statement
+     @param  support_dbug_or_missing_priv  'true' if this statement
                               should have its trace in the dbug log (--debug),
                               or if missing_privilege() may be called on this
                               trace
@@ -433,7 +434,7 @@ public:
                               member function has undefined effects.
   */
   bool start(bool support_I_S,
-             bool support_dbug_or_support_t_missing_priv,
+             bool support_dbug_or_missing_priv,
              bool end_marker, bool one_line,
              long offset, long limit, ulong max_mem_size,
              ulonglong features);
@@ -450,7 +451,7 @@ public:
 
   /// Returns whether there is a current trace
   bool is_started() const
-  { return unlikely(impl != NULL) && impl->current_stmt_in_gen != NULL; }
+  { return unlikely(pimpl != NULL) && pimpl->current_stmt_in_gen != NULL; }
 
   /**
      @returns whether the current trace writes to I_S.
@@ -485,9 +486,9 @@ public:
   void reset();
 
   /// @sa parameters of Opt_trace_context::start()
-  bool get_end_marker() const { return impl->end_marker; }
+  bool get_end_marker() const { return pimpl->end_marker; }
   /// @sa parameters of Opt_trace_context::start()
-  bool get_one_line() const { return impl->one_line; }
+  bool get_one_line() const { return pimpl->one_line; }
 
   /**
      Names of flags for @@@@optimizer_trace variable of @c sys_vars.cc :
@@ -554,7 +555,7 @@ public:
      @param  f  feature
   */
   bool feature_enabled (feature_value f) const
-  { return unlikely(impl != NULL) && (impl->features & f); }
+  { return unlikely(pimpl != NULL) && (pimpl->features & f); }
 
   /**
      Opt_trace_struct is passed Opt_trace_context*, and needs to know
@@ -562,7 +563,7 @@ public:
      this information.
   */
   Opt_trace_stmt *get_current_stmt_in_gen()
-  { return impl->current_stmt_in_gen; }
+  { return pimpl->current_stmt_in_gen; }
 
   /**
      @returns the next statement to show in I_S.
@@ -576,8 +577,8 @@ public:
   void disable_I_S_for_this_and_children()
   {
     ++I_S_disabled;
-    if (unlikely(impl != NULL))
-      impl->disable_I_S_for_this_and_children();
+    if (unlikely(pimpl != NULL))
+      pimpl->disable_I_S_for_this_and_children();
   }
 
   /**
@@ -588,8 +589,8 @@ public:
   {
     --I_S_disabled;
     DBUG_ASSERT(I_S_disabled >= 0);
-    if (unlikely(impl != NULL))
-      impl->restore_I_S();
+    if (unlikely(pimpl != NULL))
+      pimpl->restore_I_S();
   }
 
 private:
@@ -684,7 +685,7 @@ private:
     long since_offset_0;
   };
 
-  Opt_trace_context_impl *impl;
+  Opt_trace_context_impl *pimpl;
 
   /**
     <>0 <=> any to-be-created statement's trace should not be in
@@ -1311,7 +1312,6 @@ void opt_trace_print_expanded_query(THD 
 void opt_trace_disable_if_no_view_access(THD *thd, TABLE_LIST *view,
                                  TABLE_LIST *underlying_tables);
 
-class sp_head;
 void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp);
 
 void opt_trace_disable_if_no_security_context_access(THD *thd);
@@ -1435,7 +1435,8 @@ public:
 };
 
 #define opt_trace_print_expanded_query(thd, select_lex) do {} while (0)
-#define opt_trace_disable_if_no_view_access(thd, view, underlying_tables) do {} while (0)
+#define opt_trace_disable_if_no_view_access(thd, view, underlying_tables) \
+  do {} while (0)
 #define opt_trace_disable_if_no_stored_proc_func_access(thd, sp) do {} while (0)
 #define opt_trace_disable_if_no_security_context_access(thd) do {} while (0)
 

=== modified file 'sql/opt_trace2server.cc'
--- a/sql/opt_trace2server.cc	2011-05-05 15:47:46 +0000
+++ b/sql/opt_trace2server.cc	2011-05-20 12:38:41 +0000
@@ -49,7 +49,7 @@ bool list_has_optimizer_trace_table(cons
   for( ; tbl ; tbl= tbl->next_global)
   {
     if (tbl->schema_table &&
-        !strcmp(tbl->schema_table->table_name, I_S_table_name))
+        0 == strcmp(tbl->schema_table->table_name, I_S_table_name))
       return true;
   }
   return false;
@@ -107,10 +107,10 @@ Opt_trace_start::Opt_trace_start(THD *th
     optimizer debug printouts).
   */
   const ulonglong var= thd->variables.optimizer_trace;
-  bool support_I_S= false, support_dbug_or_support_missing_priv= false;
+  bool support_I_S= false, support_dbug_or_missing_priv= false;
 
   /* This will be triggered if --debug or --debug=d:opt_trace is used */
-  DBUG_EXECUTE("opt", support_dbug_or_support_missing_priv= true;);
+  DBUG_EXECUTE("opt", support_dbug_or_missing_priv= true;);
 
   // First step, decide on what type of I_S support we want
   if (unlikely(var & Opt_trace_context::FLAG_ENABLED))
@@ -164,10 +164,10 @@ Opt_trace_start::Opt_trace_start(THD *th
       So we will do security checks. So need to inform the trace system that
       it should be ready for a possible call to missing_privilege() later:
     */
-    support_dbug_or_support_missing_priv= true;
+    support_dbug_or_missing_priv= true;
   }
 
-  error= ctx->start(support_I_S, support_dbug_or_support_missing_priv,
+  error= ctx->start(support_I_S, support_dbug_or_missing_priv,
                     (var & Opt_trace_context::FLAG_END_MARKER),
                     (var & Opt_trace_context::FLAG_ONE_LINE),
                     thd->variables.optimizer_trace_offset,
@@ -239,8 +239,8 @@ void opt_trace_print_expanded_query(THD 
    @name Description of trace-induced additional security checks.
    A trace exposes information. For example if one does SELECT on a view, the
    trace contains the view's body. So, the user should be allowed to see the
-   trace only if she/he has privilege to see the body, i.e. privilege to do SHOW
-   CREATE VIEW.
+   trace only if she/he has privilege to see the body, i.e. privilege to do
+   SHOW CREATE VIEW.
    There are similar issues with stored procedures, functions, triggers.
 
    We implement this by doing additional checks on SQL objects when tracing is
@@ -286,7 +286,6 @@ void opt_trace_print_expanded_query(THD 
    - from files (reading their content), with LOAD_FILE()
    - from the list of connections (reading their queries...), with
    I_S.PROCESSLIST.
-   - from etc, maybe.
    If the connected user has EXECUTE privilege on a routine which does a
    security context change, the routine can retrieve information internally
    (if allowed by the SUID context's privileges), and present only a portion
@@ -314,7 +313,7 @@ void opt_trace_disable_if_no_security_co
   DBUG_ENTER("opt_trace_check_disable_if_no_security_context_access");
   if (likely(!(thd->variables.optimizer_trace &
                Opt_trace_context::FLAG_ENABLED)) || // (1)
-      thd->system_thread)                        // (2)
+      thd->system_thread)                           // (2)
   {
     /*
       (1) We know that the routine's execution starts with "enabled=off".
@@ -361,10 +360,11 @@ void opt_trace_disable_if_no_security_co
   */
   if (!(test_all_bits(thd->main_security_ctx.master_access,
                       (GLOBAL_ACLS & ~GRANT_ACL))) &&
-      (strcmp(thd->main_security_ctx.priv_user,
-              thd->security_ctx->priv_user) ||
-       my_strcasecmp(system_charset_info, thd->main_security_ctx.priv_host,
-                     thd->security_ctx->priv_host)))
+      (0 != strcmp(thd->main_security_ctx.priv_user,
+                   thd->security_ctx->priv_user) ||
+       0 != my_strcasecmp(system_charset_info,
+                          thd->main_security_ctx.priv_host,
+                          thd->security_ctx->priv_host)))
     trace->missing_privilege();
   DBUG_VOID_RETURN;
 #endif
@@ -449,12 +449,15 @@ void opt_trace_disable_if_no_view_access
   Security_context * const backup_table_sctx= view->security_ctx;
   Security_context * const backup_thd_sctx= thd->security_ctx;
   const GRANT_INFO backup_grant_info= view->grant;
+
   view->security_ctx= NULL;                   // no SUID context for view
   thd->security_ctx= &thd->main_security_ctx; // no SUID context for THD
   const int rc= check_table_access(thd, SHOW_VIEW_ACL, view, false, 1, true);
+
   view->security_ctx= backup_table_sctx;
   thd->security_ctx= backup_thd_sctx;
   view->grant= backup_grant_info;
+
   if (rc)
   {
     trace->missing_privilege();
@@ -583,10 +586,11 @@ int fill_optimizer_trace_info(THD *thd, 
   */
   if (!test_all_bits(thd->security_ctx->master_access,
                      (GLOBAL_ACLS & ~GRANT_ACL)) &&
-      (strcmp(thd->main_security_ctx.priv_user,
-              thd->security_ctx->priv_user) ||
-       my_strcasecmp(system_charset_info, thd->main_security_ctx.priv_host,
-                     thd->security_ctx->priv_host)))
+      (0 != strcmp(thd->main_security_ctx.priv_user,
+                   thd->security_ctx->priv_user) ||
+       0 != my_strcasecmp(system_charset_info,
+                          thd->main_security_ctx.priv_host,
+                          thd->security_ctx->priv_host)))
     return 0;
   /*
     The list must not change during the iterator's life time. This is ok as

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-05-13 14:02:31 +0000
+++ b/sql/sql_select.cc	2011-05-20 12:38:41 +0000
@@ -10268,7 +10268,7 @@ static bool make_join_select(JOIN *join,
 	      */
               sel->cond=orig_cond;
               if (!*tab->on_expr_ref)
-		DBUG_RETURN(1);			// Impossible WHERE
+                DBUG_RETURN(1);                 // Impossible WHERE
               Opt_trace_object trace_without_on(trace, "without_ON_clause");
               if (sel->test_quick_select(thd, tab->keys,
                                          used_tables & ~ current_map,

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2011-05-06 12:58:06 +0000
+++ b/unittest/gunit/CMakeLists.txt	2011-05-20 12:38:41 +0000
@@ -212,7 +212,6 @@ SET(TESTS
   my_decimal
   my_regex
   opt_trace
-  opt_notrace
   sql_list
   sql_plist
   thread_utils

=== removed file 'unittest/gunit/opt_notrace-t.cc'
--- a/unittest/gunit/opt_notrace-t.cc	2011-02-16 15:06:06 +0000
+++ b/unittest/gunit/opt_notrace-t.cc	1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA  */
-
-#include "my_config.h"
-#include <gtest/gtest.h>
-
-#if defined(OPTIMIZER_TRACE)
-#undef OPTIMIZER_TRACE
-#endif
-#define OPTIMIZER_TRACE_UNITTEST
-
-#include <opt_trace.h>
-
-namespace {
-
-TEST(Foo, Bar)
-{
-  // Fill in more here, to verify that implementations are in sync!!!
-  Opt_trace_context trace;
-  Opt_trace_object oto(&trace);
-  Opt_trace_array  ota(&trace);
-}
-
-}


Attachment: [text/bzr-bundle] bzr/guilhem.bichot@oracle.com-20110520123841-5u32fuuqzaqkzgr4.bundle
Thread
bzr commit into mysql-trunk branch (guilhem.bichot:3309) Guilhem Bichot20 May