Re: Cast possible only throught a function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Mendola Gaetano" <mendola(at)bigfoot(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Cast possible only throught a function
Date: 2003-07-26 14:09:53
Message-ID: 9272.1059228593@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Mendola Gaetano" <mendola(at)bigfoot(dot)com> writes:
> but I notice that the following function return correctly
> doing the integer -> interval cast in one "shot":

What plpgsql is doing is roughly comparable to

regression=# select '0'::interval;
interval
----------
00:00:00
(1 row)

This is not the same as a SQL type conversion --- that works only when a
cast function is defined in pg_cast.

plpgsql is pretty lax about datatype considerations. It is willing to
try to convert anything to anything else by running the first type's
output procedure (to get text) and then the second type's input
procedure. In straight SQL you'd have to specify a cast to text to
get the equivalent behavior.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Theodore Petrosky 2003-07-26 14:25:51 Re: libpq.a must be ranlibed after installation
Previous Message Tom Lane 2003-07-26 14:02:55 Re: libpq.a must be ranlibed after installation