Re: dblink: add polymorphic functions.

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: dblink: add polymorphic functions.
Дата
Msg-id 20150730171438.GQ2441@postgresql.org
обсуждение исходный текст
Ответ на Re: dblink: add polymorphic functions.  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: dblink: add polymorphic functions.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:
> Joe Conway <mail@joeconway.com> writes:
> > What about just TYPE then?
> 
> >     SELECT x::TYPE(some_expression) FROM ...
> >     SELECT CAST (x AS TYPE(some_expression)) FROM ...
> 
> Yeah, that would work.  Quick-hack proof-of-concept patch attached.

I'm amazed that this works without hacking the grammar itself, but in
retrospect that's expected.

> +     else if (pstate != NULL &&
> +              list_length(typeName->typmods) == 1 &&
> +              list_length(typeName->names) == 1 &&
> +              strcmp(strVal(linitial(typeName->names)), "type") == 0)
> +     {
> +         /* TYPE(expression) notation */
> +         Node       *typexpr = (Node *) linitial(typeName->typmods);

This is a rather ugly, but I guess not untenable.  I suppose we don't
care about any actual typmod, do we?.  Will this be of any use with the
PostGIS types and such, for which the typmod is not merely a size limit?
Also INTERVAL has some funny typmod rules, not sure if that affects
usage of this construct.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: multivariate statistics / patch v7
Следующее
От: Joe Conway
Дата:
Сообщение: Re: CREATE FUNCTION .. LEAKPROOF docs