~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.h

  • Committer: Andrew Hutchings
  • Date: 2011-01-21 11:23:19 UTC
  • mto: (2100.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2101.
  • Revision ID: andrew@linuxjedi.co.uk-20110121112319-nj1cvg0yt3nnf2rr
Add errors page to drizzle client docs
Add link to specific error in migration docs
Minor changes to migration docs

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
25
25
#include <drizzled/item.h>
26
26
#include <drizzled/sql_list.h>
27
27
#include <drizzled/item/bin_string.h>
 
28
#include "drizzled/current_session.h"
28
29
 
29
30
namespace drizzled
30
31
{
31
32
 
32
33
class Item_func :public Item_result_field
33
34
{
 
35
  Session &_session;
 
36
 
34
37
protected:
35
38
  Item **args, *tmp_arg[2];
36
39
  /*
61
64
  enum Type type() const { return FUNC_ITEM; }
62
65
  virtual enum Functype functype() const   { return UNKNOWN_FUNC; }
63
66
  virtual ~Item_func() {}
 
67
 
64
68
  Item_func(void):
65
 
    allowed_arg_cols(1), arg_count(0)
 
69
    _session(*current_session),
 
70
    allowed_arg_cols(1), arg_count(0),
 
71
    const_item_cache(false)
66
72
  {
67
73
    with_sum_func= 0;
 
74
    collation.set(DERIVATION_SYSCONST);
68
75
  }
 
76
 
69
77
  Item_func(Item *a):
70
 
    allowed_arg_cols(1), arg_count(1)
 
78
    _session(*current_session),
 
79
    allowed_arg_cols(1), arg_count(1),
 
80
    const_item_cache(false)
71
81
  {
72
82
    args= tmp_arg;
73
83
    args[0]= a;
74
84
    with_sum_func= a->with_sum_func;
 
85
    collation.set(DERIVATION_SYSCONST);
75
86
  }
 
87
  
76
88
  Item_func(Item *a,Item *b):
77
 
    allowed_arg_cols(1), arg_count(2)
 
89
    _session(*current_session),
 
90
    allowed_arg_cols(1), arg_count(2),
 
91
    const_item_cache(false)
78
92
  {
79
93
    args= tmp_arg;
80
94
    args[0]= a; args[1]= b;
81
95
    with_sum_func= a->with_sum_func || b->with_sum_func;
 
96
    collation.set(DERIVATION_SYSCONST);
82
97
  }
 
98
  
83
99
  Item_func(Item *a,Item *b,Item *c):
84
 
    allowed_arg_cols(1)
 
100
    _session(*current_session),
 
101
    allowed_arg_cols(1),
 
102
    const_item_cache(false)
85
103
  {
86
104
    arg_count= 0;
87
105
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
90
108
      args[0]= a; args[1]= b; args[2]= c;
91
109
      with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
92
110
    }
 
111
    collation.set(DERIVATION_SYSCONST);
93
112
  }
 
113
  
94
114
  Item_func(Item *a,Item *b,Item *c,Item *d):
95
 
    allowed_arg_cols(1)
 
115
    _session(*current_session),
 
116
    allowed_arg_cols(1),
 
117
    const_item_cache(false)
96
118
  {
97
119
    arg_count= 0;
98
120
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
102
124
      with_sum_func= a->with_sum_func || b->with_sum_func ||
103
125
        c->with_sum_func || d->with_sum_func;
104
126
    }
 
127
    collation.set(DERIVATION_SYSCONST);
105
128
  }
 
129
  
106
130
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
107
 
    allowed_arg_cols(1)
 
131
    _session(*current_session),
 
132
    allowed_arg_cols(1),
 
133
    const_item_cache(false)
108
134
  {
109
135
    arg_count= 5;
110
136
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
113
139
      with_sum_func= a->with_sum_func || b->with_sum_func ||
114
140
        c->with_sum_func || d->with_sum_func || e->with_sum_func ;
115
141
    }
 
142
    collation.set(DERIVATION_SYSCONST);
116
143
  }
 
144
  
117
145
  Item_func(List<Item> &list);
 
146
  
118
147
  // Constructor used for Item_cond_and/or (see Item comment)
119
148
  Item_func(Session *session, Item_func *item);
 
149
  
120
150
  bool fix_fields(Session *, Item **ref);
121
151
  void fix_after_pullout(Select_Lex *new_parent, Item **ref);
122
152
  table_map used_tables() const;
136
166
    {Sum}Functype and Item_func::functype()/Item_sum::sum_func()
137
167
    instead.
138
168
  */
139
 
  virtual const char *func_name() const { return NULL; };
 
169
  virtual const char *func_name() const { return NULL; }
140
170
  virtual bool const_item() const { return const_item_cache; }
141
171
  Item **arguments() const { return args; }
142
172
  void set_arguments(List<Item> &list);
159
189
  void count_real_length();
160
190
  void count_decimal_length();
161
191
 
162
 
  bool get_arg0_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
163
 
  bool get_arg0_time(DRIZZLE_TIME *ltime);
 
192
  bool get_arg0_date(type::Time *ltime, uint32_t fuzzy_date);
 
193
  bool get_arg0_time(type::Time *ltime);
164
194
 
165
195
  bool is_null();
166
196
 
 
197
  virtual bool deterministic() const
 
198
  {
 
199
    return false;
 
200
  }
 
201
 
167
202
  void signal_divide_by_null();
168
203
 
169
204
  virtual Field *tmp_table_field() { return result_field; }
171
206
 
172
207
  Item *get_tmp_table_item(Session *session);
173
208
 
174
 
  my_decimal *val_decimal(my_decimal *);
 
209
  type::Decimal *val_decimal(type::Decimal *);
175
210
 
176
211
  bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,
177
212
                          uint32_t flags);
188
223
                     void * arg, traverse_order order);
189
224
  double fix_result(double value);
190
225
 
 
226
  Session &getSession()
 
227
  {
 
228
    return _session;
 
229
  }
 
230
 
 
231
  Session *getSessionPtr()
 
232
  {
 
233
    return &_session;
 
234
  }
 
235
 
191
236
};
192
237
 
193
238
} /* namespace drizzled */