I tested a concept iteration over array in format [key1, value1, key2, value2, .. ] - what is nice, it works for [[key1,value1],[key2, value2], ...] too
It is only a few lines more to current code, and this change doesn't break a compatibility.
Do you think, so this patch is acceptable?
Ideas, comments?
Aside from fixing the comments... I think this needs more tests on corner cases. For example, what happens when you do
foreach a, b, c in array(array(1,2),array(3,4)) ?
it is relative simple behave -- empty values are NULL
array(1,2),array(3,4) -- do you think ARRAY[[1,2],[3,4]] is effectively ARRAY[1,2,3,4]
Or the opposite case of
foreach a,b in array(array(1,2,3))
Also, what about:
foreach a,b in '{{{1,2},{3,4}},{{5,6},{7,8}}}'::int[] ?
I fixed situation when array has not enough elements.
This no longer applies due to conflicts in src/pl/plpgsql/src/pl_exec.c caused by e524cbdc45ec6d677b1dd49
Also, what is the relationship of this patch to the row_to_array patch? Are they independent, or does one depend on the other? row_to_array by itself applies but doesn't compile.