Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Robert Haas writes: > On Fri, Dec 17, 2010 at 2:58 PM, Tom Lane wrote: >> plpgsql's parser is rickety enough that I don't have a lot of confidence >> in its ability to do things that way. > Bummer. Rickety is not good. Agreed, but it's not entirely the parser's fault: the language definition i

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Robert Haas
On Fri, Dec 17, 2010 at 2:58 PM, Tom Lane wrote: > Robert Haas writes: >> On Fri, Dec 17, 2010 at 2:15 PM, Tom Lane wrote: >>> Robert Haas writes: Unfortunately, there are likely to be a limited number of such keywords available.  While I agree it's helpful to have a clear distin

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Robert Haas writes: > On Fri, Dec 17, 2010 at 2:15 PM, Tom Lane wrote: >> Robert Haas writes: >>> Unfortunately, there are likely to be a limited number of such >>> keywords available.  While I agree it's helpful to have a clear >>> distinction between what FOR does and what FOREACH does, it's w

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Robert Haas
On Fri, Dec 17, 2010 at 2:15 PM, Tom Lane wrote: > Robert Haas writes: >> Unfortunately, there are likely to be a limited number of such >> keywords available.  While I agree it's helpful to have a clear >> distinction between what FOR does and what FOREACH does, it's wholly >> conventional here

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
2010/12/17 Tom Lane : > Pavel Stehule writes: >> Second semi argument for using ARRAY keyword is a verbosity of >> PL/pgSQL. So from this perspective a ARRAY should be minimally >> optional and ensure, so expr result will be really a array. But with a >> optional ARRAY keyword we leaving a simple

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Pavel Stehule writes: > Second semi argument for using ARRAY keyword is a verbosity of > PL/pgSQL. So from this perspective a ARRAY should be minimally > optional and ensure, so expr result will be really a array. But with a > optional ARRAY keyword we leaving a simple enhancing in future (on > pa

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Robert Haas writes: > Unfortunately, there are likely to be a limited number of such > keywords available. While I agree it's helpful to have a clear > distinction between what FOR does and what FOREACH does, it's wholly > conventional here and won't be obvious without careful reading of the > do

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
2010/12/17 Robert Haas : > On Fri, Dec 17, 2010 at 1:38 PM, Tom Lane wrote: >> "David E. Wheeler" writes: >>> On Dec 17, 2010, at 9:31 AM, Tom Lane wrote: Well, we did beat up Pavel over trying to shoehorn this facility into the existing FOR syntax, so I can hardly blame him for thinkin

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Heikki Linnakangas
On 17.12.2010 21:04, Robert Haas wrote: Unfortunately, there are likely to be a limited number of such keywords available. While I agree it's helpful to have a clear distinction between what FOR does and what FOREACH does, it's wholly conventional here and won't be obvious without careful readin

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
> We would need an extra keyword if there were some third kind of > iteration that was fundamentally different from either of these, but > like I said, I don't see a plausible candidate.  So right at the moment, > I'm leaning to the position that we could do without the ARRAY keyword > in FOREACH.

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Robert Haas
On Fri, Dec 17, 2010 at 1:38 PM, Tom Lane wrote: > "David E. Wheeler" writes: >> On Dec 17, 2010, at 9:31 AM, Tom Lane wrote: >>> Well, we did beat up Pavel over trying to shoehorn this facility into >>> the existing FOR syntax, so I can hardly blame him for thinking this >>> way.  The question i

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
"David E. Wheeler" writes: > On Dec 17, 2010, at 9:31 AM, Tom Lane wrote: >> Well, we did beat up Pavel over trying to shoehorn this facility into >> the existing FOR syntax, so I can hardly blame him for thinking this >> way. The question is whether we're willing to assume that FOREACH will >> b

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread David E. Wheeler
On Dec 17, 2010, at 9:31 AM, Tom Lane wrote: > Well, we did beat up Pavel over trying to shoehorn this facility into > the existing FOR syntax, so I can hardly blame him for thinking this > way. The question is whether we're willing to assume that FOREACH will > be limited to iterating over array

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
2010/12/17 Andrew Dunstan : > > > On 12/17/2010 12:15 PM, Pavel Stehule wrote: >> >> 2010/12/17 Itagaki Takahiro: >>> >>> It should be not a main subject, but I remember there was a discussion >>> that "IN ARRAY array-expression" looks redundant for a literal array: >>> >>>  IN ARRAY ARRAY[1, 3, 5]

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Andrew Dunstan writes: > On 12/17/2010 12:15 PM, Pavel Stehule wrote: >> The reason for this is bigger space for possible >> future features related to FOREACH loop. > So what you're saying is we need to allow ugliness now so we can have > more ugliness in future? I don't find that a convincing

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Merlin Moncure writes: > On Fri, Dec 17, 2010 at 12:15 PM, Tom Lane wrote: >> [ scratches head... ]  I don't follow what you envision this doing, >> exactly? > It's like _pg_expandarray but alterted support multiple dimensions: > select * from unnest_dims(array[['a','b'],['c','d']]) returns > [

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Andrew Dunstan
On 12/17/2010 12:15 PM, Pavel Stehule wrote: 2010/12/17 Itagaki Takahiro: It should be not a main subject, but I remember there was a discussion that "IN ARRAY array-expression" looks redundant for a literal array: IN ARRAY ARRAY[1, 3, 5] Are there any improvement for the issue? yes. It

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Merlin Moncure
On Fri, Dec 17, 2010 at 12:15 PM, Tom Lane wrote: > Merlin Moncure writes: >> another way: > >> FOREACH scalar IN ARRAY arr_exp DIMS in dim_var > >> dim_var being int[], or possibly text, of length #dimensions, giving >> per dimesion index. > > [ scratches head... ]  I don't follow what you envis

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
2010/12/17 Itagaki Takahiro : > On Sat, Dec 18, 2010 at 02:03, Merlin Moncure wrote: >>>        FOREACH scalar-variable IN ARRAY array-expression >>>        FOR_EACH scalar-variable IN ARRAY array-expression >>>        FOR_SLICE array-variable [DEPTH n] IN ARRAY array-expression >>>        FOREACH

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Merlin Moncure writes: > another way: > FOREACH scalar IN ARRAY arr_exp DIMS in dim_var > dim_var being int[], or possibly text, of length #dimensions, giving > per dimesion index. [ scratches head... ] I don't follow what you envision this doing, exactly? I'm not thrilled with that specific

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Itagaki Takahiro
On Sat, Dec 18, 2010 at 02:03, Merlin Moncure wrote: >>        FOREACH scalar-variable IN ARRAY array-expression >>        FOR_EACH scalar-variable IN ARRAY array-expression >>        FOR_SLICE array-variable [DEPTH n] IN ARRAY array-expression >>        FOREACH scalar-variable IN ARRAY array-expr

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Dmitriy Igrishin
2010/12/17 Merlin Moncure > On Fri, Dec 17, 2010 at 11:38 AM, Tom Lane wrote: > > Pavel Stehule writes: > >> 2010/12/17 Tom Lane : > >>> Furthermore, it's underspecified: who's to say how many dimensions of > >>> the array are supposed to get sliced off? There's no reasonable place > >>> to ex

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
2010/12/17 Tom Lane : > Pavel Stehule writes: >> 2010/12/17 Tom Lane : >>> Furthermore, it's underspecified: who's to say how many dimensions of >>> the array are supposed to get sliced off?  There's no reasonable place >>> to extend this syntax to specify that.  It will also be inconsistent >>> f

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Merlin Moncure
On Fri, Dec 17, 2010 at 11:38 AM, Tom Lane wrote: > Pavel Stehule writes: >> 2010/12/17 Tom Lane : >>> Furthermore, it's underspecified: who's to say how many dimensions of >>> the array are supposed to get sliced off?  There's no reasonable place >>> to extend this syntax to specify that.  It wi

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Pavel Stehule writes: > 2010/12/17 Tom Lane : >> Furthermore, it's underspecified: who's to say how many dimensions of >> the array are supposed to get sliced off?  There's no reasonable place >> to extend this syntax to specify that.  It will also be inconsistent >> for "foreach scalar in array

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
2010/12/17 Tom Lane : > Merlin Moncure writes: >> On Fri, Dec 17, 2010 at 10:47 AM, Tom Lane wrote: >>> This seems like a really bad, confusing idea.  I think it should throw >>> a type-mismatch error in this case.  If there is any use-case for such a >>> thing, which I'm quite unconvinced of, it

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Merlin Moncure writes: > On Fri, Dec 17, 2010 at 10:47 AM, Tom Lane wrote: >> This seems like a really bad, confusing idea.  I think it should throw >> a type-mismatch error in this case.  If there is any use-case for such a >> thing, which I'm quite unconvinced of, it ought to use a separate syn

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
2010/12/17 Tom Lane : > Pavel Stehule writes: >> I am resending a redesigned proposal about special plpgsql statement >> that support iteration over an array. > > OK ... > >> == Iteration over multidimensional arrays == >> Its designed to reduce one dimension from source array. It can remove >> a

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Merlin Moncure
On Fri, Dec 17, 2010 at 10:47 AM, Tom Lane wrote: > Pavel Stehule writes: >> I am resending a redesigned proposal about special plpgsql statement >> that support iteration over an array. > > OK ... > >> == Iteration over multidimensional arrays == >> Its designed to reduce one dimension from sour

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Tom Lane
Pavel Stehule writes: > I am resending a redesigned proposal about special plpgsql statement > that support iteration over an array. OK ... > == Iteration over multidimensional arrays == > Its designed to reduce one dimension from source array. It can remove > a slicing and simplify code: This

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Pavel Stehule
2010/12/17 Alvaro Herrera : > Excerpts from Pavel Stehule's message of jue dic 16 16:19:17 -0300 2010: > >> The most performance issue of access to a untoasted  array is "solved" >> with other patch. > > Was the other patch applied? > no, it's in queue for next commitfest https://commitfest.postg

Re: [HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-17 Thread Alvaro Herrera
Excerpts from Pavel Stehule's message of jue dic 16 16:19:17 -0300 2010: > The most performance issue of access to a untoasted array is "solved" > with other patch. Was the other patch applied? -- Álvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting,

[HACKERS] proposal: FOREACH-IN-ARRAY (probably for 9.2?)

2010-12-16 Thread Pavel Stehule
Hello I am resending a redesigned proposal about special plpgsql statement that support iteration over an array. The most conflict issue of last proposal was a syntax. It enhanced relative complex FOR statement. So now, it's based on new statement with simple syntax. We can use a keyword FOREACH,