Re: patch: bytea_agg

Lists: pgsql-hackers
From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: patch: bytea_agg
Date: 2011-12-21 10:04:16
Message-ID: CAFj8pRBM2YzkPQKSXgJMYFfRZp7Uv2pJ0Wyf+B7fDL3Cx4nN6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

this patch adds a bytea_agg aggregation.

It allow fast bytea concatetation.

Regards

Pavel Stehule

Attachment Content-Type Size
bytea_agg.diff text/x-patch 6.5 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-22 16:49:26
Message-ID: CA+TgmoYx-L8bDcdOO3p28byr-crEqk6j4E_0N9qSNxu1Gy-E6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 21, 2011 at 5:04 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> this patch adds a bytea_agg aggregation.
>
> It allow fast bytea concatetation.

Looks fine to me. I'll commit this, barring objections.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 13:42:51
Message-ID: CA+TgmoYZwEUngukZRL8dyCimwzHOiQP_cn7TQGeisNF_dvZR5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 22, 2011 at 11:49 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Wed, Dec 21, 2011 at 5:04 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>> this patch adds a bytea_agg aggregation.
>>
>> It allow fast bytea concatetation.
>
> Looks fine to me.  I'll commit this, barring objections.

Committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 17:51:38
Message-ID: 1324662698.14547.2.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
> this patch adds a bytea_agg aggregation.
>
> It allow fast bytea concatetation.

Why not call it string_agg? All the function names are the same between
text and bytea (e.g., ||, substr, position, length). It would be nice
not to introduce arbitrary differences.


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 18:23:13
Message-ID: CAFj8pRC2mh7fUY6oAu8rObjG4i4zhDU_VkLg2JMh_vvbAxPWXw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

2011/12/23 Peter Eisentraut <peter_e(at)gmx(dot)net>:
> On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
>> this patch adds a bytea_agg aggregation.
>>
>> It allow fast bytea concatetation.
>
> Why not call it string_agg?  All the function names are the same between
> text and bytea (e.g., ||, substr, position, length).  It would be nice
> not to introduce arbitrary differences.

My opinion is not too strong. I don't think so using string_agg is
good name (for bytea_agg) - as minimal (and only one) reason is
different API - there is no support for delimiter. If I remember well
discussion about string_agg, where delimiter is not optimal, there is
request for immutable interface for aggregates - there was a issue
with ORDER clause. So bytea_agg is good name.

Regards

Pavel

>


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 18:25:07
Message-ID: CAFj8pRA2opXkC=hOmYoP31i-aRGRPc3qd2LyP0U+h+yKBi6wUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

2011/12/23 Peter Eisentraut <peter_e(at)gmx(dot)net>:
> On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
>> this patch adds a bytea_agg aggregation.
>>
>> It allow fast bytea concatetation.
>
> Why not call it string_agg?  All the function names are the same between
> text and bytea (e.g., ||, substr, position, length).  It would be nice
> not to introduce arbitrary differences.

