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 1j4tbU-0000sg-DE for pgsql-general@arkaria.postgresql.org; Thu, 20 Feb 2020 21:43:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j4tbT-0007nq-8V for pgsql-general@arkaria.postgresql.org; Thu, 20 Feb 2020 21:43:27 +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 1j4tbS-0007nj-RN for pgsql-general@lists.postgresql.org; Thu, 20 Feb 2020 21:43:26 +0000 Received: from [66.111.4.26] (helo=out2-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j4tbN-0001i4-Ie for pgsql-general@postgresql.org; Thu, 20 Feb 2020 21:43:25 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B286D21B34; Thu, 20 Feb 2020 16:43:10 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 20 Feb 2020 16:43:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=A c3lrmHQ1cN/G1iqo64ZvKgyCfn4VD37P9CdqME967U=; b=mc5iQgfL5dKAiyAPB MKgj10iXIMzrI1RCcTYL+0AXSfEUypl+shShoVGsNldUCw6WqGYZPHRon+dUzvmg /u+T/MMsIyMZ0VsQWjv9TeeSyYPzEGQmUBwyY/utyDMVIoCcwCYfMgNgOrB1YfNp Kf4jsOEkGMGJyO/eAmWiCfRMyIEfDTOY13s+777XqwkK2FXS1qB3lAHcEBqLrGlz qrUuT3Q7o9BILY5wCdfRiuuM2kj6JUsnrrEVgTV8EhKu5JK/dLVVa4YUpgCT7OJJ HymDjFAvw/OW6rt3UqWDOnZxDJaq4mj8/8/6OpF71D1fbVSL3DjmFoFpgPcHLhKY MbSZg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=Ac3lrmHQ1cN/G1iqo64ZvKgyCfn4VD37P9CdqME96 7U=; b=JLgMxuWDSCkAgrseyKRllWCtsnzHs8gOZfzzOQOjmNiyQsU0lMrK3lGyX 1NEIsE+5easyPqXU7QQ8mpC154SgLyZwMArZveesGpqrhKpxoV2l+F6LU3Fafntz +Rmc8zKGzo1KucXeu9OZ1JEz9nm5YI0XBlbrITYIV5P9OotnL54jpltQyh5g8kgf 71D2iq75gCitCKmXj3GG5foD35CfasspIX/cQBTAHHkdz/JKadH3Rr7SOl4F2tsg YnrWemBxAzHbY+ibsnuKvPjOPYaDgkt6AGtYLFgVqG11VCbim0Ul4iYES0kLrCxl 6QaLsrSLHvhzfGsvCkVi5wq+Ry+kg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrkedvgdduheehucetufdoteggodetrfdotf 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 150AE328005E; Thu, 20 Feb 2020 16:43:09 -0500 (EST) Subject: Re: before insert for each row trigger on upsert To: Ted Toth Cc: pgsql-general References: <18def70d-c2c4-ff92-b488-243ed0287001@aklaver.com> From: Adrian Klaver Message-ID: Date: Thu, 20 Feb 2020 13:43: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 X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.26 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/20/20 1:03 PM, Ted Toth wrote: > > > On Thu, Feb 20, 2020 at 2:32 PM Adrian Klaver > wrote: > > 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. > > > I think you are right in that the trigger doesn't change the row being > updated (which is good) but it also updates another table and that's > what I'd actually like to avoid on update. Hard to say what to do without knowing what the trigger function actually does? > > > > > > Ted > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com