Re: insert throw error when year field len > 4 for timestamptz datatype - Mailing list pgsql-hackers

From Robert Haas
Subject Re: insert throw error when year field len > 4 for timestamptz datatype
Date
Msg-id CA+TgmoYSMQBr=h-MdxnhsnomsqYLHq+hw+6WNQCjjRkoHr6u7w@mail.gmail.com
Whole thread Raw
In response to Re: insert throw error when year field len > 4 for timestamptz datatype  (Rushabh Lathia <rushabh.lathia@gmail.com>)
Responses Re: insert throw error when year field len > 4 for timestamptz datatype  (Rushabh Lathia <rushabh.lathia@gmail.com>)
List pgsql-hackers
On Mon, Oct 7, 2013 at 12:41 AM, Rushabh Lathia
<rushabh.lathia@gmail.com> wrote:
> Hmm right it has some inconsistency when year length is 6. But the patch
> is based on assumption that 5-digit number is a year, because YMD and HMS
> require at least six digits. Now Year with 6-digit number its getting
> conflict with
> YMD and HMS, that the reason its ending up with error. So with patch
> approach
> that's an expected behaviour for me.
>
> I spent good amount of time on thinking how we can improve the behaviour, or
> how can be change the assumption about the year field, YMD and HMS. At
> current point of time it seems difficult to me because postgres date module
> is tightly build with few assumption and changing that may lead to big
> project.
> Not sure but personally I feel that patch which was submitted earlier was
> definitely good improvement.
>
> Any other suggestion or thought for improvement ?

I'm not entirely convinced that this patch is heading in the right
direction.  The thing is, it lets you use 5-digit years always and
longer years only in some contexts.  So I'm not sure this is really
good enough for unambiguous date input.  If you want that, you should
probably be using trusty YYYYYYYYYYY-MM-DD format.  But if you don't
need that, then isn't a five-digit year most likely a typo?  This
might be a case where throwing an error is actually better than trying
to make sense of the input.

I don't feel super-strongly about this, but I offer it as a question
for reflection.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: SSI freezing bug
Next
From: Robert Haas
Date:
Subject: Re: pgbench progress report improvements - split 3 v2 - A