Re: How hard would it be to support LIKE in return declaration of generic record function calls ?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Hannu Krosing <hannu(at)2ndquadrant(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: How hard would it be to support LIKE in return declaration of generic record function calls ?
Date: 2012-05-03 15:05:29
Message-ID: CAFj8pRBPiMrFudJ25NharZd=1hBgb6HAsO-R-sqo+KLotAN72Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/5/3 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> 2012/5/3 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>>> This notion of "anytypename" is utterly unworkable anyway; there's no
>>> way for the parser to know soon enough that a given argument position
>>> needs to be read as a type name rather than a normal expression.
>
>> type identifier is same identifier like other - but I have no
>> prototype now, so I don't know if there is some trap
>
> No, it isn't, at least not if you have any ambition to support array
> types for instance; to say nothing of types whose standard names are
> keywords, multiple words, etc.  Even if you were willing to restrict the
> feature to only work for simple-identifier type names, the parser would
> have thrown an error for failing to find a column by that name, or else
> would have misinterpreted the type name as a column name, long before
> there is any opportunity to recognize that the argument position is
> an "anytypename" argument.

we can identify a position "anytypename" before raising error - it can
be similar to current identification of PL/pgSQL variables inside
expression. Probably it is too complex for this issue :(

Maybe some keyword can help to us. What do you think about new
operator TYPE that can returns regtype value and can be used together
with polymorphic functions.

CREATE FUNCTION foo(anyregtype, ....)
RETURNS anyelement AS ..

SELECT foo('mytype', ....)

or

SELECT foo(TYPE mytype, ....)

It is little bit cleaner than NULL::type.

Regards

Pavel

>
>                        regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-05-03 15:06:53 Re: "unexpected EOF" messages
Previous Message Bruce Momjian 2012-05-03 15:01:55 Re: pgsql: Remove dead ports