~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/ref_null_helper.h

  • Committer: Monty Taylor
  • Date: 2008-10-16 09:12:23 UTC
  • mto: (511.1.6 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016091223-17ngih0qu9vssjs3
We pass -Wunused-macros now!

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_REF_NULL_HELPER_H
21
 
#define DRIZZLED_ITEM_REF_NULL_HELPER_H
22
 
 
23
 
/*
24
 
  An object of this class:
25
 
   - Converts val_XXX() calls to ref->val_XXX_result() calls, like Item_ref.
26
 
   - Sets owner->was_null=true if it has returned a NULL value from any
27
 
     val_XXX() function. This allows to inject an Item_ref_null_helper
28
 
     object into subquery and then check if the subquery has produced a row
29
 
     with NULL value.
30
 
*/
31
 
 
32
 
namespace drizzled
33
 
{
34
 
 
35
 
class Item_ref_null_helper: public Item_ref
36
 
{
37
 
protected:
38
 
  Item_in_subselect* owner;
39
 
public:
40
 
  Item_ref_null_helper(Name_resolution_context *context_arg,
41
 
                       Item_in_subselect* master, Item **item,
42
 
                       const char *table_name_arg, const char *field_name_arg)
43
 
    :Item_ref(context_arg, item, table_name_arg, field_name_arg),
44
 
     owner(master) {}
45
 
  double val_real();
46
 
  int64_t val_int();
47
 
  String* val_str(String* s);
48
 
  my_decimal *val_decimal(my_decimal *);
49
 
  bool val_bool();
50
 
  bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate);
51
 
  virtual void print(String *str, enum_query_type query_type);
52
 
  /*
53
 
    we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
54
 
  */
55
 
  table_map used_tables() const
56
 
  {
57
 
    return (depended_from ?
58
 
            OUTER_REF_TABLE_BIT :
59
 
            (*ref)->used_tables() | RAND_TABLE_BIT);
60
 
  }
61
 
};
62
 
 
63
 
} /* namespace drizzled */
64
 
 
65
 
#endif /* DRIZZLED_ITEM_REF_NULL_HELPER_H */