~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/sum.h

Merge refactored command line using for innodb

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
 
#include <drizzled/tree.h>
 
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
{
39
39
                                    const void* key2);
40
40
 
41
41
class Select_Lex;
42
 
struct Order;
 
42
struct order_st;
43
43
 
44
44
/*
45
45
  Class Item_sum is the base class used for special expressions that SQL calls
366
366
    forced_const= true;
367
367
  }
368
368
  virtual bool const_item() const { return forced_const; }
369
 
  virtual bool const_during_execution() const { return false; }
370
369
  void make_field(SendField *field);
371
370
  virtual void print(String *str, enum_query_type query_type);
372
371
  void fix_num_length_and_dec();
417
416
  bool fix_fields(Session *, Item **);
418
417
  int64_t val_int();
419
418
  String *val_str(String*str);
420
 
  type::Decimal *val_decimal(type::Decimal *);
 
419
  my_decimal *val_decimal(my_decimal *);
421
420
  void reset_field();
422
421
};
423
422
 
430
429
  Item_sum_int(Session *session, Item_sum_int *item) :Item_sum_num(session, item) {}
431
430
  double val_real() { assert(fixed == 1); return (double) val_int(); }
432
431
  String *val_str(String*str);
433
 
  type::Decimal *val_decimal(type::Decimal *);
 
432
  my_decimal *val_decimal(my_decimal *);
434
433
  enum Item_result result_type () const { return INT_RESULT; }
435
434
  void fix_length_and_dec()
436
435
  { decimals=0; max_length=21; maybe_null=null_value=0; }
442
441
protected:
443
442
  Item_result hybrid_type;
444
443
  double sum;
445
 
  type::Decimal dec_buffs[2];
 
444
  my_decimal dec_buffs[2];
446
445
  uint32_t curr_dec_buff;
447
446
  void fix_length_and_dec();
448
447
 
455
454
  double val_real();
456
455
  int64_t val_int();
457
456
  String *val_str(String*str);
458
 
  type::Decimal *val_decimal(type::Decimal *);
 
457
  my_decimal *val_decimal(my_decimal *);
459
458
  enum Item_result result_type () const { return hybrid_type; }
460
459
  void reset_field();
461
460
  void update_field();
492
491
  void cleanup();
493
492
  bool add();
494
493
  double val_real();
495
 
  type::Decimal *val_decimal(type::Decimal *);
 
494
  my_decimal *val_decimal(my_decimal *);
496
495
  int64_t val_int();
497
496
  String *val_str(String *str);
498
497
 
658
657
  enum Type type() const { return FIELD_AVG_ITEM; }
659
658
  double val_real();
660
659
  int64_t val_int();
661
 
  type::Decimal *val_decimal(type::Decimal *);
 
660
  my_decimal *val_decimal(my_decimal *);
662
661
  bool is_null() { update_null_value(); return null_value; }
663
662
  String *val_str(String*);
664
663
  enum_field_types field_type() const
690
689
  double val_real();
691
690
  // In SPs we might force the "wrong" type with select into a declare variable
692
691
  int64_t val_int();
693
 
  type::Decimal *val_decimal(type::Decimal *);
 
692
  my_decimal *val_decimal(my_decimal *);
694
693
  String *val_str(String *str);
695
694
  void reset_field();
696
695
  void update_field();
725
724
  int64_t val_int();
726
725
  String *val_str(String *str)
727
726
  { return val_string_from_real(str); }
728
 
  type::Decimal *val_decimal(type::Decimal *dec_buf)
 
727
  my_decimal *val_decimal(my_decimal *dec_buf)
729
728
  { return val_decimal_from_real(dec_buf); }
730
729
  bool is_null() { update_null_value(); return null_value; }
731
730
  enum_field_types field_type() const
782
781
  bool add();
783
782
  double val_real();
784
783
  int64_t val_int();
785
 
  type::Decimal *val_decimal(type::Decimal *);
 
784
  my_decimal *val_decimal(my_decimal *);
786
785
  void reset_field();
787
786
  void update_field();
788
787
  Item *result_item(Field *)
808
807
  Item_std_field(Item_sum_std *item);
809
808
  enum Type type() const { return FIELD_STD_ITEM; }
810
809
  double val_real();
811
 
  type::Decimal *val_decimal(type::Decimal *);
 
810
  my_decimal *val_decimal(my_decimal *);
812
811
  enum Item_result result_type () const { return REAL_RESULT; }
813
812
  enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE;}
814
813
};
843
842
  String value,tmp_value;
844
843
  double sum;
845
844
  int64_t sum_int;
846
 
  type::Decimal sum_dec;
 
845
  my_decimal sum_dec;
847
846
  Item_result hybrid_type;
848
847
  enum_field_types hybrid_field_type;
849
848
  int cmp_sign;
860
859
  void clear();
861
860
  double val_real();
862
861
  int64_t val_int();
863
 
  type::Decimal *val_decimal(type::Decimal *);
 
862
  my_decimal *val_decimal(my_decimal *);
864
863
  void reset_field();
865
864
  String *val_str(String *);
866
865
  bool keep_field_type(void) const { return 1; }
983
982
   */
984
983
  Unique *unique_filter;
985
984
  Table *table;
986
 
  Order **order;
 
985
  order_st **order;
987
986
  Name_resolution_context *context;
988
987
  /** The number of ORDER BY items. */
989
988
  uint32_t arg_count_order;
1036
1035
  void make_unique();
1037
1036
  double val_real();
1038
1037
  int64_t val_int();
1039
 
  type::Decimal *val_decimal(type::Decimal *decimal_value)
 
1038
  my_decimal *val_decimal(my_decimal *decimal_value)
1040
1039
  {
1041
1040
    return val_decimal_from_string(decimal_value);
1042
1041
  }