~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.cc

  • Committer: Monty Taylor
  • Date: 2009-04-25 20:45:19 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 1003.
  • Revision ID: mordred@inaugust.com-20090425204519-lgrl7mz2r66v0jby
Blackhole.

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"
 
20
#include <drizzled/server_includes.h>
21
21
 
22
22
#include <drizzled/sql_string.h>
23
23
#include <drizzled/sql_list.h>
31
31
#include <drizzled/error.h>
32
32
#include <drizzled/check_stack_overrun.h>
33
33
#include <limits>
34
 
#include <algorithm>
35
34
 
36
35
using namespace std;
37
36
 
38
 
namespace drizzled
39
 
{
40
 
 
41
 
 
42
37
void Item_func::set_arguments(List<Item> &list)
43
38
{
44
39
  allowed_arg_cols= 1;
45
40
  arg_count=list.elements;
46
41
  args= tmp_arg;                                // If 2 arguments
47
 
  if (arg_count <= 2 || (args=(Item**) memory::sql_alloc(sizeof(Item*)*arg_count)))
 
42
  if (arg_count <= 2 || (args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
48
43
  {
49
44
    List_iterator_fast<Item> li(list);
50
45
    Item *item;
143
138
        We shouldn't call fix_fields() twice, so check 'fixed' field first
144
139
      */
145
140
      if ((!(*arg)->fixed && (*arg)->fix_fields(session, arg)))
146
 
        return true;
 
141
        return true;        /* purecov: inspected */
147
142
      item= *arg;
148
143
 
149
144
      if (allowed_arg_cols)
465
460
  case STRING_RESULT:
466
461
    return make_string_field(table);
467
462
  case DECIMAL_RESULT:
468
 
    field= new Field_decimal(my_decimal_precision_to_length(decimal_precision(),
469
 
                                                            decimals,
470
 
                                                            unsigned_flag),
471
 
                             maybe_null,
472
 
                             name,
473
 
                             decimals,
474
 
                             unsigned_flag);
 
463
    field= new Field_new_decimal(
 
464
                       my_decimal_precision_to_length(decimal_precision(),
 
465
                                                      decimals,
 
466
                                                      unsigned_flag),
 
467
                       maybe_null, name, decimals, unsigned_flag);
475
468
    break;
476
469
  case ROW_RESULT:
477
470
  default:
556
549
  int max_int_part= 0;
557
550
  decimals= 0;
558
551
  unsigned_flag= 1;
559
 
  for (uint32_t i= 0 ; i < arg_count ; i++)
 
552
  for (uint32_t i=0 ; i < arg_count ; i++)
560
553
  {
561
554
    set_if_bigger(decimals, args[i]->decimals);
562
555
    set_if_bigger(max_int_part, args[i]->decimal_int_part());
563
556
    set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
564
557
  }
565
 
  int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
 
558
  int precision= cmin(max_int_part + decimals, DECIMAL_MAX_PRECISION);
566
559
  max_length= my_decimal_precision_to_length(precision, decimals,
567
560
                                             unsigned_flag);
568
561
}
632
625
}
633
626
 
634
627
 
635
 
} /* namespace drizzled */