Re: dblink: add polymorphic functions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
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:31:35
Message-ID: 28307.1438277495@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> Tom Lane wrote:
>> Yeah, that would work. Quick-hack proof-of-concept patch attached.

> This is a rather ugly, but I guess not untenable. I suppose we don't
> care about any actual typmod, do we?.

We get the type and typmod both from the expression. Example:

regression=# create table ref (f1 varchar, f2 varchar(3));
CREATE TABLE
regression=# insert into ref values('1','2');
INSERT 0 1
regression=# select '1234567890'::type(f1) from ref;
type
------------
1234567890
(1 row)

regression=# select '1234567890'::type(f2) from ref;
type
------
123
(1 row)

> Will this be of any use with the
> PostGIS types and such, for which the typmod is not merely a size limit?

Don't see why not. They still have to follow the rule that typmod is a
static property of an expression.

> Also INTERVAL has some funny typmod rules, not sure if that affects
> usage of this construct.

I would not think so. The weirdness about INTERVAL mainly has to do with
SQL's, ahem, inventive collection of ways to write an interval constant,
and that wouldn't really be an issue for any practical use of this
construct AFAICS. Whatever you write as the expression, we're going to
be able to reduce to a type OID and typmod.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2015-07-30 18:14:13 Re: Failing assertions in indxpath.c, placeholder.c and brin_minmax.c
Previous Message Joe Conway 2015-07-30 17:18:17 Re: CREATE FUNCTION .. LEAKPROOF docs