The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/9.6/static/plpgsql-implementation.html
Description:
Documentation is good. But if you change `INSERT INTO logtable VALUES
(logtxt, 'now');` to `RAISE INFO '%','now'::timestamptz;` in example, people
will probably try it out to see how caching works (no need to create table).
Also could explain why RETURNED value is reparsed and recalculated, while
RAISEd - not:
CREATE FUNCTION logfunc1() RETURNS timestamptz AS $$
BEGIN
RAISE INFO '%','now'::timestamptz;
RETURN 'now';
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION logfunc2() RETURNS timestamptz AS $$
DECLARE
curtime timestamp;
BEGIN
curtime := 'now';
RAISE INFO '%',curtime::timestamptz;
RETURN curtime;
END;
$$ LANGUAGE plpgsql;
t=# select logfunc1(),logfunc2();
INFO: 2017-05-04 11:49:34.828784+00
INFO: 2017-05-04 11:49:34.828784+00
logfunc1 | logfunc2
-------------------------------+-------------------------------
2017-05-04 11:49:34.828784+00 | 2017-05-04 11:49:34.828784+00
(1 row)
t=# select logfunc1(),logfunc2();
INFO: 2017-05-04 11:49:34.828784+00
INFO: 2017-05-04 11:49:39.661306+00
logfunc1 | logfunc2
-------------------------------+-------------------------------
2017-05-04 11:49:39.661306+00 | 2017-05-04 11:49:39.661306+00
(1 row)
Thank you