~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/str/format.cc

  • Committer: Stewart Smith
  • Date: 2010-06-16 14:17:58 UTC
  • mto: (1626.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 1633.
  • Revision ID: stewart@flamingspork.com-20100616141758-odpf36m0wo09ok4c
add handler_write status variable test for when statement was rolled back

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, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
#include "format.h"
 
20
#include "config.h"
 
21
#include <drizzled/function/str/format.h>
22
22
 
23
23
#include <limits>
24
24
 
25
 
#include <drizzled/charset_info.h>
26
 
#include <drizzled/type/decimal.h>
27
 
#include <drizzled/table.h>
28
 
 
29
25
using namespace std;
30
26
 
31
27
namespace drizzled
39
35
 
40
36
const int FORMAT_MAX_DECIMALS= 30;
41
37
 
 
38
Item_func_format::Item_func_format(Item *org, Item *dec)
 
39
: Item_str_func(org, dec)
 
40
{
 
41
}
 
42
 
42
43
void Item_func_format::fix_length_and_dec()
43
44
{
44
45
  collation.set(default_charset());
79
80
  if (args[0]->result_type() == DECIMAL_RESULT ||
80
81
      args[0]->result_type() == INT_RESULT)
81
82
  {
82
 
    type::Decimal dec_val, rnd_dec, *res;
 
83
    my_decimal dec_val, rnd_dec, *res;
83
84
    res= args[0]->val_decimal(&dec_val);
84
85
    if ((null_value=args[0]->null_value))
85
86
      return 0;
86
 
    class_decimal_round(E_DEC_FATAL_ERROR, res, dec, false, &rnd_dec);
87
 
    class_decimal2string(&rnd_dec, 0, str);
 
87
    my_decimal_round(E_DEC_FATAL_ERROR, res, dec, false, &rnd_dec);
 
88
    my_decimal2string(E_DEC_FATAL_ERROR, &rnd_dec, 0, 0, 0, str);
88
89
    str_length= str->length();
89
90
    if (rnd_dec.sign())
90
91
      str_length--;