~maria-captains/maria/5.5-explain-analyze

« back to all changes in this revision

Viewing changes to sql/sql_parse.cc

  • Committer: Sergey Petrunya
  • Date: 2012-09-03 15:11:24 UTC
  • Revision ID: psergey@askmonty.org-20120903151124-s1y9vrz3k4ezy642
MDEV-406: EXPLAIN ANALYZE 
- First code, it is possible to get the data for joins/unions
- Numbers for join buffering are likely to be incorrect
- Same for subqueries (what should 'loops' show?)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4642
4642
    }
4643
4643
    else
4644
4644
    {
4645
 
      if (!result && !(result= new select_send()))
 
4645
      select_send* sel_send;
 
4646
      if (!result && !(result= sel_send= new select_send()))
4646
4647
        return 1;                               /* purecov: inspected */
4647
4648
      query_cache_store_query(thd, all_tables);
 
4649
      /* 
 
4650
        Setup EXPLAIN ANALYZE
 
4651
        - Switch off production of real query output
 
4652
        - Create a sink to save EXPLAIN output
 
4653
      */
 
4654
      if (lex->describe_analyze)
 
4655
      {
 
4656
        bool bres;
 
4657
 
 
4658
        lex->explain_analyze_buf= new select_result_basic_explain_buffer;
 
4659
        lex->explain_analyze_buf->thd= thd;
 
4660
        lex->explain_analyze_buf->protocol= thd->protocol;
 
4661
 
 
4662
        lex->describe_column_list.empty();
 
4663
        thd->make_explain_field_list(lex->describe_column_list, true);
 
4664
        bres= result->send_result_set_metadata(lex->describe_column_list,
 
4665
                                               Protocol::SEND_NUM_ROWS |
 
4666
                                               Protocol::SEND_EOF);
 
4667
        if (bres)
 
4668
          return 1;
 
4669
 
 
4670
        sel_send->discard_data= TRUE;
 
4671
      }
 
4672
 
4648
4673
      res= handle_select(thd, lex, result, 0);
 
4674
 
 
4675
      if (lex->describe_analyze)
 
4676
      {
 
4677
        /* 
 
4678
          Finalize EXPLAIN ANALYZE processing. For now, this just flushes the
 
4679
          data. What it should do is to print the output in "explain order"
 
4680
         */
 
4681
        lex->unit.print_saved_explain(thd, sel_send);
 
4682
        lex->explain_analyze_buf->free();
 
4683
      }
4649
4684
      if (result != lex->result)
4650
4685
        delete result;
4651
4686
    }