[MDEV-12506] Split Item_func_min_max::fix_length_and_dec() into methods in Type_handler Created: 2017-04-14  Updated: 2017-04-22  Resolved: 2017-04-22

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: 10.3.1

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: datatype

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
Relates
relates to MDEV-12497 Wrong data type for LEAST(latin1_expr... Closed
relates to MDEV-12504 Wrong data type for LEAST(date_expr,t... Closed
relates to MDEV-12505 Wrong data type for GREATEST(bit_colu... Closed

 Description   

Item_func_min_max::fix_length_and_dec() is hard-coded for the built-in data types. To allow pluggable data type determine behavior of the functions LEAST and GREATEST, we'll move the code to Type_handler as follows:

1. Add a new method in Type_handler_hybrid_field_type:

bool aggregate_for_min_max(const char *funcname, Item **items, uint nitems);

This method will decide which data type handler should be used for the result of LEAST/GREATEST.

2. Add a new virtual method in Type_handler:

virtual bool Item_func_min_max_fix_attributes(THD *thd,
                                              Item_func_min_max *func,
                                              Item **items,
                                               uint nitems) const;

This method will calculate the data type attributes. See Type_std_attributes.

Note, implementations for the particular Type_handler_xxx classes should reuse the code from Item_hybrid_func_fix_attributes as much as possible, because the current implementation of Item_func_min_max::fix_length_and_dec() is quite buggy:

  • MDEV-12497 Wrong data type for LEAST(latin1_expr, utf8_expr)
  • MDEV-12504 Wrong data type for LEAST(date_expr,time_expr)
  • MDEV-12505 Wrong data type for GREATEST(bit_column, int_column)

Sharing the code with Item_hybrid_func should fix these problems.

3. Remove the current implementation of Item_func_min_max::fix_length_and_dec() and replace it to the new methods.

Under terms of this task we'll also disallow LEAST and GREATEST to have arguments of the GEOMETRY data type mixed with numeric and temporal arguments, as this has no sense.



 Comments   
Comment by Alexey Botchkov [ 2017-04-22 ]

Ok to push.

Comment by Alexander Barkov [ 2017-04-22 ]

Pushed to bb-10.2-ext

Generated at Thu Feb 08 07:58:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.