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

Allow ALTER TABLE…ADD SPATIAL INDEX…ALGORITHM=INPLACE

Details

    Description

      In the merge of MySQL 5.7.9 to MariaDB 10.2.2, some code was included that prevents ADD SPATIAL INDEX from being executed with ALGORITHM=INPLACE.

      Restrictions introduced in MySQL 5.7.9 are unavoidable, but MariaDB should not add its own ones. The MySQL restrictions are:

      1. table-rebuilding operations are not allowed if SPATIAL INDEX survive it
      2. ALTER TABLE…ADD SPATIAL INDEX…LOCK=NONE is not allowed

      The fix appears simple:

      diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
      index 352b223ab69..d52eaf456a4 100644
      --- a/storage/innobase/handler/handler0alter.cc
      +++ b/storage/innobase/handler/handler0alter.cc
      @@ -897,28 +897,12 @@ ha_innobase::check_if_supported_inplace_alter(
       	DBUG_ASSERT(!m_prebuilt->table->fts || m_prebuilt->table->fts->doc_col
       		    < dict_table_get_n_user_cols(m_prebuilt->table));
       
      -       /* Spatial indexes should use copy method for now.
      -       TOO: remove this when below ADD_SPATIAL_INDEX supported. */
      -       for (uint i = 0; i < ha_alter_info->index_add_count; i++) {
      -               const KEY* key =
      -                       &ha_alter_info->key_info_buffer[
      -                               ha_alter_info->index_add_buffer[i]];
      -               if (key->flags & HA_SPATIAL) {
      -                       ha_alter_info->unsupported_reason = innobase_get_err_msg(
      -                             ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS);
      -
      -                       DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
      -               }
      -       }
      -
      -#ifdef MYSQL_SPATIAL_INDEX
       	if (ha_alter_info->handler_flags
       	    & Alter_inplace_info::ADD_SPATIAL_INDEX) {
       		ha_alter_info->unsupported_reason = innobase_get_err_msg(
       			ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS);
       		online = false;
       	}
      -#endif
       
       	if (m_prebuilt->table->fts
       	    && innobase_fulltext_exist(altered_table)) {
      diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h
      index 7b3726b1fef..459304fc712 100644
      --- a/storage/innobase/include/ha_prototypes.h
      +++ b/storage/innobase/include/ha_prototypes.h
      @@ -43,7 +43,6 @@ class THD;
       #undef MYSQL_PFS
       #undef MYSQL_RENAME_INDEX
       #undef MYSQL_REPLACE_TRX_IN_THD
      -#undef MYSQL_SPATIAL_INDEX
       #undef MYSQL_STORE_FTS_DOC_ID
       
      

      Attachments

        Issue Links

          Activity

            marko Marko Mäkelä created issue -
            marko Marko Mäkelä made changes -
            Field Original Value New Value
            Status Open [ 1 ] In Progress [ 3 ]
            marko Marko Mäkelä made changes -
            Summary ADD SPATIAL INDEX is not allowed with ALGORITHM=INPLACE Allow ALTER TABLE…ADD SPATIAL INDEX…ALGORITHM=INPLACE

            jplindst, please take this initial patch and see which other tests need to be adjusted and how.

            marko Marko Mäkelä added a comment - jplindst , please take this initial patch and see which other tests need to be adjusted and how.
            marko Marko Mäkelä made changes -
            Assignee Marko Mäkelä [ marko ] Jan Lindström [ jplindst ]
            marko Marko Mäkelä made changes -
            Assignee Jan Lindström [ jplindst ] Marko Mäkelä [ marko ]

            We also have to remove the misleading constant Alter_inplace_info::ADD_SPATIAL_INDEX, which was an alias of Alter_inplace_info::ADD_INDEX.
            There are not many references to ADD_SPATIAL_INDEX; it is trivial to remove. So, ADD_INDEX will refer to creating any kind of creating and index (except ADD PRIMARY KEY).
            Already in MySQL 5.6, ADD_INDEX could refer to creating a FULLTEXT INDEX. MySQL 5.7 should not have introduced the constant ADD_SPATIAL_INDEX for one special case that is more like an implementation detail of a storage engine.

            marko Marko Mäkelä added a comment - We also have to remove the misleading constant Alter_inplace_info::ADD_SPATIAL_INDEX, which was an alias of Alter_inplace_info::ADD_INDEX. There are not many references to ADD_SPATIAL_INDEX; it is trivial to remove. So, ADD_INDEX will refer to creating any kind of creating and index (except ADD PRIMARY KEY). Already in MySQL 5.6, ADD_INDEX could refer to creating a FULLTEXT INDEX. MySQL 5.7 should not have introduced the constant ADD_SPATIAL_INDEX for one special case that is more like an implementation detail of a storage engine.
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä added a comment - bb-10.2-marko
            marko Marko Mäkelä made changes -
            Assignee Marko Mäkelä [ marko ] Jan Lindström [ jplindst ]
            Status In Progress [ 3 ] In Review [ 10002 ]

            ok to push.

            jplindst Jan Lindström (Inactive) added a comment - ok to push.
            jplindst Jan Lindström (Inactive) made changes -
            Assignee Jan Lindström [ jplindst ] Marko Mäkelä [ marko ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            Fix Version/s 10.2.9 [ 22611 ]
            Fix Version/s 10.2 [ 14601 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            marko Marko Mäkelä made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 82669 ] MariaDB v4 [ 152846 ]

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.