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

            The only existing test which does UPDATE and DELETE in userstat context and thus could have caught the regression, main.information_schema_stats, unfortunately does UPDATE and DELETE in succession (without checking the counts in between), each touching exactly 1 row, so the error cancels out, and the end result remains the same as it was.

            elenst Elena Stepanova added a comment - The only existing test which does UPDATE and DELETE in userstat context and thus could have caught the regression, main.information_schema_stats , unfortunately does UPDATE and DELETE in succession (without checking the counts in between), each touching exactly 1 row, so the error cancels out, and the end result remains the same as it was.
            elenst Elena Stepanova added a comment - A tentative fix in bb-11.5- MDEV-33151 -userstat: https://github.com/MariaDB/server/commit/fc9383808d51677dcf0e100195bb52615ce6ec2e

            Pushed fix to bb-11.5-monty

            monty Michael Widenius added a comment - Pushed fix to bb-11.5-monty

            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.