My opinion is not strong. I don't think so using string_agg is good
name (- as minimal (and only one) reason is different API - there is
no support for delimiter. If I remember well discussion about
string_agg, where delimiter is not optimal, there is request for
immutable interface for aggregates - there was a issue with ORDER
clause. So bytea_agg is good name.

Regards

Pavel

>


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 18:30:26
Message-ID: CA+TgmoYrxwd8Lv0Qj-6RK80gYzMRtOgy6mjwhUT4ELTGZ+4m0g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 23, 2011 at 12:51 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
>> this patch adds a bytea_agg aggregation.
>>
>> It allow fast bytea concatetation.
>
> Why not call it string_agg?  All the function names are the same between
> text and bytea (e.g., ||, substr, position, length).  It would be nice
> not to introduce arbitrary differences.

Well, because it doesn't operate on strings.

I argued when we added string_agg that it ought to be called
concat_agg, or something like that, but I got shouted down. So now
here we are.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 19:16:11
Message-ID: 1324667771.14547.3.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On fre, 2011-12-23 at 13:30 -0500, Robert Haas wrote:
> On Fri, Dec 23, 2011 at 12:51 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> > On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
> >> this patch adds a bytea_agg aggregation.
> >>
> >> It allow fast bytea concatetation.
> >
> > Why not call it string_agg? All the function names are the same between
> > text and bytea (e.g., ||, substr, position, length). It would be nice
> > not to introduce arbitrary differences.
>
> Well, because it doesn't operate on strings.

Sure, binary strings. Both the SQL standard and the PostgreSQL
documentation use that term.


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 19:19:34
Message-ID: CA+TgmoYkUXxHmH3Zu8-k_XArr2RWwddDs3NK+0aL28hKYfhCmw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 23, 2011 at 2:16 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On fre, 2011-12-23 at 13:30 -0500, Robert Haas wrote:
>> On Fri, Dec 23, 2011 at 12:51 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> > On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
>> >> this patch adds a bytea_agg aggregation.
>> >>
>> >> It allow fast bytea concatetation.
>> >
>> > Why not call it string_agg?  All the function names are the same between
>> > text and bytea (e.g., ||, substr, position, length).  It would be nice
>> > not to introduce arbitrary differences.
>>
>> Well, because it doesn't operate on strings.
>
> Sure, binary strings.  Both the SQL standard and the PostgreSQL
> documentation use that term.

I'm unimpressed by that argument, but let's see what other people think.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>
Cc: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>, "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 19:35:21
Message-ID: 4EF4839902000025000440B5@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> Robert Haas wrote:
>>> Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>>>> On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
>>>>> this patch adds a bytea_agg aggregation.
>>>>>
>>>>> It allow fast bytea concatetation.
>>>>
>>>> Why not call it string_agg? All the function names are the
>>>> same between text and bytea (e.g., ||, substr, position,
>>>> length). It would be nice not to introduce arbitrary
>>>> differences.
>>>
>>> Well, because it doesn't operate on strings.
>>
>> Sure, binary strings. Both the SQL standard and the PostgreSQL
>> documentation use that term.
>
> I'm unimpressed by that argument, but let's see what other people
> think.

I, for one, try to be consistent about saying "character strings"
when that is what I mean. Since at least the SQL-92 standard there
have been both "character strings" and "bit strings", with a certain
amount of symmetry in how they are handled. I don't remember when
binary strings were introduced, but that is the standard
terminology. There is, for example, a standard substring function
for binary strings.

-Kevin


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 21:19:57
Message-ID: 7924.1324675197@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Fri, Dec 23, 2011 at 2:16 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> On fre, 2011-12-23 at 13:30 -0500, Robert Haas wrote:
>>> Well, because it doesn't operate on strings.

>> Sure, binary strings. Both the SQL standard and the PostgreSQL
>> documentation use that term.

> I'm unimpressed by that argument, but let's see what other people think.

I generally agree with Peter: string_agg makes sense here. The only
real argument against it is Pavel's point that he didn't include a
delimiter parameter, but that just begs the question why not. It
seems at least plausible that there would be use-cases for it.

So I think we should try to make this as much like the text case as
possible.

regards, tom lane


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 21:36:11
Message-ID: CAFj8pRAm4hRWRJ+2KfXJ3JvQMwX-KXWty6uitK7kYjtVu=GQ9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

2011/12/23 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Fri, Dec 23, 2011 at 2:16 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>>> On fre, 2011-12-23 at 13:30 -0500, Robert Haas wrote:
>>>> Well, because it doesn't operate on strings.
>
>>> Sure, binary strings.  Both the SQL standard and the PostgreSQL
>>> documentation use that term.
>
>> I'm unimpressed by that argument, but let's see what other people think.
>
> I generally agree with Peter: string_agg makes sense here.  The only
> real argument against it is Pavel's point that he didn't include a
> delimiter parameter, but that just begs the question why not.  It
> seems at least plausible that there would be use-cases for it.

I don't know a real usage for bytea delimiter. Probably there is, but
I expect so most often use case will be without delimiter. And when it
is necessary, then || should be used. I see two ways:

a) use it bytea_agg as it now
b) use a string_agg with delimiter, that will be usually empty.

Using a string_agg for bytea is not too intuitive (but has sense) -
maybe we can introduce a synonym type for bytea - like "binary string"
or "bstring".

Regards

Pavel

>
> So I think we should try to make this as much like the text case as
> possible.
>
>                        regards, tom lane


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-23 21:48:56
Message-ID: 4EF4A2E802000025000440D7@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:

> maybe we can introduce a synonym type for bytea - like "binary
> string" or "bstring".

The standard mentions these names for binary strings:

BINARY, BINARY VARYING, or BINARY LARGE OBJECT

