From 27bae8d964f7eeb61e7e6e57586e7cb9b571b94c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 28 May 2015 11:24:37 -0400 Subject: [PATCH] Fix pg_get_functiondef() to print a function's LEAKPROOF property. 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 | 4 ++-- src/backend/utils/adt/ruleutils.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index eef78498ba6..5915cd7acb3 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -1103,11 +1103,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) { diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 578972bba25..da28e59a921 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -1944,6 +1944,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 || -- 2.39.5