Search Postgresql Archives

Re: Checking if Aggregate exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 24 Mar 2008 14:02:02 -0500
Erik Jones <erik@xxxxxxxxxx> wrote:

> 
> On Mar 24, 2008, at 1:09 PM, Martijn van Oosterhout wrote:
> > On Mon, Mar 24, 2008 at 12:47:43PM -0500, Josh Trutwin wrote:
> >> My code to check if an aggregate exists runs this query:
> >>
> >> SELECT * FROM pg_catalog.pg_aggretate WHERE aggfnoid =  
> >> 'foo'::REGPROC;
> >
> > Seems to me you'd rather want the proisagg column in pg_proc and  
> > forget
> > about pg_aggregate altogether...
> 
> Also, the idiom for checking if something is present is normally:
> 
> SELECT 1 FROM some_table WHERE ...;
> 
> This way you aren't dealing with errors, if it doesn't exist the
> query simply doesn't return any results.

This one still does return an error though I think because of the
cast:

select 1 from pg_catalog.pg_aggregate where aggfnoid =
'foo'::regproc;

ERROR:  function "foo" does not exist

Thanks,

Josh

-
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux