[MDEV-12568] Add Type_handler::subquery_type_allows_materialization() Created: 2017-04-23  Updated: 2017-04-24  Resolved: 2017-04-24

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

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

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed

 Description   

There is a code in sql/opt_subselect.cc:

    switch (outer->cmp_type()) {
    case STRING_RESULT:
      if (!(outer->collation.collation == inner->collation.collation))
        DBUG_RETURN(FALSE);
      // Materialization does not work with BLOB columns
      if (inner->field_type() == MYSQL_TYPE_BLOB ||
          inner->field_type() == MYSQL_TYPE_GEOMETRY)
        DBUG_RETURN(FALSE);
      /*
        Materialization also is unable to work when create_tmp_table() will
        create a blob column because item->max_length is too big.
        The following check is copied from Item::make_string_field():
      */
      if (inner->too_big_for_varchar())
      {
        DBUG_RETURN(FALSE);
      }
      break;
    case TIME_RESULT:
      if (mysql_type_to_time_type(outer->field_type()) !=
          mysql_type_to_time_type(inner->field_type()))
        DBUG_RETURN(FALSE);
    default:
      /* suitable for materialization */
      break;
    }

It's not friendly for new data types. It uses a switch on cmp_type() and uses mysql_type_to_time_type(outer->field_type()).

Under terms of this task we'll

1. Introduce two new virtual methods in Type_handler:

virtual enum_mysql_timestamp_type mysql_timestamp_type() const;
virtual bool subquery_type_allows_materialization(const Item *inner, const Item *outer) const;

2. Split the above code into virtual implementations for corresponding type handlers.

3. Replace calls mysql_type_to_time_type(field_type()) to type_handler()->mysql_timestamp_type()



 Comments   
Comment by Alexander Barkov [ 2017-04-24 ]

Pushed to bb-10.2-ext

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