Skip to content

bug: Convert DATETIME to TIME type error #995

@davidshiz

Description

@davidshiz

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

CONVERT(expr,type) function return result set error,
the wrong result is as follows:

mysql> SELECT CONVERT(c, TIME) FROM t1;
+------------------+
| CONVERT(c, TIME) |
+------------------+
| NULL             |
| 00:00:00         |
| 13:13:13         |
| 00:00:00         |
| 15:15:15         |
+------------------+
5 rows in set (0.12 sec)

Expected behavior

mysql> SELECT CONVERT(c, TIME) FROM t1;
+------------------+
| CONVERT(c, TIME) |
+------------------+
| 00:00:00         |
| 00:00:00         |
| 13:13:13         |
| 00:00:00         |
| 15:15:15         |
+------------------+
5 rows in set (0.01 sec)

How To Reproduce

set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE);
INSERT INTO t1 VALUES ('', NULL, '0-0-0', NULL),
('a', 12, '1212-12-12', 1.19691E+100),
('b', 13, '1313-3-13 13:13:13', 2.1961E+18),
('c', 14, '1414-4-14', 0.16191),
('d', 15, '2015-5-15 15:15:15', 1.971917);

SELECT CONVERT(c, TIME) FROM t1;

Environment

[root@HAST04 ~]# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: 7f69d33
        Last commit time: Date:   Tue Nov 22 06:31:04 2022 +0000
        Build time: Date: Tue Nov 22 16:53:27 CST 2022

[root@HAST04 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!

Metadata

Metadata

Assignees

Labels

A-bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions