Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 7B018B5DBDC for ; Fri, 17 Jun 2011 00:48:25 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 81271-05-6 for ; Fri, 17 Jun 2011 03:48:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from andromeda.yoshidanet.com.br (dns1.yoshidanet.com.br [186.225.19.19]) by mail.postgresql.org (Postfix) with ESMTP id 11B42B5DBDA for ; Fri, 17 Jun 2011 00:48:17 -0300 (ADT) Received: from [201.20.39.226] (helo=[127.0.0.1]) by andromeda.yoshidanet.com.br with esmtpa (Exim 4.72) (envelope-from ) id 1QXQ2X-0004ul-TN for pgsql-bugs@postgresql.org; Fri, 17 Jun 2011 00:48:14 -0300 Message-ID: <4DFACE72.3090505@planit.com.br> Date: Fri, 17 Jun 2011 00:48:02 -0300 From: "Luiz K. Matsumura" Organization: Plan IT Tecnologia =?ISO-8859-1?Q?Inform=E1tica_Ltda=2E?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; pt-BR; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Re: Behaviour of triggers on replicated and non replicated tables References: <4DF21A1B.3060101@planit.com.br> In-Reply-To: Content-Type: multipart/alternative; boundary="------------080006090306040008070001" X-Antivirus: avast! (VPS 110616-1, 16/06/2011), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.42 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FS_REPLICA=3.599, HTML_MESSAGE=0.001, SARE_SPEC_REPLICA=0.72 X-Spam-Level: ** X-Archive-Number: 201106/134 X-Sequence-Number: 30513 This is a multi-part message in MIME format. --------------080006090306040008070001 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Em 16/06/2011 16:39, Robert Haas escreveu: > 2011/6/10 Luiz K. Matsumura: >> I need help to know if the follow scenario is a expected behaviour, a bug of >> postgres or a bug of slony: >> >> Postgres v8.4.8 >> Slony-I v 2.0.5 >> >> I have table replicated with slony and that do some updates in another table >> not replicated. >> >> The trigger on replicated table was enabled on the slave database with the >> command: >> >> ALTER TABLE table1 ENABLE ALLWAYS TRIGGER trigger1; >> >> And this trigger is working fine as expected. >> >> The strange behaviour is that trigger do a update in another table not >> replicated, letīs say table2, and >> the triggers of this table is not fired. >> A unexpected behaviour IMHO, if I do >> >> ALTER TABLE table2 ENABLE ALWAYS TRIGGER trigger2; >> >> Then the trigger2 is fired now when trigger1 do a update in table2. >> >> My doubt is: since table2 is not replicated why they triggers dont fire even >> by a update command in >> a trigger of a replicated table ? > I'm confused. If you enable the trigger on table2, it's going to fire > when someone updates table2. Whether or not the update is coming from > another trigger or directly from the user has nothing to do with it. > Thanks for reply Robert. This is the point, when the trigger of table2 was create with a command like this CREATE TRIGGER trg_table2 BEFORE INSERT OR UPDATE ON table2 FOR EACH ROW EXECUTE PROCEDURE trg_table2(); The trigger is enabled by default as expected. If I do a update on table2 the trigger fire normally. But when a replicated table fire a trigger that do the same update, now the trigger on table2 donīt fire. I donīt know if this is slony disabling all triggers unless REPLICA and ALLWAYS trrigers even over not replicated tables or this is managed by postgresql -- Luiz K. Matsumura * * --------------080006090306040008070001 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit

Em 16/06/2011 16:39, Robert Haas escreveu:
2011/6/10 Luiz K. Matsumura <luiz@planit.com.br>:
I need help to know if the follow scenario is a expected behaviour, a bug of
postgres or a bug of slony:

Postgres v8.4.8
Slony-I v 2.0.5

I have table replicated with slony and that do some updates in another table
not replicated.

The trigger on replicated table was enabled on the slave database with the
command:

ALTER TABLE table1 ENABLE ALLWAYS TRIGGER trigger1;

And this trigger is working fine as expected.

The strange behaviour is that trigger do a update in another table not
replicated, let´s say table2, and
the triggers of this table is not fired.
A unexpected behaviour IMHO, if I do

ALTER TABLE table2 ENABLE ALWAYS TRIGGER trigger2;

Then the trigger2 is fired now when trigger1 do a update in table2.

My doubt is: since table2 is not replicated why they triggers dont fire even
by a update command in
a trigger of a replicated table ?
I'm confused.  If you enable the trigger on table2, it's going to fire
when someone updates table2.  Whether or not the update is coming from
another trigger or directly from the user has nothing to do with it.

Thanks for reply Robert.

This is the point, when the trigger of table2 was create with a command like this

CREATE TRIGGER trg_table2
  BEFORE INSERT OR UPDATE
  ON table2
  FOR EACH ROW
  EXECUTE PROCEDURE trg_table2();

The trigger is enabled by default as expected. If I do a update on table2 the trigger fire normally.
But when a replicated table fire a trigger that do the same update, now the trigger on table2 don´t fire.
I don´t know if this is slony disabling all triggers  unless REPLICA and ALLWAYS trrigers even over not replicated
tables or this is managed by postgresql


--
Luiz K. Matsumura

--------------080006090306040008070001--