[MDEV-17778] Alter table leads to a truncation warning with ANALYZE command Created: 2018-11-20  Updated: 2018-12-11  Resolved: 2018-12-10

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.4.1, 10.3.12

Type: Bug Priority: Major
Reporter: Varun Gupta (Inactive) Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
PartOf
is part of MDEV-15253 Default optimizer setting changes for... Closed

 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.



 Comments   
Comment by Varun Gupta (Inactive) [ 2018-11-20 ]

Patch
http://lists.askmonty.org/pipermail/commits/2018-November/013127.html

Comment by Sergei Petrunia [ 2018-12-09 ]

Ok to push.

Generated at Thu Feb 08 08:39:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.