~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/item/outer_ref.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

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
#include "drizzled/item/ref.h"
 
24
#include "drizzled/item/direct_ref.h"
 
25
#include "drizzled/item/field.h"
 
26
 
 
27
/*
 
28
  Class for outer fields.
 
29
  An object of this class is created when the select where the outer field was
 
30
  resolved is a grouping one. After it has been fixed the ref field will point
 
31
  to either an Item_ref or an Item_direct_ref object which will be used to
 
32
  access the field.
 
33
  See also comments for the fix_inner_refs() and the
 
34
  Item_field::fix_outer_field() functions.
 
35
*/
 
36
 
 
37
namespace drizzled
 
38
{
 
39
 
 
40
class Item_outer_ref :public Item_direct_ref
 
41
{
 
42
public:
 
43
  Item *outer_ref;
 
44
  /* The aggregate function under which this outer ref is used, if any. */
 
45
  Item_sum *in_sum_func;
 
46
  /*
 
47
    true <=> that the outer_ref is already present in the select list
 
48
    of the outer select.
 
49
  */
 
50
  bool found_in_select_list;
 
51
  Item_outer_ref(Name_resolution_context *context_arg,
 
52
                 Item_field *outer_field_arg)
 
53
    :Item_direct_ref(context_arg, 0, outer_field_arg->table_name,
 
54
                     outer_field_arg->field_name),
 
55
    outer_ref(outer_field_arg), in_sum_func(0),
 
56
    found_in_select_list(0)
 
57
  {
 
58
    ref= &outer_ref;
 
59
    set_properties();
 
60
    fixed= 0;
 
61
  }
 
62
  Item_outer_ref(Name_resolution_context *context_arg, Item **item,
 
63
                 const char *table_name_arg, const char *field_name_arg,
 
64
                 bool alias_name_used_arg)
 
65
    :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg,
 
66
                     alias_name_used_arg),
 
67
    outer_ref(0), in_sum_func(0), found_in_select_list(1)
 
68
  {}
 
69
  void save_in_result_field(bool)
 
70
  {
 
71
    outer_ref->save_org_in_field(result_field);
 
72
  }
 
73
  bool fix_fields(Session *, Item **);
 
74
  void fix_after_pullout(Select_Lex *new_parent, Item **ref);
 
75
  table_map used_tables() const
 
76
  {
 
77
    return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT;
 
78
  }
 
79
  virtual Ref_Type ref_type() { return OUTER_REF; }
 
80
};
 
81
 
 
82
} /* namespace drizzled */
 
83
 
 
84
#endif /* DRIZZLED_ITEM_OUTER_REF_H */