which have a certain symmetry with:

CHARACTER, CHARACTER VARYING, and CHARACTER
LARGE OBJECT

-Kevin


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-24 01:44:11
Message-ID: 1324690951-sup-3979@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Excerpts from Pavel Stehule's message of vie dic 23 18:36:11 -0300 2011:
> Hello
>
> 2011/12/23 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> > I generally agree with Peter: string_agg makes sense here.  The only
> > real argument against it is Pavel's point that he didn't include a
> > delimiter parameter, but that just begs the question why not.  It
> > seems at least plausible that there would be use-cases for it.
>
> I don't know a real usage for bytea delimiter. Probably there is, but
> I expect so most often use case will be without delimiter.

Well, sometimes bytea is used to store character strings when the
encoding information is to be handled by the app instead of having
Postgres know it, for various reasons. I haven't seen any of those
cases yet that would use string_add(bytea) but I wouldn't foreclose that
possibility.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2011-12-24 13:13:32
Message-ID: CAHyXU0zcqh3smyGASbDJb=SVng-=HrWh=Od1LzofavpOCZjaHw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 23, 2011 at 12:30 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> Well, because it doesn't operate on strings.
>
> I argued when we added string_agg that it ought to be called
> concat_agg, or something like that, but I got shouted down.  So now
> here we are.

+1. Using the input type names to name the function is a mistake and
should be stopped...enough. It's verbose and unnecessary...everything
else in sql is heavily overloaded (we don't have int_max() and
float_max()).

merlin


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2012-04-04 20:20:20
Message-ID: 1333570820.10072.18.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On fre, 2011-12-23 at 19:51 +0200, Peter Eisentraut wrote:
> On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
> > this patch adds a bytea_agg aggregation.
> >
> > It allow fast bytea concatetation.
>
> Why not call it string_agg? All the function names are the same between
> text and bytea (e.g., ||, substr, position, length). It would be nice
> not to introduce arbitrary differences.

Here is a patch to do the renaming. As it stands, it fails the
opr_sanity regression test, because that complains that there are now
two aggregate functions string_agg with different number of arguments.
It seems to me that that test should really only complain if the common
argument types of the two aggregates are the same, correct?

Attachment Content-Type Size
bytea-string-agg.patch text/x-patch 6.2 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2012-04-04 22:59:36
Message-ID: 11477.1333580376@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On fre, 2011-12-23 at 19:51 +0200, Peter Eisentraut wrote:
>> On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
>>> this patch adds a bytea_agg aggregation.

>> Why not call it string_agg?

> Here is a patch to do the renaming. As it stands, it fails the
> opr_sanity regression test, because that complains that there are now
> two aggregate functions string_agg with different number of arguments.
> It seems to me that that test should really only complain if the common
> argument types of the two aggregates are the same, correct?

Uh, no. That test is there for good and sufficient reasons, as per its
comment:

-- Check that there are not aggregates with the same name and different
-- numbers of arguments. While not technically wrong, we have a project policy
-- to avoid this because it opens the door for confusion in connection with
-- ORDER BY: novices frequently put the ORDER BY in the wrong place.
-- See the fate of the single-argument form of string_agg() for history.

The renaming you propose would only be acceptable to those who have
forgotten that history. I haven't.

regards, tom lane


From: Greg Stark <stark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2012-04-04 23:22:59
Message-ID: CAM-w4HOW4qw_2rMGi7Q63Bdtz+2tDWwO9wEH-gdsnumB2Jkv_Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Apr 4, 2012 at 11:59 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> The renaming you propose would only be acceptable to those who have
> forgotten that history.  I haven't.

I had. I looked it up
http://archives.postgresql.org/pgsql-bugs/2010-08/msg00044.php

That was quite a thread.

--
greg


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2012-04-07 10:52:00
Message-ID: 1333795920.26334.7.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On ons, 2012-04-04 at 18:59 -0400, Tom Lane wrote:
>
> >> Why not call it string_agg?
>
> > Here is a patch to do the renaming. As it stands, it fails the
> > opr_sanity regression test, because that complains that there are now
> > two aggregate functions string_agg with different number of arguments.
> > It seems to me that that test should really only complain if the common
> > argument types of the two aggregates are the same, correct?
>
> Uh, no. That test is there for good and sufficient reasons, as per its
> comment:
>
> -- Check that there are not aggregates with the same name and different
> -- numbers of arguments. While not technically wrong, we have a project policy
> -- to avoid this because it opens the door for confusion in connection with
> -- ORDER BY: novices frequently put the ORDER BY in the wrong place.
> -- See the fate of the single-argument form of string_agg() for history.
>
> The renaming you propose would only be acceptable to those who have
> forgotten that history. I haven't.

