mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Fix handling of empty arrays in array_fill().
array_fill(..., array[0]) produced an empty array, which is probably what users expect, but it was a one-dimensional zero-length array which is not our standard representation of empty arrays. Also, for no very good reason, it rejected empty input arrays; that case should be allowed and produce an empty output array. In passing, remove the restriction that the input array(s) have lower bound 1. That seems rather pointless, and it would have needed extra complexity to make the check deal with empty input arrays. Per bug #14487 from Andrew Gierth. It's been broken all along, so back-patch to all supported branches. Discussion: https://postgr.es/m/20170105152156.10135.64195@wrigleys.postgresql.org
This commit is contained in:
@@ -482,11 +482,19 @@ select array_fill(7, array[3,3],array[2,2]);
|
||||
select array_fill(7, array[3,3]);
|
||||
select array_fill('juhu'::text, array[3,3],array[2,2]);
|
||||
select array_fill('juhu'::text, array[3,3]);
|
||||
select a, a = '{}' as is_eq, array_dims(a)
|
||||
from (select array_fill(42, array[0]) as a) ss;
|
||||
select a, a = '{}' as is_eq, array_dims(a)
|
||||
from (select array_fill(42, '{}') as a) ss;
|
||||
select a, a = '{}' as is_eq, array_dims(a)
|
||||
from (select array_fill(42, '{}', '{}') as a) ss;
|
||||
-- raise exception
|
||||
select array_fill(1, null, array[2,2]);
|
||||
select array_fill(1, array[2,2], null);
|
||||
select array_fill(1, array[2,2], '{}');
|
||||
select array_fill(1, array[3,3], array[1,1,1]);
|
||||
select array_fill(1, array[1,2,null]);
|
||||
select array_fill(1, array[[1,2],[3,4]]);
|
||||
|
||||
select string_to_array('1|2|3', '|');
|
||||
select string_to_array('1|2|3|', '|');
|
||||
|
Reference in New Issue
Block a user