[HACKERS] CAST vs ::

Поиск
Список
Период
Сортировка
От Tom Lane
Тема [HACKERS] CAST vs ::
Дата
Msg-id 10477.1499970459@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: [HACKERS] CAST vs ::  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: [HACKERS] Fixup some misusage of appendStringInfo and friends
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] PostgreSQL - Weak DH group