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 1isOdp-0005gw-Jv for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Jan 2020 10:14:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1isOdo-00073Q-DL for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Jan 2020 10:14:12 +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 1isOdn-00073J-V9 for pgsql-hackers@lists.postgresql.org; Fri, 17 Jan 2020 10:14:12 +0000 Received: from forward104j.mail.yandex.net ([5.45.198.247]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1isOdj-0004gN-Dy for pgsql-hackers@postgreSQL.org; Fri, 17 Jan 2020 10:14:11 +0000 Received: from mxback11g.mail.yandex.net (mxback11g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:90]) by forward104j.mail.yandex.net (Yandex) with ESMTP id AB9504A1547; Fri, 17 Jan 2020 13:14:05 +0300 (MSK) Received: from sas2-ee0cb368bd51.qloud-c.yandex.net (sas2-ee0cb368bd51.qloud-c.yandex.net [2a02:6b8:c08:b7a3:0:640:ee0c:b368]) by mxback11g.mail.yandex.net (mxback/Yandex) with ESMTP id 4vwM25EJfx-E5Wi4lEF; Fri, 17 Jan 2020 13:14:05 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1579256045; bh=6nYxcMWyfq9lYAHmXpqZaXXopJ8WYacOSWNp8XJ0h5k=; h=In-Reply-To:Subject:CC:To:From:References:Date:Message-ID; b=vYNIIqw27GngQO0ZEYLFB9KvIRtxYNsAPqe2RzAaDxEo5GrZ6JdmgJDMvWcPCi2Gb M4eu14j1Frq9RYF6yhLg9HEUwZsWuQKtOITeDy+UJFYgE2Xkj0w6dzXyT8H0euM7Ga THe2eWV5M//U5W9tSwgQXlMfRJ0Ux+yg0creTjkk= Authentication-Results: mxback11g.mail.yandex.net; dkim=pass header.i=@yandex.ru Received: by sas2-ee0cb368bd51.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 2l2abfoXC3-E40SR0vY; Fri, 17 Jan 2020 13:14:04 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Date: Fri, 17 Jan 2020 12:14:03 +0200 From: Eugen Konkov Message-ID: <15010033764.20200117121403@yandex.ru> To: Bruce Momjian CC: PostgreSQL-development , pgsql-docs@lists.postgresql.org Subject: Re: Does 'instead of delete' trigger support modification of OLD In-Reply-To: <20191107222818.GA18712@momjian.us> References: <919823407.20191029175436@yandex.ru> <20191106185935.GE1843@momjian.us> <1771593631.20191107112032@yandex.ru> <352093181.20191107112429@yandex.ru> <20191107212655.GA487@momjian.us> <20191107222818.GA18712@momjian.us> 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 Hello Bruce, > Triggers are designed to check and modify input data, and since DELETE > has no input data, it makes no sense. Sorry, I am still ambiguous. You say that DELETE has no input data, but doc says that it has: https://www.postgresql.org/docs/current/trigger-definition.html For a row-level trigger, the input data also includes ... the OLD row for ... DELETE triggers Also restricting DELETE to change the returned data by DELETE RETURNING seems as incomplete. For example if triggers implement some compression. -- insert into field ZZZZZ value -- compress and actually store Zx5 into field -- Delete this insert row -- So user should get back that the value ZZZZZ was deleted and not Zx5. Correct? but currently user will see Zx5, because next code: OLD.value = uncompress( OLD.value ); does not effect RETURNING =( -- Best regards, Eugen Konkov