On 2017/12/08 23:34, Tom Lane wrote:
> Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> writes:
>> I wonder if ScalarArrayOpExpr is not really meant for multi-dimensional
>> arrays appearing on the right hand side? Because:
>> # select array[1] = any (array[array[1], array[2]]);
>
>> ERROR: operator does not exist: integer[] = integer
>
> You are falling into the misimpression that a 2-D array is an array of
> 1-D arrays. It is not, even if the syntax makes it look like that.
>
> ScalarArrayOpExpr just iterates over the array elements without regard
> to dimensionality; so the LHS must be of the element type.
Yeah, I can now see that.
Although, I wonder if there is any room for improvement here. Instead of
waiting for make_scalar_array_op() to emit the error as it does today,
would it be better if we error'd out earlier saying "ERROR: ANY/ALL
leftarg must be scalar, not array"? Attached a patch for that, if it's
worth going for at all.
Thanks,
Amit