Determine a function's volatility in C
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?
Thanks,
Bborie
--
Bborie Park
Programmer
Center for Vectorborne Diseases
UC Davis
530-752-8380
bkpark@ucdavis.edu
Hello
2011/11/12 Bborie Park <bkpark@ucdavis.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
Show quoted text
Thanks,
Bborie--
Bborie Park
Programmer
Center for Vectorborne Diseases
UC Davis
530-752-8380
bkpark@ucdavis.edu--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Bborie Park <bkpark@ucdavis.edu> writes:
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?
extern char func_volatile(Oid funcid)
(Most catalog-lookup convenience functions of this ilk can be found in
lsyscache.c, and that's also a good source of prototypes if you need a
field that's not exposed by one of those functions.)
regards, tom lane