~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/min_max.cc

  • Committer: Brian Aker
  • Date: 2010-12-08 22:35:56 UTC
  • mfrom: (1819.9.158 update-innobase)
  • Revision ID: brian@tangent.org-20101208223556-37mi4omqg7lkjzf3
Merge in Stewart's changes, 1.3 changes.

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 <drizzled/server_includes.h>
21
 
#include CSTDINT_H
22
 
#include <drizzled/functions/min_max.h>
 
20
#include "config.h"
 
21
 
 
22
#include <drizzled/function/min_max.h>
23
23
#include <drizzled/item/cmpfunc.h>
24
24
 
 
25
namespace drizzled
 
26
{
 
27
 
25
28
void Item_func_min_max::fix_length_and_dec()
26
29
{
27
30
  int max_int_part=0;
51
54
    agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1);
52
55
    if (datetime_found)
53
56
    {
54
 
      session= current_session;
 
57
      session= getSessionPtr();
55
58
      compare_as_dates= true;
56
59
    }
57
60
  }
76
79
    stored to the value pointer, if latter is provided.
77
80
 
78
81
  RETURN
79
 
   0    If one of arguments is NULL
 
82
   0    If one of arguments is NULL or there was a execution error
80
83
   #    index of the least/greatest argument
81
84
*/
82
85
 
88
91
  for (uint32_t i=0; i < arg_count ; i++)
89
92
  {
90
93
    Item **arg= args + i;
91
 
    bool is_null;
92
 
    uint64_t res= get_datetime_value(session, &arg, 0, datetime_item, &is_null);
 
94
    bool is_null_unused;
 
95
    uint64_t res= get_datetime_value(session, &arg, 0, datetime_item,
 
96
                                     &is_null_unused);
 
97
 
 
98
    /* Check if we need to stop (because of error or KILL)  and stop the loop */
 
99
    if (session->is_error())
 
100
    {
 
101
      null_value= 1;
 
102
      return 0;
 
103
    }
 
104
 
93
105
    if ((null_value= args[i]->null_value))
94
106
      return 0;
95
107
    if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
118
130
    if (null_value)
119
131
      return 0;
120
132
    str_res= args[min_max_idx]->val_str(str);
 
133
    if (args[min_max_idx]->null_value)
 
134
    {
 
135
      // check if the call to val_str() above returns a NULL value
 
136
      null_value= 1;
 
137
      return NULL;
 
138
    }
121
139
    str_res->set_charset(collation.collation);
122
140
    return str_res;
123
141
  }
142
160
  {
143
161
    double nr= val_real();
144
162
    if (null_value)
145
 
      return 0; /* purecov: inspected */
 
163
      return 0;
146
164
    str->set_real(nr,decimals,&my_charset_bin);
147
165
    return str;
148
166
  }
275
293
  return res;
276
294
}
277
295
 
 
296
} /* namespace drizzled */