~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/sum.cc

  • Committer: Brian Aker
  • Date: 2011-01-18 07:21:16 UTC
  • mfrom: (2079.3.3 session-fix)
  • Revision ID: brian@tangent.org-20110118072116-nuflltzguzhq9rgg
Merge in update so that test-run.pl runs all of test/suite and fix for
create table like and FK.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <drizzled/field/date.h>
38
38
#include <drizzled/field/datetime.h>
39
39
 
40
 
#include <drizzled/type/decimal.h>
41
 
 
42
40
#include "drizzled/internal/m_string.h"
43
41
 
44
42
#include <algorithm>
48
46
namespace drizzled
49
47
{
50
48
 
 
49
extern type::Decimal decimal_zero;
51
50
extern plugin::StorageEngine *heap_engine;
52
51
 
53
52
/**
420
419
 
421
420
void Item_sum::mark_as_sum_func()
422
421
{
423
 
  Select_Lex *cur_select= getSession().getLex()->current_select;
 
422
  Select_Lex *cur_select= current_session->lex->current_select;
424
423
  cur_select->n_sum_items++;
425
424
  cur_select->with_sum_func= 1;
426
425
  with_sum_func= 1;
724
723
  {
725
724
    field= ((Item_field*) args[0])->field;
726
725
 
727
 
    if ((field= create_tmp_field_from_field(&getSession(), field, name, table,
 
726
    if ((field= create_tmp_field_from_field(current_session, field, name, table,
728
727
                                            NULL, convert_blob_length)))
729
728
      field->flags&= ~NOT_NULL_FLAG;
730
729
    return field;
745
744
  default:
746
745
    return Item_sum::create_tmp_field(group, table, convert_blob_length);
747
746
  }
748
 
 
749
747
  if (field)
750
748
    field->init(table);
751
 
 
752
749
  return field;
753
750
}
754
751
 
1165
1162
Item_sum_avg_distinct::fix_length_and_dec()
1166
1163
{
1167
1164
  Item_sum_distinct::fix_length_and_dec();
1168
 
  prec_increment= getSession().variables.div_precincrement;
 
1165
  prec_increment= current_session->variables.div_precincrement;
1169
1166
  /*
1170
1167
    AVG() will divide val by count. We need to reserve digits
1171
1168
    after decimal point as the result can be fractional.
1228
1225
{
1229
1226
  Item_sum_sum::fix_length_and_dec();
1230
1227
  maybe_null=null_value=1;
1231
 
  prec_increment= getSession().variables.div_precincrement;
1232
 
 
 
1228
  prec_increment= current_session->variables.div_precincrement;
1233
1229
  if (hybrid_type == DECIMAL_RESULT)
1234
1230
  {
1235
1231
    int precision= args[0]->decimal_precision() + prec_increment;
1426
1422
void Item_sum_variance::fix_length_and_dec()
1427
1423
{
1428
1424
  maybe_null= null_value= 1;
1429
 
  prec_increment= getSession().variables.div_precincrement;
 
1425
  prec_increment= current_session->variables.div_precincrement;
1430
1426
 
1431
1427
  /*
1432
1428
    According to the SQL2003 standard (Part 2, Foundations; sec 10.9,
1711
1707
    str->set_real(sum,decimals, &my_charset_bin);
1712
1708
    break;
1713
1709
  case DECIMAL_RESULT:
1714
 
    class_decimal2string(&sum_dec, 0, str);
 
1710
    class_decimal2string(E_DEC_FATAL_ERROR, &sum_dec, 0, 0, 0, str);
1715
1711
    return str;
1716
1712
  case INT_RESULT:
1717
1713
    str->set_int(sum_int, unsigned_flag, &my_charset_bin);
3051
3047
  {
3052
3048
    char warn_buff[DRIZZLE_ERRMSG_SIZE];
3053
3049
    snprintf(warn_buff, sizeof(warn_buff), ER(ER_CUT_VALUE_GROUP_CONCAT), count_cut_values);
3054
 
    warning->set_msg(&getSession(), warn_buff);
 
3050
    warning->set_msg(current_session, warn_buff);
3055
3051
    warning= 0;
3056
3052
  }
3057
3053