~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.cc

  • Committer: Jay Pipes
  • Date: 2009-02-21 16:00:06 UTC
  • mto: (907.1.1 trunk-with-temporal)
  • mto: This revision was merged to the branch mainline in revision 908.
  • Revision ID: jpipes@serialcoder-20090221160006-vnk3wt4qbcz62eru
Removes the TIME column type and related time functions.

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
using namespace std;
 
21
#include <drizzled/server_includes.h>
 
22
 
 
23
#include CSTDINT_H
 
24
#include <cassert>
21
25
 
22
26
#include <drizzled/sql_string.h>
23
27
#include <drizzled/sql_list.h>
27
31
#include <drizzled/field/long.h>
28
32
#include <drizzled/field/double.h>
29
33
#include <drizzled/field/decimal.h>
 
34
#include CMATH_H
 
35
#include <drizzled/util/math.h>
30
36
#include <drizzled/session.h>
31
37
#include <drizzled/error.h>
32
38
#include <drizzled/check_stack_overrun.h>
33
 
#include <limits>
34
 
#include <algorithm>
35
 
 
36
 
using namespace std;
37
 
 
38
 
namespace drizzled
39
 
{
 
39
 
 
40
#if defined(CMATH_NAMESPACE)
 
41
using namespace CMATH_NAMESPACE;
 
42
#endif
 
43
 
40
44
 
41
45
 
42
46
void Item_func::set_arguments(List<Item> &list)
44
48
  allowed_arg_cols= 1;
45
49
  arg_count=list.elements;
46
50
  args= tmp_arg;                                // If 2 arguments
47
 
  if (arg_count <= 2 || (args=(Item**) memory::sql_alloc(sizeof(Item*)*arg_count)))
 
51
  if (arg_count <= 2 || (args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
48
52
  {
49
53
    List_iterator_fast<Item> li(list);
50
54
    Item *item;
143
147
        We shouldn't call fix_fields() twice, so check 'fixed' field first
144
148
      */
145
149
      if ((!(*arg)->fixed && (*arg)->fix_fields(session, arg)))
146
 
        return true;
 
150
        return true;        /* purecov: inspected */
147
151
      item= *arg;
148
152
 
149
153
      if (allowed_arg_cols)
464
468
    break;
465
469
  case STRING_RESULT:
466
470
    return make_string_field(table);
 
471
    break;
467
472
  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);
 
473
    field= new Field_new_decimal(
 
474
                       my_decimal_precision_to_length(decimal_precision(),
 
475
                                                      decimals,
 
476
                                                      unsigned_flag),
 
477
                       maybe_null, name, decimals, unsigned_flag);
475
478
    break;
476
479
  case ROW_RESULT:
477
480
  default:
520
523
 
521
524
double Item_func::fix_result(double value)
522
525
{
523
 
  static double fix_infinity= numeric_limits<double>::infinity();
524
 
 
525
 
  if (value != fix_infinity && value != -fix_infinity)
 
526
  if (isfinite(value))
526
527
    return value;
527
528
  null_value=1;
528
529
  return 0.0;
556
557
  int max_int_part= 0;
557
558
  decimals= 0;
558
559
  unsigned_flag= 1;
559
 
  for (uint32_t i= 0 ; i < arg_count ; i++)
 
560
  for (uint32_t i=0 ; i < arg_count ; i++)
560
561
  {
561
562
    set_if_bigger(decimals, args[i]->decimals);
562
563
    set_if_bigger(max_int_part, args[i]->decimal_int_part());
563
564
    set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
564
565
  }
565
 
  int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
 
566
  int precision= cmin(max_int_part + decimals, DECIMAL_MAX_PRECISION);
566
567
  max_length= my_decimal_precision_to_length(precision, decimals,
567
568
                                             unsigned_flag);
568
569
}
632
633
}
633
634
 
634
635
 
635
 
} /* namespace drizzled */