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 1j4sUc-0005oI-Th for pgsql-general@arkaria.postgresql.org; Thu, 20 Feb 2020 20:32:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j4sUb-0005X1-5y for pgsql-general@arkaria.postgresql.org; Thu, 20 Feb 2020 20:32:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j4sUZ-0005TC-Cy for pgsql-general@lists.postgresql.org; Thu, 20 Feb 2020 20:32:16 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j4sUW-00015f-J6 for pgsql-general@postgresql.org; Thu, 20 Feb 2020 20:32:14 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 67F8221C29; Thu, 20 Feb 2020 15:32:11 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 20 Feb 2020 15:32:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=j 2lRIdpYfKsm0tHyiJE1OnxSojhNakXFStHF4ykbKR0=; b=omXn48hikjh8QiaJP vY8ph42jN4FDkxOWH1FDzic1ALxpfTQSJFbXb0Q1zJK4DQA8Pz60gvq7SegqXZ0r Cn5rGbno2mCFByE9oyyDsj6iHhTzg+t+m+cVzn/kt35HaHtJas87r6EGboNxX6Ih jg0XDfzCLzYZXlnelito6GDwHDGmGK0V1q93hPXkIoCJdT/4nDkzJC79WwUFOY0D 1iqfcqCfeFybnRO7ef4B4iHXIgqvHzpc06Ku2gtaamhFonwEeJYaPGhcBNrcXN0Q xvKBDbxQ0BendB1c12K4cMoESgbNpoXOTbWYaLmojbLTAvMvUlPmkxayl4jmvYnE wBvdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=j2lRIdpYfKsm0tHyiJE1OnxSojhNakXFStHF4ykbK R0=; b=dWt52wCNtRvfTbZ0jZejH7Zcq0TY6FSMuHbVK+qChlPE0ie/DmmekDQW7 NMhwd7V46w6tWeavJqaLsE8H18Vc7EEUon5SEkpI4dhCoQc6vTWM2TYBuj6n5ZZ5 Q5azCjHLuE/Ni5fi8VMoPYL9Qpa2tvxrzgJWzB8xl94jvpLPWwKG4t40ks0niMmG Sk342YL0JOVkgFQKlnxjXQ8+hjVzGgt4GOj8dfICfm+Wre9pPjtj9cWNxCnpm0AM dLt7w3vtBeI/43ZylaRqhHJdpc9c5zpZn1ejXWo3D0rJtOdRyESfageCORjyJsQo B717mKl0BCgtRGuhqKJP0nA1l32jQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrkedvgddugeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjedurddvuddvrdduvdelrdduleefnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklh grvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id AA8423280062; Thu, 20 Feb 2020 15:32:10 -0500 (EST) Subject: Re: before insert for each row trigger on upsert To: Ted Toth , pgsql-general References: From: Adrian Klaver Message-ID: <18def70d-c2c4-ff92-b488-243ed0287001@aklaver.com> Date: Thu, 20 Feb 2020 12:32:09 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/20/20 12:17 PM, Ted Toth wrote: > I'm a little confused why the before insert trigger fires al all but > since it does isĀ  there a way to know that an update will occur? Because ON CONFLICT DO UPDATE is part of an INSERT command. > Basically I don't want the trigger affect the row on update. Not sure that a BEFORE trigger will work for that anyway as it will not have submitted the data yet for ON CONFLICT resolution. > > Ted -- Adrian Klaver adrian.klaver@aklaver.com