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

DROP COLUMN, DROP INDEX is wrongly claimed to be ALGORITHM=INSTANT

Details

    Description

      The following SQL test case works on 10.3 but fails to return an error on 10.4:

      --source include/have_innodb.inc
      CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB;
      --error ER_ALTER_OPERATION_NOT_SUPPORTED
      ALTER TABLE t1 DROP b, ALGORITHM=INSTANT;
      DROP TABLE t1;
      

      The reason appears to be a code change that was part of MDEV-15563:

      @@ -2003,9 +2040,7 @@ ha_innobase::check_if_supported_inplace_alter(
       		af++;
       	}
       
      -	if (supports_instant
      -	    || !(ha_alter_info->handler_flags
      -		 & ~(INNOBASE_ALTER_INSTANT | INNOBASE_INPLACE_IGNORE))) {
      +	if (supports_instant) {
       		DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
       	}
       
      

      We should not return HA_ALTER_INPLACE_INSTANT if any flags in INNOBASE_ALTER_NOREBUILD (dropping or creating secondary indexes) are set, because those are not instantaneous operations.

      Attachments

        Issue Links

          Activity

            The following fix seems to work:

            diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
            index 64607293ed9..ae1b6073b3a 100644
            --- a/storage/innobase/handler/handler0alter.cc
            +++ b/storage/innobase/handler/handler0alter.cc
            @@ -2474,7 +2474,8 @@ ha_innobase::check_if_supported_inplace_alter(
             		}
             	}
             
            -	if (supports_instant) {
            +	if (supports_instant && !(ha_alter_info->handler_flags
            +				  & INNOBASE_ALTER_NOREBUILD)) {
             		DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
             	}
             
            @@ -2585,7 +2586,9 @@ ha_innobase::check_if_supported_inplace_alter(
             	}
             
             	if (need_rebuild || fts_need_rebuild) {
            -		ha_alter_info->handler_flags |= ALTER_RECREATE_TABLE;
            +		if (!supports_instant) {
            +			ha_alter_info->handler_flags |= ALTER_RECREATE_TABLE;
            +		}
             		DBUG_RETURN(online
             			    ? HA_ALTER_INPLACE_COPY_NO_LOCK
             			    : HA_ALTER_INPLACE_COPY_LOCK);
            

            The second part is refining MDEV-21832. Without that change, we would unnecessarily force a table to be rebuilt when dropping an indexed column.

            marko Marko Mäkelä added a comment - The following fix seems to work: diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 64607293ed9..ae1b6073b3a 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -2474,7 +2474,8 @@ ha_innobase::check_if_supported_inplace_alter( } } - if (supports_instant) { + if (supports_instant && !(ha_alter_info->handler_flags + & INNOBASE_ALTER_NOREBUILD)) { DBUG_RETURN(HA_ALTER_INPLACE_INSTANT); } @@ -2585,7 +2586,9 @@ ha_innobase::check_if_supported_inplace_alter( } if (need_rebuild || fts_need_rebuild) { - ha_alter_info->handler_flags |= ALTER_RECREATE_TABLE; + if (!supports_instant) { + ha_alter_info->handler_flags |= ALTER_RECREATE_TABLE; + } DBUG_RETURN(online ? HA_ALTER_INPLACE_COPY_NO_LOCK : HA_ALTER_INPLACE_COPY_LOCK); The second part is refining MDEV-21832 . Without that change, we would unnecessarily force a table to be rebuilt when dropping an indexed column.

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              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.