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

              People

              • Assignee:
                marko Marko Mäkelä
                Reporter:
                marko Marko Mäkelä
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: