Re: Date-Time dangling unit fix - Mailing list pgsql-hackers

From Joseph Koshakow
Subject Re: Date-Time dangling unit fix
Date
Msg-id CAAvxfHcr0ibhcoxPg7LLDXDwTmcjKimk+53vH3_Lzgwxb4LfFQ@mail.gmail.com
Whole thread Raw
In response to Re: Date-Time dangling unit fix  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Date-Time dangling unit fix  (Alexander Lakhin <exclusion@gmail.com>)
List pgsql-hackers
On Sat, Mar 4, 2023 at 4:05 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>    I started to look at this, and soon noticed that while we have test cases
>    matching this sort of date input, there is no documentation for it.  The
>    code claims it's an "ISO" (presumably ISO 8601) format, and maybe it is
>    because it looks a lot like the ISO 8601 format for intervals (durations).
>    But I don't have a copy of ISO 8601, and some googling fails to find any
>    indication that anybody else believes this is a valid datetime format.
>    Wikipedia for example documents a lot of variants of ISO 8601 [1],
>    but nothing that looks like this.
>
>    I wonder if we should just rip this code out instead of fixing it.
>    I suspect its real-world usage is not different from zero.  We'd
>    have to keep the "Jnnn" Julian-date case, though, so maybe there's
>    little to be saved.
>
>    If we do keep it, there's documentation work to be done.  But the
>    first bit of doco I'd want to see is a pointer to a standard.

I also don't have a copy of ISO 8601 and wasn't able to find anything
about this variant on Google. I did find this comment in datetime.c

/*
* Was this an "ISO date" with embedded field labels? An
* example is "y2001m02d04" - thomas 2001-02-04
*/

which comes from this commit [1], which was authored by Thomas Lockhart
(presumably the same thomas from the comment). I've CC'ed Thomas in
case the email still exists and they happen to remember. The commit
message mentions ISO, but not the variant mentioned in the comment.
The mailing list thread can be found here [2], but it doesn't provide
much more information. I also found the following thread [3], which
happens to have you in it in case you remember it, which seemed to be
the motivation for commit [1]. It only contains the following line
about ISO:

> o support for "ISO variants" on input, including embedded "T" preceeding
the time fields

All that seems to imply the "y2001m02d04" ISO variant was never really
discussed in much detail and it's probably fine to remove it. Though,
it has been around for 22 years which makes it a bit scary to remove.

- Joe Koshakow

[1] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=6f58115dddfa8ca63004c4784f57ef660422861d
[2] https://www.postgresql.org/message-id/flat/3BB433D5.3CB4164E%40fourpalms.org
[3] https://www.postgresql.org/message-id/flat/3B970FF8.B9990807%40fourpalms.org#c57d83c80d295bfa19887c92122369c3

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?)
Next
From: Jeff Davis
Date:
Subject: Re: Add standard collation UNICODE