mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Allow to omit boundaries in array subscript
Allow to omiy lower or upper or both boundaries in array subscript for selecting slice of array. Author: YUriy Zhuravlev
This commit is contained in:
@@ -609,3 +609,18 @@ SELECT width_bucket(5, '{}');
|
||||
SELECT width_bucket('5'::text, ARRAY[3, 4]::integer[]);
|
||||
SELECT width_bucket(5, ARRAY[3, 4, NULL]);
|
||||
SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]);
|
||||
|
||||
-- slices with empty lower and/or upper index
|
||||
CREATE TABLE arrtest_s (
|
||||
a int2[],
|
||||
b int2[][]
|
||||
);
|
||||
INSERT INTO arrtest_s VALUES ('{1,2,3,4,5}', '{{1,2,3}, {4,5,6}, {7,8,9}}');
|
||||
SELECT a[:3], b[:2][:2] FROM arrtest_s;
|
||||
SELECT a[2:], b[2:][2:] FROM arrtest_s;
|
||||
SELECT a[:], b[:] FROM arrtest_s;
|
||||
|
||||
-- errors
|
||||
UPDATE arrtest_s SET a[:3] = '{11, 12, 13}', b[:2][:2] = '{{11,12}, {14, 15}}';
|
||||
UPDATE arrtest_s SET a[3:] = '{23, 24, 25}', b[2:][2:] = '{{25,26}, {28, 29}}';
|
||||
UPDATE arrtest_s SET a[:] = '{23, 24, 25}';
|
Reference in New Issue
Block a user