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 1hTZwd-000230-Vm for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2019 22:42:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hTZwc-0005Zi-JB for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2019 22:42:46 +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 1hTZwa-0005TT-ES for pgsql-general@lists.postgresql.org; Wed, 22 May 2019 22:42:46 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTZwV-0007K3-LA for pgsql-general@postgresql.org; Wed, 22 May 2019 22:42:44 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B895F202F2; Wed, 22 May 2019 18:42:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 22 May 2019 18:42:37 -0400 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=fm3; bh=0 WyoPe8cSEtjBr2rcqdmq8aor5Dchm0XziLHf947Cc0=; b=NTFy3jfyCk1OTxBN2 Z2VYQpP9Z0pZ7I3p4UBD72DJwpuDlRebGfitYWQc9kITpWczyEP3m3FVUC7kfBhd IuC059F6nQQSkxc1fvsN2X51xtTBvT0YLOF2Lynhf8oKzdZT1UjyZrw07vKOUqS+ rlA0Duy3I3LSVSFjzVclgaellnvS+W+SHaWt1K5o8G9L9ctHyoCFsJSggr2XrAaP 65MiS7qrBdIHg1pCgteJ9KLS+UBDA0S+o66q4ZgP1YWqE0H7LN069AC1kxf5HbuH mrGWz27meiLQms6haZvwIEFICPoOwDsOsWVWYKkRRkbSsKz7VzSFFplRc8L4QgGH SyPZQ== 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=0WyoPe8cSEtjBr2rcqdmq8aor5Dchm0XziLHf947C c0=; b=ER4WBKKMMcDWsIOrKHPqwNpVbHwP/vQhLDguXp5zF7yHaOSz72QGm7dPa p0kFeinL9/WFta5m8+fsr4TdslJasdiYU/Che2efsyq070a8kxmWgK2w7nfAICVG 7TgltbOZCqRE5X4Y9uWEiTllGl0/EsZdD9MqJuouCXryZw6crqWLflVUsPwSKhOZ IGeoPWXnzoakKsFkg6+qxCKI2hl1Qdf/z3vC7FXloEn79ooNGZiC5vP4NCbw8api Y0YCd7kt/CfGheDOk0MRl7SwPIk05e19b0WKSvwNpCRKxZzZCtdumTYnWlVx0ww3 9H5z8ltxyoYAIukxUs19MarKG00/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddufedgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuffhomhgrihhnpehpohhsthhgrhgvsh hqlhdqrghrtghhihhvvgdrohhrghenucfkphepjedurddvuddvrdduhedtrddvtddvnecu rfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvg hrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id CA377380085; Wed, 22 May 2019 18:42:36 -0400 (EDT) Subject: Re: Trigger bug ? To: PegoraroF10 , pgsql-general@postgresql.org References: <1558560792308-0.post@n3.nabble.com> <1558563706827-0.post@n3.nabble.com> From: Adrian Klaver Message-ID: <0514c201-42f8-2cf4-2325-015ef78f65bb@aklaver.com> Date: Wed, 22 May 2019 15:42:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1558563706827-0.post@n3.nabble.com> 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 5/22/19 3:21 PM, PegoraroF10 wrote: > sorry, I wasn´t clear, when I sad returning Null I tried to say that new.PK > was Null, not the function result > Try to create exactly what I sent you and you´ll see null values on that pk. Yes because FOR EACH STATEMENT may deal with multiple rows, so it is undefined what NEW.pk is referring to. More below. > And that occurs just because that trigger was created without EACH > ROW/STATEMENT. > So, my question is, PG should return an error and not create that trigger > because ROW/STATEMENT was not specified, correct ? It was implicitly specified. Per the docs it will be FOR EACH STATEMENT by default in the absence of user input. If you just need the new PK why not?: INSERT INTO some_table ... RETURNING pk; > > > > -- > Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html > > > -- Adrian Klaver adrian.klaver@aklaver.com