Skip to content

The query is inconsistent with MySQL when using the default value of the current_date() column in the function #53746

@BrianLiu955

Description

@BrianLiu955

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

#In TiDB
#table creation
mysql> show create table rand;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| rand | CREATE TABLE rand (
id int(11) DEFAULT NULL,
date_t date DEFAULT CURRENT_DATE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> insert into rand(id) values(1);
Query OK, 1 row affected (0.01 sec)

mysql> insert into rand values(1,'2024-06-03 00:00:00.000000');
Query OK, 1 row affected (0.01 sec)

mysql> select * from rand;
+------+------------+
| id | date_t |
+------+------------+
| 1 | 2024-06-03 |
| 1 | 2024-06-03 |
+------+------------+
2 rows in set (0.01 sec)

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

#Behavior in MySQL
root@localhost : test 02:15:59>>> select date_t ,count() from rand group by date_t;
+------------+----------+
| date_t | count(
) |
+------------+----------+
| 2024-06-03 | 2 |
+------------+----------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

#Behavior in TiDB
mysql> select date_t ,count() from rand group by date_t;
+------------+----------+
| date_t | count(
) |
+------------+----------+
| 2024-06-03 | 1 |
| 2024-06-03 | 1 |
+------------+----------+
2 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

v7.1.1

Metadata

Metadata

Assignees

Labels

affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.component/ddlThis issue is related to DDL of TiDB.report/customerCustomers have encountered this bug.severity/majortype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions