Lists: | Postg스포츠 토토 베트맨SQL |
---|
From: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Support for array_remove and array_replace functions |
Date: | 2012-06-14 10:41:53 |
Message-ID: | 1339670513.25463.10.camel@greygoo.devise-it.lan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
following Gabriele's email regarding our previous patch on "Foreign
Key Arrays"[1], I am sending a subset of that patch which includes only
two array functions which will be needed in that patch: array_remove
(limited to single-dimensional arrays) and array_replace.
The patch includes changes to the documentation.
Cheers,
Marco
[1] http://archives.postgresql.org/message-id/4FD8F422.40709%402ndQuadrant.it
--
Marco Nenciarini - 2ndQuadrant Italy
PostgreSQL Training, Services and Support
marco(dot)nenciarini(at)2ndQuadrant(dot)it | www.2ndQuadrant.it
Attachment | Content-Type | Size |
---|---|---|
array-functions.patch.bz2 | application/x-bzip | 4.7 KB |
From: | Alex Hunsaker <badalex(at)gmail(dot)com> |
---|---|
To: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for array_remove and array_replace functions |
Date: | 2012-06-30 02:16:08 |
Message-ID: | CAFaPBrTxJQNJ_Hatt=J2dopGGMjwdTX=GVwER+7o4unCGM6N8Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Jun 14, 2012 at 4:41 AM, Marco Nenciarini <
marco(dot)nenciarini(at)2ndquadrant(dot)it> wrote:
> Hi,
>
> following Gabriele's email regarding our previous patch on "Foreign
> Key Arrays"[1], I am sending a subset of that patch which includes only
> two array functions which will be needed in that patch: array_remove
> (limited to single-dimensional arrays) and array_replace.
>
> The patch includes changes to the documentation.
>
Hi, I've been reviewing this patch.
Good documentation, and regression tests. The code looked fine but I didn't
care for the code duplication between array_replace and array_remove so I
merged those into a helper function, array_replace_internal(). Thoughts?
Other than that it all looks good to me.
Attachment | Content-Type | Size |
---|---|---|
array-functions_v2.patch.bz2 | application/x-bzip2 | 4.0 KB |
From: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> |
---|---|
To: | Alex Hunsaker <badalex(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for array_remove and array_replace functions |
Date: | 2012-06-30 21:28:28 |
Message-ID: | 4FEF6F7C.2060408@2ndquadrant.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 30/06/2012 04:16, Alex Hunsaker wrote:
>
> Hi, I've been reviewing this patch.
>
> Good documentation, and regression tests. The code looked fine but I
> didn't care for the code duplication between array_replace and
> array_remove so I merged those into a helper function,
> array_replace_internal(). Thoughts?
It looks reasonable.
There was a typo in array_replace which was caught by regression tests.
I've fixed the typo and changed a comment in array_replace_internal.
Patch v3 attached.
Regards,
Marco
--
Marco Nenciarini - 2ndQuadrant Italy
PostgreSQL Training, Services and Support
marco(dot)nenciarini(at)2ndQuadrant(dot)it | www.2ndQuadrant.it
Attachment | Content-Type | Size |
---|---|---|
array-functions-v3.patch.bz2 | application/x-bzip | 4.5 KB |
From: | Alex Hunsaker <badalex(at)gmail(dot)com> |
---|---|
To: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for array_remove and array_replace functions |
Date: | 2012-07-01 19:20:58 |
Message-ID: | CAFaPBrTo4_qKcFWFg4nTPupAFPdWR_t6e2Jv3RWagi-k-QLziQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sat, Jun 30, 2012 at 3:28 PM, Marco Nenciarini
<marco(dot)nenciarini(at)2ndquadrant(dot)it> wrote:
>
> On 30/06/2012 04:16, Alex Hunsaker wrote:
> >
> > Hi, I've been reviewing this patch.
> >
> > Good documentation, and regression tests. The code looked fine but I
> > didn't care for the code duplication between array_replace and
> > array_remove so I merged those into a helper function,
> > array_replace_internal(). Thoughts?
>
> It looks reasonable.
>
> There was a typo in array_replace which was caught by regression tests.
> I've fixed the typo and changed a comment in array_replace_internal.
>
> Patch v3 attached.
Looks good to me, marked ready for commiter.
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> |
Cc: | Alex Hunsaker <badalex(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for array_remove and array_replace functions |
Date: | 2012-07-11 15:54:50 |
Message-ID: | 4960.1342022090@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> writes:
> Patch v3 attached.
I'm looking at this patch now. The restriction of array_remove to
one-dimensional arrays seems a bit annoying. I see the difficulty:
if the input is multi-dimensional then removing some elements could
lead to a non-rectangular array, which isn't supported. However,
that could be dealt with by decreeing that the *result* is
one-dimensional and of the necessary length, regardless of the
dimensionality of the input.
I'm not actually certain whether that's a better definition or not.
But one less error case seems like generally a good thing.
Comments?
regards, tom lane
From: | Alex Hunsaker <badalex(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for array_remove and array_replace functions |
Date: | 2012-07-11 16:53:52 |
Message-ID: | CAFaPBrQasSqBUbp1s85YwmKLJzWRRE1ie4D5_u4cgSkpfJLy3w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg스포츠 토토 베트맨SQL |
On Wed, Jul 11, 2012 at 9:54 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> writes:
>> Patch v3 attached.
>
> I'm looking at this patch now. The restriction of array_remove to
> one-dimensional arrays seems a bit annoying. I see the difficulty:
> if the input is multi-dimensional then removing some elements could
> lead to a non-rectangular array, which isn't supported. However,
> that could be dealt with by decreeing that the *result* is
> one-dimensional and of the necessary length, regardless of the
> dimensionality of the input.
Makes sense to me. +1
The other option ISTM is to replace removed entries with NULL-- which
I don't really like.
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Alex Hunsaker <badalex(at)gmail(dot)com> |
Cc: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for array_remove and array_replace functions |
Date: | 2012-07-11 17:00:34 |
Message-ID: | 6966.1342026034@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Alex Hunsaker <badalex(at)gmail(dot)com> writes:
> On Wed, Jul 11, 2012 at 9:54 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I'm looking at this patch now. The restriction of array_remove to
>> one-dimensional arrays seems a bit annoying. I see the difficulty:
>> if the input is multi-dimensional then removing some elements could
>> lead to a non-rectangular array, which isn't supported. However,
>> that could be dealt with by decreeing that the *result* is
>> one-dimensional and of the necessary length, regardless of the
>> dimensionality of the input.
> Makes sense to me. +1
> The other option ISTM is to replace removed entries with NULL-- which
> I don't really like.
Well, you can do that with array_replace, so I don't see a need to
define array_remove that way.
regards, tom lane
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Alex Hunsaker <badalex(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for array_remove and array_replace functions |
Date: | 2012-07-11 17:40:50 |
Message-ID: | EB4DDD52-8FFE-4CE7-92AD-7826EFB4CC59@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Jul 11, 2012, at 11:53 AM, Alex Hunsaker <badalex(at)gmail(dot)com> wrote:
> On Wed, Jul 11, 2012 at 9:54 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> writes:
>>> Patch v3 attached.
>>
>> I'm looking at this patch now. The restriction of array_remove to
>> one-dimensional arrays seems a bit annoying. I see the difficulty:
>> if the input is multi-dimensional then removing some elements could
>> lead to a non-rectangular array, which isn't supported. However,
>> that could be dealt with by decreeing that the *result* is
>> one-dimensional and of the necessary length, regardless of the
>> dimensionality of the input.
>
> Makes sense to me. +1
+1 from me, too.
...Robert
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> |
Cc: | Alex Hunsaker <badalex(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for array_remove and array_replace functions |
Date: | 2012-07-11 18:06:55 |
Message-ID: | 15405.1342030015@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it> writes:
> Patch v3 attached.
Applied with mostly-but-not-entirely cosmetic adjustments.
I left array_remove throwing error for multi-dimensional arrays for
the moment, because I realized that changing the dimensionality as
I suggested would conflict with the optimization to return the original
array if there were no matches. I don't think we'd want the definition
to read "multidimensional arrays are changed to one dimension, but only
if at least one element is removed" --- that's getting a little too
weird. If anyone's really hot to make it work on multi-D arrays, we
could consider disabling that optimization; it's not clear to me that
it's worth a lot. But for now I'm willing to stick with the
throw-an-error approach.
regards, tom lane