cal I pass arguments directly to final function in aggregates

From: Nicklas Avén <nicklas(dot)aven(at)jordogskog(dot)no>
To: pgsql-general(at)postgresql(dot)org
Subject: cal I pass arguments directly to final function in aggregates
Date: 2013-05-18 23:14:47
Message-ID: 51980B67.3040803@jordogskog.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hallo

I am trying to create an aggregate function.

One of the arguments is static and is not needed until the final function.
From the doc I see that the final function " must take a single
argument of typestate_data_type"

Is it not possible to just pass this arguments directly to the final
function?

I was looking at string_agg but that was doing all the processing in the
SFUNC if I understand it right.

But to use it as example, if it instead would have collected all strings
in an array and added the delimiter in the final function, would that be
possible?

I would expect the definition of the aggregate to look something like:

CREATE AGGREGATE string_agg(text, text) (
SFUNC=string_agg_transfn($1),
STYPE=internal,
FINALFUNC=string_agg_finalfn($2)
);

Am I missing something or am I just thinking in irregular circles (that
happens now and then)

Best Regards

Nicklas Avén

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-05-18 23:26:11 Re: cal I pass arguments directly to final function in aggregates
Previous Message hubert depesz lubaczewski 2013-05-18 08:39:29 Re: Why does row estimation on nested loop make no sense to me