Thread: pg_get_functiondef() does not show LEAKPROOF for leakproof functions

pg_get_functiondef() does not show LEAKPROOF for leakproof functions

From
Jeevan Chalke
Date:
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

Attachment
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



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