Re: [GENERAL] Needed function IF(expr, expr, expr)
| От | Tom Lane |
|---|---|
| Тема | Re: [GENERAL] Needed function IF(expr, expr, expr) |
| Дата | |
| Msg-id | 16032.1062981485@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: [GENERAL] Needed function IF(expr, expr, expr) (Rod Taylor <rbt@rbt.ca>) |
| Ответы |
Re: [GENERAL] Needed function IF(expr, expr, expr)
|
| Список | pgsql-hackers |
Rod Taylor <rbt@rbt.ca> writes:
>> Any comments on the UNKNOWN issue? It's not too late to change that for
>> 7.4, if we have consensus that we should.
> I would actually prefer to get UNKNOWN so I can apply my own default
> type, but we're not even given the chance to resolve the unknown issue
> ourselves.
> CREATE OR REPLACE FUNCTION if(bool,anyelement,anyelement)
> RETURNS anyelement
> AS 'SELECT
> CASE WHEN $2 is of (unknown) THEN
> CASE WHEN $1 THEN $2::point ELSE $3::point END
> ELSE
> CASE WHEN $1 THEN $2 ELSE $3 END
> END' language SQL;
There's no chance of that working --- the parser has to be able to
determine the result type of a function invocation without reference
to the function body. (Otherwise CREATE OR REPLACE FUNCTION invalidates
every use of the function.)
I don't feel that the anyelement in -> anyelement out mechanism is the
last word in polymorphism, though. Care to propose additional features
of the same kind? If you can find a way to describe the behavior you
want in terms of the function signature, it'd be worth considering ...
regards, tom lane
В списке pgsql-hackers по дате отправления: