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

Alter table leads to a truncation warning with ANALYZE command

    Details

      Description

      --source include/have_innodb.inc
       
      set @@optimizer_use_condition_selectivity=4;
      set @@use_stat_tables=PREFERABLY;
       
      create table t1 (a int)engine=InnoDB;
      insert into t1 values (1),(1),(2),(3);
      

       
      MariaDB [test]> analyze table t1;
      +---------+---------+----------+-----------------------------------------+
      | Table   | Op      | Msg_type | Msg_text                                |
      +---------+---------+----------+-----------------------------------------+
      | test.t1 | analyze | status   | Engine-independent statistics collected |
      | test.t1 | analyze | status   | OK                                      |
      +---------+---------+----------+-----------------------------------------+
      
      

      MariaDB [test]> alter table t1 change a b int;
      Query OK, 0 rows affected (0.029 sec)
      Records: 0  Duplicates: 0  Warnings: 0
      

      MariaDB [test]> analyze table t1;
      +---------+---------+----------+----------------------------------------------------+
      | Table   | Op      | Msg_type | Msg_text                                           |
      +---------+---------+----------+----------------------------------------------------+
      | test.t1 | analyze | status   | Engine-independent statistics collected            |
      | test.t1 | analyze | Note     | Data truncated for column 'avg_frequency' at row 1 |
      | test.t1 | analyze | status   | OK                                                 |
      +---------+---------+----------+----------------------------------------------------+
      

      MariaDB [test]> select * from mysql.column_stats;
      +---------+------------+-------------+-----------+-----------+-------------+------------+---------------+-----------+-----------+-----------+
      | db_name | table_name | column_name | min_value | max_value | nulls_ratio | avg_length | avg_frequency | hist_size | hist_type | histogram |
      +---------+------------+-------------+-----------+-----------+-------------+------------+---------------+-----------+-----------+-----------+
      | test    | t1         | b           | 1         | 3         |      0.0000 |     4.0000 |        1.3333 |         0 | NULL      | NULL      |
      +---------+------------+-------------+-----------+-----------+-------------+------------+---------------+-----------+-----------+-----------+
      1 row in set (0.001 sec)
      
      

      The avg_frequency is 1.3333. The behaviour needs to be consistent.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                varun Varun Gupta
                Reporter:
                varun Varun Gupta
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: