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

LP:601164 - Wrong result for DELETE over a table with a virtual column

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      DELETE over a table containing a virtual column with ORDER BY an index and with a LIMIT clause may return wrong results
      if the WHERE clause contains a condition for the virtual column:

      MariaDB [test]> create table t1 (a int, b int, v int as (a+1), index idx(b));
      Query OK, 0 rows affected (0.00 sec)

      MariaDB [test]> insert into t1(a, b) values (4, 40), (3, 30), (5, 50), (7, 70), (8, 80), (2, 20), (1, 10);
      Query OK, 7 rows affected (0.00 sec)
      Records: 7 Duplicates: 0 Warnings: 0

      MariaDB [test]> select * from t1 order by b;
      --------------

      a b v

      --------------

      1 10 2
      2 20 3
      3 30 4
      4 40 5
      5 50 6
      7 70 8
      8 80 9

      --------------
      7 rows in set (0.00 sec)

      MariaDB [test]> delete from t1 where v > 6 order by b limit 1;
      Query OK, 0 rows affected (6.19 sec)

      MariaDB [test]> select * from t1;
      --------------

      a b v

      --------------

      4 40 5
      3 30 4
      5 50 6
      7 70 8
      8 80 9
      2 20 3
      1 10 2

      --------------
      7 rows in set (0.00 sec)

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            psergey Sergei Petrunia added a comment -

            Re: Wrong result for DELETE over a table with a virtual column
            This bug can be observed in current MariaDB 5.2

            Show
            psergey Sergei Petrunia added a comment - Re: Wrong result for DELETE over a table with a virtual column This bug can be observed in current MariaDB 5.2
            Hide
            igor Igor Babaev added a comment -

            Re: Wrong result for DELETE over a table with a virtual column
            There is a similar problem for some UPDATEs.
            For the same table as in the reported test case we have:

            MariaDB [test]> update t1 set a=v order by b limit 1;
            Query OK, 1 row affected (34.82 sec)
            Rows matched: 1 Changed: 1 Warnings: 0

            MariaDB [test]> select * from t1 order by b;
            --------------

            a b v

            --------------

            NULL 10 NULL
            2 20 3
            3 30 4
            4 40 5
            5 50 6
            7 70 8
            8 80 9

            --------------
            7 rows in set (0.00 sec)

            Show
            igor Igor Babaev added a comment - Re: Wrong result for DELETE over a table with a virtual column There is a similar problem for some UPDATEs. For the same table as in the reported test case we have: MariaDB [test] > update t1 set a=v order by b limit 1; Query OK, 1 row affected (34.82 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [test] > select * from t1 order by b; ----- ---- ----- a b v ----- ---- ----- NULL 10 NULL 2 20 3 3 30 4 4 40 5 5 50 6 7 70 8 8 80 9 ----- ---- ----- 7 rows in set (0.00 sec)
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 601164

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 601164

              People

              • Assignee:
                igor Igor Babaev
                Reporter:
                igor Igor Babaev
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: