~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.h

  • Committer: Monty Taylor
  • Date: 2011-01-26 19:15:55 UTC
  • mto: This revision was merged to the branch mainline in revision 2126.
  • Revision ID: mordred@inaugust.com-20110126191555-nq5nnzyscvngsip2
Turns on -fvisibility=hidden by default. Symbols intended to be used by
plugins need to be marked with DRIZZLED_API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
 
21
21
 
22
 
#pragma once
 
22
#ifndef DRIZZLED_FUNCTION_FUNC_H
 
23
#define DRIZZLED_FUNCTION_FUNC_H
23
24
 
24
25
/// TODO: Rename this file - func.h is stupid.
25
26
 
26
 
#include <drizzled/charset.h>
27
27
#include <drizzled/item.h>
 
28
#include <drizzled/sql_list.h>
28
29
#include <drizzled/item/bin_string.h>
29
 
#include <drizzled/lex_string.h>
30
 
#include <drizzled/sql_list.h>
31
 
#include <drizzled/type/decimal.h>
 
30
#include "drizzled/current_session.h"
32
31
 
33
 
#include <drizzled/visibility.h>
 
32
#include "drizzled/visibility.h"
34
33
 
35
34
namespace drizzled
36
35
{
37
36
 
38
 
class DRIZZLED_API Item_func : public Item_result_field
 
37
class DRIZZLED_API Item_func :
 
38
  public Item_result_field
39
39
{
 
40
  Session &_session;
 
41
 
40
42
protected:
41
43
  Item **args, *tmp_arg[2];
42
44
  /*
44
46
    0 means get this number from first argument
45
47
  */
46
48
  uint32_t allowed_arg_cols;
47
 
 
48
49
public:
49
50
 
50
51
  using Item::split_sum_func;
69
70
  virtual enum Functype functype() const   { return UNKNOWN_FUNC; }
70
71
  virtual ~Item_func() {}
71
72
 
72
 
  Item_func(void);
 
73
  Item_func(void):
 
74
    _session(*current_session),
 
75
    allowed_arg_cols(1), arg_count(0),
 
76
    const_item_cache(false)
 
77
  {
 
78
    with_sum_func= 0;
 
79
    collation.set(DERIVATION_SYSCONST);
 
80
  }
73
81
 
74
 
  Item_func(Item *a);
75
 
  
76
 
  Item_func(Item *a,Item *b);
77
 
  
78
 
  Item_func(Item *a,Item *b,Item *c);
79
 
  
80
 
  Item_func(Item *a,Item *b,Item *c,Item *d);
81
 
  
82
 
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
 
82
  Item_func(Item *a):
 
83
    _session(*current_session),
 
84
    allowed_arg_cols(1), arg_count(1),
 
85
    const_item_cache(false)
 
86
  {
 
87
    args= tmp_arg;
 
88
    args[0]= a;
 
89
    with_sum_func= a->with_sum_func;
 
90
    collation.set(DERIVATION_SYSCONST);
 
91
  }
 
92
  
 
93
  Item_func(Item *a,Item *b):
 
94
    _session(*current_session),
 
95
    allowed_arg_cols(1), arg_count(2),
 
96
    const_item_cache(false)
 
97
  {
 
98
    args= tmp_arg;
 
99
    args[0]= a; args[1]= b;
 
100
    with_sum_func= a->with_sum_func || b->with_sum_func;
 
101
    collation.set(DERIVATION_SYSCONST);
 
102
  }
 
103
  
 
104
  Item_func(Item *a,Item *b,Item *c):
 
105
    _session(*current_session),
 
106
    allowed_arg_cols(1),
 
107
    const_item_cache(false)
 
108
  {
 
109
    arg_count= 0;
 
110
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
 
111
    {
 
112
      arg_count= 3;
 
113
      args[0]= a; args[1]= b; args[2]= c;
 
114
      with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
 
115
    }
 
116
    collation.set(DERIVATION_SYSCONST);
 
117
  }
 
118
  
 
119
  Item_func(Item *a,Item *b,Item *c,Item *d):
 
120
    _session(*current_session),
 
121
    allowed_arg_cols(1),
 
122
    const_item_cache(false)
 
123
  {
 
124
    arg_count= 0;
 
125
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
 
126
    {
 
127
      arg_count= 4;
 
128
      args[0]= a; args[1]= b; args[2]= c; args[3]= d;
 
129
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
130
        c->with_sum_func || d->with_sum_func;
 
131
    }
 
132
    collation.set(DERIVATION_SYSCONST);
 
133
  }
 
134
  
 
135
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
 
136
    _session(*current_session),
 
137
    allowed_arg_cols(1),
 
138
    const_item_cache(false)
 
139
  {
 
140
    arg_count= 5;
 
141
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
 
142
    {
 
143
      args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
 
144
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
145
        c->with_sum_func || d->with_sum_func || e->with_sum_func ;
 
146
    }
 
147
    collation.set(DERIVATION_SYSCONST);
 
148
  }
83
149
  
84
150
  Item_func(List<Item> &list);
85
151
  
120
186
  virtual void split_sum_func(Session *session, Item **ref_pointer_array,
121
187
                              List<Item> &fields);
122
188
 
123
 
  virtual void print(String *str);
124
 
  void print_op(String *str);
125
 
  void print_args(String *str, uint32_t from);
 
189
  virtual void print(String *str, enum_query_type query_type);
 
190
  void print_op(String *str, enum_query_type query_type);
 
191
  void print_args(String *str, uint32_t from, enum_query_type query_type);
126
192
  virtual void fix_num_length_and_dec();
127
193
  void count_only_length();
128
194
  void count_real_length();
161
227
  void traverse_cond(Cond_traverser traverser,
162
228
                     void * arg, traverse_order order);
163
229
  double fix_result(double value);
 
230
 
 
231
  Session &getSession()
 
232
  {
 
233
    return _session;
 
234
  }
 
235
 
 
236
  Session *getSessionPtr()
 
237
  {
 
238
    return &_session;
 
239
  }
 
240
 
164
241
};
165
242
 
166
243
} /* namespace drizzled */
167
244
 
168
245
 
 
246
#endif /* DRIZZLED_FUNCTION_FUNC_H */