pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christian Fritze <The.Finn@sprawl.de>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Re: going gaga on creating an aggregate... [solved of course...]
Date: Sun, 16 Apr 2000 01:04:10 -0400
Message-ID: <26648.955861450@sss.pgh.pa.us> (raw)
In-Reply-To: <200004152301.BAA02788@chatsubo.sprawl.de>
References: <200004152301.BAA02788@chatsubo.sprawl.de>

Christian Fritze <The.Finn@sprawl.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
executor.

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



view thread (2+ messages)

Message-ID: <26648.955861450@sss.pgh.pa.us>
Permalink:  ../26648.955861450@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26648.955861450@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, The.Finn@sprawl.de
  Subject: Re: going gaga on creating an aggregate... [solved of course...]
  In-Reply-To: <26648.955861450@sss.pgh.pa.us>
  References: <200004152301.BAA02788@chatsubo.sprawl.de> <26648.955861450@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox