~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/subselect.cc

  • Committer: Jay Pipes
  • Date: 2009-11-19 18:58:35 UTC
  • mto: (1223.1.2 push)
  • mto: This revision was merged to the branch mainline in revision 1224.
  • Revision ID: jpipes@serialcoder-20091119185835-o59wyfjiet3keutu
Fixes some valgrind warnings regarding conditionals depending on unintialized variables.  Use initializer lists properly, dang it. :) Also, removed the new_Cached_item() function's use_result_field, as this was only used for views and was producing a valgrind warning unnecessarily.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
  return (cond? (new Item_cond_and(cond, item)) : item);
41
41
}
42
42
 
43
 
Item_subselect::Item_subselect():
44
 
  Item_result_field(), value_assigned(0), session(0), substitution(0),
45
 
  engine(0), old_engine(0), used_tables_cache(0), have_to_be_excluded(0),
46
 
  const_item_cache(1), engine_changed(0), changed(0),
 
43
Item_subselect::Item_subselect() :
 
44
  Item_result_field(),
 
45
  value_assigned(false),
 
46
  session(NULL),
 
47
  substitution(NULL),
 
48
  unit(NULL),
 
49
  engine(NULL),
 
50
  old_engine(NULL),
 
51
  used_tables_cache(0),
 
52
  max_columns(0),
 
53
  parsing_place(NO_MATTER),
 
54
  have_to_be_excluded(false),
 
55
  const_item_cache(true),
 
56
  engine_changed(false),
 
57
  changed(false),
47
58
  is_correlated(false)
48
59
{
49
60
  with_subselect= 1;
704
715
}
705
716
 
706
717
Item_in_subselect::Item_in_subselect(Item * left_exp,
707
 
                                     Select_Lex *select_lex):
708
 
  Item_exists_subselect(), left_expr_cache(0), first_execution(true),
709
 
  optimizer(0), pushed_cond_guards(NULL), exec_method(NOT_TRANSFORMED),
710
 
  upper_item(0)
 
718
                                     Select_Lex *select_lex) :
 
719
  Item_exists_subselect(),
 
720
  left_expr(left_exp),
 
721
  left_expr_cache(NULL),
 
722
  first_execution(true),
 
723
  optimizer(NULL),
 
724
  pushed_cond_guards(NULL),
 
725
  sj_convert_priority(0),
 
726
  expr_join_nest(NULL),
 
727
  exec_method(NOT_TRANSFORMED),
 
728
  upper_item(NULL)
711
729
{
712
 
  left_expr= left_exp;
713
730
  init(select_lex, new select_exists_subselect(this));
714
731
  max_columns= UINT_MAX;
715
732
  maybe_null= 1;
1814
1831
 
1815
1832
bool Item_in_subselect::init_left_expr_cache()
1816
1833
{
1817
 
  JOIN *outer_join;
1818
 
  Next_select_func end_select;
1819
 
  bool use_result_field= false;
 
1834
  JOIN *outer_join= NULL;
1820
1835
 
1821
1836
  outer_join= unit->outer_select()->join;
1822
 
  if (!outer_join || !outer_join->tables)
 
1837
  if (! outer_join || ! outer_join->tables || ! outer_join->join_tab)
1823
1838
    return true;
1824
 
  /*
1825
 
    If we use end_[send | write]_group to handle complete rows of the outer
1826
 
    query, make the cache of the left IN operand use Item_field::result_field
1827
 
    instead of Item_field::field.  We need this because normally
1828
 
    Cached_item_field uses Item::field to fetch field data, while
1829
 
    copy_ref_key() that copies the left IN operand into a lookup key uses
1830
 
    Item::result_field. In the case end_[send | write]_group result_field is
1831
 
    one row behind field.
1832
 
  */
1833
 
  end_select= outer_join->join_tab[outer_join->tables-1].next_select;
1834
 
  if (end_select == end_send_group || end_select == end_write_group)
1835
 
    use_result_field= true;
1836
1839
 
1837
1840
  if (!(left_expr_cache= new List<Cached_item>))
1838
1841
    return true;
1839
1842
 
1840
1843
  for (uint32_t i= 0; i < left_expr->cols(); i++)
1841
1844
  {
1842
 
    Cached_item *cur_item_cache= new_Cached_item(session,
1843
 
                                                 left_expr->element_index(i),
1844
 
                                                 use_result_field);
 
1845
    Cached_item *cur_item_cache= new_Cached_item(session, left_expr->element_index(i));
1845
1846
    if (!cur_item_cache || left_expr_cache->push_front(cur_item_cache))
1846
1847
      return true;
1847
1848
  }