Re: Function array_agg(array)
От | Ali Akbar |
---|---|
Тема | Re: Function array_agg(array) |
Дата | |
Msg-id | CACQjQLqX2v895YVMYABCXgVP4QLenXgqiRgx9v_5oz7t79G-0w@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Function array_agg(array) (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Function array_agg(array)
|
Список | pgsql-hackers |
2014-10-11 22:28 GMT+07:00 Tom Lane <tgl@sss.pgh.pa.us>:
-- Seems dangerous as heck; certainly it would have side-effects far more
wide-ranging than just making this particular function work.
A safer answer is to split array_agg into two functions,
array_agg(anynonarray) -> anyarray
array_agg(anyarray) -> anyarray
I rather imagine you should do that anyway, because I really doubt
that this hack is operating quite as intended. I suspect you are
producing arrays containing arrays as elements, not true 2-D arrays.
That's not a direction we want to go in I think; certainly there are
no other operations that produce such things.
Thanks for the review. Yes, it looks like the patch produced array as the elements. So, all array operations behaves wierdly.
In this quick & dirty patch, I am trying to implement the array_agg(anyarray), introducing two new functions:
- array_agg_anyarray_transfn
- array_agg_anyarray_finalfn
- array_agg_anyarray_finalfn
At first, i want to use accumArrayResult and makeMdArrayResult, but it's complicated to work with multi-dimensional arrays with those two functions. So i combined array_cat with those function.
Currently, it cannot handle NULL arrays:
backend> select array_agg(a) from (values(null::int[])) a(a);
1: array_agg (typeid = 1007, len = -1, typmod = -1, byval = f)
----
ERROR: cannot aggregate null arrays
backend> select array_agg(a) from (values(null::int[])) a(a);
1: array_agg (typeid = 1007, len = -1, typmod = -1, byval = f)
----
ERROR: cannot aggregate null arrays
Regards,
Ali Akbar
Вложения
В списке pgsql-hackers по дате отправления: