~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/sum.h

  • Committer: Stewart Smith
  • Author(s): Marko Mäkelä, Stewart Smith
  • Date: 2010-11-17 05:52:09 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1971.
  • Revision ID: stewart@flamingspork.com-20101117055209-69m035q6h7e1txrc
Merge Revision revid:marko.makela@oracle.com-20100629113248-fvl48lnzr44z94gg from MySQL InnoDB

Original revid:marko.makela@oracle.com-20100629113248-fvl48lnzr44z94gg

Original Authors: Marko Mkel <marko.makela@oracle.com>
Original commit message:
Bug#52199 utf32: mbminlen=4, mbmaxlen=4, type->mbminlen=0, type->mbmaxlen=4

Merge and adjust a forgotten change to fix this bug.
rb://393 approved by Jimmy Yang
  ------------------------------------------------------------------------
  r3794 | marko | 2009-01-07 14:14:53 +0000 (Wed, 07 Jan 2009) | 18 lines

  branches/6.0: Allow the minimum length of a multi-byte character to be
  up to 4 bytes. (Bug #35391)

  dtype_t, dict_col_t: Replace mbminlen:2, mbmaxlen:3 with mbminmaxlen:5.
  In this way, the 5 bits can hold two values of 0..4, and the storage size
  of the fields will not cross the 64-bit boundary.  Encode the values as
  DATA_MBMAX * mbmaxlen + mbminlen.  Define the auxiliary macros
  DB_MBMINLEN(mbminmaxlen), DB_MBMAXLEN(mbminmaxlen), and
  DB_MINMAXLEN(mbminlen, mbmaxlen).

  Try to trim and pad UTF-16 and UTF-32 with spaces as appropriate.

  Alexander Barkov suggested the use of cs->cset->fill(cs, buff, len, 0x20).
  ha_innobase::store_key_val_for_row() now does that, but the added function
  row_mysql_pad_col() does not, because it doesn't have the MySQL TABLE object.

  rb://49 approved by Heikki Tuuri
  ------------------------------------------------------------------------

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
22
22
 
23
23
/* classes for sum functions */
24
24
 
 
25
 
25
26
#include "drizzled/tree.h"
26
27
#include <drizzled/hybrid_type.h>
27
28
#include <drizzled/item.h>
28
29
#include <drizzled/item/field.h>
29
30
#include <drizzled/item/bin_string.h>
30
 
#include <drizzled/charset_info.h>
31
31
 
32
32
namespace drizzled
33
33
{
416
416
  bool fix_fields(Session *, Item **);
417
417
  int64_t val_int();
418
418
  String *val_str(String*str);
419
 
  type::Decimal *val_decimal(type::Decimal *);
 
419
  my_decimal *val_decimal(my_decimal *);
420
420
  void reset_field();
421
421
};
422
422
 
429
429
  Item_sum_int(Session *session, Item_sum_int *item) :Item_sum_num(session, item) {}
430
430
  double val_real() { assert(fixed == 1); return (double) val_int(); }
431
431
  String *val_str(String*str);
432
 
  type::Decimal *val_decimal(type::Decimal *);
 
432
  my_decimal *val_decimal(my_decimal *);
433
433
  enum Item_result result_type () const { return INT_RESULT; }
434
434
  void fix_length_and_dec()
435
435
  { decimals=0; max_length=21; maybe_null=null_value=0; }
441
441
protected:
442
442
  Item_result hybrid_type;
443
443
  double sum;
444
 
  type::Decimal dec_buffs[2];
 
444
  my_decimal dec_buffs[2];
445
445
  uint32_t curr_dec_buff;
446
446
  void fix_length_and_dec();
447
447
 
454
454
  double val_real();
455
455
  int64_t val_int();
456
456
  String *val_str(String*str);
457
 
  type::Decimal *val_decimal(type::Decimal *);
 
457
  my_decimal *val_decimal(my_decimal *);
458
458
  enum Item_result result_type () const { return hybrid_type; }
459
459
  void reset_field();
460
460
  void update_field();
491
491
  void cleanup();
492
492
  bool add();
493
493
  double val_real();
494
 
  type::Decimal *val_decimal(type::Decimal *);
 
494
  my_decimal *val_decimal(my_decimal *);
495
495
  int64_t val_int();
496
496
  String *val_str(String *str);
497
497
 
657
657
  enum Type type() const { return FIELD_AVG_ITEM; }
658
658
  double val_real();
659
659
  int64_t val_int();
660
 
  type::Decimal *val_decimal(type::Decimal *);
 
660
  my_decimal *val_decimal(my_decimal *);
661
661
  bool is_null() { update_null_value(); return null_value; }
662
662
  String *val_str(String*);
663
663
  enum_field_types field_type() const
689
689
  double val_real();
690
690
  // In SPs we might force the "wrong" type with select into a declare variable
691
691
  int64_t val_int();
692
 
  type::Decimal *val_decimal(type::Decimal *);
 
692
  my_decimal *val_decimal(my_decimal *);
693
693
  String *val_str(String *str);
694
694
  void reset_field();
695
695
  void update_field();
724
724
  int64_t val_int();
725
725
  String *val_str(String *str)
726
726
  { return val_string_from_real(str); }
727
 
  type::Decimal *val_decimal(type::Decimal *dec_buf)
 
727
  my_decimal *val_decimal(my_decimal *dec_buf)
728
728
  { return val_decimal_from_real(dec_buf); }
729
729
  bool is_null() { update_null_value(); return null_value; }
730
730
  enum_field_types field_type() const
781
781
  bool add();
782
782
  double val_real();
783
783
  int64_t val_int();
784
 
  type::Decimal *val_decimal(type::Decimal *);
 
784
  my_decimal *val_decimal(my_decimal *);
785
785
  void reset_field();
786
786
  void update_field();
787
787
  Item *result_item(Field *)
807
807
  Item_std_field(Item_sum_std *item);
808
808
  enum Type type() const { return FIELD_STD_ITEM; }
809
809
  double val_real();
810
 
  type::Decimal *val_decimal(type::Decimal *);
 
810
  my_decimal *val_decimal(my_decimal *);
811
811
  enum Item_result result_type () const { return REAL_RESULT; }
812
812
  enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE;}
813
813
};
842
842
  String value,tmp_value;
843
843
  double sum;
844
844
  int64_t sum_int;
845
 
  type::Decimal sum_dec;
 
845
  my_decimal sum_dec;
846
846
  Item_result hybrid_type;
847
847
  enum_field_types hybrid_field_type;
848
848
  int cmp_sign;
859
859
  void clear();
860
860
  double val_real();
861
861
  int64_t val_int();
862
 
  type::Decimal *val_decimal(type::Decimal *);
 
862
  my_decimal *val_decimal(my_decimal *);
863
863
  void reset_field();
864
864
  String *val_str(String *);
865
865
  bool keep_field_type(void) const { return 1; }
1035
1035
  void make_unique();
1036
1036
  double val_real();
1037
1037
  int64_t val_int();
1038
 
  type::Decimal *val_decimal(type::Decimal *decimal_value)
 
1038
  my_decimal *val_decimal(my_decimal *decimal_value)
1039
1039
  {
1040
1040
    return val_decimal_from_string(decimal_value);
1041
1041
  }