From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@postgreSQL.org
Subject: CAST vs ::
Date: Thu, 13 Jul 2017 14:27:39 -0400
Message-ID: <10477.1499970459@sss.pgh.pa.us> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
In most places, you can write CAST(x AS t) and x::t interchangeably.
But that doesn't work for function-in-FROM. This is OK:
select * from cast(fdc() as complex);
but this is not:
select * from fdc()::complex;
ERROR: syntax error at or near "::"
I just realized that this is a problem for ruleutils.c, which thinks
it can always use the short form:
regression=# create view vv as select * from cast(fdc() as complex);
CREATE VIEW
regression=# \d+ vv
View "public.vv"
Column | Type | Collation | Nullable | Default | Storage | Descript
ion
--------+------------------+-----------+----------+---------+---------+---------
----
r | double precision | | | | plain |
i | double precision | | | | plain |
View definition:
SELECT fdc.r,
fdc.i
FROM fdc()::complex fdc(r, i);
That view definition will not reload.
Not sure about the most reasonable fix. It might be possible to tweak
the grammar to allow this case, but I'm not at all sure about that.
An easy fix would be to make ruleutils print casts as CAST() all the
time, but that would probably annoy a lot of people (it'd certainly
break a lot of regression tests). Maybe we can hack ruleutils to use
the CAST syntax only in this specific context.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: CAST vs ::
In-Reply-To: <10477.1499970459@sss.pgh.pa.us>
References: <10477.1499970459@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox