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

Strange error message if you try to FLUSH TABLES <view> after LOCK TABLES <view>

    XMLWordPrintable

Details

    Description

      If you try to execute FLUSH TABLES on a view after read-locking that view with LOCK TABLES ... READ|WRITE, then you get an error message that doesn't seem to make a lot of sense.

      For example, if we have this view:

      CREATE TABLE t (qty INT, price INT);
      CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;
      

      Then let's see what happens:

      MariaDB [db1]> LOCK TABLES v READ;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [db1]> FLUSH TABLES v;
      ERROR 1100 (HY000): Table 'v' was not locked with LOCK TABLES
      

      If we execute the same statement on the base table, then we get a different error message:

      MariaDB [db1]> LOCK TABLES t READ;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [db1]> FLUSH TABLES t;
      ERROR 1099 (HY000): Table 't' was locked with a READ lock and can't be updated
      

      Trying to flush a write-locked view has the same problem:

      MariaDB [db1]> LOCK TABLES v WRITE;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [db1]> FLUSH TABLES v;
      ERROR 1100 (HY000): Table 'v' was not locked with LOCK TABLES
      

      But this does work for base tables:

      MariaDB [db1]> LOCK TABLES t WRITE;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [db1]> FLUSH TABLES t;
      Query OK, 0 rows affected (0.00 sec)
      

      Is the error message wrong, or is FLUSH partially broken for views at the moment?

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              GeoffMontee Geoff Montee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.