Re: Printing command string passed to EXECUTE command in plpgsql (after argument resolution) - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Printing command string passed to EXECUTE command in plpgsql (after argument resolution)
Date
Msg-id AANLkTinHgpvw4+0raje_KfLtRMXO-derxe6HrKeke-hO@mail.gmail.com
Whole thread Raw
In response to Re: Printing command string passed to EXECUTE command in plpgsql (after argument resolution)  (Allan Kamau <kamauallan@gmail.com>)
List 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 by date:

Previous
From: Allan Kamau
Date:
Subject: Re: Printing command string passed to EXECUTE command in plpgsql (after argument resolution)
Next
From: Michael Clark
Date:
Subject: Re: Should PQconsumeInput/PQisBusy be expensive to use?