diff options
author | unknown <konstantin@mysql.com> | 2005-03-13 23:50:43 +0300 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2005-03-13 23:50:43 +0300 |
commit | 1534ed8e1553eb3105bc06d963038a82d548b8d9 (patch) | |
tree | dfbb52f3c23bf61610783925dd1ed12c6c69942f /sql/field.h | |
parent | 08e23eb602937a5957899e9230f93ca96b25a9ce (diff) | |
download | mariadb-git-1534ed8e1553eb3105bc06d963038a82d548b8d9.tar.gz |
WL#926 "SUM(DISTINCT) and AVG(DISTINCT)": improvement of SUM(DISTINCT) and
implementation of AVG(DISTINCT) which utilizes the approach with Fields.
The patch implemented in October is portede to the up-to-date tree
containing DECIMAL type.
Tests for AVG(DISTINCT) (although there is not much to test provided
that SUM(DISTINCT) works), cleanups for COUNT(DISTINCT) and GROUP_CONCAT()
will follow in another changeset.
sql/field.cc:
A handy way to init create_field used for use with virtual tmp tables.
Feel free to extend it for your own needs.
sql/field.h:
Declaration for create_field::init_for_tmp_table()
sql/item.cc:
Implementation for a framework used to easily handle different result
types of SQL expressions. Instead of having instances of each possible
result type (integer, decimal, double) in every item, variables
of all used types are moved to struct Hybrid_type.
Hybrid_type can change its dynamic type in runtime, and become,
for instance, DECIMAL from INTEGER.
All type-specific Item operations are moved to the class hierarchy
Hybrid_type_traits. Item::decimals and Item::max_length can
be moved to Hybrid_type as well.
sql/item.h:
Declaration for Hybrid_type framework. See also comments for item.cc
in this changeset.
sql/item_sum.cc:
Rewritten implementation for Item_sum_sum_distinct (SUM(DISTINCT))
and added implementation for Item_sum_avg_distinct (AVG(DISTINCT)).
The classes utilize Hybrid_type class hierarchy and Fields to
convert SUM/AVG arguments to binary representation and store in a RB-tree.
sql/item_sum.h:
Declarations for Item_sum_distinct (the new intermediate class used
for SUM and AVG distinct), Item_sum_sum_distinct, Item_sum_avg_distinct.
sql/sql_select.cc:
Implementatio of create_virtual_tmp_table().
sql/sql_select.h:
Declaration for create_virtual_tmp_table.
sql/sql_yacc.yy:
Grammar support for Item_sum_avg_distinct.
Diffstat (limited to 'sql/field.h')
-rw-r--r-- | sql/field.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/field.h b/sql/field.h index a92ef1db297..083af27d6d9 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1340,7 +1340,8 @@ public: Create field class for CREATE TABLE */ -class create_field :public Sql_alloc { +class create_field :public Sql_alloc +{ public: const char *field_name; const char *change; // If done with alter table @@ -1362,6 +1363,11 @@ public: create_field() :after(0) {} create_field(Field *field, Field *orig_field); void create_length_to_internal_length(void); + + /* Init for a tmp table field. To be extended if need be. */ + void init_for_tmp_table(enum_field_types sql_type_arg, + uint32 max_length, uint32 decimals, + bool maybe_null, bool is_unsigned); }; |