Re: some ri_triggers.c cleanup

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: some ri_triggers.c cleanup
Date: 2019-02-23 23:34:32
Message-ID: CADkLM=fwEQ+PL9iV3cGoPrUbFkyF0ArhRVoBeOsJ6fXmKt0qSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 22, 2019 at 1:12 PM Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
wrote:

> On Fri, Feb 22, 2019 at 11:05 AM Peter Eisentraut <
> peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
>
>> ri_triggers.c is endlessly long and repetitive. I want to clean it up a
>> bit (more).
>>
>
> Having just been down this road, I agree that a lot of cleanup is needed
> and possible.
>
>
>> I looked into all these switch cases for the unimplemented MATCH PARTIAL
>> option. I toyed around with how a MATCH PARTIAL implementation would
>> actually look like, and it likely wouldn't use the existing code
>> structure anyway, so let's just simplify this for now.
>>
>
> +1
>
>
>
>> Attached are some patches.
>
>
> I intend to look this over in much greater detail, but I did skim the code
> and it seems like you left the SET DEFAULT and SET NULL paths separate. In
> my attempt at statement level triggers I realized that they only differed
> by the one literal value, and parameterized the function.
>
>

I've looked it over more closely now and I think that it's a nice
improvement.

As I suspected, the code for SET NULL and SET DEFAULT are highly similar
(see .diff), the major difference being two constants, the order of some
variable declarations, and the recheck in the set-default case.

The changes were so simple that I felt remiss not adding the patch for you
(see .patch).

Passes make check.

Attachment Content-Type Size
setnull_vs_setdefault.diff text/x-patch 3.6 KB
0004-Combine-ri_setdefault-and-ri_setnull.patch text/x-patch 8.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Corey Huinker 2019-02-24 00:14:27 Re: \describe*
Previous Message Michael Paquier 2019-02-23 23:13:34 Re: Autovaccuum vs temp tables crash