Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UE2a1-00018j-NZ for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Mar 2013 19:03:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UE2a0-0002dk-F8 for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Mar 2013 19:03:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UE2Zz-0002de-DO for pgsql-bugs@postgresql.org; Fri, 08 Mar 2013 19:03:43 +0000 Received: from nm25-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.156]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UE2Zs-0007j8-8w for pgsql-bugs@postgresql.org; Fri, 08 Mar 2013 19:03:42 +0000 Received: from [98.139.212.146] by nm25.bullet.mail.bf1.yahoo.com with NNFMP; 08 Mar 2013 19:03:34 -0000 Received: from [98.139.212.194] by tm3.bullet.mail.bf1.yahoo.com with NNFMP; 08 Mar 2013 19:03:33 -0000 Received: from [127.0.0.1] by omp1003.mail.bf1.yahoo.com with NNFMP; 08 Mar 2013 19:03:33 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 968682.41564.bm@omp1003.mail.bf1.yahoo.com Received: (qmail 57945 invoked by uid 60001); 8 Mar 2013 19:03:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1362769413; bh=r2Qv4PFF9PxvCKm8zdrOwPbICmB2pnkC+t9/Xh3e8bI=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=mzyF4kHjYwJr20xbnWrHcq1bqfr5tzW3tK49r6qIJaODhZWdDpGPOGc2OUUTFwO0oqUlP65KhvJHlpcoEsQZjNeOu4oRXFlpfxar4lpe6xY+zU81nK98te2IiiMfh3Cg2HLSAM7ufvPGe/hPrSDsuHXPw4ipETE2U7dMY3yw6WY= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=ymail.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=HwZVt7RHBgBfoWFa7PtB4HYE3yofXXRjcfQSxCBHXiSEhYm7gSS4PqB+8IWg+2kRZTToMFBCX+CIr9jicb8jjq2ZprRfkyhsnrMsfVZATarCLw+qfTE3Eyk+G+oK6s/oapV7NPbELHlbpVMEKnXK4WChEKn8FrpdqZUYPp5A4eU=; X-YMail-OSG: 5sA_MnYVM1ltefbp06oE0AgFJuie2EQahooHAfXNUjbJ_mN 212LktayscdUUHcmbYsv56ljD8p.Z4PsiI7qJ046dFeRnNX6MowXgukRPN7M BmSjbhBPxgIkcJulL1xx_FyELk1xakYbJtFH8CbcEUbq5gkAaO8T_Qr0t7vb qh3r3w58xTwk35pvxOHoiL25o8jXmxd9zw1oDYEVXCs.uJSxP0Gz3c6gyGi7 ghWrEWFmydgmnI2pxyYNzdMNe_Ng0hc5XTfBpPYP9KqFu97WwgCITR91yFdo x1G2cT5iPSrI6h6gAl6RPSE5HJdLZzg7l_2iAY2Nqm7IHQFx1SbtADSGCoeK C_Fld1NL90Q47vJ1OrNCFtJb_9y40xL5iQEpir_W0iWFIl_UMM.otoYsQI5R zr_e09RUz4XTdpmw4Fa7lj7ZCgnq.GI91Phl0ZX_j6lWJijjP.xmoW4WIDio 6oV3V11C_bicXZEaKSnfD43ezyD1GS_CoWSoKfNNDp09TGcJdgmokNrPMnWN pdXQ.GNjT23Y0CUkxAxOi5tbuwsuaEeuBjlNJ9qkmZXYN8H1Ja6rMnrreSlh AJdiHSdVb Received: from [76.255.18.237] by web162901.mail.bf1.yahoo.com via HTTP; Fri, 08 Mar 2013 11:03:33 PST X-Rocket-MIMEInfo: 001.001, Im12LmdvbnphbGV6QGNpci5lcyIgPG12LmdvbnphbGV6QGNpci5lcz4gd3JvdGU6Cgo.IE9uIHRhYmxlX0IgYXBwZWFyczoKPsKgwqAgaWTCoMKgwqAgfCBzaXR1YXRpb24gfCB3aGVuCj4gLS0tLS0tLS0rLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tCj7CoMKgIDIzwqDCoMKgIHwgU3RhcnRlZMKgIHwgMjAxMy0wMy0wOCAxMjozMzozNQo.wqDCoCAyM8KgwqDCoCB8IFN0YXJ0ZWTCoCB8IDIwMTMtMDMtMDggMTI6MzM6MzcKPgo.IEkgZG9uJ3QgdW5kZXJzdGFuZCB3aHkgYWZ0ZXIgdGhlIHNlY28BMAEBAQE- X-Mailer: YahooMailWebService/0.8.135.514 References: Message-ID: <1362769413.51869.YahooMailNeo@web162901.mail.bf1.yahoo.com> Date: Fri, 8 Mar 2013 11:03:33 -0800 (PST) From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: BUG #7924: Trigger update function don't take correct values To: "mv.gonzalez@cir.es" , "pgsql-bugs@postgresql.org" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org "mv.gonzalez@cir.es" wrote: > On table_B appears: >=A0=A0 id=A0=A0=A0 | situation | when > --------+-----------+--------------------- >=A0=A0 23=A0=A0=A0 | Started=A0 | 2013-03-08 12:33:35 >=A0=A0 23=A0=A0=A0 | Started=A0 | 2013-03-08 12:33:37 > > I don't understand why after the second update, the insert done on table_B > is incorrect, and has the same values that the first one. > > I've been looking for some kind of explanation like cache or something, b= ut > I couldn't find anything. It helps to provide a self-containted test case like this: test=3D# CREATE TABLE table_a (id int PRIMARY KEY, situation text NOT NULL); CREATE TABLE test=3D# INSERT INTO table_a VALUES (23, 'Unknown'); INSERT 0 1 test=3D# CREATE TABLE table_b (id int NOT NULL, sitation text NOT NULL, "wh= en" timestamptz NOT NULL); CREATE TABLE test=3D# CREATE FUNCTION log_func() test-#=A0=A0 RETURNS TRIGGER test-#=A0=A0 LANGUAGE plpgsql test-# AS $$ test$# BEGIN test$#=A0=A0 set datestyle to 'sql'; test$#=A0=A0 set datestyle to 'european'; test$#=A0=A0 IF (TG_OP =3D 'UPDATE' and (OLD.situation!=3DNEW.situation)) T= HEN test$#=A0=A0=A0=A0 INSERT INTO table_B VALUES (OLD.id,NEW.situation,NOW()); test$#=A0=A0 END IF; test$#=A0=A0 RETURN NULL; test$# END; test$# $$; CREATE FUNCTION test=3D# CREATE TRIGGER log_trig test-#=A0=A0 AFTER UPDATE ON table_a test-#=A0=A0 FOR EACH ROW EXECUTE PROCEDURE log_func(); CREATE TRIGGER test=3D# update table_A set situation=3D'Started' where id=3D'23'; UPDATE 1 test=3D# select * from table_a; =A0id | situation ----+----------- =A023 | Started (1 row) test=3D# select * from table_b; =A0id | sitation |=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 when=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 =A0 ----+----------+-------------------------------- =A023 | Started=A0 | 08/03/2013 13:01:08.169213 CST (1 row) test=3D# update table_A set situation=3D'Waiting' where id=3D'23'; UPDATE 1 test=3D# select * from table_a; =A0id | situation ----+----------- =A023 | Waiting (1 row) test=3D# select * from table_b; =A0id | sitation |=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 when=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 =A0 ----+----------+-------------------------------- =A023 | Started=A0 | 08/03/2013 13:01:08.169213 CST =A023 | Waiting=A0 | 08/03/2013 13:01:08.179754 CST (2 rows) How about showing us yours? -- Kevin Grittner EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs