plpgsql: support identif%TYPE[], (from ToDo)

Lists: pgsql-hackers
From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: plpgsql: support identif%TYPE[], (from ToDo)
Date: 2009-07-28 20:53:08
Message-ID: 162867790907281353q65ac87fx205029b224353b03@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

I would to solve some points from ToDo. I began with TYPE [] support.
I thing, so this should be relative simple, but there are one issue.

There are syntax for declare array from scalar type -

create or replace function x(a int)
returns ... as $$
declare f a%type[] <--
begin ...

but there are not syntax for inversion - scalar from array.
Theoretically we could to define variable with same type (array) and
everywhere work with first element. Or we should to define some
syntax:

My first idea is using word element:

create or replace function x(a int[])
...
declare f a%element;
begin
...

any ideas?

regards
Pavel


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql: support identif%TYPE[], (from ToDo)
Date: 2009-07-28 21:11:13
Message-ID: 20090728211113.GB22289@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jul 28, 2009 at 10:53:08PM +0200, Pavel Stehule wrote:
> Hello
>
> I would to solve some points from ToDo. I began with TYPE [] support.
> I thing, so this should be relative simple, but there are one issue.

<snip>

> My first idea is using word element:
>
> create or replace function x(a int[])
> ...
> declare f a%element;
> begin
> ...

I would have thought:

declare f a[0]%type;

as in: the type of a[0]. Perhaps a[]%type but that seems less natural.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql: support identif%TYPE[], (from ToDo)
Date: 2009-07-29 03:49:36
Message-ID: 28917.1248839376@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> I would to solve some points from ToDo. I began with TYPE [] support.

plpgsql's %type support is a crock that's going to have to be rewritten
from the ground up as soon as we consolidate the lexer with the core.
I wouldn't suggest spending any time in that area now.

regards, tom lane


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql: support identif%TYPE[], (from ToDo)
Date: 2009-07-29 05:44:23
Message-ID: 162867790907282244h304d4939heb026889f60fe9ed@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2009/7/29 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> I would to solve some points from ToDo. I began with TYPE [] support.
>
> plpgsql's %type support is a crock that's going to have to be rewritten
> from the ground up as soon as we consolidate the lexer with the core.
> I wouldn't suggest spending any time in that area now.

ook

Pavel

>
>                        regards, tom lane
>


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql: support identif%TYPE[], (from ToDo)
Date: 2009-07-29 10:56:46
Message-ID: 603c8f070907290356v49f467b6nbf72eae48d2b296c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jul 29, 2009 at 1:44 AM, Pavel Stehule<pavel(dot)stehule(at)gmail(dot)com> wrote:
> 2009/7/29 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>>> I would to solve some points from ToDo. I began with TYPE [] support.
>>
>> plpgsql's %type support is a crock that's going to have to be rewritten
>> from the ground up as soon as we consolidate the lexer with the core.
>> I wouldn't suggest spending any time in that area now.
>
> ook

There's also the fact that we still have almost half the patches in
this CommitFest that have yet to be closed out. If you're looking for
something to do....

...Robert


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql: support identif%TYPE[], (from ToDo)
Date: 2009-07-29 15:25:53
Message-ID: 162867790907290825p5e2554ffvf958829454d24b47@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2009/7/29 Robert Haas <robertmhaas(at)gmail(dot)com>:
> On Wed, Jul 29, 2009 at 1:44 AM, Pavel Stehule<pavel(dot)stehule(at)gmail(dot)com> wrote:
>> 2009/7/29 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>>> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>>>> I would to solve some points from ToDo. I began with TYPE [] support.
>>>
>>> plpgsql's %type support is a crock that's going to have to be rewritten
>>> from the ground up as soon as we consolidate the lexer with the core.
>>> I wouldn't suggest spending any time in that area now.
>>
>> ook
>
> There's also the fact that we still have almost half the patches in
> this CommitFest that have yet to be closed out.  If you're looking for
> something to do....
>

I am bad man for review and I understand little bit only to plpgsql. I
am preparing plan for next commitfest.

Pavel

> ...Robert
>


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql: support identif%TYPE[], (from ToDo)
Date: 2009-07-29 15:30:08
Message-ID: 162867790907290830p7a0d81f0g67c30c5ffd807f6d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2009/7/28 Martijn van Oosterhout <kleptog(at)svana(dot)org>:
> On Tue, Jul 28, 2009 at 10:53:08PM +0200, Pavel Stehule wrote:
>> Hello
>>
>> I would to solve some points from ToDo. I began with TYPE [] support.
>> I thing, so this should be relative simple, but there are one issue.
>
> <snip>
>
>> My first idea is using word element:
>>
>> create or replace function x(a int[])
>> ...
>> declare f a%element;
>> begin
>> ...
>
> I would have thought:
>
> declare f a[0]%type;
>
> as in: the type of a[0]. Perhaps a[]%type but that seems less natural.
>

It's clean so a[0] means element of array, but why zero. PostgreSQL
array should to start from any int value :(. And this syntax is little
bit difficult parserable.

What do you thing about:

declare
f array of a%type;
x element of f%type;

??

regards
Pavel

> Have a nice day,
> --
> Martijn van Oosterhout   <kleptog(at)svana(dot)org>   http://svana.org/kleptog/
>> Please line up in a tree and maintain the heap invariant while
>> boarding. Thank you for flying nlogn airlines.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iD8DBQFKb2lxIB7bNG8LQkwRApwuAJ4snkAtixsMa2ju8r0jYYIH2hIJ6ACeOVQj
> /oiBdGmX8zQddwmwsvjLnOM=
> =xtg2
> -----END PGP SIGNATURE-----
>
>