Skip site navigation (1) Skip section navigation (2)

Re: help: now() + N is now failing!

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: mel(at)gmanmi(dot)tv, pgsql-novice(at)postgresql(dot)org
Subject: Re: help: now() + N is now failing!
Date: 2003-07-29 15:20:27
Message-ID: 22295.1059492027@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Dmitry Tkach <dmitry(at)openratings(dot)com> writes:
> I guess, the now()+2 has the same problem - for some reason, it fails to 
> coerce timestamptz into date automatically :-(
> Why is that? There is only one function called date_pli(), and there is 
> an unambigous conversion date(timestamptz)... Why does it now force the 
> user to cast explicitly???

Because it's an information-losing coercion.

To reduce the odds that a surprising interpretation will be chosen, we
have tightened the casting rules so that only up-promotions and not
down-promotions will happen implicitly within expressions.

As a comparison point, you would like float8 + int4 to be done in
float8 rather than int4 arithmetic, would you not?  If both directions
of casting are equally implicit then there's no basis for the parser to
choose the preferred operator.

An alternative approach for Mel to fix his problem is to change the
pg_cast entry for timestamptz-to-date to allow it to happen implicitly,
but (a) that might have unforeseen side effects in other contexts, and
(b) it wouldn't get dumped by pg_dump, as a custom operator will.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Dmitry TkachDate: 2003-07-29 16:01:39
Subject: Re: help: now() + N is now failing!
Previous:From: Stephan SzaboDate: 2003-07-29 15:08:51
Subject: Re: help: now() + N is now failing!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group