Skip to content

analyze table returns Incorrect datetime value error #39336

@xuyifangreeneyes

Description

@xuyifangreeneyes

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> use test;
Database changed
mysql> set @@global.tidb_partition_prune_mode = 'dynamic';
Query OK, 0 rows affected, 1 warning (0.02 sec)

mysql> set @@session.tidb_partition_prune_mode = 'dynamic';
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> create table t1 (
    ->     a datetime(3) default null,
    ->     b int
    -> ) partition by range (b) (
    ->     partition p0 values less than (1000),
    ->     partition p1 values less than (2000),
    ->     partition p3 values less than (maxvalue)
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> set @@sql_mode='';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values
    -> ('2022-11-23 14:25:08.000', 1001),
    -> ('1000-00-09 00:00:00.000', 1001),
    -> ('1000-00-06 00:00:00.000', 1001),
    -> ('1000-00-06 00:00:00.000', 1001),
    -> ('2022-11-23 14:24:30.000',    1),
    -> ('2022-11-23 14:24:32.000',    1),
    -> ('2022-11-23 14:24:33.000',    1),
    -> ('2022-11-23 14:24:35.000',    1),
    -> ('1000-00-09 00:00:00.000',    1),
    -> ('1000-00-06 00:00:00.000',    1),
    -> ('1000-00-06 00:00:00.000',    1),
    -> ('2022-11-23 14:25:11.000', 2001),
    -> ('2022-11-23 14:25:16.000', 3001),
    -> ('1000-00-09 00:00:00.000', 3001),
    -> ('1000-00-09 00:00:00.000', 2001),
    -> ('1000-00-06 00:00:00.000', 2001),
    -> ('1000-00-09 00:00:00.000', 2001);
Query OK, 17 rows affected (0.00 sec)
Records: 17  Duplicates: 0  Warnings: 0

mysql> analyze table t1 with 0 topn;
ERROR 1292 (22007): Incorrect datetime value: '1000-00-09'

2. What did you expect to see? (Required)

analyze table t1 with 0 topn is finished without error.

3. What did you see instead (Required)

analyze table t1 with 0 topn returns error.

4. What is your TiDB version? (Required)

6.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions