Re: BUG #4509: array_cat's null behaviour is inconsistent

Поиск
Список
Период
Сортировка
От Kev
Тема Re: BUG #4509: array_cat's null behaviour is inconsistent
Дата
Msg-id 5aa36b5a-3707-4901-a86f-5c32f5cb7bcd@v22g2000pro.googlegroups.com
обсуждение исходный текст
Ответ на BUG #4509: array_cat's null behaviour is inconsistent  ("Kevin Field" <kev@brantaero.com>)
Ответы Re: BUG #4509: array_cat's null behaviour is inconsistent  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
> I'm loath to change just this one thing though.  If we're going to
> monkey with it, I think we should start by having a thought-through
> proposal about the behavior of all the array functions for corner
> cases like null arrays and empty arrays (cf recent discussion about
> zero-dimensional arrays).

If those are the only corner cases, here's something to work with.

Looking at http://www.postgresql.org/docs/8.3/interactive/functions-array.html,
I'd propose that every one of those operators and functions should
return NULL::(normal-return-type) if any of their operands are NULL,
to be consistent with Section 9.2 and to differentiate from the empty-
array cases below, and that logic should precede anything to do with
empty arrays.  As for empty arrays, the following additions to the
logic:

= true if both arrays are empty
<> true if either array is empty but not both
< true if left operand is empty and right is not
> true if right operand is empty and left is not
<= true if left operand is empty
>= true if right operand is empty
@> true if right operand is empty
<@ true if left operand is empty
&& false if either array is empty
|| (both array-array cases) return other array if one is empty (if
left is empty, return right, elsif right is empty, return left)
|| (both element-array cases) return ARRAY[element] if array is empty

array_append return ARRAY[element] if array is empty
array_cat return other array if one is empty (if left is empty, return
right, elsif right is empty, return left)
array_dims return results obtained by ignoring empty sub-arrays; if
entire array is empty, return ''
array_lower raise exception if array is empty (there are no dimensions
to inquire about)
array_prepend return ARRAY[element] if array is empty
array_to_string return '' if array is empty
array_upper raise exception if array is empty (there are no dimensions
to inquire about)
string_to_array return '' if left operand is ''

Hope that's useful...
Kev

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Alex Hunsaker"
Дата:
Сообщение: Re: plperl & sort
Следующее
От: "Alexey Bashtanov"
Дата:
Сообщение: BUG #4513: VACUUM FULL fails with "out of memory" error