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

TABLE_STATISTICS increments ROWS_CHANGED twice upon UPDATE and does not count DELETE

Details

    Description

      This is a regression introduced by MDEV-33151.
      The column rows_changed already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE/DELETE, which wasn't happening before, apparently due to the typo:

      @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
               check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
             continue;
       
      +    rows_changed= (rows_stats->inserted + rows_stats->updated +
      +                   rows_stats->updated);
      

      set @userstat.save= @@userstat;
      set global userstat= 1;
       
      create table t (a int);
      insert into t values (1),(2);
       
      flush table_statistics;
      update t set a = a + 10;
      select rows_changed from information_schema.table_statistics where table_name = 't';
      delete from t where a = 11;
      select rows_changed from information_schema.table_statistics where table_name = 't';
       
      # Cleanup
      drop table t;
      set global userstat= @userstat.save;
      

      bb-11.5-MDEV-33151-userstat 36c7a912bc

      flush table_statistics;
      update t set a = a + 10;
      select rows_changed from information_schema.table_statistics where table_name = 't';
      rows_changed
      4
      delete from t where a = 11;
      select rows_changed from information_schema.table_statistics where table_name = 't';
      rows_changed
      4
      

      The expected result is "2" and "3" correspondingly, which is returned by the baseline.

      Attachments

        Issue Links

          Activity

            elenst Elena Stepanova created issue -
            elenst Elena Stepanova made changes -
            Field Original Value New Value
            elenst Elena Stepanova made changes -
            Description This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2", which is returned by the baseline.
            This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            Possibly the idea was to include *deleted* rows instead, which would seem quite logical, but before MDEV-33151 userstat didn't count deleted rows in {{rows_changed}} on whatever reason, so I'm not sure whether it's supposed to start now.

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2", which is returned by the baseline.
            elenst Elena Stepanova made changes -
            Description This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            Possibly the idea was to include *deleted* rows instead, which would seem quite logical, but before MDEV-33151 userstat didn't count deleted rows in {{rows_changed}} on whatever reason, so I'm not sure whether it's supposed to start now.

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2", which is returned by the baseline.
            This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            Possibly the idea was to include *deleted* rows instead, which would seem quite logical, but on whatever reason, before MDEV-33151 userstat didn't count deleted rows in {{rows_changed}}, so I'm not sure whether it's supposed to start now.

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2", which is returned by the baseline.
            elenst Elena Stepanova made changes -
            Description This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            Possibly the idea was to include *deleted* rows instead, which would seem quite logical, but on whatever reason, before MDEV-33151 userstat didn't count deleted rows in {{rows_changed}}, so I'm not sure whether it's supposed to start now.

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2", which is returned by the baseline.
            This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2" and "3" correspondingly, which is returned by the baseline.
            elenst Elena Stepanova made changes -
            Summary TABLE_STATISTICS increments rows_changed twice upon update TABLE_STATISTICS increments rows_changed twice upon UPDATE and does not count DELETE
            elenst Elena Stepanova made changes -
            Summary TABLE_STATISTICS increments rows_changed twice upon UPDATE and does not count DELETE TABLE_STATISTICS increments ROWS_CHANGED twice upon UPDATE and does not count DELETE
            elenst Elena Stepanova made changes -
            Description This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2" and "3" correspondingly, which is returned by the baseline.
            This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE/DELETE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2" and "3" correspondingly, which is returned by the baseline.
            elenst Elena Stepanova made changes -
            Description This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE/DELETE, which wasn't happening before, apparently due to a typo.
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2" and "3" correspondingly, which is returned by the baseline.
            This is a regression introduced by MDEV-33151.
            The column {{rows_changed}} already existed, it wasn't added by MDEV-33151; but it now shows wrong counts for UPDATE/DELETE, which wasn't happening before, apparently due to the typo:
            {code:java}
            @@ -40,14 +47,22 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
                     check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1))
                   continue;
             
            + rows_changed= (rows_stats->inserted + rows_stats->updated +
            + rows_stats->updated);
            {code}

            {code:sql}
            set @userstat.save= @@userstat;
            set global userstat= 1;

            create table t (a int);
            insert into t values (1),(2);

            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';

            # Cleanup
            drop table t;
            set global userstat= @userstat.save;
            {code}

            {code:sql|title=bb-11.5-MDEV-33151-userstat 36c7a912bc}
            flush table_statistics;
            update t set a = a + 10;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            delete from t where a = 11;
            select rows_changed from information_schema.table_statistics where table_name = 't';
            rows_changed
            4
            {code}
            The expected result is "2" and "3" correspondingly, which is returned by the baseline.
            elenst Elena Stepanova made changes -
            Assignee Michael Widenius [ monty ] Elena Stepanova [ elenst ]
            elenst Elena Stepanova made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            elenst Elena Stepanova made changes -
            Assignee Elena Stepanova [ elenst ] Michael Widenius [ monty ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            monty Michael Widenius made changes -
            Status In Review [ 10002 ] In Testing [ 10301 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 11.5.1 [ 29634 ]
            Fix Version/s 11.5 [ 29506 ]
            Resolution Fixed [ 1 ]
            Status In Testing [ 10301 ] Closed [ 6 ]

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.