Re: Bug fix for missing years in make_date()

From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug fix for missing years in make_date()
Date: 2015-04-01 15:40:27
Message-ID: 20150401154027.GA18201@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 31, 2015 at 12:22:39PM -0700, David Fetter wrote:
> On Tue, Mar 31, 2015 at 12:58:27PM -0400, Tom Lane wrote:
> > David Fetter <david(at)fetter(dot)org> writes:
> > > On Tue, Mar 31, 2015 at 10:34:45AM -0400, Adam Brightwell wrote:
> > >> Previously, zero was rejected, what does it do now? I'm sure it
> > >> represents 0 AD/CE, however, is that important enough to note
> > >> given that it was not allowed previously?
> >
> > > Now, it's supposed to take 0 as 1 BCE, -1 as 2 BCE, etc. There
> > > should probably be tests for that.
> >
> > Surely that is *not* what we want?
>
> It is if we're to be consistent with the rest of the system, to wit:
>
> SELECT to_date('YYYY','0000');
> to_date
> ---------------
> 0001-01-01 BC
> (1 row)

Looking at this further, I think that it should be consistent with
cast rather than with to_date().

SELECT date '0000-01-01';
ERROR: date/time field value out of range: "0000-01-01"
LINE 1: SELECT date '0000-01-01';

Please find attached the next revision of the patch.

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment Content-Type Size
wider_make_date_003.patch text/plain 2.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Denish Patel 2015-04-01 15:46:46 Re: Permission select pg_stat_replication
Previous Message Robert Haas 2015-04-01 15:40:13 Re: Tables cannot have INSTEAD OF triggers