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

Wrong partitioning by KEY() after key dropped

    Details

      Description

      Reproduce

      create or replace table t1 (pk int, x timestamp(6), primary key (pk, x)) engine innodb
      partition by key() partitions 2;
       
      insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
      alter table t1 drop primary key, drop column x, add primary key (pk); 
      select * from t1 partition (p0);
      

      Result

      +----+
      | pk |
      +----+
      |  1 |
      |  2 |
      +----+
      

      Both records are in p0 which is unacceptable for new partitioning expression.

      Expected

      Table is repartitioned by pk.

      +----+
      | pk |
      +----+
      |  1 |
      +----+
      

      Cause

      Empty key() clause implies that key might be changed by ALTER, but inplace algorithm must not be used since repartitioning is required for a different key.

      Fix

      Prohibit inplace when there is DROP PRIMARY KEY and table is partitioned by key.

      More details

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                midenok Aleksey Midenkov
                Reporter:
                midenok Aleksey Midenkov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: