~linuxjedi/drizzle/trunk-bug-738024

« back to all changes in this revision

Viewing changes to drizzled/join.cc

  • Committer: Monty Taylor
  • Date: 2011-03-08 06:21:17 UTC
  • mfrom: (2223.1.3 build)
  • Revision ID: mordred@inaugust.com-20110308062117-4i2syq1gqtmcmcyk
Merge Olaf - XID and Dynamic_array refactoring
Merge Andrew - Optimizer bugs

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
#include <drizzled/select_result.h>
64
64
#include <drizzled/debug.h>
65
65
#include <drizzled/item/subselect.h>
66
 
 
 
66
#include <drizzled/my_hash.h>
67
67
#include <algorithm>
68
68
 
69
69
using namespace std;
70
70
 
71
 
namespace drizzled
72
 
{
 
71
namespace drizzled {
 
72
 
73
73
extern plugin::StorageEngine *heap_engine;
74
74
 
75
75
/** Declarations of static functions used in this source file. */
823
823
      (select_options & SELECT_DESCRIBE) &&
824
824
      select_lex->master_unit() == &session->getLex()->unit) // upper level SELECT
825
825
  {
826
 
    conds=new Item_int((int64_t) 0,1);  // Always false
 
826
    conds=new Item_int(0, 1);  // Always false
827
827
  }
828
828
 
829
829
  if (make_join_select(this, select, conds))
1513
1513
    session->set_proc_info("Copying to tmp table");
1514
1514
    if (! curr_join->sort_and_group && curr_join->const_tables != curr_join->tables)
1515
1515
      curr_join->join_tab[curr_join->const_tables].sorted= 0;
1516
 
    if ((tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table)))
 
1516
    if ((tmp_error= do_select(curr_join, NULL, curr_tmp_table)))
1517
1517
    {
1518
1518
      error= tmp_error;
1519
1519
      return;
1612
1612
              exec_tmp_table2= create_tmp_table(session,
1613
1613
                                                &curr_join->tmp_table_param,
1614
1614
                                                *curr_all_fields,
1615
 
                                                (Order*) 0,
 
1615
                                                NULL,
1616
1616
                                                curr_join->select_distinct &&
1617
1617
                                                !curr_join->group_list,
1618
1618
                                                1, curr_join->select_options,
1664
1664
        curr_join->join_tab[curr_join->const_tables].sorted= 0;
1665
1665
      
1666
1666
      if (setup_sum_funcs(curr_join->session, curr_join->sum_funcs) 
1667
 
        || (tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table)))
 
1667
        || (tmp_error= do_select(curr_join, NULL, curr_tmp_table)))
1668
1668
      {
1669
1669
        error= tmp_error;
1670
1670
        return;
2324
2324
          Item* new_item= new Item_func_rollup_const(item);
2325
2325
          if (!new_item)
2326
2326
            return 1;
2327
 
          new_item->fix_fields(session, (Item **) 0);
 
2327
          new_item->fix_fields(session, NULL);
2328
2328
          *it.ref()= new_item;
2329
2329
          for (Order *tmp= group_tmp; tmp; tmp= tmp->next)
2330
2330
          {
4727
4727
        COND *const_cond=
4728
4728
          make_cond_for_table(cond,
4729
4729
              join->const_table_map,
4730
 
              (table_map) 0, 1);
 
4730
              0, 1);
4731
4731
        for (JoinTable *tab= join->join_tab+join->const_tables;
4732
4732
            tab < join->join_tab+join->tables ; tab++)
4733
4733
        {
5750
5750
      if (!table->cursor->stats.records && !embedding)
5751
5751
      {                                         // Empty table
5752
5752
        s->dependent= 0;                        // Ignore LEFT JOIN depend.
5753
 
        set_position(join, const_count++, s, (optimizer::KeyUse*) 0);
 
5753
        set_position(join, const_count++, s, NULL);
5754
5754
        continue;
5755
5755
      }
5756
5756
      outer_join|= table->map;
5778
5778
              (table->cursor->getEngine()->check_flag(HTON_BIT_STATS_RECORDS_IS_EXACT)) &&
5779
5779
        !join->no_const_tables)
5780
5780
    {
5781
 
      set_position(join, const_count++, s, (optimizer::KeyUse*) 0);
 
5781
      set_position(join, const_count++, s, NULL);
5782
5782
    }
5783
5783
  }
5784
5784
  stat_vector[i]=0;
5902
5902
            table->mark_as_null_row();
5903
5903
            found_const_table_map|= table->map;
5904
5904
            join->const_table_map|= table->map;
5905
 
            set_position(join, const_count++, s, (optimizer::KeyUse*) 0);
 
5905
            set_position(join, const_count++, s, NULL);
5906
5906
            goto more_const_tables_found;
5907
5907
           }
5908
5908
          keyuse++;
5921
5921
          int tmp= 0;
5922
5922
          s->type= AM_SYSTEM;
5923
5923
          join->const_table_map|=table->map;
5924
 
          set_position(join, const_count++, s, (optimizer::KeyUse*) 0);
 
5924
          set_position(join, const_count++, s, NULL);
5925
5925
          partial_pos= join->getSpecificPosInPartialPlan(const_count - 1);
5926
5926
          if ((tmp= s->joinReadConstTable(partial_pos)))
5927
5927
          {
6069
6069
          caller to abort with a zero row result.
6070
6070
        */
6071
6071
        join->const_table_map|= s->table->map;
6072
 
        set_position(join, const_count++, s, (optimizer::KeyUse*) 0);
 
6072
        set_position(join, const_count++, s, NULL);
6073
6073
        s->type= AM_CONST;
6074
6074
        if (*s->on_expr_ref)
6075
6075
        {
6175
6175
*/
6176
6176
static Table *get_sort_by_table(Order *a, Order *b,TableList *tables)
6177
6177
{
6178
 
  table_map map= (table_map) 0;
 
6178
  table_map map= 0;
6179
6179
 
6180
6180
  if (!a)
6181
6181
    a= b;                                       // Only one need to be given