~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.h

  • Committer: Brian Aker
  • Date: 2010-08-18 23:12:07 UTC
  • mto: This revision was merged to the branch mainline in revision 1719.
  • Revision ID: brian@tangent.org-20100818231207-2dgclr6o06q90np1
Test scoped ptr in the tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
 
21
 
 
22
20
#ifndef DRIZZLED_FUNCTION_FUNC_H
23
21
#define DRIZZLED_FUNCTION_FUNC_H
24
22
 
25
23
/// TODO: Rename this file - func.h is stupid.
26
24
 
27
 
#include <drizzled/charset_info.h>
28
25
#include <drizzled/item.h>
 
26
#include <drizzled/sql_list.h>
29
27
#include <drizzled/item/bin_string.h>
30
 
#include <drizzled/lex_string.h>
31
 
#include <drizzled/sql_list.h>
32
 
#include <drizzled/type/decimal.h>
33
 
 
34
 
#include <drizzled/visibility.h>
 
28
#include "drizzled/current_session.h"
35
29
 
36
30
namespace drizzled
37
31
{
38
32
 
39
 
class DRIZZLED_API Item_func :
40
 
  public Item_result_field
 
33
class Item_func :public Item_result_field
41
34
{
42
35
  Session &_session;
43
36
 
48
41
    0 means get this number from first argument
49
42
  */
50
43
  uint32_t allowed_arg_cols;
51
 
 
52
44
public:
53
45
 
54
46
  using Item::split_sum_func;
73
65
  virtual enum Functype functype() const   { return UNKNOWN_FUNC; }
74
66
  virtual ~Item_func() {}
75
67
 
76
 
  Item_func(void);
 
68
  Item_func(void):
 
69
    _session(*current_session),
 
70
    allowed_arg_cols(1), arg_count(0)
 
71
  {
 
72
    with_sum_func= 0;
 
73
  }
77
74
 
78
 
  Item_func(Item *a);
79
 
  
80
 
  Item_func(Item *a,Item *b);
81
 
  
82
 
  Item_func(Item *a,Item *b,Item *c);
83
 
  
84
 
  Item_func(Item *a,Item *b,Item *c,Item *d);
85
 
  
86
 
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
 
75
  Item_func(Item *a):
 
76
    _session(*current_session),
 
77
    allowed_arg_cols(1), arg_count(1)
 
78
  {
 
79
    args= tmp_arg;
 
80
    args[0]= a;
 
81
    with_sum_func= a->with_sum_func;
 
82
  }
 
83
  
 
84
  Item_func(Item *a,Item *b):
 
85
    _session(*current_session),
 
86
    allowed_arg_cols(1), arg_count(2)
 
87
  {
 
88
    args= tmp_arg;
 
89
    args[0]= a; args[1]= b;
 
90
    with_sum_func= a->with_sum_func || b->with_sum_func;
 
91
  }
 
92
  
 
93
  Item_func(Item *a,Item *b,Item *c):
 
94
    _session(*current_session),
 
95
    allowed_arg_cols(1)
 
96
  {
 
97
    arg_count= 0;
 
98
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
 
99
    {
 
100
      arg_count= 3;
 
101
      args[0]= a; args[1]= b; args[2]= c;
 
102
      with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
 
103
    }
 
104
  }
 
105
  
 
106
  Item_func(Item *a,Item *b,Item *c,Item *d):
 
107
    _session(*current_session),
 
108
    allowed_arg_cols(1)
 
109
  {
 
110
    arg_count= 0;
 
111
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
 
112
    {
 
113
      arg_count= 4;
 
114
      args[0]= a; args[1]= b; args[2]= c; args[3]= d;
 
115
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
116
        c->with_sum_func || d->with_sum_func;
 
117
    }
 
118
  }
 
119
  
 
120
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
 
121
    _session(*current_session),
 
122
    allowed_arg_cols(1)
 
123
  {
 
124
    arg_count= 5;
 
125
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
 
126
    {
 
127
      args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
 
128
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
129
        c->with_sum_func || d->with_sum_func || e->with_sum_func ;
 
130
    }
 
131
  }
87
132
  
88
133
  Item_func(List<Item> &list);
89
134
  
109
154
    {Sum}Functype and Item_func::functype()/Item_sum::sum_func()
110
155
    instead.
111
156
  */
112
 
  virtual const char *func_name() const { return NULL; }
 
157
  virtual const char *func_name() const { return NULL; };
113
158
  virtual bool const_item() const { return const_item_cache; }
114
159
  Item **arguments() const { return args; }
115
160
  void set_arguments(List<Item> &list);
132
177
  void count_real_length();
133
178
  void count_decimal_length();
134
179
 
135
 
  bool get_arg0_date(type::Time &ltime, uint32_t fuzzy_date);
136
 
  bool get_arg0_time(type::Time &ltime);
 
180
  bool get_arg0_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
 
181
  bool get_arg0_time(DRIZZLE_TIME *ltime);
137
182
 
138
183
  bool is_null();
139
184
 
140
 
  virtual bool deterministic() const
141
 
  {
142
 
    return false;
143
 
  }
144
 
 
145
185
  void signal_divide_by_null();
146
186
 
147
187
  virtual Field *tmp_table_field() { return result_field; }
149
189
 
150
190
  Item *get_tmp_table_item(Session *session);
151
191
 
152
 
  type::Decimal *val_decimal(type::Decimal *);
 
192
  my_decimal *val_decimal(my_decimal *);
153
193
 
154
194
  bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,
155
195
                          uint32_t flags);