Skip to content

after changing DAY function,the value unexpectedly become null #260

@chen8908917

Description

@chen8908917

after changing DAY function,the value unexpectedly become null

mysql> SELECT DISTINCT DAY(yhw76.c5) AS col_1, VERSION() AS col_2 FROM t3 AS yhw76;
+-------+----------------------------+
| col_1 | col_2                      |
+-------+----------------------------+
|    18 | 5.6.29-PXC-5.4.19-SNAPSHOT |
+-------+----------------------------+
1 row in set (0.01 sec)

mysql> SELECT DISTINCT DAY(yhw76.c5 + INTERVAL '365' DAY) AS col_1, VERSION() AS col_2 FROM t3 AS yhw76;
+-------+----------------------------+
| col_1 | col_2                      |
+-------+----------------------------+
|  NULL | 5.6.29-PXC-5.4.19-SNAPSHOT |
+-------+----------------------------+
1 row in set (0.01 sec)

Additionally ,in mysql"9.5.0, it has been solved

mysql> SELECT DISTINCT DAY(yhw76.c5) AS col_1, VERSION() AS col_2 FROM t3 AS yhw76;
+-------+-------+
| col_1 | col_2 |
+-------+-------+
|    18 | 9.5.0 |
+-------+-------+
1 row in set (0.00 sec)

mysql> SELECT DISTINCT DAY(yhw76.c5 + INTERVAL '365' DAY) AS col_1, VERSION() AS col_2 FROM t3 AS yhw76;
+-------+-------+
| col_1 | col_2 |
+-------+-------+
|    18 | 9.5.0 |
+-------+-------+
1 row in set (0.00 sec)

How to repeat

DROP DATABASE IF EXISTS test;
CREATE DATABASE IF NOT EXISTS test;
USE test;


CREATE TABLE t3 (
    c5 TIME NULL
);

INSERT INTO t3 ( c5) VALUES ('2023-01-01 22:44:35');


SELECT DISTINCT DAY(yhw76.c5) AS col_1, VERSION() AS col_2 FROM t3 AS yhw76;
SELECT DISTINCT DAY(yhw76.c5 + INTERVAL '365' DAY) AS col_1, VERSION() AS col_2 FROM t3 AS yhw76;

Version

mysql> select polardb_version();
+---------+--------------+---------------------+
| TYPE    | VERSION      | RELEASE_DATE        |
+---------+--------------+---------------------+
| Product | PolarDB V2.0 | Distributed Edition |
| CN      | 2.4.0.5.4.19 | SNAPSHOT            |
| DN      | 2.4.0.8.4.19 | 20240430            |
| GMS     | 2.4.0.8.4.19 | 20240430            |
+---------+--------------+---------------------+
4 rows in set (0.00 sec)

mysql> select @@version;
+-------------------------+
| @@version               |
+-------------------------+
| 8.0.32-X-Cluster-8.4.19 |
+-------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions