pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Joseph Krogh <andreas@visena.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Having more than one constraint trigger on a table
Date: Tue, 22 Oct 2019 17:26:57 +0200 (CEST)
Message-ID: <VisenaEmail.1f.ee5e8ebc5c098085.16df40bf8c6@tc7-visena> (raw)
In-Reply-To: <27796c9e-4e3a-72bd-ad69-02733e989ab9@aklaver.com>


På tirsdag 22. oktober 2019 kl. 17:12:59, skrev Adrian Klaver <
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>: 
[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. 

Is it clearer now what I'm trying to achieve? 


--
 Andreas Joseph Krogh

view thread (5+ messages)  latest in thread

Message-ID: <VisenaEmail.1f.ee5e8ebc5c098085.16df40bf8c6@tc7-visena>
Permalink:  ../VisenaEmail.1f.ee5e8ebc5c098085.16df40bf8c6@tc7-visena/
Also on:    postgresql.org/message-id/VisenaEmail.1f.ee5e8ebc5c098085.16df40bf8c6@tc7-visena

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andreas@visena.com
  Subject: Re: Having more than one constraint trigger on a table
  In-Reply-To: <VisenaEmail.1f.ee5e8ebc5c098085.16df40bf8c6@tc7-visena>
  References: <27796c9e-4e3a-72bd-ad69-02733e989ab9@aklaver.com> <VisenaEmail.1f.ee5e8ebc5c098085.16df40bf8c6@tc7-visena>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox