Re: Determine a function's volatility in C

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bborie Park <bkpark(at)ucdavis(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Determine a function's volatility in C
Date: 2011-11-12 05:24:57
Message-ID: CAFj8pRB+d0mqCSH06eHREtS0ELzqe866BBpiCFtwtY5xDqxCsA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2011/11/12 Bborie Park <bkpark(at)ucdavis(dot)edu>:
> Hey all,
>
> I'm wondering if there is a way to determine a function's volatility
> in C.  The function information provided through fmgr_info() doesn't
> provide it.  Ideas?
>

you should to look to pg_proc table

search in postgresql code

tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
proc = (Form_pg_proc) GETSTRUCT(tuple);

...

switch (proc->provolatile)
{
case PROVOLATILE_IMMUTABLE:
appendStringInfoString(&buf, " IMMUTABLE");
break;
case PROVOLATILE_STABLE:
appendStringInfoString(&buf, " STABLE");
break;
case PROVOLATILE_VOLATILE:
break;
}

...

ReleaseSysCache(tuple);

Regards

Pavel Stehule

> Thanks,
> Bborie
>
> --
> Bborie Park
> Programmer
> Center for Vectorborne Diseases
> UC Davis
> 530-752-8380
> bkpark(at)ucdavis(dot)edu
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-11-12 05:36:16 Re: Determine a function's volatility in C
Previous Message Bborie Park 2011-11-12 00:39:01 Determine a function's volatility in C