Re: REVIEW: WIP: plpgsql - foreach in - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: REVIEW: WIP: plpgsql - foreach in
Date
Msg-id AANLkTi=FU-XDD59vWo_HFJy2foSuCRTc+WbZ8okeyT+K@mail.gmail.com
Whole thread Raw
In response to Re: REVIEW: WIP: plpgsql - foreach in  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: REVIEW: WIP: plpgsql - foreach in  (Cédric Villemain <cedric.villemain.debian@gmail.com>)
Re: REVIEW: WIP: plpgsql - foreach in  (Itagaki Takahiro <itagaki.takahiro@gmail.com>)
List 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

pgsql-hackers by date:

Previous
From: Itagaki Takahiro
Date:
Subject: Re: Add support for logging the current role
Next
From: Cédric Villemain
Date:
Subject: Re: REVIEW: WIP: plpgsql - foreach in