[MDEV-15287] Bad result for LEAST/GREATEST(datetime_alike_string, time) Created: 2018-02-12  Updated: 2018-02-13  Resolved: 2018-02-12

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.3.5

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-8894 Inserting fractional seconds into My... Closed

 Description   

This query returns bad results:

SELECT
  GREATEST('2010-01-01 10:10:10',TIME('-20:20:20')),
  GREATEST('2010-01-01 10:10:10',TIME('20:20:20')),
  LEAST('2010-01-01 10:10:10',TIME('-20:20:20')),
  LEAST('2010-01-01 10:10:10',TIME('20:20:20'))\G

GREATEST('2010-01-01 10:10:10',TIME('-20:20:20')): 802:10:10.000000
 GREATEST('2010-01-01 10:10:10',TIME('20:20:20')): 802:10:10.000000
   LEAST('2010-01-01 10:10:10',TIME('-20:20:20')): -20:20:20.000000
    LEAST('2010-01-01 10:10:10',TIME('20:20:20')): 20:20:20.000000

Implicit conversion from the string literal '2010-01-01 10:10:10' to TIME does not seem to work well inside LEAST/GREATEST.

The expected behavior would be to return results similar to this query (with explicit CAST added around the string):

SELECT
  GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')),
  GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20')),
  LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')),
  LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20'))\G

GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')): 10:10:10.000000
 GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20')): 20:20:20.000000
   LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')): -20:20:20.000000
    LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20')): 10:10:10.000000



 Comments   
Comment by Alexander Barkov [ 2018-02-12 ]

Pushed to bb-10.2-ext

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