Re: BUG #2056: to_char no long takes time as input?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Nick Addington <adding(at)math(dot)wisc(dot)edu>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2056: to_char no long takes time as input?
Date: 2005-11-20 09:07:14
Message-ID: 20051120090714.GA32592@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-patches

On Sun, Nov 20, 2005 at 07:53:50AM +0000, Nick Addington wrote:
> The following code works in 8.0.4 but fails in 8.1.0:
>
> select to_char('1:00 pm'::time,'HH:MM AM');
>
> 8.1.0 gives this is the error message:
> ERROR: invalid format specification for an interval value
> HINT: Intervals are not tied to specific calendar dates.
>
> I saw some discussion on the -hackers list about deprecating
> to_char(interval, text), but do you really want to chuck to_char(time,
> text)? That's a useful function. Or at least, I was using it...

to_char(time,text) doesn't exist, at least not in 7.3 and later --
you can see that with "\df to_char" in psql. If you set debug_print_parse
to on and set client_min_messages to debug1, you'll see that the
function being called is funcid 1768, which is

test=> select 1768::regprocedure;
regprocedure
------------------------
to_char(interval,text)
(1 row)

You'll also see that this function's first argument is a function
expression with funcid 1370, which is

test=> select 1370::regprocedure;
regprocedure
------------------------------------
"interval"(time without time zone)
(1 row)

So the time value is first converted to an interval and then passed
to to_char(interval,text).

test=> select "interval"('1:00 pm'::time);
interval
----------
13:00:00
(1 row)

test=> select to_char('13:00:00'::interval,'HH:MM AM');
ERROR: invalid format specification for an interval value
HINT: Intervals are not tied to specific calendar dates.

This looks like the commit that changed the behavior in 8.1 (the
hint was added later):

http://archives.postgresql.org/pgsql-committers/2005-08/msg00200.php

--
Michael Fuhr

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Yusuf Belgore 2005-11-20 09:45:45 BUG #2057: unable to install a server on the admin
Previous Message Nick Addington 2005-11-20 07:53:50 BUG #2056: to_char no long takes time as input?

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-11-20 16:59:47 Re: BUG #2056: to_char no long takes time as input?
Previous Message Nick Addington 2005-11-20 07:53:50 BUG #2056: to_char no long takes time as input?