Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfOT9-00043G-LR for pgsql-docs@arkaria.postgresql.org; Fri, 04 Jan 2019 12:20:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gfOT8-0004qK-7y for pgsql-docs@arkaria.postgresql.org; Fri, 04 Jan 2019 12:20:54 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfOT8-0004q9-24 for pgsql-docs@lists.postgresql.org; Fri, 04 Jan 2019 12:20:54 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gfOT5-0002nc-3y for pgsql-docs@postgresql.org; Fri, 04 Jan 2019 12:20:53 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 44B341136724E for ; Fri, 4 Jan 2019 05:20:48 -0700 (MST) Date: Fri, 4 Jan 2019 05:20:48 -0700 (MST) From: PegoraroF10 To: pgsql-docs@postgresql.org Message-ID: <1546604448278-0.post@n3.nabble.com> Subject: UPDATE OF on REPLICA TRIGGERS MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk We tried a lot, maybe for some days, to have some triggers working properly on a replica server. So we read a discussion that is not possible to have UPDATE OF in a trigger which works only on REPLICA. Our tests was production using version 10 and replica using version 11. I thing it would be helpful if the docs had this explained. Or an exception would occur when we try to create a REPLICA TRIGGER with UPDATE OF. Document it with something like ... replace your "UPDATE OF col1, col2" when you create your trigger which works only on replica for "new.col1 is distinct of old.col1" inside your trigger function. CREATE OR REPLACE FUNCTION CalculateSomethingOnReplica() RETURNS TRIGGER AS $$ BEGIN IF tg_op = 'update' THEN IF new.col1 IS NOT DISTINCT FROM old.col1 THEN --DoTheCalc END IF; END IF; RETURN NULL; END; $$ LANGUAGE plpgsql; CREATE TRIGGER CalculateSomethingOnReplica AFTER UPDATE ON MyTable FOR EACH ROW EXECUTE PROCEDURE CalculateSomethingOnReplica(); ALTER TABLE MyTable ENABLE REPLICA TRIGGER CalculateSomethingOnReplica; -- Sent from: http://www.postgresql-archive.org/PostgreSQL-docs-f2165602.html