From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | CAST vs :: |
Date: | 2017-07-13 18:27:39 |
Message-ID: | 10477.1499970459@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-07-13 18:30:25 | Re: PostgreSQL - Weak DH group |
Previous Message | Heikki Linnakangas | 2017-07-13 18:07:44 | Re: Fixup some misusage of appendStringInfo and friends |