Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1wN1-0004WG-No for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Oct 2017 15:23:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e1wN1-0000Cu-9N for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Oct 2017 15:22:59 +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 1e1wN0-000099-C1; Tue, 10 Oct 2017 15:22:58 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1wMx-0005qz-4F; Tue, 10 Oct 2017 15:22:57 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id C9AF321C1ED3; Tue, 10 Oct 2017 18:22:53 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from localhost (unknown [46.101.213.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 5F44F21C08FC; Tue, 10 Oct 2017 18:22:53 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1507648973; bh=uVpzxDzSQiMlhXJLmJeEpeuiL/Akrr16rHQIkp67htI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=ItTUxocCjmJJCUTorDIXm+4M3S5k9zBeS+gDAAH9lNOPSI2cnftDRtynN3CBpx2nr qrSGf8xDEz4K5FhMEwQYhh2Scpn+DSynTG/dAp8LUvQX5d+9lL0SZB6Vi060EW8m8I ghlZlWR+YoYVNrAsI3cQm6vgoxV5nwOhtqymn7dI= Date: Tue, 10 Oct 2017 18:22:51 +0300 From: Aleksander Alekseev To: Petr Jelinek Cc: Masahiko Sawada , PostgreSQL Hackers , pgsql-bugs Subject: Re: 10.0: Logical replication doesn't execute BEFORE UPDATE OF trigger Message-ID: <20171010152250.GA30140@e733.localdomain> References: <20171009141341.GA16999@e733.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mP3DRpeJDSE+ciuQ" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Petr, > let me start by saying that my view is that this is simply a > documentation bug. Meaning that I didn't document that it does not work, > but I also never intended it to work. Main reason is that we can't > support the semantics of "UPDATE OF" correctly (see bellow). And I think > it's better to not support something at all rather than making it behave > differently in different cases. >=20 > Now about the proposed patch, I don't think this is correct way to > support this as it will only work when either PRIMARY KEY column was > changed or when REPLICA IDENTITY is set to FULL for the table. And even > then it will have very different semantics from how it works when the > row is updated by SQL statement (all non-toasted columns will be > reported as changed regardless of actually being changed or not). >=20 > The more proper way to do this would be to run data comparison of the > new tuple and the existing tuple values which a) will have different > behavior than normal "UPDATE OF" triggers have because we still can't > tell what columns were mentioned in the original query and b) will not > exactly help performance (and perhaps c) one can write the trigger to > behave this way already without impacting all other use-cases). I personally think that solution proposed by Masahiko is much better than current behavior. We could document current limitations you've mentioned and probably add a corresponding warning during execution of ALTER TABLE ... ENABLE REPLICA TRIGGER. I don't insist on this particular approach though. What I really don't like is that PostgreSQL allows to create something that supposedly should work but in fact doesn't. Such behavior is obviously a bug. So as an alternative we could just return an error in response to ALTER TABLE ... ENABLE REPLICA TRIGGER query for triggers that we know will never be executed. --=20 Best regards, Aleksander Alekseev --mP3DRpeJDSE+ciuQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEECAokn0QZCoIHW4GpEEnCBLXCDtYFAlnc5cgACgkQEEnCBLXC Dta3/Q//Z6PiTHRBHKggouIpRPvzSDPqzmEBi8J0wum6cHlLlZYOEiaboVrCsdLc L743v38Yy0e9ZNuNDV644C1xVTiggs3kjDLSZPrWCNF4bLvLtDZ/haL3Yz5COyuQ IKCK0avk3VP4F7ALaIia9Vq9Tpcu3Hpratijn83jiu19m3quoif7KUsnXtZXzhm/ OwEeV9x96fQpp4LD2rc80r3l8ByDuOAHPoxJR6kByfcY7AqyePLlOxxWO4RPcy0m 2NX+r8ygf/9BK8UKe5jvnj/6jLKKz5PmJq9HpMG+Qbkge/to9I2KFxZJAXFGFLhH a4Q++XFRqjOfg4upe/bu+0glR1gi6Uq/1DwwX4AfMtB8HejSgp61LfjaKbO0VL1v 0m6VxrzsWGBfD4XEAs/5blfBdwV1AKeVUZs+w9UF/EXB5/pNsbCztxoQKCG2/8Vo OEK46eSvOu5cyHc71cS8SC1L1pBh3224l1wbbuyYZd/CNjBRjw1ZljjIAGO6O/4O vXfDTGi/3YGW72PzTREDgKI8qvI2w00+QXO+YvOuIEPszaeM4DWP7mVve8e3jttG fObKz6Z/5LcH/kLo2tIhdO5T0GPrUSFMaknRtZ2eIAsez5vXpZW9xmPsQTzny2wk QiH+zvJJlxK9u/4mMWOmgMecjMyhZkfVzdR05JU/iODQEPeQZiI= =kPvG -----END PGP SIGNATURE----- --mP3DRpeJDSE+ciuQ--