Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1njg7a-0006D6-IR for pgsql-docs@arkaria.postgresql.org; Wed, 27 Apr 2022 11:46:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1njg7Z-0001EJ-Az for pgsql-docs@arkaria.postgresql.org; Wed, 27 Apr 2022 11:46:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1njg7Z-0001EA-3H for pgsql-docs@lists.postgresql.org; Wed, 27 Apr 2022 11:46:13 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1njg7W-0000nU-KH for pgsql-docs@lists.postgresql.org; Wed, 27 Apr 2022 11:46:12 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 0FCA73200931; Wed, 27 Apr 2022 07:46:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 27 Apr 2022 07:46:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1651059968; x=1651146368; bh=5+B+iJb/k/og1PZBIwNTGEYnTygA NPL/ekBkWPab7Vc=; b=qeH8onXWeJhWIWmBcCnuGMXA3cnOtRHGDRMCwgRnYdL9 dPDIPRVcsdT9Enk9J9LsYEEzi3O8EHbQ0AwfExwyQhO4U/ygkh1VPJDtfuAWuu77 u1J9V59cbqQpn9woiWFL3P0incwynOUOaHLBr8eoRu6+SE6zyMpMGBZq///sGedO q7DDV9CcwFxz6PK4UeOzL5Xq5DGY5QriDGhBVouXSwQAyowU9Ry+s1XEytk5795H BZ8NO+j4VkUJ9+VUbbiL0/0/wDJZxor4km7c/EcWP8rpFolUvKUGocmiJPIA06RG 2Iyp8NQB24CO8yfe6NwOXv4aJW4BlFqY7sjgayeEUQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehgdegudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkgggtugfgjgesthekre dttddtjeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgv segrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepkedthfekveduue fgueelteekgfejgeekueduudeuveeuvddufffggfetiefhvdefnecuffhomhgrihhnpehp ohhsthhgrhgvshhqlhdrohhrghdpvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv segrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 27 Apr 2022 07:46:08 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id AB9562A070E; Wed, 27 Apr 2022 13:46:05 +0200 (CEST) Date: Wed, 27 Apr 2022 13:46:05 +0200 From: Alvaro Herrera To: Jian He Cc: pgsql-docs@lists.postgresql.org Subject: Re: 43.10 Trigger Functions one sentences kind of not easy to understand. Message-ID: <202204271146.waevseyzqnsb@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Apr-27, Jian He wrote: > https://www.postgresql.org/docs/current/plpgsql-trigger.html > > > *Returning a row value different from the original value > > of NEW alters the row that will be inserted or updated.* > I just want confirm the highlighted sentence is equivalent as the > following sql code: Yes: > begin; > > CREATE TABLE documents ( > > docdesc text, > > misc text, > > modification_time timestamp with time zone DEFAULT now() > > ); > > CREATE FUNCTION documents_update_mod_time() RETURNS trigger > > AS $$ > > begin > > new.modification_time := now(); > > > return new; > > > end > > $$ > > LANGUAGE plpgsql; > > CREATE TRIGGER documents_modification_time > > BEFORE INSERT OR UPDATE ON documents > > FOR EACH ROW > > EXECUTE PROCEDURE documents_update_mod_time(); > > commit; This is the usual way to modify the row being inserted. > As a non-native english speaker, I kind of feel this sentence quite hard to > understand.... Maybe you can split it up at periods and think about individual parts separately. The docs are intentionally packed very densely with information, to avoid making them longer than they already are. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/