![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
"Vitali Stupin" <Vitali.Stupin (AT) ria (DOT) ee> writes: The error "invalid memory alloc request size 4294967293" apears when selecting array of empty arrays: select ARRAY['{}'::text[],'{}'::text[]]; I can get a core dump off it too, sometimes. The problem is in ExecEvalArray, which computes the dimension of the result as [1:2] even though there are no elements to put in it. Joe, what do you think about this? Offhand I think that the only workable definition is that this case yields another zero-dimensional array, but maybe there is another choice? |
|
We should probably check all the other array operations to see if they have comparable problems. |
#2
| |||
| |||
|
|
Sorry for the slow response -- I'm at the airport just heading home from a marathon 30 day business trip. |
|
Tom Lane wrote: "Vitali Stupin" <Vitali.Stupin (AT) ria (DOT) ee> writes: The error "invalid memory alloc request size 4294967293" apears when selecting array of empty arrays: select ARRAY['{}'::text[],'{}'::text[]]; Joe, what do you think about this? Offhand I think that the only workable definition is that this case yields another zero-dimensional array, but maybe there is another choice? I think producing another zero-dimensional result is the only way that makes sense unless/until we change multidimensional arrays to really be arrays of array-datatype elements. Right now they're two different things. |
#3
| |||
| |||
|
|
Joe Conway <mail (AT) joeconway (DOT) com> writes: Sorry for the slow response -- I'm at the airport just heading home from a marathon 30 day business trip. Yow. Hope you get some time off... |
|
On looking at the code, I notice that this somewhat-related case works: regression=# select array[null::text[], null::text[]]; array ------- {} (1 row) The reason is that null inputs are just ignored in ExecEvalArray. So one pretty simple patch would be to ignore zero-dimensional inputs too. This would have implications for mixed inputs though: instead of regression=# select array['{}'::text[], '{a,b,c}'::text[]]; ERROR: multidimensional arrays must have array expressions with matching dimensions you'd get behavior like regression=# select array[null::text[], '{a,b,c}'::text[]]; array ----------- {{a,b,c}} (1 row) Which of these seems more sane? |
#4
| |||
| |||
|
|
... But as I've opined before, all of this seems to me to be much cleaner if arrays were always one-dimensional, and array elements could also be nested arrays (per SQL 2003). If we said that the cardinality of the nested array is an integral part of the datatype, then I think you would have: regression=# select array['{}'::text[], '{a,b,c}'::text[]]; ERROR: nested arrays must have array expressions with matching dimensions regression=# select array[NULL::text[], '{a,b,c}'::text[]]; array ----------- {NULL, {a,b,c}} (1 row) So maybe this is the behavior we should shoot for now? |
![]() |
| Thread Tools | |
| Display Modes | |
| |