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

For unsupported statements ROW_NUMBER shows different values depending on previous events

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.7(EOL)
    • 10.11
    • Server
    • None

    Description

      --source include/have_innodb.inc
      --disable_abort_on_error
       
      create or replace table t (a tinyint) engine=InnoDB;
      backup stage end;
      get diagnostics condition 1 @n1 = row_number;
      insert into t values (1),(2),(1000);
      backup stage end;
      get diagnostics condition 1 @n2 = row_number;
      select 1;
      backup stage end;
      get diagnostics condition 1 @n3 = row_number;
      select @n1, @n2, @n3;
      

      bb-10.7-row_number cb9002bee36

      MariaDB [test]> select @n1, @n2, @n3;
      +------+------+------+
      | @n1  | @n2  | @n3  |
      +------+------+------+
      |    0 |    3 |    1 |
      +------+------+------+
      1 row in set (0.000 sec)
      

      It should probably be always 0.

      Same applies to various other statements, e.g. the same test case returns the same result if backup stage end is replaced by a failing drop database, or grant, etc.

      Attachments

        Issue Links

          Activity

            elenst Elena Stepanova created issue -
            elenst Elena Stepanova made changes -
            Field Original Value New Value
            elenst Elena Stepanova made changes -
            Summary Failed BACKUP STAGE sets ROW_NUMBER to 1 Failed BACKUP STAGE sets ROW_NUMBER to 1 or returns the previous value
            elenst Elena Stepanova made changes -
            Description {code:sql}
            BACKUP STAGE END;
            get diagnostics condition 1 @n = row_number;
            select @n;
            {code}

            {code:sql|title=bb-10.7-row_number cb9002bee36}
            MariaDB [test]> show warnings;
            +-------+------+-------------------------------------------------+
            | Level | Code | Message |
            +-------+------+-------------------------------------------------+
            | Error | 4146 | You must start backup with "BACKUP STAGE START" |
            +-------+------+-------------------------------------------------+
            1 row in set (0.000 sec)

            MariaDB [test]> get diagnostics condition 1 @n = row_number;
            Query OK, 0 rows affected (0.000 sec)

            MariaDB [test]> select @n;
            +------+
            | @n |
            +------+
            | 1 |
            +------+
            1 row in set (0.001 sec)
            {code}

            It should probably be 0.
            {code:sql}
            --disable_abort_on_error

            create or replace table t (a tinyint);
            backup stage end;
            get diagnostics condition 1 @n1 = row_number;
            insert into t values (1),(2),(1000);
            backup stage end;
            get diagnostics condition 1 @n2 = row_number;
            select 1;
            backup stage end;
            get diagnostics condition 1 @n3 = row_number;
            select @n1, @n2, @n3;
            {code}

            {code:sql|title=bb-10.7-row_number cb9002bee36}
            MariaDB [test]> select @n1, @n2, @n3;
            +------+------+------+
            | @n1 | @n2 | @n3 |
            +------+------+------+
            | 0 | 3 | 1 |
            +------+------+------+
            1 row in set (0.000 sec)
            {code}

            It should probably be always 0.
            elenst Elena Stepanova made changes -
            Summary Failed BACKUP STAGE sets ROW_NUMBER to 1 or returns the previous value Failed BACKUP STAGE sets ROW_NUMBER to different values depending on previous events
            elenst Elena Stepanova made changes -
            Description {code:sql}
            --disable_abort_on_error

            create or replace table t (a tinyint);
            backup stage end;
            get diagnostics condition 1 @n1 = row_number;
            insert into t values (1),(2),(1000);
            backup stage end;
            get diagnostics condition 1 @n2 = row_number;
            select 1;
            backup stage end;
            get diagnostics condition 1 @n3 = row_number;
            select @n1, @n2, @n3;
            {code}

            {code:sql|title=bb-10.7-row_number cb9002bee36}
            MariaDB [test]> select @n1, @n2, @n3;
            +------+------+------+
            | @n1 | @n2 | @n3 |
            +------+------+------+
            | 0 | 3 | 1 |
            +------+------+------+
            1 row in set (0.000 sec)
            {code}

            It should probably be always 0.
            {code:sql}
            --source include/have_innodb.inc
            --disable_abort_on_error
             
            create or replace table t (a tinyint) engine=InnoDB;
            backup stage end;
            get diagnostics condition 1 @n1 = row_number;
            insert into t values (1),(2),(1000);
            backup stage end;
            get diagnostics condition 1 @n2 = row_number;
            select 1;
            backup stage end;
            get diagnostics condition 1 @n3 = row_number;
            select @n1, @n2, @n3;
            {code}

            {code:sql|title=bb-10.7-row_number cb9002bee36}
            MariaDB [test]> select @n1, @n2, @n3;
            +------+------+------+
            | @n1 | @n2 | @n3 |
            +------+------+------+
            | 0 | 3 | 1 |
            +------+------+------+
            1 row in set (0.000 sec)
            {code}

            It should probably be always 0.
            elenst Elena Stepanova made changes -
            Priority Trivial [ 5 ] Minor [ 4 ]
            elenst Elena Stepanova made changes -
            Component/s Backup [ 13902 ]
            Description {code:sql}
            --source include/have_innodb.inc
            --disable_abort_on_error
             
            create or replace table t (a tinyint) engine=InnoDB;
            backup stage end;
            get diagnostics condition 1 @n1 = row_number;
            insert into t values (1),(2),(1000);
            backup stage end;
            get diagnostics condition 1 @n2 = row_number;
            select 1;
            backup stage end;
            get diagnostics condition 1 @n3 = row_number;
            select @n1, @n2, @n3;
            {code}

            {code:sql|title=bb-10.7-row_number cb9002bee36}
            MariaDB [test]> select @n1, @n2, @n3;
            +------+------+------+
            | @n1 | @n2 | @n3 |
            +------+------+------+
            | 0 | 3 | 1 |
            +------+------+------+
            1 row in set (0.000 sec)
            {code}

            It should probably be always 0.
            {code:sql}
            --source include/have_innodb.inc
            --disable_abort_on_error
             
            create or replace table t (a tinyint) engine=InnoDB;
            backup stage end;
            get diagnostics condition 1 @n1 = row_number;
            insert into t values (1),(2),(1000);
            backup stage end;
            get diagnostics condition 1 @n2 = row_number;
            select 1;
            backup stage end;
            get diagnostics condition 1 @n3 = row_number;
            select @n1, @n2, @n3;
            {code}

            {code:sql|title=bb-10.7-row_number cb9002bee36}
            MariaDB [test]> select @n1, @n2, @n3;
            +------+------+------+
            | @n1 | @n2 | @n3 |
            +------+------+------+
            | 0 | 3 | 1 |
            +------+------+------+
            1 row in set (0.000 sec)
            {code}

            It should probably be always 0.

            Same applies to various other statements, e.g. the same test case returns the same result if {{backup stage end}} is replaced by a failing {{drop database}}, or {{grant}}, etc.
            Summary Failed BACKUP STAGE sets ROW_NUMBER to different values depending on previous events Non-table statements set ROW_NUMBER to different values depending on previous events

            Also applies to at least some ALTER TABLEs, e.g.

            alter table t add key(a(0));
            

            I give up on trying to make the summary accurate, please adjust it as needed after analysis.

            elenst Elena Stepanova added a comment - Also applies to at least some ALTER TABLEs, e.g. alter table t add key (a(0)); I give up on trying to make the summary accurate, please adjust it as needed after analysis.

            Given the variety of affected statements, I'm raising it to Major, but since apparently it concerns (mainly?) statements which are out of the scope of MDEV-10075, I'm keeping it off 10.7 "must do" list.

            elenst Elena Stepanova added a comment - Given the variety of affected statements, I'm raising it to Major, but since apparently it concerns (mainly?) statements which are out of the scope of MDEV-10075 , I'm keeping it off 10.7 "must do" list.
            elenst Elena Stepanova made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            Summary Non-table statements set ROW_NUMBER to different values depending on previous events For unsupported statements ROW_NUMBER shows different values depending on previous events
            elenst Elena Stepanova made changes -
            Assignee Rucha Deodhar [ rucha174 ] Elena Stepanova [ elenst ]
            elenst Elena Stepanova made changes -
            Comment [ I didn't realize that MDEV-26635 hadn't yet been pushed when I was filing this, so maybe it will fix everything. I'll re-check. ]
            elenst Elena Stepanova made changes -
            Assignee Elena Stepanova [ elenst ] Rucha Deodhar [ rucha174 ]

            Somewhat more obvious case

            SELECT 1 INTO OUTFILE 'f';
            SELECT COUNT(*) FROM information_schema.tables;
            --error ER_FILE_EXISTS_ERROR
            SELECT 1 INTO OUTFILE 'f';
            GET DIAGNOSTICS CONDITION 1 @n = ROW_NUMBER, @m = MESSAGE_TEXT;
            SELECT @n, @m;
            

            bb-10.7-row_number c27f04ede

            COUNT(*)
            265
            SELECT 1 INTO OUTFILE 'f';
            ERROR HY000: File 'f' already exists
            GET DIAGNOSTICS CONDITION 1 @n = ROW_NUMBER, @m = MESSAGE_TEXT;
            SELECT @n, @m;
            @n	@m
            266	File 'f' already exists
            

            elenst Elena Stepanova added a comment - Somewhat more obvious case SELECT 1 INTO OUTFILE 'f' ; SELECT COUNT (*) FROM information_schema.tables; --error ER_FILE_EXISTS_ERROR SELECT 1 INTO OUTFILE 'f' ; GET DIAGNOSTICS CONDITION 1 @n = ROW_NUMBER, @m = MESSAGE_TEXT; SELECT @n, @m; bb-10.7-row_number c27f04ede COUNT (*) 265 SELECT 1 INTO OUTFILE 'f' ; ERROR HY000: File 'f' already exists GET DIAGNOSTICS CONDITION 1 @n = ROW_NUMBER, @m = MESSAGE_TEXT; SELECT @n, @m; @n @m 266 File 'f' already exists
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 126299 ] MariaDB v4 [ 143258 ]
            rucha174 Rucha Deodhar made changes -
            Fix Version/s 10.8 [ 26121 ]
            Fix Version/s 10.7 [ 24805 ]
            rucha174 Rucha Deodhar made changes -
            Fix Version/s 10.9 [ 26905 ]
            Fix Version/s 10.8 [ 26121 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.11 [ 27614 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.9 [ 26905 ]

            People

              rucha174 Rucha Deodhar
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.