Patch to fix documentation about AFTER triggers

From: Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Patch to fix documentation about AFTER triggers
Date: 2017-05-12 21:15:37
Message-ID: e24a6a6d-5670-739b-00f3-41a226a80f25@illuminatedcomputing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here is a patch to amend the docs here:

https://www.postgresql.org/docs/devel/static/plpgsql-trigger.html

In the example for an AFTER trigger, you see this code:

--
-- Create a row in emp_audit to reflect the operation performed on emp,
-- make use of the special variable TG_OP to work out the operation.
--
IF (TG_OP = 'DELETE') THEN
INSERT INTO emp_audit SELECT 'D', now(), user, OLD.*;
RETURN OLD;
ELSIF (TG_OP = 'UPDATE') THEN
INSERT INTO emp_audit SELECT 'U', now(), user, NEW.*;
RETURN NEW;
ELSIF (TG_OP = 'INSERT') THEN
INSERT INTO emp_audit SELECT 'I', now(), user, NEW.*;
RETURN NEW;
END IF;
RETURN NULL; -- result is ignored since this is an AFTER trigger

What are all those RETURNs doing in there? The comment on the final
RETURN is correct, so returning NEW or OLD above seems confusing, and
likely a copy/paste error.

This patch just removes those three lines from the example code.

Thanks!
Paul

Attachment Content-Type Size
plpgsql_trigger_docs_v1.patch text/x-patch 766 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-05-12 21:20:04 Re: WITH clause in CREATE STATISTICS
Previous Message Tom Lane 2017-05-12 21:15:27 About forced dependencies on catversion.h