Re: Trigger problems/questions

From: Jim Fulton <jim(at)jimfulton(dot)info>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Jim Fulton <jim(at)jimfulton(dot)info>, pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger problems/questions
Date: 2017-06-15 17:56:52
Message-ID: CAPDm-FgNP7=xSs7eTw760GonBO7ABzULEP+Ps6hNBON_vhUj5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jun 15, 2017 at 1:44 PM, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)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

--
Jim Fulton
http://jimfulton.info

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim Fulton 2017-06-15 18:39:38 Re: Trigger problems/questions
Previous Message Tom Lane 2017-06-15 17:56:43 Re: Trigger problems/questions