~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/functions/num1.cc

  • Committer: Brian Aker
  • Date: 2008-10-13 16:50:30 UTC
  • mfrom: (509.1.4 codestyle)
  • Revision ID: brian@tangent.org-20081013165030-642le57opeglwfdw
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
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 <drizzled/server_includes.h>
 
21
 
 
22
#include CSTDINT_H
 
23
#include <cassert>
 
24
 
 
25
#include <drizzled/functions/num1.h>
 
26
 
 
27
/**
 
28
  Set result type for a numeric function of one argument
 
29
  (can be also used by a numeric function of many arguments, if the result
 
30
  type depends only on the first argument)
 
31
*/
 
32
 
 
33
void Item_func_num1::find_num_type()
 
34
{
 
35
  switch (hybrid_type= args[0]->result_type()) {
 
36
  case INT_RESULT:
 
37
    unsigned_flag= args[0]->unsigned_flag;
 
38
    break;
 
39
  case STRING_RESULT:
 
40
  case REAL_RESULT:
 
41
    hybrid_type= REAL_RESULT;
 
42
    max_length= float_length(decimals);
 
43
    break;
 
44
  case DECIMAL_RESULT:
 
45
    break;
 
46
  default:
 
47
    assert(0);
 
48
  }
 
49
  return;
 
50
}
 
51
 
 
52
void Item_func_num1::fix_num_length_and_dec()
 
53
{
 
54
  decimals= args[0]->decimals;
 
55
  max_length= args[0]->max_length;
 
56
}
 
57
 
 
58
 
 
59