~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Brian Aker
  • Date: 2008-10-08 02:28:58 UTC
  • mfrom: (489.1.13 codestyle)
  • Revision ID: brian@tangent.org-20081008022858-ea8esagkxmn0dupc
Merge of Monty's work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1219
1219
    return(0);
1220
1220
  optimized= 1;
1221
1221
 
1222
 
  thd_proc_info(thd, "optimizing");
 
1222
  thd->set_proc_info("optimizing");
1223
1223
  row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR :
1224
1224
              unit->select_limit_cnt);
1225
1225
  /* select_limit is used to decide if we are likely to scan the whole table */
1345
1345
  sort_by_table= get_sort_by_table(order, group_list, select_lex->leaf_tables);
1346
1346
 
1347
1347
  /* Calculate how to do the join */
1348
 
  thd_proc_info(thd, "statistics");
 
1348
  thd->set_proc_info("statistics");
1349
1349
  if (make_join_statistics(this, select_lex->leaf_tables, conds, &keyuse) ||
1350
1350
      thd->is_fatal_error)
1351
1351
  {
1354
1354
 
1355
1355
  /* Remove distinct if only const tables */
1356
1356
  select_distinct= select_distinct && (const_tables != tables);
1357
 
  thd_proc_info(thd, "preparing");
 
1357
  thd->set_proc_info("preparing");
1358
1358
  if (result->initialize_tables(this))
1359
1359
  {
1360
1360
    return(1);                          // error == -1
1789
1789
  /* Create a tmp table if distinct or if the sort is too complicated */
1790
1790
  if (need_tmp)
1791
1791
  {
1792
 
    thd_proc_info(thd, "Creating tmp table");
 
1792
    thd->set_proc_info("Creating tmp table");
1793
1793
 
1794
1794
    init_items_ref_array();
1795
1795
 
1837
1837
    /* if group or order on first table, sort first */
1838
1838
    if (group_list && simple_group)
1839
1839
    {
1840
 
      thd_proc_info(thd, "Sorting for group");
 
1840
      thd->set_proc_info("Sorting for group");
1841
1841
      if (create_sort_index(thd, this, group_list,
1842
1842
                            HA_POS_ERROR, HA_POS_ERROR, false) ||
1843
1843
          alloc_group_fields(this, group_list) ||
1858
1858
 
1859
1859
      if (!group_list && ! exec_tmp_table1->distinct && order && simple_order)
1860
1860
      {
1861
 
        thd_proc_info(thd, "Sorting for order");
 
1861
        thd->set_proc_info("Sorting for order");
1862
1862
        if (create_sort_index(thd, this, order,
1863
1863
                              HA_POS_ERROR, HA_POS_ERROR, true))
1864
1864
        {
2014
2014
  List<Item> *columns_list= &fields_list;
2015
2015
  int      tmp_error;
2016
2016
 
2017
 
  thd_proc_info(thd, "executing");
 
2017
  thd->set_proc_info("executing");
2018
2018
  error= 0;
2019
2019
  (void) result->prepare2(); // Currently, this cannot fail.
2020
2020
 
2140
2140
    curr_tmp_table= exec_tmp_table1;
2141
2141
 
2142
2142
    /* Copy data to the temporary table */
2143
 
    thd_proc_info(thd, "Copying to tmp table");
 
2143
    thd->set_proc_info("Copying to tmp table");
2144
2144
    if (!curr_join->sort_and_group &&
2145
2145
        curr_join->const_tables != curr_join->tables)
2146
2146
      curr_join->join_tab[curr_join->const_tables].sorted= 0;
2255
2255
      }
2256
2256
      if (curr_join->group_list)
2257
2257
      {
2258
 
        thd_proc_info(thd, "Creating sort index");
 
2258
        thd->set_proc_info("Creating sort index");
2259
2259
        if (curr_join->join_tab == join_tab && save_join_tab())
2260
2260
        {
2261
2261
          return;
2269
2269
        sortorder= curr_join->sortorder;
2270
2270
      }
2271
2271
      
2272
 
      thd_proc_info(thd, "Copying to group table");
 
2272
      thd->set_proc_info("Copying to group table");
2273
2273
      tmp_error= -1;
2274
2274
      if (curr_join != this)
2275
2275
      {
2326
2326
    curr_join->join_free();                     /* Free quick selects */
2327
2327
    if (curr_join->select_distinct && ! curr_join->group_list)
2328
2328
    {
2329
 
      thd_proc_info(thd, "Removing duplicates");
 
2329
      thd->set_proc_info("Removing duplicates");
2330
2330
      if (curr_join->tmp_having)
2331
2331
        curr_join->tmp_having->update_used_tables();
2332
2332
      if (remove_duplicates(curr_join, curr_tmp_table,
2384
2384
  }
2385
2385
  if (curr_join->group_list || curr_join->order)
2386
2386
  {
2387
 
    thd_proc_info(thd, "Sorting result");
 
2387
    thd->set_proc_info("Sorting result");
2388
2388
    /* If we have already done the group, add HAVING to sorted table */
2389
2389
    if (curr_join->tmp_having && ! curr_join->group_list && 
2390
2390
        ! curr_join->sort_and_group)
2494
2494
  curr_join->fields= curr_fields_list;
2495
2495
 
2496
2496
  {
2497
 
    thd_proc_info(thd, "Sending data");
 
2497
    thd->set_proc_info("Sending data");
2498
2498
    result->send_fields(*curr_fields_list,
2499
2499
                        Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
2500
2500
    error= do_select(curr_join, curr_fields_list, NULL);
2648
2648
  {
2649
2649
    if (!(join= new JOIN(thd, fields, select_options, result)))
2650
2650
        return(true);
2651
 
    thd_proc_info(thd, "init");
 
2651
    thd->set_proc_info("init");
2652
2652
    thd->used_tables=0;                         // Updated by setup_fields
2653
2653
    if ((err= join->prepare(rref_pointer_array, tables, wild_num,
2654
2654
                           conds, og_num, order, group, having, proc_param,
2691
2691
err:
2692
2692
  if (free_join)
2693
2693
  {
2694
 
    thd_proc_info(thd, "end");
 
2694
    thd->set_proc_info("end");
2695
2695
    err|= select_lex->cleanup();
2696
2696
    return(err || thd->is_error());
2697
2697
  }