~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/outer_ref.h

  • Committer: Brian Aker
  • Date: 2008-12-11 08:52:18 UTC
  • mfrom: (670.1.11 devel)
  • Revision ID: brian@tangent.org-20081211085218-cpmznmzrflyd82j2
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef DRIZZLED_ITEM_OUTER_REF_H
 
21
#define DRIZZLED_ITEM_OUTER_REF_H
 
22
 
 
23
/*
 
24
  Class for outer fields.
 
25
  An object of this class is created when the select where the outer field was
 
26
  resolved is a grouping one. After it has been fixed the ref field will point
 
27
  to either an Item_ref or an Item_direct_ref object which will be used to
 
28
  access the field.
 
29
  See also comments for the fix_inner_refs() and the
 
30
  Item_field::fix_outer_field() functions.
 
31
*/
 
32
 
 
33
class Item_outer_ref :public Item_direct_ref
 
34
{
 
35
public:
 
36
  Item *outer_ref;
 
37
  /* The aggregate function under which this outer ref is used, if any. */
 
38
  Item_sum *in_sum_func;
 
39
  /*
 
40
    true <=> that the outer_ref is already present in the select list
 
41
    of the outer select.
 
42
  */
 
43
  bool found_in_select_list;
 
44
  Item_outer_ref(Name_resolution_context *context_arg,
 
45
                 Item_field *outer_field_arg)
 
46
    :Item_direct_ref(context_arg, 0, outer_field_arg->table_name,
 
47
                     outer_field_arg->field_name),
 
48
    outer_ref(outer_field_arg), in_sum_func(0),
 
49
    found_in_select_list(0)
 
50
  {
 
51
    ref= &outer_ref;
 
52
    set_properties();
 
53
    fixed= 0;
 
54
  }
 
55
  Item_outer_ref(Name_resolution_context *context_arg, Item **item,
 
56
                 const char *table_name_arg, const char *field_name_arg,
 
57
                 bool alias_name_used_arg)
 
58
    :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg,
 
59
                     alias_name_used_arg),
 
60
    outer_ref(0), in_sum_func(0), found_in_select_list(1)
 
61
  {}
 
62
  void save_in_result_field(bool)
 
63
  {
 
64
    outer_ref->save_org_in_field(result_field);
 
65
  }
 
66
  bool fix_fields(Session *, Item **);
 
67
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
 
68
  table_map used_tables() const
 
69
  {
 
70
    return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT;
 
71
  }
 
72
  virtual Ref_Type ref_type() { return OUTER_REF; }
 
73
};
 
74
 
 
75
 
 
76
#endif /* DRIZZLED_ITEM_OUTER_REF_H */