drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
minus.cc
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008 Sun Microsystems, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <config.h>
21
22#include <drizzled/function/math/minus.h>
23#include <drizzled/type/decimal.h>
24
25namespace drizzled
26{
27
32
34{
35 Item_num_op::fix_length_and_dec();
36 if (unsigned_flag)
37 unsigned_flag= 0;
38}
39
40
42{
43 double value= args[0]->val_real() - args[1]->val_real();
44 if ((null_value=args[0]->null_value || args[1]->null_value))
45 return 0.0;
46 return fix_result(value);
47}
48
49
51{
52 int64_t value=args[0]->val_int() - args[1]->val_int();
53 if ((null_value=args[0]->null_value || args[1]->null_value))
54 return 0;
55 return value;
56}
57
61
63{
64 type::Decimal value1, *val1;
65 type::Decimal value2, *val2=
66
67 val1= args[0]->val_decimal(&value1);
68 if ((null_value= args[0]->null_value))
69 return 0;
70 val2= args[1]->val_decimal(&value2);
71 if (!(null_value= (args[1]->null_value ||
72 (class_decimal_sub(E_DEC_FATAL_ERROR, decimal_value, val1,
73 val2) > 3))))
74 return decimal_value;
75 return 0;
76}
77
78} /* namespace drizzled */
type::Decimal * decimal_op(type::Decimal *)
Definition minus.cc:62
int64_t int_op()
Performs the operation that this functions implements when the result type is INT.
Definition minus.cc:50
double real_op()
Performs the operation that this functions implements when the result type is REAL.
Definition minus.cc:41
bool null_value
Definition item.h:124
TODO: Rename this file - func.h is stupid.