I had reviewed that thread very carefully, but I'm not sure it applies.
The issue was that we don't want aggregates with optional second
argument, because "novices" could confuse

agg(a, b ORDER BY c)

with

agg(a ORDER BY b, c) -- wrong

without the error being flagged.

But that doesn't apply if the first argument has different types.
Erroneously calling agg(textdatum ORDER BY textdatum, sthelse) will not
result in a call to agg(bytea). (Unless the textdatum is really an
unknown literal, but that would be silly.)

Nevertheless, the problem would now be that adding string_agg(bytea)
would effectively forbid adding string_agg(bytea, delim) in the future.
So making a two-argument string_agg(bytea, bytea) now seems like the
best solution anyway. (This applies independently of the function
renaming, actually.)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2012-04-07 14:38:08
Message-ID: 2278.1333809488@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On ons, 2012-04-04 at 18:59 -0400, Tom Lane wrote:
>> Uh, no. That test is there for good and sufficient reasons, as per its
>> comment:

> I had reviewed that thread very carefully, but I'm not sure it applies.
> The issue was that we don't want aggregates with optional second
> argument, because "novices" could confuse

> agg(a, b ORDER BY c)

> with

> agg(a ORDER BY b, c) -- wrong

> without the error being flagged.

> But that doesn't apply if the first argument has different types.
> Erroneously calling agg(textdatum ORDER BY textdatum, sthelse) will not
> result in a call to agg(bytea).

The point of the policy is to be sure that we will throw a specific
error message with a suitable hint when a malformed call is made.
If there are alternative aggregates in the catalogs that have the
potential to "capture" such a call, then we risk the wrong thing
happening. It appears that the lack of any implicit cast from bytea to
text would prevent that today, but I still think this proposal boxes
us in to an unreasonable degree compared to the benefit. For example,
this would greatly restrict our ability to throw "ambiguous aggregate"
messages.

> Nevertheless, the problem would now be that adding string_agg(bytea)
> would effectively forbid adding string_agg(bytea, delim) in the future.
> So making a two-argument string_agg(bytea, bytea) now seems like the
> best solution anyway. (This applies independently of the function
> renaming, actually.)

Hm. So are you now suggesting we should get rid of one-argument
bytea_agg and replace it with two-argument string_agg(bytea,bytea)?
I could support that, since we've not released bytea_agg yet.

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2012-04-11 17:46:55
Message-ID: 1334166415.25392.14.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On lör, 2012-04-07 at 10:38 -0400, Tom Lane wrote:
> > Nevertheless, the problem would now be that adding string_agg(bytea)
> > would effectively forbid adding string_agg(bytea, delim) in the
> future.
> > So making a two-argument string_agg(bytea, bytea) now seems like the
> > best solution anyway. (This applies independently of the function
> > renaming, actually.)
>
> Hm. So are you now suggesting we should get rid of one-argument
> bytea_agg and replace it with two-argument string_agg(bytea,bytea)?
> I could support that, since we've not released bytea_agg yet.

Yes, that looks like the best solution. Here is a patch for that.

Attachment Content-Type Size
bytea-string-agg.patch text/x-patch 7.4 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: bytea_agg
Date: 2012-04-11 17:57:13
Message-ID: 27704.1334167033@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On lr, 2012-04-07 at 10:38 -0400, Tom Lane wrote:
>> Hm. So are you now suggesting we should get rid of one-argument
>> bytea_agg and replace it with two-argument string_agg(bytea,bytea)?
>> I could support that, since we've not released bytea_agg yet.

> Yes, that looks like the best solution. Here is a patch for that.

Looks sane in a quick once-over, except for the documentation entry.
I'm not really thrilled with "text, text or bytea, bytea" because it
seems easy to misparse. Moreover, as written the entry claims that
the return type is text either way, which is wrong. You could fix
the latter by writing "same as argument data type", but I wonder
whether it'd be better to make separate table entries for the two
forms.

regards, tom lane