Skip site navigation (1) Skip section navigation (2)

Re: Re: going gaga on creating an aggregate... [solved of course...]

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christian Fritze <The(dot)Finn(at)sprawl(dot)de>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Re: going gaga on creating an aggregate... [solved of course...]
Date: 2000-04-16 05:04:10
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Christian Fritze <The(dot)Finn(at)sprawl(dot)de> writes:
>  create aggregate test_agg_1 (
>  basetype = text, 
>  stype1 = text, 
>  sfunc1 = textcat, 
>  initcond1 = '');

> and then selecting like

>  select test_agg_1(textvar || ' ') from testtable;

> perfectly suites my needs. Sorry for the fuzz!

> Still I'm somewhat curious as to why my first 
> approach didn't work...

The difference is that textcat is a built-in function (C-coded), and
what you were previously trying to supply to CREATE AGGREGATE was an
SQL function.  The function manager is currently quite paranoid about
allowing SQL functions to be invoked from arbitrary contexts inside the
system; in particular it won't allow one to be called from the aggregate

This restriction is probably overly conservative, but it's not
completely without foundation.  For example, imagine defining an index
whose sort order depends on an SQL function, and then make the SQL
function be one that queries, or even worse updates, the table the index
is on.  Is that gonna work?  Nyet: it'll lead to infinite recursion,
crash and burn.  So for the moment I'd rather see the code err on the
side of caution.  Eventually we need a more sophisticated execution
model that can catch such recursive loops directly, and then we can
allow the normal non-recursive cases without fear.

			regards, tom lane

In response to

pgsql-sql by date

Next:From: Andrew Perrin - DemographyDate: 2000-04-17 05:01:17
Subject: indexes and keys
Previous:From: Christian FritzeDate: 2000-04-15 23:01:27
Subject: Re: going gaga on creating an aggregate... [solved of course...]

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group