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

Swap atomically a view in place of an altered table

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 10.11
    • 10.11
    • None
    • None

    Description

      In some scenarios it there is a need to add/drop columns for a table and replace it with a view to allow old applications to work unchanged until they are updated.

      As MariaDB does not have transactional DDL, we have to do it in some other way.

      The following 'almost' works:

      create table t1 (a int);
      create table t2 like t1;
      create table v1 select a from t2;
      drop table t2;
      lock table t1 write, v1 write;
      alter table t1 add column (b int);
      rename table t1 to t2, v1 to t1;
      ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction
      

      The task is to allow the above rename table to succeed.

      Another possible solution to do this nicely (from the user's point of view) is to extend alter table:

      alter table t1 add column (b int) rename as t1 replace with v1;

      Where the 'replace with v1 means: rename v1 to t1'

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            monty Michael Widenius
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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