Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d9Hw9-0002cz-4L for pgsql-hackers@arkaria.postgresql.org; Fri, 12 May 2017 21:17:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d9Hw8-0002On-NE for pgsql-hackers@arkaria.postgresql.org; Fri, 12 May 2017 21:17:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d9Hub-0005dc-1q for pgsql-hackers@postgresql.org; Fri, 12 May 2017 21:15:45 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d9HuX-0000NF-OV for pgsql-hackers@postgresql.org; Fri, 12 May 2017 21:15:44 +0000 Received: by mail-pf0-x22c.google.com with SMTP id m17so35594918pfg.3 for ; Fri, 12 May 2017 14:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illuminatedcomputing-com.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version; bh=UAVHd1GhYFqBwQ8NJgJsHexs+m62EdvCMvUCvXLd1Kk=; b=pCAD9nkcFJZu+1/13s4e8wFvgYLGbip056IX/ssMX6GDdzhQMbgRN1Z4QydFsjR59M uAtsZKMdGcHFIXAtyQM/MwBrfkwBpYHUo+6mlG3t/8ar1VEdLyiVGvNq1K8HMxGRQTNp b4m0y9Vq5pVlTeMBlqoxL1XOzO97UlNU5+mcCXAqfguz4Mz4KJYYDeYrcS9dXmWW0QpQ WIw01vKj3eygTi4mdzkcyi730ojp1ZSnw/f+W/vGLytUFugWQtzOaW9GG+xoiUi5018L nmbxYG/qXzY19JOI+p+dxNStoinerXFJ7gNsDb15DyRF1fVv3ifcQoKc6SWYhQ2SBpWR 32Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=UAVHd1GhYFqBwQ8NJgJsHexs+m62EdvCMvUCvXLd1Kk=; b=jUXlOHkd4KxWgWmQCywl7pfGk7dxgHy/bqtNKAEs0pVKK02ox5j/gdFHLH+1m90VlY PdEKH4pRymyew5FjXCxIJsvz2vJOUUuvkgqRK+eXHTnZIWihgUs937vB4p/0YK6eQdQT 6AMpQ6LxvQur4Iwqo1o5BS6CoeR+dGAhFYL4/HRGDpWSuX8chycmFRObcN2fyPIJpeH7 HL6Jjsb7tlwo61Qd6lnlbKoQVUuS4fcqxRmziBM5RGcorxEoOiUyQ/jKTcwiaDs7Jzcw wUkiNLW6imueL8BEH/pNfpPbdF0dwb2ASHxbNORh8fZRryqfw7JhFU4QBuWpt5pS4CA5 WSYA== X-Gm-Message-State: AODbwcCaTF1ysnwetfuLvKw5vhTWB2gTjJXnSm16JdnJ6QaIPytofHEd 1t1yv+OPcD7vUQC9 X-Received: by 10.98.130.201 with SMTP id w192mr6765323pfd.34.1494623739128; Fri, 12 May 2017 14:15:39 -0700 (PDT) Received: from [192.168.2.201] (static-50-53-109-254.bvtn.or.frontiernet.net. [50.53.109.254]) by smtp.googlemail.com with ESMTPSA id y190sm7170448pgd.25.2017.05.12.14.15.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 May 2017 14:15:38 -0700 (PDT) To: Pgsql Hackers From: Paul Jungwirth Subject: Patch to fix documentation about AFTER triggers Message-ID: Date: Fri, 12 May 2017 14:15:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------0CB9A971E707983B9753BDBF" X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------0CB9A971E707983B9753BDBF Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------0CB9A971E707983B9753BDBF Content-Type: text/x-patch; name="plpgsql_trigger_docs_v1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="plpgsql_trigger_docs_v1.patch" diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index a6088e9..dc29e7c 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -3999,13 +3999,10 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$ -- 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 END; --------------0CB9A971E707983B9753BDBF Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------0CB9A971E707983B9753BDBF--