← Back to team overview

maria-developers team mailing list archive

Re: MDEV-11829 RFC3339 Support

 

Hi, Seth!

On Feb 02, Seth Shelnutt wrote:
> Hello,
> 
> This is in response to the comments on the initial pull request I made
> for adding RFC3339 support [1].
> 
> The proposal is to add support for parsing RFC3339 and then use the
> given timezone offset to shift the datetime.  I think most users would
> expect the behavior to be converted to the timezone of the mariadb
> server / session as defined in THD. Most timezone operations are
> depended on the session specified timezone, whether that is set or
> inherited from global timezone, or system timezone.

It's not what SQL standard specifies. It says,

  <...> whenever a datetime value without time zone is to be implicitly
  derived from one with, SQL assumes the value with time zone to be UTC,
  adds the time zone displacement to it to give local time, and the
  result, without any time zone displacement, is local.

This doesn't make much sense to be, really, because it totally ignores
the session time zone. On the other hand, if you'd convert the UTC value
to be in the session time zone, you'd totally ignore the displacement
value. I don't see any behavior being better than the other, so I'd
stick to the standard by default.

> In order to convert from RFC3339 timezone to session timezone, we will
> need to return the timezone from the str_to_datetime function. As
> mentioned there is no timezone member of the MY_TIME struct. I believe
> a change to the MY_TIME struct would be the most beneficial and
> cleanest approach. This would allow for handling RFC3339 and future
> additions, such as a datetime with time zone field, similar to the
> ansi timestamp with time zone. The struct is used in a several ways,
> including packing into longlong, all of those cases would need to be
> handled. This would be a much larger and more involved patchset.

To support TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE literals
(literals only, not expressions or fields or variables), it would be
enough to parse them in str_to_datetime(), there is no need to return
the time zone back to the caller in MY_TIME.

> With any approach, the timezone could then be handled outside of
> my_time.c, where we have THD and the timezone class, which can easily
> handle the conversion.

There is no need to handle time zone outside of my_time.c if
all we want is TIMESTAMP WITH TIME ZONE literals with the standard
conversion behavior. It can be implemented completely inside
str_to_datetime.

Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx


Follow ups

References