Re: join of array
От | Joe Conway |
---|---|
Тема | Re: join of array |
Дата | |
Msg-id | 3F3CFD76.5030300@joeconway.com обсуждение исходный текст |
Ответ на | Re: join of array (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: join of array
summary and request |
Список | pgsql-general |
Tom Lane wrote: > Pavel Stehule <stehule@kix.fsv.cvut.cz> writes: > >>Is possible merge two arrays like >>array[1,2,3] + array[4,5,6] => array[1,2,3,4,5,6] > > > I was about to say that || would do it, but I see that's not quite > right: > > regression=# SELECT ARRAY[1,2,3] || ARRAY[4,5,6]; > ?column? > ------------------- > {{1,2,3},{4,5,6}} > (1 row) > > Offhand, I would think that '{1,2,3,4,5,6}' would be what I'd > intuitively expect to get from "concatenating" these arrays. > Joe, do we really have this implemented per spec? > Hmmm, it made sense to me, at at least at some point ;-). Here's the SQL99 guidance (SQL200X doesn't give any more detailed guidance): 4.11.3.2 Operators that operate on array values and return array values <array concatenation> is an operation that returns the array value made by joining its array value operands in the order given. So I guess it ought to be changed. We also have ARRAY[1,2] || 3 == '{1,2,3}' and ARRAY[[1,2],[3,4]] || ARRAY[5,6] == '{{1,2},{3,4},{5,6}}' and ARRAY[[1,2],[3,4]] || ARRAY[[1,2],[3,4]] == '{{{1,2},{3,4}},{{1,2},{3,4}}}' I think the first two still make sense. I guess the third case ought to be: ARRAY[[1,2],[3,4]] || ARRAY[[1,2],[3,4]] == '{{1,2},{3,4},{1,2},{3,4}}' ? If this sounds good, I'll work on a patch for the behavior as well as the docs. Joe
В списке pgsql-general по дате отправления: