~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.cc

  • Committer: Lee Bieber
  • Date: 2011-02-11 20:30:05 UTC
  • mfrom: (2157.1.3 build)
  • Revision ID: kalebral@gmail.com-20110211203005-757o1y2yf78dxzqr
Merge Stewart - 716848: drizzleimport displays wrong program_name
Merge Stewart - update README file
Merge Andrew and Joe - Exposes the InnoDB SYS_REPLICATION_LOG to data_dictionary so that it is fast and fixes many issues we have been having

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
22
 
#include <drizzled/check_stack_overrun.h>
23
 
#include <drizzled/current_session.h>
24
 
#include <drizzled/error.h>
 
20
#include "config.h"
 
21
 
 
22
#include <drizzled/sql_string.h>
 
23
#include <drizzled/sql_list.h>
 
24
 
 
25
#include <drizzled/function/math/int.h>
 
26
#include <drizzled/field/int32.h>
 
27
#include <drizzled/field/int64.h>
25
28
#include <drizzled/field/decimal.h>
26
29
#include <drizzled/field/double.h>
27
 
#include <drizzled/field/int32.h>
28
 
#include <drizzled/field/int64.h>
29
30
#include <drizzled/field/size.h>
30
 
#include <drizzled/function/math/int.h>
31
31
#include <drizzled/session.h>
32
 
#include <drizzled/sql_list.h>
33
 
#include <drizzled/sql_string.h>
34
 
 
 
32
#include <drizzled/error.h>
 
33
#include <drizzled/check_stack_overrun.h>
35
34
#include <limits>
36
35
#include <algorithm>
37
36
 
41
40
{
42
41
 
43
42
 
44
 
Item_func::Item_func(void):
45
 
  _session(*current_session),
46
 
  allowed_arg_cols(1), arg_count(0),
47
 
  const_item_cache(false)
48
 
  {
49
 
    with_sum_func= 0;
50
 
    collation.set(DERIVATION_SYSCONST);
51
 
  }
52
 
 
53
 
Item_func::Item_func(Item *a):
54
 
  _session(*current_session),
55
 
  allowed_arg_cols(1), arg_count(1),
56
 
  const_item_cache(false)
57
 
  {
58
 
    args= tmp_arg;
59
 
    args[0]= a;
60
 
    with_sum_func= a->with_sum_func;
61
 
    collation.set(DERIVATION_SYSCONST);
62
 
  }
63
 
 
64
 
Item_func::Item_func(Item *a,Item *b):
65
 
  _session(*current_session),
66
 
  allowed_arg_cols(1), arg_count(2),
67
 
  const_item_cache(false)
68
 
  {
69
 
    args= tmp_arg;
70
 
    args[0]= a; args[1]= b;
71
 
    with_sum_func= a->with_sum_func || b->with_sum_func;
72
 
    collation.set(DERIVATION_SYSCONST);
73
 
  }
74
 
 
75
 
Item_func::Item_func(Item *a,Item *b,Item *c):
76
 
  _session(*current_session),
77
 
  allowed_arg_cols(1),
78
 
  const_item_cache(false)
79
 
  {
80
 
    arg_count= 0;
81
 
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
82
 
    {
83
 
      arg_count= 3;
84
 
      args[0]= a; args[1]= b; args[2]= c;
85
 
      with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
86
 
    }
87
 
    collation.set(DERIVATION_SYSCONST);
88
 
  }
89
 
 
90
 
Item_func::Item_func(Item *a,Item *b,Item *c,Item *d):
91
 
  _session(*current_session),
92
 
  allowed_arg_cols(1),
93
 
  const_item_cache(false)
94
 
  {
95
 
    arg_count= 0;
96
 
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
97
 
    {
98
 
      arg_count= 4;
99
 
      args[0]= a; args[1]= b; args[2]= c; args[3]= d;
100
 
      with_sum_func= a->with_sum_func || b->with_sum_func ||
101
 
        c->with_sum_func || d->with_sum_func;
102
 
    }
103
 
    collation.set(DERIVATION_SYSCONST);
104
 
  }
105
 
 
106
 
Item_func::Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
107
 
  _session(*current_session),
108
 
  allowed_arg_cols(1),
109
 
  const_item_cache(false)
110
 
  {
111
 
    arg_count= 5;
112
 
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
113
 
    {
114
 
      args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
115
 
      with_sum_func= a->with_sum_func || b->with_sum_func ||
116
 
        c->with_sum_func || d->with_sum_func || e->with_sum_func ;
117
 
    }
118
 
    collation.set(DERIVATION_SYSCONST);
119
 
  }
120
 
 
121
 
 
122
43
void Item_func::set_arguments(List<Item> &list)
123
44
{
124
45
  allowed_arg_cols= 1;
126
47
  args= tmp_arg;                                // If 2 arguments
127
48
  if (arg_count <= 2 || (args=(Item**) memory::sql_alloc(sizeof(Item*)*arg_count)))
128
49
  {
129
 
    List<Item>::iterator li(list.begin());
 
50
    List_iterator_fast<Item> li(list);
130
51
    Item *item;
131
52
    Item **save_args= args;
132
53
 
136
57
      with_sum_func|=item->with_sum_func;
137
58
    }
138
59
  }
139
 
  list.clear();          // Fields are used
 
60
  list.empty();          // Fields are used
140
61
}
141
62
 
142
63
Item_func::Item_func(List<Item> &list) :
163
84
      args= tmp_arg;
164
85
    else
165
86
    {
166
 
      if (!(args=(Item**) session->getMemRoot()->allocate(sizeof(Item*)*arg_count)))
 
87
      if (!(args=(Item**) session->alloc(sizeof(Item*)*arg_count)))
167
88
        return;
168
89
    }
169
90
    memcpy(args, item->args, sizeof(Item*)*arg_count);