Re: RfD: more powerful "any" types - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: RfD: more powerful "any" types
Date
Msg-id 162867790909132234v728f14c6jb33678b1aba51479@mail.gmail.com
Whole thread Raw
In response to Re: RfD: more powerful "any" types  (Hannu Krosing <hannu@2ndQuadrant.com>)
List pgsql-hackers
2009/9/13 Hannu Krosing <hannu@2ndquadrant.com>:
> On Sun, 2009-09-13 at 21:50 +0200, Pavel Stehule wrote:
>> Hello
>>
>> >
>> > ANY [TYPE] and SAME AS [TYPE OF] are syntactic sugar indeed, but they
>> > are much more SQL-like than needing to write "any" or anyelement(n) as
>> > argument type or return type
>> >
>>
>> I looked on possibilities in gram.y and I thing, type identifiers
>>
>> "ANY TYPE" is possible without any problems (this should be synonym for "any"),
>> "SAME AS" needs add "same" keyword to col_name_keywords , i.e. "same"
>> is prohibited for function names - it should be a problem

I afraid so this technique isn't allowed in SQL parser, or is i

>>
>> regards
>> Pavel Stehule
>>
>> I found so pgparser provide some ref type syntax via % symbol. So we
>> can use following syntax:
>>
>> CREATE OR REPLACE FUNCTION foo(a ANY TYPE, b a%TYPE)
>> RETURNS a%TYPE ...
>>
>> It is not pretty like SAME AS, but I am sure, so this is doable
>> (parser knows it now)
>>
>> any other ideas?
>
> Hmm, maybe try to make lexer recognize "SAME AS" as one token and then
> deal with other cases of 'name AS' ?

I afraid so this technique isn't allowed in SQL parser, or is it?

>
> Or make the syntax a little uglier,
>
> CREATE OR REPLACE FUNCTION foo(a ANY TYPE, b TYPE OF a)
>
> CREATE OR REPLACE FUNCTION foo(ANY TYPE, TYPE OF $1)

TYPE OF generate shift/reduce too :(

Pavel

>
>
> and maybe try
>
> CREATE OR REPLACE FUNCTION foo(a ANY TYPE, b TYPE OF a)
> RETURNS ARRAY OF TYPE OF a
>
> instead of
>
> CREATE OR REPLACE FUNCTION foo(a anyelement, b anyelement)
> RETURNS anyarray
>
>>
>> regards
>> Pavel Stehule
>
>
> --
> Hannu Krosing   http://www.2ndQuadrant.com
> PostgreSQL Scalability and Availability
>   Services, Consulting and Training
>
>
>


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: [PATCH] 8.5 plpgsql change for named notation: treat word following AS keyword as label v3
Next
From: Peter Eisentraut
Date:
Subject: Re: Why does LOG have higher priority than ERROR and WARNING?