~drizzle-trunk/drizzle/development

642.1.10 by Lee
move functions from item.cc/item.h to item directory
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
class Item_ref_null_helper: public Item_ref
33
{
34
protected:
35
  Item_in_subselect* owner;
36
public:
37
  Item_ref_null_helper(Name_resolution_context *context_arg,
38
                       Item_in_subselect* master, Item **item,
39
                       const char *table_name_arg, const char *field_name_arg)
40
    :Item_ref(context_arg, item, table_name_arg, field_name_arg),
41
     owner(master) {}
42
  double val_real();
43
  int64_t val_int();
44
  String* val_str(String* s);
45
  my_decimal *val_decimal(my_decimal *);
46
  bool val_bool();
47
  bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate);
48
  virtual void print(String *str, enum_query_type query_type);
49
  /*
50
    we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
51
  */
52
  table_map used_tables() const
53
  {
54
    return (depended_from ?
55
            OUTER_REF_TABLE_BIT :
56
            (*ref)->used_tables() | RAND_TABLE_BIT);
57
  }
58
};
59
60
#endif /* DRIZZLED_ITEM_REF_NULL_HELPER_H */