Re: REVIEW: WIP: plpgsql - foreach in

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: REVIEW: WIP: plpgsql - foreach in
Date: 2011-01-24 11:10:03
Message-ID: AANLkTi=FU-XDD59vWo_HFJy2foSuCRTc+WbZ8okeyT+K@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

>
>
>> Other comments- I don't like using 'i' and 'j', you really should use
>> better variable names, especially in large loops which contain other
>> loops.  I'd also suggest changing the outer loop to be equivilant to the
>> number of iterations that will be done instead of the number of items
>> and then to *not* update 'i' inside the inner-loop.  That structure is
>> really just confusing, imv (I certainly didn't entirely follow what was
>> happening there the first time I read it).  Isn't there a function you
>> could use to pull out the array slice you need on each iteration through
>> the array?

I looked on code again. There are a few results:

I'll change identifiers 'i' and 'j' with any, that you send. It's
usual identifiers for nested loops and in this case they has really
well known semantic - it's subscript of array.

But others changes are more difficult

we have to iterate over array's items because it allow seq. access to
array's data. I need a global index for function "array_get_isnull". I
can't to use a buildin functions like array_slize_size or
array_get_slice, because there is high overhead of array_seek
function. I redesigned the initial part of main cycle, but code is
little bit longer :(, but I hope, it is more readable.

Regards

Pavel

>>
>
> I don't know a better short index identifiers than I used. But I am
> not against to change.
>
> I'll try to redesign main cycle.
>
> Regards
>
> Pavel Stehule
>
>
>
>>        Thanks,
>>
>>                Stephen
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.10 (GNU/Linux)
>>
>> iEYEARECAAYFAk086MEACgkQrzgMPqB3kigCzQCffx0iVSMjU2UbOgAOaY/MvtOp
>> iKsAnA5tdhKxTssdXJ+Rda4qkhNVm26g
>> =Yn5O
>> -----END PGP SIGNATURE-----
>>
>>
>

Attachment Content-Type Size
foreach.diff text/x-patch 16.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Cédric Villemain 2011-01-24 11:30:40 Re: REVIEW: WIP: plpgsql - foreach in
Previous Message Itagaki Takahiro 2011-01-24 10:15:26 Re: Add support for logging the current role