Re: array functions - request for opinions (was Re: [PATCHES]
От | Joe Conway |
---|---|
Тема | Re: array functions - request for opinions (was Re: [PATCHES] |
Дата | |
Msg-id | 3ED2D1B3.5040508@joeconway.com обсуждение исходный текст |
Ответ на | Re: array functions - request for opinions (was Re: [PATCHES] array (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: array functions - request for opinions (was Re: [PATCHES] array
|
Список | pgsql-hackers |
Tom Lane wrote: > You would also have to assume that the subscript lower bound is one, > which doesn't bother me but is an additional bit of state that has to > appear out of nowhere. (In the assignment case you don't have to assume > that, since the subscript tells you what to do.) I've gotten this working for array concatenation and assignment. Examples: -- empty array concatenated with any element, return one element, -- one-dimensional array, with lower bound set to 1 regression=# select '{}'::int4[] || 1; ?column? ---------- {1} (1 row) regression=# select 0 || '{}'::int4[]; ?column? ---------- {0} (1 row) regression=# select array_dims(0 || '{}'::int4[]); array_dims ------------ [1:1] (1 row) -- empty array concatenated with any non-empty, return the non-empty one regression=# select '{}'::int4[] || array[[[1,2],[3,4]]]; ?column? ----------------- {{{1,2},{3,4}}} (1 row) -- concatenate two empty arrays, return empty array regression=# select '{}'::int4[] || '{}'::int4[]; ?column? ---------- {} (1 row) -- assignment to empty array: determine number -- of dimensions and array subscripts based on those -- given in the assignment statement regression=# create table t(f float8[]); CREATE TABLE regression=# insert into t values('{}'); INSERT 2011035 1 regression=# update t set f[-2:2] = array[1,2,3,4,5]; UPDATE 1 regression=# select * from t; f ------------- {1,2,3,4,5} (1 row) regression=# select array_dims(f) from t; array_dims ------------ [-2:2] (1 row) One question, should this work to create an empty array: regression=# select array[]; ERROR: parser: parse error at or near "]" at character 14 or by analogy to '{}'::int4[] regression=# select array[]::int4[]; ERROR: parser: parse error at or near "]" at character 14 Or is the current '{}'::int4[] syntax all we want/need? Joe
В списке pgsql-hackers по дате отправления: