Skip site navigation (1)
Skip section navigation (2)
## Re: BUG #2694: Memory allocation error when selecting array

### In response to

### Responses

### pgsql-bugs by date

Tom Lane wrote: > 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... Yeah, I just took a week. Next week I'm back to work and the week after that I'm back to Germany for a few... > 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? I'm not sure I love either. I would think both NULL and empty array expressions should be disallowed in this scenario, i.e.: regression=# select array['{}'::text[], '{a,b,c}'::text[]]; ERROR: multidimensional arrays must have array expressions with matching dimensions regression=# select array[NULL::text[], '{a,b,c}'::text[]]; ERROR: multidimensional arrays must have array expressions with matching dimensions In both cases you are trying to construct a multidimensional array with inconsistent dimensions. On the other hand, building an N-dimension array from entirely empty array expressions should just produce an empty array, while using all NULL expressions should produce an N-dim array full of NULLs. 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? Joe

- Re: BUG #2694: Memory allocation error when selecting array at 2006-10-18 18:08:36 from Tom Lane

- Re: BUG #2694: Memory allocation error when selecting array at 2006-11-06 18:28:37 from Tom Lane

Next: From:Thomas H.Date:2006-10-29 20:21:05Subject: Re: BUG #2712: could not fsync segment: PermissionPrevious: From: Magnus HaganderDate: 2006-10-29 17:10:37Subject: Re: BUG #2712: could not fsync segment: Permission