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 via email to