[MDEV-9234] Add Type_handler::union_element_finalize() Created: 2015-12-03  Updated: 2021-07-28  Resolved: 2019-04-23

Status: Closed
Project: MariaDB Server
Component/s: Data types
Fix Version/s: 10.4.5

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

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
Relates
relates to MDEV-12775 Reuse data type aggregation code for ... Closed

 Description   

There is a code in sql_union.cc which checks that an Item is OK as a UNION field.

    while ((type= tp++))
    {
      if (type->cmp_type() == STRING_RESULT &&
          type->collation.derivation == DERIVATION_NONE)
      {
        my_error(ER_CANT_AGGREGATE_NCOLLATIONS, MYF(0), "UNION");
        goto err;
      }
    }

Currently, this code has only one purpose: In case of character string data types it makes sure that the aggregated data type has a non-conflicting collation, to disallow this:

mysql> (SELECT 'a' COLLATE utf8_general_ci) UNION (SELECT 'b' COLLATE utf8_unicode_ci);
ERROR 1267 (HY000): Illegal mix of collations (utf8_general_ci,EXPLICIT) and (utf8_unicode_ci,EXPLICIT) for operation 'UNION'

All other built-in data types have no additional requirements on the aggregated data type.
But user defined data types may want to have their own requirements.

This code should go into a new virtual method in Type_handler.


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