Re: [GENERAL] Trigger problems/questions - Mailing list pgsql-general

From Jim Fulton
Subject Re: [GENERAL] Trigger problems/questions
Date
Msg-id CAPDm-FgNP7=xSs7eTw760GonBO7ABzULEP+Ps6hNBON_vhUj5A@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Trigger problems/questions  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general


On Thu, Jun 15, 2017 at 1:44 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 06/15/2017 10:23 AM, Jim Fulton wrote:

...
 
I do not pretend to fully understand what the the triggers/functions are really doing,
but I did notice this:

create or replace function populate_community_zoid_triggerf()

...

new_zoid := NEW.state ->> 'community_zoid';
zoid := find_community_zoid(
            NEW.zoid, NEW.class_name, NEW.state)::text;
if zoid is null then
    if new_zoid is not null then
    NEW.state := NEW.state - 'community_zoid';
    end if;
else
    if new_zoid is null or zoid != new_zoid then
    NEW.state :=
        NEW.state || ('{"community_zoid": ' || zoid || '}')::jsonb;
    end if;
end if;

...


Not sure what happens if zoid is null and new_zoid is null also?

Then then no change is needed and nothing happens, which is correct.
 
Or if it matters?

Nope.

Thanks for looking.

Jim

--

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] Trigger problems/questions
Next
From: Jim Fulton
Date:
Subject: Re: [GENERAL] Trigger problems/questions