Re: dblink: add polymorphic functions.

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joe Conway <mail(at)joeconway(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: dblink: add polymorphic functions.
Date: 2015-07-30 17:14:38
Message-ID: 20150730171438.GQ2441@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Joe Conway <mail(at)joeconway(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2015-07-30 17:18:17 Re: CREATE FUNCTION .. LEAKPROOF docs
Previous Message Heikki Linnakangas 2015-07-30 16:58:39 Re: multivariate statistics / patch v7