Re: Printing command string passed to EXECUTE command in plpgsql (after argument resolution)

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Printing command string passed to EXECUTE command in plpgsql (after argument resolution)
Дата
Msg-id AANLkTinHgpvw4+0raje_KfLtRMXO-derxe6HrKeke-hO@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Printing command string passed to EXECUTE command in plpgsql (after argument resolution)  (Allan Kamau <kamauallan@gmail.com>)
Список pgsql-general
> I could use the RAISE NOTICE could work but I will have to write
> another command string and use % in place of the $<somenumber> for the
> parameters, one string for RAISE NOTICE and the other for EXECUTE.
> This may potentially introduce some differences (due to human error)
> between the output of RAISE NOTICE and the command string executed
> after parameter solution during the call to EXECUTE.
>

you can simply minimalize these risks

CREATE OR REPLACE FUNCTION notice(text, boolena)
RETURNS text AS $$
BEGIN
  IF $2 THEN
    RAISE NOTICE '%', $1;
  END IF;
  RETURN $1;
END;
$$ LANGUAGE plpgsql;

and then you can use it in EXECUTE

EXECUTE notice('SELECT ....', true) USING ...

Regards

Pavel Stehule

> Pavel's suggestion to use 'auto_explain' contrib module may be one of
> the probable solutions.
>
> Allan.
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

В списке pgsql-general по дате отправления:

Предыдущее
От: Allan Kamau
Дата:
Сообщение: Re: Printing command string passed to EXECUTE command in plpgsql (after argument resolution)
Следующее
От: Michael Clark
Дата:
Сообщение: Re: Should PQconsumeInput/PQisBusy be expensive to use?