pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Hans <hguijtra@xs4all.nl>
To: pgsql-general@lists.postgresql.org
Subject: Re: Trigger not firing
Date: Mon, 1 Jun 2020 06:43:32 -0700
Message-ID: <215a6911-1045-7710-2084-d715e8d20b29@aklaver.com> (raw)
In-Reply-To: <bf8e0535-4197-a81d-f4b2-ce2e18ec9711@xs4all.nl>
References: <159077982292.12069.16282824319899836435@malur.postgresql.org>
	<0f0451cc-aa72-2cfc-111a-5e956ca16457@xs4all.nl>
	<dfb7cce5-6a3b-5494-a19c-ce412f6d439c@aklaver.com>
	<bf8e0535-4197-a81d-f4b2-ce2e18ec9711@xs4all.nl>

On 6/1/20 3:09 AM, Hans wrote:
>>> I've had a weird problem in a production system. The customer had 
>>> installed a new server with our software on it. The software installs 
>>> a Postgres database schema that includes a number of triggers. The 
>>> triggers perform inserts into an additional table.
>>
>> How is the install done?
> 
> Our instructions tell them to apt-get it from the default repository. I 
> can ask on tuesday for more information.

But there is more to it then that as you show below. So what is the 
outline for a customer to get from clean server to one with your 
software fully installed?

The Postgres logs from the period the below was run might be 
informative. I'm guessing that is going to have to wait until Tuesday.

> 
>>> Our software contains no code for disabling triggers. It creates them 
>>> once, during database initialisation (i.e. before any data is put 
>>> in), and then leaves them alone. I have no reason to believe the 
>>> customer messed with the database either.
>>
>> Exactly how is that done?
> 
> We give them a C++ program that creates the tables, and then executes:
> 
> CREATE OR REPLACE FUNCTION generic.update_usergrouptest_from_test() 
> RETURNS trigger AS $$
> DECLARE
>   x INTEGER;
> BEGIN
>   IF NEW.usergroup_ids <> OLD.usergroup_ids THEN
>    DELETE FROM generic.usergroup_test WHERE test_id = NEW.id;
> 
>    FOREACH x IN ARRAY NEW.usergroup_ids LOOP
>     INSERT INTO generic.usergroup_test (test_id, usergroup_id) VALUES 
> (NEW.id, x);
>    END LOOP;
>   END IF;
> 
>   RETURN NEW;
> END;
> $$ LANGUAGE plpgsql;
> 
> and then
> 
> CREATE TRIGGER update_usergrouptest_from_test
> AFTER UPDATE ON generic.test
> FOR EACH ROW EXECUTE PROCEDURE generic.update_usergrouptest_from_test();

> Hans
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (6+ messages)

Message-ID: <215a6911-1045-7710-2084-d715e8d20b29@aklaver.com>
Permalink:  ../215a6911-1045-7710-2084-d715e8d20b29@aklaver.com/
Also on:    postgresql.org/message-id/215a6911-1045-7710-2084-d715e8d20b29@aklaver.com

 · 

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: adrian.klaver@aklaver.com, hguijtra@xs4all.nl
  Subject: Re: Trigger not firing
  In-Reply-To: <215a6911-1045-7710-2084-d715e8d20b29@aklaver.com>
  References: <159077982292.12069.16282824319899836435@malur.postgresql.org> <0f0451cc-aa72-2cfc-111a-5e956ca16457@xs4all.nl> <dfb7cce5-6a3b-5494-a19c-ce412f6d439c@aklaver.com> <bf8e0535-4197-a81d-f4b2-ce2e18ec9711@xs4all.nl> <215a6911-1045-7710-2084-d715e8d20b29@aklaver.com>

* 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