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);
regression=# \d+ vv
                                  View "public.vv"
 Column |       Type       | Collation | Nullable | Default | Storage | Descript
 r      | double precision |           |          |         | plain   | 
 i      | double precision |           |          |         | plain   | 
View definition:
 SELECT fdc.r,
   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 (
To make changes to your subscription:

Reply via email to