Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12568

Add Type_handler::subquery_type_allows_materialization()

    XMLWordPrintable

Details

    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()

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.