mariadb/storage
Alexander Barkov 705fc43eaa MDEV-12775 Reuse data type aggregation code for hybrid functions and UNION
Introducing a new class Type_holder (used internally in sql_union.cc),
to reuse exactly the same data type attribute aggregation Type_handler API
for hybrid functions and UNION.

This fixes a number of bugs in UNION:

- MDEV-9495 Wrong field type for a UNION of a signed and an unsigned INT expression
- MDEV-9497 UNION and COALESCE produce different field types for DECIMAL+INT
- MDEV-12594 UNION between fixed length double columns does not always preserve scale
- MDEV-12595 UNION converts INT to BIGINT
- MDEV-12599 UNION is not symmetric when mixing INT and CHAR

Details:

- sql_union.cc: Reusing attribute aggregation for UNION.
  Adding new methods:
  * st_select_lex_unit::join_union_type_handlers()
  * st_select_lex_unit::join_union_type_attributes()
  * st_select_lex_unit::join_union_item_types()
  Removing the old join_types()-based code.

- Changing Type_handler::Item_hybrid_func_fix_attributes()
  to accept "name", Type_handler_hybrid_field_type, Type_all_attributes
  as three separate parameters instead of a single Item_hybrid_func parameter,
  to make it possible to pass both Item_hybrid_func and Type_holder.

- Moving the former special GEOMETRY and ENUM/SET attribute aggregation code
  from Item_type_holder::join_types() to
  * Type_handler_typelib::Item_hybrid_func_fix_attributes().
  * Type_handler_geometry::Item_hybrid_func_fix_attrubutes().
  This makes GEOMETRY/ENUM/SET symmetric with all other data types
  (from the UNION point of view).
  Removing Item_type_holder::join_types() and Item_type_holder::get_full_info().

- Adding new methods into Type_all_attributes:
  * Type_all_attributes::set_geometry_type() and
    Item_hybrid_func::set_geometry_type().
  * Adding Type_all_attributes::get_typelib().
  * Adding Type_all_attributes::set_typelib().

- Adding Type_handler_typelib as a common parent for
  Type_handler_enum and Type_handler_set, to avoid code duplication: they have
  already had two common methods, and we're adding one more shared method.

- Adding Type_all_attributes::set_maybe_null(), as some type handlers
  may want to set maybe_null (e.g. Type_handler_geometry) during data type
  attribute aggregation.

- Changing Type_geometry_attributes() to accept Type_handler
  and Type_all_attributes as two separate parameters, instead
  of a single Item parameter, to make it possible to pass Type_holder.

- Adding Item_args::add_argument().

- Moving Item_args::alloc_arguments() from "protected" to "public".

- Moving Item_type_holder::Item_type_holder() from item.cc to item.h, as
  now it's very simple.
  Btw, this constructor should probably be eventually removed.
  It's now used only in sql_show.cc, which could be modified to use
  Item_return_decimal (for symmetry with Item_return_xxx created for all
  other data types). Or, another option: remove all Item_return_xxx and
  use Item_type_holder for all data types instead.

- storage/tokudb/mysql-test/tokudb/r/type_float.result
  Recording new results (MDEV-12594).

- mysql-test/r/cte_recursive.result
  Recording new results (MDEV-9497)

- mysql-test/r/subselect*.result
  Recording new results (MDEV-12595)

- mysql-test/r/metadata.result
  Recording new results (MDEV-9495)

- mysql-test/r/temp_table.result
  Recording new results (MDEV-12594)

- mysql-test/r/type_float.result
  Recording new results (MDEV-12594)
2017-05-15 23:45:31 +04:00
..
archive Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
blackhole Added "const" to new data for handler::update_row() 2017-04-18 12:23:53 +03:00
cassandra Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
connect Fixed compiler warnings and warnings from build.tags 2017-05-08 02:33:35 +03:00
csv Added "const" to new data for handler::update_row() 2017-04-18 12:23:53 +03:00
example Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
federated Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
federatedx Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
heap Added "const" to new data for handler::update_row() 2017-04-18 12:23:53 +03:00
innobase Fixed compiler warnings and warnings from build.tags 2017-05-08 02:33:35 +03:00
maria Fixed compiler warnings and warnings from build.tags 2017-05-08 02:33:35 +03:00
mroonga MDEV-10139 Support for SEQUENCE objects 2017-05-08 02:44:55 +03:00
myisam Fixed compiler warnings and warnings from build.tags 2017-05-08 02:33:35 +03:00
myisammrg Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
oqgraph Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
perfschema MDEV-12695 Add Column_definition::type_handler() 2017-05-05 07:00:18 +04:00
rocksdb Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-05-05 16:12:54 +04:00
sequence Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
sphinx Changing field::field_name and Item::name to LEX_CSTRING 2017-04-23 22:35:46 +03:00
spider Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-05-05 16:12:54 +04:00
test_sql_discovery store/show vcols as item->print() 2016-12-12 20:35:41 +01:00
tokudb MDEV-12775 Reuse data type aggregation code for hybrid functions and UNION 2017-05-15 23:45:31 +04:00
xtradb Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-05-05 16:12:54 +04:00