Re: CREATE OR REPLACE AGGREGATE

From: Robert James <srobertjames(at)gmail(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: CREATE OR REPLACE AGGREGATE
Date: 2011-12-18 00:04:18
Message-ID: CAGYyBggyYDDjNvAowOhpycHjd35-b14QY3sNhjFcCcKAGKC9vw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/15/11, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> On Thu, Dec 15, 2011 at 11:29 AM, Robert James <srobertjames(at)gmail(dot)com>
> wrote:
>> Is there anyway to do the equivalent of CREATE OR REPLACE AGGREGATE?
>> Or - maybe even better - CREATE AGGREGATE if it doesn't already exist?
>
> Well, you have DROP [IF EXISTS] which should cover at least some of
> the use cases.
>
> I'm not sure a OR REPLACE for aggreates is a good idea -- you can
> already REPLACE the internal function (which is mostly what you need).
> The aggregate itself mainly defines the input types, state, and
> output types. The main advantage of replace is you get to preserve
> the oid and avoid dependency issues -- if you are changing the
> aggregate, it's pretty likely you'd have to go through that anyways.

Thanks. Can you elaborate? My use case is that the CREATE is done as
part of a database migration system, and we don't always track fully
if it's been run once already. (Not to mention that some aggregates
are built into 8.4 but lacking on 8.3). I'd like code that will
create it if it's not there.

My concern with simply dropping it first is that some other objects
might depend on it, causing the drop to be rejected.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert James 2011-12-18 00:06:21 Re: Logical Aggregate Functions (eg ANY())
Previous Message Filip Rembiałkowski 2011-12-17 21:25:40 segfault with plproxy