1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
4
* Copyright (C) 2008 Sun Microsystems, Inc.
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"
32
33
class Item_func :public Item_result_field
35
38
Item **args, *tmp_arg[2];
61
64
enum Type type() const { return FUNC_ITEM; }
62
65
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
63
66
virtual ~Item_func() {}
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)
74
collation.set(DERIVATION_SYSCONST);
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)
74
84
with_sum_func= a->with_sum_func;
85
collation.set(DERIVATION_SYSCONST);
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)
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);
83
99
Item_func(Item *a,Item *b,Item *c):
100
_session(*current_session),
102
const_item_cache(false)
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;
111
collation.set(DERIVATION_SYSCONST);
94
114
Item_func(Item *a,Item *b,Item *c,Item *d):
115
_session(*current_session),
117
const_item_cache(false)
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;
127
collation.set(DERIVATION_SYSCONST);
106
130
Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
131
_session(*current_session),
133
const_item_cache(false)
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 ;
142
collation.set(DERIVATION_SYSCONST);
117
145
Item_func(List<Item> &list);
118
147
// Constructor used for Item_cond_and/or (see Item comment)
119
148
Item_func(Session *session, Item_func *item);
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()
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();
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);
197
virtual bool deterministic() const
167
202
void signal_divide_by_null();
169
204
virtual Field *tmp_table_field() { return result_field; }
172
207
Item *get_tmp_table_item(Session *session);
174
my_decimal *val_decimal(my_decimal *);
209
type::Decimal *val_decimal(type::Decimal *);
176
211
bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,