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 1iNeab-0007vN-QE for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2019 14:59:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iNeaa-0000aQ-9V for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2019 14:59:48 +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 1iNeaZ-0000Te-QP for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2019 14:59:47 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iNeaX-0008TI-Eu for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2019 14:59:46 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id AD642220A9; Thu, 24 Oct 2019 10:59:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 24 Oct 2019 10:59:44 -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=fm1; bh=t zWyrvQDaMrh7DdrnjgUvS1DaKVd26JTEeoi4bhFZ/Q=; b=Nd9rVl6R7vGxsg3Gt j1ZIgxrP9aV+aefXNMBXdTKj0VTWagqYuI58QkcnN72EfMdP4WGjgsVA0s1bVGFs eD9kOuW6cRCumOeH7cqzeeYsOiXTJe9g22nxl4aOMssew80u0xzEnBl0xZJSbYFO Hgt6+Jzsaa8Gqr188Wp2ihytxy9zXZnYzeo239mzkTDnwKtVtER/cp6hneDBCZeF k8BaQ8q8ev+94EOmNOMzudXWrYf7+JomDLHNbpcRHn/r24bkPvJM9MIBcMehPt6L cgukWfJT78suDcZOr0mR8+Tz/ce/4S717DpJOmefTIf26sYmfaSVGKRkwRq9wA38 6/JYw== 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=fm1; bh=tzWyrvQDaMrh7DdrnjgUvS1DaKVd26JTEeoi4bhFZ /Q=; b=Ez12qo7EubTwlfwsxh02/15ud7rpChY9kVtLNqpucS/0gC85PJ8y7S2Gu PCNWzpme9xDTkFpUbhM1tOeuunQWE1sjWarG9N0KUCRs1maqGMLAvrm0FjGpHtcA yA/Wk3zDole2cm907pyhwdO04NFGyGzzzaf23CbOwOWPGf6SHLmRzHDd3Db+ZGH7 Kl1w+QBp/M7LUSTp7yyvcATSh1+wQ9N0x1W6TZ8TP7W1fLOFECQHG3nKEiljBYEE NDRcXm4MVkd9oIvOh3/NUbqyGCprV9WSnD3s5cClr9qDA/uPxpBQuoqAPUOVabxx /8erdpLUFc+7mCCrmtgz3mSB7SeBw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrledugdekvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecukfhppedujeegrddvuddrkedtrddukeehnecurfgrrhgrmhepmhgrihhlfhhrohhm pegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsthgvrh fuihiivgeptd X-ME-Proxy: Received: from [192.168.1.3] (174-21-80-185.tukw.qwest.net [174.21.80.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 6745C80061; Thu, 24 Oct 2019 10:59:43 -0400 (EDT) Subject: Re: Having more than one constraint trigger on a table To: Andreas Joseph Krogh , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <33ad2642-ae94-29f6-cbc6-0122894ddf26@aklaver.com> Date: Thu, 24 Oct 2019 07:59:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 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 10/22/19 8:26 AM, Andreas Joseph Krogh wrote: > På tirsdag 22. oktober 2019 kl. 17:12:59, skrev Adrian Klaver > >: > > [snip] > No. > When I sort the triggers I get: > > test=# create table trg_str(fld_1 varchar); > CREATE TABLE > test=# insert into trg_str values ('trigger_1_update_fts'), > ('trigger_2'), ('trigger_3'), ('trigger_1_check_nocycle'); > INSERT 0 4 > test=# select * from trg_test order by fld_1 ; >   id | fld_1 > ----+------- > (0 rows) > > test=# select * from trg_str order by fld_1 ; >            fld_1 > ------------------------- >   trigger_1_check_nocycle >   trigger_1_update_fts >   trigger_2 >   trigger_3 > > Is this how you want them to fire as it does not match what you say > above?: > > (I know they were not /declared/ in that order, but..) > Yes, all "trigger_1_*" are the "actuall triggers triggering the logic", > trigger_2 and trigger_3 are only there as part of the "make > constraint-triggers fire only once"-mechanism, in which the function in > the first trigger is the function performing the actual logic. > So, being I want 2 "logical chunks" to happen I have two > "trigger_1"-triggers (there is no established terminilogy for this > AFAIK), each calling a function performing the logick which is to happen > only once (per row). > > "The first "main" trigger-function is update_company_fts_tf() ... The > second "main" trigger-function is company_parent_no_cycle()" > > It might be easier to understand if sketch out a schematic version of > what you are trying to achieve. > > The point is; I want to functions to be called > - update_company_fts_tf() > - company_parent_no_cycle() > , each only once, as constraint-triggers on the same table. So they are > called by the "level 1 triggers" which must fire first. To be clear the order they fire relative to each other is not important? > Is it clearer now what I'm trying to achieve? Sort of, though I am still not entirely what the whole process is trying to achieve. What the mix of deferred and un-deferred triggers and 'logical' and housekeeping functions are doing is not clear to me. That is why I suggested a schematic representation of the trigger flow would be helpful. Leave out the fine details and create a flow chart of what you want to happen. > -- > Andreas Joseph Krogh -- Adrian Klaver adrian.klaver@aklaver.com