~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/math_functions/ceiling.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
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
20
20
#include "config.h"
21
21
#include <math.h>
22
22
#include "ceiling.h"
 
23
#include <drizzled/type/decimal.h>
23
24
 
24
25
namespace drizzled
25
26
{
34
35
    break;
35
36
  case DECIMAL_RESULT:
36
37
  {
37
 
    my_decimal dec_buf, *dec;
 
38
    type::Decimal dec_buf, *dec;
38
39
    if ((dec= Item_func_ceiling::decimal_op(&dec_buf)))
39
 
      my_decimal2int(E_DEC_FATAL_ERROR, dec, unsigned_flag, &result);
 
40
      dec->val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &result);
40
41
    else
41
42
      result= 0;
42
43
    break;
58
59
  return ceil(value);
59
60
}
60
61
 
61
 
my_decimal *Item_func_ceiling::decimal_op(my_decimal *decimal_value)
 
62
type::Decimal *Item_func_ceiling::decimal_op(type::Decimal *decimal_value)
62
63
{
63
 
  my_decimal val, *value= args[0]->val_decimal(&val);
 
64
  type::Decimal val, *value= args[0]->val_decimal(&val);
64
65
  if (!(null_value= (args[0]->null_value ||
65
 
                     my_decimal_ceiling(E_DEC_FATAL_ERROR, value,
 
66
                     class_decimal_ceiling(E_DEC_FATAL_ERROR, value,
66
67
                                        decimal_value) > 1)))
67
68
    return decimal_value;
68
69
  return 0;