pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_get_functiondef() does not show LEAKPROOF for leakproof functions
3+ messages / 3 participants
[nested] [flat]
* pg_get_functiondef() does not show LEAKPROOF for leakproof functions
@ 2015-05-28 08:52 Jeevan Chalke <jeevan.chalke@enterprisedb.com>
0 siblings, 1 reply; 3+ messages in thread
From: Jeevan Chalke @ 2015-05-28 08:52 UTC (permalink / raw)
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>; pgsql-bugs
Hi,
If function is created with the LEAKPROOF option, then pg_get_functiondef()
does not show that in the returned definition.
Is it expected OR are we missing that option in pg_get_functiondef().
However only superuser can define a leakproof function.
Was this the reson we are not showing that in pg_get_functiondef() output?
I don't think we should hide this detail.
Here is the sample testcase to reproduce the issue:
postgres=# CREATE OR REPLACE FUNCTION foobar(i integer) RETURNS integer AS
$$
BEGIN
RETURN i + 1;
END;
$$
STRICT
LEAKPROOF
LANGUAGE plpgsql;
CREATE FUNCTION
postgres=# select pg_get_functiondef((select oid from pg_proc where proname
= 'foobar'));
pg_get_functiondef
-----------------------------------------------------
CREATE OR REPLACE FUNCTION public.foobar(i integer)+
RETURNS integer +
LANGUAGE plpgsql +
STRICT +
AS $function$ +
BEGIN +
RETURN i + 1; +
END; +
$function$ +
(1 row)
postgres=# select proname, proleakproof from pg_proc where proname =
'foobar';
proname | proleakproof
---------+--------------
foobar | t
(1 row)
Attached patch which adds that in pg_get_functiondef().
--
Jeevan B Chalke
Principal Software Engineer, Product Development
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Attachments:
fix_leakproof_in_pg_get_functiondef.patch (text/x-patch, 569B) download
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 5517113..e316951 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1985,6 +1985,8 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
appendStringInfoString(&buf, " STRICT");
if (proc->prosecdef)
appendStringInfoString(&buf, " SECURITY DEFINER");
+ if (proc->proleakproof)
+ appendStringInfoString(&buf, " LEAKPROOF");
/* This code for the default cost and rows should match functioncmds.c */
if (proc->prolang == INTERNALlanguageId ||
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_get_functiondef() does not show LEAKPROOF for leakproof functions
@ 2015-05-28 12:40 Michael Paquier <michael.paquier@gmail.com>
parent: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Paquier @ 2015-05-28 12:40 UTC (permalink / raw)
To: Jeevan Chalke <jeevan.chalke@enterprisedb.com>; +Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>; pgsql-bugs
On Thu, May 28, 2015 at 5:52 PM, Jeevan Chalke
<jeevan.chalke@enterprisedb.com> wrote:
> If function is created with the LEAKPROOF option, then pg_get_functiondef()
> does not show that in the returned definition.
> Is it expected OR are we missing that option in pg_get_functiondef().
>
> However only superuser can define a leakproof function.
> Was this the reason we are not showing that in pg_get_functiondef() output?>
> I don't think we should hide this detail.
Agreed. I guess that it has been simply forgotten. pg_proc can be
easily queried, so functions marked as leakproof are easy to find out
in any case.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_get_functiondef() does not show LEAKPROOF for leakproof functions
@ 2015-05-28 14:18 Tom Lane <tgl@sss.pgh.pa.us>
parent: Michael Paquier <michael.paquier@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2015-05-28 14:18 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Jeevan Chalke <jeevan.chalke@enterprisedb.com>; PostgreSQL Hackers <pgsql-hackers@postgresql.org>; pgsql-bugs
Michael Paquier <michael.paquier@gmail.com> writes:
> On Thu, May 28, 2015 at 5:52 PM, Jeevan Chalke
> <jeevan.chalke@enterprisedb.com> wrote:
>> If function is created with the LEAKPROOF option, then pg_get_functiondef()
>> does not show that in the returned definition.
>> Is it expected OR are we missing that option in pg_get_functiondef().
> Agreed. I guess that it has been simply forgotten. pg_proc can be
> easily queried, so functions marked as leakproof are easy to find out
> in any case.
Looks like a clear oversight to me. I had first thought that this might
have been intentional because pg_dump needed it to act like that --- but
pg_dump doesn't use pg_get_functiondef. I think it was simply forgotten.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2015-05-28 14:18 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-05-28 08:52 pg_get_functiondef() does not show LEAKPROOF for leakproof functions Jeevan Chalke <jeevan.chalke@enterprisedb.com>
2015-05-28 12:40 ` Michael Paquier <michael.paquier@gmail.com>
2015-05-28 14:18 ` Tom Lane <tgl@sss.pgh.pa.us>
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