Fix pg_get_functiondef() to print a function's LEAKPROOF property.
authorTom Lane <[email protected]>
Thu, 28 May 2015 15:24:37 +0000 (11:24 -0400)
committerTom Lane <[email protected]>
Thu, 28 May 2015 15:24:37 +0000 (11:24 -0400)
Seems to have been an oversight in the original leakproofness patch.
Per report and patch from Jeevan Chalke.

In passing, prettify some awkward leakproof-related code in AlterFunction.

src/backend/commands/functioncmds.c
src/backend/utils/adt/ruleutils.c

index 998357b154d1251cd46a34e3f5cc7b4090fd38ff..166c7ce2408b227ef66f23c71e08efeb06e1d8f0 100644 (file)
@@ -1314,11 +1314,11 @@ AlterFunction(AlterFunctionStmt *stmt)
        procForm->prosecdef = intVal(security_def_item->arg);
    if (leakproof_item)
    {
-       if (intVal(leakproof_item->arg) && !superuser())
+       procForm->proleakproof = intVal(leakproof_item->arg);
+       if (procForm->proleakproof && !superuser())
            ereport(ERROR,
                    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                  errmsg("only superuser can define a leakproof function")));
-       procForm->proleakproof = intVal(leakproof_item->arg);
    }
    if (cost_item)
    {
index 4df1105e02b7f9245f52caf42112370513a70049..8258463a104454ca758bccf6c76f6fc520c9c807 100644 (file)
@@ -1769,6 +1769,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 ||