Re: usage of pg_get_functiondef() -- SQL state 42809

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: david(dot)sahagian(at)emc(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: usage of pg_get_functiondef() -- SQL state 42809
Date: 2012-03-19 20:34:35
Message-ID: 20116.1332189275@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<david(dot)sahagian(at)emc(dot)com> writes:
> -- This blows up. -- SQL state: 42809 -- ERROR: "array_agg" is an aggregate function

> select
> TRG.tgname, TFX.proname, pg_get_functiondef(TFX.oid) as fdef
> from
> pg_trigger TRG
> inner join pg_proc TFX on TFX.oid = TRG.tgfoid
> where
> TRG.tgisinternal = true
> and
> pg_get_functiondef(TFX.oid) = 'whatever'

> Can you help me understand why this blows up ?

The second part of the WHERE clause can be evaluated against pg_proc
rows for which pg_get_functiondef() will fail.

An easy workaround would be to use TRG.tgfoid instead, so that the WHERE
clause gets pushed down to the other table. There probably shouldn't be
any entries in pg_trigger for which pg_get_functiondef() will fail.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Welty, Richard 2012-03-19 20:35:08 Re: current thinking on Amazon EC2?
Previous Message Mike Christensen 2012-03-19 20:30:37 Re: current thinking on Amazon EC2?