From: | Kev <kevinjamesfield(at)gmail(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #4509: array_cat's null behaviour is inconsistent |
Date: | 2008-11-05 16:53:28 |
Message-ID: | 5aa36b5a-3707-4901-a86f-5c32f5cb7bcd@v22g2000pro.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2008-11-05 17:54:10 | Re: plperl & sort |
Previous Message | Tom Lane | 2008-11-05 16:44:37 | Re: BUG #4512: PostgreSQL crash on update command |